JDK-8177068 : incomplete classpath causes NPE in Flow
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8,9,11
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2017-03-18
  • Updated: 2021-04-30
  • Resolved: 2019-09-05
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 JDK 14
11.0.12Fixed 14 b14Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
 The following program crashes javac. The classpath is incomplete, but the missing classes two.C and two.C$D are referenced from the class file for one.A.

I reproduced with 9-ea+161, and it also affects recent JDK 8 releases.

=== ./one/A.java
package one;
public class A {
  public A(two.C.D x) {}
}
=== ./T.java
import one.A;
class T {
  {
    System.err.println(two.C.D.g());
  }
}
=== ./two/C.java
package two;
public class C {
  public static class D {
    public static int g() {
      return 1;
    }
  }
}
===

$ javac T.java
$ rm two/*.class
$ javac T.java -sourcepath :
An exception has occurred in the compiler (9-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 and the following diagnostic in your report. Thank you.
java.lang.NullPointerException
        at jdk.compiler/com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitApply(Flow.java:1233)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1628)
        at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
        at jdk.compiler/com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:393)
        at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.visitExec(TreeScanner.java:213)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1446)
        at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
        at jdk.compiler/com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:393)
        at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
        at jdk.compiler/com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitBlock(Flow.java:995)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1014)
        at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
        at jdk.compiler/com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:393)
        at jdk.compiler/com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitClassDef(Flow.java:897)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:774)
        at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
        at jdk.compiler/com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:393)
        at jdk.compiler/com.sun.tools.javac.comp.Flow$FlowAnalyzer.analyzeTree(Flow.java:1325)
        at jdk.compiler/com.sun.tools.javac.comp.Flow$FlowAnalyzer.analyzeTree(Flow.java:1315)
        at jdk.compiler/com.sun.tools.javac.comp.Flow.analyzeTree(Flow.java:213)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1410)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1384)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:980)
        at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:302)
        at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:162)
        at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:55)
        at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:41)
Comments
Fix Request(11u): Backporting fixes NPE issues our users of jdk11 have. The patch does not apply cleanly to 11u and requires to change calls of ���attribSpeculative��� in the patch to 11u API. 11u RFR: https://mail.openjdk.java.net/pipermail/jdk-updates-dev/2021-April/005808.html Webrev: http://cr.openjdk.java.net/~eastigeevich/8177068/webrev.00/
21-04-2021

URL: https://hg.openjdk.java.net/jdk/jdk/rev/a3c63a9dfb2c User: jlahoda Date: 2019-09-05 10:43:56 +0000
05-09-2019

although this is a crash, it is provoked in kind of corner case situation: if a class file is removed from the class path and some classes happen to have InnerClasses attributes linking to the removed class. We have been trying with different solutions and this one doesn't seem to be an easy one. Also we need to touch the class loading and symbol completion areas which could be risky at this time of the game
21-12-2017

I can now reproduce the crash with the updated T.java
21-03-2017

> ./T$D.class That class shouldn't exist - two.C has a nested class D, T does not.
20-03-2017

I can't reproduce this on b161 on the mac. The steps I used are: ~/WorkDir/OpenJDK/bugs/bug8177068$ ~/java/jdk9/b161/bin/javac T.java ~/WorkDir/OpenJDK/bugs/bug8177068$ rm two/*.class ~/WorkDir/OpenJDK/bugs/bug8177068$ ~/java/jdk9/b161/bin/javac T.java -sourcepath : ~/WorkDir/OpenJDK/bugs/bug8177068$ find . . ./one ./one/A.class ./one/A.java ./T$D.class ./T.class ./T.java ./two ./two/C.java ~/WorkDir/OpenJDK/bugs/bug8177068$
20-03-2017