< 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;

2252             public <T> void setCarrierThreadLocal(CarrierThreadLocal<T> local, T value) {
2253                 ((ThreadLocal<T>)local).setCarrierThreadLocal(value);
2254             }
2255 
2256             public void removeCarrierThreadLocal(CarrierThreadLocal<?> local) {
2257                 ((ThreadLocal<?>)local).removeCarrierThreadLocal();
2258             }
2259 
2260             public Object[] scopedValueCache() {
2261                 return Thread.scopedValueCache();
2262             }
2263 
2264             public void setScopedValueCache(Object[] cache) {
2265                 Thread.setScopedValueCache(cache);
2266             }
2267 
2268             public Object scopedValueBindings() {
2269                 return Thread.scopedValueBindings();
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 WrongThreadException();
2307                 }
2308             }
2309 
2310             public Executor virtualThreadDefaultScheduler() {
2311                 return VirtualThread.defaultScheduler();
2312             }
2313 




















2314             public StackWalker newStackWalkerInstance(Set<StackWalker.Option> options,
2315                                                       ContinuationScope contScope,
2316                                                       Continuation continuation) {
2317                 return StackWalker.newInstance(options, null, contScope, continuation);
2318             }
2319 
2320             public String getLoaderNameID(ClassLoader loader) {
2321                 return loader != null ? loader.nameAndId() : "null";
2322             }
2323 
2324             @Override
2325             public void copyToSegmentRaw(String string, MemorySegment segment, long offset) {
2326                 string.copyToSegmentRaw(segment, offset);
2327             }
2328 
2329             @Override
2330             public boolean bytesCompatible(String string, Charset charset) {
2331                 return string.bytesCompatible(charset);
2332             }
2333         });

  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;

2251             public <T> void setCarrierThreadLocal(CarrierThreadLocal<T> local, T value) {
2252                 ((ThreadLocal<T>)local).setCarrierThreadLocal(value);
2253             }
2254 
2255             public void removeCarrierThreadLocal(CarrierThreadLocal<?> local) {
2256                 ((ThreadLocal<?>)local).removeCarrierThreadLocal();
2257             }
2258 
2259             public Object[] scopedValueCache() {
2260                 return Thread.scopedValueCache();
2261             }
2262 
2263             public void setScopedValueCache(Object[] cache) {
2264                 Thread.setScopedValueCache(cache);
2265             }
2266 
2267             public Object scopedValueBindings() {
2268                 return Thread.scopedValueBindings();
2269             }
2270 
2271             public long nativeThreadID(Thread thread) {
2272                 return thread.nativeThreadID();
2273             }
2274 
2275             public void setThreadNativeID(long id) {
2276                 Thread.currentThread().setNativeThreadID(id);
2277             }
2278 
2279             public Continuation getContinuation(Thread thread) {
2280                 return thread.getContinuation();
2281             }
2282 
2283             public void setContinuation(Thread thread, Continuation continuation) {
2284                 thread.setContinuation(continuation);
2285             }
2286 
2287             public ContinuationScope virtualThreadContinuationScope() {
2288                 return VirtualThread.continuationScope();
2289             }
2290 
2291             public void parkVirtualThread() {
2292                 Thread thread = Thread.currentThread();
2293                 if (thread instanceof BaseVirtualThread vthread) {
2294                     vthread.park();
2295                 } else {
2296                     throw new WrongThreadException();
2297                 }
2298             }
2299 
2300             public void parkVirtualThread(long nanos) {
2301                 Thread thread = Thread.currentThread();
2302                 if (thread instanceof BaseVirtualThread vthread) {
2303                     vthread.parkNanos(nanos);
2304                 } else {
2305                     throw new WrongThreadException();
2306                 }
2307             }
2308 
2309             public void unparkVirtualThread(Thread thread) {
2310                 if (thread instanceof BaseVirtualThread vthread) {
2311                     vthread.unpark();
2312                 } else {
2313                     throw new IllegalArgumentException();
2314                 }
2315             }
2316 
2317             public Thread.VirtualThreadScheduler defaultVirtualThreadScheduler() {
2318                 return VirtualThread.defaultScheduler();
2319             }
2320 
2321             public boolean isCustomDefaultVirtualThreadScheduler() {
2322                 return VirtualThread.isCustomDefaultScheduler();
2323             }
2324 
2325             public Thread.VirtualThreadScheduler virtualThreadScheduler(Thread thread) {
2326                 if (thread instanceof VirtualThread vthread) {
2327                     return vthread.scheduler(true);
2328                 } else {
2329                     throw new IllegalArgumentException();
2330                 }
2331             }
2332 
2333             public <T> T supplyIfUnmounted(Thread thread, Supplier<T> supplyIfAlive, Supplier<T> supplyIfNotAlive) {
2334                 if (thread instanceof VirtualThread vthread) {
2335                     return vthread.supplyIfUnmounted(supplyIfAlive, supplyIfNotAlive);
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 >