< prev index next >

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

Print this page

  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package java.lang;
  26 
  27 import java.io.BufferedInputStream;
  28 import java.io.BufferedOutputStream;
  29 import java.io.Console;
  30 import java.io.FileDescriptor;
  31 import java.io.FileInputStream;
  32 import java.io.FileOutputStream;
  33 import java.io.IOException;
  34 import java.io.InputStream;
  35 import java.io.OutputStream;
  36 import java.io.PrintStream;
  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;

 471      * @throws     IndexOutOfBoundsException  if copying would cause
 472      *             access of data outside array bounds.
 473      * @throws     ArrayStoreException  if an element in the {@code src}
 474      *             array could not be stored into the {@code dest} array
 475      *             because of a type mismatch.
 476      * @throws     NullPointerException if either {@code src} or
 477      *             {@code dest} is {@code null}.
 478      */
 479     @IntrinsicCandidate
 480     public static native void arraycopy(Object src,  int  srcPos,
 481                                         Object dest, int destPos,
 482                                         int length);
 483 
 484     /**
 485      * Returns the same hash code for the given object as
 486      * would be returned by the default method hashCode(),
 487      * whether or not the given object's class overrides
 488      * hashCode().
 489      * The hash code for the null reference is zero.
 490      *















 491      * @param x object for which the hashCode is to be calculated
 492      * @return  the hashCode
 493      * @since   1.1
 494      * @see Object#hashCode
 495      * @see java.util.Objects#hashCode(Object)
 496      */
 497     @IntrinsicCandidate
 498     public static native int identityHashCode(Object x);
 499 
 500     /**
 501      * System properties.
 502      *
 503      * See {@linkplain #getProperties getProperties} for details.
 504      */
 505     private static Properties props;
 506 
 507     /**
 508      * Determines the current system properties.
 509      * <p>
 510      * The current set of system properties for use by the

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 }

  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package java.lang;
  26 
  27 import java.io.BufferedInputStream;
  28 import java.io.BufferedOutputStream;
  29 import java.io.Console;
  30 import java.io.FileDescriptor;
  31 import java.io.FileInputStream;
  32 import java.io.FileOutputStream;
  33 import java.io.IOException;
  34 import java.io.InputStream;
  35 import java.io.OutputStream;
  36 import java.io.PrintStream;
  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.ClassFileFormatVersion;
  43 import java.lang.reflect.Executable;
  44 import java.lang.reflect.Method;
  45 import java.net.URI;
  46 import java.nio.channels.Channel;
  47 import java.nio.channels.spi.SelectorProvider;
  48 import java.nio.charset.CharacterCodingException;
  49 import java.nio.charset.Charset;
  50 import java.security.ProtectionDomain;
  51 import java.util.List;
  52 import java.util.Locale;
  53 import java.util.Map;
  54 import java.util.Objects;
  55 import java.util.Properties;
  56 import java.util.ResourceBundle;
  57 import java.util.Set;
  58 import java.util.concurrent.Executor;
  59 import java.util.concurrent.ScheduledExecutorService;
  60 import java.util.function.Supplier;
  61 import java.util.concurrent.ConcurrentHashMap;
  62 import java.util.stream.Stream;

 472      * @throws     IndexOutOfBoundsException  if copying would cause
 473      *             access of data outside array bounds.
 474      * @throws     ArrayStoreException  if an element in the {@code src}
 475      *             array could not be stored into the {@code dest} array
 476      *             because of a type mismatch.
 477      * @throws     NullPointerException if either {@code src} or
 478      *             {@code dest} is {@code null}.
 479      */
 480     @IntrinsicCandidate
 481     public static native void arraycopy(Object src,  int  srcPos,
 482                                         Object dest, int destPos,
 483                                         int length);
 484 
 485     /**
 486      * Returns the same hash code for the given object as
 487      * would be returned by the default method hashCode(),
 488      * whether or not the given object's class overrides
 489      * hashCode().
 490      * The hash code for the null reference is zero.
 491      *
 492      * <div class="preview-block">
 493      *      <div class="preview-comment">
 494      *          The "identity hash code" of a {@linkplain Class#isValue() value object}
 495      *          is computed by combining the identity hash codes of the value object's fields recursively.
 496      *      </div>
 497      * </div>
 498      * @apiNote
 499      * <div class="preview-block">
 500      *      <div class="preview-comment">
 501      *          Note that, like ==, this hash code exposes information about a value object's
 502      *          private fields that might otherwise be hidden by an identity object.
 503      *          Developers should be cautious about storing sensitive secrets in value object fields.
 504      *      </div>
 505      * </div>
 506      *
 507      * @param x object for which the hashCode is to be calculated
 508      * @return  the hashCode
 509      * @since   1.1
 510      * @see Object#hashCode
 511      * @see java.util.Objects#hashCode(Object)
 512      */
 513     @IntrinsicCandidate
 514     public static native int identityHashCode(Object x);
 515 
 516     /**
 517      * System properties.
 518      *
 519      * See {@linkplain #getProperties getProperties} for details.
 520      */
 521     private static Properties props;
 522 
 523     /**
 524      * Determines the current system properties.
 525      * <p>
 526      * The current set of system properties for use by the

2325             }
2326 
2327             public void unparkVirtualThread(Thread thread) {
2328                 if (thread instanceof BaseVirtualThread vthread) {
2329                     vthread.unpark();
2330                 } else {
2331                     throw new WrongThreadException();
2332                 }
2333             }
2334 
2335             public Executor virtualThreadDefaultScheduler() {
2336                 return VirtualThread.defaultScheduler();
2337             }
2338 
2339             public StackWalker newStackWalkerInstance(Set<StackWalker.Option> options,
2340                                                       ContinuationScope contScope,
2341                                                       Continuation continuation) {
2342                 return StackWalker.newInstance(options, null, contScope, continuation);
2343             }
2344 
2345             public int classFileFormatVersion(Class<?> clazz) {
2346                 return clazz.getClassFileVersion();
2347             }
2348 
2349             public String getLoaderNameID(ClassLoader loader) {
2350                 return loader != null ? loader.nameAndId() : "null";
2351             }
2352 
2353             @Override
2354             public void copyToSegmentRaw(String string, MemorySegment segment, long offset, int srcIndex, int srcLength) {
2355                 string.copyToSegmentRaw(segment, offset, srcIndex, srcLength);
2356             }
2357 
2358             @Override
2359             public boolean bytesCompatible(String string, Charset charset, int srcIndex, int numChars) {
2360                 return string.bytesCompatible(charset, srcIndex, numChars);
2361             }
2362         });
2363     }
2364 }
< prev index next >