Community
Participate
Working Groups
Created attachment 96645 [details] Test plugin with popup action I was trying to resolve a core Java type (e.g. java.util.ArrayList) in a project whose classpath is broken because the project was imported into the workspace. I was surprised to see a ClassCastException instead of getting null or empty array back from the IType.resolveType(String) call. I've attached a simple TestPlugin (w/ source) that illustrates this problem. I'll also attach a test project next. Steps: 1. Launch eclipse with the TestPlugin. 2. Import the JavaProject into workspace, but don't fix the classpath errors. 3. Right-click foo.Bar java file and run the New Submenu > New Action popup. 4. See the following ClassCastException: java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.lookup.PackageBinding incompatible with org.eclipse.jdt.internal.compiler.lookup.TypeBinding at org.eclipse.jdt.internal.codeassist.select.SelectionOnQualifiedTypeReference.getTypeBinding(SelectionOnQualifiedTypeReference.java:49) at org.eclipse.jdt.internal.compiler.ast.TypeReference.internalResolveType(TypeReference.java:130) at org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveType(TypeReference.java:197) at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.resolveTypeFor(SourceTypeBinding.java:1280) at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.fields(SourceTypeBinding.java:610) at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.faultInTypesForFieldsAndMethods(SourceTypeBinding.java:588) at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.faultInTypes(CompilationUnitScope.java:438) at org.eclipse.jdt.internal.codeassist.SelectionEngine.selectType(SelectionEngine.java:1177) at org.eclipse.jdt.internal.core.NamedMember.resolveType(NamedMember.java:292) at org.eclipse.jdt.internal.core.NamedMember.resolveType(NamedMember.java:245) at testplugin.popup.actions.NewAction.run(NewAction.java:53) ...
Created attachment 96646 [details] JavaProject
Another way to reproduce the bug: 1) create the java project P 2) remore the JRE from the classpath 3) create Test.java public class Test { java.util.ArrayList v; } 4) select 'java.util.ArrayList' 5) do F3 (code select) This cause the same exception.
Created attachment 97172 [details] Proposed fix
Released for 3.4M7. Tests added ResolveTests2#testBug227822a() -> testBug227822d()
Verified for 3.4M7 using I20080427-2000.