JDK-6218229 : crash: java.lang.NullPointerException at com.sun.tools.javac.comp.Check.checkCompatibleConcretes(Che
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 5.0,6,6u14
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: linux,windows_2000,windows_xp
  • CPU: x86
  • Submitted: 2005-01-17
  • Updated: 2010-07-29
  • Resolved: 2006-01-07
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 6
6 b67Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
MS Windows 2000 [Version 5.00.2195]

A DESCRIPTION OF THE PROBLEM :
Javac crashes in compiling the test code below.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a file Test.java with the source code below. Then run javac Test.java.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
compiled classes
ACTUAL -
javac crash

ERROR MESSAGES/STACK TRACES THAT OCCUR :
An exception has occurred in the compiler (1.5.0_01). 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.Check.checkCompatibleConcretes(Check.java:1141)
        at com.sun.tools.javac.comp.Check.checkCompatibleSupertypes(Check.java:1495)
        at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:2451)
        at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2406)
        at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2355)
        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:444)
        at com.sun.tools.javac.main.Main.compile(Main.java:592)
        at com.sun.tools.javac.main.Main.compile(Main.java:544)
        at com.sun.tools.javac.Main.compile(Main.java:67)
        at com.sun.tools.javac.Main.main(Main.java:52)


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
interface Ac<S extends St<S,A>,A extends Ac<S,A>> { };

interface St<S extends St<S,A>,A extends Ac<S,A>> { };

abstract class CSS<X, Y> implements St<CSS<X, Y>, CSN<X, Y>> {};

final class CSN<X, Y> extends CSS<X, Y> implements Ac<CSS<X, Y>, CSN<X, Y>> {};
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
If class CSN is defined in the file BEFORE class CSS, then the program compiles.
###@###.### 2005-1-17 17:38:56 GMT

Comments
EVALUATION In response to SDN feedback: Thank you for bringing this problem to our attention. I have reopened 6292765. See also bug 6404691. Until I have a solution that fixes all these related issues, I think it is premature to consider a backport to 5.0.
17-06-2006

SUGGESTED FIX http://sa.sfbay.sun.com/projects/langtools_data/mustang/6218229/
26-01-2006

SUGGESTED FIX --- /tmp/geta29287 2005-12-05 00:22:12.346244856 +0530 +++ src/share/classes/com/sun/tools/javac/comp/MemberEnter.java 2005-12-05 00:18:03.680047864 +0530 @@ -815,6 +815,7 @@ : (c.fullname == names.java_lang_Object) ? Type.noType : syms.objectType; + ct.supertype_field = supertype; // Determine interfaces. ListBuffer<Type> interfaces = new ListBuffer<Type>(); @@ -837,7 +838,6 @@ chk.checkNotRepeated(iface.pos(), i, interfaceSet); } } - ct.supertype_field = supertype; if ((c.flags_field & ANNOTATION) != 0) ct.interfaces_field = List.of(syms.annotationType); else
04-12-2005

EVALUATION We should try to fix this in mustang. This has no compatibility impact and a workaround exists, so we don't plan to backport this to JDK 5. The problem appears to be that attribClassBody is called to soon, specifically checkCompatibleSupertypes. The fix should ensure that attribClassBody is called after all classes have been entered. While cycles in the inheritance graph are disallowed, cyclic dependencies can exist anyways as the submitters example illustrates. ###@###.### 2005-1-25 01:33:30 GMT We are considering backporting this to Tiger. ###@###.### 2005-07-02 20:06:56 GMT
25-01-2005