diff options
author | jay | 2018-08-08 05:25:29 +0000 |
---|---|---|
committer | jay | 2018-08-10 08:04:10 +0000 |
commit | 0d1092730bf38c2d22fba391019110bf12049774 (patch) | |
tree | c6dddca58fc212010fc57c2fe13e0790b585a7d3 | |
parent | a8119f5a19c5e89a1af1d9ee62dbab09a2622af4 (diff) | |
download | eclipse.jdt.core-0d1092730bf38c2d22fba391019110bf12049774.tar.gz eclipse.jdt.core-0d1092730bf38c2d22fba391019110bf12049774.tar.xz eclipse.jdt.core-0d1092730bf38c2d22fba391019110bf12049774.zip |
Change-Id: Ia696898b71b068381945082967cd92557202f947
Signed-off-by: jay <jarthana@in.ibm.com>
9 files changed, 127 insertions, 4 deletions
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/DeclaredTypeImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/DeclaredTypeImpl.java index 422236ef26..7523d53375 100644 --- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/DeclaredTypeImpl.java +++ b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/DeclaredTypeImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2017 BEA Systems, Inc. + * Copyright (c) 2006, 2018 BEA Systems, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,10 +24,8 @@ import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeVisitor; import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl; -import org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding; import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding; import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; -import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding; import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding; 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 9b159e0d5f..22a5fd6070 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 @@ -1427,6 +1427,13 @@ public abstract class AbstractJavaModelTests extends SuiteOfTestCases { project.setRawClasspath(newPath, null); return project; } + protected IClasspathEntry getJRTLibraryEntry() { + if (!isJRE9) return null; + String javaHome = System.getProperty("java.home") + File.separator; + Path bootModPath = new Path(javaHome +"/lib/jrt-fs.jar"); + Path sourceAttachment = new Path(javaHome +"/lib/src.zip"); + return JavaCore.newLibraryEntry(bootModPath, sourceAttachment, null, null, null, false); + } /* } * Creates a Java project where prj=src=bin and with JCL_LIB on its classpath. 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 a17703bc3e..d7afeba825 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 @@ -6958,6 +6958,63 @@ public class ModuleBuilderTests extends ModifyingResourceTests { this.deleteProject("com.greetings"); } } + public void testBug534624a() throws CoreException, IOException { + if (!isJRE9) return; + IJavaProject project = null; + Hashtable<String, String> options = JavaCore.getOptions(); + try { + project = setUpJavaProject("bug.test.b534624"); + IClasspathEntry[] rawClasspath = project.getRawClasspath(); + IClasspathEntry jrtEntry = getJRTLibraryEntry(); + for(int i = 0; i < rawClasspath.length; i++) { + if (rawClasspath[i].getEntryKind() == IClasspathEntry.CPE_CONTAINER) + rawClasspath[i] = jrtEntry; + } + project.setRawClasspath(rawClasspath, null); + project.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_10); + project.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_10); + project.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_10); + getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null); + IMarker[] markers = project.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE); + assertMarkers("Unexpected markers", "Version9 cannot be resolved to a module", markers); + } finally { + if (project != null) + deleteProject(project); + JavaCore.setOptions(options); + } + } + public void testBug534624b() throws CoreException, IOException { + if (!isJRE9) return; + IJavaProject project = null; + Hashtable<String, String> options = JavaCore.getOptions(); + try { + project = setUpJavaProject("bug.test.b534624"); + IClasspathEntry[] rawClasspath = project.getRawClasspath(); + IClasspathEntry jrtEntry = getJRTLibraryEntry(); + for(int i = 0; i < rawClasspath.length; i++) { + if (rawClasspath[i].getEntryKind() == IClasspathEntry.CPE_CONTAINER) + rawClasspath[i] = jrtEntry; + } + project.setRawClasspath(rawClasspath, null); + project.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_9); + project.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_9); + project.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_9); + getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null); + IMarker[] markers = project.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE); + assertMarkers("Unexpected markers", "Version10 cannot be resolved to a module", markers); + + project.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_10); + project.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_10); + project.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_10); + getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null); + markers = project.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE); + assertMarkers("Unexpected markers", "Version9 cannot be resolved to a module", markers); + } finally { + if (project != null) + deleteProject(project); + JavaCore.setOptions(options); + } + } 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.tests.model/workspace/bug.test.b534624/.classpath b/org.eclipse.jdt.core.tests.model/workspace/bug.test.b534624/.classpath new file mode 100644 index 0000000000..404104c8bd --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/workspace/bug.test.b534624/.classpath @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10"> + <attributes> + <attribute name="module" value="true"/> + </attributes> + </classpathentry> + <classpathentry kind="lib" path="lib/multi.jar"> + <attributes> + <attribute name="module" value="true"/> + </attributes> + </classpathentry> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/org.eclipse.jdt.core.tests.model/workspace/bug.test.b534624/.project b/org.eclipse.jdt.core.tests.model/workspace/bug.test.b534624/.project new file mode 100644 index 0000000000..cb5a6bc8f2 --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/workspace/bug.test.b534624/.project @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>bug.test.b534624</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/org.eclipse.jdt.core.tests.model/workspace/bug.test.b534624/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.jdt.core.tests.model/workspace/bug.test.b534624/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..d779bfb4d2 --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/workspace/bug.test.b534624/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,13 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=10 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=10 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=10 diff --git a/org.eclipse.jdt.core.tests.model/workspace/bug.test.b534624/lib/multi.jar b/org.eclipse.jdt.core.tests.model/workspace/bug.test.b534624/lib/multi.jar Binary files differnew file mode 100644 index 0000000000..c28b088a36 --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/workspace/bug.test.b534624/lib/multi.jar diff --git a/org.eclipse.jdt.core.tests.model/workspace/bug.test.b534624/src/module-info.java b/org.eclipse.jdt.core.tests.model/workspace/bug.test.b534624/src/module-info.java new file mode 100644 index 0000000000..5f8fde45f4 --- /dev/null +++ b/org.eclipse.jdt.core.tests.model/workspace/bug.test.b534624/src/module-info.java @@ -0,0 +1,4 @@ +module bug.test.b534624 { + requires Version9; + requires Version10; +}
\ No newline at end of file diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJar.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJar.java index 39c1ee10e0..a0b66c437d 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJar.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJar.java @@ -110,7 +110,19 @@ IModule initializeModule() { ZipFile file = null; try { file = new ZipFile(this.zipFilename); - ClassFileReader classfile = ClassFileReader.read(file, IModule.MODULE_INFO_CLASS); // FIXME: use jar cache + String releasePath = "META-INF/versions/" + this.compliance + '/' + IModule.MODULE_INFO_CLASS; //$NON-NLS-1$ + System.out.println("Reading for module from: " + this.zipFilename); //$NON-NLS-1$ + ClassFileReader classfile = null; + try { + classfile = ClassFileReader.read(file, releasePath); + System.out.println("Read classfile : " + classfile); //$NON-NLS-1$ + } catch (Exception e) { + e.printStackTrace(); + // move on to the default + } + if (classfile == null) { + classfile = ClassFileReader.read(file, IModule.MODULE_INFO_CLASS); // FIXME: use jar cache + } if (classfile != null) { mod = classfile.getModuleDeclaration(); } |