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

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 7
    • Fix Version/s: 7
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b102
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: