From b518dd30c4a045621f7a7e8c3b38ebedefb4cd09 Mon Sep 17 00:00:00 2001 From: "Jan S." Date: Sun, 26 May 2024 19:21:00 +0200 Subject: [PATCH] use JavaCore.latestSupportedJavaVersion and AST.getJLSLatest() if available --- .../decompiler/util/DecompilerOutputUtil.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/DecompilerOutputUtil.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/DecompilerOutputUtil.java index d7019040..2874360f 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/DecompilerOutputUtil.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/DecompilerOutputUtil.java @@ -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 allVersions = new LinkedList<>(JavaCore.getAllVersions()); @@ -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()) { @@ -816,6 +833,8 @@ public static int getMaxJSLLevel() { } } jslLevel = maxFieldValue; + AST.getJLSLatest(); + return jslLevel; } }