JDK-6421111 : NullPointerException thrown when retrieving bounds for the type parameter
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2006-05-03
  • Updated: 2012-03-22
  • Resolved: 2006-10-23
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
7Resolved
Related Reports
Duplicate :  
Description
Processing the following source:

-----
package tmp;

import java.util.*;

public class S_GETBOUNDS<TP1 extends ArrayList & Set> {
}
-----


  and retrieving the bounds for TP1 in the following way:


----
        // inside the "process" method of the processor

        elements = processingEnv.getElementUtils();
        TypeElement element = elements.getTypeElement("tmp.S_GETBOUNDS");
        List<TypeParameterElement> ltpe = (List<TypeParameterElement>)element.getTypeParameters();
        TypeParameterElement tpe = ltpe.get(0);
        List<TypeMirror> bounds = (List<TypeMirror>)tpe.getBounds();           // (1)
----


  the NullPointerException is thrown at (.) 1:


-----
java.lang.NullPointerException
        at com.sun.tools.javac.code.Symbol$TypeSymbol.getBounds(Symbol.java:550)
        at com.sun.tools.javac.code.Symbol$TypeSymbol.getBounds(Symbol.java:467)
        at javasoft.sqe.tests.api.javax.lang.model.element.TypeElement.GETBOUNDS.test(GETBOUNDS.java:38)
        at javasoft.sqe.jck.lib.javax.annotation.processing.ProcessorTest.process(ProcessorTest.java:50)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:628)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment.discovery(JavacProcessingEnvironment.java:559)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:698)
        at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:866)
        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:636)
        at com.sun.tools.javac.main.Main.compile(Main.java:332)
        at com.sun.tools.javac.main.Main.compile(Main.java:255)
        at com.sun.tools.javac.main.Main.compile(Main.java:246)
        at com.sun.tools.javac.Main.compile(Main.java:70)
        at com.sun.tools.javac.Main.main(Main.java:55)
-----


  If the "& Set" part is removed from source - things go the expected way.

Comments
EVALUATION This problem is because type variables aren't properly initialized after enter. This causes other problems and should be addressed by ensuring that type variables are initialized during Enter/MemberEnter phase.
05-05-2006