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

JSR 199: Compiler doesn't diagnose crash in user code

XMLWordPrintable

    • b138
    • generic
    • generic
    • Verified

      Compiler crash with SimpleJavaFileObject

      <testcase>
      import java.net.URI;
      import java.util.Arrays;
      import javax.tools.*;
      import static javax.tools.StandardLocation.*;
      import static javax.tools.JavaFileObject.Kind.*;

      class JFO extends SimpleJavaFileObject {
          public JFO(URI uri, JavaFileObject.Kind kind) {
              super(uri, kind);
          }
      }
      public class JFOTest04 {
          public static void main(String... arg) throws Exception {
              JavaCompilerTool javac = ToolProvider.getSystemJavaCompilerTool();
              JavaFileObject jfo = new JFO(new URI("JFOTest04.java"),SOURCE);
              JavaCompilerTool.CompilationTask ct = javac.getTask(null,null,null,null,
                              null, Arrays.asList(jfo));
              ct.run();
          }
      }
      </testcase>

      <output>
      bash-3.00$ java JFOTest04
      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) a
      fter checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
      java.lang.UnsupportedOperationException
              at javax.tools.SimpleJavaFileObject.getCharContent(SimpleJavaFileObject.java:110)
              at com.sun.tools.javac.main.JavaCompiler.readSource(JavaCompiler.java:434)
              at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:501)
              at com.sun.tools.javac.main.JavaCompiler.parseFiles(JavaCompiler.java:733)
              at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:659)
              at com.sun.tools.javac.main.Main.compile(Main.java:327)
              at com.sun.tools.javac.api.JavacTaskImpl.run(JavacTaskImpl.java:113)
              at JFOTest04.main(JFOTest04.java:18)
      </output>

      <java-version>
      bash-3.00$ java -version
      java version "1.6.0-beta2"
      Java(TM) SE Runtime Environment (build 1.6.0-beta2-b86)
      Java HotSpot(TM) Client VM (build 1.6.0-beta2-b86, mixed mode)
      </java-version>
      failing testcase: javac/api/JavaFileObject/JFOTest04
      Updated testcase
      --------------------
      import java.net.URI;
      import java.util.Arrays;
      import javax.tools.*;
      import static javax.tools.JavaFileObject.Kind.*;

      class JFO extends SimpleJavaFileObject {
          public JFO(URI uri, JavaFileObject.Kind kind) {
              super(uri, kind);
          }
      }
      public class JFOTest04 {
          public static void main(String... arg) throws Exception {
              JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
              JavaFileObject jfo = new JFO(new URI("JFOTest04.java"),SOURCE);
              JavaCompiler.CompilationTask ct = javac.getTask(null,null,null,null,
                              null, Arrays.asList(jfo));
              ct.call();
          }
      }
      ----------------------------

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: