Community
Participate
Working Groups
N20110403-2000 - Have this class: package xy; public class Try { void test(String s, Integer i) { combine(s, i).compareTo(null); //1 Comparable comp= combine(s, i); //2 java.io.Serializable ser= combine(s, i); //3 combine(s, i); //4 //bug99922 java.util.Arrays.asList(s, i); } <T> T combine(T t1, T t2) { return Math.random() > 0 ? t1 : t2; } } - open ASTView on "combine(s, i)" - expand the type binding of the SimpleName "combine" java.lang.NullPointerException at java.lang.String.<init>(String.java:177) at org.eclipse.jdt.core.dom.TypeBinding.getName(TypeBinding.java:656) at org.eclipse.jdt.core.dom.TypeBinding.getQualifiedName(TypeBinding.java:786) at org.eclipse.jdt.astview.views.Binding.getLabel(Binding.java:315) at org.eclipse.jdt.astview.views.ASTViewLabelProvider.getText(ASTViewLabelProvider.java:78) at org.eclipse.jface.viewers.WrappedViewerLabelProvider.getText(WrappedViewerLabelProvider.java:108) at org.eclipse.jface.viewers.WrappedViewerLabelProvider.update(WrappedViewerLabelProvider.java:164) at org.eclipse.jface.viewers.ViewerColumn.refresh(ViewerColumn.java:152) at org.eclipse.jface.viewers.AbstractTreeViewer.doUpdateItem(AbstractTreeViewer.java:938)
Note that the problematic binding is not the type binding for the expression type of "combine(s, i)", but the result of calling getGenericTypeOfWildcardType() on that type.
I have a trivial fix for this one. The method getGenericTypeOfWildcardType() should return null for an intersection type.
Created attachment 192758 [details] Proposed fix + regression test I don't touch other cases for intersection types like getRank(), isUpperBound(), getName(), getQualifiedName(), getBound(). This will be done when fixing bug 99931.
Released in HEAD and BETA_JAVA7 branch. The NPE came from trying to display the name of the generic type of wildcard for an intersection type. To prevent it, the call to getGenericTypeOfWildcardType() now returns null for intersection type.
Verified for 3.7M7 using build I20110421-1800