Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimeon Andreev2018-10-05 08:44:58 +0000
committerSimeon Andreev2018-10-05 08:44:58 +0000
commitc8704fcf1e4c9699953ee8853703820bcf8c0e00 (patch)
treec97d3315ed3f456d3021786d899abfa654548d5f
parent3ec45e3d11e353e98a0d6d639ab9ec900cfef59e (diff)
downloadeclipse.jdt.core-c8704fcf1e4c9699953ee8853703820bcf8c0e00.tar.gz
eclipse.jdt.core-c8704fcf1e4c9699953ee8853703820bcf8c0e00.tar.xz
eclipse.jdt.core-c8704fcf1e4c9699953ee8853703820bcf8c0e00.zip
Bug 539698 - JavaSearchNameEnvironment disable module operation in <1.9
This change disables parts of JavaSearchNameEnvironment.mapToClassPathLocation(), if the respective project has compliance level of Java 1.8 or lower. This is done to reduce impact of Java 1.9 module related changes for Java 1.8 users, such as potential bugs and performance drops. Change-Id: Ie2c68497b52da77c391d6da995f519e9cff5cd5a Signed-off-by: Simeon Andreev <simeon.danailov.andreev@gmail.com>
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchNameEnvironment.java17
1 files changed, 15 insertions, 2 deletions
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchNameEnvironment.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchNameEnvironment.java
index 4aae053a23..a61e40abd2 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchNameEnvironment.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchNameEnvironment.java
@@ -70,7 +70,7 @@ public class JavaSearchNameEnvironment implements IModuleAwareNameEnvironment, S
Map<String, org.eclipse.jdt.core.ICompilationUnit> workingCopies;
public JavaSearchNameEnvironment(IJavaProject javaProject, org.eclipse.jdt.core.ICompilationUnit[] copies) {
- if (CompilerOptions.versionToJdkLevel(javaProject.getOption(JavaCore.COMPILER_COMPLIANCE, true)) >= ClassFileConstants.JDK9) {
+ if (isComplianceJava9OrHigher(javaProject)) {
this.moduleLocations = new HashMap<>();
this.moduleToClassPathLocations = new HashMap<>();
}
@@ -185,6 +185,13 @@ private ClasspathLocation mapToClassPathLocation(JavaModelManager manager, Packa
// problem opening zip file or getting root kind
// consider root corrupt and ignore
}
+ if (isComplianceJava9OrHigher(root.getJavaProject())) {
+ addModuleClassPathInfo(root, defaultModule, cp);
+ }
+ return cp;
+}
+
+private void addModuleClassPathInfo(PackageFragmentRoot root, IModuleDescription defaultModule, ClasspathLocation cp) {
IModuleDescription imd = root.getModuleDescription();
if (imd != null) {
String moduleName = addModuleClassPathInfo(cp, imd);
@@ -195,7 +202,6 @@ private ClasspathLocation mapToClassPathLocation(JavaModelManager manager, Packa
} else if (defaultModule != null) {
addModuleClassPathInfo(cp, defaultModule);
}
- return cp;
}
private String addModuleClassPathInfo(ClasspathLocation cp, IModuleDescription imd) {
IModule mod = NameLookup.getModuleDescriptionInfo(imd);
@@ -396,4 +402,11 @@ public char[][] getAllAutomaticModules() {
.map(m -> m.name()).collect(Collectors.toSet());
return set.toArray(new char[set.size()][]);
}
+
+private static boolean isComplianceJava9OrHigher(IJavaProject javaProject) {
+ if (javaProject == null) {
+ return false;
+ }
+ return CompilerOptions.versionToJdkLevel(javaProject.getOption(JavaCore.COMPILER_COMPLIANCE, true)) >= ClassFileConstants.JDK9;
+}
}

Back to the top