< prev index next >

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

Print this page

    @@ -351,11 +351,18 @@
           *         if {@code sm} is non-null and a security manager is not allowed
           *         to be set dynamically
           * @see #getSecurityManager
           * @see SecurityManager#checkPermission
           * @see java.lang.RuntimePermission
    +      * @deprecated This method is only useful in conjunction with
    +      *       {@linkplain SecurityManager the Security Manager}, which is
    +      *       deprecated and subject to removal in a future release.
    +      *       Consequently, this method is also deprecated and subject to
    +      *       removal. There is no replacement for the Security Manager or this
    +      *       method.
           */
    +     @Deprecated(since="17", forRemoval=true)
          public static void setSecurityManager(SecurityManager sm) {
              if (allowSecurityManager()) {
                  if (security == null) {
                      // ensure image reader is initialized
                      Object.class.getResource("java/lang/ANY");

    @@ -417,11 +424,18 @@
           *
           * @return  if a security manager has already been established for the
           *          current application, then that security manager is returned;
           *          otherwise, {@code null} is returned.
           * @see     #setSecurityManager
    +      * @deprecated This method is only useful in conjunction with
    +      *       {@linkplain SecurityManager the Security Manager}, which is
    +      *       deprecated and subject to removal in a future release.
    +      *       Consequently, this method is also deprecated and subject to
    +      *       removal. There is no replacement for the Security Manager or this
    +      *       method.
           */
    +     @Deprecated(since="17", forRemoval=true)
          public static SecurityManager getSecurityManager() {
              if (allowSecurityManager()) {
                  return security;
              } else {
                  return null;

    @@ -2146,11 +2160,16 @@
                              throw new InternalError("Could not create SecurityManager", e);
                          }
                          allowSecurityManager = MAYBE;
                  }
              } else {
    -             allowSecurityManager = MAYBE;
    +             allowSecurityManager = NEVER;
    +         }
    +
    +         if (allowSecurityManager != NEVER) {
    +             System.err.println("WARNING: The Security Manager is deprecated" +
    +                     " and will be removed in a future release.");
              }

              // initializing the system class loader
              VM.initLevel(3);

< prev index next >