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

JSR 199: Crash with CompilationTask.run

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P2 P2
    • 6
    • 6
    • tools
    • generic
    • generic

      Crash with CompilationTask.run().
      JVM will crash with following testcase.
      <code>
      import java.util.ArrayList;
      import java.util.List;
      import javax.tools.*;
      import static javax.tools.StandardJavaFileManager.StandardLocation.*;
      import static javax.tools.JavaFileObject.Kind.*;

      public class Foo {
          private void test(String... args) throws Throwable {
               JavaCompilerTool javac = ToolProvider.getSystemJavaCompilerTool();
               JavaFileManager jfm = javac.getStandardFileManager(null);
               JavaFileObject jfo =
               jfm.getJavaFileForInput(CLASS_PATH,args[0],SOURCE);
               List<JavaFileObject> list = new ArrayList<JavaFileObject>();
               list.add(jfo);
               JavaCompilerTool.CompilationTask task =
                       javac.getTask(null,jfm,null,null,null,list);
               task.run();
          }
          public static void main(String... arg) throws Throwable {
               Foo test = new Foo();
               test.test("Foo.java");
          }
      }
      </code>
      Output of the above testcase:
      <output>
      bash-3.00$ javac Foo.java
      bash-3.00$ java Foo
      An exception has occurred in the compiler (1.6.0-beta2). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
      java.lang.NullPointerException
              at com.sun.tools.javac.main.JavaCompiler.readSource(JavaCompiler.java:420)
              at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:485)
              at com.sun.tools.javac.main.JavaCompiler.parseFiles(JavaCompiler.java:710)
              at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:636)
              at com.sun.tools.javac.main.Main.compile(Main.java:332)
              at com.sun.tools.javac.api.JavacTaskImpl.run(JavacTaskImpl.java:111)
              at Foo.test(Foo.java:17)
              at Foo.main(Foo.java:21)
      </output>
      <java-version>
      bash-3.00$ java -version
      java version "1.6.0-beta2"
      Java(TM) SE Runtime Environment (build 1.6.0-beta2-b82)
      Java HotSpot(TM) Client VM (build 1.6.0-beta2-b82, mixed mode)
      </java-version>

            ahe Peter Ahe
            savadhansunw Seetharama Avadhanam (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: