31
31
import java .util .Map ;
32
32
import java .util .Objects ;
33
33
34
- import com .oracle .svm .core .jdk .JDKUtils ;
35
- import jdk .graal .compiler .serviceprovider .JavaVersionUtil ;
36
34
import org .graalvm .nativeimage .IsolateThread ;
37
35
import org .graalvm .nativeimage .Platforms ;
38
36
import org .graalvm .nativeimage .impl .InternalPlatform ;
54
52
55
53
import jdk .graal .compiler .api .directives .GraalDirectives ;
56
54
import jdk .graal .compiler .replacements .ReplacementsUtil ;
55
+ import jdk .graal .compiler .serviceprovider .JavaVersionUtil ;
57
56
58
57
@ TargetClass (Thread .class )
59
58
@ SuppressWarnings ({"unused" })
@@ -117,7 +116,7 @@ public final class Target_java_lang_Thread {
117
116
*/
118
117
@ Alias //
119
118
@ RecomputeFieldValue (kind = RecomputeFieldValue .Kind .Reset ) //
120
- @ TargetElement (onlyWith = JDK21OrEarlier .class )
119
+ @ TargetElement (onlyWith = JDK21OrEarlier .class ) //
121
120
public AccessControlContext inheritedAccessControlContext ;
122
121
123
122
@ Alias //
@@ -218,6 +217,7 @@ void setCurrentThread(Thread thread) {
218
217
@ Substitute
219
218
@ SuppressWarnings ({"unused" })
220
219
@ Platforms (InternalPlatform .NATIVE_ONLY .class )
220
+ @ TargetElement (onlyWith = JDK21OrEarlier .class )
221
221
private Target_java_lang_Thread (
222
222
ThreadGroup g ,
223
223
String name ,
@@ -237,6 +237,27 @@ private Target_java_lang_Thread(
237
237
this .scopedValueBindings = NEW_THREAD_BINDINGS ;
238
238
}
239
239
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
+
240
261
@ Substitute
241
262
static String genThreadName () {
242
263
int threadNum = JavaThreads .JavaThreadNumberSingleton .singleton ().threadInitNumber .incrementAndGet ();
@@ -543,7 +564,7 @@ boolean isTerminated() {
543
564
final class Target_java_lang_Thread_Constants {
544
565
// Checkstyle: stop
545
566
@ SuppressWarnings ("removal" ) //
546
- @ TargetElement (onlyWith = JDK21OrEarlier .class )
567
+ @ TargetElement (onlyWith = JDK21OrEarlier .class ) //
547
568
@ Alias static AccessControlContext NO_PERMISSIONS_ACC ;
548
569
549
570
@ Alias static ThreadGroup VTHREAD_GROUP ;
0 commit comments