37 import java.lang.annotation.Annotation;
38 import java.lang.foreign.MemorySegment;
39 import java.lang.invoke.MethodHandle;
40 import java.lang.invoke.MethodType;
41 import java.lang.module.ModuleDescriptor;
42 import java.lang.reflect.Executable;
43 import java.lang.reflect.Method;
44 import java.net.URI;
45 import java.nio.channels.Channel;
46 import java.nio.channels.spi.SelectorProvider;
47 import java.nio.charset.CharacterCodingException;
48 import java.nio.charset.Charset;
49 import java.security.ProtectionDomain;
50 import java.util.List;
51 import java.util.Locale;
52 import java.util.Map;
53 import java.util.Objects;
54 import java.util.Properties;
55 import java.util.ResourceBundle;
56 import java.util.Set;
57 import java.util.concurrent.Executor;
58 import java.util.function.Supplier;
59 import java.util.concurrent.ConcurrentHashMap;
60 import java.util.stream.Stream;
61
62 import jdk.internal.javac.Restricted;
63 import jdk.internal.loader.NativeLibraries;
64 import jdk.internal.logger.LoggerFinderLoader.TemporaryLoggerFinder;
65 import jdk.internal.misc.Blocker;
66 import jdk.internal.misc.CarrierThreadLocal;
67 import jdk.internal.util.StaticProperty;
68 import jdk.internal.module.ModuleBootstrap;
69 import jdk.internal.module.ServicesCatalog;
70 import jdk.internal.reflect.CallerSensitive;
71 import jdk.internal.reflect.Reflection;
72 import jdk.internal.access.JavaLangAccess;
73 import jdk.internal.access.SharedSecrets;
74 import jdk.internal.logger.LoggerFinderLoader;
75 import jdk.internal.logger.LazyLoggers;
76 import jdk.internal.logger.LocalizedLoggerWrapper;
77 import jdk.internal.misc.VM;
2257 public <T> void setCarrierThreadLocal(CarrierThreadLocal<T> local, T value) {
2258 ((ThreadLocal<T>)local).setCarrierThreadLocal(value);
2259 }
2260
2261 public void removeCarrierThreadLocal(CarrierThreadLocal<?> local) {
2262 ((ThreadLocal<?>)local).removeCarrierThreadLocal();
2263 }
2264
2265 public Object[] scopedValueCache() {
2266 return Thread.scopedValueCache();
2267 }
2268
2269 public void setScopedValueCache(Object[] cache) {
2270 Thread.setScopedValueCache(cache);
2271 }
2272
2273 public Object scopedValueBindings() {
2274 return Thread.scopedValueBindings();
2275 }
2276
2277 public Continuation getContinuation(Thread thread) {
2278 return thread.getContinuation();
2279 }
2280
2281 public void setContinuation(Thread thread, Continuation continuation) {
2282 thread.setContinuation(continuation);
2283 }
2284
2285 public ContinuationScope virtualThreadContinuationScope() {
2286 return VirtualThread.continuationScope();
2287 }
2288
2289 public void parkVirtualThread() {
2290 Thread thread = Thread.currentThread();
2291 if (thread instanceof BaseVirtualThread vthread) {
2292 vthread.park();
2293 } else {
2294 throw new WrongThreadException();
2295 }
2296 }
2297
2298 public void parkVirtualThread(long nanos) {
2299 Thread thread = Thread.currentThread();
2300 if (thread instanceof BaseVirtualThread vthread) {
2301 vthread.parkNanos(nanos);
2302 } else {
2303 throw new WrongThreadException();
2304 }
2305 }
2306
2307 public void unparkVirtualThread(Thread thread) {
2308 if (thread instanceof BaseVirtualThread vthread) {
2309 vthread.unpark();
2310 } else {
2311 throw new WrongThreadException();
2312 }
2313 }
2314
2315 public Executor virtualThreadDefaultScheduler() {
2316 return VirtualThread.defaultScheduler();
2317 }
2318
2319 public StackWalker newStackWalkerInstance(Set<StackWalker.Option> options,
2320 ContinuationScope contScope,
2321 Continuation continuation) {
2322 return StackWalker.newInstance(options, null, contScope, continuation);
2323 }
2324
2325 public String getLoaderNameID(ClassLoader loader) {
2326 return loader != null ? loader.nameAndId() : "null";
2327 }
2328
2329 @Override
2330 public void copyToSegmentRaw(String string, MemorySegment segment, long offset) {
2331 string.copyToSegmentRaw(segment, offset);
2332 }
2333
2334 @Override
2335 public boolean bytesCompatible(String string, Charset charset) {
2336 return string.bytesCompatible(charset);
2337 }
2338 });
|
37 import java.lang.annotation.Annotation;
38 import java.lang.foreign.MemorySegment;
39 import java.lang.invoke.MethodHandle;
40 import java.lang.invoke.MethodType;
41 import java.lang.module.ModuleDescriptor;
42 import java.lang.reflect.Executable;
43 import java.lang.reflect.Method;
44 import java.net.URI;
45 import java.nio.channels.Channel;
46 import java.nio.channels.spi.SelectorProvider;
47 import java.nio.charset.CharacterCodingException;
48 import java.nio.charset.Charset;
49 import java.security.ProtectionDomain;
50 import java.util.List;
51 import java.util.Locale;
52 import java.util.Map;
53 import java.util.Objects;
54 import java.util.Properties;
55 import java.util.ResourceBundle;
56 import java.util.Set;
57 import java.util.function.Supplier;
58 import java.util.concurrent.ConcurrentHashMap;
59 import java.util.stream.Stream;
60
61 import jdk.internal.javac.Restricted;
62 import jdk.internal.loader.NativeLibraries;
63 import jdk.internal.logger.LoggerFinderLoader.TemporaryLoggerFinder;
64 import jdk.internal.misc.Blocker;
65 import jdk.internal.misc.CarrierThreadLocal;
66 import jdk.internal.util.StaticProperty;
67 import jdk.internal.module.ModuleBootstrap;
68 import jdk.internal.module.ServicesCatalog;
69 import jdk.internal.reflect.CallerSensitive;
70 import jdk.internal.reflect.Reflection;
71 import jdk.internal.access.JavaLangAccess;
72 import jdk.internal.access.SharedSecrets;
73 import jdk.internal.logger.LoggerFinderLoader;
74 import jdk.internal.logger.LazyLoggers;
75 import jdk.internal.logger.LocalizedLoggerWrapper;
76 import jdk.internal.misc.VM;
2256 public <T> void setCarrierThreadLocal(CarrierThreadLocal<T> local, T value) {
2257 ((ThreadLocal<T>)local).setCarrierThreadLocal(value);
2258 }
2259
2260 public void removeCarrierThreadLocal(CarrierThreadLocal<?> local) {
2261 ((ThreadLocal<?>)local).removeCarrierThreadLocal();
2262 }
2263
2264 public Object[] scopedValueCache() {
2265 return Thread.scopedValueCache();
2266 }
2267
2268 public void setScopedValueCache(Object[] cache) {
2269 Thread.setScopedValueCache(cache);
2270 }
2271
2272 public Object scopedValueBindings() {
2273 return Thread.scopedValueBindings();
2274 }
2275
2276 public long nativeThreadID(Thread thread) {
2277 return thread.nativeThreadID();
2278 }
2279
2280 public void setThreadNativeID(long id) {
2281 Thread.currentThread().setNativeThreadID(id);
2282 }
2283
2284 public Continuation getContinuation(Thread thread) {
2285 return thread.getContinuation();
2286 }
2287
2288 public void setContinuation(Thread thread, Continuation continuation) {
2289 thread.setContinuation(continuation);
2290 }
2291
2292 public ContinuationScope virtualThreadContinuationScope() {
2293 return VirtualThread.continuationScope();
2294 }
2295
2296 public void parkVirtualThread() {
2297 Thread thread = Thread.currentThread();
2298 if (thread instanceof BaseVirtualThread vthread) {
2299 vthread.park();
2300 } else {
2301 throw new WrongThreadException();
2302 }
2303 }
2304
2305 public void parkVirtualThread(long nanos) {
2306 Thread thread = Thread.currentThread();
2307 if (thread instanceof BaseVirtualThread vthread) {
2308 vthread.parkNanos(nanos);
2309 } else {
2310 throw new WrongThreadException();
2311 }
2312 }
2313
2314 public void unparkVirtualThread(Thread thread) {
2315 if (thread instanceof BaseVirtualThread vthread) {
2316 vthread.unpark();
2317 } else {
2318 throw new IllegalArgumentException();
2319 }
2320 }
2321
2322 public Thread.VirtualThreadScheduler defaultVirtualThreadScheduler() {
2323 return VirtualThread.defaultScheduler();
2324 }
2325
2326 public boolean isCustomDefaultVirtualThreadScheduler() {
2327 return VirtualThread.isCustomDefaultScheduler();
2328 }
2329
2330 public Thread.VirtualThreadScheduler virtualThreadScheduler(Thread thread) {
2331 if (thread instanceof VirtualThread vthread) {
2332 return vthread.scheduler(true);
2333 } else {
2334 throw new IllegalArgumentException();
2335 }
2336 }
2337
2338 public StackWalker newStackWalkerInstance(Set<StackWalker.Option> options,
2339 ContinuationScope contScope,
2340 Continuation continuation) {
2341 return StackWalker.newInstance(options, null, contScope, continuation);
2342 }
2343
2344 public String getLoaderNameID(ClassLoader loader) {
2345 return loader != null ? loader.nameAndId() : "null";
2346 }
2347
2348 @Override
2349 public void copyToSegmentRaw(String string, MemorySegment segment, long offset) {
2350 string.copyToSegmentRaw(segment, offset);
2351 }
2352
2353 @Override
2354 public boolean bytesCompatible(String string, Charset charset) {
2355 return string.bytesCompatible(charset);
2356 }
2357 });
|