From eeaed54edc449a8328415441fbed4cd78d0e6e7a Mon Sep 17 00:00:00 2001 From: Akash Yadav Date: Wed, 22 Feb 2023 20:34:52 +0530 Subject: [PATCH] fix: remove unnecessary reflective access in JavacConfigProvider --- .../config/JavacConfigProvider.java | 36 ++----------------- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/subprojects/java-compiler/src/main/java/com/itsaky/androidide/config/JavacConfigProvider.java b/subprojects/java-compiler/src/main/java/com/itsaky/androidide/config/JavacConfigProvider.java index cc9966107..a8ca4ae13 100644 --- a/subprojects/java-compiler/src/main/java/com/itsaky/androidide/config/JavacConfigProvider.java +++ b/subprojects/java-compiler/src/main/java/com/itsaky/androidide/config/JavacConfigProvider.java @@ -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 androidide.java.home property if it has been specified * else fallbacks to the java.home property.