JDK-6359951 : Class field usage in generic
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 5.0
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: linux
  • CPU: x86
  • Submitted: 2005-12-07
  • Updated: 2010-04-02
  • Resolved: 2006-02-18
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 b73Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.5.0_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)


ADDITIONAL OS VERSION INFORMATION :
Linux is003029 2.6.11.10 #1 Wed Jun 1 11:36:47 CEST 2005 i686 GNU/Linux
Windows XP

A DESCRIPTION OF THE PROBLEM :
The following program :

class Foo {
    class C<T> { public static Class classOfT = T.getClass();}
    class D<T> { }
    class E<T> extends D< T.classOfT> { }
}

When compiled with "javac Foo.java" always yields the following error:

java.lang.NullPointerException
        at com.sun.tools.javac.comp.Attr.selectSym(Attr.java:1774)
        at com.sun.tools.javac.comp.Attr.selectSym(Attr.java:1812)
        at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:1699)
        at com.sun.tools.javac.tree.Tree$Select.accept(Tree.java:987)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
        at com.sun.tools.javac.comp.Attr.attribType(Attr.java:308)
        at com.sun.tools.javac.comp.Attr.attribTypes(Attr.java:351)
        at com.sun.tools.javac.comp.Attr.visitTypeApply(Attr.java:2212)
        at com.sun.tools.javac.tree.Tree$TypeApply.accept(Tree.java:1058)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
        at com.sun.tools.javac.comp.Attr.attribType(Attr.java:308)
        at com.sun.tools.javac.comp.Attr.attribBase(Attr.java:381)
        at com.sun.tools.javac.comp.MemberEnter.complete(MemberEnter.java:792)
        at com.sun.tools.javac.code.Symbol.complete(Symbol.java:355)
        at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:612)
        at com.sun.tools.javac.comp.Enter.complete(Enter.java:448)
        at com.sun.tools.javac.comp.Enter.main(Enter.java:426)
        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:413)
        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)


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a file Foo.java which contents are:
class Foo {
    class C<T> { public static Class classOfT = T.getClass();}
    class D<T> { }
    class E<T> extends D< T.classOfT> { }
}
Then try to compile the file with the command "javac Foo.java".

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I was expecting the byte code class files "Foo.class" "Foo$C.class" "Foo$D.class" "Foo$E.class" to be created.
ACTUAL -
Instread I get this message:
An exception has occurred in the compiler (1.5.0_04). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport)  after checking the Bug Parade forduplicates. Include your program and the following diagnostic in your report.  Thank you.
java.lang.NullPointerException
        at com.sun.tools.javac.comp.Attr.selectSym(Attr.java:1774)
        at com.sun.tools.javac.comp.Attr.selectSym(Attr.java:1812)
        at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:1699)
        at com.sun.tools.javac.tree.Tree$Select.accept(Tree.java:987)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
        at com.sun.tools.javac.comp.Attr.attribType(Attr.java:308)
        at com.sun.tools.javac.comp.Attr.attribTypes(Attr.java:351)
        at com.sun.tools.javac.comp.Attr.visitTypeApply(Attr.java:2212)
        at com.sun.tools.javac.tree.Tree$TypeApply.accept(Tree.java:1058)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
        at com.sun.tools.javac.comp.Attr.attribType(Attr.java:308)
        at com.sun.tools.javac.comp.Attr.attribBase(Attr.java:381)
        at com.sun.tools.javac.comp.MemberEnter.complete(MemberEnter.java:792)
        at com.sun.tools.javac.code.Symbol.complete(Symbol.java:355)
        at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:612)
        at com.sun.tools.javac.comp.Enter.complete(Enter.java:448)
        at com.sun.tools.javac.comp.Enter.main(Enter.java:426)
        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:413)
        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)


ERROR MESSAGES/STACK TRACES THAT OCCUR :

An exception has occurred in the compiler (1.5.0_04). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport)  after checking the Bug Parade forduplicates. Include your program and the following diagnostic in your report.  Thank you.
java.lang.NullPointerException
        at com.sun.tools.javac.comp.Attr.selectSym(Attr.java:1774)
        at com.sun.tools.javac.comp.Attr.selectSym(Attr.java:1812)
        at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:1699)
        at com.sun.tools.javac.tree.Tree$Select.accept(Tree.java:987)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
        at com.sun.tools.javac.comp.Attr.attribType(Attr.java:308)
        at com.sun.tools.javac.comp.Attr.attribTypes(Attr.java:351)
        at com.sun.tools.javac.comp.Attr.visitTypeApply(Attr.java:2212)
        at com.sun.tools.javac.tree.Tree$TypeApply.accept(Tree.java:1058)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
        at com.sun.tools.javac.comp.Attr.attribType(Attr.java:308)
        at com.sun.tools.javac.comp.Attr.attribBase(Attr.java:381)
        at com.sun.tools.javac.comp.MemberEnter.complete(MemberEnter.java:792)
        at com.sun.tools.javac.code.Symbol.complete(Symbol.java:355)
        at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:612)
        at com.sun.tools.javac.comp.Enter.complete(Enter.java:448)
        at com.sun.tools.javac.comp.Enter.main(Enter.java:426)
        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:413)
        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 ----------
class Foo {
    class C<T> { public static Class classOfT = T.getClass();}
    class D<T> { }
    class E<T> extends D< T.classOfT> { }
}
---------- END SOURCE ----------

Comments
SUGGESTED FIX Webrev of changes: http://sa.sfbay/projects/langtools/bugid_summary.pl?bugid=6359951
14-02-2006

EVALUATION Crashes are bad, but the program is not correct so javac should report an error.
13-12-2005