3131import java .util .Map ;
3232import java .util .Objects ;
3333
34- import com .oracle .svm .core .jdk .JDKUtils ;
35- import jdk .graal .compiler .serviceprovider .JavaVersionUtil ;
3634import org .graalvm .nativeimage .IsolateThread ;
3735import org .graalvm .nativeimage .Platforms ;
3836import org .graalvm .nativeimage .impl .InternalPlatform ;
5452
5553import jdk .graal .compiler .api .directives .GraalDirectives ;
5654import jdk .graal .compiler .replacements .ReplacementsUtil ;
55+ import jdk .graal .compiler .serviceprovider .JavaVersionUtil ;
5756
5857@ TargetClass (Thread .class )
5958@ SuppressWarnings ({"unused" })
@@ -117,7 +116,7 @@ public final class Target_java_lang_Thread {
117116 */
118117 @ Alias //
119118 @ RecomputeFieldValue (kind = RecomputeFieldValue .Kind .Reset ) //
120- @ TargetElement (onlyWith = JDK21OrEarlier .class )
119+ @ TargetElement (onlyWith = JDK21OrEarlier .class ) //
121120 public AccessControlContext inheritedAccessControlContext ;
122121
123122 @ Alias //
@@ -218,6 +217,7 @@ void setCurrentThread(Thread thread) {
218217 @ Substitute
219218 @ SuppressWarnings ({"unused" })
220219 @ Platforms (InternalPlatform .NATIVE_ONLY .class )
220+ @ TargetElement (onlyWith = JDK21OrEarlier .class )
221221 private Target_java_lang_Thread (
222222 ThreadGroup g ,
223223 String name ,
@@ -237,6 +237,27 @@ private Target_java_lang_Thread(
237237 this .scopedValueBindings = NEW_THREAD_BINDINGS ;
238238 }
239239
240+ @ Substitute
241+ @ Platforms (InternalPlatform .NATIVE_ONLY .class )
242+ @ TargetElement (onlyWith = JDKLatest .class )
243+ private Target_java_lang_Thread (
244+ ThreadGroup g ,
245+ String name ,
246+ int characteristics ,
247+ Runnable target ,
248+ long stackSize ) {
249+ /* Non-0 instance field initialization. */
250+ this .interruptLock = new Object ();
251+ /* Injected Target_java_lang_Thread instance field initialization. */
252+ this .threadData = new ThreadData ();
253+
254+ String nameLocal = (name != null ) ? name : genThreadName ();
255+ boolean inheritThreadLocals = (characteristics & NO_INHERIT_THREAD_LOCALS ) == 0 ;
256+ JavaThreads .initializeNewThread (this , g , target , nameLocal , stackSize , null , inheritThreadLocals );
257+
258+ this .scopedValueBindings = NEW_THREAD_BINDINGS ;
259+ }
260+
240261 @ Substitute
241262 static String genThreadName () {
242263 int threadNum = JavaThreads .JavaThreadNumberSingleton .singleton ().threadInitNumber .incrementAndGet ();
@@ -543,7 +564,7 @@ boolean isTerminated() {
543564final class Target_java_lang_Thread_Constants {
544565 // Checkstyle: stop
545566 @ SuppressWarnings ("removal" ) //
546- @ TargetElement (onlyWith = JDK21OrEarlier .class )
567+ @ TargetElement (onlyWith = JDK21OrEarlier .class ) //
547568 @ Alias static AccessControlContext NO_PERMISSIONS_ACC ;
548569
549570 @ Alias static ThreadGroup VTHREAD_GROUP ;
0 commit comments