Skip to content

Commit

Permalink
[SPARK-13278][CORE] Launcher fails to start with JDK 9 EA
Browse files Browse the repository at this point in the history
  • Loading branch information
cl4es committed Feb 10, 2016
1 parent 5947fa8 commit 0da18a6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,9 @@ static void addPermGenSizeOpt(List<String> cmd) {
if (getJavaVendor() == JavaVendor.IBM) {
return;
}
String[] version = System.getProperty("java.version").split("\\.");
if (Integer.parseInt(version[0]) > 1 || Integer.parseInt(version[1]) > 7) {
if (javaMajorVersion(System.getProperty("java.version")) > 7) {
return;
}

for (String arg : cmd) {
if (arg.startsWith("-XX:MaxPermSize=")) {
return;
Expand All @@ -336,4 +334,18 @@ static void addPermGenSizeOpt(List<String> cmd) {
cmd.add("-XX:MaxPermSize=256m");
}

/**
* Get the major version of the java.version string supplied.
*/
static int javaMajorVersion(String javaVersion) {
String[] version = javaVersion.split("[+.\\-]+");
int major = Integer.parseInt(version[0]);
// if major > 1, we're using the JEP-223 version string, e.g., 9-ea, 9+120
// otherwise the second number is the major version
if (major > 1) {
return major;
} else {
return Integer.parseInt(version[1]);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,18 @@ public void testPythonArgQuoting() {
assertEquals("\"a \\\"b\\\" c\"", quoteForCommandString("a \"b\" c"));
}

@Test
public void testJavaMajorVersion() {
assertEquals(6, javaMajorVersion("1.6.0_50"));
assertEquals(7, javaMajorVersion("1.7.0_79"));
assertEquals(8, javaMajorVersion("1.8.0_66"));
assertEquals(9, javaMajorVersion("9-ea"));
assertEquals(9, javaMajorVersion("9+100"));
assertEquals(9, javaMajorVersion("9"));
assertEquals(9, javaMajorVersion("9.1.0"));
assertEquals(10, javaMajorVersion("10"));
}

private void testOpt(String opts, List<String> expected) {
assertEquals(String.format("test string failed to parse: [[ %s ]]", opts),
expected, parseOptionString(opts));
Expand Down

0 comments on commit 0da18a6

Please sign in to comment.