< 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.concurrent.ScheduledExecutorService;
  59 import java.util.function.Supplier;
  60 import java.util.concurrent.ConcurrentHashMap;
  61 import java.util.stream.Stream;
  62 
  63 import jdk.internal.javac.Restricted;
  64 import jdk.internal.loader.NativeLibraries;
  65 import jdk.internal.logger.LoggerFinderLoader.TemporaryLoggerFinder;
  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;

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








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




2320                 return VirtualThread.defaultScheduler();
2321             }
2322 








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





2342         });
2343     }
2344 }

  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 builtinVirtualThreadScheduler() {
2326                 return VirtualThread.builtinScheduler(true);
2327             }
2328 
2329             public Thread.VirtualThreadScheduler defaultVirtualThreadScheduler() {
2330                 return VirtualThread.defaultScheduler();
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, int srcIndex, int srcLength) {
2353                 string.copyToSegmentRaw(segment, offset, srcIndex, srcLength);
2354             }
2355 
2356             @Override
2357             public boolean bytesCompatible(String string, Charset charset, int srcIndex, int numChars) {
2358                 return string.bytesCompatible(charset, srcIndex, numChars);
2359             }
2360 
2361             @Override
2362             public void finishInit(StackTraceElement[] stackTrace) {
2363                 StackTraceElement.finishInit(stackTrace);
2364             }
2365         });
2366     }
2367 }
< prev index next >