JDK-6703334 : javac NPE in Check$Validator.visitSelect
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 1.4.2_18
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_7
  • CPU: sparc
  • Submitted: 2008-05-16
  • Updated: 2011-02-16
  • Resolved: 2009-02-09
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.
Other Other Other
1.4.2_19-rev b09Fixed 1.4.2_20-revFixed 1.4.2_21Fixed
Description
Description: 1.4.2 javac NPE in Check$Validator.visitSelect

 FULL PRODUCT VERSION :
./java -version
java version "1.4.2_14"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_14-b03) Java
HotSpot(TM) Client VM (build 1.4.2_14-b03, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
SunOS 5.8 Generic_108528-14 sun4u sparc SUNW,Ultra-4

A DESCRIPTION OF THE PROBLEM :
  Verified this NPE happens when following conditions are met.

- The class in the java source being compiled (A) implements an interface
(B)
  whose super class (interface) is not visible during compilation.
- .class exists for the interface (B) above.
- (A) implements another interface that is in a package.

This problem happens on JDK 1.4.2_* on Solaris and Windows.

myc.java	(A)
myitf/myitf.java	// interface which (B) extends
myitf/myitf.class	//
myitf2.class	(B) .class
myitf2.java	(B)

$ find . -name '*.java' | xargs pg | cat
::::::::::::::
./myc.java
::::::::::::::
public final class myc implements myitf2, java.io.Serializable {

}
::::::::::::::
./myitf/myitf.java
::::::::::::::
public interface myitf {
  final int VAR = 1;
}
::::::::::::::
./myitf2.java
::::::::::::::
public interface myitf2 extends myitf {
  public abstract void methodA();
}



$ <jdk1.4.2_14>/bin/javac myc.java
myc.java:1: cannot access myitf
file myitf.class not found
public final class myc implements myitf2, java.io.Serializable {
             ^
An exception has occurred in the compiler (1.4.2_14). Please file a bug at
the Java Developer Connection (http://java.sun.com/cgi-bin/bugreport.cgi)
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.v8.comp.Check$Validator.visitSelect(Check.java:437)
        at com.sun.tools.javac.v8.tree.Tree$Select.accept(Tree.java:1091)
        at com.sun.tools.javac.v8.comp.Check.validate(Check.java:409)
        at com.sun.tools.javac.v8.comp.Check.validate(Check.java:420)
        at com.sun.tools.javac.v8.comp.Attr.attribClassBody(Attr.java:1369)
        at com.sun.tools.javac.v8.comp.Attr.attribClass(Attr.java:1356)
        at com.sun.tools.javac.v8.comp.Attr.attribClass(Attr.java:1332)
        at
com.sun.tools.javac.v8.JavaCompiler.compile(JavaCompiler.java:355)
        at com.sun.tools.javac.v8.Main.compile(Main.java:569)
        at com.sun.tools.javac.Main.compile(Main.java:36)
        at com.sun.tools.javac.Main.main(Main.java:27)

The problem is not seen with jdk 1.5 :
$ <jdk1.5.0_12>/bin/javac myc.java
myc.java:1: cannot access myitf
file myitf.class not found
public final class myc implements myitf2, java.io.Serializable {
             ^

Comments
EVALUATION Thrown exception is valid, although as we've already reported an error, we should not print it, but silently exit. Please find suggested fix attached; it brings javac in 1.4.2 in line with 1.5.0's one.
19-06-2008

SUGGESTED FIX --- src/share/javac/com/sun/tools/javac/v8/Main.java- 2008-02-01 20:34:43.000000000 +0300 +++ src/share/javac/com/sun/tools/javac/v8/Main.java 2008-06-19 21:56:33.177999786 +0400 @@ -586,7 +586,12 @@ return EXIT_SYSERR; } catch (Throwable ex) { - bugMessage(ex); + // If we've already reported an error, compensate for + // buggy compiler error recovery by swallowing thrown + // exceptions. + if (comp == null || comp.errorCount() == 0 || + options == null || options.get("dev") != null) + bugMessage(ex); return EXIT_ABNORMAL; } finally { if (comp != null)
19-06-2008