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

Compiler thows NPE, if SecurityManager doen't give access permission

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • P4
    • None
    • 7
    • tools
    • generic
    • generic

    Description

      Compiler thows incorrect exception with SecurityManager

      <testcase>
      import java.io.*;
      import java.util.*;
      import javax.tools.*;

      class SManager extends SecurityManager {

      }

      public class Foo {
        public static void main(String... arg) throws IOException {
            System.setSecurityManager(new SManager());
            JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
            StandardJavaFileManager javaFileManager =
      javac.getStandardFileManager(null,null,null);
        }
      }

      </testcase>

      <output>
      G:\trails>java Foo
      javax.tools.ToolProvider: java.lang.ClassNotFoundException: com/sun/tools/javac/api/JavacTool; access denied (java.util.
      PropertyPermission sun.tools.ToolProvider read)
      javax.tools.ToolProvider: java.security.AccessControlException: access denied (java.util.PropertyPermission java.home re
      ad); access denied (java.util.PropertyPermission sun.tools.ToolProvider read)
      javax.tools.ToolProvider: Lazy.compilerClass == null; access denied (java.util.PropertyPermission sun.tools.ToolProvider
       read)
      Exception in thread "main" java.lang.NullPointerException
              at Foo.main(Foo.java:13)

      </output>

      The above program throws NullPoniterException which is incorrect or can be documented.

      Attachments

        Activity

          People

            jjg Jonathan Gibbons
            savadhansunw Seetharama Avadhanam (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: