diff options
| author | Jay Arthanareeswaran | 2017-08-07 10:52:40 +0000 |
|---|---|---|
| committer | Jay Arthanareeswaran | 2017-08-07 10:52:40 +0000 |
| commit | 6af4a0a291a362228d60748995c15e8fd3464cbc (patch) | |
| tree | 3b560c5d70e6d501e82cce01771bed64f2c48094 | |
| parent | 2200a415a222e363ef80aa74c9e6c21e7c5413d5 (diff) | |
| download | eclipse.jdt.core-6af4a0a291a362228d60748995c15e8fd3464cbc.tar.gz eclipse.jdt.core-6af4a0a291a362228d60748995c15e8fd3464cbc.tar.xz eclipse.jdt.core-6af4a0a291a362228d60748995c15e8fd3464cbc.zip | |
Bug 415860 - [1.8][compiler] EclipseCompiler should not hard code
compliance level
Change-Id: Iaeba374dcdcca8b2eba55ba0d0d6e2cfb1319a69
Signed-off-by: Jay Arthanareeswaran <jarthana@in.ibm.com>
3 files changed, 24 insertions, 10 deletions
diff --git a/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerInvocationTests.java b/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerInvocationTests.java index 35ebe2cc28..a2f7590a53 100644 --- a/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerInvocationTests.java +++ b/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerInvocationTests.java @@ -1,10 +1,14 @@ /******************************************************************************* - * Copyright (c) 2008, 2014 IBM Corporation and others. + * Copyright (c) 2008, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * + * This is an implementation of an early-draft specification developed under the Java + * Community Process (JCP) and is made available for testing and evaluation purposes + * only. The code is not compatible with any specification of the JCP. + * * Contributors: * IBM Corporation - initial API and implementation * IBM Corporation - fix for 342936 @@ -83,10 +87,13 @@ void runTest( String expectedErrOutputString, boolean shouldFlushOutputDirectory, String[] classFileNames) { + List<String> opt = options == null ? new ArrayList<>() : new ArrayList<>(options); + opt.add("-source"); + opt.add("1.6"); super.runTest( shouldCompileOK, sourceFiles, - new CompilerInvocationTestsArguments(standardJavaFileManager, options, compileFileNames), + new CompilerInvocationTestsArguments(standardJavaFileManager, opt, compileFileNames), expectedOutOutputString, expectedErrOutputString, shouldFlushOutputDirectory, diff --git a/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerToolTests.java b/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerToolTests.java index 23a9f53a4b..3f93295ed3 100644 --- a/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerToolTests.java +++ b/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerToolTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2014 IBM Corporation and others. + * Copyright (c) 2006, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -462,7 +462,8 @@ static final String[] FAKE_ZERO_ARG_OPTIONS = new String[] { assertTrue("Should not happen", false); } assertNotNull("No reader", reader); - assertEquals("Wrong value", ClassFileConstants.JDK1_6, reader.getVersion()); + // This needs fix. This test case by design will produce different output every compiler version. + assertEquals("Wrong value", ClassFileConstants.JDK9, reader.getVersion()); // check that the .class file exist for X assertTrue("delete failed", inputFile.delete()); } diff --git a/org.eclipse.jdt.compiler.tool/src/org/eclipse/jdt/internal/compiler/tool/EclipseCompiler.java b/org.eclipse.jdt.compiler.tool/src/org/eclipse/jdt/internal/compiler/tool/EclipseCompiler.java index 60a7f06df6..65801d2276 100644 --- a/org.eclipse.jdt.compiler.tool/src/org/eclipse/jdt/internal/compiler/tool/EclipseCompiler.java +++ b/org.eclipse.jdt.compiler.tool/src/org/eclipse/jdt/internal/compiler/tool/EclipseCompiler.java @@ -1,10 +1,14 @@ /******************************************************************************* - * Copyright (c) 2006, 2015 IBM Corporation and others. + * Copyright (c) 2006, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * + * This is an implementation of an early-draft specification developed under the Java + * Community Process (JCP) and is made available for testing and evaluation purposes + * only. The code is not compatible with any specification of the JCP. + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -46,9 +50,11 @@ public class EclipseCompiler implements JavaCompiler { private static Set<SourceVersion> SupportedSourceVersions; static { // Eclipse compiler supports all possible versions from version 0 to - // version 6 + // version 8 // we don't care about the order - EnumSet<SourceVersion> enumSet = EnumSet.range(SourceVersion.RELEASE_0, SourceVersion.RELEASE_6); + // TODO: At the moment, we can't have RELEASE_9 here because Eclipse must still be able to run on JRE 8 + // Come up with a better way to return the version constants. + EnumSet<SourceVersion> enumSet = EnumSet.range(SourceVersion.RELEASE_0, SourceVersion.RELEASE_8); // we don't want anybody to modify this list EclipseCompiler.SupportedSourceVersions = Collections.unmodifiableSet(enumSet); } @@ -114,9 +120,9 @@ public class EclipseCompiler implements JavaCompiler { eclipseCompiler2.fileManager = this.getStandardFileManager(someDiagnosticListener, null, null); } - eclipseCompiler2.options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6); - eclipseCompiler2.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6); - eclipseCompiler2.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6); + eclipseCompiler2.options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_9); + eclipseCompiler2.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_9); + eclipseCompiler2.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_9); ArrayList<String> allOptions = new ArrayList<>(); if (options != null) { |
