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

Enabling java security manager will make programe thrown wrong exception ( main method not found )

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 7
    • 7
    • tools
    • b102
    • generic
    • generic
    • Verified

      Here is a very simple code to reproduce it :

      ========================
      bash-3.00$ cat Test.java
      import java.security.*;
      import sun.security.pkcs11.SunPKCS11;

      public class Test {

          public static void main(String[] args) throws Exception {

                  Provider p = new SunPKCS11(args[0]);
                  Security.insertProviderAt(p, 1);

         }

      }

      ============= Run with B62 =================

      bash-3.00$ /java/re/jdk/7.0/promoted/all/b62/binaries/solaris-sparc/bin/javac Test.java
      bash-3.00$ /java/re/jdk/7.0/promoted/all/b62/binaries/solaris-sparc/bin/java -Djava.security.manager Test ecprovider.cfg.bak
      Error: Main method not found in class Test, please define the main method as:
         public static void main(String[] args)
      Exception in thread "main" java.lang.RuntimeException: Main method not found in Test
              at sun.launcher.LauncherHelper.signatureDiagnostic(LauncherHelper.java:214)
              at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:202)

      ===============Run with b35======================

      bash-3.00$ /java/re/jdk/7.0/promoted/all/b35/binaries/solaris-sparc/bin/javac Test.java
      bash-3.00$ /java/re/jdk/7.0/promoted/all/b35/binaries/solaris-sparc/bin/java Test ecprovider.cfg.bak
      bash-3.00$ /java/re/jdk/7.0/promoted/all/b35/binaries/solaris-sparc/bin/java -Djava.security.manager Test ecprovider.cfg.bak
      Exception in thread "main" java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.security.pkcs11)
              at java.security.AccessControlContext.checkPermission(AccessControlContext.java:345)
              at java.security.AccessController.checkPermission(AccessController.java:555)
              at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
              at java.lang.SecurityManager.checkPackageAccess(SecurityManager.java:1529)
              at java.lang.ClassLoader$1.run(ClassLoader.java:349)
              at java.lang.ClassLoader$1.run(ClassLoader.java:347)
              at java.security.AccessController.doPrivileged(Native Method)
              at java.lang.ClassLoader.checkPackageAccess(ClassLoader.java:347)
      Error: Could not find the main class Test.
      Error: A JNI error has occurred, please check your installation and try again

      ================================
      When running with b62 , and enable java.security.manager , it thrown "Main method not found" RuntimeException , this is not the correct exception.
      However , it looks like the behaviour of b35 is correct . this is a regression.

            ksrini Kumar Srinivasan
            jgaosunw Judy Gao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: