JDK-6864382 : NPE in the rich formatter when processing an unattributed type-variable
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: unknown
  • Submitted: 2009-07-24
  • Updated: 2013-07-18
  • Resolved: 2012-01-13
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 7
7 b70Fixed
Related Reports
Relates :  
Relates :  
Description
I see NPE (introduced in JDK7-b62) in javac for the following source:

--- test.java ---
class test<T> extends T {}
--- test.java ---


$ /set/java/jdk6.0/solaris-sparc/bin/javac test.java
test.java:1: unexpected type
found   : type parameter T
required: class
class test<T> extends T {}
                      ^
1 error

$ /set/java/re/jdk/7/promoted/ea/b61/binaries/solaris-sparc/bin/javac test.java
test.java:1: unexpected type
class test<T> extends T {}
                      ^
  required: class
  found:    type parameter T
1 error

$ /set/java/re/jdk/7/promoted/ea/b62/binaries/solaris-sparc/bin/javac test.java
An exception has occurred in the compiler (1.7.0-ea). 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.code.Types.getBounds(Types.java:1859)
        at com.sun.tools.javac.util.RichDiagnosticFormatter$2.visitTypeVar(RichDiagnosticFormatter.java:506)
        at com.sun.tools.javac.util.RichDiagnosticFormatter$2.visitTypeVar(RichDiagnosticFormatter.java:422)
        at com.sun.tools.javac.code.Type$TypeVar.accept(Type.java:949)
        at com.sun.tools.javac.code.Types$UnaryVisitor.visit(Types.java:3425)
        at com.sun.tools.javac.util.RichDiagnosticFormatter.preprocessType(RichDiagnosticFormatter.java:418)
        at com.sun.tools.javac.util.RichDiagnosticFormatter.preprocessArgument(RichDiagnosticFormatter.java:147)
        at com.sun.tools.javac.util.RichDiagnosticFormatter.preprocessDiagnostic(RichDiagnosticFormatter.java:130)
        at com.sun.tools.javac.util.RichDiagnosticFormatter.preprocessArgument(RichDiagnosticFormatter.java:153)
        at com.sun.tools.javac.util.RichDiagnosticFormatter.preprocessDiagnostic(RichDiagnosticFormatter.java:130)
        at com.sun.tools.javac.util.RichDiagnosticFormatter.format(RichDiagnosticFormatter.java:103)
        at com.sun.tools.javac.util.RichDiagnosticFormatter.format(RichDiagnosticFormatter.java:62)
        at com.sun.tools.javac.util.Log.writeDiagnostic(Log.java:367)
        at com.sun.tools.javac.util.Log.report(Log.java:344)
        at com.sun.tools.javac.util.AbstractLog.error(AbstractLog.java:92)
        at com.sun.tools.javac.comp.Check.typeTagError(Check.java:216)
        at com.sun.tools.javac.comp.Check.checkClassType(Check.java:490)
        at com.sun.tools.javac.comp.Check.checkClassType(Check.java:505)
        at com.sun.tools.javac.comp.Attr.checkBase(Attr.java:543)
        at com.sun.tools.javac.comp.Attr.attribBase(Attr.java:528)
        at com.sun.tools.javac.comp.MemberEnter.complete(MemberEnter.java:851)
        at com.sun.tools.javac.code.Symbol.complete(Symbol.java:404)
        at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:793)
        at com.sun.tools.javac.comp.Enter.complete(Enter.java:468)
        at com.sun.tools.javac.comp.Enter.main(Enter.java:446)
        at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:902)
        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:805)
        at com.sun.tools.javac.main.Main.compile(Main.java:400)
        at com.sun.tools.javac.main.Main.compile(Main.java:318)
        at com.sun.tools.javac.main.Main.compile(Main.java:309)
        at com.sun.tools.javac.Main.compile(Main.java:82)
        at com.sun.tools.javac.Main.main(Main.java:67)

Comments
SUGGESTED FIX A webrev of this fix is available at the following URL: http://hg.openjdk.java.net/jdk7/tl/langtools/rev/dd5c51734ad9
30-07-2009

EVALUATION this is another small bug due to the big change in the way javac generates diagnostics, in this case a bad handling of an unattributed type-variable. When the formatter tries to process the type-variable bound, a NPE is thrown, because the bound is missing (the type variable has not been attriuted because an error has been found during class enter).
24-07-2009