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

javac crashes with wrong module-info.class in module path

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b26
    • Verification:
      Verified

      Description

      ADDITIONAL SYSTEM INFORMATION :
      OS Version:
      Windows 10 Pro 1909 Build 18363.720

      Java version:
      openjdk version "15-ea" 2020-09-15
      OpenJDK Runtime Environment (build 15-ea+15-619)
      OpenJDK 64-Bit Server VM (build 15-ea+15-619, mixed mode, sharing)

      Javac version:
      javac 15-ea

      A DESCRIPTION OF THE PROBLEM :
      Javac crashes when a compiled module-info.class file is located in the module path. The error seems to occur only, when the module name and the directory in the module path differ, e.g. a module 'a.b.c' located in a directory 'a.b.c' does not interfere with the compilation while the same module located in a directory 'x' crashes the compiler.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create the following file tree:
      .
      +---com.example.a
      | module-info.java with content: module com.example.a {}
      \---com.example.b
              module-info.java with content: module com.example.b {uses com.example.c;}
      Then invoke the following commands:
      javac -d ".\bin\a\" .\com.example.a\module-info.java
      javac -d ".\bin\b\" -p ".\bin\" .\com.example.b\module-info.java

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      A normal error message about a missing package instead of a crash.
      ACTUAL -
      An exception has occurred in the compiler (15-ea). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
      java.lang.NullPointerException
              at jdk.compiler/com.sun.tools.javac.code.Symtab.lookupPackage(Symtab.java:679)
              at jdk.compiler/com.sun.tools.javac.code.ClassFinder.loadClass(ClassFinder.java:426)
              at jdk.compiler/com.sun.tools.javac.comp.Resolve$6.lambda$loadClass$3(Resolve.java:2038)
              at jdk.compiler/com.sun.tools.javac.comp.Resolve.lookupInvisibleSymbol(Resolve.java:2138)
              at jdk.compiler/com.sun.tools.javac.comp.Resolve$6.loadClass(Resolve.java:2031)
              at jdk.compiler/com.sun.tools.javac.comp.Resolve.loadClass(Resolve.java:2012)
              at jdk.compiler/com.sun.tools.javac.comp.Resolve.findIdentInPackageInternal(Resolve.java:2402)
              at jdk.compiler/com.sun.tools.javac.comp.Resolve.findIdentInPackage(Resolve.java:2390)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.selectSym(Attr.java:4186)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:4071)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2276)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:663)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribType(Attr.java:729)
              at jdk.compiler/com.sun.tools.javac.comp.Modules$UsesProvidesVisitor.visitUses(Modules.java:1138)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCUses.accept(JCTree.java:3052)
              at jdk.compiler/com.sun.tools.javac.comp.Modules$UsesProvidesVisitor.lambda$visitModuleDef$0(Modules.java:995)
              at java.base/java.lang.Iterable.forEach(Iterable.java:75)
              at jdk.compiler/com.sun.tools.javac.comp.Modules$UsesProvidesVisitor.visitModuleDef(Modules.java:995)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCModuleDecl.accept(JCTree.java:2839)
              at jdk.compiler/com.sun.tools.javac.comp.Modules.lambda$getUsesProvidesCompleter$4(Modules.java:970)
              at jdk.compiler/com.sun.tools.javac.code.Symbol$ModuleSymbol.completeUsesProvides(Symbol.java:1045)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.visitModuleDef(Attr.java:5065)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCModuleDecl.accept(JCTree.java:2839)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:663)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:737)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribModule(Attr.java:4962)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribModule(Attr.java:4953)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attrib(Attr.java:4910)
              at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1346)
              at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:972)
              at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:316)
              at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:176)
              at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
              at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)
      printing javac parameters to: D:\dev\experiments\java\single-module\javac.20200322_125319.args

      CUSTOMER SUBMITTED WORKAROUND :
      Putting the class files in a different directory than the module path avoids the error.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jlahoda Jan Lahoda
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: