Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8318711

LogManager specification mentions LoggingPermission("control") which is not instantiatable

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 21
    • core-libs
    • None

      Various methods of

        https://docs.oracle.com/en/java/javase/21/docs/api/java.logging/java/util/logging/LogManager.html

      assert

        SecurityException - if a security manager exists and if the caller does not have LoggingPermission("control").

      However it's not possible to instantiate LoggingPermission("control"),
      there's no one-arg constructor https://docs.oracle.com/en/java/javase/21/docs/api/java.logging/java/util/logging/LoggingPermission.html

      Moreover it's not possible to instantiate anything other than new LoggingPermission("control", "") or LoggingPermission("control", null)

      The OpenJDK's implementation of LogManager contains:

      static final Permission controlPermission =
                  new LoggingPermission("control", null);

          void checkPermission() {
              @SuppressWarnings("removal")
              SecurityManager sm = System.getSecurityManager();
              if (sm != null)
                  sm.checkPermission(controlPermission);
          }

      So the LogManager's spec could be improved to say for example:

      SecurityException - if a security manager exists and if the caller does not have LoggingPermission("control", null).

      or simply

      SecurityException - if a security manager exists and if the caller does not have LoggingPermission.

            dfuchs Daniel Fuchs
            dbessono Dmitry Bessonov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: