diff options
author | Stephan Herrmann | 2019-01-07 21:53:53 +0000 |
---|---|---|
committer | Stephan Herrmann | 2019-01-11 21:23:13 +0000 |
commit | 8f27de00ee41924ca8f840207a4c9805178a3f1d (patch) | |
tree | 59a95c3348e2813e35f688884130bac816d27c07 | |
parent | 8c846dbf9461e97c1f8b787c2a4e1efacdabc689 (diff) | |
download | eclipse.jdt.core-8f27de00ee41924ca8f840207a4c9805178a3f1d.tar.gz eclipse.jdt.core-8f27de00ee41924ca8f840207a4c9805178a3f1d.tar.xz eclipse.jdt.core-8f27de00ee41924ca8f840207a4c9805178a3f1d.zip |
Bug 543092 - [reconcile] "the type javax.xml.bind.JAXBException isI20190111-1800
ambiguous" with jboss-jaxb-api_2.3_spec
Change-Id: I6f7ac68751eeb88d89938724ccce2c1347d90521
4 files changed, 134 insertions, 8 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java index f113e64fe2..32690e1e53 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2018 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 @@ -1446,6 +1446,8 @@ public abstract class AbstractJavaModelTests extends SuiteOfTestCases { throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, e.getMessage(), e)); } } else { + if (attributes == null) + attributes = new IClasspathAttribute[] { JavaCore.newClasspathAttribute(IClasspathAttribute.MODULE, "true") }; jrtEntry = JavaCore.newLibraryEntry(bootModPath, sourceAttachment, null, null, attributes, false); } IJavaProject project = this.createJavaProject(name, srcFolders, new String[0], diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NullAnnotationModelTests9.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NullAnnotationModelTests9.java index 9a72d96b4a..0386f57d44 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NullAnnotationModelTests9.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NullAnnotationModelTests9.java @@ -87,9 +87,10 @@ public class NullAnnotationModelTests9 extends ReconcilerTests { " public String id(String in) { return in; }\n" + "}\n"); - p2 = createJavaProject("mod.two", new String[] {"src"}, new String[] {"JCL19_LIB", this.ANNOTATION_LIB}, "bin", "9"); + p2 = createJavaProject("mod.two", new String[] {"src"}, new String[] {"JCL19_LIB"}, "bin", "9"); IClasspathAttribute[] attr = { JavaCore.newClasspathAttribute(IClasspathAttribute.MODULE, "true") }; addClasspathEntry(p2, JavaCore.newProjectEntry(p.getPath(), null, false, attr, false)); + addClasspathEntry(p2, JavaCore.newLibraryEntry(new Path(this.ANNOTATION_LIB), null, null, null, attr, false)); p2.setOption(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED); createFolder("/mod.two/src/client"); diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests9.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests9.java index 919c45ef17..16166b5a8d 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests9.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests9.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2018 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 @@ -449,5 +449,125 @@ public void testBug540541() throws CoreException, IOException { JavaCore.setOptions(options); } } +public void testBug543092() throws Exception { + if (!isJRE9) { + System.err.println("Test "+getName()+" requires a JRE 9"); + return; + } + IJavaProject p = null; + try { + // ---- module log: + // - has log4j on the module path + p = createJava9ProjectWithJREAttributes("p", new String[] {"src"}, + new IClasspathAttribute[] {JavaCore.newClasspathAttribute(IClasspathAttribute.MODULE, "true")}); + String jarAbsPath = p.getProject().getLocation()+"/lib-modular.jar"; + createJar(new String[] { + "module-info.java", + "module lib {\n" + + " exports lib.lab;\n" + + "}\n", + "lib/lab/Lib.java", + "package lib.lab;\n" + + "public class Lib {}\n" + }, + jarAbsPath, + null, + "9"); + addLibraryEntry(p, new Path(jarAbsPath), false); + + String jarAbsPath2 = p.getProject().getLocation()+"/lib-nonmodular.jar"; + createJar(new String[] { + "lib/lab/Lib.java", + "package lib.lab;\n" + + "public class Lib {}\n", + }, + jarAbsPath2); + addLibraryEntry(p, new Path(jarAbsPath2), false); + + createFolder("p/src/test"); + createFile("p/src/test/Test.java", + "package test;\n" + + "public class Test {\n" + + " lib.lab.Lib lob;\n" + + "}\n"); + p.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null); + IMarker[] markers = p.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE); + assertMarkers("markers in p", + "", + markers); + + this.workingCopy = getCompilationUnit("p/src/test/Test.java").getWorkingCopy(this.wcOwner, null); + this.problemRequestor.initialize(this.workingCopy.getSource().toCharArray()); + this.workingCopy.reconcile(AST_INTERNAL_JLS11, true, this.wcOwner, null); + assertProblems("Expecting no problems", + "----------\n" + + "----------\n", + this.problemRequestor); + + } finally { + deleteProject(p); + } +} +public void testBug543092b() throws Exception { + if (!isJRE9) { + System.err.println("Test "+getName()+" requires a JRE 9"); + return; + } + IJavaProject p = null; + try { + // ---- module log: + // - has log4j on the module path + IClasspathAttribute[] moduleAttributes = new IClasspathAttribute[] {JavaCore.newClasspathAttribute(IClasspathAttribute.MODULE, "true")}; + p = createJava9ProjectWithJREAttributes("p", new String[] {"src"}, moduleAttributes); + String jarAbsPath = p.getProject().getLocation()+"/lib-modular.jar"; + createJar(new String[] { + "module-info.java", + "module lib {\n" + + " exports lib.lab;\n" + + "}\n", + "lib/lab/Lib.java", + "package lib.lab;\n" + + "public class Lib {}\n" + }, + jarAbsPath, + null, + "9"); + addLibraryEntry(p, new Path(jarAbsPath), null, null, null, null, moduleAttributes, false); + String jarAbsPath2 = p.getProject().getLocation()+"/lib-nonmodular.jar"; + createJar(new String[] { + "lib/lab/Lib.java", + "package lib.lab;\n" + + "public class Lib {}\n", + }, + jarAbsPath2); + addLibraryEntry(p, new Path(jarAbsPath2), false); + + createFolder("p/src/test"); + createFile("p/src/test/Test.java", + "package test;\n" + + "public class Test {\n" + + " lib.lab.Lib lob;\n" + + "}\n"); + p.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null); + IMarker[] markers = p.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE); + assertMarkers("markers in p", + "The package lib.lab is accessible from more than one module: <unnamed>, lib", + markers); + + this.workingCopy = getCompilationUnit("p/src/test/Test.java").getWorkingCopy(this.wcOwner, null); + this.problemRequestor.initialize(this.workingCopy.getSource().toCharArray()); + this.workingCopy.reconcile(AST_INTERNAL_JLS11, true, this.wcOwner, null); + assertProblems("Expecting no problems", + "----------\n" + + "1. ERROR in /p/src/test/Test.java (at line 3)\n" + + " lib.lab.Lib lob;\n" + + " ^^^^^^^\n" + + "The package lib.lab is accessible from more than one module: <unnamed>, lib\n" + + "----------\n", + this.problemRequestor); + } finally { + deleteProject(p); + } +} } diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java index cf98d1712f..835d45736e 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2018 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 @@ -879,8 +879,6 @@ public class NameLookup implements SuffixConstants { try { if (root.getKind() == IPackageFragmentRoot.K_SOURCE) module = root.getJavaProject().getModuleDescription(); // from any root in this project - else - module = root.getModuleDescription(); } catch (JavaModelException e) { cache.put(root, NO_MODULE); return null; @@ -890,9 +888,14 @@ public class NameLookup implements SuffixConstants { IClasspathEntry classpathEntry = rootToEntry.apply(root); if (classpathEntry instanceof ClasspathEntry) { if (((ClasspathEntry) classpathEntry).isModular()) { - // modular but no module-info implies this is an automatic module - module = ((PackageFragmentRoot) root).getAutomaticModuleDescription(classpathEntry); + module = root.getModuleDescription(); + if (module == null) { + // modular but no module-info implies this is an automatic module + module = ((PackageFragmentRoot) root).getAutomaticModuleDescription(classpathEntry); + } } + } else if (root instanceof JrtPackageFragmentRoot) { + module = root.getModuleDescription(); // always considered modular } } cache.put(root, module != null ? module : NO_MODULE); |