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

JavaCompilerTool.CompilationTask.getDiagnostics() will throw java.lang.IllegalArgumentException

XMLWordPrintable

    • generic
    • generic

      JavaCompilerTool.CompilationTask.getDiagnostics() will throw java.lang.IllegalArgumentException
      <code>
      import java.io.File;
      import java.io.PrintWriter;
      import javax.tools.*;
      import static javax.tools.JavaFileObject.Kind.*;

      class Foo {
          public static void main(String[] args) throws Exception {
              JavaCompilerTool compiler = ToolProvider.defaultJavaCompiler();
              JavaFileManager jfm = ToolProvider.defaultJavaCompiler().getStandardFileManager();
              //jfm = compiler.getStandardFileManager();
              JavaFileObject jfo = jfm.getFileForInput("Test13.jar");
              compiler.run((PrintWriter)null, jfo).getDiagnostics();
          }
      }
      <\code>
      Test13.jar have Foo.java but I observed this bug with any kind of jar file.
      output of the code:
      <output>
      E:\javatrails\compilerAPI>javac Test24.java

      E:\javatrails\compilerAPI>java Test24
      An exception has occurred in the compiler (1.6.0-auto). 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 diagnos
      tic in your report. Thank you.
      java.lang.IllegalArgumentException
              at com.sun.tools.javac.util.Diagnostic.<init>(Diagnostic.java:274)
              at com.sun.tools.javac.util.Diagnostic$Factory.warning(Diagnostic.java:97)
              at com.sun.tools.javac.util.Log.warning(Log.java:420)
              at com.sun.tools.javac.util.DefaultFileManager.decode(DefaultFileManager.java:610)
              at com.sun.tools.javac.util.DefaultFileManager.access$300(DefaultFileManager.java:54)
              at com.sun.tools.javac.util.DefaultFileManager$RegularFileObject.getCharContent(DefaultFileManager.java:744)
              at com.sun.tools.javac.util.DefaultFileManager$RegularFileObject.getCharContent(DefaultFileManager.java:637)
              at com.sun.tools.javac.main.JavaCompiler.readSource(JavaCompiler.java:416)
              at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:480)
              at com.sun.tools.javac.main.JavaCompiler.parseFiles(JavaCompiler.java:697)
              at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:629)
              at com.sun.tools.javac.main.Main.compile(Main.java:756)
              at com.sun.tools.javac.api.JavacTaskImpl.run(JavacTaskImpl.java:82)
              at com.sun.tools.javac.api.JavacTaskImpl.getDiagnostics(JavacTaskImpl.java:99)
              at com.sun.tools.javac.api.JavacTaskImpl.getDiagnostics(JavacTaskImpl.java:47)
              at Test24.compile(Test24.java:14)
              at Test24.main(Test24.java:18)
      <\output>

      <java-version>
      java version "1.6.0-auto"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-auto-294)
      Java HotSpot(TM) Client VM (build 1.6.0-ea-b57, mixed mode)
      <\java-version>

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: