< prev index next >

src/java.base/share/classes/java/lang/System.java

Print this page

  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;

2260             public <T> void setCarrierThreadLocal(CarrierThreadLocal<T> local, T value) {
2261                 ((ThreadLocal<T>)local).setCarrierThreadLocal(value);
2262             }
2263 
2264             public void removeCarrierThreadLocal(CarrierThreadLocal<?> local) {
2265                 ((ThreadLocal<?>)local).removeCarrierThreadLocal();
2266             }
2267 
2268             public Object[] scopedValueCache() {
2269                 return Thread.scopedValueCache();
2270             }
2271 
2272             public void setScopedValueCache(Object[] cache) {
2273                 Thread.setScopedValueCache(cache);
2274             }
2275 
2276             public Object scopedValueBindings() {
2277                 return Thread.scopedValueBindings();
2278             }
2279 








2280             public Continuation getContinuation(Thread thread) {
2281                 return thread.getContinuation();
2282             }
2283 
2284             public void setContinuation(Thread thread, Continuation continuation) {
2285                 thread.setContinuation(continuation);
2286             }
2287 
2288             public ContinuationScope virtualThreadContinuationScope() {
2289                 return VirtualThread.continuationScope();
2290             }
2291 
2292             public void parkVirtualThread() {
2293                 Thread thread = Thread.currentThread();
2294                 if (thread instanceof BaseVirtualThread vthread) {
2295                     vthread.park();
2296                 } else {
2297                     throw new WrongThreadException();
2298                 }
2299             }
2300 
2301             public void parkVirtualThread(long nanos) {
2302                 Thread thread = Thread.currentThread();
2303                 if (thread instanceof BaseVirtualThread vthread) {
2304                     vthread.parkNanos(nanos);
2305                 } else {
2306                     throw new WrongThreadException();
2307                 }
2308             }
2309 
2310             public void unparkVirtualThread(Thread thread) {
2311                 if (thread instanceof BaseVirtualThread vthread) {
2312                     vthread.unpark();
2313                 } else {
2314                     throw new WrongThreadException();
2315                 }
2316             }
2317 
2318             public Executor virtualThreadDefaultScheduler() {
2319                 return VirtualThread.defaultScheduler();
2320             }
2321 












2322             public StackWalker newStackWalkerInstance(Set<StackWalker.Option> options,
2323                                                       ContinuationScope contScope,
2324                                                       Continuation continuation) {
2325                 return StackWalker.newInstance(options, null, contScope, continuation);
2326             }
2327 
2328             public String getLoaderNameID(ClassLoader loader) {
2329                 return loader != null ? loader.nameAndId() : "null";
2330             }
2331 
2332             @Override
2333             public void copyToSegmentRaw(String string, MemorySegment segment, long offset) {
2334                 string.copyToSegmentRaw(segment, offset);
2335             }
2336 
2337             @Override
2338             public boolean bytesCompatible(String string, Charset charset) {
2339                 return string.bytesCompatible(charset);
2340             }
2341         });

  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;

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