Skip to content

Commit

Permalink
Fix version parsing for jdk10.
Browse files Browse the repository at this point in the history
  • Loading branch information
rspilker committed Feb 6, 2018
1 parent 2f1069e commit 9ecfe23
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/utils/lombok/javac/Javac.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ private Javac() {
/** Matches any of the 8 primitive names, such as {@code boolean}. */
private static final Pattern PRIMITIVE_TYPE_NAME_PATTERN = Pattern.compile("^(boolean|byte|short|int|long|float|double|char)$");

private static final Pattern VERSION_PARSER = Pattern.compile("^(\\d{1,6})\\.(\\d{1,6}).*$");
private static final Pattern SOURCE_PARSER = Pattern.compile("^JDK(\\d{1,6})_(\\d{1,6}).*$");
private static final Pattern VERSION_PARSER = Pattern.compile("^(\\d{1,6})\\.?(\\d{1,6})?.*$");
private static final Pattern SOURCE_PARSER = Pattern.compile("^JDK(\\d{1,6})_?(\\d{1,6})?.*$");

private static final AtomicInteger compilerVersion = new AtomicInteger(-1);

Expand All @@ -79,11 +79,11 @@ public static int getJavaCompilerVersion() {
Matcher m = VERSION_PARSER.matcher(JavaCompiler.version());
if (m.matches()) {
int major = Integer.parseInt(m.group(1));
int minor = Integer.parseInt(m.group(2));
if (major == 1) {
compilerVersion.set(minor);
return minor;
int minor = Integer.parseInt(m.group(2));
return setVersion(minor);
}
if (major >= 9) return setVersion(major);
}
}

Expand All @@ -92,16 +92,19 @@ public static int getJavaCompilerVersion() {
Matcher m = SOURCE_PARSER.matcher(name);
if (m.matches()) {
int major = Integer.parseInt(m.group(1));
int minor = Integer.parseInt(m.group(2));
if (major == 1) {
compilerVersion.set(minor);
return minor;
int minor = Integer.parseInt(m.group(2));
return setVersion(minor);
}
if (major >= 9) return setVersion(major);
}
}

compilerVersion.set(6);
return 6;
return setVersion(6);
}

private static int setVersion(int version) {
compilerVersion.set(version);
return version;
}

private static final Class<?> DOCCOMMENTTABLE_CLASS;
Expand Down

0 comments on commit 9ecfe23

Please sign in to comment.