< prev index next >

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

Print this page

  66 import jdk.internal.misc.Blocker;
  67 import jdk.internal.misc.CarrierThreadLocal;
  68 import jdk.internal.util.StaticProperty;
  69 import jdk.internal.module.ModuleBootstrap;
  70 import jdk.internal.module.ServicesCatalog;
  71 import jdk.internal.reflect.CallerSensitive;
  72 import jdk.internal.reflect.Reflection;
  73 import jdk.internal.access.JavaLangAccess;
  74 import jdk.internal.access.SharedSecrets;
  75 import jdk.internal.logger.LoggerFinderLoader;
  76 import jdk.internal.logger.LazyLoggers;
  77 import jdk.internal.logger.LocalizedLoggerWrapper;
  78 import jdk.internal.misc.VM;
  79 import jdk.internal.util.SystemProps;
  80 import jdk.internal.vm.Continuation;
  81 import jdk.internal.vm.ContinuationScope;
  82 import jdk.internal.vm.StackableScope;
  83 import jdk.internal.vm.ThreadContainer;
  84 import jdk.internal.vm.annotation.IntrinsicCandidate;
  85 import jdk.internal.vm.annotation.Stable;

  86 import sun.reflect.annotation.AnnotationType;
  87 import sun.nio.ch.Interruptible;
  88 import sun.nio.cs.UTF_8;
  89 
  90 /**
  91  * The {@code System} class contains several useful class fields
  92  * and methods. It cannot be instantiated.
  93  *
  94  * Among the facilities provided by the {@code System} class
  95  * are standard input, standard output, and error output streams;
  96  * access to externally defined properties and environment
  97  * variables; a means of loading files and libraries; and a utility
  98  * method for quickly copying a portion of an array.
  99  *
 100  * @since   1.0
 101  */
 102 public final class System {
 103     /* Register the natives via the static initializer.
 104      *
 105      * The VM will invoke the initPhase1 method to complete the initialization

2249             public <T> void setCarrierThreadLocal(CarrierThreadLocal<T> local, T value) {
2250                 ((ThreadLocal<T>)local).setCarrierThreadLocal(value);
2251             }
2252 
2253             public void removeCarrierThreadLocal(CarrierThreadLocal<?> local) {
2254                 ((ThreadLocal<?>)local).removeCarrierThreadLocal();
2255             }
2256 
2257             public Object[] scopedValueCache() {
2258                 return Thread.scopedValueCache();
2259             }
2260 
2261             public void setScopedValueCache(Object[] cache) {
2262                 Thread.setScopedValueCache(cache);
2263             }
2264 
2265             public Object scopedValueBindings() {
2266                 return Thread.scopedValueBindings();
2267             }
2268 








2269             public Continuation getContinuation(Thread thread) {
2270                 return thread.getContinuation();
2271             }
2272 
2273             public void setContinuation(Thread thread, Continuation continuation) {
2274                 thread.setContinuation(continuation);
2275             }
2276 
2277             public ContinuationScope virtualThreadContinuationScope() {
2278                 return VirtualThread.continuationScope();
2279             }
2280 
2281             public void parkVirtualThread() {
2282                 Thread thread = Thread.currentThread();
2283                 if (thread instanceof BaseVirtualThread vthread) {
2284                     vthread.park();
2285                 } else {
2286                     throw new WrongThreadException();
2287                 }
2288             }
2289 
2290             public void parkVirtualThread(long nanos) {
2291                 Thread thread = Thread.currentThread();
2292                 if (thread instanceof BaseVirtualThread vthread) {
2293                     vthread.parkNanos(nanos);
2294                 } else {
2295                     throw new WrongThreadException();
2296                 }
2297             }
2298 
2299             public void unparkVirtualThread(Thread thread) {
2300                 if (thread instanceof BaseVirtualThread vthread) {
2301                     vthread.unpark();
2302                 } else {
2303                     throw new WrongThreadException();
2304                 }
2305             }
2306 
2307             public Executor virtualThreadDefaultScheduler() {
2308                 return VirtualThread.defaultScheduler();
2309             }
2310 








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

  66 import jdk.internal.misc.Blocker;
  67 import jdk.internal.misc.CarrierThreadLocal;
  68 import jdk.internal.util.StaticProperty;
  69 import jdk.internal.module.ModuleBootstrap;
  70 import jdk.internal.module.ServicesCatalog;
  71 import jdk.internal.reflect.CallerSensitive;
  72 import jdk.internal.reflect.Reflection;
  73 import jdk.internal.access.JavaLangAccess;
  74 import jdk.internal.access.SharedSecrets;
  75 import jdk.internal.logger.LoggerFinderLoader;
  76 import jdk.internal.logger.LazyLoggers;
  77 import jdk.internal.logger.LocalizedLoggerWrapper;
  78 import jdk.internal.misc.VM;
  79 import jdk.internal.util.SystemProps;
  80 import jdk.internal.vm.Continuation;
  81 import jdk.internal.vm.ContinuationScope;
  82 import jdk.internal.vm.StackableScope;
  83 import jdk.internal.vm.ThreadContainer;
  84 import jdk.internal.vm.annotation.IntrinsicCandidate;
  85 import jdk.internal.vm.annotation.Stable;
  86 import sun.nio.ch.NativeThread;
  87 import sun.reflect.annotation.AnnotationType;
  88 import sun.nio.ch.Interruptible;
  89 import sun.nio.cs.UTF_8;
  90 
  91 /**
  92  * The {@code System} class contains several useful class fields
  93  * and methods. It cannot be instantiated.
  94  *
  95  * Among the facilities provided by the {@code System} class
  96  * are standard input, standard output, and error output streams;
  97  * access to externally defined properties and environment
  98  * variables; a means of loading files and libraries; and a utility
  99  * method for quickly copying a portion of an array.
 100  *
 101  * @since   1.0
 102  */
 103 public final class System {
 104     /* Register the natives via the static initializer.
 105      *
 106      * The VM will invoke the initPhase1 method to complete the initialization

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