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;
2245 public <T> void setCarrierThreadLocal(CarrierThreadLocal<T> local, T value) {
2246 ((ThreadLocal<T>)local).setCarrierThreadLocal(value);
2247 }
2248
2249 public void removeCarrierThreadLocal(CarrierThreadLocal<?> local) {
2250 ((ThreadLocal<?>)local).removeCarrierThreadLocal();
2251 }
2252
2253 public Object[] scopedValueCache() {
2254 return Thread.scopedValueCache();
2255 }
2256
2257 public void setScopedValueCache(Object[] cache) {
2258 Thread.setScopedValueCache(cache);
2259 }
2260
2261 public Object scopedValueBindings() {
2262 return Thread.scopedValueBindings();
2263 }
2264
2265 public Continuation getContinuation(Thread thread) {
2266 return thread.getContinuation();
2267 }
2268
2269 public void setContinuation(Thread thread, Continuation continuation) {
2270 thread.setContinuation(continuation);
2271 }
2272
2273 public ContinuationScope virtualThreadContinuationScope() {
2274 return VirtualThread.continuationScope();
2275 }
2276
2277 public void parkVirtualThread() {
2278 Thread thread = Thread.currentThread();
2279 if (thread instanceof BaseVirtualThread vthread) {
2280 vthread.park();
2281 } else {
2282 throw new WrongThreadException();
2283 }
2284 }
2285
2286 public void parkVirtualThread(long nanos) {
2287 Thread thread = Thread.currentThread();
2288 if (thread instanceof BaseVirtualThread vthread) {
2289 vthread.parkNanos(nanos);
2290 } else {
2291 throw new WrongThreadException();
2292 }
2293 }
2294
2295 public void unparkVirtualThread(Thread thread) {
2296 if (thread instanceof BaseVirtualThread vthread) {
2297 vthread.unpark();
2298 } else {
2299 throw new WrongThreadException();
2300 }
2301 }
2302
2303 public Executor virtualThreadDefaultScheduler() {
2304 return VirtualThread.defaultScheduler();
2305 }
2306
2307 public StackWalker newStackWalkerInstance(Set<StackWalker.Option> options,
2308 ContinuationScope contScope,
2309 Continuation continuation) {
2310 return StackWalker.newInstance(options, null, contScope, continuation);
2311 }
2312
2313 public String getLoaderNameID(ClassLoader loader) {
2314 return loader != null ? loader.nameAndId() : "null";
2315 }
2316
2317 @Override
2318 public void copyToSegmentRaw(String string, MemorySegment segment, long offset) {
2319 string.copyToSegmentRaw(segment, offset);
2320 }
2321
2322 @Override
2323 public boolean bytesCompatible(String string, Charset charset) {
2324 return string.bytesCompatible(charset);
2325 }
2326 });
|
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;
2244 public <T> void setCarrierThreadLocal(CarrierThreadLocal<T> local, T value) {
2245 ((ThreadLocal<T>)local).setCarrierThreadLocal(value);
2246 }
2247
2248 public void removeCarrierThreadLocal(CarrierThreadLocal<?> local) {
2249 ((ThreadLocal<?>)local).removeCarrierThreadLocal();
2250 }
2251
2252 public Object[] scopedValueCache() {
2253 return Thread.scopedValueCache();
2254 }
2255
2256 public void setScopedValueCache(Object[] cache) {
2257 Thread.setScopedValueCache(cache);
2258 }
2259
2260 public Object scopedValueBindings() {
2261 return Thread.scopedValueBindings();
2262 }
2263
2264 public long nativeThreadID(Thread thread) {
2265 return thread.nativeThreadID();
2266 }
2267
2268 public void setThreadNativeID(long id) {
2269 Thread.currentThread().setNativeThreadID(id);
2270 }
2271
2272 public Continuation getContinuation(Thread thread) {
2273 return thread.getContinuation();
2274 }
2275
2276 public void setContinuation(Thread thread, Continuation continuation) {
2277 thread.setContinuation(continuation);
2278 }
2279
2280 public ContinuationScope virtualThreadContinuationScope() {
2281 return VirtualThread.continuationScope();
2282 }
2283
2284 public void parkVirtualThread() {
2285 Thread thread = Thread.currentThread();
2286 if (thread instanceof BaseVirtualThread vthread) {
2287 vthread.park();
2288 } else {
2289 throw new WrongThreadException();
2290 }
2291 }
2292
2293 public void parkVirtualThread(long nanos) {
2294 Thread thread = Thread.currentThread();
2295 if (thread instanceof BaseVirtualThread vthread) {
2296 vthread.parkNanos(nanos);
2297 } else {
2298 throw new WrongThreadException();
2299 }
2300 }
2301
2302 public void unparkVirtualThread(Thread thread) {
2303 if (thread instanceof BaseVirtualThread vthread) {
2304 vthread.unpark();
2305 } else {
2306 throw new IllegalArgumentException();
2307 }
2308 }
2309
2310 public Thread.VirtualThreadScheduler defaultVirtualThreadScheduler() {
2311 return VirtualThread.defaultScheduler();
2312 }
2313
2314 public boolean isCustomDefaultVirtualThreadScheduler() {
2315 return VirtualThread.isCustomDefaultScheduler();
2316 }
2317
2318 public Thread.VirtualThreadScheduler virtualThreadScheduler(Thread thread) {
2319 if (thread instanceof VirtualThread vthread) {
2320 return vthread.scheduler(true);
2321 } else {
2322 throw new IllegalArgumentException();
2323 }
2324 }
2325
2326 public StackWalker newStackWalkerInstance(Set<StackWalker.Option> options,
2327 ContinuationScope contScope,
2328 Continuation continuation) {
2329 return StackWalker.newInstance(options, null, contScope, continuation);
2330 }
2331
2332 public String getLoaderNameID(ClassLoader loader) {
2333 return loader != null ? loader.nameAndId() : "null";
2334 }
2335
2336 @Override
2337 public void copyToSegmentRaw(String string, MemorySegment segment, long offset) {
2338 string.copyToSegmentRaw(segment, offset);
2339 }
2340
2341 @Override
2342 public boolean bytesCompatible(String string, Charset charset) {
2343 return string.bytesCompatible(charset);
2344 }
2345 });
|