Skip to content

Commit 5c98f08

Browse files
authored
Parse complex Java version strings (#16)
Extract the major version even when followed by "early release" markers. Fixes #15.
1 parent 3ed60dd commit 5c98f08

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

JythonCli.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,10 @@ public class JythonCli {
6262
*/
6363
static String getJvmMajorVersion() {
6464
String version = System.getProperty("java.version");
65-
String major = "";
6665
if (version.startsWith("1.")) {
67-
major = version.substring(2, 3);
68-
} else {
69-
int dotIndex = version.indexOf(".");
70-
if (dotIndex != -1) {
71-
major = version.substring(0, dotIndex);
72-
} else {
73-
major = version;
74-
}
66+
version = version.substring(2);
7567
}
76-
return major;
68+
return version.replaceAll("(\\d+).+", "$1");
7769
}
7870

7971
/**

0 commit comments

Comments
 (0)