JDK-8198315 : Incomplete classpath causes NPE in TransTypes
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 10
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2018-02-16
  • Updated: 2018-05-30
  • Resolved: 2018-05-22
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11
11 b15Fixed
Related Reports
Relates :  
Description
=== A.java
public class A {}
=== B.java
public class B extends A {}
=== C.java
public class C extends D<B> {}
=== D.java
public class D<T extends A> {
  public void f(String s) {}
}
=== Test.java
public class Test {
  public void test(C c) {
    c.f(null, null);
  }
}
===

$ javac A.java B.java C.java D.java
$ rm A.class
$ javac -fullversion -sourcepath : -implicit:none Test.java
javac full version "10-ea+37"
...
java.lang.NullPointerException
	at jdk.compiler/com.sun.tools.javac.comp.TransTypes.visitSelect(TransTypes.java:862)
	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2110)
	at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
	at jdk.compiler/com.sun.tools.javac.comp.TransTypes.translate(TransTypes.java:499)
	at jdk.compiler/com.sun.tools.javac.comp.TransTypes.visitApply(TransTypes.java:672)
	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1634)
	at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
	at jdk.compiler/com.sun.tools.javac.comp.TransTypes.translate(TransTypes.java:499)
	at jdk.compiler/com.sun.tools.javac.comp.TransTypes.visitExec(TransTypes.java:650)
	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1452)
	at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
	at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:70)
	at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.visitBlock(TreeTranslator.java:167)
Comments
Turns out not related to JDK-8177068, although related to CompletionFailures. There is an expected error in the source: --- Test.java:9: error: method f in class D<T> cannot be applied to given types; c.f(null, null); ^ required: String found: <null>,<null> reason: actual and formal argument lists differ in length where T is a type-variable: T extends A declared in class D 1 error --- But when A.class is missing, when this error is being reported, a CompletionFailure is thrown: --- at jdk.compiler/com.sun.tools.javac.code.ClassFinder.classFileNotFound(ClassFinder.java:393) at jdk.compiler/com.sun.tools.javac.code.ClassFinder.fillIn(ClassFinder.java:388) at jdk.compiler/com.sun.tools.javac.code.ClassFinder.complete(ClassFinder.java:291) at jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:631) at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1315) at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.complete(Type.java:1140) at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.getTypeArguments(Type.java:1066) at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.isErroneous(Type.java:1096) at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.isErroneous(Type.java:1097) at jdk.compiler/com.sun.tools.javac.code.Types.getBounds(Types.java:2671) at jdk.compiler/com.sun.tools.javac.util.RichDiagnosticFormatter$1.visitTypeVar(RichDiagnosticFormatter.java:559) at jdk.compiler/com.sun.tools.javac.util.RichDiagnosticFormatter$1.visitTypeVar(RichDiagnosticFormatter.java:459) at jdk.compiler/com.sun.tools.javac.code.Type$TypeVar.accept(Type.java:1654) at jdk.compiler/com.sun.tools.javac.code.Types$UnaryVisitor.visit(Types.java:4926) at jdk.compiler/com.sun.tools.javac.util.RichDiagnosticFormatter$1.visit(RichDiagnosticFormatter.java:463) at jdk.compiler/com.sun.tools.javac.util.RichDiagnosticFormatter$1.visitClassType(RichDiagnosticFormatter.java:541) at jdk.compiler/com.sun.tools.javac.util.RichDiagnosticFormatter$1.visitClassType(RichDiagnosticFormatter.java:459) at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.accept(Type.java:993) at jdk.compiler/com.sun.tools.javac.code.Types$UnaryVisitor.visit(Types.java:4926) at jdk.compiler/com.sun.tools.javac.util.RichDiagnosticFormatter.preprocessType(RichDiagnosticFormatter.java:455) at jdk.compiler/com.sun.tools.javac.util.RichDiagnosticFormatter.preprocessArgument(RichDiagnosticFormatter.java:184) at jdk.compiler/com.sun.tools.javac.util.RichDiagnosticFormatter.preprocessDiagnostic(RichDiagnosticFormatter.java:167) at jdk.compiler/com.sun.tools.javac.util.RichDiagnosticFormatter.format(RichDiagnosticFormatter.java:116) at jdk.compiler/com.sun.tools.javac.util.RichDiagnosticFormatter.format(RichDiagnosticFormatter.java:72) at jdk.compiler/com.sun.tools.javac.util.Log.writeDiagnostic(Log.java:736) at jdk.compiler/com.sun.tools.javac.util.Log$DefaultDiagnosticHandler.report(Log.java:714) at jdk.compiler/com.sun.tools.javac.util.Log.report(Log.java:674) at jdk.compiler/com.sun.tools.javac.comp.Resolve.logResolveError(Resolve.java:3701) at jdk.compiler/com.sun.tools.javac.comp.Resolve.accessInternal(Resolve.java:2478) at jdk.compiler/com.sun.tools.javac.comp.Resolve.accessMethod(Resolve.java:2496) at jdk.compiler/com.sun.tools.javac.comp.Resolve$BasicLookupHelper.access(Resolve.java:3294) at jdk.compiler/com.sun.tools.javac.comp.Resolve$10.access(Resolve.java:2664) at jdk.compiler/com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:3535) at jdk.compiler/com.sun.tools.javac.comp.Resolve.resolveQualifiedMethod(Resolve.java:2654) at jdk.compiler/com.sun.tools.javac.comp.Resolve.resolveQualifiedMethod(Resolve.java:2648) at jdk.compiler/com.sun.tools.javac.comp.Attr.selectSym(Attr.java:3727) at jdk.compiler/com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3607) at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2110) at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655) at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:2006) at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1634) at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655) at jdk.compiler/com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:702) at jdk.compiler/com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1773) at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1452) at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655) at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724) at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:743) at jdk.compiler/com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1294) at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1020) at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655) at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724) at jdk.compiler/com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1098) at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:866) at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655) at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724) at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4720) at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4611) at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4540) at jdk.compiler/com.sun.tools.javac.comp.Attr.attrib(Attr.java:4485) at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1336) at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:968) at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:306) at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:165) at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57) at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43) --- So the report does not actually happen. The CF is caught, and is sent to Check.completionError, which tries to report an error, but because a different error (the original one) has already been reported at the same coordinates, it will be skipped. So, in the end, neither of these errors is really reported, and the compilation continues.
05-03-2018

Yep, looks very similar
28-02-2018

I suspect this has the same root cause as JDK-8177068 (CompletionFailure thrown, caught and error reported inside speculative attribution). I'll check.
28-02-2018