< prev index next >

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

Print this page




  39 import java.lang.reflect.Constructor;
  40 import java.lang.reflect.Executable;
  41 import java.lang.reflect.Method;
  42 import java.lang.reflect.Modifier;
  43 import java.net.URI;
  44 import java.nio.charset.CharacterCodingException;
  45 import java.security.AccessControlContext;
  46 import java.security.ProtectionDomain;
  47 import java.security.AccessController;
  48 import java.security.PrivilegedAction;
  49 import java.nio.channels.Channel;
  50 import java.nio.channels.spi.SelectorProvider;
  51 import java.nio.charset.Charset;
  52 import java.util.Iterator;
  53 import java.util.List;
  54 import java.util.Map;
  55 import java.util.Objects;
  56 import java.util.Properties;
  57 import java.util.PropertyPermission;
  58 import java.util.ResourceBundle;

  59 import java.util.function.Supplier;
  60 import java.util.concurrent.ConcurrentHashMap;
  61 import java.util.stream.Stream;
  62 
  63 import jdk.internal.util.StaticProperty;
  64 import jdk.internal.module.ModuleBootstrap;
  65 import jdk.internal.module.ServicesCatalog;
  66 import jdk.internal.reflect.CallerSensitive;
  67 import jdk.internal.reflect.Reflection;
  68 import jdk.internal.HotSpotIntrinsicCandidate;
  69 import jdk.internal.access.JavaLangAccess;
  70 import jdk.internal.access.SharedSecrets;
  71 import jdk.internal.misc.VM;
  72 import jdk.internal.logger.LoggerFinderLoader;
  73 import jdk.internal.logger.LazyLoggers;
  74 import jdk.internal.logger.LocalizedLoggerWrapper;
  75 import jdk.internal.util.SystemProps;
  76 import jdk.internal.vm.annotation.Stable;
  77 import sun.reflect.annotation.AnnotationType;
  78 import sun.nio.ch.Interruptible;


2261 
2262             public byte[] getBytesNoRepl(String s, Charset cs) throws CharacterCodingException {
2263                 return StringCoding.getBytesNoRepl(s, cs);
2264             }
2265 
2266             public String newStringUTF8NoRepl(byte[] bytes, int off, int len) {
2267                 return StringCoding.newStringUTF8NoRepl(bytes, off, len);
2268             }
2269 
2270             public byte[] getBytesUTF8NoRepl(String s) {
2271                 return StringCoding.getBytesUTF8NoRepl(s);
2272             }
2273 
2274             public void setCause(Throwable t, Throwable cause) {
2275                 t.setCause(cause);
2276             }
2277 
2278             public void loadLibrary(Class<?> caller, String library) {
2279                 assert library.indexOf(java.io.File.separatorChar) < 0;
2280                 ClassLoader.loadLibrary(caller, library, false);































































2281             }
2282         });
2283     }
2284 }


  39 import java.lang.reflect.Constructor;
  40 import java.lang.reflect.Executable;
  41 import java.lang.reflect.Method;
  42 import java.lang.reflect.Modifier;
  43 import java.net.URI;
  44 import java.nio.charset.CharacterCodingException;
  45 import java.security.AccessControlContext;
  46 import java.security.ProtectionDomain;
  47 import java.security.AccessController;
  48 import java.security.PrivilegedAction;
  49 import java.nio.channels.Channel;
  50 import java.nio.channels.spi.SelectorProvider;
  51 import java.nio.charset.Charset;
  52 import java.util.Iterator;
  53 import java.util.List;
  54 import java.util.Map;
  55 import java.util.Objects;
  56 import java.util.Properties;
  57 import java.util.PropertyPermission;
  58 import java.util.ResourceBundle;
  59 import java.util.concurrent.Callable;
  60 import java.util.function.Supplier;
  61 import java.util.concurrent.ConcurrentHashMap;
  62 import java.util.stream.Stream;
  63 
  64 import jdk.internal.util.StaticProperty;
  65 import jdk.internal.module.ModuleBootstrap;
  66 import jdk.internal.module.ServicesCatalog;
  67 import jdk.internal.reflect.CallerSensitive;
  68 import jdk.internal.reflect.Reflection;
  69 import jdk.internal.HotSpotIntrinsicCandidate;
  70 import jdk.internal.access.JavaLangAccess;
  71 import jdk.internal.access.SharedSecrets;
  72 import jdk.internal.misc.VM;
  73 import jdk.internal.logger.LoggerFinderLoader;
  74 import jdk.internal.logger.LazyLoggers;
  75 import jdk.internal.logger.LocalizedLoggerWrapper;
  76 import jdk.internal.util.SystemProps;
  77 import jdk.internal.vm.annotation.Stable;
  78 import sun.reflect.annotation.AnnotationType;
  79 import sun.nio.ch.Interruptible;


2262 
2263             public byte[] getBytesNoRepl(String s, Charset cs) throws CharacterCodingException {
2264                 return StringCoding.getBytesNoRepl(s, cs);
2265             }
2266 
2267             public String newStringUTF8NoRepl(byte[] bytes, int off, int len) {
2268                 return StringCoding.newStringUTF8NoRepl(bytes, off, len);
2269             }
2270 
2271             public byte[] getBytesUTF8NoRepl(String s) {
2272                 return StringCoding.getBytesUTF8NoRepl(s);
2273             }
2274 
2275             public void setCause(Throwable t, Throwable cause) {
2276                 t.setCause(cause);
2277             }
2278 
2279             public void loadLibrary(Class<?> caller, String library) {
2280                 assert library.indexOf(java.io.File.separatorChar) < 0;
2281                 ClassLoader.loadLibrary(caller, library, false);
2282             }
2283 
2284             public Thread currentCarrierThread() {
2285                 return Thread.currentCarrierThread();
2286             }
2287             public <R> R executeOnCarrierThread(Callable<R> task) throws Exception {
2288                 Thread t = Thread.currentCarrierThread();
2289                 Fiber<?> f = t.getFiber();
2290                 if (f != null) t.setFiber(null);
2291                 try {
2292                     return task.call();
2293                 } finally {
2294                     if (f != null) t.setFiber(f);
2295                 }
2296             }
2297             public <T> T getCarrierThreadLocal(ThreadLocal<T> local) {
2298                 return local.getCarrierThreadLocal();
2299             }
2300             public Fiber<?> getFiber(Thread t) {
2301                 if (t instanceof ShadowThread) {
2302                     return ((ShadowThread) t).fiber();
2303                 } else {
2304                     return null;
2305                 }
2306             }
2307             public Thread getShadowThread(Fiber<?> f) {
2308                 return f.shadowThreadOrNull();
2309             }
2310             public Object currentStrand() {
2311                 Thread thread = Thread.currentCarrierThread();
2312                 Fiber<?> fiber = thread.getFiber();
2313                 return (fiber != null) ? fiber : thread;
2314             }
2315             public void interrupt(Object strand) {
2316                 if (strand instanceof Fiber) {
2317                     ((Fiber) strand).interrupt();
2318                 } else {
2319                     ((Thread) strand).interrupt();
2320                 }
2321             }
2322             public boolean isInterrupted() {
2323                 Object strand = currentStrand();
2324                 if (strand instanceof Fiber) {
2325                     return ((Fiber) strand).isInterrupted();
2326                 } else {
2327                     return ((Thread) strand).isInterrupted();
2328                 }
2329             }
2330             public boolean clearInterrupt() {
2331                 if (currentStrand() instanceof Fiber) {
2332                     return Fiber.clearInterrupt();
2333                 } else {
2334                     return Thread.interrupted();
2335                 }
2336             }
2337             public void parkFiber() {
2338                 Fiber.park();
2339             }
2340             public void parkFiber(long nanos) {
2341                 Fiber.parkNanos(nanos);
2342             }
2343             public void unparkFiber(Fiber<?> fiber) {
2344                 fiber.unpark();
2345             }
2346         });
2347     }
2348 }
< prev index next >