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

java.security.AccessControlContext.checkPermission(null) incorrect

XMLWordPrintable

    • beta
    • sparc
    • solaris_2.6
    • Verified



      Name: ksC84122 Date: 04/26/99


      JDK 1.2.2 java.security.AccessController.checkPermission(null) throws
      NullPointerException while
      java.security.AccessControlContext.checkPermission(null)
      does not throw NullPointerException.

      This is an inconsistency.
      java.security.AccessControlContext.checkPermission(null)
      should also throw NullPointerException.

      A test example which demonstrates this problem.
      ===== test43.java ========
      import java.security.ProtectionDomain;
      import java.security.AccessControlContext;
      import java.security.AccessController;


      public class test43 {

         public static void main (String argv[]) {
             SecurityManager sec = new SecurityManager();
             ProtectionDomain pd[] = new ProtectionDomain[1];
             
             try {
      (new AccessControlContext(pd)).checkPermission(null);
                 System.out.println("CASE1: NullPointerException not thrown");
             } catch (NullPointerException npe) {
                 System.out.println("CASE1: NullPointerException thrown");
             }


             try {
      AccessController.checkPermission(null);
                 System.out.println("CASE2: NullPointerException not thrown");
                 return;
             } catch (NullPointerException npe) { //OKAY
                 System.out.println("CASE2: NullPointerException thrown");
             }
             return;
        }
      }



      ========= Sample run (JDK1.2.2) ==========
      #>java test43
      CASE1: NullPointerException not thrown
      CASE2: NullPointerException thrown

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

            mullan Sean Mullan
            skosunw Sko Sko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: