Community
Participate
Working Groups
Running I200208270833 This code IWorkspace ws = testcasesPlugin.getWorkspace(); IWorkspaceRoot root = ws.getRoot(); IProject project = root.getProjects()[0]; IJavaProject jp = JavaCore.create(project); CompilationUnit cu = AST.parseCompilationUnit( "import Class.*; public class Class {}".toCharArray(), "Class", jp); cu.accept(new ASTVisitor() { public boolean visit(ImportDeclaration node) { try { IBinding binding = node.resolveBinding(); } catch (Exception e) { System.out.println("Got a " + e.getClass() + ": " + e.getMessage()); } return true; } }); produces the output Got a class java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding I think DefaultBindingResolver.resolveImport() needs to check whether the binding returned from getTypeOrPackage() is a type or package and respond appropriately. On-demand imports from types are legal - JLS 7.5.2. Thanks Mark
Fixed and released in 2.1 stream.
Verified.
Regression test added (test0375)