Skip to content

Commit

Permalink
use JavaCore.latestSupportedJavaVersion and AST.getJLSLatest() if
Browse files Browse the repository at this point in the history
available
  • Loading branch information
jpstotz committed May 26, 2024
1 parent 0b26602 commit b518dd3
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,14 @@ public static String getMaxDecompileLevel() {
return level;
}

// replacement for newer Eclipse versions
// return JavaCore.latestSupportedJavaVersion();
Object obj = ReflectionUtils.invokeMethod(JavaCore.class, "latestSupportedJavaVersion");
if (obj != null) {
level = (String) obj;
return level;
}

// filter oot all versions that are not a simple integers e.g. "9" "10" ...
Pattern p = Pattern.compile("^\\d+$");
List<String> allVersions = new LinkedList<>(JavaCore.getAllVersions());
Expand Down Expand Up @@ -800,6 +808,15 @@ public static int getMaxJSLLevel() {
if (jslLevel != -1) {
return jslLevel;
}

// replacement for newer Eclipse versions
// return AST.getJLSLatest();
Object obj = ReflectionUtils.invokeMethod(AST.class, "getJLSLatest");
if (obj != null) {
jslLevel = (Integer) obj;
return jslLevel;
}

Pattern p = Pattern.compile("^JLS\\d+$");
int maxFieldValue = 8; // Java 8 is supported by all Eclipse versions ECD targets
for (Field f : AST.class.getFields()) {
Expand All @@ -816,6 +833,8 @@ public static int getMaxJSLLevel() {
}
}
jslLevel = maxFieldValue;
AST.getJLSLatest();

return jslLevel;
}
}

0 comments on commit b518dd3

Please sign in to comment.