JDK-8042741 : Java 8 compiler throws NullPointerException depending location in source file
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_7
  • CPU: x86_64
  • Submitted: 2014-05-07
  • Updated: 2014-11-06
  • Resolved: 2014-05-29
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 8 JDK 9
8u20 b20Fixed 9Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Windows 7 (64 bit)
Linux (64 bit)

A DESCRIPTION OF THE PROBLEM :
On our open-source project BRJS (https://github.com/BladeRunnerJS/brjs), we have seen that when we renamed a public abstract class to 'AbstractAssetLocation', it throws a NullPointerException with the Java 8 compiler.

--------------------------------------------------
An exception has occurred in the compiler (1.8.0). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport)  after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report.  Thank you.
java.lang.NullPointerException
        at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.trackable(Flow.java:1479)
        at com.sun.tools.javac.comp.Flow$AssignAnalyzer.checkInit(Flow.java:2454)
        at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.checkInit(Flow.java:1555)
        at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.visitIdent(Flow.java:2328)
        at com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:2005)
        at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
        at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:389)
        at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scan(Flow.java:1367)
        at com.sun.tools.javac.tree.TreeScanner.visitSelect(TreeScanner.java:264)
        at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1891)
        at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
        at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:389)
        at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scan(Flow.java:1367)
        at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scanExpr(Flow.java:1596)
        at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.visitApply(Flow.java:2204)
        at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1459)
        at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
        at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:389)
        at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scan(Flow.java:1367)
        at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scanExpr(Flow.java:1596)
        at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scanExprs(Flow.java:1608)
        at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.visitApply(Flow.java:2205)
        at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1459)
....
--------------------------------------------------


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Environment setup:
set JAVA7_HOME to point to Java7
set JAVA8_HOME to point to Java8 

Get the code:
git clone https://github.com/BladeRunnerJS/brjs
git checkout d8a4af2
cd into 'brjs' folder
execute 'gradlew compileJava'

See that this command fails with the stack trace detailed in the description.

If you checkout the commit prior to this:
git checkout 4ac3238
gradlew compileJava

- see that this now passes

The list of commits in this specific Pull Request can be found here:
- https://github.com/BladeRunnerJS/brjs/pull/599


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expected result is that there is no compilation error.
ACTUAL -
Java 1.8.0 Java compiler throws NullPointerException

REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
If I rename the class and prefix it with an 'X' (refactoring it via Eclipse) to  'XAbstractAssetLocation', the issue goes away for Windows 7, but still fails for Linux 64bit.



Comments
Re Vicente's comment at 2014-05-14, you can use -Xbootclasspath/p: to specify a jar to be searched ahead of tools.jar.
29-05-2014