290 private static native void setErr0(PrintStream err); |
289 private static native void setErr0(PrintStream err); |
291 |
290 |
292 /** |
291 /** |
293 * Sets the System security. |
292 * Sets the System security. |
294 * |
293 * |
295 * <p> If there is a security manager already installed, this method first |
294 * If there is a security manager already installed, this method first |
296 * calls the security manager's <code>checkPermission</code> method |
295 * calls the security manager's {@code checkPermission} method |
297 * with a <code>RuntimePermission("setSecurityManager")</code> |
296 * with a {@code RuntimePermission("setSecurityManager")} |
298 * permission to ensure it's ok to replace the existing |
297 * permission to ensure it's ok to replace the existing |
299 * security manager. |
298 * security manager. |
300 * This may result in throwing a <code>SecurityException</code>. |
299 * This may result in throwing a {@code SecurityException}. |
301 * |
300 * |
302 * <p> Otherwise, the argument is established as the current |
301 * <p> Otherwise, the argument is established as the current |
303 * security manager. If the argument is <code>null</code> and no |
302 * security manager. If the argument is {@code null} and no |
304 * security manager has been established, then no action is taken and |
303 * security manager has been established, then no action is taken and |
305 * the method simply returns. |
304 * the method simply returns. |
306 * |
305 * |
307 * @param s the security manager. |
306 * @param s the security manager. |
308 * @exception SecurityException if the security manager has already |
307 * @throws SecurityException if the security manager has already |
309 * been set and its <code>checkPermission</code> method |
308 * been set and its {@code checkPermission} method |
310 * doesn't allow it to be replaced. |
309 * doesn't allow it to be replaced. |
311 * @see #getSecurityManager |
310 * @see #getSecurityManager |
312 * @see SecurityManager#checkPermission |
311 * @see SecurityManager#checkPermission |
313 * @see java.lang.RuntimePermission |
312 * @see java.lang.RuntimePermission |
314 */ |
313 */ |
435 |
434 |
436 /** |
435 /** |
437 * Copies an array from the specified source array, beginning at the |
436 * Copies an array from the specified source array, beginning at the |
438 * specified position, to the specified position of the destination array. |
437 * specified position, to the specified position of the destination array. |
439 * A subsequence of array components are copied from the source |
438 * A subsequence of array components are copied from the source |
440 * array referenced by <code>src</code> to the destination array |
439 * array referenced by {@code src} to the destination array |
441 * referenced by <code>dest</code>. The number of components copied is |
440 * referenced by {@code dest}. The number of components copied is |
442 * equal to the <code>length</code> argument. The components at |
441 * equal to the {@code length} argument. The components at |
443 * positions <code>srcPos</code> through |
442 * positions {@code srcPos} through |
444 * <code>srcPos+length-1</code> in the source array are copied into |
443 * {@code srcPos+length-1} in the source array are copied into |
445 * positions <code>destPos</code> through |
444 * positions {@code destPos} through |
446 * <code>destPos+length-1</code>, respectively, of the destination |
445 * {@code destPos+length-1}, respectively, of the destination |
447 * array. |
446 * array. |
448 * <p> |
447 * <p> |
449 * If the <code>src</code> and <code>dest</code> arguments refer to the |
448 * If the {@code src} and {@code dest} arguments refer to the |
450 * same array object, then the copying is performed as if the |
449 * same array object, then the copying is performed as if the |
451 * components at positions <code>srcPos</code> through |
450 * components at positions {@code srcPos} through |
452 * <code>srcPos+length-1</code> were first copied to a temporary |
451 * {@code srcPos+length-1} were first copied to a temporary |
453 * array with <code>length</code> components and then the contents of |
452 * array with {@code length} components and then the contents of |
454 * the temporary array were copied into positions |
453 * the temporary array were copied into positions |
455 * <code>destPos</code> through <code>destPos+length-1</code> of the |
454 * {@code destPos} through {@code destPos+length-1} of the |
456 * destination array. |
455 * destination array. |
457 * <p> |
456 * <p> |
458 * If <code>dest</code> is <code>null</code>, then a |
457 * If {@code dest} is {@code null}, then a |
459 * <code>NullPointerException</code> is thrown. |
458 * {@code NullPointerException} is thrown. |
460 * <p> |
459 * <p> |
461 * If <code>src</code> is <code>null</code>, then a |
460 * If {@code src} is {@code null}, then a |
462 * <code>NullPointerException</code> is thrown and the destination |
461 * {@code NullPointerException} is thrown and the destination |
463 * array is not modified. |
462 * array is not modified. |
464 * <p> |
463 * <p> |
465 * Otherwise, if any of the following is true, an |
464 * Otherwise, if any of the following is true, an |
466 * <code>ArrayStoreException</code> is thrown and the destination is |
465 * {@code ArrayStoreException} is thrown and the destination is |
467 * not modified: |
466 * not modified: |
468 * <ul> |
467 * <ul> |
469 * <li>The <code>src</code> argument refers to an object that is not an |
468 * <li>The {@code src} argument refers to an object that is not an |
470 * array. |
469 * array. |
471 * <li>The <code>dest</code> argument refers to an object that is not an |
470 * <li>The {@code dest} argument refers to an object that is not an |
472 * array. |
471 * array. |
473 * <li>The <code>src</code> argument and <code>dest</code> argument refer |
472 * <li>The {@code src} argument and {@code dest} argument refer |
474 * to arrays whose component types are different primitive types. |
473 * to arrays whose component types are different primitive types. |
475 * <li>The <code>src</code> argument refers to an array with a primitive |
474 * <li>The {@code src} argument refers to an array with a primitive |
476 * component type and the <code>dest</code> argument refers to an array |
475 * component type and the {@code dest} argument refers to an array |
477 * with a reference component type. |
476 * with a reference component type. |
478 * <li>The <code>src</code> argument refers to an array with a reference |
477 * <li>The {@code src} argument refers to an array with a reference |
479 * component type and the <code>dest</code> argument refers to an array |
478 * component type and the {@code dest} argument refers to an array |
480 * with a primitive component type. |
479 * with a primitive component type. |
481 * </ul> |
480 * </ul> |
482 * <p> |
481 * <p> |
483 * Otherwise, if any of the following is true, an |
482 * Otherwise, if any of the following is true, an |
484 * <code>IndexOutOfBoundsException</code> is |
483 * {@code IndexOutOfBoundsException} is |
485 * thrown and the destination is not modified: |
484 * thrown and the destination is not modified: |
486 * <ul> |
485 * <ul> |
487 * <li>The <code>srcPos</code> argument is negative. |
486 * <li>The {@code srcPos} argument is negative. |
488 * <li>The <code>destPos</code> argument is negative. |
487 * <li>The {@code destPos} argument is negative. |
489 * <li>The <code>length</code> argument is negative. |
488 * <li>The {@code length} argument is negative. |
490 * <li><code>srcPos+length</code> is greater than |
489 * <li>{@code srcPos+length} is greater than |
491 * <code>src.length</code>, the length of the source array. |
490 * {@code src.length}, the length of the source array. |
492 * <li><code>destPos+length</code> is greater than |
491 * <li>{@code destPos+length} is greater than |
493 * <code>dest.length</code>, the length of the destination array. |
492 * {@code dest.length}, the length of the destination array. |
494 * </ul> |
493 * </ul> |
495 * <p> |
494 * <p> |
496 * Otherwise, if any actual component of the source array from |
495 * Otherwise, if any actual component of the source array from |
497 * position <code>srcPos</code> through |
496 * position {@code srcPos} through |
498 * <code>srcPos+length-1</code> cannot be converted to the component |
497 * {@code srcPos+length-1} cannot be converted to the component |
499 * type of the destination array by assignment conversion, an |
498 * type of the destination array by assignment conversion, an |
500 * <code>ArrayStoreException</code> is thrown. In this case, let |
499 * {@code ArrayStoreException} is thrown. In this case, let |
501 * <b><i>k</i></b> be the smallest nonnegative integer less than |
500 * <b><i>k</i></b> be the smallest nonnegative integer less than |
502 * length such that <code>src[srcPos+</code><i>k</i><code>]</code> |
501 * length such that {@code src[srcPos+}<i>k</i>{@code ]} |
503 * cannot be converted to the component type of the destination |
502 * cannot be converted to the component type of the destination |
504 * array; when the exception is thrown, source array components from |
503 * array; when the exception is thrown, source array components from |
505 * positions <code>srcPos</code> through |
504 * positions {@code srcPos} through |
506 * <code>srcPos+</code><i>k</i><code>-1</code> |
505 * {@code srcPos+}<i>k</i>{@code -1} |
507 * will already have been copied to destination array positions |
506 * will already have been copied to destination array positions |
508 * <code>destPos</code> through |
507 * {@code destPos} through |
509 * <code>destPos+</code><i>k</I><code>-1</code> and no other |
508 * {@code destPos+}<i>k</I>{@code -1} and no other |
510 * positions of the destination array will have been modified. |
509 * positions of the destination array will have been modified. |
511 * (Because of the restrictions already itemized, this |
510 * (Because of the restrictions already itemized, this |
512 * paragraph effectively applies only to the situation where both |
511 * paragraph effectively applies only to the situation where both |
513 * arrays have component types that are reference types.) |
512 * arrays have component types that are reference types.) |
514 * |
513 * |
515 * @param src the source array. |
514 * @param src the source array. |
516 * @param srcPos starting position in the source array. |
515 * @param srcPos starting position in the source array. |
517 * @param dest the destination array. |
516 * @param dest the destination array. |
518 * @param destPos starting position in the destination data. |
517 * @param destPos starting position in the destination data. |
519 * @param length the number of array elements to be copied. |
518 * @param length the number of array elements to be copied. |
520 * @exception IndexOutOfBoundsException if copying would cause |
519 * @throws IndexOutOfBoundsException if copying would cause |
521 * access of data outside array bounds. |
520 * access of data outside array bounds. |
522 * @exception ArrayStoreException if an element in the <code>src</code> |
521 * @throws ArrayStoreException if an element in the {@code src} |
523 * array could not be stored into the <code>dest</code> array |
522 * array could not be stored into the {@code dest} array |
524 * because of a type mismatch. |
523 * because of a type mismatch. |
525 * @exception NullPointerException if either <code>src</code> or |
524 * @throws NullPointerException if either {@code src} or |
526 * <code>dest</code> is <code>null</code>. |
525 * {@code dest} is {@code null}. |
527 */ |
526 */ |
528 @HotSpotIntrinsicCandidate |
527 @HotSpotIntrinsicCandidate |
529 public static native void arraycopy(Object src, int srcPos, |
528 public static native void arraycopy(Object src, int srcPos, |
530 Object dest, int destPos, |
529 Object dest, int destPos, |
531 int length); |
530 int length); |
572 private static Properties props; |
571 private static Properties props; |
573 private static native Properties initProperties(Properties props); |
572 private static native Properties initProperties(Properties props); |
574 |
573 |
575 /** |
574 /** |
576 * Determines the current system properties. |
575 * Determines the current system properties. |
577 * <p> |
576 * |
578 * First, if there is a security manager, its |
577 * First, if there is a security manager, its |
579 * <code>checkPropertiesAccess</code> method is called with no |
578 * {@code checkPropertiesAccess} method is called with no |
580 * arguments. This may result in a security exception. |
579 * arguments. This may result in a security exception. |
581 * <p> |
580 * <p> |
582 * The current set of system properties for use by the |
581 * The current set of system properties for use by the |
583 * {@link #getProperty(String)} method is returned as a |
582 * {@link #getProperty(String)} method is returned as a |
584 * <code>Properties</code> object. If there is no current set of |
583 * {@code Properties} object. If there is no current set of |
585 * system properties, a set of system properties is first created and |
584 * system properties, a set of system properties is first created and |
586 * initialized. This set of system properties always includes values |
585 * initialized. This set of system properties always includes values |
587 * for the following keys: |
586 * for the following keys: |
588 * <table class="striped" style="text-align:left"> |
587 * <table class="striped" style="text-align:left"> |
589 * <caption style="display:none">Shows property keys and associated values</caption> |
588 * <caption style="display:none">Shows property keys and associated values</caption> |
590 * <thead> |
589 * <thead> |
591 * <tr><th scope="col">Key</th> |
590 * <tr><th scope="col">Key</th> |
592 * <th scope="col">Description of Associated Value</th></tr> |
591 * <th scope="col">Description of Associated Value</th></tr> |
593 * </thead> |
592 * </thead> |
594 * <tbody> |
593 * <tbody> |
595 * <tr><th scope="row"><code>java.version</code></th> |
594 * <tr><th scope="row">{@code java.version}</th> |
596 * <td>Java Runtime Environment version, which may be interpreted |
595 * <td>Java Runtime Environment version, which may be interpreted |
597 * as a {@link Runtime.Version}</td></tr> |
596 * as a {@link Runtime.Version}</td></tr> |
598 * <tr><th scope="row"><code>java.version.date</code></th> |
597 * <tr><th scope="row">{@code java.version.date}</th> |
599 * <td>Java Runtime Environment version date, in ISO-8601 YYYY-MM-DD |
598 * <td>Java Runtime Environment version date, in ISO-8601 YYYY-MM-DD |
600 * format, which may be interpreted as a {@link |
599 * format, which may be interpreted as a {@link |
601 * java.time.LocalDate}</td></tr> |
600 * java.time.LocalDate}</td></tr> |
602 * <tr><th scope="row"><code>java.vendor</code></th> |
601 * <tr><th scope="row">{@code java.vendor}</th> |
603 * <td>Java Runtime Environment vendor</td></tr> |
602 * <td>Java Runtime Environment vendor</td></tr> |
604 * <tr><th scope="row"><code>java.vendor.url</code></th> |
603 * <tr><th scope="row">{@code java.vendor.url}</th> |
605 * <td>Java vendor URL</td></tr> |
604 * <td>Java vendor URL</td></tr> |
606 * <tr><th scope="row"><code>java.vendor.version</code></th> |
605 * <tr><th scope="row">{@code java.vendor.version}</th> |
607 * <td>Java vendor version</td></tr> |
606 * <td>Java vendor version</td></tr> |
608 * <tr><th scope="row"><code>java.home</code></th> |
607 * <tr><th scope="row">{@code java.home}</th> |
609 * <td>Java installation directory</td></tr> |
608 * <td>Java installation directory</td></tr> |
610 * <tr><th scope="row"><code>java.vm.specification.version</code></th> |
609 * <tr><th scope="row">{@code java.vm.specification.version}</th> |
611 * <td>Java Virtual Machine specification version which may be |
610 * <td>Java Virtual Machine specification version which may be |
612 * interpreted as a {@link Runtime.Version}</td></tr> |
611 * interpreted as a {@link Runtime.Version}</td></tr> |
613 * <tr><th scope="row"><code>java.vm.specification.vendor</code></th> |
612 * <tr><th scope="row">{@code java.vm.specification.vendor}</th> |
614 * <td>Java Virtual Machine specification vendor</td></tr> |
613 * <td>Java Virtual Machine specification vendor</td></tr> |
615 * <tr><th scope="row"><code>java.vm.specification.name</code></th> |
614 * <tr><th scope="row">{@code java.vm.specification.name}</th> |
616 * <td>Java Virtual Machine specification name</td></tr> |
615 * <td>Java Virtual Machine specification name</td></tr> |
617 * <tr><th scope="row"><code>java.vm.version</code></th> |
616 * <tr><th scope="row">{@code java.vm.version}</th> |
618 * <td>Java Virtual Machine implementation version which may be |
617 * <td>Java Virtual Machine implementation version which may be |
619 * interpreted as a {@link Runtime.Version}</td></tr> |
618 * interpreted as a {@link Runtime.Version}</td></tr> |
620 * <tr><th scope="row"><code>java.vm.vendor</code></th> |
619 * <tr><th scope="row">{@code java.vm.vendor}</th> |
621 * <td>Java Virtual Machine implementation vendor</td></tr> |
620 * <td>Java Virtual Machine implementation vendor</td></tr> |
622 * <tr><th scope="row"><code>java.vm.name</code></th> |
621 * <tr><th scope="row">{@code java.vm.name}</th> |
623 * <td>Java Virtual Machine implementation name</td></tr> |
622 * <td>Java Virtual Machine implementation name</td></tr> |
624 * <tr><th scope="row"><code>java.specification.version</code></th> |
623 * <tr><th scope="row">{@code java.specification.version}</th> |
625 * <td>Java Runtime Environment specification version which may be |
624 * <td>Java Runtime Environment specification version which may be |
626 * interpreted as a {@link Runtime.Version}</td></tr> |
625 * interpreted as a {@link Runtime.Version}</td></tr> |
627 * <tr><th scope="row"><code>java.specification.vendor</code></th> |
626 * <tr><th scope="row">{@code java.specification.vendor}</th> |
628 * <td>Java Runtime Environment specification vendor</td></tr> |
627 * <td>Java Runtime Environment specification vendor</td></tr> |
629 * <tr><th scope="row"><code>java.specification.name</code></th> |
628 * <tr><th scope="row">{@code java.specification.name}</th> |
630 * <td>Java Runtime Environment specification name</td></tr> |
629 * <td>Java Runtime Environment specification name</td></tr> |
631 * <tr><th scope="row"><code>java.class.version</code></th> |
630 * <tr><th scope="row">{@code java.class.version}</th> |
632 * <td>Java class format version number</td></tr> |
631 * <td>Java class format version number</td></tr> |
633 * <tr><th scope="row"><code>java.class.path</code></th> |
632 * <tr><th scope="row">{@code java.class.path}</th> |
634 * <td>Java class path (refer to |
633 * <td>Java class path (refer to |
635 * {@link ClassLoader#getSystemClassLoader()} for details)</td></tr> |
634 * {@link ClassLoader#getSystemClassLoader()} for details)</td></tr> |
636 * <tr><th scope="row"><code>java.library.path</code></th> |
635 * <tr><th scope="row">{@code java.library.path}</th> |
637 * <td>List of paths to search when loading libraries</td></tr> |
636 * <td>List of paths to search when loading libraries</td></tr> |
638 * <tr><th scope="row"><code>java.io.tmpdir</code></th> |
637 * <tr><th scope="row">{@code java.io.tmpdir}</th> |
639 * <td>Default temp file path</td></tr> |
638 * <td>Default temp file path</td></tr> |
640 * <tr><th scope="row"><code>java.compiler</code></th> |
639 * <tr><th scope="row">{@code java.compiler}</th> |
641 * <td>Name of JIT compiler to use</td></tr> |
640 * <td>Name of JIT compiler to use</td></tr> |
642 * <tr><th scope="row"><code>os.name</code></th> |
641 * <tr><th scope="row">{@code os.name}</th> |
643 * <td>Operating system name</td></tr> |
642 * <td>Operating system name</td></tr> |
644 * <tr><th scope="row"><code>os.arch</code></th> |
643 * <tr><th scope="row">{@code os.arch}</th> |
645 * <td>Operating system architecture</td></tr> |
644 * <td>Operating system architecture</td></tr> |
646 * <tr><th scope="row"><code>os.version</code></th> |
645 * <tr><th scope="row">{@code os.version}</th> |
647 * <td>Operating system version</td></tr> |
646 * <td>Operating system version</td></tr> |
648 * <tr><th scope="row"><code>file.separator</code></th> |
647 * <tr><th scope="row">{@code file.separator}</th> |
649 * <td>File separator ("/" on UNIX)</td></tr> |
648 * <td>File separator ("/" on UNIX)</td></tr> |
650 * <tr><th scope="row"><code>path.separator</code></th> |
649 * <tr><th scope="row">{@code path.separator}</th> |
651 * <td>Path separator (":" on UNIX)</td></tr> |
650 * <td>Path separator (":" on UNIX)</td></tr> |
652 * <tr><th scope="row"><code>line.separator</code></th> |
651 * <tr><th scope="row">{@code line.separator}</th> |
653 * <td>Line separator ("\n" on UNIX)</td></tr> |
652 * <td>Line separator ("\n" on UNIX)</td></tr> |
654 * <tr><th scope="row"><code>user.name</code></th> |
653 * <tr><th scope="row">{@code user.name}</th> |
655 * <td>User's account name</td></tr> |
654 * <td>User's account name</td></tr> |
656 * <tr><th scope="row"><code>user.home</code></th> |
655 * <tr><th scope="row">{@code user.home}</th> |
657 * <td>User's home directory</td></tr> |
656 * <td>User's home directory</td></tr> |
658 * <tr><th scope="row"><code>user.dir</code></th> |
657 * <tr><th scope="row">{@code user.dir}</th> |
659 * <td>User's current working directory</td></tr> |
658 * <td>User's current working directory</td></tr> |
660 * </tbody> |
659 * </tbody> |
661 * </table> |
660 * </table> |
662 * <p> |
661 * <p> |
663 * Multiple paths in a system property value are separated by the path |
662 * Multiple paths in a system property value are separated by the path |
664 * separator character of the platform. |
663 * separator character of the platform. |
665 * <p> |
664 * <p> |
666 * Note that even if the security manager does not permit the |
665 * Note that even if the security manager does not permit the |
667 * <code>getProperties</code> operation, it may choose to permit the |
666 * {@code getProperties} operation, it may choose to permit the |
668 * {@link #getProperty(String)} operation. |
667 * {@link #getProperty(String)} operation. |
669 * |
668 * |
670 * @implNote In addition to the standard system properties, the system |
669 * @implNote In addition to the standard system properties, the system |
671 * properties may include the following keys: |
670 * properties may include the following keys: |
672 * <table class="striped"> |
671 * <table class="striped"> |
756 System.props = props; |
754 System.props = props; |
757 } |
755 } |
758 |
756 |
759 /** |
757 /** |
760 * Gets the system property indicated by the specified key. |
758 * Gets the system property indicated by the specified key. |
761 * <p> |
759 * |
762 * First, if there is a security manager, its |
760 * First, if there is a security manager, its |
763 * <code>checkPropertyAccess</code> method is called with the key as |
761 * {@code checkPropertyAccess} method is called with the key as |
764 * its argument. This may result in a SecurityException. |
762 * its argument. This may result in a SecurityException. |
765 * <p> |
763 * <p> |
766 * If there is no current set of system properties, a set of system |
764 * If there is no current set of system properties, a set of system |
767 * properties is first created and initialized in the same manner as |
765 * properties is first created and initialized in the same manner as |
768 * for the <code>getProperties</code> method. |
766 * for the {@code getProperties} method. |
769 * |
767 * |
770 * @param key the name of the system property. |
768 * @param key the name of the system property. |
771 * @return the string value of the system property, |
769 * @return the string value of the system property, |
772 * or <code>null</code> if there is no property with that key. |
770 * or {@code null} if there is no property with that key. |
773 * |
771 * |
774 * @exception SecurityException if a security manager exists and its |
772 * @throws SecurityException if a security manager exists and its |
775 * <code>checkPropertyAccess</code> method doesn't allow |
773 * {@code checkPropertyAccess} method doesn't allow |
776 * access to the specified system property. |
774 * access to the specified system property. |
777 * @exception NullPointerException if <code>key</code> is |
775 * @throws NullPointerException if {@code key} is {@code null}. |
778 * <code>null</code>. |
776 * @throws IllegalArgumentException if {@code key} is empty. |
779 * @exception IllegalArgumentException if <code>key</code> is empty. |
|
780 * @see #setProperty |
777 * @see #setProperty |
781 * @see java.lang.SecurityException |
778 * @see java.lang.SecurityException |
782 * @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String) |
779 * @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String) |
783 * @see java.lang.System#getProperties() |
780 * @see java.lang.System#getProperties() |
784 */ |
781 */ |
792 return props.getProperty(key); |
789 return props.getProperty(key); |
793 } |
790 } |
794 |
791 |
795 /** |
792 /** |
796 * Gets the system property indicated by the specified key. |
793 * Gets the system property indicated by the specified key. |
797 * <p> |
794 * |
798 * First, if there is a security manager, its |
795 * First, if there is a security manager, its |
799 * <code>checkPropertyAccess</code> method is called with the |
796 * {@code checkPropertyAccess} method is called with the |
800 * <code>key</code> as its argument. |
797 * {@code key} as its argument. |
801 * <p> |
798 * <p> |
802 * If there is no current set of system properties, a set of system |
799 * If there is no current set of system properties, a set of system |
803 * properties is first created and initialized in the same manner as |
800 * properties is first created and initialized in the same manner as |
804 * for the <code>getProperties</code> method. |
801 * for the {@code getProperties} method. |
805 * |
802 * |
806 * @param key the name of the system property. |
803 * @param key the name of the system property. |
807 * @param def a default value. |
804 * @param def a default value. |
808 * @return the string value of the system property, |
805 * @return the string value of the system property, |
809 * or the default value if there is no property with that key. |
806 * or the default value if there is no property with that key. |
810 * |
807 * |
811 * @exception SecurityException if a security manager exists and its |
808 * @throws SecurityException if a security manager exists and its |
812 * <code>checkPropertyAccess</code> method doesn't allow |
809 * {@code checkPropertyAccess} method doesn't allow |
813 * access to the specified system property. |
810 * access to the specified system property. |
814 * @exception NullPointerException if <code>key</code> is |
811 * @throws NullPointerException if {@code key} is {@code null}. |
815 * <code>null</code>. |
812 * @throws IllegalArgumentException if {@code key} is empty. |
816 * @exception IllegalArgumentException if <code>key</code> is empty. |
|
817 * @see #setProperty |
813 * @see #setProperty |
818 * @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String) |
814 * @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String) |
819 * @see java.lang.System#getProperties() |
815 * @see java.lang.System#getProperties() |
820 */ |
816 */ |
821 public static String getProperty(String key, String def) { |
817 public static String getProperty(String key, String def) { |
828 return props.getProperty(key, def); |
824 return props.getProperty(key, def); |
829 } |
825 } |
830 |
826 |
831 /** |
827 /** |
832 * Sets the system property indicated by the specified key. |
828 * Sets the system property indicated by the specified key. |
833 * <p> |
829 * |
834 * First, if a security manager exists, its |
830 * First, if a security manager exists, its |
835 * <code>SecurityManager.checkPermission</code> method |
831 * {@code SecurityManager.checkPermission} method |
836 * is called with a <code>PropertyPermission(key, "write")</code> |
832 * is called with a {@code PropertyPermission(key, "write")} |
837 * permission. This may result in a SecurityException being thrown. |
833 * permission. This may result in a SecurityException being thrown. |
838 * If no exception is thrown, the specified property is set to the given |
834 * If no exception is thrown, the specified property is set to the given |
839 * value. |
835 * value. |
840 * |
836 * |
841 * @param key the name of the system property. |
837 * @param key the name of the system property. |
842 * @param value the value of the system property. |
838 * @param value the value of the system property. |
843 * @return the previous value of the system property, |
839 * @return the previous value of the system property, |
844 * or <code>null</code> if it did not have one. |
840 * or {@code null} if it did not have one. |
845 * |
841 * |
846 * @exception SecurityException if a security manager exists and its |
842 * @throws SecurityException if a security manager exists and its |
847 * <code>checkPermission</code> method doesn't allow |
843 * {@code checkPermission} method doesn't allow |
848 * setting of the specified property. |
844 * setting of the specified property. |
849 * @exception NullPointerException if <code>key</code> or |
845 * @throws NullPointerException if {@code key} or |
850 * <code>value</code> is <code>null</code>. |
846 * {@code value} is {@code null}. |
851 * @exception IllegalArgumentException if <code>key</code> is empty. |
847 * @throws IllegalArgumentException if {@code key} is empty. |
852 * @see #getProperty |
848 * @see #getProperty |
853 * @see java.lang.System#getProperty(java.lang.String) |
849 * @see java.lang.System#getProperty(java.lang.String) |
854 * @see java.lang.System#getProperty(java.lang.String, java.lang.String) |
850 * @see java.lang.System#getProperty(java.lang.String, java.lang.String) |
855 * @see java.util.PropertyPermission |
851 * @see java.util.PropertyPermission |
856 * @see SecurityManager#checkPermission |
852 * @see SecurityManager#checkPermission |
867 return (String) props.setProperty(key, value); |
863 return (String) props.setProperty(key, value); |
868 } |
864 } |
869 |
865 |
870 /** |
866 /** |
871 * Removes the system property indicated by the specified key. |
867 * Removes the system property indicated by the specified key. |
872 * <p> |
868 * |
873 * First, if a security manager exists, its |
869 * First, if a security manager exists, its |
874 * <code>SecurityManager.checkPermission</code> method |
870 * {@code SecurityManager.checkPermission} method |
875 * is called with a <code>PropertyPermission(key, "write")</code> |
871 * is called with a {@code PropertyPermission(key, "write")} |
876 * permission. This may result in a SecurityException being thrown. |
872 * permission. This may result in a SecurityException being thrown. |
877 * If no exception is thrown, the specified property is removed. |
873 * If no exception is thrown, the specified property is removed. |
878 * |
874 * |
879 * @param key the name of the system property to be removed. |
875 * @param key the name of the system property to be removed. |
880 * @return the previous string value of the system property, |
876 * @return the previous string value of the system property, |
881 * or <code>null</code> if there was no property with that key. |
877 * or {@code null} if there was no property with that key. |
882 * |
878 * |
883 * @exception SecurityException if a security manager exists and its |
879 * @throws SecurityException if a security manager exists and its |
884 * <code>checkPropertyAccess</code> method doesn't allow |
880 * {@code checkPropertyAccess} method doesn't allow |
885 * access to the specified system property. |
881 * access to the specified system property. |
886 * @exception NullPointerException if <code>key</code> is |
882 * @throws NullPointerException if {@code key} is {@code null}. |
887 * <code>null</code>. |
883 * @throws IllegalArgumentException if {@code key} is empty. |
888 * @exception IllegalArgumentException if <code>key</code> is empty. |
|
889 * @see #getProperty |
884 * @see #getProperty |
890 * @see #setProperty |
885 * @see #setProperty |
891 * @see java.util.Properties |
886 * @see java.util.Properties |
892 * @see java.lang.SecurityException |
887 * @see java.lang.SecurityException |
893 * @see java.lang.SecurityManager#checkPropertiesAccess() |
888 * @see java.lang.SecurityManager#checkPropertiesAccess() |
936 * insensitivity, on different operating systems. For these |
931 * insensitivity, on different operating systems. For these |
937 * reasons, environment variables are more likely to have |
932 * reasons, environment variables are more likely to have |
938 * unintended side effects. It is best to use system properties |
933 * unintended side effects. It is best to use system properties |
939 * where possible. Environment variables should be used when a |
934 * where possible. Environment variables should be used when a |
940 * global effect is desired, or when an external system interface |
935 * global effect is desired, or when an external system interface |
941 * requires an environment variable (such as <code>PATH</code>). |
936 * requires an environment variable (such as {@code PATH}). |
942 * |
937 * |
943 * <p>On UNIX systems the alphabetic case of <code>name</code> is |
938 * <p>On UNIX systems the alphabetic case of {@code name} is |
944 * typically significant, while on Microsoft Windows systems it is |
939 * typically significant, while on Microsoft Windows systems it is |
945 * typically not. For example, the expression |
940 * typically not. For example, the expression |
946 * <code>System.getenv("FOO").equals(System.getenv("foo"))</code> |
941 * {@code System.getenv("FOO").equals(System.getenv("foo"))} |
947 * is likely to be true on Microsoft Windows. |
942 * is likely to be true on Microsoft Windows. |
948 * |
943 * |
949 * @param name the name of the environment variable |
944 * @param name the name of the environment variable |
950 * @return the string value of the variable, or <code>null</code> |
945 * @return the string value of the variable, or {@code null} |
951 * if the variable is not defined in the system environment |
946 * if the variable is not defined in the system environment |
952 * @throws NullPointerException if <code>name</code> is <code>null</code> |
947 * @throws NullPointerException if {@code name} is {@code null} |
953 * @throws SecurityException |
948 * @throws SecurityException |
954 * if a security manager exists and its |
949 * if a security manager exists and its |
955 * {@link SecurityManager#checkPermission checkPermission} |
950 * {@link SecurityManager#checkPermission checkPermission} |
956 * method doesn't allow access to the environment variable |
951 * method doesn't allow access to the environment variable |
957 * <code>name</code> |
952 * {@code name} |
958 * @see #getenv() |
953 * @see #getenv() |
959 * @see ProcessBuilder#environment() |
954 * @see ProcessBuilder#environment() |
960 */ |
955 */ |
961 public static String getenv(String name) { |
956 public static String getenv(String name) { |
962 SecurityManager sm = getSecurityManager(); |
957 SecurityManager sm = getSecurityManager(); |
1700 /** |
1691 /** |
1701 * Terminates the currently running Java Virtual Machine. The |
1692 * Terminates the currently running Java Virtual Machine. The |
1702 * argument serves as a status code; by convention, a nonzero status |
1693 * argument serves as a status code; by convention, a nonzero status |
1703 * code indicates abnormal termination. |
1694 * code indicates abnormal termination. |
1704 * <p> |
1695 * <p> |
1705 * This method calls the <code>exit</code> method in class |
1696 * This method calls the {@code exit} method in class |
1706 * <code>Runtime</code>. This method never returns normally. |
1697 * {@code Runtime}. This method never returns normally. |
1707 * <p> |
1698 * <p> |
1708 * The call <code>System.exit(n)</code> is effectively equivalent to |
1699 * The call {@code System.exit(n)} is effectively equivalent to |
1709 * the call: |
1700 * the call: |
1710 * <blockquote><pre> |
1701 * <blockquote><pre> |
1711 * Runtime.getRuntime().exit(n) |
1702 * Runtime.getRuntime().exit(n) |
1712 * </pre></blockquote> |
1703 * </pre></blockquote> |
1713 * |
1704 * |
1714 * @param status exit status. |
1705 * @param status exit status. |
1715 * @throws SecurityException |
1706 * @throws SecurityException |
1716 * if a security manager exists and its <code>checkExit</code> |
1707 * if a security manager exists and its {@code checkExit} |
1717 * method doesn't allow exit with the specified status. |
1708 * method doesn't allow exit with the specified status. |
1718 * @see java.lang.Runtime#exit(int) |
1709 * @see java.lang.Runtime#exit(int) |
1719 */ |
1710 */ |
1720 public static void exit(int status) { |
1711 public static void exit(int status) { |
1721 Runtime.getRuntime().exit(status); |
1712 Runtime.getRuntime().exit(status); |
1722 } |
1713 } |
1723 |
1714 |
1724 /** |
1715 /** |
1725 * Runs the garbage collector. |
1716 * Runs the garbage collector. |
1726 * <p> |
1717 * |
1727 * Calling the <code>gc</code> method suggests that the Java Virtual |
1718 * Calling the {@code gc} method suggests that the Java Virtual |
1728 * Machine expend effort toward recycling unused objects in order to |
1719 * Machine expend effort toward recycling unused objects in order to |
1729 * make the memory they currently occupy available for quick reuse. |
1720 * make the memory they currently occupy available for quick reuse. |
1730 * When control returns from the method call, the Java Virtual |
1721 * When control returns from the method call, the Java Virtual |
1731 * Machine has made a best effort to reclaim space from all discarded |
1722 * Machine has made a best effort to reclaim space from all discarded |
1732 * objects. |
1723 * objects. |
1733 * <p> |
1724 * <p> |
1734 * The call <code>System.gc()</code> is effectively equivalent to the |
1725 * The call {@code System.gc()} is effectively equivalent to the |
1735 * call: |
1726 * call: |
1736 * <blockquote><pre> |
1727 * <blockquote><pre> |
1737 * Runtime.getRuntime().gc() |
1728 * Runtime.getRuntime().gc() |
1738 * </pre></blockquote> |
1729 * </pre></blockquote> |
1739 * |
1730 * |
1781 * |
1772 * |
1782 * Otherwise, the filename argument is mapped to a native library image in |
1773 * Otherwise, the filename argument is mapped to a native library image in |
1783 * an implementation-dependent manner. |
1774 * an implementation-dependent manner. |
1784 * |
1775 * |
1785 * <p> |
1776 * <p> |
1786 * The call <code>System.load(name)</code> is effectively equivalent |
1777 * The call {@code System.load(name)} is effectively equivalent |
1787 * to the call: |
1778 * to the call: |
1788 * <blockquote><pre> |
1779 * <blockquote><pre> |
1789 * Runtime.getRuntime().load(name) |
1780 * Runtime.getRuntime().load(name) |
1790 * </pre></blockquote> |
1781 * </pre></blockquote> |
1791 * |
1782 * |
1792 * @param filename the file to load. |
1783 * @param filename the file to load. |
1793 * @exception SecurityException if a security manager exists and its |
1784 * @throws SecurityException if a security manager exists and its |
1794 * <code>checkLink</code> method doesn't allow |
1785 * {@code checkLink} method doesn't allow |
1795 * loading of the specified dynamic library |
1786 * loading of the specified dynamic library |
1796 * @exception UnsatisfiedLinkError if either the filename is not an |
1787 * @throws UnsatisfiedLinkError if either the filename is not an |
1797 * absolute path name, the native library is not statically |
1788 * absolute path name, the native library is not statically |
1798 * linked with the VM, or the library cannot be mapped to |
1789 * linked with the VM, or the library cannot be mapped to |
1799 * a native library image by the host system. |
1790 * a native library image by the host system. |
1800 * @exception NullPointerException if <code>filename</code> is |
1791 * @throws NullPointerException if {@code filename} is {@code null} |
1801 * <code>null</code> |
|
1802 * @see java.lang.Runtime#load(java.lang.String) |
1792 * @see java.lang.Runtime#load(java.lang.String) |
1803 * @see java.lang.SecurityManager#checkLink(java.lang.String) |
1793 * @see java.lang.SecurityManager#checkLink(java.lang.String) |
1804 */ |
1794 */ |
1805 @CallerSensitive |
1795 @CallerSensitive |
1806 public static void load(String filename) { |
1796 public static void load(String filename) { |
1807 Runtime.getRuntime().load0(Reflection.getCallerClass(), filename); |
1797 Runtime.getRuntime().load0(Reflection.getCallerClass(), filename); |
1808 } |
1798 } |
1809 |
1799 |
1810 /** |
1800 /** |
1811 * Loads the native library specified by the <code>libname</code> |
1801 * Loads the native library specified by the {@code libname} |
1812 * argument. The <code>libname</code> argument must not contain any platform |
1802 * argument. The {@code libname} argument must not contain any platform |
1813 * specific prefix, file extension or path. If a native library |
1803 * specific prefix, file extension or path. If a native library |
1814 * called <code>libname</code> is statically linked with the VM, then the |
1804 * called {@code libname} is statically linked with the VM, then the |
1815 * JNI_OnLoad_<code>libname</code> function exported by the library is invoked. |
1805 * JNI_OnLoad_{@code libname} function exported by the library is invoked. |
1816 * See the <a href="{@docRoot}/../specs/jni/index.html"> JNI Specification</a> |
1806 * See the <a href="{@docRoot}/../specs/jni/index.html"> JNI Specification</a> |
1817 * for more details. |
1807 * for more details. |
1818 * |
1808 * |
1819 * Otherwise, the libname argument is loaded from a system library |
1809 * Otherwise, the libname argument is loaded from a system library |
1820 * location and mapped to a native library image in an implementation- |
1810 * location and mapped to a native library image in an implementation- |
1821 * dependent manner. |
1811 * dependent manner. |
1822 * <p> |
1812 * <p> |
1823 * The call <code>System.loadLibrary(name)</code> is effectively |
1813 * The call {@code System.loadLibrary(name)} is effectively |
1824 * equivalent to the call |
1814 * equivalent to the call |
1825 * <blockquote><pre> |
1815 * <blockquote><pre> |
1826 * Runtime.getRuntime().loadLibrary(name) |
1816 * Runtime.getRuntime().loadLibrary(name) |
1827 * </pre></blockquote> |
1817 * </pre></blockquote> |
1828 * |
1818 * |
1829 * @param libname the name of the library. |
1819 * @param libname the name of the library. |
1830 * @exception SecurityException if a security manager exists and its |
1820 * @throws SecurityException if a security manager exists and its |
1831 * <code>checkLink</code> method doesn't allow |
1821 * {@code checkLink} method doesn't allow |
1832 * loading of the specified dynamic library |
1822 * loading of the specified dynamic library |
1833 * @exception UnsatisfiedLinkError if either the libname argument |
1823 * @throws UnsatisfiedLinkError if either the libname argument |
1834 * contains a file path, the native library is not statically |
1824 * contains a file path, the native library is not statically |
1835 * linked with the VM, or the library cannot be mapped to a |
1825 * linked with the VM, or the library cannot be mapped to a |
1836 * native library image by the host system. |
1826 * native library image by the host system. |
1837 * @exception NullPointerException if <code>libname</code> is |
1827 * @throws NullPointerException if {@code libname} is {@code null} |
1838 * <code>null</code> |
|
1839 * @see java.lang.Runtime#loadLibrary(java.lang.String) |
1828 * @see java.lang.Runtime#loadLibrary(java.lang.String) |
1840 * @see java.lang.SecurityManager#checkLink(java.lang.String) |
1829 * @see java.lang.SecurityManager#checkLink(java.lang.String) |
1841 */ |
1830 */ |
1842 @CallerSensitive |
1831 @CallerSensitive |
1843 public static void loadLibrary(String libname) { |
1832 public static void loadLibrary(String libname) { |