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

Elements.getAllModuleElements() does not work properly before JavacTask.analyze()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • 25
    • 24
    • tools
    • None

      Consider this sequence:
      ```
      jshell> var t = (com.sun.source.util.JavacTask) javax.tools.ToolProvider.getSystemJavaCompiler().getTask(null, null, null, null, null, List.of(javax.tools.SimpleJavaFileObject.forSource(URI.create("mem://Test.java"), "")))
      t ==> com.sun.tools.javac.api.JavacTaskImpl@1a8a8f7c

      jshell> t.getElements().getAllModuleElements()
      | Exception java.lang.AssertionError
      | at Assert.error (Assert.java:155)
      | at Assert.checkNonNull (Assert.java:62)
      | at Modules.allModules (Modules.java:1226)
      | at JavacElements.getAllModuleElements (JavacElements.java:132)
      | at (#2:1)

      ```

      This feels wrong.

      See:
      https://github.com/openjdk/jdk/pull/18934/files#r1767657515

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

              Created:
              Updated: