Skip to content

Commit

Permalink
Fix detection of minimum support version for javac
Browse files Browse the repository at this point in the history
  • Loading branch information
xxDark committed Jan 7, 2022
1 parent 6340a6d commit 4a72119
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,13 @@ public static JavacTargetVersion getMinJavacSupport() {
try {
Class<?> cls = Class.forName("com.sun.tools.javac.jvm.Target");
Field min = cls.getDeclaredField("MIN");
min.setAccessible(true);
Object minTargetInstance = min.get(null);
Field version = cls.getDeclaredField("majorVersion");
version.setAccessible(true);
return fromClassMajor(version.getInt(minTargetInstance));
} catch (Exception ex) {
Log.error("Failed to find javac minimum supported version, defaulting to Java 7");
Log.error(ex, "Failed to find javac minimum supported version, defaulting to Java 7");
}
return V7;
}
Expand Down

0 comments on commit 4a72119

Please # to comment.