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

constructor java.util.logging.Handler() throws SecurityException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 5.0
    • core-libs



      Name: apR10229 Date: 05/29/2003


      Filed By : SPB JCK team (###@###.###)
      JDK : java full version "1.5.0-beta-b07"
      JCK : 1.5
      Platform[s] : Linux
      switch/Mode :
      JCK test owner : http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto
      Failing Test [s] : N/A


      Specification excerpt:
      ======================
      --------- J2SE API spec v.1.5 ---------
      ...
      protected Handler()

             Default constructor. The resulting Handler has a log level of Level.ALL, no Formatter, and no Filter. A
             default ErrorManager instance is installed as the ErrorManager.
      ...
      ---------- end-of-excerpt ---------------

      Problem description
      ===================
      The behavior of the protected constructor java.util.logging.Handler()
      contradicts with 1.5 API Doc. There is an unexpected SecurityException
      when trying to create Handler's child without LoggingPermission("control").
       
          
      Minimized test:
      ===============
      ------- Test.java -------
      import java.util.logging.*;
      import java.security.*;;

      public class Test {
          public static void main(String[] argv) {
            System.setSecurityManager(new SampleSM());
            StubHandler h = new StubHandler();
          }
      }

      class SampleSM extends SecurityManager {
        public SampleSM() {
          super();
        }
        public void checkPermission(Permission perm) {
          if (perm.getName().equals("control")) {
            throw new SecurityException();
          }
        }
      }

      class StubHandler extends Handler {
        public StubHandler() {
          super();
        }
        public void close() {
        }
        public void flush() {
        }
        public void publish(LogRecord record) {
        }
      }

      ------- end-of-Test.java -------

      Minimized test output:
      ======================
      <pav@libra(pts/5).375> java -cp . Test
      Exception in thread "main" java.lang.ExceptionInInitializerError
              at java.util.logging.Handler.<init>(Handler.java:32)
              at StubHandler.<init>(Test.java:24)
              at Test.main(Test.java:7)
      Caused by: java.lang.SecurityException
              at SampleSM.checkPermission(Test.java:17)
              at java.util.logging.LogManager.checkAccess(LogManager.java:798)
              at java.util.logging.Logger.setLevel(Logger.java:1071)
              at java.util.logging.LogManager$RootLogger.<init>(LogManager.java:836)
              at java.util.logging.LogManager$RootLogger.<init>(LogManager.java:832)
              at java.util.logging.LogManager$1.run(LogManager.java:159)
              at java.security.AccessController.doPrivileged(Native Method)
              at java.util.logging.LogManager.<clinit>(LogManager.java:141)
              ... 3 more
      java.lang.NoClassDefFoundError
              at java.util.logging.LogManager$Cleaner.run(LogManager.java:179)
      <pav@libra(pts/5).376>


      JCK test source location:
      ==========================
      /java/re/jck/1.5//nightly/binaries/latest/JCK-runtime-15/tests

      Specific Machine Info:
      =====================
      Linux libra 2.4.18 #10 Fri Jun 28 18:21:54 MSD 2002 i686 unknown

      ======================================================================

            Unassigned Unassigned
            pavsunw Pav Pav (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: