diff options
author | Stephan Herrmann | 2018-08-13 08:26:36 +0000 |
---|---|---|
committer | Stephan Herrmann | 2018-08-13 08:26:36 +0000 |
commit | 64a4230ba343028e55ac0adb1bdb5ba92cc9bb8a (patch) | |
tree | 825ce25ff12044e5eb429c8fd338b9ebaf6d05af | |
parent | d9427fb00c61d1e59c9a217f96de43d0bc551f7c (diff) | |
download | eclipse.jdt.core-64a4230ba343028e55ac0adb1bdb5ba92cc9bb8a.tar.gz eclipse.jdt.core-64a4230ba343028e55ac0adb1bdb5ba92cc9bb8a.tar.xz eclipse.jdt.core-64a4230ba343028e55ac0adb1bdb5ba92cc9bb8a.zip |
Bug 536706 - [tests] Failures in mac after moving to new test machineI20180814-0910I20180814-0900I20180813-2000
- sysout for jre-detection
- during javac comparison still use the current runtime
- register a few more 1.8.0_x versions
Change-Id: I1750cd50d394b61d42b07a2415808ebd90ccd2fd
2 files changed, 50 insertions, 21 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java index 96362653de..d1d5a80bee 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java @@ -234,26 +234,7 @@ static class JavacCompiler { if (rawVersion == null) { rawVersion = getVersion(this.javacPathName); } - if (rawVersion.indexOf("1.4") != -1 || - this.javacPathName.indexOf("1.4") != -1 - /* in fact, SUN javac 1.4 does not support the -version option; - * this is a imperfect heuristic to catch the case */) { - this.version = JavaCore.VERSION_1_4; - } else if (rawVersion.indexOf("1.5") != -1) { - this.version = JavaCore.VERSION_1_5; - } else if (rawVersion.indexOf("1.6") != -1) { - this.version = JavaCore.VERSION_1_6; - } else if (rawVersion.indexOf("1.7") != -1) { - this.version = JavaCore.VERSION_1_7; - } else if (rawVersion.indexOf("1.8") != -1) { - this.version = JavaCore.VERSION_1_8; - } else if(rawVersion.startsWith("9")) { - this.version = JavaCore.VERSION_9; - } else if(rawVersion.startsWith("10")) { - this.version = JavaCore.VERSION_10; - } else { - throw new RuntimeException("unknown javac version: " + rawVersion); - } + this.version = versionFromRawVersion(rawVersion, this.javacPathName); this.compliance = CompilerOptions.versionToJdkLevel(this.version); this.minor = minorFromRawVersion(this.version, rawVersion); this.rawVersion = rawVersion; @@ -289,6 +270,29 @@ static class JavacCompiler { } } } + static String versionFromRawVersion(String rawVersion, String javacPathName) { + if (rawVersion.indexOf("1.4") != -1 || + (javacPathName != null && + javacPathName.indexOf("1.4") != -1) + /* in fact, SUN javac 1.4 does not support the -version option; + * this is a imperfect heuristic to catch the case */) { + return JavaCore.VERSION_1_4; + } else if (rawVersion.indexOf("1.5") != -1) { + return JavaCore.VERSION_1_5; + } else if (rawVersion.indexOf("1.6") != -1) { + return JavaCore.VERSION_1_6; + } else if (rawVersion.indexOf("1.7") != -1) { + return JavaCore.VERSION_1_7; + } else if (rawVersion.indexOf("1.8") != -1) { + return JavaCore.VERSION_1_8; + } else if(rawVersion.startsWith("9")) { + return JavaCore.VERSION_9; + } else if(rawVersion.startsWith("10")) { + return JavaCore.VERSION_10; + } else { + throw new RuntimeException("unknown javac version: " + rawVersion); + } + } // projects known raw versions to minors; minors should grow with time, so // that before and after relationships be easy to implement upon compilers // of the same version; two latest digits are used for variants into levels @@ -349,6 +353,18 @@ static class JavacCompiler { if ("1.8.0_162".equals(rawVersion)) { return 2100; } + if ("1.8.0_171".equals(rawVersion)) { + return 2200; + } + if ("1.8.0_172".equals(rawVersion)) { + return 2300; + } + if ("1.8.0_181".equals(rawVersion)) { + return 2400; + } + if ("1.8.0_182".equals(rawVersion)) { + return 2500; + } } if (version == JavaCore.VERSION_9) { if ("9".equals(rawVersion)) { @@ -436,6 +452,18 @@ static class JavaRuntime { } return cached; } + public static JavaRuntime fromCurrentVM() throws IOException, InterruptedException { + String rawVersion = System.getProperty("java.version"); + JavaRuntime cached = (JavaRuntime) runtimes.get(rawVersion); + if (cached == null) { + String jreRootDirPath = Util.getJREDirectory(); + String version = JavacCompiler.versionFromRawVersion(rawVersion, jreRootDirPath); + int minor = JavacCompiler.minorFromRawVersion(version, rawVersion); + cached = new JavaRuntime(jreRootDirPath, version, rawVersion, minor); + runtimes.put(rawVersion, cached); + } + return cached; + } private JavaRuntime(String rootDirectoryPath, String version, String rawVersion, int minor) throws IOException, InterruptedException { this.rootDirectoryPath = rootDirectoryPath; this.javaPathName = new File(this.rootDirectoryPath + File.separator @@ -2215,7 +2243,7 @@ protected void runJavac( if ((expectedOutputString != null || expectedErrorString != null) && !javacTestErrorFlag && mismatch == 0 && sourceFileNames != null && !className.endsWith(PACKAGE_INFO_NAME) && !className.endsWith(MODULE_INFO_NAME)) { - JavaRuntime runtime = JavaRuntime.runtimeFor(compiler); + JavaRuntime runtime = JavaRuntime.fromCurrentVM(); StringBuffer stderr = new StringBuffer(); StringBuffer stdout = new StringBuffer(); String vmOptions = ""; diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java index 8ddc3fa9f7..d73df43e0a 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java @@ -51,6 +51,7 @@ public class GenericTypeTest extends AbstractComparableTest { } else { throw new IllegalStateException("Unrecognized Java version: "+version); } + System.out.println("NESTED_CLASS_USE_DOLLAR="+NESTED_CLASS_USE_DOLLAR+" based on version="+version); } } |