Bug 186189 - NPE trying to open the following class using the ASTView
Summary: NPE trying to open the following class using the ASTView
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 RC1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-09 11:53 EDT by Olivier Thomann CLA
Modified: 2007-05-15 05:08 EDT (History)
1 user (show)

See Also:
kent_johnson: review+


Attachments
Proposed fix (999 bytes, patch)
2007-05-09 13:35 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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