Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

fixed determineJava11OrLater #808

Merged
merged 1 commit into from May 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -62,8 +62,13 @@ public static boolean isJava11OrLater() {
private static boolean determineJava11OrLater() {
String javaVersion = System.getProperty("java.version");
try {
int version = Integer.parseInt(javaVersion);
return version >= 11;
Pattern p = Pattern.compile("(\\d+)(.)*");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively we could check CharSequence.class.getMethod(..) and catch NoSuchMethod.

Matcher matcher = p.matcher(javaVersion);
if (matcher.matches()) {
String first = matcher.group(1);
int version = Integer.parseInt(first);
return version >= 11;
}
} catch (NumberFormatException e) {
// ok
}
Expand Down
Expand Up @@ -7,6 +7,9 @@
*******************************************************************************/
package org.eclipse.xtend.ide.tests;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
Expand Down Expand Up @@ -45,8 +48,13 @@ public static boolean isJava11OrLater() {
private static boolean determineJava11OrLater() {
String javaVersion = System.getProperty("java.version");
try {
int version = Integer.parseInt(javaVersion);
return version >= 11;
Pattern p = Pattern.compile("(\\d+)(.)*");
Matcher matcher = p.matcher(javaVersion);
if (matcher.matches()) {
String first = matcher.group(1);
int version = Integer.parseInt(first);
return version >= 11;
}
} catch (NumberFormatException e) {
// ok
}
Expand Down