JDK-6352136 : TypeMirror.asElement().getEnclosedElements() throws NPE
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2005-11-17
  • Updated: 2010-04-02
  • Resolved: 2006-03-04
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 b75Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
Simple code below results in NullPointerException
 static class typekindVisitor extends TypeKindVisitor6<Boolean, Void> {
 	public Boolean defaultAction(TypeMirror tm, Void v) {
 	  List<? extends Element> le = tm.asElement().getEnclosedElements(); //<<--NPE
	  for(Element e : le ) e.asType().accept(new typekindVisitor(), null);
	   tm.accept( new typekindVisitor(), null);
	   return true;
	}
}

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

EVALUATION At some point the test program takes an ExecutableElement, calls asType() to get an ExecutableType, and later calls asElement() on that ExecutableType. The ExecutableType instance does not have a usable tsym value set: the second call always returns the same stub instance (named "Method"). This stub instance should never be returned to an external caller. Once the program tries to operate on it, treating it as a normal ExecutableElement, it is doomed.
17-12-2005

EVALUATION Sample code doesn't compile. What is tm?
17-11-2005