Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2018-04-25 21:46:03 +0000
committerStephan Herrmann2018-04-26 17:23:39 +0000
commit6b97a681df8c535cea10c8719f30c96cd76a63ac (patch)
treea99585d4a13745a59932843df9bc7ccfe1d3e323
parentb9c7228db069a63b5c1805833caad7a4bb92e2ab (diff)
downloadeclipse.jdt.core-6b97a681df8c535cea10c8719f30c96cd76a63ac.tar.gz
eclipse.jdt.core-6b97a681df8c535cea10c8719f30c96cd76a63ac.tar.xz
eclipse.jdt.core-6b97a681df8c535cea10c8719f30c96cd76a63ac.zip
Bug 534009 - java.lang.ClassCastException:I20180426-2000
org.eclipse.jdt.internal.core.ModuleDescriptionInfo cannot be cast to org.eclipse.jdt.internal.compiler.env.IBinaryModule Change-Id: I7ec69d7352b6747ea7d0759957fcd779e32213fc
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter9Test.java38
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java4
2 files changed, 40 insertions, 2 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter9Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter9Test.java
index 6ec2491c2c..a60c43b48e 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter9Test.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter9Test.java
@@ -1368,5 +1368,43 @@ public class ASTConverter9Test extends ConverterTestSetup {
deleteProject("Second");
}
}
+ public void testBug534009() throws Exception {
+ try {
+ IJavaProject project1 = createJavaProject("Foo", new String[] {"src"}, new String[] {jcl9lib}, "bin", "9");
+ project1.open(null);
+ createFile("/Foo/src/module-info.java",
+ "module Foo {}");
+ project1.close(); // sync
+ project1.open(null);
+ createFolder("/Foo/src/foo");
+ createFile("/Foo/src/foo/Foo.java",
+ "package foo;\n" +
+ "\n" +
+ "public class Foo {\n" +
+ " public interface MyInterface<T> {\n" +
+ " public void perform(T t);\n" +
+ " }\n" +
+ " public <T> MyInterface<T> createMyInterface() {\n" +
+ " return new My\n" + // incomplete, use case is: completion after "My"
+ " }\n" +
+ "}\n");
+ ASTParser parser = ASTParser.newParser(this.ast.apiLevel());
+ parser.setProject(project1);
+ parser.setResolveBindings(true);
+ String key = "Lfoo/Foo$MyInterface<Lfoo/Foo;:1TT;>;";
+ class BindingRequestor extends ASTRequestor {
+ ITypeBinding _result = null;
+ public void acceptBinding(String bindingKey, IBinding binding) {
+ if (this._result == null && binding != null && binding.getKind() == IBinding.TYPE)
+ this._result = (ITypeBinding) binding;
+ }
+ }
+ BindingRequestor requestor = new BindingRequestor();
+ parser.createASTs(new ICompilationUnit[0], new String[] {key}, requestor, null);
+ assertEquals("expected binding", key, requestor._result.getKey());
+ } finally {
+ deleteProject("Foo");
+ }
+ }
// Add new tests here
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java
index 27e8107fb9..e85b81bdfe 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java
@@ -419,10 +419,10 @@ private ModuleBinding getModuleFromAnswer(NameEnvironmentAnswer answer) {
} else {
moduleBinding = this.knownModules.get(moduleName);
if (moduleBinding == null && this.nameEnvironment instanceof IModuleAwareNameEnvironment) {
- assert answer.isBinaryType();
IModule iModule = ((IModuleAwareNameEnvironment) this.nameEnvironment).getModule(moduleName);
try {
- moduleBinding = BinaryModuleBinding.create(iModule, this);
+ this.typeRequestor.accept(iModule, this);
+ moduleBinding = this.knownModules.get(moduleName);
} catch (NullPointerException e) {
System.err.println("Bug 529367: moduleName: " + new String(moduleName) + "iModule null" + //$NON-NLS-1$ //$NON-NLS-2$
(iModule == null ? "true" : "false")); //$NON-NLS-1$ //$NON-NLS-2$]

Back to the top