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

Fix Elements.get{Type,Package}Element/JavaCompiler.resolveIdent on uninitialized javac

    Details

      Description

      Some code (and tests), is doing a sequence of code like this:
      {code}
      javax.tools.JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
      JavacTaskImpl task = (JavacTaskImpl)tool.getTask(null, null, null, null, null, null);
      JavaCompiler compiler = JavaCompiler.instance(task.getContext());
      compiler.resolveIdent("T1");
      {code}

      Or:
      {code}
      JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
      JavacTask javac = (JavacTask)tool.getTask(null, fm, null, null, null, null);
      Elements elements = javac.getElements();
      TypeElement elem = elements.getTypeElement(type);
      {code}

      This used to work in JDK 8, but is not working under Jake.

      This causes failures of several tests:
      tools/javac/6330997/T6330997.java
      tools/javac/api/TestResolveIdent.java

      And also affects some other tests:
      tools/javac/importscope/dependencies/DependenciesTest.java
      tools/javac/processing/model/testgetallmembers/Main.java

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jlahoda Jan Lahoda
                Reporter:
                jlahoda Jan Lahoda
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: