2929import java .util .Calendar ;
3030import java .util .Date ;
3131import java .util .HashMap ;
32+ import java .util .HashSet ;
3233import java .util .Hashtable ;
34+ import java .util .LinkedHashMap ;
35+ import java .util .LinkedHashSet ;
3336import java .util .Properties ;
37+ import java .util .Set ;
3438import java .util .UUID ;
39+ import java .util .concurrent .ConcurrentHashMap ;
40+ import java .util .concurrent .locks .AbstractOwnableSynchronizer ;
41+ import java .util .concurrent .locks .AbstractQueuedSynchronizer ;
42+ import java .util .concurrent .locks .ReentrantLock ;
3543import java .util .stream .Stream ;
3644
3745import org .springframework .aop .SpringProxy ;
4149import org .springframework .aot .hint .RuntimeHintsRegistrar ;
4250import org .springframework .aot .hint .SerializationHints ;
4351import org .springframework .aot .hint .TypeReference ;
52+ import org .springframework .batch .core .Entity ;
53+ import org .springframework .batch .core .ExitStatus ;
54+ import org .springframework .batch .core .JobExecution ;
55+ import org .springframework .batch .core .JobInstance ;
56+ import org .springframework .batch .core .JobParameter ;
57+ import org .springframework .batch .core .JobParameters ;
58+ import org .springframework .batch .core .StepContribution ;
59+ import org .springframework .batch .core .StepExecution ;
4460import org .springframework .batch .core .scope .context .JobContext ;
4561import org .springframework .batch .core .scope .context .StepContext ;
62+ import org .springframework .batch .item .Chunk ;
63+ import org .springframework .batch .item .ExecutionContext ;
4664import org .springframework .core .DecoratingProxy ;
4765
4866/**
@@ -58,6 +76,12 @@ public class CoreRuntimeHints implements RuntimeHintsRegistrar {
5876 @ Override
5977 public void registerHints (RuntimeHints hints , ClassLoader classLoader ) {
6078
79+ Set <String > jdkTypes = Set .of ("java.time.Ser" , "java.util.Collections$SynchronizedSet" ,
80+ "java.util.Collections$SynchronizedCollection" , "java.util.concurrent.locks.ReentrantLock$Sync" ,
81+ "java.util.concurrent.locks.ReentrantLock$FairSync" ,
82+ "java.util.concurrent.locks.ReentrantLock$NonfairSync" ,
83+ "java.util.concurrent.ConcurrentHashMap$Segment" );
84+
6185 // resource hints
6286 hints .resources ().registerPattern ("org/springframework/batch/core/schema-h2.sql" );
6387 hints .resources ().registerPattern ("org/springframework/batch/core/schema-derby.sql" );
@@ -88,14 +112,31 @@ public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
88112 hints .reflection ().registerType (Types .class , MemberCategory .DECLARED_FIELDS );
89113 hints .reflection ().registerType (JobContext .class , MemberCategory .INVOKE_PUBLIC_METHODS );
90114 hints .reflection ().registerType (StepContext .class , MemberCategory .INVOKE_PUBLIC_METHODS );
115+ hints .reflection ().registerType (JobParameter .class , MemberCategory .values ());
116+ hints .reflection ().registerType (JobParameters .class , MemberCategory .values ());
117+ hints .reflection ().registerType (ExitStatus .class , MemberCategory .values ());
118+ hints .reflection ().registerType (JobInstance .class , MemberCategory .values ());
119+ hints .reflection ().registerType (JobExecution .class , MemberCategory .values ());
120+ hints .reflection ().registerType (StepExecution .class , MemberCategory .values ());
121+ hints .reflection ().registerType (StepContribution .class , MemberCategory .values ());
122+ hints .reflection ().registerType (Entity .class , MemberCategory .values ());
123+ hints .reflection ().registerType (ExecutionContext .class , MemberCategory .values ());
124+ hints .reflection ().registerType (Chunk .class , MemberCategory .values ());
125+ jdkTypes .stream ().map (TypeReference ::of )
126+ .forEach (type -> hints .reflection ().registerType (type , MemberCategory .values ()));
91127
92128 // serialization hints
93129 SerializationHints serializationHints = hints .serialization ();
94- Stream .of (Number .class , Byte .class , Short .class , Integer .class , Long .class , Double .class , Float .class ,
95- Character .class , String .class , Boolean .class , Date .class , Calendar .class , LocalDate .class ,
96- LocalTime .class , LocalDateTime .class , OffsetTime .class , OffsetDateTime .class , ZonedDateTime .class ,
97- Instant .class , Duration .class , Period .class , HashMap .class , Hashtable .class , ArrayList .class ,
98- Properties .class , Exception .class , UUID .class ).forEach (serializationHints ::registerType );
130+ Stream .of (LinkedHashSet .class , LinkedHashMap .class , HashSet .class , ReentrantLock .class , ConcurrentHashMap .class ,
131+ AbstractOwnableSynchronizer .class , AbstractQueuedSynchronizer .class , Number .class , Byte .class ,
132+ Short .class , Integer .class , Long .class , Double .class , Float .class , Character .class , String .class ,
133+ Boolean .class , Date .class , Calendar .class , LocalDate .class , LocalTime .class , LocalDateTime .class ,
134+ OffsetTime .class , OffsetDateTime .class , ZonedDateTime .class , Instant .class , Duration .class ,
135+ Period .class , HashMap .class , Hashtable .class , ArrayList .class , JobParameter .class , JobParameters .class ,
136+ ExitStatus .class , JobInstance .class , JobExecution .class , StepExecution .class , StepContribution .class ,
137+ Entity .class , ExecutionContext .class , Chunk .class , Properties .class , Exception .class , UUID .class )
138+ .forEach (serializationHints ::registerType );
139+ jdkTypes .stream ().map (TypeReference ::of ).forEach (serializationHints ::registerType );
99140 }
100141
101142}
0 commit comments