Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2019-01-27 13:44:52 +0000
committerStephan Herrmann2019-01-27 13:50:52 +0000
commitea9de51889c00ff80b902c9c52b47f43330d3f52 (patch)
tree9b23319d6b8b5631939fd6a782e939bbf0d33a6d
parenta564c4bb82e4a5a73ce782d5fa3c0f4e9caafd9b (diff)
downloadeclipse.jdt.core-ea9de51889c00ff80b902c9c52b47f43330d3f52.tar.gz
eclipse.jdt.core-ea9de51889c00ff80b902c9c52b47f43330d3f52.tar.xz
eclipse.jdt.core-ea9de51889c00ff80b902c9c52b47f43330d3f52.zip
Bug 543701 - javax.xml.transform.Result cannot be resolved after 4.11 M1
Change-Id: I5c947b5403d5251079aee6dc8053135ffda017ac Signed-off-by: Stephan Herrmann <stephan.herrmann@berlin.de>
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java55
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java6
2 files changed, 58 insertions, 3 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java
index 5b27b3fb5e..e1570a0e23 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java
@@ -7712,6 +7712,61 @@ public class ModuleBuilderTests extends ModifyingResourceTests {
}
}
+ public void testBug543701() throws Exception {
+ IJavaProject p = createJava9Project("p");
+ String outputDirectory = Util.getOutputDirectory();
+ try {
+ String jar1Path = outputDirectory + File.separator + "lib1.jar";
+ Util.createJar(new String[] {
+ "javax/xml/transform/Result.java",
+ "package javax.xml.transform;\n" +
+ "public class Result {}\n"
+ }, new HashMap<>(), jar1Path);
+
+ String jar2Path = outputDirectory + File.separator + "lib2.jar";
+ Util.createJar(new String[] {
+ "p2/C2.java",
+ "package p2;\n" +
+ "import javax.xml.transform.Result;\n" +
+ "public class C2 {\n" +
+ " public void m(Number n) {}\n" +
+ " public void m(Result r) {}\n" + // Result will be ambiguous looking from project 'p', but should not break compilation
+ "}\n"
+ }, new HashMap<>(), jar2Path);
+
+ addLibraryEntry(p, jar1Path, false);
+ addLibraryEntry(p, jar2Path, false);
+
+ createFolder("p/src/pp");
+ String testPath = "p/src/pp/Test.java";
+ String testSource =
+ "package pp;\n" +
+ "import p2.C2;\n" +
+ "public class Test {\n" +
+ " void test(C2 c2) {\n" +
+ " c2.m(Integer.valueOf(1));\n" +
+ " }\n" +
+ "}\n";
+ createFile(testPath, testSource);
+
+ p.getProject().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, null);
+ assertNoErrors();
+
+ this.problemRequestor.initialize(testSource.toCharArray());
+ getCompilationUnit(testPath).getWorkingCopy(this.wcOwner, null);
+ assertProblems("unexpected problems",
+ "----------\n" +
+ "----------\n",
+ this.problemRequestor);
+ } finally {
+ deleteProject(p);
+ // clean up output dir
+ File outputDir = new File(outputDirectory);
+ if (outputDir.exists())
+ Util.flushDirectoryContent(outputDir);
+ }
+ }
+
protected void assertNoErrors() throws CoreException {
for (IProject p : getWorkspace().getRoot().getProjects()) {
int maxSeverity = p.findMaxProblemSeverity(null, true, IResource.DEPTH_INFINITE);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java
index 18558d1801..fd4246da7d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -107,10 +107,10 @@ ReferenceBinding resolve(LookupEnvironment environment, boolean convertGenericTo
if (targetType == null) {
char[] typeName = this.compoundName[this.compoundName.length - 1];
targetType = this.fPackage.getType0(typeName);
- if (targetType == this) { //$IDENTITY-COMPARISON$
+ if (targetType == this || targetType == null) { //$IDENTITY-COMPARISON$
if (this.fPackage instanceof SplitPackageBinding) // leverage SplitPackageBinding to avoid duplicate creation of BinaryTypeBinding
targetType = environment.askForType(this.fPackage, typeName, this.fPackage.enclosingModule);
- else
+ else if (targetType == this) //$IDENTITY-COMPARISON$
targetType = environment.askForType(this.compoundName, this.fPackage.enclosingModule);
}
if ((targetType == null || targetType == this) && CharOperation.contains('.', typeName)) { //$IDENTITY-COMPARISON$

Back to the top