mirror of
https://gitee.com/zhangsken/AndroidIDE.git
synced 2026-10-16 07:49:44 +08:00
fix: remove unnecessary reflective access in JavacConfigProvider
This commit is contained in:
+3
-33
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user