From 3fdfb39a3f2cf3752dd73e49bf9ade7f95184317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=8A?= =?UTF-8?q?=D1=80=20=D0=9A=D1=83=D1=80=D1=82=D0=B0=D0=BA=D0=BE=D0=B2?= Date: Wed, 19 Jun 2024 13:19:38 +0300 Subject: [PATCH] Prototype for https://github.com/eclipse-jdt/eclipse.jdt.ui/issues/1448 --- .../ui/wizards/buildpaths/BuildPathSupport.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildPathSupport.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildPathSupport.java index dec4fe716b6..04e3802c5fa 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildPathSupport.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildPathSupport.java @@ -39,6 +39,7 @@ import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.eclipse.jdt.internal.corext.util.JavaModelUtil; import org.eclipse.jdt.internal.corext.util.Messages; @@ -422,6 +423,16 @@ public static Map getEEOptions(IExecutionEnvironment ee) { String complianceOption= eeOptions.get(JavaCore.COMPILER_COMPLIANCE); if (complianceOption == null) return null; + String latestCompilerVersion= CompilerOptions.getLatestVersion(); + if (Integer.parseInt(latestCompilerVersion) < Integer.parseInt(complianceOption)) { + eeOptions.put(JavaCore.COMPILER_COMPLIANCE, latestCompilerVersion); + if(eeOptions.containsKey(JavaCore.COMPILER_SOURCE)) { + eeOptions.put(JavaCore.COMPILER_SOURCE, latestCompilerVersion); + } + if(eeOptions.containsKey(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM)) { + eeOptions.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, latestCompilerVersion); + } + } // eeOptions can miss some options, make sure they are complete: HashMap options= new HashMap<>();