fix: remove unnecessary reflective access in JavacConfigProvider

This commit is contained in:
Akash Yadav
2023-02-22 20:34:52 +05:30
parent 282a363587
commit eeaed54edc
@@ -14,48 +14,18 @@ public class JavacConfigProvider {
/**
* The latest source version that can be modeled.
*/
private static SourceVersion latestSourceVersion;
private static SourceVersion latestSourceVersion = SourceVersion.RELEASE_17;
/**
* The latest source version supported by the compiler.
*/
private static SourceVersion latestSupportedSourceVersion;
private static SourceVersion latestSupportedSourceVersion = latestSourceVersion;
/**
* Whether Java 9+ modules are enabled.
*/
private static boolean modulesEnabled = true;
static {
try {
Field latest = tryGetRelease("RELEASE_17");
if (latest == null) {
latest = tryGetRelease("RELEASE_11");
}
if (latest == null) {
latest = tryGetRelease("RELEASE_8");
}
if (latest == null) {
throw new IllegalStateException();
}
latestSourceVersion = (SourceVersion)latest.get(null);
latestSupportedSourceVersion = latestSourceVersion;
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
static Field tryGetRelease(String release) {
try {
return SourceVersion.class.getDeclaredField(release);
} catch (NoSuchFieldException e) {
return null;
}
}
/**
* Gets the <code>androidide.java.home</code> property if it has been specified
* else fallbacks to the <code>java.home</code> property.