diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2021-10-22 09:54:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-22 09:54:12 +0200 |
commit | 341c458f108d4bb207e32c6e61647ca673526a6e (patch) | |
tree | f65f76f8c838a73f5f91f8efe0811c6b019857bb /test/core/src/lombok/RunTestsViaEcj.java | |
parent | 13d84b129e562fdc71b049778c3b3bd2376e29a4 (diff) | |
parent | 553b25addde4fab136258f7718e274a98bfbe34a (diff) | |
download | lombok-341c458f108d4bb207e32c6e61647ca673526a6e.tar.gz lombok-341c458f108d4bb207e32c6e61647ca673526a6e.tar.bz2 lombok-341c458f108d4bb207e32c6e61647ca673526a6e.zip |
Merge pull request #3007 from Rawi01/eclipse-junit
Resolve var/val only once in eclipse
Diffstat (limited to 'test/core/src/lombok/RunTestsViaEcj.java')
-rw-r--r-- | test/core/src/lombok/RunTestsViaEcj.java | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/test/core/src/lombok/RunTestsViaEcj.java b/test/core/src/lombok/RunTestsViaEcj.java index afba8c7f..6137de49 100644 --- a/test/core/src/lombok/RunTestsViaEcj.java +++ b/test/core/src/lombok/RunTestsViaEcj.java @@ -64,9 +64,22 @@ import org.osgi.framework.BundleContext; public class RunTestsViaEcj extends AbstractRunTests { protected CompilerOptions ecjCompilerOptions() { CompilerOptions options = new CompilerOptions(); - options.complianceLevel = Eclipse.getLatestEcjCompilerVersionConstant(); - options.sourceLevel = Eclipse.getLatestEcjCompilerVersionConstant(); - options.targetJDK = Eclipse.getLatestEcjCompilerVersionConstant(); + Map<String, String> warnings = new HashMap<String, String>(); + + String javaVersionString = System.getProperty("compiler.compliance.level"); + long ecjCompilerVersionConstant = Eclipse.getLatestEcjCompilerVersionConstant(); + long ecjCompilerVersion = Eclipse.getEcjCompilerVersion(); + if (javaVersionString != null) { + long javaVersion = Long.parseLong(javaVersionString); + ecjCompilerVersionConstant = (javaVersion + 44) << 16; + ecjCompilerVersion = javaVersion; + } else { + // Preview features are only allowed if the maximum compiler version is equal to the source version + warnings.put("org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures", "enabled"); + } + options.complianceLevel = ecjCompilerVersionConstant; + options.sourceLevel = ecjCompilerVersionConstant; + options.targetJDK = ecjCompilerVersionConstant; options.docCommentSupport = false; options.parseLiteralExpressionsAsConstants = true; options.inlineJsrBytecode = true; @@ -78,17 +91,14 @@ public class RunTestsViaEcj extends AbstractRunTests { options.reportUnusedParameterWhenOverridingConcrete = false; options.reportDeadCodeInTrivialIfStatement = false; options.generateClassFiles = false; - Map<String, String> warnings = new HashMap<String, String>(); warnings.put(CompilerOptions.OPTION_ReportUnusedLocal, "ignore"); warnings.put(CompilerOptions.OPTION_ReportUnusedLabel, "ignore"); warnings.put(CompilerOptions.OPTION_ReportUnusedImport, "ignore"); warnings.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, "ignore"); warnings.put(CompilerOptions.OPTION_ReportIndirectStaticAccess, "warning"); warnings.put(CompilerOptions.OPTION_ReportNonStaticAccessToStatic, "warning"); - warnings.put("org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures", "enabled"); warnings.put("org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures", "ignore"); - int ecjVersion = Eclipse.getEcjCompilerVersion(); - warnings.put(CompilerOptions.OPTION_Source, (ecjVersion < 9 ? "1." : "") + ecjVersion); + warnings.put(CompilerOptions.OPTION_Source, (ecjCompilerVersion < 9 ? "1." : "") + ecjCompilerVersion); options.set(warnings); return options; } @@ -96,7 +106,7 @@ public class RunTestsViaEcj extends AbstractRunTests { protected IErrorHandlingPolicy ecjErrorHandlingPolicy() { return new IErrorHandlingPolicy() { public boolean stopOnFirstError() { - return true; + return false; } public boolean proceedOnErrors() { |