Bug 186189

Summary: NPE trying to open the following class using the ASTView
Product: [Eclipse Project] JDT Reporter: Olivier Thomann <Olivier_Thomann>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: philippe_mulet
Version: 3.3Flags: kent_johnson: review+
Target Milestone: 3.3 RC1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed fix none

Description Olivier Thomann CLA 2007-05-09 11:53:43 EDT
Using I20070508-0800, I got this stack trace trying to open the ASTView and going to the node l.get(0).
java.lang.NullPointerException
at org.eclipse.jdt.core.dom.TypeBinding.getBinaryName(TypeBinding.java:128)
at org.eclipse.jdt.astview.views.Binding.getChildren(Binding.java:171)
at org.eclipse.jdt.astview.views.ASTViewContentProvider.getChildren(ASTViewContentProvider.java:95)
at org.eclipse.jdt.astview.views.ASTViewContentProvider.hasChildren(ASTViewContentProvider.java:252)
at org.eclipse.jface.viewers.AbstractTreeViewer.isExpandable(AbstractTreeViewer.java:1999)
at org.eclipse.jface.viewers.TreeViewer.isExpandable(TreeViewer.java:511)
at org.eclipse.jface.viewers.AbstractTreeViewer.isExpandable(AbstractTreeViewer.java:2025)
at org.eclipse.jface.viewers.AbstractTreeViewer.updatePlus(AbstractTreeViewer.java:2649)

import java.util.List;

public class X {
	<T> T foo(T t) {
		return null;
	}
	
	Object bar() {
		return new Object() {
			void bar(List<?> l) {
				foo(l.get(0));
			}
		};
	}
	
	public static void main(String args[]) {
	}
}
Comment 1 Olivier Thomann CLA 2007-05-09 11:54:43 EDT
Philippe, I'll look at it for RC1.
We should not blow up in the DOM binding especially if the code has no error.
Comment 2 Olivier Thomann CLA 2007-05-09 11:56:32 EDT
The problem occurs when trying to get the type binding of the expression:
foo(l.get(0))

I am investigating.
Comment 3 Olivier Thomann CLA 2007-05-09 13:26:20 EDT
The problem comes from the fact that the ITypeBinding for foo is a capture binding and a capture binding has no binary name. In this case, we tried to extract the binary name as if it was a type variable.
Since the JLS 13.1 doesn't specify any binary name for captures, null is an acceptable answer in this case.
Comment 4 Olivier Thomann CLA 2007-05-09 13:35:53 EDT
Created attachment 66520 [details]
Proposed fix
Comment 5 Olivier Thomann CLA 2007-05-09 13:36:22 EDT
Kent, please review.
Comment 6 Olivier Thomann CLA 2007-05-09 14:51:09 EDT
Released for 3.3RC1.
Added regression test org.eclipse.jdt.core.tests.dom.ASTConverter15Test#test0272
Comment 7 Frederic Fusier CLA 2007-05-15 05:08:13 EDT
Verified for 3.3 RC1 using I20070515-0010