Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.jdt.core.tests.compiler/pom.xml2
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest10.java88
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java32
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java7
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java2
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java31
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java6
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JEP286ReservedWordTest.java172
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JEP286Test.java792
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JSR335ClassFileTest.java10
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LambdaExpressionsTest.java8
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodParametersAttributeTest.java12
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NonFatalErrorTest.java47
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java43
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SerializableLambdaTest.java4
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java23
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/dom/StandAloneASTParserTest.java40
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/TestCase.java13
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/LocalVMLauncher.java3
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java51
-rw-r--r--org.eclipse.jdt.core.tests.model/JCL/converterJclMin10.jarbin0 -> 14586 bytes
-rw-r--r--org.eclipse.jdt.core.tests.model/JCL/converterJclMin10src.zipbin0 -> 9140 bytes
-rw-r--r--org.eclipse.jdt.core.tests.model/JCL/jclMin10.jarbin0 -> 21072 bytes
-rw-r--r--org.eclipse.jdt.core.tests.model/JCL/jclMin10src.zipbin0 -> 8785 bytes
-rw-r--r--org.eclipse.jdt.core.tests.model/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.jdt.core.tests.model/pom.xml2
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunAllJava10Tests.java92
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter10Test.java150
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter9Test.java40
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTTest.java7
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/AbstractASTTests.java11
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ConverterTestSetup.java17
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/TypeAnnotationsConverterTest.java4
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java42
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java4
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests10.java354
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaConventionTests.java1
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java2
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs10Tests.java139
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java12
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NullAnnotationModelTests.java8
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java4
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/RunCompletionModelTests.java8
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/RunJavaSearchTests.java1
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeResolveTests.java130
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingTest.java13
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ImportRewriteTest.java6
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Converter10/.classpath6
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Converter10/.project17
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Converter10/src/X.java4
-rw-r--r--org.eclipse.jdt.core/.settings/.api_filters1057
-rw-r--r--org.eclipse.jdt.core/.settings/org.eclipse.pde.api.tools.prefs12
-rw-r--r--org.eclipse.jdt.core/META-INF/MANIFEST.MF5
-rw-r--r--org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java57
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java2
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java10
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java21
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Keywords.java10
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java19
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java41
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java5
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java61
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java167
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java6
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java11
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeParameter.java12
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java30
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java10
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java15
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java20
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/IntersectionTypeBinding18.java22
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java13
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java110
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java22
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java29
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java6
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java57
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java3
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java6
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java100
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties19
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java51
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java12
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTNode.java17
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTParser.java3
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java5
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SimpleType.java12
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Type.java18
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/rewrite/ImportRewrite.java4
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java8
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java1
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java1
-rw-r--r--org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java3
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java36
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/CompilationUnitSorter.java3
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java11
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyResourceElementsOperation.java4
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateElementInCUOperation.java4
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeMemberOperation.java6
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeleteElementsOperation.java4
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java6
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModularClassFile.java9
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java12
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Disassembler.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java6
-rw-r--r--org.eclipse.jdt.core/pom.xml4
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/AbstractOTJLDNullAnnotationTest.java2
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/AbstractOTJLDTest.java2
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/other/Java5.java10
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/regression/ReportedBugs.java2
114 files changed, 3442 insertions, 1248 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF b/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF
index cb05ce3d3..702a86e8f 100644
--- a/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.core.tests.compiler;singleton:=true
-Bundle-Version: 3.12.361.qualifier
+Bundle-Version: 3.12.411.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.jdt.core.tests.compiler,
@@ -28,3 +28,4 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Eclipse-BundleShape: dir
Bundle-Activator: org.eclipse.jdt.core.tests.compiler.Activator
Bundle-ActivationPolicy: lazy
+Automatic-Module-Name: org.eclipse.jdt.core.tests.compiler
diff --git a/org.eclipse.jdt.core.tests.compiler/pom.xml b/org.eclipse.jdt.core.tests.compiler/pom.xml
index 7e8a8ca95..9f6f725c4 100644
--- a/org.eclipse.jdt.core.tests.compiler/pom.xml
+++ b/org.eclipse.jdt.core.tests.compiler/pom.xml
@@ -20,7 +20,7 @@
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.core.tests.compiler</artifactId>
- <version>3.12.361-SNAPSHOT</version>
+ <version>3.12.411-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest10.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest10.java
new file mode 100644
index 000000000..04b6998bb
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest10.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2018 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Jesper Steen Møller <jesper@selskabet.org> - contributions for:
+ * Bug 531046: [10] ICodeAssist#codeSelect support for 'var'
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.parser;
+
+import org.eclipse.jdt.core.JavaModelException;
+
+import junit.framework.Test;
+
+public class SelectionParserTest10 extends AbstractSelectionTest {
+ static {
+ // TESTS_NUMBERS = new int[] { 1 };
+ // TESTS_NAMES = new String[] { "test001" };
+ }
+
+ public static Test suite() {
+ return buildMinimalComplianceTestSuite(SelectionParserTest10.class, F_10);
+ }
+
+ public SelectionParserTest10(String testName) {
+ super(testName);
+ }
+
+ public void test001() throws JavaModelException {
+ String string = "public class X {\n"
+ + " public static void main(String[] args) {\n"
+ + " var s_s = args[0];\n"
+ + " }\n"
+ + "}\n";
+
+ String selection = "s_s";
+ String expectedSelection = "<SelectionOnLocalName:var s_s = args[0]>;";
+
+ String completionIdentifier = "s_s";
+ String expectedUnitDisplayString = "public class X {\n" +
+ " public X() {\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " <SelectionOnLocalName:var s_s = args[0]>;\n" +
+ " }\n" +
+ "}\n";
+ String expectedReplacedSource = "s_s";
+ String testName = "X.java";
+
+ int selectionStart = string.lastIndexOf(selection);
+ int selectionEnd = string.lastIndexOf(selection) + selection.length() - 1;
+
+ checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
+ completionIdentifier, expectedReplacedSource, testName);
+ }
+
+ public void test002() throws JavaModelException {
+ String string = "public class X {\n"
+ + " public static void main(String[] args) {\n"
+ + " var s_s = args[0];\n"
+ + " }\n"
+ + "}\n";
+
+ String selection = "var";
+ String expectedSelection = "<SelectOnType:var>";
+
+ String completionIdentifier = "var";
+ String expectedUnitDisplayString = "public class X {\n" +
+ " public X() {\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " <SelectOnType:var> s_s = args[0];\n" +
+ " }\n" +
+ "}\n";
+ String expectedReplacedSource = "var";
+ String testName = "X.java";
+
+ int selectionStart = string.lastIndexOf(selection);
+ int selectionEnd = string.lastIndexOf(selection) + selection.length() - 1;
+
+ checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
+ completionIdentifier, expectedReplacedSource, testName);
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java
index 8b37f550a..3a9b9e006 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java
@@ -1,18 +1,26 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
+ * Jesper Steen Møller <jesper@selskabet.org> - Contributions for
+ * bug 527554 - [18.3] Compiler support for JEP 286 Local-Variable Type
+ *
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.parser;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.jdt.core.tests.compiler.regression.JEP286ReservedWordTest;
import org.eclipse.jdt.core.tests.junit.extension.TestCase;
import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
@@ -136,6 +144,26 @@ public static TestSuite getTestSuite(boolean addComplianceDiagnoseTest) {
TestCase.RUN_ONLY_ID = null;
all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.JDK9, tests_9));
}
+ if ((possibleComplianceLevels & AbstractCompilerTest.F_10) != 0) {
+ ArrayList tests_10 = (ArrayList)testClasses.clone();
+ tests_10.addAll(TEST_CLASSES_1_5);
+ tests_10.add(ParserTest1_7.class);
+ tests_10.add(LambdaExpressionSyntaxTest.class);
+ tests_10.add(ReferenceExpressionSyntaxTest.class);
+ tests_10.add(TypeAnnotationSyntaxTest.class);
+ tests_10.add(CompletionParserTest18.class);
+ tests_10.add(SelectionParserTest18.class);
+ tests_10.add(SelectionParserTest9.class);
+ tests_10.add(ModuleDeclarationSyntaxTest.class);
+ tests_10.add(JEP286ReservedWordTest.class);
+ // Reset forgotten subsets tests
+ TestCase.TESTS_PREFIX = null;
+ TestCase.TESTS_NAMES = null;
+ TestCase.TESTS_NUMBERS= null;
+ TestCase.TESTS_RANGE = null;
+ TestCase.RUN_ONLY_ID = null;
+ all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.JDK9, tests_10));
+ }
return all;
}
public static Test suite() {
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
index 92e0ceb06..f8fa37d5c 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
@@ -241,6 +241,8 @@ static class JavacCompiler {
this.version = JavaCore.VERSION_1_8;
} else if(rawVersion.startsWith("9")) {
this.version = JavaCore.VERSION_9;
+ } else if(rawVersion.startsWith("10")) {
+ this.version = JavaCore.VERSION_10;
} else {
throw new RuntimeException("unknown javac version: " + rawVersion);
}
@@ -334,6 +336,9 @@ static class JavacCompiler {
if (version == JavaCore.VERSION_9) {
return 0000; // We are still in EA
}
+ if (version == JavaCore.VERSION_10) {
+ return 0000; // We are still in EA
+ }
throw new RuntimeException("unknown raw javac version: " + rawVersion);
}
// returns 0L if everything went fine; else the lower word contains the
@@ -1066,6 +1071,8 @@ protected static class JavacTestOptions {
buffer.append("\" -1.8 " + processAnnot);
} else if (this.complianceLevel == ClassFileConstants.JDK9) {
buffer.append("\" -9 " + processAnnot);
+ } else if (this.complianceLevel == ClassFileConstants.JDK10) {
+ buffer.append("\" -10 " + processAnnot);
}
buffer
.append(" -preserveAllLocals -proceedOnError -nowarn -g -classpath \"")
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
index 1b74bc191..e5b295c91 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
@@ -12651,7 +12651,7 @@ public void test385780_warn_option() {
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=405225
public void test405225_extdirs() {
- if (AbstractCompilerTest.isJRE9)
+ if (AbstractCompilerTest.isJRE9Plus)
return;
this.runConformTest(
new String[] {
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
index 04a91cc01..73509b0c1 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
@@ -4,6 +4,10 @@
* 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
@@ -44,6 +48,7 @@
* bug 384567 - [1.5][compiler] Compiler accepts illegal modifiers on package declaration
* bug 412153 - [1.8][compiler] Check validity of annotations which may be repeatable
* bug 419209 - [1.8] Repeating container annotations should be rejected in the presence of annotation it contains
+ * bug 527554 - [18.3] Compiler support for JEP 286 Local-Variable Type
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -1144,6 +1149,19 @@ public void _test011_problem_categories() {
expectedProblemAttributes.put("UsingTerminallyDeprecatedSinceVersionField", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
expectedProblemAttributes.put("UsingTerminallyDeprecatedSinceVersionMethod", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
expectedProblemAttributes.put("UsingTerminallyDeprecatedSinceVersionType", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
+ expectedProblemAttributes.put("VarIsNotAllowedHere", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
+ expectedProblemAttributes.put("VarIsReserved", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
+ expectedProblemAttributes.put("VarIsReservedInFuture", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
+ expectedProblemAttributes.put("VarLocalCannotBeArray", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
+ expectedProblemAttributes.put("VarLocalCannotBeArrayInitalizers", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
+ expectedProblemAttributes.put("VarLocalCannotBeLambda", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
+ expectedProblemAttributes.put("VarLocalCannotBeMethodReference", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
+ expectedProblemAttributes.put("VarLocalInitializedToNull", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
+ expectedProblemAttributes.put("VarLocalInitializedToVoid", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
+ expectedProblemAttributes.put("VarLocalMultipleDeclarators", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
+ expectedProblemAttributes.put("VarLocalReferencesItself", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
+ expectedProblemAttributes.put("VarLocalCannotBeArray", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
+ expectedProblemAttributes.put("VarLocalWithoutInitizalier", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("VarargsElementTypeNotVisible", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("VarargsElementTypeNotVisibleForConstructor", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("VarargsConflict", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
@@ -2139,6 +2157,19 @@ public void test012_compiler_problems_tuning() {
expectedProblemAttributes.put("IllegalArrayOfUnionType", SKIP);
expectedProblemAttributes.put("IllegalArrayTypeInIntersectionCast", SKIP);
expectedProblemAttributes.put("ProblemNotAnalysed", SKIP);
+ expectedProblemAttributes.put("VarIsNotAllowedHere", SKIP);
+ expectedProblemAttributes.put("VarIsReserved", SKIP);
+ expectedProblemAttributes.put("VarIsReservedInFuture", SKIP);
+ expectedProblemAttributes.put("VarLocalCannotBeArray", SKIP);
+ expectedProblemAttributes.put("VarLocalCannotBeArrayInitalizers", SKIP);
+ expectedProblemAttributes.put("VarLocalCannotBeLambda", SKIP);
+ expectedProblemAttributes.put("VarLocalCannotBeMethodReference", SKIP);
+ expectedProblemAttributes.put("VarLocalInitializedToNull", SKIP);
+ expectedProblemAttributes.put("VarLocalInitializedToVoid", SKIP);
+ expectedProblemAttributes.put("VarLocalMultipleDeclarators", SKIP);
+ expectedProblemAttributes.put("VarLocalReferencesItself", SKIP);
+ expectedProblemAttributes.put("VarLocalTooManyBrackets", SKIP);
+ expectedProblemAttributes.put("VarLocalWithoutInitizalier", SKIP);
//{ObjectTeams: new constants:
expectedProblemAttributes.put("OTJ_RELATED", SKIP);
expectedProblemAttributes.put("OTCHAP", SKIP);
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
index 07dd703b1..aca0d295d 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
@@ -40282,7 +40282,7 @@ public void test1151() throws Exception {
"}\n"
},
//"java.lang.ref.Reference<X<java.lang.String>.Other<java.lang.Thread>.Deeply>##java.lang.ref.Reference<X<java.lang.String>.Other<java.lang.Thread>.Deeply$Inside<java.lang.Number>>"
- (isJRE9
+ (isJRE9Plus
? "java.lang.ref.Reference<X<java.lang.String>$Other<java.lang.Thread>$Deeply>"
: "java.lang.ref.Reference<X<java.lang.String>.Other<java.lang.Thread>.Deeply>")
);
@@ -40398,7 +40398,7 @@ public void test1153() {
"}\n"
},
"java.lang.ref.Reference<p.X$Rather$Deeply>##java.lang.ref.Reference<p.X$Rather>##java.lang.ref.Reference<p.X$Rather$Deeply$Inside>##"+
- (isJRE9
+ (isJRE9Plus
? "java.lang.ref.Reference<p.X<java.lang.String>$Other<java.lang.Thread>$Deeply>"
: "java.lang.ref.Reference<p.X<java.lang.String>.Other<java.lang.Thread>.Deeply>"),
null,
@@ -40480,7 +40480,7 @@ public void test1155() throws Exception {
" }\n" +
"}\n"
},
- (isJRE9
+ (isJRE9Plus
? "java.lang.ref.Reference<X<java.lang.String>$Other<java.lang.Thread>$Deeply>"
: "java.lang.ref.Reference<X<java.lang.String>.Other<java.lang.Thread>.Deeply>") );
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JEP286ReservedWordTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JEP286ReservedWordTest.java
new file mode 100644
index 000000000..354723e13
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JEP286ReservedWordTest.java
@@ -0,0 +1,172 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Jesper Steen Møller 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:
+ * Jesper Steen Møller - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.regression;
+
+import java.io.IOException;
+
+import org.eclipse.jdt.core.tests.util.CompilerTestSetup;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
+
+import junit.framework.Test;
+
+@SuppressWarnings({ "rawtypes" })
+public class JEP286ReservedWordTest extends AbstractRegressionTest {
+
+public static Class testClass() {
+ return JEP286ReservedWordTest.class;
+}
+public void initialize(CompilerTestSetup setUp) {
+ super.initialize(setUp);
+}
+public static Test suite() {
+ return buildMinimalComplianceTestSuite(testClass(), F_1_8);
+}
+
+public JEP286ReservedWordTest(String testName){
+ super(testName);
+}
+
+public void test0001_class_var_warning() throws IOException {
+ String classVar =
+ " public class var { public int a; };\n";
+
+ String classX =
+ "public class X {\n" +
+ classVar +
+ " +\n" +
+ "}\n";
+ String errorTail =
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " +\n" +
+ " ^\n" +
+ "Syntax error on token \"+\", delete this token\n" +
+ "----------\n";
+
+ if (this.complianceLevel == ClassFileConstants.JDK10) {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ classX
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ classVar +
+ " ^^^\n" +
+ "'var' is not a valid type name\n" +
+ errorTail);
+ } else {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ classX
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 2)\n" +
+ classVar +
+ " ^^^\n" +
+ "'var' should not be used as an type name, since it is a reserved word from source level 10 on\n" +
+ errorTail);
+ }
+}
+public void test0002_interface_var_warning() throws IOException {
+ String interfaceVar =
+ " interface var { };\n";
+
+ String classX =
+ "public class X {\n" +
+ interfaceVar +
+ " +\n" +
+ "}\n";
+ String errorTail =
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " +\n" +
+ " ^\n" +
+ "Syntax error on token \"+\", delete this token\n" +
+ "----------\n";
+
+ if (this.complianceLevel == ClassFileConstants.JDK10) {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ classX
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ interfaceVar +
+ " ^^^\n" +
+ "'var' is not a valid type name\n" +
+ errorTail);
+ } else {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ classX
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 2)\n" +
+ interfaceVar +
+ " ^^^\n" +
+ "'var' should not be used as an type name, since it is a reserved word from source level 10 on\n" +
+ errorTail);
+ }
+}
+public void testBug530920() throws IOException {
+ String classX = "public class X<var extends Number> { }\n";
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ classX
+ },
+ this.complianceLevel == ClassFileConstants.JDK10 ?
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X<var extends Number> { }\n" +
+ " ^^^\n" +
+ "'var' is not allowed here\n"
+ :
+ "----------\n" +
+ "1. WARNING in X.java (at line 1)\n" +
+ " public class X<var extends Number> { }\n" +
+ " ^^^\n" +
+ "'var' should not be used as an type name, since it is a reserved word from source level 10 on\n"
+ );
+}
+public void testBug530920a() throws IOException {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " <var extends Number> var getNumber() {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}"
+ },
+ this.complianceLevel == ClassFileConstants.JDK10 ?
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " <var extends Number> var getNumber() {\n" +
+ " ^^^\n" +
+ "'var' is not allowed here\n"
+ :
+ "----------\n" +
+ "1. WARNING in X.java (at line 2)\n" +
+ " <var extends Number> var getNumber() {\n" +
+ " ^^^\n" +
+ "'var' should not be used as an type name, since it is a reserved word from source level 10 on\n"
+ );
+}
+}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JEP286Test.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JEP286Test.java
new file mode 100644
index 000000000..20e5a1488
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JEP286Test.java
@@ -0,0 +1,792 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Jesper Steen Møller 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:
+ * Jesper Steen Møller - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.regression;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jdt.core.tests.util.CompilerTestSetup;
+import org.eclipse.jdt.internal.compiler.ASTVisitor;
+import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
+import org.junit.Assert;
+
+import junit.framework.Test;
+
+@SuppressWarnings({ "unchecked", "rawtypes" })
+public class JEP286Test extends AbstractRegressionTest {
+
+public static Class testClass() {
+ return JEP286Test.class;
+}
+public void initialize(CompilerTestSetup setUp) {
+ super.initialize(setUp);
+}
+public static Test suite() {
+ return buildMinimalComplianceTestSuite(testClass(), F_10);
+}
+
+public JEP286Test(String testName){
+ super(testName);
+}
+static {
+// TESTS_NAMES = new String[] { "test0018_project_variable_types" };
+}
+protected Map getCompilerOptions() {
+ Map options = super.getCompilerOptions();
+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_10);
+ options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_10);
+ options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_10);
+ return options;
+}
+private static final Map<String, String> simpleTypeNames = new HashMap<>();
+static {
+ simpleTypeNames.put("String", "java.lang.String");
+ simpleTypeNames.put("Object", "java.lang.Object");
+ simpleTypeNames.put("Bar", "X.Bar");
+
+ simpleTypeNames.put("AnonymousObjectSubclass", "new java.lang.Object(){}");
+ simpleTypeNames.put("AnonymousRunnableSubclass", "new java.lang.Runnable(){}");
+ simpleTypeNames.put("CollectionOfExtString", "Collection<? extends java.lang.String>");
+ simpleTypeNames.put("CollectionOfSuperString", "Collection<? super java.lang.String>");
+ simpleTypeNames.put("CollectionAny", "Collection<?>");
+ simpleTypeNames.put("ComparableAny", "Comparable<?>");
+ simpleTypeNames.put("CollectionExt_ComparableAny", "Collection<? extends Comparable<?>>");
+ simpleTypeNames.put("CollectionSuperComparableAny", "Collection<? super Comparable<?>>");
+ simpleTypeNames.put("IntLongFloat", "java.lang.Number&Comparable<?>");
+ simpleTypeNames.put("ListTestAndSerializable", "List<? extends Z & java.io.Serializable>");
+ simpleTypeNames.put("TestAndSerializable", "Z & java.io.Serializable");
+}
+
+static void assertInferredType(LocalDeclaration varDecl) {
+ String varName = new String(varDecl.name);
+ int underscoreIndex = varName.indexOf('_');
+ Assert.assertNotEquals(-1, underscoreIndex);
+ String typeNamePart = varName.substring(underscoreIndex+1);
+ typeNamePart = typeNamePart.replaceAll("ARRAY", "[]"); // So that we assume that x_intARRAY is of type int[]
+ String expectedTypeName = simpleTypeNames.getOrDefault(typeNamePart, typeNamePart);
+ String actualTypeName = varDecl.binding.type.debugName();
+ // System.out.println("For " + varName + ", we expect " + expectedTypeName + ", the type was: "
+ // + actualTypeName + " - " + (expectedTypeName.equals(actualTypeName) ? "❤️" : "🤡"));
+ Assert.assertEquals("Type of variable " + varName, expectedTypeName, actualTypeName);
+}
+
+// This visitor visits the 'testXxx' method in the visited classes, checking for expected types of local variables (using the debug name)
+private final static class InferredTypeVerifier extends ASTVisitor {
+ public int localsChecked = 0;
+ public InferredTypeVerifier() { }
+
+ @Override
+ public boolean visit(TypeDeclaration memberTypeDeclaration, ClassScope scope) {
+ return false; // Don't check Foo itself
+ }
+
+ @Override
+ public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
+ if (! new String(methodDeclaration.selector).startsWith("test")) return false;
+ return super.visit(methodDeclaration, scope);
+ }
+
+ @Override
+ public boolean visit(LocalDeclaration localDeclaration, BlockScope scope) {
+ assertInferredType(localDeclaration);
+ this.localsChecked++;
+ return super.visit(localDeclaration, scope);
+ }
+ }
+
+public void test0001_local_variable_inference() throws IOException {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " var x = \"SUCCESS\";\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "SUCCESS");
+}
+public void test0002_inferred_for() throws IOException {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " int sum = 0;\n" +
+ " for(var n = 1; n <= 2; ++n) {\n" +
+ " sum += n;\n" +
+ " }\n" +
+ " System.out.println(\"SUCCESS \" + sum);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "SUCCESS 3");
+}
+public void test0003_inferred_enhanced_for() throws IOException {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " int sum = 0;\n" +
+ " for(var n : java.util.List.of(1, 2)) {\n" +
+ " sum += n;\n" +
+ " }\n" +
+ " System.out.println(\"SUCCESS \" + sum);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "SUCCESS 3");
+}
+public void test0004_try_with_resources() throws IOException {
+ try(java.io.Writer w = new java.io.StringWriter()) {
+ w.write("SUCCESS!\n");
+ System.out.println(w.toString());
+ }
+
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String [] args) throws Exception {\n" +
+ " try(var w = new java.io.StringWriter()) {\n" +
+ " w.write(\"SUCCESS\\n\");" +
+ " System.out.println(w.toString());\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ },
+ "SUCCESS");
+}
+public void test0005_no_initializer() throws IOException {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] argv) {\n" +
+ " var a;\n" +
+ " for(var b;;);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " var a;\n" +
+ " ^\n" +
+ "Cannot use 'var' on variable without initializer\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " for(var b;;);\n" +
+ " ^\n" +
+ "Cannot use 'var' on variable without initializer\n" +
+ "----------\n");
+}
+public void test0006_multiple_declarators() throws IOException {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] argv) {\n" +
+ " var a = 1, b = 2;\n" +
+ " for(var c = 1, d = 20; c<d; c++);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " var a = 1, b = 2;\n" +
+ " ^\n" +
+ "'var' is not allowed in a compound declaration\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " for(var c = 1, d = 20; c<d; c++);\n" +
+ " ^\n" +
+ "'var' is not allowed in a compound declaration\n" +
+ "----------\n");
+}
+public void test0007_var_in_wrong_place() throws IOException {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " private var someField = 0;\n" +
+ " public var method() {\n" +
+ " return null;\n" +
+ " }\n" +
+ " public void main(var arg) {\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " private var someField = 0;\n" +
+ " ^^^\n" +
+ "'var' is not allowed here\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " public var method() {\n" +
+ " ^^^\n" +
+ "'var' is not allowed here\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 6)\n" +
+ " public void main(var arg) {\n" +
+ " ^^^\n" +
+ "'var' is not allowed here\n" +
+ "----------\n");
+}
+public void test0008_null_initializer() throws IOException {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void main(String[] arg) {\n" +
+ " var notMuch = null;\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " var notMuch = null;\n" +
+ " ^^^^^^^\n" +
+ "Cannot infer type for local variable initialized to 'null'\n" +
+ "----------\n");
+}
+public void test0008_void_initializer() throws IOException {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void foo() {\n" +
+ " }\n" +
+ "\n" +
+ " public void baz() {\n" +
+ " var nothingHere = foo();\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " var nothingHere = foo();\n" +
+ " ^^^^^^^^^^^\n" +
+ "Variable initializer is 'void' -- cannot infer variable type\n" +
+ "----------\n");
+}
+public void test0009_var_as_type_name() throws IOException {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public enum var { V, A, R };\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " public enum var { V, A, R };\n" +
+ " ^^^\n" +
+ "'var' is not a valid type name\n" +
+ "----------\n");
+}
+public void test0010_array_initializer() throws IOException {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void main(String [] args) {\n" +
+ " var myArray = { 1, 2, 3 };\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " var myArray = { 1, 2, 3 };\n" +
+ " ^^^^^^^\n" +
+ "Array initializer needs an explicit target-type\n" +
+ "----------\n");
+}
+public void test0011_array_type() throws IOException {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void main(String [] args) {\n" +
+ " var myArray[] = new int[42];\n" +
+ " var[] moreArray = new int[1337];\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " var myArray[] = new int[42];\n" +
+ " ^^^^^^^\n" +
+ "'var' is not allowed as an element type of an array\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " var[] moreArray = new int[1337];\n" +
+ " ^^^^^^^^^\n" +
+ "'var' is not allowed as an element type of an array\n" +
+ "----------\n");
+}
+public void test0012_self_reference() throws IOException {
+
+ // BTW: This will give a VerifyError: int a = ((java.util.concurrent.Callable<Integer>)(() -> true ? 1 : a)).call();
+ // The cases are tested. a is a simple case, with plain usage in the same scope. b is used in a nested scope.
+ // c and d are shadowed by the nested definitions.
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void main(String [] args) {\n" +
+ " var a = 42 + a;\n" +
+ " var b = ((java.util.concurrent.Callable<Integer>)(() -> true ? 1 : b)).call();\n" +
+ " var c = new java.util.concurrent.Callable<Integer>() {\n" +
+ " public Integer call() {\n" +
+ " int c = 42; return c;\n" +
+ " }\n" +
+ " }.call();" +
+ " var d = new java.util.concurrent.Callable<Integer>() {\n" +
+ " int d = 42;\n" +
+ " public Integer call() {\n" +
+ " return d;\n" +
+ " }\n" +
+ " }.call();" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " var a = 42 + a;\n" +
+ " ^\n" +
+ "Declaration using 'var' may not contain references to itself\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " var b = ((java.util.concurrent.Callable<Integer>)(() -> true ? 1 : b)).call();\n" +
+ " ^\n" +
+ "Declaration using 'var' may not contain references to itself\n" +
+ "----------\n" +
+ "3. WARNING in X.java (at line 7)\n" +
+ " int c = 42; return c;\n" +
+ " ^\n" +
+ "The local variable c is hiding another local variable defined in an enclosing scope\n" +
+ "----------\n"+
+ "3. WARNING in X.java (at line 10)\n" +
+ " int d = 42;\n" +
+ " ^\n" +
+ "The field new Callable<Integer>(){}.d is hiding another local variable defined in an enclosing scope\n" +
+ "----------\n");
+}
+public void test0013_lambda() throws IOException {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void main(String [] args) {\n" +
+ " var a = (int i) -> 42;\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " var a = (int i) -> 42;\n" +
+ " ^\n" +
+ "Lambda expression needs an explicit target-type\n" +
+ "----------\n");
+}
+public void test0014_method_reference() throws IOException {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void main(String [] args) {\n" +
+ " var a = X::main;\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " var a = X::main;\n" +
+ " ^\n" +
+ "Method reference needs an explicit target-type\n" +
+ "----------\n");
+}
+public void test0015_complain_over_first_poly_encountered() throws Exception {
+
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void main(String [] args) {\n" +
+ " var a = args.length > 1 ? X::main : (int i) -> 42;\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " var a = args.length > 1 ? X::main : (int i) -> 42;\n" +
+ " ^\n" +
+ "Method reference needs an explicit target-type\n" +
+ "----------\n");
+}
+public void test0016_dont_capture_deep_poly_expressions() throws IOException {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String [] args) throws Exception {\n" +
+ " var z = ((java.util.concurrent.Callable<String>)(() -> \"SUCCESS\"));\n" +
+ " var x = args.length > 1 ? \"FAILURE\" : z.call();\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "SUCCESS");
+}
+//static <T extends List<? super E>, E extends List<? super Integer>> void doSomething(T[] e) {
+// e[0] = null;
+//}
+
+public void test0017_simple_variable_types() throws Exception {
+ InferredTypeVerifier typeVerifier = new InferredTypeVerifier();
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.util.List;\n" +
+ "\n" +
+ "public class X {\n" +
+ " void test() {\n" +
+ " var i_String = \"\";\n" +
+ " for (var i2_String = \"\" ; ; ) { break; }\n" +
+ " for (var i2_String : iterableOfString()) { break; }\n" +
+ " for (var i2_String : arrayOfString()) { break; }\n" +
+ " try (var i2_Bar = new Bar()) { } finally { }\n" +
+ " try (var i2_Bar = new Bar(); var i3_Bar = new Bar()) { } finally { }\n" +
+ " }\n" +
+ "\n" +
+ " Iterable<String> iterableOfString() { return null; }\n" +
+ " String[] arrayOfString() { return null; }\n" +
+ "\n" +
+ " static class Bar implements AutoCloseable {\n" +
+ " @Override\n" +
+ " public void close() { }\n" +
+ " }\n" +
+ "}\n" +
+ "\n"
+ },
+ typeVerifier);
+ Assert.assertEquals(7, typeVerifier.localsChecked);
+}
+public void test0018_primitive_variable_types() throws Exception {
+ InferredTypeVerifier typeVerifier = new InferredTypeVerifier();
+ this.runConformTest(
+ new String[] {
+ "Y.java",
+ "class Y {\n" +
+ " boolean[] booleanArray = { true };\n" +
+ " byte[] byteArray = { 1 };\n" +
+ " char[] charArray = { 'c' };\n" +
+ " short[] shortArray = { 42 };\n" +
+ " int[] intArray = { 42 };\n" +
+ " long[] longArray = { 42L };\n" +
+ " float[] floatArray = { 0.1f };\n" +
+ " double[] doubleArray = { 0.2d };\n" +
+ "\n" +
+ " void testBuiltins() {\n" +
+ " var z_boolean = false;\n" +
+ " var b_byte = (byte)0xff;\n" +
+ " var c_char = 'c';\n" +
+ " var s_short = (short)42;\n" +
+ " var i_int = 42;\n" +
+ " var l_long = 42L;\n" +
+ " var f_float = 0.25f;\n" +
+ " var d_double = 0.35d;\n" +
+ " }\n" +
+ "\n" +
+ " void testBuiltinsForEach() {\n" +
+ " for (var z_boolean : booleanArray) { System.out.print(\".\"); }\n" +
+ " for (var b_byte : byteArray) { System.out.print(\".\"); }\n" +
+ " for (var c_char : charArray) { System.out.print(\".\"); }\n" +
+ " for (var s_short : shortArray) { System.out.print(\".\"); }\n" +
+ " for (var i_int : intArray) { System.out.print(\".\"); }\n" +
+ " for (var l_long : longArray) { System.out.print(\".\"); }\n" +
+ " for (var f_float : floatArray) { System.out.print(\".\"); }\n" +
+ " for (var d_double : doubleArray) { System.out.print(\".\"); }\n" +
+ " }\n" +
+ " void testBuiltinsArray() {\n" +
+ " var z_booleanARRAY = booleanArray;\n" +
+ " var b_byteARRAY = byteArray;\n" +
+ " var c_charARRAY = charArray;\n" +
+ " var s_shortARRAY = shortArray;\n" +
+ " var i_intARRAY = intArray;\n" +
+ " var l_longARRAY = longArray;\n" +
+ " var f_floatARRAY = floatArray;\n" +
+ " var d_doubleARRAY = doubleArray;\n" +
+ " }\n" +
+ "\n" +
+ "}\n"
+ },
+ typeVerifier);
+ Assert.assertEquals(24, typeVerifier.localsChecked);
+}
+public void test0018_project_variable_types() throws Exception {
+ InferredTypeVerifier typeVerifier = new InferredTypeVerifier();
+ this.runConformTest(
+ new String[] {
+ "Z.java",
+ "import java.util.Collection;\n" +
+ "import java.util.List;\n" +
+ "import java.io.Serializable;\n" +
+ "\n" +
+ "class Z {\n" +
+ "\n" +
+ " void testExtends() {\n" +
+ " var l1_CollectionOfExtString = extendsString();\n" +
+ " for (var l2_CollectionOfExtString = extendsString() ; ; ) { break; }\n" +
+ " for (var l3_CollectionOfExtString : extendsStringArr()) { break; }\n" +
+ " for (var l4_CollectionOfExtString : extendsCollectionIterable()) { break; }\n" +
+ " for (var l5_String : extendsString()) { break; }\n" +
+ " }\n" +
+ "\n" +
+ " void testExtendsFbound() { \n" +
+ " var l1_CollectionExt_ComparableAny = extendsTBound();\n" +
+ " for (var l2_CollectionExt_ComparableAny = extendsTBound() ; ; ) { break; }\n" +
+ " for (var l3_CollectionExt_ComparableAny : extendsTBoundArray()) { break; }\n" +
+ " for (var l3_CollectionExt_ComparableAny : extendsTBoundIter()) { break; }\n" +
+ " for (var l4_ComparableAny : extendsTBound()) { break; }\n" +
+ " }\n" +
+ "\n" +
+ " void testSuperTBound() {\n" +
+ " var s_CollectionAny = superTBound();\n" +
+ " for (var s2_CollectionAny = superTBound() ; ; ) { break; }\n" +
+ " for (var s2_CollectionAny : superTBoundArray()) { break; }\n" +
+ " for (var s2_CollectionAny : superTBoundIter()) { break; }\n" +
+ " for (var s2_Object : superTBound()) { break; }\n" +
+ " }\n" +
+ "\n" +
+ " void testCollectSuper() {\n" +
+ " var s_CollectionOfSuperString = superString();\n" +
+ " for (var s2_CollectionOfSuperString = superString() ; ; ) { break; }\n" +
+ " for (var s2_CollectionOfSuperString : superStringArray()) { break; }\n" +
+ " for (var s2_CollectionOfSuperString : superCollectionIterable()) { break; }\n" +
+ " for (var s2_Object : superString()) { break; }\n" +
+ " }\n" +
+ "\n" +
+ " void testUnbound() {\n" +
+ " var s_CollectionAny = unboundedString();\n" +
+ " for (var s2_CollectionAny = unboundedString() ; ; ) { break; }\n" +
+ " for (var s2_CollectionAny : unboundedStringArray()) { break; }\n" +
+ " for (var s2_CollectionAny : unboundedCollectionIterable()) { break; }\n" +
+ " for (var s2_Object : unboundedString()) { break; }\n" +
+ " }\n" +
+ "\n" +
+ " void testTypeOfAnAnonymousClass() {\n" +
+ " var o_AnonymousObjectSubclass = new Object() { };\n" +
+ " for (var s2_AnonymousObjectSubclass = new Object() { } ; ; ) { break; }\n" +
+ " for (var s2_AnonymousObjectSubclass : arrayOf(new Object() { })) { break; }\n" +
+ " for (var s2_AnonymousObjectSubclass : listOf(new Object() { })) { break; }\n" +
+ " }\n" +
+ "\n" +
+ " void testTypeOfAnAnonymousInterface() {\n" +
+ " var r_AnonymousRunnableSubclass = new Runnable() { public void run() { } };\n" +
+ " for (var s2_AnonymousRunnableSubclass = new Runnable() { public void run() { } } ; ; ) { break; }\n" +
+ " for (var s2_AnonymousRunnableSubclass : arrayOf(new Runnable() { public void run() { } })) { break; }\n" +
+ " for (var s2_AnonymousRunnableSubclass : listOf(new Runnable() { public void run() { } })) { break; }\n" +
+ " }\n" +
+ "\n" +
+ " void testTypeOfIntersectionType() {\n" +
+ " var c_IntLongFloat = choose(1, 1L);\n" +
+ " for (var s2_IntLongFloat = choose(1, 1L) ; ;) { break; }\n" +
+ " for (var s2_IntLongFloat : arrayOf(choose(1, 1L))) { break; }\n" +
+ " for (var s2_IntLongFloat : listOf(choose(1, 1L))) { break; }\n" +
+ " }\n" +
+ "\n" +
+ " public void testProjections() {\n" +
+ " var inter_ListTestAndSerializable = getIntersections();\n" +
+ " var r_TestAndSerializable = inter_ListTestAndSerializable.get(0);\n" +
+ " }\n" +
+ "\n" +
+ " Collection<? extends String> extendsString() { return null; }\n" +
+ " Collection<? super String> superString() { return null; }\n" +
+ " Collection<?> unboundedString() { return null; }\n" +
+ "\n" +
+ " Collection<? extends String>[] extendsStringArr() { return null; }\n" +
+ " Collection<? super String>[] superStringArray() { return null; }\n" +
+ " Collection<?>[] unboundedStringArray() { return null; }\n" +
+ "\n" +
+ " Iterable<? extends Collection<? extends String>> extendsCollectionIterable() { return null; }\n" +
+ " Iterable<? extends Collection<? super String>> superCollectionIterable() { return null; }\n" +
+ " Iterable<? extends Collection<?>> unboundedCollectionIterable() { return null; }\n" +
+ "\n" +
+ " <TBound extends Comparable<TBound>> Collection<? extends TBound> extendsTBound() { return null; }\n" +
+ " <TBound extends Comparable<TBound>> Collection<? super TBound> superTBound() { return null; }\n" +
+ "\n" +
+ " <TBound extends Comparable<TBound>> Collection<? extends TBound>[] extendsTBoundArray() { return null; }\n" +
+ " <TBound extends Comparable<TBound>> Collection<? super TBound>[] superTBoundArray() { return null; }\n" +
+ "\n" +
+ " <TBound extends Comparable<TBound>> Iterable<? extends Collection<? extends TBound>> extendsTBoundIter() { return null; }\n" +
+ " <TBound extends Comparable<TBound>> Iterable<? extends Collection<? super TBound>> superTBoundIter() { return null; }\n" +
+ "\n" +
+ " <TBound> Collection<TBound> listOf(TBound b) { return null; }\n" +
+ " <TBound> TBound[] arrayOf(TBound b) { return null; }\n" +
+ "\n" +
+ " <TBound> TBound choose(TBound b1, TBound b2) { return b1; }\n" +
+ " <T extends Z & Serializable> List<? extends T> getIntersections() {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}"
+ },
+ typeVerifier);
+ Assert.assertEquals(39, typeVerifier.localsChecked);
+}
+public void testBug531832() throws IOException {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " for (var[] v : args) { }\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " for (var[] v : args) { }\n" +
+ " ^\n" +
+ "'var' is not allowed as an element type of an array\n" +
+ "----------\n");
+}
+public void testBug530879() throws IOException {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void foo() { }\n" +
+ " public static void main(String [] args) {\n" +
+ " for (var v : foo()) { }\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " for (var v : foo()) { }\n" +
+ " ^\n" +
+ "Variable initializer is 'void' -- cannot infer variable type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " for (var v : foo()) { }\n" +
+ " ^^^^^\n" +
+ "Can only iterate over an array or an instance of java.lang.Iterable\n" +
+ "----------\n");
+}
+public void testBug530879a() throws IOException {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " for (var v : null) { }\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " for (var v : null) { }\n" +
+ " ^\n" +
+ "Cannot infer type for local variable initialized to 'null'\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " for (var v : null) { }\n" +
+ " ^^^^\n" +
+ "Can only iterate over an array or an instance of java.lang.Iterable\n" +
+ "----------\n");
+}
+public void testBug532349() throws IOException {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void foo(Boolean p) {\n" +
+ " Y<? super Boolean> y = new Y<>();\n" +
+ " var v = y;\n" +
+ " Y<? super Boolean> tmp = v;\n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T extends Boolean> {\n" +
+ "}"
+ });
+}
+public void testBug532349a() throws IOException {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.util.List;\n" +
+ "import java.util.ArrayList;\n" +
+ "public class X {\n" +
+ " public static void foo(Boolean p) {\n" +
+ " List<Y<? super Boolean>> l = new ArrayList<>();\n" +
+ " var dlv = l;\n" +
+ " for (var iv : dlv) {\n" +
+ " Y<? super Boolean> id = iv;\n" +
+ " }" +
+ " }\n" +
+ "}\n" +
+ "class Y<T extends Boolean> {}"
+ });
+}
+public void testBug532349b() throws IOException {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void foo(Boolean p) {\n" +
+ " Y<? super Boolean> y = new Y<>();\n" +
+ " try (var v = y) {\n" +
+ " Y<? super Boolean> tmp = v;\n" +
+ " } catch (Exception e) { }\n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T extends Boolean> implements AutoCloseable {\n" +
+ " @Override\n" +
+ " public void close() throws Exception {}\n" +
+ "}"
+ });
+}
+public void testBug532351() throws IOException {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void foo(Boolean p) {\n" +
+ " Y<? super Number> y = new Y<Number>(); // Javac reports, ECJ accepts\n" +
+ " var v = y;\n" +
+ " Y<? super Number> tmp = v;\n" +
+ " }\n" +
+ " class Y<T extends Number> {\n" +
+ " }\n" +
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " Y<? super Number> y = new Y<Number>(); // Javac reports, ECJ accepts\n" +
+ " ^^^^^^^^^^^^^^^\n" +
+ "No enclosing instance of type X is accessible. Must qualify the allocation with an enclosing instance of type X (e.g. x.new A() where x is an instance of X).\n" +
+ "----------\n");
+}
+}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JSR335ClassFileTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JSR335ClassFileTest.java
index 8cf336fac..21035a386 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JSR335ClassFileTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JSR335ClassFileTest.java
@@ -4,7 +4,11 @@
* 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:
* Jesper Steen Moller - initial API and implementation
* Bug 416885 - [1.8][compiler]IncompatibleClassChange error (edit)
@@ -35,7 +39,9 @@ public JSR335ClassFileTest(String name) {
// No need for a tearDown()
protected void setUp() throws Exception {
super.setUp();
- this.versionString = (this.complianceLevel < ClassFileConstants.JDK9) ? "version 1.8 : 52.0" : "version 9 : 53.0";
+ this.versionString = (this.complianceLevel < ClassFileConstants.JDK9)
+ ? "version 1.8 : 52.0"
+ : (this.complianceLevel < ClassFileConstants.JDK10 ? "version 9 : 53.0" : "version 10 : 54.0");
}
/*
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LambdaExpressionsTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LambdaExpressionsTest.java
index 22b3ef7c2..db3d71e3f 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LambdaExpressionsTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LambdaExpressionsTest.java
@@ -5028,7 +5028,7 @@ public void test447119d() {
"[- java.util.List<java.lang.String> noop(java.util.List<java.lang.String>)]",
null,
true,
- (isJRE9
+ (isJRE9Plus
? new String[] { "--add-opens", "java.base/java.io=ALL-UNNAMED" }
: new String [] { "-Ddummy" }) // Not sure, unless we force the VM to not be reused by passing dummy vm argument, the generated program aborts midway through its execution.
);
@@ -5192,7 +5192,7 @@ public void test449063() {
" }\n" +
"}"
},
- (isJRE9
+ (isJRE9Plus
? "Test$Tuple<java.lang.Integer, java.lang.String>\n" +
"Test$Tuple<java.lang.String, java.lang.Double>"
: "Test.Test$Tuple<java.lang.Integer, java.lang.String>\n" +
@@ -5263,7 +5263,7 @@ public void test449063a() {
" }\n" +
"}"
},
- (isJRE9
+ (isJRE9Plus
? "Test$Tuple<java.lang.Integer, java.lang.String>\n" +
"Test$Tuple<java.lang.String, java.lang.Double>"
: "Test.Test$Tuple<java.lang.Integer, java.lang.String>\n" +
@@ -5477,7 +5477,7 @@ public void test449063e() {
" }\n" +
"}"
},
- (isJRE9
+ (isJRE9Plus
? "Test$Tuple<java.lang.Integer, java.lang.String>\n" +
"Test$Tuple<java.lang.String, java.lang.Double>"
: "Test.Test$Tuple<java.lang.Integer, java.lang.String>\n" +
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodParametersAttributeTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodParametersAttributeTest.java
index dc8768018..1106e949f 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodParametersAttributeTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodParametersAttributeTest.java
@@ -1,12 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2013, 2016 Jesper Steen Moeller and others.
+ * Copyright (c) 2013, 2018 Jesper Steen Moeller 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:
* Jesper Steen Moeller - initial API and implementation
+ * bug 527554 - [18.3] Compiler support for JEP 286 Local-Variable Type
+ *
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -33,7 +39,9 @@ public class MethodParametersAttributeTest extends AbstractRegressionTest {
// No need for a tearDown()
protected void setUp() throws Exception {
super.setUp();
- this.versionString = (this.complianceLevel < ClassFileConstants.JDK9) ? "version 1.8 : 52.0" : "version 9 : 53.0";
+ this.versionString = (this.complianceLevel < ClassFileConstants.JDK9)
+ ? "version 1.8 : 52.0"
+ : (this.complianceLevel < ClassFileConstants.JDK10 ? "version 9 : 53.0" : "version 10 : 54.0");
}
@SuppressWarnings("rawtypes")
public static Class testClass() {
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NonFatalErrorTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NonFatalErrorTest.java
index fb4073736..e9f6f6e50 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NonFatalErrorTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NonFatalErrorTest.java
@@ -528,4 +528,51 @@ public class NonFatalErrorTest extends AbstractRegressionTest {
"",
JavacTestOptions.SKIP);
}
+ public void testDuplicateImports1() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5) return; // uses static imports
+ runConformTest(
+ new String[] {
+ "Test.java",
+ "import java.lang.Character.Subset;\n" +
+ "import static java.lang.Character.Subset;\n" +
+ "\n" +
+ "public class Test {\n" +
+ " Subset s = null;\n" +
+ "}\n"
+ });
+ }
+ public void testDuplicateImports2() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5) return; // uses static imports
+ runConformTest(
+ new String[] {
+ "Test.java",
+ "import static java.awt.geom.Line2D.Double;\n" +
+ "import static java.awt.geom.Line2D.Double;\n" +
+ "\n" +
+ "public class Test {\n" +
+ " Double d = null;\n" +
+ "}\n"
+ });
+ }
+ public void testDuplicateImports3() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5) return; // uses static imports
+ runNegativeTest(
+ new String[] {
+ "Test.java",
+ // JLS doesn't really allow this duplication, but also javac defers the error to the use site, see:
+ // https://bugs.openjdk.java.net/browse/JDK-8133619?focusedCommentId=14133759&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14133759
+ "import static java.awt.geom.Line2D.Double;\n" +
+ "import static java.awt.geom.Point2D.Double;\n" +
+ "\n" +
+ "public class Test {\n" +
+ " Double d = null;\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in Test.java (at line 5)\n" +
+ " Double d = null;\n" +
+ " ^^^^^^\n" +
+ "The type Double is ambiguous\n" +
+ "----------\n");
+ }
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java
index b6ad4458a..f2d984fc8 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java
@@ -23,6 +23,7 @@ import java.util.Map;
import junit.framework.Test;
import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
@SuppressWarnings({ "unchecked", "rawtypes" })
@@ -15405,4 +15406,46 @@ public void testBug515292() {
""
);
}
+public void testBug531040() {
+ if (this.complianceLevel < ClassFileConstants.JDK10)
+ return;
+ runNegativeTestWithLibs(
+ new String[] {
+ "Test.java",
+ "import java.util.*;\n" +
+ "\n" +
+ "import org.eclipse.jdt.annotation.NonNull;\n" +
+ "\n" +
+ "public class Test {\n" +
+ " void test() {\n" +
+ " var list1 = new ArrayList<@NonNull String>();\n" +
+ " list1.add(null);\n" +
+ " @NonNull String val = \"\";\n" +
+ " var list2 = getList(val);\n" +
+ " list2.add(null);\n" +
+ " }\n" +
+ " <T> List<T> getList(T... in) {\n" +
+ " return Arrays.asList(in);\n" +
+ " }\n" +
+ "}\n" +
+ ""
+ },
+ "----------\n" +
+ "1. ERROR in Test.java (at line 8)\n" +
+ " list1.add(null);\n" +
+ " ^^^^\n" +
+ "Null type mismatch: required \'@NonNull String\' but the provided value is null\n" +
+ "----------\n" +
+ "2. ERROR in Test.java (at line 11)\n" +
+ " list2.add(null);\n" +
+ " ^^^^\n" +
+ "Null type mismatch: required \'@NonNull String\' but the provided value is null\n" +
+ "----------\n" +
+ "3. WARNING in Test.java (at line 13)\n" +
+ " <T> List<T> getList(T... in) {\n" +
+ " ^^\n" +
+ "Type safety: Potential heap pollution via varargs parameter in\n" +
+ "----------\n"
+ );
+}
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SerializableLambdaTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SerializableLambdaTest.java
index c76e6bc9e..e608cf8f8 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SerializableLambdaTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SerializableLambdaTest.java
@@ -1574,7 +1574,7 @@ public class SerializableLambdaTest extends AbstractRegressionTest {
"Looking for Testbed.foo\n" +
"true",
null,true,
- (isJRE9
+ (isJRE9Plus
? new String[] { "--add-opens", "java.base/java.io=ALL-UNNAMED" }
: new String [] { "-Ddummy" })
);
@@ -1662,7 +1662,7 @@ public class SerializableLambdaTest extends AbstractRegressionTest {
"Looking for Testbed$MethodRefImpl.<init>\n" +
"true",
null,true,
- (isJRE9
+ (isJRE9Plus
? new String[] { "--add-opens", "java.base/java.io=ALL-UNNAMED" }
: new String [] { "-Ddummy" })
);
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java
index 2e2b4f9bb..d87c15aa3 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
* Technical University Berlin - adapted for Object Teams
@@ -167,6 +171,10 @@ public static Test suite() {
since_9.add(ModuleAttributeTests.class);
since_9.add(AutomaticModuleNamingTest.class);
since_9.add(UnnamedModuleTest.class);
+
+ // add 10 specific test here (check duplicates)
+ ArrayList since_10 = new ArrayList();
+ since_10.add(JEP286Test.class);
// Build final test suite
TestSuite all = new TestSuite(TestAll.class.getName());
@@ -239,6 +247,19 @@ public static Test suite() {
TestCase.RUN_ONLY_ID = null;
all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.JDK9, tests_9));
}
+
+ if ((possibleComplianceLevels & AbstractCompilerTest.F_10) != 0) {
+ ArrayList tests_10 = (ArrayList)standardTests.clone();
+ tests_10.addAll(since_1_4);
+ tests_10.addAll(since_1_5);
+ tests_10.addAll(since_1_6);
+ tests_10.addAll(since_1_7);
+ tests_10.addAll(since_1_8);
+ tests_10.addAll(since_9);
+ tests_10.addAll(since_10);
+ TestCase.resetForgottenFilters(tests_10);
+ all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.JDK10, tests_10));
+ }
all.addTest(new TestSuite(Jsr14Test.class));
return all;
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/dom/StandAloneASTParserTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/dom/StandAloneASTParserTest.java
index 13285981d..dbaad0063 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/dom/StandAloneASTParserTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/dom/StandAloneASTParserTest.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2010, 2017 IBM Corporation and others.
+ * Copyright (c) 2010, 2018 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
* Stephan Herrmann - Contribution for
@@ -43,6 +47,7 @@ import org.eclipse.jdt.core.dom.MethodInvocation;
import org.eclipse.jdt.core.dom.ModuleDeclaration;
import org.eclipse.jdt.core.dom.NodeFinder;
import org.eclipse.jdt.core.dom.SimpleName;
+import org.eclipse.jdt.core.dom.Type;
import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
import org.eclipse.jdt.core.dom.VariableDeclarationStatement;
@@ -54,7 +59,7 @@ public class StandAloneASTParserTest extends AbstractRegressionTest {
super(name);
}
- private static final int AST_JLS_LATEST = AST.JLS9;
+ private static final int AST_JLS_LATEST = AST.JLS10;
public ASTNode runConversion(
int astLevel,
@@ -638,6 +643,7 @@ public class StandAloneASTParserTest extends AbstractRegressionTest {
assertTrue("should have parsed a CUD", ast instanceof CompilationUnit);
}
+ @Deprecated
public void testBug465048() {
String source =
"class A {\n" +
@@ -670,6 +676,7 @@ public class StandAloneASTParserTest extends AbstractRegressionTest {
/**
* Verifies that ASTParser doesn't throw an IllegalArgumentException when given
* this valid input.
+ * @deprecated
*/
public void testBug480545() {
String input = "class Test2 { void f(Test2... xs) {} }";
@@ -680,6 +687,7 @@ public class StandAloneASTParserTest extends AbstractRegressionTest {
parser.setCompilerOptions(options);
assertNotNull(parser.createAST(null));
}
+ @Deprecated
public void testBug493336_001() {
String input = "public class X implements á¼³ {\n" +
" public static final class if {\n"+
@@ -701,6 +709,7 @@ public class StandAloneASTParserTest extends AbstractRegressionTest {
parser.setCompilerOptions(options1);
assertNotNull(parser.createAST(null));
}
+ @Deprecated
public void testBug526996_001() {
File rootDir = new File(System.getProperty("java.io.tmpdir"));
String contents =
@@ -796,4 +805,31 @@ public class StandAloneASTParserTest extends AbstractRegressionTest {
fileY.delete();
}
}
+ public void testBug530299_001() {
+ String contents =
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " var x = new X();\n" +
+ " for (var i = 0; i < 10; ++i) {}\n" +
+ " }\n" +
+ "}";
+ ASTParser parser = ASTParser.newParser(AST.JLS10);
+ parser.setSource(contents.toCharArray());
+ parser.setStatementsRecovery(true);
+ parser.setBindingsRecovery(true);
+ parser.setKind(ASTParser.K_COMPILATION_UNIT);
+ parser.setEnvironment(null, new String[] {null}, null, true);
+ parser.setResolveBindings(true);
+ ASTNode node = parser.createAST(null);
+ assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
+ CompilationUnit cu = (CompilationUnit) node;
+ assertTrue("Problems in compilation", cu.getProblems().length == 0);
+ TypeDeclaration typeDeclaration = (TypeDeclaration) cu.types().get(0);
+ MethodDeclaration[] methods = typeDeclaration.getMethods();
+ MethodDeclaration methodDeclaration = methods[0];
+ VariableDeclarationStatement vStmt = (VariableDeclarationStatement) methodDeclaration.getBody().statements().get(0);
+ Type type = vStmt.getType();
+ assertNotNull(type);
+ assertTrue("not a var", type.isVar());
+ }
} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/TestCase.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/TestCase.java
index 92c77c174..a6e58211d 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/TestCase.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/TestCase.java
@@ -1,12 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
+ * Jesper S Moller <jesper@selskabet.org> - Contributions for
+ * bug 527554 - [18.3] Compiler support for JEP 286 Local-Variable Type
*******************************************************************************/
package org.eclipse.jdt.core.tests.junit.extension;
@@ -35,6 +41,7 @@ import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.jdt.core.Flags;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.compiler.batch.Main;
import org.eclipse.jdt.internal.core.nd.indexer.Indexer;
@@ -817,7 +824,7 @@ protected boolean isFirst() {
}
protected void setUp() throws Exception {
- Indexer.getInstance().enableAutomaticIndexing(false);
+ if (JavaCore.getPlugin() != null) Indexer.getInstance().enableAutomaticIndexing(false);
super.setUp();
// Store test class and its name when changing
@@ -906,7 +913,7 @@ public void stopMeasuring() {
protected void tearDown() throws Exception {
super.tearDown();
- Indexer.getInstance().enableAutomaticIndexing(true);
+ if (JavaCore.getPlugin() != null) Indexer.getInstance().enableAutomaticIndexing(true);
// Memory storage if specified
if (STORE_MEMORY != null && MEM_LOG_FILE != null) {
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/LocalVMLauncher.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/LocalVMLauncher.java
index 687e3e8c7..266008cab 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/LocalVMLauncher.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/LocalVMLauncher.java
@@ -15,6 +15,7 @@ package org.eclipse.jdt.core.tests.runtime;
import java.io.*;
import java.util.*;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.tests.util.Util;
/**
@@ -73,7 +74,7 @@ public static LocalVMLauncher getLauncher() {
// }
// SH}
String javaVersion = System.getProperty("java.version");
- boolean isJrt = javaVersion != null && javaVersion.length() > 0 && javaVersion.charAt(0) == '9';
+ boolean isJrt = javaVersion != null && javaVersion.length() > 0 && JavaCore.compareJavaVersions(javaVersion, "9") >= 0;
File file = new File(Util.getJREDirectory() + (isJrt ? "/lib/jrt-fs.jar" : "/lib/rt.jar"));
if (file.exists()) {
return new StandardVMLauncher();
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java
index ea9289e23..26dca6425 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
*******************************************************************************/
@@ -38,6 +42,7 @@ public class AbstractCompilerTest extends TestCase {
public static final int F_1_7 = 0x10;
public static final int F_1_8 = 0x20;
public static final int F_9 = 0x40;
+ public static final int F_10 = 0x80;
public static final boolean RUN_JAVAC = CompilerOptions.ENABLED.equals(System.getProperty("run.javac"));
private static final int UNINITIALIZED = -1;
@@ -46,7 +51,7 @@ public class AbstractCompilerTest extends TestCase {
protected long complianceLevel;
protected boolean enableAPT = false;
- protected static boolean isJRE9 = false; // Stop gap, so tests need not be run at 9, but some tests can be adjusted for JRE 9
+ protected static boolean isJRE9Plus = false; // Stop gap, so tests need not be run at 9, but some tests can be adjusted for JRE 9
/**
* Build a test suite made of test suites for all possible running VM compliances .
@@ -84,6 +89,9 @@ public class AbstractCompilerTest extends TestCase {
if ((complianceLevels & AbstractCompilerTest.F_9) != 0) {
suite.addTest(buildUniqueComplianceTestSuite(evaluationTestClass, ClassFileConstants.JDK9));
}
+ if ((complianceLevels & AbstractCompilerTest.F_10) != 0) {
+ suite.addTest(buildUniqueComplianceTestSuite(evaluationTestClass, ClassFileConstants.JDK10));
+ }
}
/**
@@ -120,6 +128,9 @@ public class AbstractCompilerTest extends TestCase {
if ((complianceLevels & AbstractCompilerTest.F_9) != 0) {
suite.addTest(buildComplianceTestSuite(testClasses, setupClass, ClassFileConstants.JDK9));
}
+ if ((complianceLevels & AbstractCompilerTest.F_10) != 0) {
+ suite.addTest(buildComplianceTestSuite(testClasses, setupClass, ClassFileConstants.JDK10));
+ }
return suite;
}
@@ -251,6 +262,14 @@ public class AbstractCompilerTest extends TestCase {
suite.addTest(buildUniqueComplianceTestSuite(evaluationTestClass, ClassFileConstants.JDK9));
}
}
+ int level10 = complianceLevels & AbstractCompilerTest.F_10;
+ if (level10 != 0) {
+ if (level10 < minimalCompliance) {
+ System.err.println("Cannot run "+evaluationTestClass.getName()+" at compliance "+CompilerOptions.versionFromJdkLevel(ClassFileConstants.JDK10)+"!");
+ } else {
+ suite.addTest(buildUniqueComplianceTestSuite(evaluationTestClass, ClassFileConstants.JDK10));
+ }
+ }
return suite;
}
@@ -267,7 +286,9 @@ public class AbstractCompilerTest extends TestCase {
long highestLevel = highestComplianceLevels();
if (highestLevel < uniqueCompliance) {
String complianceString;
- if (highestLevel == ClassFileConstants.JDK9)
+ if (highestLevel == ClassFileConstants.JDK10)
+ complianceString = "10";
+ else if (highestLevel == ClassFileConstants.JDK9)
complianceString = "9";
else if (highestLevel == ClassFileConstants.JDK1_8)
complianceString = "1.8";
@@ -299,6 +320,9 @@ public class AbstractCompilerTest extends TestCase {
*/
public static long highestComplianceLevels() {
int complianceLevels = AbstractCompilerTest.getPossibleComplianceLevels();
+ if ((complianceLevels & AbstractCompilerTest.F_10) != 0) {
+ return ClassFileConstants.JDK10;
+ }
if ((complianceLevels & AbstractCompilerTest.F_9) != 0) {
return ClassFileConstants.JDK9;
}
@@ -326,7 +350,7 @@ public class AbstractCompilerTest extends TestCase {
public static int getPossibleComplianceLevels() {
if (possibleComplianceLevels == UNINITIALIZED) {
String specVersion = System.getProperty("java.specification.version");
- isJRE9 = CompilerOptions.VERSION_9.equals(specVersion);
+ isJRE9Plus = CompilerOptions.VERSION_9.equals(specVersion) || CompilerOptions.VERSION_10.equals(specVersion);
String compliance = System.getProperty("compliance");
if (compliance != null) {
if (CompilerOptions.VERSION_1_3.equals(compliance)) {
@@ -343,6 +367,8 @@ public class AbstractCompilerTest extends TestCase {
possibleComplianceLevels = F_1_8;
} else if (CompilerOptions.VERSION_9.equals(compliance)) {
possibleComplianceLevels = F_9;
+ } else if (CompilerOptions.VERSION_10.equals(compliance)) {
+ possibleComplianceLevels = F_10;
} else {
System.out.println("Invalid compliance specified (" + compliance + ")");
System.out.print("Use one of ");
@@ -352,7 +378,9 @@ public class AbstractCompilerTest extends TestCase {
System.out.print(CompilerOptions.VERSION_1_6 + ", ");
System.out.print(CompilerOptions.VERSION_1_7 + ", ");
System.out.print(CompilerOptions.VERSION_1_8 + ", ");
- System.out.println(CompilerOptions.VERSION_9);
+ System.out.print(CompilerOptions.VERSION_1_8 + ", ");
+ System.out.print(CompilerOptions.VERSION_9 + ", ");
+ System.out.println(CompilerOptions.VERSION_10);
System.out.println("Defaulting to all possible compliances");
}
}
@@ -386,6 +414,10 @@ public class AbstractCompilerTest extends TestCase {
if (canRun9) {
possibleComplianceLevels |= F_9;
}
+ boolean canRun10 = canRun9 && !CompilerOptions.VERSION_9.equals(specVersion);
+ if (canRun10) {
+ possibleComplianceLevels |= F_10;
+ }
} else if ("1.0".equals(specVersion)
|| CompilerOptions.VERSION_1_1.equals(specVersion)
|| CompilerOptions.VERSION_1_2.equals(specVersion)
@@ -402,6 +434,9 @@ public class AbstractCompilerTest extends TestCase {
possibleComplianceLevels |= F_1_8;
if (!CompilerOptions.VERSION_1_8.equals(specVersion)) {
possibleComplianceLevels |= F_9;
+ if (!CompilerOptions.VERSION_10.equals(specVersion)) {
+ possibleComplianceLevels |= F_10;
+ }
}
}
}
@@ -506,7 +541,7 @@ public class AbstractCompilerTest extends TestCase {
}
public String decorateAnnotationValueLiteral(String val) {
- if (!isJRE9) {
+ if (!isJRE9Plus) {
return val;
}
StringBuilder builder = new StringBuilder(val);
@@ -550,6 +585,10 @@ public class AbstractCompilerTest extends TestCase {
options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_9);
options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_9);
options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_9);
+ } else if (this.complianceLevel == ClassFileConstants.JDK10) {
+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_10);
+ options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_10);
+ options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_10);
}
return options;
}
diff --git a/org.eclipse.jdt.core.tests.model/JCL/converterJclMin10.jar b/org.eclipse.jdt.core.tests.model/JCL/converterJclMin10.jar
new file mode 100644
index 000000000..df361f565
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/JCL/converterJclMin10.jar
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/JCL/converterJclMin10src.zip b/org.eclipse.jdt.core.tests.model/JCL/converterJclMin10src.zip
new file mode 100644
index 000000000..23ce774f5
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/JCL/converterJclMin10src.zip
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/JCL/jclMin10.jar b/org.eclipse.jdt.core.tests.model/JCL/jclMin10.jar
new file mode 100644
index 000000000..6f2af93c9
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/JCL/jclMin10.jar
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/JCL/jclMin10src.zip b/org.eclipse.jdt.core.tests.model/JCL/jclMin10src.zip
new file mode 100644
index 000000000..37447f944
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/JCL/jclMin10src.zip
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/META-INF/MANIFEST.MF b/org.eclipse.jdt.core.tests.model/META-INF/MANIFEST.MF
index d3cadda0d..8a97be161 100644
--- a/org.eclipse.jdt.core.tests.model/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.core.tests.model/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.core.tests.model;singleton:=true
-Bundle-Version: 3.10.361.qualifier
+Bundle-Version: 3.10.411.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.jdt.core.tests,
@@ -29,3 +29,4 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Eclipse-BundleShape: dir
Bundle-Activator: org.eclipse.jdt.core.tests.Activator
Bundle-ActivationPolicy: lazy
+Automatic-Module-Name: org.eclipse.jdt.core.tests.model
diff --git a/org.eclipse.jdt.core.tests.model/pom.xml b/org.eclipse.jdt.core.tests.model/pom.xml
index a693b3f26..366e9d159 100644
--- a/org.eclipse.jdt.core.tests.model/pom.xml
+++ b/org.eclipse.jdt.core.tests.model/pom.xml
@@ -20,7 +20,7 @@
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.core.tests.model</artifactId>
- <version>3.10.361-SNAPSHOT</version>
+ <version>3.10.411-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunAllJava10Tests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunAllJava10Tests.java
new file mode 100644
index 000000000..1b34f6dc4
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunAllJava10Tests.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2018 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
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.eclipse.jdt.core.tests.dom.ASTConverter10Test;
+import org.eclipse.jdt.core.tests.dom.ConverterTestSetup;
+import org.eclipse.jdt.core.tests.model.CompletionTests10;
+import org.eclipse.jdt.core.tests.model.JavaSearchBugs10Tests;
+import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+@SuppressWarnings({"rawtypes", "unchecked"})
+public class RunAllJava10Tests extends TestCase {
+
+ public RunAllJava10Tests(String name) {
+ super(name);
+ }
+ public static Class[] getAllTestClasses() {
+ return new Class[] {
+ JavaSearchBugs10Tests.class,
+ CompletionTests10.class,
+ };
+ }
+
+ public static Class[] getConverterTestClasses() {
+ return new Class[] {
+ ASTConverter10Test.class,
+ };
+ }
+
+ public static Class[] getCompilerClasses() {
+ return new Class[] {
+ org.eclipse.jdt.core.tests.eval.TestAll.class,
+ org.eclipse.jdt.core.tests.compiler.regression.TestAll.class,
+ };
+ }
+
+ public static Test suite() {
+ TestSuite ts = new TestSuite(RunAllJava10Tests.class.getName());
+
+ Class[] testClasses = getAllTestClasses();
+ addTestsToSuite(ts, testClasses);
+ testClasses = getConverterTestClasses();
+ addTestsToSuite(ts, testClasses);
+
+ AbstractCompilerTest.setpossibleComplianceLevels(AbstractCompilerTest.F_10);
+ addTestsToSuite(ts, getCompilerClasses());
+ // ComplianceDiagnoseTest is already added to the test suite through getTestSuite
+ ts.addTest(org.eclipse.jdt.core.tests.compiler.parser.TestAll.getTestSuite(false));
+ return ts;
+ }
+ public static void addTestsToSuite(TestSuite suite, Class[] testClasses) {
+
+ for (int i = 0; i < testClasses.length; i++) {
+ Class testClass = testClasses[i];
+ // call the suite() method and add the resulting suite to the suite
+ try {
+ Method suiteMethod = testClass.getDeclaredMethod("suite", new Class[0]); //$NON-NLS-1$
+ Test test = (Test)suiteMethod.invoke(null, new Object[0]);
+ suite.addTest(test);
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.getTargetException().printStackTrace();
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ protected void tearDown() throws Exception {
+ ConverterTestSetup.PROJECT_SETUP = false;
+ super.tearDown();
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter10Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter10Test.java
new file mode 100644
index 000000000..6150d12b8
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter10Test.java
@@ -0,0 +1,150 @@
+/*******************************************************************************
+ * Copyright (c) 2018 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
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.dom;
+
+import junit.framework.Test;
+
+import org.eclipse.jdt.core.dom.*;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.JavaModelException;
+
+public class ASTConverter10Test extends ConverterTestSetup {
+
+ ICompilationUnit workingCopy;
+// private static final String jcl9lib = "CONVERTER_JCL9_LIB";
+
+
+ public void setUpSuite() throws Exception {
+ super.setUpSuite();
+ this.ast = AST.newAST(AST_INTERNAL_JLS10);
+ }
+
+ public ASTConverter10Test(String name) {
+ super(name);
+ }
+
+ static {
+// TESTS_NUMBERS = new int[] { 19 };
+// TESTS_RANGE = new int[] { 1, -1 };
+// TESTS_NAMES = new String[] {"testBug532421_002"};
+ }
+ public static Test suite() {
+ String javaVersion = System.getProperty("java.version");
+ if (javaVersion.length() > 3) {
+ javaVersion = javaVersion.substring(0, 3);
+ }
+ long jdkLevel = CompilerOptions.versionToJdkLevel(javaVersion);
+ if (jdkLevel >= ClassFileConstants.JDK9) {
+ isJRE9 = true;
+ }
+ return buildModelTestSuite(ASTConverter10Test.class);
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ if (this.workingCopy != null) {
+ this.workingCopy.discardWorkingCopy();
+ this.workingCopy = null;
+ }
+ }
+
+ public void testBug527558_001() throws JavaModelException {
+ String contents =
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " var x = new X();\n" +
+ " for (var i = 0; i < 10; ++i) {}\n" +
+ " }\n" +
+ "}";
+ this.workingCopy = getWorkingCopy("/Converter10/src/X.java", true/*resolve*/);
+ ASTNode node = buildAST(contents, this.workingCopy);
+ assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
+ node = getASTNode((CompilationUnit)node, 0, 0);
+ MethodDeclaration methodDeclaration = (MethodDeclaration) node;
+ VariableDeclarationStatement vStmt = (VariableDeclarationStatement) methodDeclaration.getBody().statements().get(0);
+ checkSourceRange(vStmt, "var x = new X();", contents);
+ Type type = vStmt.getType();
+ assertNotNull(type);
+ assertTrue("not a var", type.isVar());
+ IBinding binding = type.resolveBinding();
+ assertTrue("null binding", binding != null);
+ }
+ public void testBug527558_002() throws JavaModelException {
+ String contents =
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " var i = y -> 1;\n" +
+ " }\n" +
+ "}\n" +
+ "interface I {\n" +
+ " public int foo(int i);\n" +
+ "}\n";
+ this.workingCopy = getWorkingCopy("/Converter10/src/X.java", true/*resolve*/);
+ ASTNode node = buildAST(contents, this.workingCopy, false);
+ assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
+ node = getASTNode((CompilationUnit)node, 0, 0);
+ MethodDeclaration methodDeclaration = (MethodDeclaration) node;
+ VariableDeclarationStatement vStmt = (VariableDeclarationStatement) methodDeclaration.getBody().statements().get(0);
+ checkSourceRange(vStmt, "var i = y -> 1;", contents);
+ Type type = vStmt.getType();
+ assertTrue("not a var", type.isVar());
+ IBinding binding = type.resolveBinding();
+ assertTrue("null binding", binding != null);
+ }
+ public void testBug532421_001() throws JavaModelException {
+ String contents =
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " var arr1 = new String[10];\n" +
+ " }\n" +
+ "}";
+ this.workingCopy = getWorkingCopy("/Converter10/src/X.java", true/*resolve*/);
+ ASTNode node = buildAST(contents, this.workingCopy, false);
+ assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
+ node = getASTNode((CompilationUnit)node, 0, 0);
+ MethodDeclaration methodDeclaration = (MethodDeclaration) node;
+ VariableDeclarationStatement vStmt = (VariableDeclarationStatement) methodDeclaration.getBody().statements().get(0);
+ checkSourceRange(vStmt, "var arr1 = new String[10];", contents);
+ Type type = vStmt.getType();
+ assertTrue("not a var", type.isVar());
+ IBinding binding = type.resolveBinding();
+ assertTrue("null binding", binding != null);
+ assertTrue("binding incorrect", binding.getName().equals("String[]"));
+ }
+ public void testBug532421_002() throws JavaModelException {
+ String contents =
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " var list = new Y<String>();\n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {}";
+ this.workingCopy = getWorkingCopy("/Converter10/src/X.java", true/*resolve*/);
+ ASTNode node = buildAST(contents, this.workingCopy, false);
+ assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
+ node = getASTNode((CompilationUnit)node, 0, 0);
+ MethodDeclaration methodDeclaration = (MethodDeclaration) node;
+ VariableDeclarationStatement vStmt = (VariableDeclarationStatement) methodDeclaration.getBody().statements().get(0);
+ checkSourceRange(vStmt, "var list = new Y<String>();", contents);
+ Type type = vStmt.getType();
+ assertTrue("not a var", type.isVar());
+ IBinding binding = type.resolveBinding();
+ assertTrue("null binding", binding != null);
+ assertTrue("binding incorrect", binding.getName().equals("Y<String>"));
+ }
+// Add new tests here
+}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter9Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter9Test.java
index f501ee8c6..c88e4ef7d 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter9Test.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter9Test.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2016, 2017 IBM Corporation and others.
+ * Copyright (c) 2016, 2018 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
*******************************************************************************/
@@ -43,7 +47,13 @@ public class ASTConverter9Test extends ConverterTestSetup {
public void setUpSuite() throws Exception {
super.setUpSuite();
- this.ast = AST.newAST(AST_INTERNAL_JLS9);
+ this.ast = AST.newAST(getAST9());
+ }
+ /**
+ * @deprecated
+ */
+ static int getAST9() {
+ return AST.JLS9;
}
public ASTConverter9Test(String name) {
@@ -164,7 +174,7 @@ public class ASTConverter9Test extends ConverterTestSetup {
this.workingCopies[0] = getWorkingCopy(
"/Converter9/src/module-info.java", content);
- CompilationUnit unit = (CompilationUnit) runConversion(AST_INTERNAL_JLS9, this.workingCopies[0], false/*no bindings*/);
+ CompilationUnit unit = (CompilationUnit) runConversion(this.ast.apiLevel(), this.workingCopies[0], false/*no bindings*/);
ModuleDeclaration moduleDecl = unit.getModule();
assertFalse(moduleDecl.isOpen());
@@ -259,7 +269,7 @@ public class ASTConverter9Test extends ConverterTestSetup {
"}\n";
createFile("/Bug514417/src/pack1/X.java", content);
ICompilationUnit sourceUnit = getCompilationUnit("Bug514417" , "src", "pack1", "X.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- ASTNode unit = runConversion(AST_INTERNAL_JLS9, sourceUnit, true);
+ ASTNode unit = runConversion(this.ast.apiLevel(), sourceUnit, true);
assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, unit.getNodeType());
List imps = ((CompilationUnit) unit).imports();
assertEquals("import missing", 1, imps.size());
@@ -299,7 +309,7 @@ public class ASTConverter9Test extends ConverterTestSetup {
this.workingCopies[0] = getWorkingCopy(
"/Converter9/src/module-info.java", content);
- CompilationUnit unit = (CompilationUnit) runConversion(AST_INTERNAL_JLS9, this.workingCopies[0], false/*no bindings*/);
+ CompilationUnit unit = (CompilationUnit) runConversion(this.ast.apiLevel(), this.workingCopies[0], false/*no bindings*/);
ModuleDeclaration moduleDecl = unit.getModule();
assertTrue(moduleDecl.isOpen());
@@ -425,7 +435,7 @@ public class ASTConverter9Test extends ConverterTestSetup {
project3.open(null);
ICompilationUnit sourceUnit1 = getCompilationUnit("ConverterTests9" , "src", "", "module-info.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- ASTNode unit1 = runConversion(AST_INTERNAL_JLS9, sourceUnit1, true);
+ ASTNode unit1 = runConversion(this.ast.apiLevel(), sourceUnit1, true);
assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, unit1.getNodeType());
ModuleDeclaration moduleDecl1 = ((CompilationUnit) unit1).getModule();
checkSourceRange(moduleDecl1, fileContent, fileContent);
@@ -440,7 +450,7 @@ public class ASTConverter9Test extends ConverterTestSetup {
// indirectly fetch the binary version of "first" via "third":
ICompilationUnit sourceUnit3 = getCompilationUnit("third" , "src", "", "module-info.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- ASTNode unit3 = runConversion(AST_INTERNAL_JLS9, sourceUnit3, true);
+ ASTNode unit3 = runConversion(this.ast.apiLevel(), sourceUnit3, true);
assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, unit3.getNodeType());
ModuleDeclaration moduleDecl3 = ((CompilationUnit) unit3).getModule();
IModuleBinding firstModAsBinary = moduleDecl3.resolveBinding().getRequiredModules()[1]; // skip java.base
@@ -531,7 +541,7 @@ public class ASTConverter9Test extends ConverterTestSetup {
project1.open(null);
ICompilationUnit sourceUnit1 = getCompilationUnit("ConverterTests9" , "src", "", "module-info.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- ASTNode unit1 = runConversion(AST_INTERNAL_JLS9, sourceUnit1, true);
+ ASTNode unit1 = runConversion(this.ast.apiLevel(), sourceUnit1, true);
assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, unit1.getNodeType());
ModuleDeclaration moduleDecl1 = ((CompilationUnit) unit1).getModule();
checkSourceRange(moduleDecl1, fileContent, fileContent);
@@ -587,7 +597,7 @@ public class ASTConverter9Test extends ConverterTestSetup {
project1.open(null);
ICompilationUnit sourceUnit1 = getCompilationUnit("ConverterTests9" , "src", "", "module-info.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- ASTNode unit1 = runConversion(AST_INTERNAL_JLS9, sourceUnit1, true);
+ ASTNode unit1 = runConversion(this.ast.apiLevel(), sourceUnit1, true);
assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, unit1.getNodeType());
ModuleDeclaration moduleDecl1 = ((CompilationUnit) unit1).getModule();
checkSourceRange(moduleDecl1, fileContent, fileContent);
@@ -653,7 +663,7 @@ public class ASTConverter9Test extends ConverterTestSetup {
project1.open(null);
ICompilationUnit sourceUnit1 = getCompilationUnit("ConverterTests9" , "src", "", "module-info.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- ASTNode unit1 = runConversion(AST_INTERNAL_JLS9, sourceUnit1, true);
+ ASTNode unit1 = runConversion(this.ast.apiLevel(), sourceUnit1, true);
assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, unit1.getNodeType());
ModuleDeclaration moduleDecl1 = ((CompilationUnit) unit1).getModule();
checkSourceRange(moduleDecl1, fileContent, fileContent);
@@ -705,7 +715,7 @@ public class ASTConverter9Test extends ConverterTestSetup {
+ "}";
this.workingCopies[0] = getWorkingCopy("/Converter9/src/module-info.java", content);
- CompilationUnit unit = (CompilationUnit) runConversion(AST_INTERNAL_JLS9, this.workingCopies[0], false/*no bindings*/);
+ CompilationUnit unit = (CompilationUnit) runConversion(this.ast.apiLevel(), this.workingCopies[0], false/*no bindings*/);
ModuleDeclaration moduleDecl = unit.getModule();
checkSourceRange(moduleDecl, content, content);
}
@@ -717,7 +727,7 @@ public class ASTConverter9Test extends ConverterTestSetup {
+ "}";
this.workingCopies[0] = getWorkingCopy("/Converter9/src/p/I1.java", content);
- CompilationUnit unit = (CompilationUnit) runConversion(AST_INTERNAL_JLS9, this.workingCopies[0], false/*no bindings*/);
+ CompilationUnit unit = (CompilationUnit) runConversion(this.ast.apiLevel(), this.workingCopies[0], false/*no bindings*/);
AbstractTypeDeclaration typeDeclaration = (AbstractTypeDeclaration) unit.types().get(0);
MethodDeclaration method = (MethodDeclaration) typeDeclaration.bodyDeclarations().get(0);
assertTrue("Method Malformed", (method.getFlags() & ASTNode.MALFORMED) == 0);
@@ -737,7 +747,7 @@ public class ASTConverter9Test extends ConverterTestSetup {
IJavaElement[] elements = new IJavaElement[] {
firstModule,
};
- ASTParser parser = ASTParser.newParser(AST_INTERNAL_JLS9);
+ ASTParser parser = ASTParser.newParser(this.ast.apiLevel());
parser.setProject(project1);
IBinding[] bindings = parser.createBindings(elements, null);
assertBindingsEqual(
@@ -783,7 +793,7 @@ public class ASTConverter9Test extends ConverterTestSetup {
IJavaElement[] elements = new IJavaElement[] {
firstModule,
};
- ASTParser parser = ASTParser.newParser(AST_INTERNAL_JLS9);
+ ASTParser parser = ASTParser.newParser(this.ast.apiLevel());
parser.setProject(project2);
IBinding[] bindings = parser.createBindings(elements, null);
assertBindingsEqual(
@@ -818,7 +828,7 @@ public class ASTConverter9Test extends ConverterTestSetup {
project1.open(null);
ICompilationUnit sourceUnit1 = getCompilationUnit("ConverterTests9" , "src", "pack", "X.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- ASTNode unit1 = runConversion(AST_INTERNAL_JLS9, sourceUnit1, true);
+ ASTNode unit1 = runConversion(this.ast.apiLevel(), sourceUnit1, true);
assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, unit1.getNodeType());
CompilationUnit cu = (CompilationUnit) unit1;
ImportDeclaration importDeclaration = (ImportDeclaration) cu.imports().get(0);
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTTest.java
index f4591d6f9..cf68d4528 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTTest.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
* Technical University Berlin - adapted for Object Teams
@@ -41,6 +45,7 @@ public class ASTTest extends org.eclipse.jdt.core.tests.junit.extension.TestCase
/**
* Internal synonym for constant AST.JSL9
* to alleviate deprecation warnings once AST.JLS9 is deprecated in future.
+ * @deprecated
*/
protected static final int AST_INTERNAL_JLS9 = AST.JLS9;
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/AbstractASTTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/AbstractASTTests.java
index 7192aea4f..9637f90ec 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/AbstractASTTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/AbstractASTTests.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2004, 2016 IBM Corporation and others.
+ * Copyright (c) 2004, 2018 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
*******************************************************************************/
@@ -485,11 +489,14 @@ public class AbstractASTTests extends ModifyingResourceTests implements DefaultM
return new ASTNode[] {unit};
return nodes;
}
+ @SuppressWarnings("deprecation")
protected ASTNode[] buildASTs(String newContents, ICompilationUnit cu, boolean reportErrors, boolean enableStatementRecovery, boolean bindingRecovery) throws JavaModelException {
String option = cu.getJavaProject().getOption(JavaCore.COMPILER_COMPLIANCE, true);
long jdkLevel = CompilerOptions.versionToJdkLevel(option);
int JLSLevel = AST_INTERNAL_JLS3;
- if (jdkLevel >= ClassFileConstants.JDK9) {
+ if (jdkLevel >= ClassFileConstants.JDK10) {
+ JLSLevel = AST_INTERNAL_JLS10;
+ } else if (jdkLevel >= ClassFileConstants.JDK9) {
JLSLevel = AST_INTERNAL_JLS9;
} else if (jdkLevel >= ClassFileConstants.JDK1_8) {
JLSLevel = AST_INTERNAL_JLS8;
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ConverterTestSetup.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ConverterTestSetup.java
index 9da38a030..bed8145a6 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ConverterTestSetup.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ConverterTestSetup.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
*******************************************************************************/
@@ -100,6 +104,7 @@ public abstract class ConverterTestSetup extends AbstractASTTests {
this.deleteProject("Converter17"); //$NON-NLS-1$
this.deleteProject("Converter18"); //$NON-NLS-1$
this.deleteProject("Converter9"); //$NON-NLS-1$
+ this.deleteProject("Converter10"); //$NON-NLS-1$
PROJECT_SETUP = false;
} else {
TEST_SUITES.remove(getClass());
@@ -110,6 +115,7 @@ public abstract class ConverterTestSetup extends AbstractASTTests {
this.deleteProject("Converter17"); //$NON-NLS-1$
this.deleteProject("Converter18"); //$NON-NLS-1$
this.deleteProject("Converter9"); //$NON-NLS-1$
+ this.deleteProject("Converter10"); //$NON-NLS-1$
PROJECT_SETUP = false;
}
}
@@ -155,6 +161,14 @@ public abstract class ConverterTestSetup extends AbstractASTTests {
new IPath[] {getConverterJCLPath("9"), getConverterJCLSourcePath("9"), getConverterJCLRootSourcePath()},
null);
}
+ } else if ("10".equals(compliance)) {
+ if (JavaCore.getClasspathVariable("CONVERTER_JCL10_LIB") == null) {
+ setupExternalJCL("converterJclMin10");
+ JavaCore.setClasspathVariables(
+ new String[] {"CONVERTER_JCL10_LIB", "CONVERTER_JCL10_SRC", "CONVERTER_JCL10_SRCROOT"},
+ new IPath[] {getConverterJCLPath("10"), getConverterJCLSourcePath("10"), getConverterJCLRootSourcePath()},
+ null);
+ }
} else if (JavaCore.getClasspathVariable("CONVERTER_JCL_LIB") == null) {
setupExternalJCL("converterJclMin");
JavaCore.setClasspathVariables(
@@ -177,6 +191,7 @@ public abstract class ConverterTestSetup extends AbstractASTTests {
setUpJavaProject("Converter17", "1.7"); //$NON-NLS-1$ //$NON-NLS-2$
setUpJavaProject("Converter18", "1.8"); //$NON-NLS-1$ //$NON-NLS-2$
setUpJavaProject("Converter9", "9"); //$NON-NLS-1$ //$NON-NLS-2$
+ setUpJavaProject("Converter10", "10"); //$NON-NLS-1$ //$NON-NLS-2$
waitUntilIndexesReady(); // needed to find secondary types
PROJECT_SETUP = true;
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/TypeAnnotationsConverterTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/TypeAnnotationsConverterTest.java
index 89a341092..8b179d937 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/TypeAnnotationsConverterTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/TypeAnnotationsConverterTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -23,7 +23,7 @@ public class TypeAnnotationsConverterTest extends ConverterTestSetup {
public void setUpSuite() throws Exception {
super.setUpSuite();
- this.ast = AST.newAST(AST_INTERNAL_JLS9);
+ this.ast = AST.newAST(AST_INTERNAL_JLS10);
}
public TypeAnnotationsConverterTest(String name) {
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java
index ac0257d79..5ad2d3adf 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java
@@ -5,6 +5,10 @@
* 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
*******************************************************************************/
@@ -85,8 +89,14 @@ public abstract class AbstractJavaModelTests extends SuiteOfTestCases {
/**
* Internal synonym for constant AST.JSL9
* to alleviate deprecation warnings once AST.JLS9 is deprecated in future.
+ * @deprecated
*/
protected static final int AST_INTERNAL_JLS9 = AST.JLS9;
+ /**
+ * Internal synonym for constant AST.JSL10
+ * to alleviate deprecation warnings once AST.JLS10 is deprecated in future.
+ */
+ protected static final int AST_INTERNAL_JLS10 = AST.JLS10;
public static class BasicProblemRequestor implements IProblemRequestor {
public void acceptProblem(IProblem problem) {}
@@ -1303,15 +1313,21 @@ public abstract class AbstractJavaModelTests extends SuiteOfTestCases {
return createJava9Project(name, new String[]{"src"});
}
protected IJavaProject createJava9Project(String name, String[] srcFolders) throws CoreException {
- return createJava9ProjectWithJREAttributes(name, srcFolders, null);
+ return createJava9ProjectWithJREAttributes(name, srcFolders, null, "9");
+ }
+ protected IJavaProject createJava10Project(String name, String[] srcFolders) throws CoreException {
+ return createJava9ProjectWithJREAttributes(name, srcFolders, null, "10");
}
protected IJavaProject createJava9ProjectWithJREAttributes(String name, String[] srcFolders, IClasspathAttribute[] attributes) throws CoreException {
+ return createJava9ProjectWithJREAttributes(name, srcFolders, attributes, "9");
+ }
+ protected IJavaProject createJava9ProjectWithJREAttributes(String name, String[] srcFolders, IClasspathAttribute[] attributes, String compliance) throws CoreException {
String javaHome = System.getProperty("java.home") + File.separator;
Path bootModPath = new Path(javaHome +"/lib/jrt-fs.jar");
Path sourceAttachment = new Path(javaHome +"/lib/src.zip");
IClasspathEntry jrtEntry = JavaCore.newLibraryEntry(bootModPath, sourceAttachment, null, null, attributes, false);
IJavaProject project = this.createJavaProject(name, srcFolders, new String[0],
- new String[0], "bin", "9");
+ new String[0], "bin", compliance);
IClasspathEntry[] old = project.getRawClasspath();
IClasspathEntry[] newPath = new IClasspathEntry[old.length +1];
System.arraycopy(old, 0, newPath, 0, old.length);
@@ -1849,6 +1865,12 @@ public abstract class AbstractJavaModelTests extends SuiteOfTestCases {
options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_9);
options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_9);
javaProject.setOptions(options);
+ } else if ("10".equals(compliance)) {
+ Map options = new HashMap();
+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_10);
+ options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_10);
+ options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_10);
+ javaProject.setOptions(options);
}
result[0] = javaProject;
}
@@ -2941,7 +2963,10 @@ public abstract class AbstractJavaModelTests extends SuiteOfTestCases {
newJclLibString = "JCL18_FULL";
newJclSrcString = "JCL18_SRC"; // Use the same source
} else {
- if (compliance.length() < 3) {
+ if (compliance.equals("10")) {
+ newJclLibString = "JCL10_LIB";
+ newJclSrcString = "JCL10_SRC";
+ } else if (compliance.length() < 3) {
newJclLibString = "JCL19_LIB";
newJclSrcString = "JCL19_SRC";
} else if (compliance.charAt(2) > '7') {
@@ -2990,9 +3015,10 @@ public abstract class AbstractJavaModelTests extends SuiteOfTestCases {
IPath jcl5Lib = new Path("JCL15_LIB");
IPath jcl8Lib = new Path("JCL18_LIB");
IPath jcl9Lib = new Path("JCL19_LIB");
+ IPath jcl10Lib = new Path("JCL10_LIB");
IPath jclFull = new Path("JCL18_FULL");
- return path.equals(jclLib) || path.equals(jcl5Lib) || path.equals(jcl8Lib) || path.equals(jcl9Lib) || path.equals(jclFull);
+ return path.equals(jclLib) || path.equals(jcl5Lib) || path.equals(jcl8Lib) || path.equals(jcl9Lib) || path.equals(jcl10Lib) || path.equals(jclFull);
}
public void setUpJCLClasspathVariables(String compliance) throws JavaModelException, IOException {
setUpJCLClasspathVariables(compliance, false);
@@ -3039,6 +3065,14 @@ public abstract class AbstractJavaModelTests extends SuiteOfTestCases {
new IPath[] {getExternalJCLPath("9"), getExternalJCLSourcePath("9"), getExternalJCLRootSourcePath()},
null);
}
+ } else if ("10".equals(compliance)) {
+ if (JavaCore.getClasspathVariable("JCL10_LIB") == null) {
+ setupExternalJCL("jclMin10");
+ JavaCore.setClasspathVariables(
+ new String[] {"JCL10_LIB", "JCL10_SRC", "JCL_SRCROOT"},
+ new IPath[] {getExternalJCLPath("9"), getExternalJCLSourcePath("9"), getExternalJCLRootSourcePath()},
+ null);
+ }
} else {
if (JavaCore.getClasspathVariable("JCL_LIB") == null) {
setupExternalJCL("jclMin");
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java
index 15454c744..18ecda8ba 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -2596,7 +2596,7 @@ public void testBug495598_001() throws CoreException {
"public class X {}\n");
ICompilationUnit cuD = getCompilationUnit("/P/src/X.java");
- ASTParser parser = ASTParser.newParser(AST_INTERNAL_JLS9);
+ ASTParser parser = ASTParser.newParser(AST_INTERNAL_JLS10);
parser.setProject(this.testProject);
parser.setSource(cuD);
parser.setResolveBindings(true);
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests10.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests10.java
new file mode 100644
index 000000000..8ff3ac113
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests10.java
@@ -0,0 +1,354 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Jesper Steen Møller 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:
+ * Jesper Steen Møller - initial API and implementation
+ * bug 529556 - [18.3] Add content assist support for 'var' as a type
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.model;
+
+import java.util.stream.Stream;
+
+import org.eclipse.jdt.core.JavaModelException;
+
+import junit.framework.Test;
+
+public class CompletionTests10 extends AbstractJavaModelCompletionTests {
+ static {
+// TESTS_NAMES = new String[]{"test0001_block_scope"};
+ }
+public CompletionTests10(String name) {
+ super(name);
+}
+public void setUpSuite() throws Exception {
+ if (COMPLETION_PROJECT == null) {
+ COMPLETION_PROJECT = setUpJavaProject("Completion", "10");
+ } else {
+ setUpProjectCompliance(COMPLETION_PROJECT, "10");
+ }
+ super.setUpSuite();
+}
+public static Test suite() {
+ return buildModelTestSuite(CompletionTests10.class);
+}
+public void test0001_block_scope() throws JavaModelException {
+ CompletionResult result = complete(
+ "/Completion/src3/test0001/Test.java",
+ "package test0001;\n" +
+ "\n" +
+ "public class Test {\n" +
+ " void x() {\n" +
+ " va\n" +
+ " }\n" +
+ "}",
+ "va");
+
+ assertResults(
+ "expectedTypesSignatures=null\n" +
+ "expectedTypesKeys=null",
+ result.context);
+
+ assertResults(
+ "var[KEYWORD]{var, null, null, var, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
+ result.proposals);
+}
+public void test0001a_block_scope_switch() throws JavaModelException {
+ CompletionResult result = complete(
+ "/Completion/src3/test0001/Test.java",
+ "package test0001;\n" +
+ "\n" +
+ "public class Test {\n" +
+ " void x(int a) {\n" +
+ " switch(a) {\n" +
+ " case 1: va\n" +
+ " }\n" +
+ " }\n" +
+ "}",
+ "va");
+
+ assertResults(
+ "expectedTypesSignatures=null\n" +
+ "expectedTypesKeys=null",
+ result.context);
+
+ assertResults(
+ "var[KEYWORD]{var, null, null, var, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
+ result.proposals);
+}
+public void test0002_block_scope_final() throws JavaModelException {
+ CompletionResult result = complete(
+ "/Completion/src3/test0002/Test.java",
+ "package test0002;\n" +
+ "\n" +
+ "public class Test {\n" +
+ " void x() {\n" +
+ " final va\n" +
+ " }\n" +
+ "}",
+ "va");
+
+ assertResults(
+ "expectedTypesSignatures=null\n" +
+ "expectedTypesKeys=null",
+ result.context);
+
+ assertResults(
+ "var[KEYWORD]{var, null, null, var, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
+ result.proposals);
+}
+public void test0003_inside_for() throws JavaModelException {
+ CompletionResult result = complete(
+ "/Completion/src3/test0003/Test.java",
+ "package test0003;\n" +
+ "\n" +
+ "public class Test {\n" +
+ " void x() {\n" +
+ " for(va\n" +
+ " }\n" +
+ "}",
+ "va");
+
+ assertResults(
+ "expectedTypesSignatures=null\n" +
+ "expectedTypesKeys=null",
+ result.context);
+
+ assertResults(
+ "var[KEYWORD]{var, null, null, var, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
+ result.proposals);
+}
+public void test0004_inside_for_final() throws JavaModelException {
+ CompletionResult result = complete(
+ "/Completion/src3/test0004/Test.java",
+ "package test0004;\n" +
+ "\n" +
+ "public class Test {\n" +
+ " void x() {\n" +
+ " for(final va\n" +
+ " }\n" +
+ "}",
+ "va");
+
+ assertResults(
+ "expectedTypesSignatures=null\n" +
+ "expectedTypesKeys=null",
+ result.context);
+
+ assertResults(
+ "var[KEYWORD]{var, null, null, var, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
+ result.proposals);
+}
+public void test0005_inside_try() throws JavaModelException {
+ CompletionResult result = complete(
+ "/Completion/src3/test0005/Test.java",
+ "package test0005;\n" +
+ "\n" +
+ "public class Test {\n" +
+ " void x() {\n" +
+ " try(va\n" +
+ " }\n" +
+ "}",
+ "va");
+
+ assertResults(
+ "expectedTypesSignatures=null\n" +
+ "expectedTypesKeys=null",
+ result.context);
+
+ assertResults(
+ "var[KEYWORD]{var, null, null, var, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
+ result.proposals);
+}
+public void test0006_inside_try_final() throws JavaModelException {
+ CompletionResult result = complete(
+ "/Completion/src3/test0006/Test.java",
+ "package test0006;\n" +
+ "\n" +
+ "public class Test {\n" +
+ " void x() {\n" +
+ " try(final va\n" +
+ " }\n" +
+ "}",
+ "va");
+
+ assertResults(
+ "expectedTypesSignatures=null\n" +
+ "expectedTypesKeys=null",
+ result.context);
+
+ assertResults(
+ "var[KEYWORD]{var, null, null, var, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
+ result.proposals);
+}
+
+public void test0007_not_inside_expression() throws JavaModelException {
+ CompletionResult result = complete(
+ "/Completion/src3/test0007/Test.java",
+ "package test0007;\n" +
+ "\n" +
+ "public class Test {\n" +
+ " void x() {\n" +
+ " int a = 2 + \n" +
+ " }\n" +
+ "}",
+ "+ ");
+
+ assertResults(
+ "expectedTypesSignatures={S,I,J,F,D,C,B,Ljava.lang.String;}\n" +
+ "expectedTypesKeys={S,I,J,F,D,C,B,Ljava/lang/String;}",
+ result.context);
+
+ assertProposalCount("var[KEYWORD]", 0, 14, result);
+}
+
+public void test0008_not_in_class_scope() throws JavaModelException {
+ CompletionResult result = complete(
+ "/Completion/src3/test0008/Test.java",
+ "package test0008;\n" +
+ "\n" +
+ "public class Test { \n" +
+
+ "}",
+ "{");
+
+ assertResults(
+ "expectedTypesSignatures=null\n" +
+ "expectedTypesKeys=null",
+ result.context);
+
+ assertProposalCount("var[KEYWORD]", 0, 21, result);
+}
+ public void test0009_in_formal_param_lists() throws JavaModelException {
+ CompletionResult result = complete(
+ "/Completion/src3/test0009/Test.java",
+ "package test0009;\n" +
+ "\n" +
+ "public class Test {\n" +
+ " void x( ) {\n" +
+ " }\n" +
+ "}",
+ "x(");
+
+ assertResults(
+ "expectedTypesSignatures=null\n" +
+ "expectedTypesKeys=null",
+ result.context);
+ assertProposalCount("var[KEYWORD]", 0, 15, result);
+ }
+
+public void testbug_529556_missing_type_info_on_vars() throws JavaModelException {
+ CompletionResult result = complete(
+ "/Completion/src3/test0001/Test.java",
+ "package test0001;\n" +
+ "\n" +
+ "public class Test {\n" +
+ " private class Dummy {\n" +
+ " public void a_method() {/n"+
+ " }\n" +
+ " void x() {\n" +
+ " var x = new Dummy();\n" +
+ " x.a\n" +
+ " }\n" +
+ "}",
+ "x.a");
+ assertResults(
+ "a_method[METHOD_REF]{a_method(), Ltest0001.Test$Dummy;, ()V, a_method, null, " + (R_DEFAULT + 30) + "}",
+ result.proposals);
+}
+public void testBug532476a() throws JavaModelException {
+ CompletionResult result = complete(
+ "/Completion/src3/p/X.java",
+ "package p;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " var i_jk = 0;\n" +
+ " System.out.println(i_);/n"+
+ " }\n" +
+ "}",
+ "i_");
+ assertResults(
+ "i_jk[LOCAL_VARIABLE_REF]{i_jk, null, I, i_jk, null, " + (R_DEFAULT + 22) + "}",
+ result.proposals);
+}
+public void testBug532476b() throws JavaModelException {
+ CompletionResult result = complete(
+ "/Completion/src3/p/X.java",
+ "package p;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " for (var i_jkl : args) {\n" +
+ " System.out.println(i_);/n"+
+ " }\n" +
+ " }\n" +
+ "}",
+ "i_");
+ assertResults(
+ "i_jkl[LOCAL_VARIABLE_REF]{i_jkl, null, Ljava.lang.Object;, i_jkl, null, " + (R_DEFAULT + 22) + "}",
+ result.proposals);
+}
+public void testBug532476c() throws JavaModelException {
+ CompletionResult result = complete(
+ "/Completion/src3/p/X.java",
+ "package p;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " for (var i_jkl = 0; i_ " +
+ " }\n" +
+ "}",
+ "i_");
+ assertResults(
+ "i_jkl[LOCAL_VARIABLE_REF]{i_jkl, null, I, i_jkl, null, " + (R_DEFAULT + 22) + "}",
+ result.proposals);
+}
+public void testBug532476d() throws JavaModelException {
+ CompletionResult result = complete(
+ "/Completion/src3/p/X.java",
+ "package p;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " for (var i_jkl = 0; ; i_ " +
+ " }\n" +
+ "}",
+ "i_");
+ assertResults(
+ "i_jkl[LOCAL_VARIABLE_REF]{i_jkl, null, I, i_jkl, null, " + (R_DEFAULT + 22) + "}",
+ result.proposals);
+}
+public void testBug532476e() throws JavaModelException {
+ CompletionResult result = complete(
+ "/Completion/src3/p/X.java",
+ "package p;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " for (var i_jkl : args) {\n" +
+ " System.out.println(i_jkl.fin);/n"+
+ " }\n" +
+ " }\n" +
+ "}",
+ "i_jkl.fin");
+ assertResults(
+ "finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, " + (R_DEFAULT + 30) + "}",
+ result.proposals);
+}
+private void assertProposalCount(String proposal, int expectedCount, int expectedOtherCount, CompletionResult result) {
+ String[] proposals = result.proposals.split("\n");
+ long proposalsCount = Stream.of(proposals).filter(s -> s.startsWith(proposal)).count();
+ assertEquals(
+ "Unexpected occurrences of " + proposal + " - result was " + result.proposals,
+ expectedCount, proposalsCount);
+
+ long otherProposalsCount = proposals.length - proposalsCount;
+ assertEquals(
+ "Unexpected occurrences that were not " + proposal + " - result was " + result.proposals,
+ expectedOtherCount, otherProposalsCount);
+}
+
+}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaConventionTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaConventionTests.java
index f8e28347b..a3fad9884 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaConventionTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaConventionTests.java
@@ -96,6 +96,7 @@ public class JavaConventionTests extends AbstractJavaModelTests {
CompilerOptions.VERSION_1_7,
CompilerOptions.VERSION_1_8,
CompilerOptions.VERSION_9,
+ CompilerOptions.VERSION_10,
};
/*
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java
index 4e29db6d5..0e3b05445 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java
@@ -2633,7 +2633,7 @@ public void testBug351697() throws Exception {
proj.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
try {
- ASTParser parser= ASTParser.newParser(AST_INTERNAL_JLS9);
+ ASTParser parser= ASTParser.newParser(AST_INTERNAL_JLS10);
parser.setSource(unit);
parser.setResolveBindings(true);
ASTNode node = parser.createAST(null);
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs10Tests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs10Tests.java
new file mode 100644
index 000000000..6652b41e7
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs10Tests.java
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2018 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
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.model;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.WorkingCopyOwner;
+import org.eclipse.jdt.core.search.IJavaSearchScope;
+import org.eclipse.jdt.core.search.ReferenceMatch;
+import org.eclipse.jdt.core.search.SearchEngine;
+import org.eclipse.jdt.core.search.SearchMatch;
+import org.eclipse.jdt.core.search.TypeReferenceMatch;
+import junit.framework.Test;
+
+public class JavaSearchBugs10Tests extends AbstractJavaSearchTests {
+
+ static {
+// org.eclipse.jdt.internal.core.search.BasicSearchEngine.VERBOSE = true;
+// TESTS_NUMBERS = new int[] { 19 };
+// TESTS_RANGE = new int[] { 1, -1 };
+// TESTS_NAMES = new String[] {"testBug529434_001"};
+}
+
+public JavaSearchBugs10Tests(String name) {
+ super(name);
+ this.endChar = "";
+}
+public static Test suite() {
+ return buildModelTestSuite(JavaSearchBugs10Tests.class, BYTECODE_DECLARATION_ORDER);
+}
+class TestCollector extends JavaSearchResultCollector {
+ public void acceptSearchMatch(SearchMatch searchMatch) throws CoreException {
+ super.acceptSearchMatch(searchMatch);
+ }
+}
+class ReferenceCollector extends JavaSearchResultCollector {
+ protected void writeLine() throws CoreException {
+ super.writeLine();
+ ReferenceMatch refMatch = (ReferenceMatch) this.match;
+ IJavaElement localElement = refMatch.getLocalElement();
+ if (localElement != null) {
+ this.line.append("+[");
+ if (localElement.getElementType() == IJavaElement.ANNOTATION) {
+ this.line.append('@');
+ this.line.append(localElement.getElementName());
+ this.line.append(" on ");
+ this.line.append(localElement.getParent().getElementName());
+ } else {
+ this.line.append(localElement.getElementName());
+ }
+ this.line.append(']');
+ }
+ }
+
+}
+class TypeReferenceCollector extends ReferenceCollector {
+ protected void writeLine() throws CoreException {
+ super.writeLine();
+ TypeReferenceMatch typeRefMatch = (TypeReferenceMatch) this.match;
+ IJavaElement[] others = typeRefMatch.getOtherElements();
+ int length = others==null ? 0 : others.length;
+ if (length > 0) {
+ this.line.append("+[");
+ for (int i=0; i<length; i++) {
+ IJavaElement other = others[i];
+ if (i>0) this.line.append(',');
+ if (other.getElementType() == IJavaElement.ANNOTATION) {
+ this.line.append('@');
+ this.line.append(other.getElementName());
+ this.line.append(" on ");
+ this.line.append(other.getParent().getElementName());
+ } else {
+ this.line.append(other.getElementName());
+ }
+ }
+ this.line.append(']');
+ }
+ }
+}
+
+IJavaSearchScope getJavaSearchScope() {
+ return SearchEngine.createJavaSearchScope(new IJavaProject[] {getJavaProject("JavaSearchBugs")});
+}
+IJavaSearchScope getJavaSearchScopeBugs(String packageName, boolean addSubpackages) throws JavaModelException {
+ if (packageName == null) return getJavaSearchScope();
+ return getJavaSearchPackageScope("JavaSearchBugs", packageName, addSubpackages);
+}
+public ICompilationUnit getWorkingCopy(String path, String source) throws JavaModelException {
+ if (this.wcOwner == null) {
+ this.wcOwner = new WorkingCopyOwner() {};
+ }
+ return getWorkingCopy(path, source, this.wcOwner);
+}
+@Override
+public void setUpSuite() throws Exception {
+ super.setUpSuite();
+ JAVA_PROJECT = setUpJavaProject("JavaSearchBugs", "10");
+}
+public void tearDownSuite() throws Exception {
+ deleteProject("JavaSearchBugs");
+ super.tearDownSuite();
+}
+protected void setUp () throws Exception {
+ super.setUp();
+ this.resultCollector = new TestCollector();
+ this.resultCollector.showAccuracy(true);
+}
+
+public void testBug529434_001() throws CoreException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java",
+ "class B {\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) throws Exception {\n" +
+ " var B = new B();\n" +
+ " }\n" +
+ "}\n"
+ );
+ search("B", CONSTRUCTOR, REFERENCES, EXACT_RULE);
+ assertSearchResults("src/X.java void X.main(String[]) [new B()] EXACT_MATCH");
+}
+// Add more tests here
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java
index 1070abe3a..8f902e6f7 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2016, 2017 IBM Corporation and others.
+ * Copyright (c) 2016, 2018 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
*******************************************************************************/
@@ -707,9 +711,7 @@ public class ModuleBuilderTests extends ModifyingResourceTests {
Hashtable<String, String> javaCoreOptions = JavaCore.getOptions();
try {
IJavaProject project = setUpJavaProject("ConvertToModule", "9");
- if (!project.getOption("org.eclipse.jdt.core.compiler.compliance", true).equals("9")) {
- return;
- }
+ assertEquals(project.getOption("org.eclipse.jdt.core.compiler.compliance", true), "9");
project.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
IPackageFragmentRoot[] roots = project.getPackageFragmentRoots();
IPackageFragmentRoot theRoot = null;
@@ -4827,6 +4829,7 @@ public class ModuleBuilderTests extends ModifyingResourceTests {
JavaCore.setOptions(javaCoreOptions);
}
}
+ @Deprecated
public void testBug519935() throws CoreException, IOException {
if (!isJRE9) return;
Hashtable<String, String> javaCoreOptions = JavaCore.getOptions();
@@ -4895,6 +4898,7 @@ public class ModuleBuilderTests extends ModifyingResourceTests {
JavaCore.setOptions(javaCoreOptions);
}
}
+ @Deprecated
public void testBug520310() throws CoreException, IOException {
if (!isJRE9) return;
try {
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NullAnnotationModelTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NullAnnotationModelTests.java
index 6c76ce18b..9e73be422 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NullAnnotationModelTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NullAnnotationModelTests.java
@@ -293,7 +293,7 @@ public class NullAnnotationModelTests extends ReconcilerTests {
"Buildpath problem: the type invalid, which is configured as a null annotation type, cannot be resolved\n" +
"----------\n");
- ASTParser parser = ASTParser.newParser(AST_INTERNAL_JLS9);
+ ASTParser parser = ASTParser.newParser(AST_INTERNAL_JLS10);
parser.setProject(p);
parser.setResolveBindings(true);
parser.setSource(unit);
@@ -356,7 +356,7 @@ public class NullAnnotationModelTests extends ReconcilerTests {
assertEquals("Should have no markers", 0, markers.length);
// Challenge CompilationUnitResolver:
- ASTParser parser = ASTParser.newParser(AST_INTERNAL_JLS9);
+ ASTParser parser = ASTParser.newParser(AST_INTERNAL_JLS10);
parser.setProject(p);
parser.setResolveBindings(true);
parser.setSource(unit);
@@ -427,7 +427,7 @@ public class NullAnnotationModelTests extends ReconcilerTests {
assertEquals("Unexpected marker path", "/P/p1/C1.java", markers[0].getResource().getFullPath().toString());
// Challenge CompilationUnitResolver:
- ASTParser parser = ASTParser.newParser(AST_INTERNAL_JLS9);
+ ASTParser parser = ASTParser.newParser(AST_INTERNAL_JLS10);
parser.setProject(p);
parser.setResolveBindings(true);
parser.setSource(unit);
@@ -480,7 +480,7 @@ public class NullAnnotationModelTests extends ReconcilerTests {
final ICompilationUnit unit = getCompilationUnit("/P/p1/C1.java").getWorkingCopy(this.wcOwner, null);
assertNoProblem(c1SourceString.toCharArray(), unit);
- ASTParser parser = ASTParser.newParser(AST_INTERNAL_JLS9);
+ ASTParser parser = ASTParser.newParser(AST_INTERNAL_JLS10);
parser.setProject(p);
parser.setResolveBindings(true);
parser.setSource(unit);
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java
index 99e42e6f3..504b23c84 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -77,7 +77,7 @@ public class ReconcilerTests extends ModifyingResourceTests {
}
}
- /*package*/ static final int JLS_LATEST = AST.JLS9;
+ /*package*/ static final int JLS_LATEST = AST.JLS10;
static class ReconcileParticipant extends CompilationParticipant {
IJavaElementDelta delta;
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/RunCompletionModelTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/RunCompletionModelTests.java
index b06899c52..b75424e96 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/RunCompletionModelTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/RunCompletionModelTests.java
@@ -1,13 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
* Gábor Kövesdán - Contribution for Bug 350000 - [content assist] Include non-prefix matches in auto-complete suggestions
+ * Jesper Steen Møller - Contributions for bug 529552 - [18.3] Add 'var' in completions
*******************************************************************************/
package org.eclipse.jdt.core.tests.model;
@@ -34,6 +39,7 @@ public class RunCompletionModelTests extends junit.framework.TestCase {
COMPLETION_SUITES.add(CompletionTests_1_5.class);
COMPLETION_SUITES.add(CompletionTests18.class);
COMPLETION_SUITES.add(CompletionTests9.class);
+ COMPLETION_SUITES.add(CompletionTests10.class);
COMPLETION_SUITES.add(CompletionContextTests.class);
COMPLETION_SUITES.add(CompletionContextTests_1_5.class);
COMPLETION_SUITES.add(CompletionWithMissingTypesTests.class);
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/RunJavaSearchTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/RunJavaSearchTests.java
index 8b12c726d..733618923 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/RunJavaSearchTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/RunJavaSearchTests.java
@@ -62,6 +62,7 @@ public class RunJavaSearchTests extends junit.framework.TestCase {
allClasses.add(JavaSearchBugsTests2.class);
allClasses.add(JavaSearchBugs8Tests.class);
allClasses.add(JavaSearchBugs9Tests.class);
+ allClasses.add(JavaSearchBugs10Tests.class);
allClasses.add(JavaSearchMultipleProjectsTests.class);
allClasses.add(SearchTests.class);
allClasses.add(JavaSearchScopeTests.class);
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeResolveTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeResolveTests.java
index b54342b7e..62bac3eb1 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeResolveTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeResolveTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -1200,4 +1200,132 @@ public void test479963a() throws CoreException, IOException {
deleteProject("P");
}
}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=479963
+public void test531046a() throws CoreException, IOException {
+ if (!isJRE9) return;
+ try {
+ createJava10Project("P", new String[] {"src"});
+ String source = "package p;\n"
+ + "public class X {\n"
+ + " public static void main(java.lang.String[] args) {\n"
+ + " var s1 = args[0];\n"
+ + " System.out.println(s1);\n"
+ + " }\n"
+ + "}\n";
+ createFolder("/P/src/p");
+ createFile("/P/src/p/X.java", source);
+ waitForAutoBuild();
+
+ ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java");
+ String select = "s1";
+ IJavaElement[] elements = unit.codeSelect(source.indexOf(select), select.length());
+ ILocalVariable variable = (ILocalVariable) elements[0];
+ elements = unit.findElements(variable);
+ assertNotNull("Should not be null", elements);
+ assertEquals("incorrect type", "Ljava.lang.String;", variable.getTypeSignature());
+ } finally {
+ deleteProject("P");
+ }
+}
+public void test531046b() throws CoreException, IOException {
+ if (!isJRE9) return;
+ try {
+ createJava10Project("P", new String[] {"src"});
+ String source = "package p;\n"
+ + "public class X {\n"
+ + " public static void main(java.lang.String[] args) {\n"
+ + " var s1 = args[0];\n"
+ + " System.out.println(s1);\n"
+ + " }\n"
+ + "}\n";
+ createFolder("/P/src/p");
+ createFile("/P/src/p/X.java", source);
+ waitForAutoBuild();
+
+ ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java");
+ String select = "s1";
+ IJavaElement[] elements = unit.codeSelect(source.lastIndexOf(select), select.length());
+ ILocalVariable variable = (ILocalVariable) elements[0];
+ elements = unit.findElements(variable);
+ assertNotNull("Should not be null", elements);
+ assertEquals("incorrect type", "Ljava.lang.String;", variable.getTypeSignature());
+ } finally {
+ deleteProject("P");
+ }
+}
+public void test531046c() throws CoreException, IOException {
+ if (!isJRE9) return;
+ try {
+ createJava10Project("P", new String[] {"src"});
+ String source = "package p;\n"
+ + "public class X {\n"
+ + " public static void main(java.lang.String[] args) {\n"
+ + " var s1 = args;\n"
+ + " System.out.println(s1);\n"
+ + " }\n"
+ + "}\n";
+ createFolder("/P/src/p");
+ createFile("/P/src/p/X.java", source);
+ waitForAutoBuild();
+
+ ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java");
+ String select = "s1";
+ IJavaElement[] elements = unit.codeSelect(source.lastIndexOf(select), select.length());
+ ILocalVariable variable = (ILocalVariable) elements[0];
+ elements = unit.findElements(variable);
+ assertNotNull("Should not be null", elements);
+ assertEquals("incorrect type", "[Ljava.lang.String;", variable.getTypeSignature());
+ } finally {
+ deleteProject("P");
+ }
+}
+public void test531046d() throws CoreException, IOException {
+ if (!isJRE9) return;
+ try {
+ createJava10Project("P", new String[] {"src"});
+ String source = "package p;\n"
+ + "public class X {\n"
+ + " public static void main(java.lang.String[] args) {\n"
+ + " var s1 = new java.util.HashMap<String, Object>();\n"
+ + " }\n"
+ + "}\n";
+ createFolder("/P/src/p");
+ createFile("/P/src/p/X.java", source);
+ waitForAutoBuild();
+
+ ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java");
+ String select = "s1";
+ IJavaElement[] elements = unit.codeSelect(source.lastIndexOf(select), select.length());
+ ILocalVariable variable = (ILocalVariable) elements[0];
+ elements = unit.findElements(variable);
+ assertNotNull("Should not be null", elements);
+ assertEquals("incorrect type", "Ljava.util.HashMap<Ljava.lang.String;Ljava.lang.Object;>;", variable.getTypeSignature());
+ } finally {
+ deleteProject("P");
+ }
+}
+public void test531046e() throws CoreException, IOException {
+ if (!isJRE9) return;
+ try {
+ createJava10Project("P", new String[] {"src"});
+ String source = "package p;\n"
+ + "public class X {\n"
+ + " public static void main(java.lang.String[] args) {\n"
+ + " var s1 = new java.util.HashMap<String, Object>();\n"
+ + " }\n"
+ + "}\n";
+ createFolder("/P/src/p");
+ createFile("/P/src/p/X.java", source);
+ waitForAutoBuild();
+
+ ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java");
+ String select = "var";
+ IJavaElement[] elements = unit.codeSelect(source.lastIndexOf(select), select.length());
+ assertEquals("should not be empty", 1, elements.length);
+ IType type = (IType) elements[0];
+ assertEquals("incorrect type", "java.util.HashMap<java.lang.String,java.lang.Object>", type.getFullyQualifiedParameterizedName());
+ } finally {
+ deleteProject("P");
+ }
+}
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingTest.java
index f7a005aec..330a5fe2e 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingTest.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
*******************************************************************************/
@@ -62,7 +66,12 @@ public class ASTRewritingTest extends AbstractJavaModelTests {
/** @deprecated using deprecated code */
private final static int JLS8_INTERNAL = AST.JLS8;
- private final static int[] JLS_LEVELS = { JLS2_INTERNAL, JLS3_INTERNAL, JLS4_INTERNAL, JLS8_INTERNAL, AST.JLS9 };
+ /** @deprecated using deprecated code */
+ private final static int JLS9_INTERNAL = AST.JLS9;
+
+ private final static int JLS10_INTERNAL = AST.JLS10;
+
+ private final static int[] JLS_LEVELS = { JLS2_INTERNAL, JLS3_INTERNAL, JLS4_INTERNAL, JLS8_INTERNAL, JLS9_INTERNAL, JLS10_INTERNAL };
private static final String ONLY_AST_STRING = "_only";
private static final String SINCE_AST_STRING = "_since";
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ImportRewriteTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ImportRewriteTest.java
index 7877192e4..5b740675a 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ImportRewriteTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ImportRewriteTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -4956,7 +4956,7 @@ public class ImportRewriteTest extends AbstractJavaModelTests {
"}\n";
ICompilationUnit cu = pack1.createCompilationUnit("X.java", contents, false, null);
- ASTParser parser = ASTParser.newParser(AST_INTERNAL_JLS9);
+ ASTParser parser = ASTParser.newParser(AST_INTERNAL_JLS10);
parser.setSource(cu);
parser.setResolveBindings(true);
parser.setStatementsRecovery(true);
@@ -4981,7 +4981,7 @@ public class ImportRewriteTest extends AbstractJavaModelTests {
"}\n";
ICompilationUnit cu = pack1.createCompilationUnit("X.java", contents, false, null);
- ASTParser parser = ASTParser.newParser(AST_INTERNAL_JLS9);
+ ASTParser parser = ASTParser.newParser(AST_INTERNAL_JLS10);
parser.setSource(cu);
parser.setResolveBindings(true);
parser.setStatementsRecovery(true);
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter10/.classpath b/org.eclipse.jdt.core.tests.model/workspace/Converter10/.classpath
new file mode 100644
index 000000000..3522bc0c3
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/workspace/Converter10/.classpath
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="var" path="CONVERTER_JCL18_LIB" sourcepath="CONVERTER_JCL18_SRC" rootpath="CONVERTER_JCL_SRCROOT"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter10/.project b/org.eclipse.jdt.core.tests.model/workspace/Converter10/.project
new file mode 100644
index 000000000..474aee115
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/workspace/Converter10/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>Converter10</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter10/src/X.java b/org.eclipse.jdt.core.tests.model/workspace/Converter10/src/X.java
new file mode 100644
index 000000000..5a1a8880f
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/workspace/Converter10/src/X.java
@@ -0,0 +1,4 @@
+public class X {
+ public void foo(X this) {
+ }
+}
diff --git a/org.eclipse.jdt.core/.settings/.api_filters b/org.eclipse.jdt.core/.settings/.api_filters
index affb36e82..edcef091e 100644
--- a/org.eclipse.jdt.core/.settings/.api_filters
+++ b/org.eclipse.jdt.core/.settings/.api_filters
@@ -1,376 +1,96 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.jdt.core" version="2">
<resource path="META-INF/MANIFEST.MF">
- <filter id="923795461">
- <message_arguments>
- <message_argument value="3.13.0"/>
- <message_argument value="3.13.0"/>
- </message_arguments>
- </filter>
- <filter comment="keep the same version as 4.7.1 for now" id="924844039">
- <message_arguments>
- <message_argument value="3.13.0"/>
- <message_argument value="3.13.0"/>
- </message_arguments>
- </filter>
- <filter comment="new API was backported" id="924844039">
- <message_arguments>
- <message_argument value="3.13.101"/>
- <message_argument value="3.13.100"/>
- </message_arguments>
- </filter>
<filter id="924844039">
<message_arguments>
- <message_argument value="3.13.50"/>
- <message_argument value="3.13.0"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="compiler/org/eclipse/jdt/core/compiler/CategorizedProblem.java" type="org.eclipse.jdt.core.compiler.CategorizedProblem">
- <filter comment="future additions have always been announced in the API" id="336658481">
- <message_arguments>
- <message_argument value="org.eclipse.jdt.core.compiler.CategorizedProblem"/>
- <message_argument value="CAT_MODULE"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="CAT_MODULE"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="compiler/org/eclipse/jdt/core/compiler/CharOperation.java" type="org.eclipse.jdt.core.compiler.CharOperation">
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="ALL_PREFIX"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="COMMA_SEPARATOR"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="concatAll(char[], char[], char)"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="containsEqual(char[][], char[])"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="prepend(char, char[])"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="toCharArrays(List&lt;String&gt;)"/>
+ <message_argument value="3.13.102"/>
+ <message_argument value="3.13.101"/>
</message_arguments>
</filter>
</resource>
<resource path="compiler/org/eclipse/jdt/core/compiler/IProblem.java" type="org.eclipse.jdt.core.compiler.IProblem">
- <filter comment="must react to added constant CAT_MODULE" id="388194388">
- <message_arguments>
- <message_argument value="org.eclipse.jdt.core.compiler.IProblem"/>
- <message_argument value="IgnoreCategoriesMask"/>
- <message_argument value="16777215"/>
- </message_arguments>
- </filter>
<filter id="1209008130">
<message_arguments>
<message_argument value="3.14"/>
<message_argument value="3.13"/>
- <message_argument value="AbstractServiceImplementation"/>
+ <message_argument value="VarIsNotAllowedHere"/>
</message_arguments>
</filter>
<filter id="1209008130">
<message_arguments>
<message_argument value="3.14"/>
<message_argument value="3.13"/>
- <message_argument value="AutoManagedVariableResourceNotBelow9"/>
+ <message_argument value="VarIsReserved"/>
</message_arguments>
</filter>
<filter id="1209008130">
<message_arguments>
<message_argument value="3.14"/>
<message_argument value="3.13"/>
- <message_argument value="ConflictingPackageFromModules"/>
+ <message_argument value="VarIsReservedInFuture"/>
</message_arguments>
</filter>
<filter id="1209008130">
<message_arguments>
<message_argument value="3.14"/>
<message_argument value="3.13"/>
- <message_argument value="ConflictingPackageFromOtherModules"/>
+ <message_argument value="VarLocalCannotBeArray"/>
</message_arguments>
</filter>
<filter id="1209008130">
<message_arguments>
<message_argument value="3.14"/>
<message_argument value="3.13"/>
- <message_argument value="CyclicModuleDependency"/>
+ <message_argument value="VarLocalCannotBeArrayInitalizers"/>
</message_arguments>
</filter>
<filter id="1209008130">
<message_arguments>
<message_argument value="3.14"/>
<message_argument value="3.13"/>
- <message_argument value="DuplicateExports"/>
+ <message_argument value="VarLocalCannotBeLambda"/>
</message_arguments>
</filter>
<filter id="1209008130">
<message_arguments>
<message_argument value="3.14"/>
<message_argument value="3.13"/>
- <message_argument value="DuplicateModuleRef"/>
+ <message_argument value="VarLocalCannotBeMethodReference"/>
</message_arguments>
</filter>
<filter id="1209008130">
<message_arguments>
<message_argument value="3.14"/>
<message_argument value="3.13"/>
- <message_argument value="DuplicateOpens"/>
+ <message_argument value="VarLocalInitializedToNull"/>
</message_arguments>
</filter>
<filter id="1209008130">
<message_arguments>
<message_argument value="3.14"/>
<message_argument value="3.13"/>
- <message_argument value="DuplicateRequires"/>
+ <message_argument value="VarLocalInitializedToVoid"/>
</message_arguments>
</filter>
<filter id="1209008130">
<message_arguments>
<message_argument value="3.14"/>
<message_argument value="3.13"/>
- <message_argument value="DuplicateResource"/>
+ <message_argument value="VarLocalMultipleDeclarators"/>
</message_arguments>
</filter>
<filter id="1209008130">
<message_arguments>
<message_argument value="3.14"/>
<message_argument value="3.13"/>
- <message_argument value="DuplicateServices"/>
+ <message_argument value="VarLocalReferencesItself"/>
</message_arguments>
</filter>
<filter id="1209008130">
<message_arguments>
<message_argument value="3.14"/>
<message_argument value="3.13"/>
- <message_argument value="DuplicateUses"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="IllegalModifierCombinationForPrivateInterfaceMethod9"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="IllegalModifierForInterfaceMethod9"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="IllegalModifierForModule"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="InvalidOpensStatement"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="InvalidServiceImplType"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="InvalidServiceIntfType"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="MissingRequiresTransitiveForTypeInAPI"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="ModuleRelated"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="NestedServiceImpl"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="NonDenotableTypeArgumentForAnonymousDiamond"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="NonPublicTypeInAPI"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="NotAccessibleConstructor"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="NotAccessibleField"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="NotAccessibleMethod"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="NotAccessiblePackage"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="NotAccessibleType"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="NotExportedTypeInAPI"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="OverridingTerminallyDeprecatedMethod"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="PackageDoesNotExistOrIsEmpty"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="ProviderMethodOrConstructorRequiredForServiceImpl"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="ServiceImplDefaultConstructorNotPublic"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="ServiceImplNotDefinedByModule"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="UndefinedModule"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="UnnamedPackageInNamedModule"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="UsingTerminallyDeprecatedConstructor"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="UsingTerminallyDeprecatedField"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="UsingTerminallyDeprecatedMethod"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="UsingTerminallyDeprecatedType"/>
+ <message_argument value="VarLocalWithoutInitizalier"/>
</message_arguments>
</filter>
</resource>
@@ -387,624 +107,16 @@
<message_arguments>
<message_argument value="3.14"/>
<message_argument value="3.13"/>
- <message_argument value="JLS9"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="newExportsStatement()"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="newModuleDeclaration()"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="newModuleModifier(ModuleModifier.ModuleModifierKeyword)"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="newOpensDirective()"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="newProvidesDirective()"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="newRequiresDirective()"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="newUsesDirective()"/>
+ <message_argument value="JLS10"/>
</message_arguments>
</filter>
</resource>
- <resource path="dom/org/eclipse/jdt/core/dom/ASTMatcher.java" type="org.eclipse.jdt.core.dom.ASTMatcher">
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="match(ExportsDirective, Object)"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="match(ModuleDeclaration, Object)"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="match(ModuleModifier, Object)"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="match(OpensDirective, Object)"/>
- </message_arguments>
- </filter>
+ <resource path="dom/org/eclipse/jdt/core/dom/Type.java" type="org.eclipse.jdt.core.dom.Type">
<filter id="1141899266">
<message_arguments>
<message_argument value="3.14"/>
<message_argument value="3.13"/>
- <message_argument value="match(ProvidesDirective, Object)"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="match(RequiresDirective, Object)"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="match(UsesDirective, Object)"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="dom/org/eclipse/jdt/core/dom/ASTNode.java" type="org.eclipse.jdt.core.dom.ASTNode">
- <filter comment="make room for new JDT constants" id="388194388">
- <message_arguments>
- <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
- <message_argument value="BASE_CALL_MESSAGE_SEND"/>
- <message_argument value="100"/>
- </message_arguments>
- </filter>
- <filter comment="make room for new JDT constants" id="388194388">
- <message_arguments>
- <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
- <message_argument value="BASE_CONSTRUCTOR_INVOCATION"/>
- <message_argument value="98"/>
- </message_arguments>
- </filter>
- <filter comment="make room for new JDT constants" id="388194388">
- <message_arguments>
- <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
- <message_argument value="CALLIN_MAPPING_DECLARATION"/>
- <message_argument value="94"/>
- </message_arguments>
- </filter>
- <filter comment="make room for new JDT constants" id="388194388">
- <message_arguments>
- <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
- <message_argument value="CALLOUT_MAPPING_DECLARATION"/>
- <message_argument value="95"/>
- </message_arguments>
- </filter>
- <filter comment="make room for new JDT constants" id="388194388">
- <message_arguments>
- <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
- <message_argument value="FIELD_ACCESS_SPEC"/>
- <message_argument value="101"/>
- </message_arguments>
- </filter>
- <filter comment="make room for new JDT constants" id="388194388">
- <message_arguments>
- <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
- <message_argument value="GUARD_PREDICATE_DECLARATION"/>
- <message_argument value="107"/>
- </message_arguments>
- </filter>
- <filter comment="make room for new JDT constants" id="388194388">
- <message_arguments>
- <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
- <message_argument value="LIFTING_TYPE"/>
- <message_argument value="96"/>
- </message_arguments>
- </filter>
- <filter comment="make room for new JDT constants" id="388194388">
- <message_arguments>
- <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
- <message_argument value="METHOD_BINDING_OPERATOR"/>
- <message_argument value="108"/>
- </message_arguments>
- </filter>
- <filter comment="make room for new JDT constants" id="388194388">
- <message_arguments>
- <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
- <message_argument value="METHOD_SPEC"/>
- <message_argument value="93"/>
- </message_arguments>
- </filter>
- <filter comment="make room for new JDT constants" id="388194388">
- <message_arguments>
- <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
- <message_argument value="PARAMETER_MAPPING"/>
- <message_argument value="99"/>
- </message_arguments>
- </filter>
- <filter comment="make room for new JDT constants" id="388194388">
- <message_arguments>
- <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
- <message_argument value="PRECEDENCE_DECLARATION"/>
- <message_argument value="106"/>
- </message_arguments>
- </filter>
- <filter comment="make room for new JDT constants" id="388194388">
- <message_arguments>
- <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
- <message_argument value="ROLE_TYPE_DECLARATION"/>
- <message_argument value="102"/>
- </message_arguments>
- </filter>
- <filter comment="make room for new JDT constants" id="388194388">
- <message_arguments>
- <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
- <message_argument value="TSUPER_CONSTRUCTOR_INVOCATION"/>
- <message_argument value="104"/>
- </message_arguments>
- </filter>
- <filter comment="make room for new JDT constants" id="388194388">
- <message_arguments>
- <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
- <message_argument value="TSUPER_MESSAGE_SEND"/>
- <message_argument value="103"/>
- </message_arguments>
- </filter>
- <filter comment="make room for new JDT constants" id="388194388">
- <message_arguments>
- <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
- <message_argument value="TYPE_ANCHOR"/>
- <message_argument value="105"/>
- </message_arguments>
- </filter>
- <filter comment="make room for new JDT constants" id="388194388">
- <message_arguments>
- <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
- <message_argument value="WITHIN_STATEMENT"/>
- <message_argument value="97"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="EXPORTS_DIRECTIVE"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="MODULE_DECLARATION"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="MODULE_MODIFIER"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="OPENS_DIRECTIVE"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="PROVIDES_DIRECTIVE"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="REQUIRES_DIRECTIVE"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="USES_DIRECTIVE"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="dom/org/eclipse/jdt/core/dom/ASTVisitor.java" type="org.eclipse.jdt.core.dom.ASTVisitor">
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="endVisit(ExportsDirective)"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="endVisit(ModuleDeclaration)"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="endVisit(ModuleModifier)"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="endVisit(OpensDirective)"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="endVisit(ProvidesDirective)"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="endVisit(RequiresDirective)"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="endVisit(UsesDirective)"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="visit(ExportsDirective)"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="visit(ModuleDeclaration)"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="visit(ModuleModifier)"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="visit(OpensDirective)"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="visit(ProvidesDirective)"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="visit(RequiresDirective)"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="visit(UsesDirective)"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="dom/org/eclipse/jdt/core/dom/CompilationUnit.java" type="org.eclipse.jdt.core.dom.CompilationUnit">
- <filter comment="has never been subclassable" id="336744520">
- <message_arguments>
- <message_argument value="org.eclipse.jdt.core.dom.CompilationUnit"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="MODULE_PROPERTY"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="getModule()"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="setModule(ModuleDeclaration)"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="dom/org/eclipse/jdt/core/dom/IBinding.java" type="org.eclipse.jdt.core.dom.IBinding">
- <filter comment="make room for new JDT constants" id="388194388">
- <message_arguments>
- <message_argument value="org.eclipse.jdt.core.dom.IBinding"/>
- <message_argument value="METHOD_MAPPING"/>
- <message_argument value="7"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="MODULE"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="dom/org/eclipse/jdt/core/dom/TryStatement.java" type="org.eclipse.jdt.core.dom.TryStatement">
- <filter comment="has never been subclassable" id="336744520">
- <message_arguments>
- <message_argument value="org.eclipse.jdt.core.dom.TryStatement"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="RESOURCES2_PROPERTY"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="formatter/org/eclipse/jdt/core/formatter/CodeFormatter.java" type="org.eclipse.jdt.core.formatter.CodeFormatter">
- <filter id="336658481">
- <message_arguments>
- <message_argument value="org.eclipse.jdt.core.formatter.CodeFormatter"/>
- <message_argument value="K_MODULE_INFO"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="K_MODULE_INFO"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java" type="org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants">
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="FORMATTER_ALIGNMENT_FOR_MODULE_STATEMENTS"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="model/org/eclipse/jdt/core/CompletionProposal.java" type="org.eclipse.jdt.core.CompletionProposal">
- <filter comment="make room for new JDT constants" id="388194388">
- <message_arguments>
- <message_argument value="org.eclipse.jdt.core.CompletionProposal"/>
- <message_argument value="OVERRIDE_ROLE_DECLARATION"/>
- <message_argument value="28"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="MODULE_DECLARATION"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="MODULE_REF"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="model/org/eclipse/jdt/core/Flags.java" type="org.eclipse.jdt.core.Flags">
- <filter comment="Necessary flag change after adopting Java 9 in OTDT" id="388194388">
- <message_arguments>
- <message_argument value="org.eclipse.jdt.core.Flags"/>
- <message_argument value="AccTeam"/>
- <message_argument value="32768"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="AccModule"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="isModule(int)"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="model/org/eclipse/jdt/core/IClasspathAttribute.java" type="org.eclipse.jdt.core.IClasspathAttribute">
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="ADD_EXPORTS"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="ADD_READS"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="LIMIT_MODULES"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="MODULE"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="MODULE_MAIN_CLASS"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="PATCH_MODULE"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="model/org/eclipse/jdt/core/IJavaElement.java" type="org.eclipse.jdt.core.IJavaElement">
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="JAVA_MODULE"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="model/org/eclipse/jdt/core/IJavaProject.java" type="org.eclipse.jdt.core.IJavaProject">
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="findModule(String, WorkingCopyOwner)"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="getModuleDescription()"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="model/org/eclipse/jdt/core/IPackageFragment.java" type="org.eclipse.jdt.core.IPackageFragment">
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="getAllClassFiles()"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="getModularClassFile()"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="getOrdinaryClassFile(String)"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="getOrdinaryClassFiles()"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="model/org/eclipse/jdt/core/IPackageFragmentRoot.java" type="org.eclipse.jdt.core.IPackageFragmentRoot">
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="getModuleDescription()"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="model/org/eclipse/jdt/core/ITypeRoot.java" type="org.eclipse.jdt.core.ITypeRoot">
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="getModule()"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="model/org/eclipse/jdt/core/JavaConventions.java" type="org.eclipse.jdt.core.JavaConventions">
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="validateModuleName(String, String, String)"/>
+ <message_argument value="isVar()"/>
</message_arguments>
</filter>
</resource>
@@ -1020,145 +132,14 @@
<message_arguments>
<message_argument value="3.14"/>
<message_argument value="3.13"/>
- <message_argument value="COMPILER_PB_API_LEAKS"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="COMPILER_PB_TERMINAL_DEPRECATION"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="VERSION_9"/>
+ <message_argument value="VERSION_10"/>
</message_arguments>
</filter>
<filter id="1141899266">
<message_arguments>
<message_argument value="3.14"/>
<message_argument value="3.13"/>
- <message_argument value="compileWithAttributes(IModuleDescription, Map&lt;String,String&gt;)"/>
- </message_arguments>
- </filter>
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="getReferencedModules(IJavaProject)"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="model/org/eclipse/jdt/core/JavaModelException.java" type="org.eclipse.jdt.core.JavaModelException">
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="JavaModelException(IStatus)"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="model/org/eclipse/jdt/core/compiler/ReconcileContext.java" type="org.eclipse.jdt.core.compiler.ReconcileContext">
- <filter id="1141899266">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="getAST(int)"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="model/org/eclipse/jdt/core/util/IAttributeNamesConstants.java" type="org.eclipse.jdt.core.util.IAttributeNamesConstants">
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="MODULE"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="MODULE_MAIN_CLASS"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="MODULE_PACKAGES"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="model/org/eclipse/jdt/core/util/IConstantPoolConstant.java" type="org.eclipse.jdt.core.util.IConstantPoolConstant">
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="CONSTANT_Module"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="CONSTANT_Module_SIZE"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="CONSTANT_Package"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="CONSTANT_Package_SIZE"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="model/org/eclipse/jdt/core/util/IModifierConstants.java" type="org.eclipse.jdt.core.util.IModifierConstants">
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="ACC_MODULE"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="ACC_OPEN"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="ACC_STATIC_PHASE"/>
- </message_arguments>
- </filter>
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="ACC_TRANSITIVE"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="search/org/eclipse/jdt/core/search/IJavaSearchConstants.java" type="org.eclipse.jdt.core.search.IJavaSearchConstants">
- <filter id="1209008130">
- <message_arguments>
- <message_argument value="3.14"/>
- <message_argument value="3.13"/>
- <message_argument value="MODULE"/>
+ <message_argument value="getAllVersions()"/>
</message_arguments>
</filter>
</resource>
diff --git a/org.eclipse.jdt.core/.settings/org.eclipse.pde.api.tools.prefs b/org.eclipse.jdt.core/.settings/org.eclipse.pde.api.tools.prefs
index 6f7536aee..bbb69ac19 100644
--- a/org.eclipse.jdt.core/.settings/org.eclipse.pde.api.tools.prefs
+++ b/org.eclipse.jdt.core/.settings/org.eclipse.pde.api.tools.prefs
@@ -1,4 +1,4 @@
-#Fri May 21 10:24:07 EDT 2010
+ANNOTATION_ELEMENT_TYPE_ADDED_FIELD=Error
ANNOTATION_ELEMENT_TYPE_ADDED_METHOD_WITHOUT_DEFAULT_VALUE=Error
ANNOTATION_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error
ANNOTATION_ELEMENT_TYPE_REMOVED_FIELD=Error
@@ -8,6 +8,10 @@ API_COMPONENT_ELEMENT_TYPE_REMOVED_API_TYPE=Error
API_COMPONENT_ELEMENT_TYPE_REMOVED_REEXPORTED_API_TYPE=Error
API_COMPONENT_ELEMENT_TYPE_REMOVED_REEXPORTED_TYPE=Error
API_COMPONENT_ELEMENT_TYPE_REMOVED_TYPE=Error
+API_USE_SCAN_FIELD_SEVERITY=Error
+API_USE_SCAN_METHOD_SEVERITY=Error
+API_USE_SCAN_TYPE_SEVERITY=Error
+CLASS_ELEMENT_TYPE_ADDED_FIELD=Error
CLASS_ELEMENT_TYPE_ADDED_METHOD=Error
CLASS_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error
CLASS_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error
@@ -47,6 +51,7 @@ ILLEGAL_IMPLEMENT=Warning
ILLEGAL_INSTANTIATE=Warning
ILLEGAL_OVERRIDE=Warning
ILLEGAL_REFERENCE=Warning
+INTERFACE_ELEMENT_TYPE_ADDED_DEFAULT_METHOD=Error
INTERFACE_ELEMENT_TYPE_ADDED_FIELD=Error
INTERFACE_ELEMENT_TYPE_ADDED_METHOD=Error
INTERFACE_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error
@@ -58,6 +63,7 @@ INTERFACE_ELEMENT_TYPE_REMOVED_FIELD=Error
INTERFACE_ELEMENT_TYPE_REMOVED_METHOD=Error
INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error
INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error
+INVALID_ANNOTATION=Warning
INVALID_JAVADOC_TAG=Warning
INVALID_REFERENCE_IN_SYSTEM_LIBRARIES=Warning
LEAK_EXTEND=Warning
@@ -75,6 +81,7 @@ METHOD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error
METHOD_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error
METHOD_ELEMENT_TYPE_REMOVED_ANNOTATION_DEFAULT_VALUE=Error
METHOD_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error
+MISSING_EE_DESCRIPTIONS=Warning
TYPE_PARAMETER_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error
TYPE_PARAMETER_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error
TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error
@@ -83,10 +90,13 @@ TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error
TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error
UNUSED_PROBLEM_FILTERS=Warning
automatically_removed_unused_problem_filters=false
+changed_execution_env=Error
eclipse.preferences.version=1
incompatible_api_component_version=Error
incompatible_api_component_version_include_major_without_breaking_change=Disabled
incompatible_api_component_version_include_minor_without_api_change=Disabled
+incompatible_api_component_version_report_major_without_breaking_change=Warning
+incompatible_api_component_version_report_minor_without_api_change=Warning
invalid_since_tag_version=Error
malformed_since_tag=Error
missing_since_tag=Error
diff --git a/org.eclipse.jdt.core/META-INF/MANIFEST.MF b/org.eclipse.jdt.core/META-INF/MANIFEST.MF
index ef4066239..4da32aad5 100644
--- a/org.eclipse.jdt.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.core/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.core; singleton:=true
-Bundle-Version: 3.13.101.v_OTDT_r262_qualifier
+Bundle-Version: 3.13.102.v_OTDT_r262_qualifier
Bundle-Activator: org.eclipse.jdt.core.JavaCore
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -38,7 +38,7 @@ Export-Package: org.eclipse.jdt.core,
org.eclipse.jdt.compiler.tool,
org.eclipse.pde.api.tools,
org.eclipse.jdt.apt.core",
- org.eclipse.jdt.internal.core;x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.pde.api.tools,org.eclipse.jdt.launching",
+ org.eclipse.jdt.internal.core;x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.pde.api.tools",
org.eclipse.jdt.internal.core.builder;x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.pde.api.tools",
org.eclipse.jdt.internal.core.dom;x-internal:=true,
org.eclipse.jdt.internal.core.dom.rewrite;x-internal:=true,
@@ -91,3 +91,4 @@ Require-Bundle: org.eclipse.core.resources;bundle-version="[3.12.0,4.0.0)",
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Eclipse-ExtensibleAPI: true
Bundle-ActivationPolicy: lazy
+Automatic-Module-Name: org.eclipse.jdt.core
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java
index 8e6d4c027..cd5443977 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -1791,6 +1791,8 @@ private boolean checkVMVersion(long minimalSupportedVersion) {
return ClassFileConstants.JDK1_8 >= minimalSupportedVersion;
case ClassFileConstants.MAJOR_VERSION_9: // 9
return ClassFileConstants.JDK9 >= minimalSupportedVersion;
+ case ClassFileConstants.MAJOR_VERSION_10: // 9
+ return ClassFileConstants.JDK10 >= minimalSupportedVersion;
}
// unknown version
return false;
@@ -2217,6 +2219,16 @@ public void configure(String[] argv) {
mode = DEFAULT;
continue;
}
+ if (currentArg.equals("-10") || currentArg.equals("-10.0")) { //$NON-NLS-1$ //$NON-NLS-2$
+ if (didSpecifyCompliance) {
+ throw new IllegalArgumentException(
+ this.bind("configure.duplicateCompliance", currentArg)); //$NON-NLS-1$
+ }
+ didSpecifyCompliance = true;
+ this.options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_10);
+ mode = DEFAULT;
+ continue;
+ }
if (currentArg.equals("-d")) { //$NON-NLS-1$
if (this.destinationPath != null) {
StringBuffer errorMessage = new StringBuffer();
@@ -2785,6 +2797,8 @@ public void configure(String[] argv) {
this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_8);
} else if (currentArg.equals("1.9") || currentArg.equals("9") || currentArg.equals("9.0")) { //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_9);
+ } else if (currentArg.equals("10") || currentArg.equals("10.0")) { //$NON-NLS-1$//$NON-NLS-2$
+ this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_10);
}
else if (currentArg.equals("jsr14")) { //$NON-NLS-1$
this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_JSR14);
@@ -2870,6 +2884,8 @@ public void configure(String[] argv) {
this.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_8);
} else if (currentArg.equals("1.9") || currentArg.equals("9") || currentArg.equals("9.0")) { //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
this.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_9);
+ } else if (currentArg.equals("10") || currentArg.equals("10.0")) { //$NON-NLS-1$//$NON-NLS-2$
+ this.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_10);
} else {
throw new IllegalArgumentException(this.bind("configure.source", currentArg)); //$NON-NLS-1$
}
@@ -5522,7 +5538,30 @@ protected void validateOptions(boolean didSpecifyCompliance) {
this.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_9);
if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_9);
}
+ } else if (CompilerOptions.VERSION_10.equals(version)) {
+ if (this.didSpecifySource) {
+ Object source = this.options.get(CompilerOptions.OPTION_Source);
+ if (CompilerOptions.VERSION_1_3.equals(source)
+ || CompilerOptions.VERSION_1_4.equals(source)) {
+ if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4);
+ } else if (CompilerOptions.VERSION_1_5.equals(source)
+ || CompilerOptions.VERSION_1_6.equals(source)) {
+ if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6);
+ } else if (CompilerOptions.VERSION_1_7.equals(source)) {
+ if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7);
+ } else if (CompilerOptions.VERSION_1_8.equals(source)) {
+ if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_8);
+ } else if (CompilerOptions.VERSION_9.equals(source)) {
+ if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_9);
+ } else if (CompilerOptions.VERSION_10.equals(source)) {
+ if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_10);
+ }
+ } else {
+ this.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_10);
+ if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_10);
+ }
}
+
} else if (this.didSpecifySource) {
Object version = this.options.get(CompilerOptions.OPTION_Source);
// default is source 1.3 target 1.2 and compliance 1.4
@@ -5541,6 +5580,12 @@ protected void validateOptions(boolean didSpecifyCompliance) {
} else if (CompilerOptions.VERSION_1_8.equals(version)) {
if (!didSpecifyCompliance) this.options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_8);
if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_8);
+ } else if (CompilerOptions.VERSION_9.equals(version)) {
+ if (!didSpecifyCompliance) this.options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_9);
+ if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_9);
+ } else if (CompilerOptions.VERSION_10.equals(version)) {
+ if (!didSpecifyCompliance) this.options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_10);
+ if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_10);
}
}
@@ -5549,7 +5594,15 @@ protected void validateOptions(boolean didSpecifyCompliance) {
final String compliance = this.options.get(CompilerOptions.OPTION_Compliance);
this.complianceLevel = CompilerOptions.versionToJdkLevel(compliance);
}
- if (sourceVersion.equals(CompilerOptions.VERSION_1_8)
+ if (sourceVersion.equals(CompilerOptions.VERSION_10)
+ && this.complianceLevel < ClassFileConstants.JDK10) {
+ // compliance must be 10 if source is 10
+ throw new IllegalArgumentException(this.bind("configure.incompatibleComplianceForSource", this.options.get(CompilerOptions.OPTION_Compliance), CompilerOptions.VERSION_10)); //$NON-NLS-1$
+ } else if (sourceVersion.equals(CompilerOptions.VERSION_9)
+ && this.complianceLevel < ClassFileConstants.JDK9) {
+ // compliance must be 9 if source is 9
+ throw new IllegalArgumentException(this.bind("configure.incompatibleComplianceForSource", this.options.get(CompilerOptions.OPTION_Compliance), CompilerOptions.VERSION_9)); //$NON-NLS-1$
+ } else if (sourceVersion.equals(CompilerOptions.VERSION_1_8)
&& this.complianceLevel < ClassFileConstants.JDK1_8) {
// compliance must be 1.8 if source is 1.8
throw new IllegalArgumentException(this.bind("configure.incompatibleComplianceForSource", this.options.get(CompilerOptions.OPTION_Compliance), CompilerOptions.VERSION_1_8)); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java
index 0eb8b8447..7ad02d89c 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java
@@ -13146,7 +13146,7 @@ public final class CompletionEngine
continue next;
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=328674
- if (local.declaration.initialization != null) {
+ if (local.declaration.initialization != null && !local.declaration.type.isTypeNameVar(null)) {
// proposal being asked inside field's initialization. Don't propose this field.
continue next;
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java
index 009c36032..a510c09a8 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java
@@ -9,6 +9,8 @@
* IBM Corporation - initial API and implementation
* Fraunhofer FIRST - extended API and implementation
* Technical University Berlin - extended API and implementation
+ * Jesper Steen Møller <jesper@selskabet.org> - contributions for:
+ * Bug 531046: [10] ICodeAssist#codeSelect support for 'var'
*******************************************************************************/
package org.eclipse.jdt.internal.codeassist;
@@ -59,9 +61,11 @@ import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Expression.DecapsulationState;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
import org.eclipse.jdt.internal.compiler.ast.ImportReference;
+import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.ModuleDeclaration;
import org.eclipse.jdt.internal.compiler.ast.PackageVisibilityStatement;
+import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeParameter;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
@@ -1618,6 +1622,12 @@ public final class SelectionEngine extends Engine implements ISearchRequestor {
}
return true;
}
+ public boolean visit(
+ LocalDeclaration localDeclaration, BlockScope scope) {
+ if (localDeclaration.type instanceof SingleTypeReference && ((SingleTypeReference)localDeclaration.type).token == assistIdentifier)
+ throw new SelectionNodeFound(localDeclaration.binding.type);
+ return true; // do nothing by default, keep traversing
+ }
public boolean visit(FieldDeclaration fieldDeclaration, MethodScope scope) {
if (fieldDeclaration.name == assistIdentifier){
throw new SelectionNodeFound(fieldDeclaration.binding);
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java
index 9daa06614..e62c55e3c 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -11,6 +11,9 @@
* Technical University Berlin - extended API and implementation
* Stephan Herrmann - Contribution for
* bug 401035 - [1.8] A few tests have started failing recently
+ * Jesper Steen Møller - Contributions for
+ * bug 529552 - [18.3] Add 'var' in completions
+ * Bug 529556 - [18.3] Add content assist support for 'var' as a type
*******************************************************************************/
package org.eclipse.jdt.internal.codeassist.complete;
@@ -3011,7 +3014,11 @@ protected void consumeExitVariableWithInitialization() {
AbstractVariableDeclaration variable = (AbstractVariableDeclaration) this.astStack[this.astPtr];
if (this.cursorLocation + 1 < variable.initialization.sourceStart ||
this.cursorLocation > variable.initialization.sourceEnd) {
- variable.initialization = null;
+ if (!variable.type.isTypeNameVar(null)) {
+ if (! (variable instanceof LocalDeclaration && ((LocalDeclaration)variable).isTypeNameVar(this.compilationUnit.scope))) {
+ variable.initialization = null;
+ }
+ }
} else if (this.assistNode != null && this.assistNode == variable.initialization) {
this.assistNodeParent = variable;
}
@@ -5065,6 +5072,9 @@ public NameReference createSingleAssistNameReference(char[] assistName, long pos
//gbr}
keywords[count++]= Keywords.FINAL;
keywords[count++]= Keywords.CLASS;
+ if (this.options.complianceLevel >= ClassFileConstants.JDK10) {
+ keywords[count++]= Keywords.VAR;
+ }
if(this.previousKind == K_BLOCK_DELIMITER) {
switch (this.previousInfo) {
@@ -5090,6 +5100,10 @@ public NameReference createSingleAssistNameReference(char[] assistName, long pos
keywords[count++] = Keywords.BASE;
keywords[count++] = Keywords.RESULT;
// SH}
+ } else if (kind == K_BETWEEN_FOR_AND_RIGHT_PAREN) {
+ if (this.options.complianceLevel >= ClassFileConstants.JDK10) {
+ keywords[count++]= Keywords.VAR;
+ }
} else if(kind != K_BETWEEN_CASE_AND_COLON && kind != K_BETWEEN_DEFAULT_AND_COLON) {
keywords[count++]= Keywords.TRUE;
keywords[count++]= Keywords.FALSE;
@@ -5117,6 +5131,9 @@ public NameReference createSingleAssistNameReference(char[] assistName, long pos
keywords[count++]= Keywords.FINAL;
keywords[count++]= Keywords.CLASS;
+ if (this.options.complianceLevel >= ClassFileConstants.JDK10) {
+ keywords[count++]= Keywords.VAR;
+ }
if(isInsideLoop()) {
keywords[count++]= Keywords.CONTINUE;
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Keywords.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Keywords.java
index e1c1b181c..1d949cf4b 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Keywords.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Keywords.java
@@ -1,21 +1,22 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
- * $Id: Keywords.java 19896 2009-04-15 14:02:56Z stephan $
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Fraunhofer FIRST - extended API and implementation
* Technical University Berlin - extended API and implementation
+ * Jesper Steen Møller - Contributions for
+ * bug 529552 - [18.3] Add 'var' in completions
*******************************************************************************/
package org.eclipse.jdt.internal.codeassist.impl;
public interface Keywords {
//{ObjectTeams: adapted count
- int COUNT = 62;
+ int COUNT = 63;
//carp}
char[] ABSTRACT = "abstract".toCharArray(); //$NON-NLS-1$
@@ -68,6 +69,7 @@ public interface Keywords {
char[] TRUE = "true".toCharArray(); //$NON-NLS-1$
char[] FALSE = "false".toCharArray(); //$NON-NLS-1$
char[] NULL = "null".toCharArray(); //$NON-NLS-1$
+ char[] VAR = "var".toCharArray(); //$NON-NLS-1$ // Admittedly not a full blown keyword, just "reserved"
//{ObjectTeams: OT specific modifiers and keywords
char[] TEAM = "team".toCharArray(); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java
index 7126c32cd..244a8c576 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java
@@ -1,14 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Fraunhofer FIRST - extended API and implementation
* Technical University Berlin - extended API and implementation
+ * Jesper Steen Møller <jesper@selskabet.org> - contributions for:
+ * Bug 531046: [10] ICodeAssist#codeSelect support for 'var'
*******************************************************************************/
package org.eclipse.jdt.internal.codeassist.select;
@@ -587,7 +589,7 @@ protected void consumeEnterVariable() {
AbstractVariableDeclaration variable = (AbstractVariableDeclaration) this.astStack[this.astPtr];
if (variable.type == this.assistNode){
- if (!this.diet){
+ if (!this.diet && ! variable.type.isTypeNameVar(null)) {
this.restartRecovery = true; // force to restart in recovery mode
this.lastIgnoredToken = -1;
}
@@ -600,11 +602,14 @@ protected void consumeExitVariableWithInitialization() {
// does not keep the initialization if selection is not inside
AbstractVariableDeclaration variable = (AbstractVariableDeclaration) this.astStack[this.astPtr];
- int start = variable.initialization.sourceStart;
- int end = variable.initialization.sourceEnd;
- if ((this.selectionStart < start) && (this.selectionEnd < start) ||
- (this.selectionStart > end) && (this.selectionEnd > end)) {
+ int start = variable.declarationSourceStart;
+ int end = variable.declarationSourceEnd;
+ // Keep the initialization intact, because that's the only way we are going to know the type
+ if (!variable.type.isTypeNameVar(null)) {
+ if ((this.selectionStart < start) && (this.selectionEnd < start) ||
+ (this.selectionStart > end) && (this.selectionEnd > end)) {
variable.initialization = null;
+ }
}
triggerRecoveryUponLambdaClosure(variable, false);
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java
index d497b3437..e47ad78af 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java
@@ -4,7 +4,7 @@
* 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
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* IBM Corporation - added the following constants
@@ -216,7 +216,18 @@
* RepeatableAnnotationIsDocumented
* RepeatableAnnotationIsInherited
* RepeatableAnnotationWithRepeatingContainerAnnotation
-*******************************************************************************/
+ * VarLocalMultipleDeclarators
+ * VarLocalCannotBeArray
+ * VarLocalReferencesItself
+ * VarLocalWithoutInitizalier
+ * VarLocalInitializedToNull
+ * VarLocalCannotBeArrayInitalizers
+ * VarLocalCannotBeLambda
+ * VarLocalCannotBeMethodReference
+ * VarIsReserved
+ * VarIsReservedInFuture
+ * VarIsNotAllowedHere
+******************************************************************************/
package org.eclipse.jdt.core.compiler;
import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
@@ -2018,6 +2029,32 @@ void setSourceStart(int sourceStart);
/** @since 3.13 */
int UnlikelyEqualsArgumentType = 1201;
+ /* Local-Variable Type Inference */
+ /** @since 3.14 */
+ int VarLocalMultipleDeclarators = Syntax + 1500; // ''var'' is not allowed in a compound declaration
+ /** @since 3.14 */
+ int VarLocalCannotBeArray = Syntax + 1501; // ''var'' is not allowed as an element type of an array
+ /** @since 3.14 */
+ int VarLocalReferencesItself = Syntax + 1502; // Declaration using ''var'' may not contin references to itself
+ /** @since 3.14 */
+ int VarLocalWithoutInitizalier = Syntax + 1503; // Cannot use ''var'' on variable without initializer
+ /** @since 3.14 */
+ int VarLocalInitializedToNull = TypeRelated + 1504; // Variable initialized to ''null'' needs an explicit target-type
+ /** @since 3.14 */
+ int VarLocalInitializedToVoid = TypeRelated + 1505; // Variable initializer is ''void'' -- cannot infer variable type
+ /** @since 3.14 */
+ int VarLocalCannotBeArrayInitalizers = TypeRelated + 1506; // Array initializer needs an explicit target-type
+ /** @since 3.14 */
+ int VarLocalCannotBeLambda = TypeRelated + 1507; // Lambda expression needs an explicit target-type
+ /** @since 3.14 */
+ int VarLocalCannotBeMethodReference = TypeRelated + 1508; // Method reference needs an explicit target-type
+ /** @since 3.14 */
+ int VarIsReserved = Syntax + 1509; // ''var'' is not a valid type name
+ /** @since 3.14 */
+ int VarIsReservedInFuture = Syntax + 1510; // ''var'' should not be used as an type name, since it is a reserved word from source level 10 on
+ /** @since 3.14 */
+ int VarIsNotAllowedHere = Syntax + 1511; // ''var'' is not allowed here
+
//{ObjectTeams:
int OTJ_RELATED = 1000000;
int OTCHAP = 100000;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
index 678d325df..a0fc2dbac 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -93,7 +93,7 @@ public abstract class ASTNode implements TypeConstants, TypeIds {
public final static int Bit20 = 0x80000; // contains syntax errors (method declaration, type declaration, field declarations, initializer), typeref: <> name ref: lambda capture)
public final static int Bit21 = 0x100000;
public final static int Bit22 = 0x200000; // parenthesis count (expression) | used (import reference) shadows outer local (local declarations)
- public final static int Bit23 = 0x400000; // parenthesis count (expression)
+ public final static int Bit23 = 0x400000; // parenthesis count (expression) | second or later declarator in declaration (local declarations)
public final static int Bit24 = 0x800000; // parenthesis count (expression)
public final static int Bit25 = 0x1000000; // parenthesis count (expression)
public final static int Bit26 = 0x2000000; // parenthesis count (expression)
@@ -163,6 +163,7 @@ public abstract class ASTNode implements TypeConstants, TypeIds {
public static final int IsLocalDeclarationReachable = Bit31;
public static final int IsForeachElementVariable = Bit5;
public static final int ShadowsOuterLocal = Bit22;
+ public static final int IsAdditionalDeclarator = Bit23;
// for name refs or local decls
public static final int FirstAssignmentToLocal = Bit4;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java
index 83014d971..4c61a21a7 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java
index c590ba9fb..320e3e34f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java
@@ -1,10 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Technical University Berlin - extended API and implementation
@@ -20,6 +20,7 @@
* Bug 415790 - [compiler][resource]Incorrect potential resource leak warning in for loop with close in try/catch
* Jesper S Moller - Contribution for
* bug 401853 - Eclipse Java compiler creates invalid bytecode (java.lang.VerifyError)
+ * bug 527554 - [18.3] Compiler support for JEP 286 Local-Variable Type
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
@@ -441,6 +442,46 @@ public class ForeachStatement extends Statement {
return output;
}
+ private TypeBinding getCollectionElementType(TypeBinding collectionType) {
+ if (collectionType == null) return null;
+
+ boolean isTargetJsr14 = this.scope.compilerOptions().targetJDK == ClassFileConstants.JDK1_4;
+ if (collectionType.isCapture()) {
+ TypeBinding upperBound = ((CaptureBinding)collectionType).firstBound;
+ if (upperBound != null && upperBound.isArrayType())
+ collectionType = upperBound; // partially anticipating the fix for https://bugs.openjdk.java.net/browse/JDK-8013843
+ }
+ if (collectionType.isArrayType()) { // for(E e : E[])
+ return ((ArrayBinding) collectionType).elementsType();
+ } else if (collectionType instanceof ReferenceBinding) {
+ ReferenceBinding iterableType = ((ReferenceBinding)collectionType).findSuperTypeOriginatingFrom(T_JavaLangIterable, false /*Iterable is not a class*/);
+ if (iterableType == null && isTargetJsr14) {
+ iterableType = ((ReferenceBinding)collectionType).findSuperTypeOriginatingFrom(T_JavaUtilCollection, false /*Iterable is not a class*/);
+ }
+ if (iterableType == null) return null;
+
+ TypeBinding[] arguments = null;
+ switch (iterableType.kind()) {
+ case Binding.RAW_TYPE : // for(Object o : Iterable)
+ return this.scope.getJavaLangObject();
+
+ case Binding.GENERIC_TYPE : // for (T t : Iterable<T>) - in case used inside Iterable itself
+ arguments = iterableType.typeVariables();
+ break;
+
+ case Binding.PARAMETERIZED_TYPE : // for(E e : Iterable<E>)
+ arguments = ((ParameterizedTypeBinding)iterableType).arguments;
+ break;
+
+ default:
+ return null;
+ }
+ // generic or parameterized case
+ if (arguments.length != 1) return null; // per construction can only be one
+ return arguments[0];
+ }
+ return null;
+ }
public void resolve(BlockScope upperScope) {
//{ObjectTeams: don't discard scope from previous attempt:
if (this.scope == null)
@@ -451,6 +492,22 @@ public class ForeachStatement extends Statement {
TypeBinding elementType = this.elementVariable.type.resolvedType;
TypeBinding collectionType = this.collection == null ? null : this.collection.resolveType(upperScope);
+ // Patch the resolved type
+ if (this.elementVariable.isTypeNameVar(upperScope)) {
+ elementType = getCollectionElementType(collectionType);
+ if (this.elementVariable.type.dimensions() > 0 || this.elementVariable.type.extraDimensions() > 0) {
+ upperScope.problemReporter().varLocalCannotBeArray(this.elementVariable);
+ }
+ if (TypeBinding.equalsEquals(TypeBinding.NULL, collectionType)) {
+ upperScope.problemReporter().varLocalInitializedToNull(this.elementVariable);
+ elementType = collectionType;
+ } else if (TypeBinding.equalsEquals(TypeBinding.VOID, collectionType)) {
+ upperScope.problemReporter().varLocalInitializedToVoid(this.elementVariable);
+ elementType = collectionType;
+ }
+ elementType = this.elementVariable.patchType(elementType);
+ }
+
TypeBinding expectedCollectionType = null;
if (elementType != null && collectionType != null) {
boolean isTargetJsr14 = this.scope.compilerOptions().targetJDK == ClassFileConstants.JDK1_4;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java
index ba0477175..fed16a7b0 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java
@@ -1,10 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Fraunhofer FIRST - extended API and implementation
@@ -30,6 +30,8 @@
* Bug 453483 - [compiler][null][loop] Improve null analysis for loops
* Jesper S Moller - Contributions for
* Bug 378674 - "The method can be declared as static" is wrong
+ * Bug 527554 - [18.3] Compiler support for JEP 286 Local-Variable Type
+ * Bug 529556 - [18.3] Add content assist support for 'var' as a type
* Andy Clement (GoPivotal, Inc) aclement@gopivotal.com - Contributions for
* Bug 409250 - [1.8][compiler] Various loose ends in 308 code generation
* Bug 426616 - [1.8][compiler] Type Annotations, multiple problems
@@ -37,8 +39,11 @@
package org.eclipse.jdt.internal.compiler.ast;
import static org.eclipse.jdt.internal.compiler.ast.ExpressionContext.ASSIGNMENT_CONTEXT;
+import static org.eclipse.jdt.internal.compiler.ast.ExpressionContext.VANILLA_CONTEXT;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.impl.*;
@@ -249,6 +254,50 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
public boolean isReceiver() {
return false;
}
+ public TypeBinding patchType(TypeBinding newType) {
+ // Perform upwards projection on type wrt mentioned type variables
+ TypeBinding[] mentionedTypeVariables= findCapturedTypeVariables(newType);
+ if (mentionedTypeVariables != null && mentionedTypeVariables.length > 0) {
+ newType = newType.upwardsProjection(this.binding.declaringScope, mentionedTypeVariables);
+ }
+ this.type.resolvedType = newType;
+ if (this.binding != null) {
+ this.binding.type = newType;
+ this.binding.markInitialized();
+ }
+ return this.type.resolvedType;
+ }
+
+ private TypeVariableBinding[] findCapturedTypeVariables(TypeBinding typeBinding) {
+ final Set<TypeVariableBinding> mentioned = new HashSet<>();
+ TypeBindingVisitor.visit(new TypeBindingVisitor() {
+ @Override
+ public boolean visit(TypeVariableBinding typeVariable) {
+ if (typeVariable.isCapture())
+ mentioned.add(typeVariable);
+ return super.visit(typeVariable);
+ }
+ }, typeBinding);
+ if (mentioned.isEmpty()) return null;
+ return mentioned.toArray(new TypeVariableBinding[mentioned.size()]);
+ }
+
+ private static Expression findPolyExpression(Expression e) {
+ // This is simpler than using an ASTVisitor, since we only care about a very few select cases.
+ if (e instanceof FunctionalExpression) {
+ return e;
+ }
+ if (e instanceof ConditionalExpression) {
+ ConditionalExpression ce = (ConditionalExpression)e;
+ Expression candidate = findPolyExpression(ce.valueIfTrue);
+ if (candidate == null) {
+ candidate = findPolyExpression(ce.valueIfFalse);
+ }
+ if (candidate != null) return candidate;
+ }
+ return null;
+ }
+
public void resolve(BlockScope scope) {
// prescan NNBD
@@ -256,15 +305,30 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
handleNonNullByDefault(scope, this.annotations, this);
}
+ TypeBinding variableType = null;
+ boolean variableTypeInferenceError = false;
+ boolean isTypeNameVar = isTypeNameVar(scope);
//{ObjectTeams: avoid duplicate resolving:
- TypeBinding variableType = null;
- if (this.binding == null) {
- variableType = this.type.resolveType(scope, true /* check bounds*/);
-/* orig:
- // create a binding and add it to the scope
- TypeBinding variableType = this.type.resolveType(scope, true /* check bounds* /);
- :giro */
+ if (this.binding != null)
+ variableType = this.binding.type;
+ else {
// SH}
+ if (isTypeNameVar) {
+ if ((this.bits & ASTNode.IsForeachElementVariable) == 0) {
+ // infer a type from the initializer
+ if (this.initialization != null) {
+ variableType = checkInferredLocalVariableInitializer(scope);
+ variableTypeInferenceError = variableType != null;
+ } else {
+ // That's always an error
+ scope.problemReporter().varLocalWithoutInitizalier(this);
+ variableType = scope.getJavaLangObject();
+ variableTypeInferenceError = true;
+ }
+ }
+ } else {
+ variableType = this.type.resolveType(scope, true /* check bounds*/);
+ }
//{ObjectTeams: wrap declared type
{
@@ -302,20 +366,55 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
if ((this.modifiers & ClassFileConstants.AccFinal)!= 0 && this.initialization == null) {
this.modifiers |= ExtraCompilerModifiers.AccBlankFinal;
}
- this.binding = new LocalVariableBinding(this, variableType, this.modifiers, false /*isArgument*/);
+ if (isTypeNameVar) {
+ // Create binding for the initializer's type
+ // In order to resolve self-referential initializers, we must declare the variable with a placeholder type (j.l.Object), and then patch it later
+ this.binding = new LocalVariableBinding(this, variableType != null ? variableType : scope.getJavaLangObject(), this.modifiers, false) {
+ private boolean isInitialized = false;
+
+ public void markReferenced() {
+ if (! this.isInitialized) {
+ scope.problemReporter().varLocalReferencesItself(LocalDeclaration.this);
+ this.type = null;
+ this.isInitialized = true; // Quell additional type errors
+ }
+ }
+ @Override
+ public void markInitialized() {
+ this.isInitialized = true;
+ }
+ };
+ } else {
+ // create a binding from the specified type
+ this.binding = new LocalVariableBinding(this, variableType, this.modifiers, false /*isArgument*/);
+ }
scope.addLocalVariable(this.binding);
this.binding.setConstant(Constant.NotAConstant);
// allow to recursivelly target the binding....
// the correct constant is harmed if correctly computed at the end of this method
-//{ObjectTeams: end if (this.binding == null)
- } else {
- variableType = this.binding.type;
+//{ObjectTeams: end if (this.binding != null) else ...
}
// SH}
if (variableType == null) {
- if (this.initialization != null)
+ if (this.initialization != null) {
this.initialization.resolveType(scope); // want to report all possible errors
+ if (isTypeNameVar && this.initialization.resolvedType != null) {
+ if (TypeBinding.equalsEquals(TypeBinding.NULL, this.initialization.resolvedType)) {
+ scope.problemReporter().varLocalInitializedToNull(this);
+ variableTypeInferenceError = true;
+ } else if (TypeBinding.equalsEquals(TypeBinding.VOID, this.initialization.resolvedType)) {
+ scope.problemReporter().varLocalInitializedToVoid(this);
+ variableTypeInferenceError = true;
+ }
+ variableType = patchType(this.initialization.resolvedType);
+ } else {
+ variableTypeInferenceError = true;
+ }
+ }
+ }
+ this.binding.markInitialized();
+ if (variableTypeInferenceError) {
return;
}
@@ -328,9 +427,9 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
this.initialization.computeConversion(scope, variableType, initializationType);
}
} else {
- this.initialization.setExpressionContext(ASSIGNMENT_CONTEXT);
+ this.initialization.setExpressionContext(isTypeNameVar ? VANILLA_CONTEXT : ASSIGNMENT_CONTEXT);
this.initialization.setExpectedType(variableType);
- TypeBinding initializationType = this.initialization.resolveType(scope);
+ TypeBinding initializationType = this.initialization.resolvedType != null ? this.initialization.resolvedType : this.initialization.resolveType(scope);
if (initializationType != null) {
//{ObjectTeams: wrap rhs type:
initializationType = RoleTypeCreator.maybeWrapUnqualifiedRoleType(initializationType, scope, this.initialization);
@@ -387,6 +486,37 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
this.binding.tagBits &= ~TagBits.AnnotationNullMASK;
}
+ /*
+ * Checks the initializer for simple errors, and reports an error as needed. If error is found,
+ * returns a reasonable match for further type checking.
+ */
+ private TypeBinding checkInferredLocalVariableInitializer(BlockScope scope) {
+ TypeBinding errorType = null;
+ if (this.initialization instanceof ArrayInitializer) {
+ scope.problemReporter().varLocalCannotBeArrayInitalizers(this);
+ errorType = scope.createArrayType(scope.getJavaLangObject(), 1); // Treat as array of anything
+ } else {
+ // Catch-22: isPolyExpression() is not reliable BEFORE resolveType, so we need to peek to suppress the errors
+ Expression polyExpression = findPolyExpression(this.initialization);
+ if (polyExpression instanceof ReferenceExpression) {
+ scope.problemReporter().varLocalCannotBeMethodReference(this);
+ errorType = TypeBinding.NULL;
+ } else if (polyExpression != null) { // Should be instanceof LambdaExpression, but this is safer
+ scope.problemReporter().varLocalCannotBeLambda(this);
+ errorType = TypeBinding.NULL;
+ }
+ }
+ if (this.type.dimensions() > 0 || this.type.extraDimensions() > 0) {
+ scope.problemReporter().varLocalCannotBeArray(this);
+ errorType = scope.createArrayType(scope.getJavaLangObject(), 1); // This is just to quell some warnings
+ }
+ if ((this.bits & ASTNode.IsAdditionalDeclarator) != 0) {
+ scope.problemReporter().varLocalMultipleDeclarators(this);
+ errorType = this.initialization.resolveType(scope);
+ }
+ return errorType;
+ }
+
public void traverse(ASTVisitor visitor, BlockScope scope) {
if (visitor.visit(this, scope)) {
@@ -418,4 +548,9 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
return this.name == RecoveryScanner.FAKE_IDENTIFIER &&
(this.type instanceof SingleTypeReference || (this.type instanceof QualifiedTypeReference && !(this.type instanceof ArrayQualifiedTypeReference))) && this.initialization == null && !this.type.isBaseTypeReference();
}
+
+ public boolean isTypeNameVar(Scope scope) {
+ return this.type != null && this.type.isTypeNameVar(scope);
+ }
+
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java
index 20385ced9..a98be15de 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java
@@ -1,10 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Fraunhofer FIRST - extended API and implementation
@@ -21,6 +21,7 @@
* bug 382721 - [1.8][compiler] Effectively final variables needs special treatment
* bug 378674 - "The method can be declared as static" is wrong
* bug 404657 - [1.8][compiler] Analysis for effectively final variables fails to consider loops
+ * bug 527554 - [18.3] Compiler support for JEP 286 Local-Variable Type
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
@@ -1055,6 +1056,7 @@ public TypeBinding resolveType(BlockScope scope) {
if (this.binding instanceof LocalVariableBinding) {
this.bits &= ~ASTNode.RestrictiveFlagMASK; // clear bits
this.bits |= Binding.LOCAL;
+ ((LocalVariableBinding) this.binding).markReferenced();
if (!variable.isFinal() && (this.bits & ASTNode.IsCapturedOuterLocal) != 0) {
if (scope.compilerOptions().sourceLevel < ClassFileConstants.JDK1_8) // for 8, defer till effective finality could be ascertained.
scope.problemReporter().cannotReferToNonFinalOuterLocal((LocalVariableBinding)variable, this);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java
index d4b19ff1f..2b1a076c8 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java
@@ -1,10 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Fraunhofer FIRST - extended API and implementation
@@ -1717,6 +1717,13 @@ public void resolve() {
return;
}
try {
+ if (CharOperation.equals(this.name, TypeConstants.VAR)) {
+ if (this.scope.compilerOptions().sourceLevel < ClassFileConstants.JDK10) {
+ this.scope.problemReporter().varIsReservedTypeNameInFuture(this);
+ } else {
+ this.scope.problemReporter().varIsReservedTypeName(this);
+ }
+ }
// resolve annotations and check @Deprecated annotation
long annotationTagBits = sourceType.getAnnotationTagBits();
if ((annotationTagBits & TagBits.AnnotationDeprecated) == 0
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeParameter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeParameter.java
index d48707e98..5f92e6661 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeParameter.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeParameter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -18,8 +18,10 @@ package org.eclipse.jdt.internal.compiler.ast;
import java.util.List;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.ast.TypeReference.AnnotationCollector;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.codegen.AnnotationTargetTypeConstants;
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
@@ -33,6 +35,7 @@ import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.eclipse.jdt.internal.compiler.lookup.Scope;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
import org.eclipse.objectteams.otdt.internal.core.compiler.ast.TypeAnchorReference;
import org.eclipse.objectteams.otdt.internal.core.compiler.lookup.ITeamAnchor;
@@ -128,6 +131,13 @@ public class TypeParameter extends AbstractVariableDeclaration {
if (this.annotations != null || scope.environment().usesNullTypeAnnotations()) {
resolveAnnotations(scope);
}
+ if (CharOperation.equals(this.name, TypeConstants.VAR)) {
+ if (scope.compilerOptions().sourceLevel < ClassFileConstants.JDK10) {
+ scope.problemReporter().varIsReservedTypeNameInFuture(this);
+ } else {
+ scope.problemReporter().varIsNotAllowedHere(this);
+ }
+ }
}
public void resolve(BlockScope scope) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java
index f95e9b47d..9b269bc20 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -30,6 +30,10 @@
* Bug 383624 - [1.8][compiler] Revive code generation support for type annotations (from Olivier's work)
* Bug 409236 - [1.8][compiler] Type annotations on intersection cast types dropped by code generator
* Bug 415399 - [1.8][compiler] Type annotations on constructor results dropped by the code generator
+ * Jesper S Møller <jesper@selskabet.org> - Contributions for
+ * bug 527554 - [18.3] Compiler support for JEP 286 Local-Variable Type
+ * bug 529556 - [18.3] Add content assist support for 'var' as a type
+ *
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
@@ -42,6 +46,7 @@ import org.eclipse.jdt.internal.codeassist.select.SelectionNodeFound;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.ast.NullAnnotationMatching.CheckMode;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.codegen.AnnotationContext;
import org.eclipse.jdt.internal.compiler.codegen.AnnotationTargetTypeConstants;
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
@@ -603,7 +608,11 @@ protected TypeBinding internalResolveType(Scope scope, int location) {
}
// SH}
if ((hasError = !type.isValidBinding()) == true) {
- reportInvalidType(scope);
+ if (this.isTypeNameVar(scope)) {
+ reportVarIsNotAllowedHere(scope);
+ } else {
+ reportInvalidType(scope);
+ }
switch (type.problemId()) {
case ProblemReasons.NotFound :
case ProblemReasons.NotVisible :
@@ -732,6 +741,10 @@ protected void reportInvalidType(Scope scope) {
scope.problemReporter().invalidType(this, this.resolvedType);
}
+protected void reportVarIsNotAllowedHere(Scope scope) {
+ scope.problemReporter().varIsNotAllowedHere(this);
+}
+
public TypeBinding resolveSuperType(ClassScope scope) {
// assumes the implementation of resolveType(ClassScope) will call back to detect cycles
TypeBinding superType = resolveType(scope);
@@ -911,4 +924,17 @@ public TypeReference[] getTypeReferences() {
public boolean isBaseTypeReference() {
return false;
}
+/**
+ * Checks to see if the declaration uses 'var' as type name
+ * @param scope Relevant scope, for error reporting
+ * @return true, if source level is Java 10 or above and the type name is just 'var', false otherwise
+ */
+public boolean isTypeNameVar(Scope scope) {
+ CompilerOptions compilerOptions = scope != null ? scope.compilerOptions() : null;
+ if (compilerOptions != null && compilerOptions.sourceLevel < ClassFileConstants.JDK10) {
+ return false;
+ }
+ char[][] typeName = this.getTypeName();
+ return typeName.length == 1 && CharOperation.equals(typeName[0], TypeConstants.VAR);
+}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java
index afd45afb3..4b4faf595 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java
@@ -127,6 +127,7 @@ public interface ClassFileConstants {
int MAJOR_VERSION_1_7 = 51;
int MAJOR_VERSION_1_8 = 52;
int MAJOR_VERSION_9 = 53;
+ int MAJOR_VERSION_10 = 54;
int MINOR_VERSION_0 = 0;
int MINOR_VERSION_1 = 1;
@@ -145,6 +146,7 @@ public interface ClassFileConstants {
long JDK1_7 = ((long)ClassFileConstants.MAJOR_VERSION_1_7 << 16) + ClassFileConstants.MINOR_VERSION_0;
long JDK1_8 = ((long)ClassFileConstants.MAJOR_VERSION_1_8 << 16) + ClassFileConstants.MINOR_VERSION_0;
long JDK9 = ((long)ClassFileConstants.MAJOR_VERSION_9 << 16) + ClassFileConstants.MINOR_VERSION_0;
+ long JDK10 = ((long)ClassFileConstants.MAJOR_VERSION_10 << 16) + ClassFileConstants.MINOR_VERSION_0;
/*
* cldc1.1 is 45.3, but we modify it to be different from JDK1_1.
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
index c14c8c41a..cd50062ff 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
@@ -304,6 +304,7 @@ public class CompilerOptions {
public static final String VERSION_1_7 = "1.7"; //$NON-NLS-1$
public static final String VERSION_1_8 = "1.8"; //$NON-NLS-1$
public static final String VERSION_9 = "9"; //$NON-NLS-1$
+ public static final String VERSION_10 = "10"; //$NON-NLS-1$
public static final String ERROR = "error"; //$NON-NLS-1$
public static final String WARNING = "warning"; //$NON-NLS-1$
public static final String INFO = "info"; //$NON-NLS-1$
@@ -975,6 +976,11 @@ public class CompilerOptions {
if (jdkLevel == ClassFileConstants.JDK9)
return VERSION_9;
break;
+ case ClassFileConstants.MAJOR_VERSION_10 :
+ // JDK10 uses same major version ad JDK9
+ if (jdkLevel == ClassFileConstants.JDK10)
+ return VERSION_10;
+ break;
}
return Util.EMPTY_STRING; // unknown version
}
@@ -1025,6 +1031,10 @@ public class CompilerOptions {
switch (version.charAt(0)) {
case '9':
return ClassFileConstants.JDK9;
+ case '1':
+ if (version.length() > 1 && version.charAt(1) == '0') {
+ return ClassFileConstants.JDK10; // Level for JDK 10
+ }
// No default - let it go through the remaining checks.
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java
index 8ca86c49e..188096df6 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -24,6 +24,8 @@
* Bug 438458 - [1.8][null] clean up handling of null type annotations wrt type variables
* Bug 440759 - [1.8][null] @NonNullByDefault should never affect wildcards and uses of a type variable
* Bug 441693 - [1.8][null] Bogus warning for type argument annotated with @NonNull
+ * Jesper S Møller - Contributions for bug 381345 : [1.8] Take care of the Java 8 major version
+ * Bug 527554 - [18.3] Compiler support for JEP 286 Local-Variable Type
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
@@ -233,6 +235,17 @@ public TypeBinding erasure() {
return this.environment.createArrayType(erasedType, this.dimensions);
return this;
}
+
+public ArrayBinding upwardsProjection(Scope scope, TypeBinding[] mentionedTypeVariables) {
+ TypeBinding leafType = this.leafComponentType.upwardsProjection(scope, mentionedTypeVariables);
+ return scope.environment().createArrayType(leafType, this.dimensions, this.typeAnnotations);
+}
+
+public ArrayBinding downwardsProjection(Scope scope, TypeBinding[] mentionedTypeVariables) {
+ TypeBinding leafType = this.leafComponentType.downwardsProjection(scope, mentionedTypeVariables);
+ return scope.environment().createArrayType(leafType, this.dimensions, this.typeAnnotations);
+}
+
public LookupEnvironment environment() {
return this.environment;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java
index c9d65c5ef..234355022 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -15,6 +15,8 @@
* Bug 456497 - [1.8][null] during inference nullness from target type is lost against weaker hint from applicability analysis
* Bug 456924 - StackOverflowError during compilation
* Bug 462790 - [null] NPE in Expression.computeConversion()
+ * Jesper S Møller - Contributions for bug 381345 : [1.8] Take care of the Java 8 major version
+ * Bug 527554 - [18.3] Compiler support for JEP 286 Local-Variable Type
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
@@ -462,6 +464,22 @@ public class CaptureBinding extends TypeVariableBinding {
return this.wildcard;
}
+ public ReferenceBinding downwardsProjection(Scope scope, TypeBinding[] mentionedTypeVariables) {
+ ReferenceBinding result = null;
+ if (enterRecursiveProjectionFunction()) {
+ for (int i = 0; i < mentionedTypeVariables.length; ++i) {
+ if (TypeBinding.equalsEquals(this, mentionedTypeVariables[i])) {
+ if (this.lowerBound != null) {
+ result = (ReferenceBinding) this.lowerBound.downwardsProjection(scope, mentionedTypeVariables);
+ }
+ break;
+ }
+ }
+ exitRecursiveProjectionFunction();
+ }
+ return result;
+ }
+
/*
* CaptureBinding needs even more propagation, because we are creating a naked type
* (during CaptureBinding(WildcardBinding,ReferenceBinding,int,int,ASTNode,int)
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/IntersectionTypeBinding18.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/IntersectionTypeBinding18.java
index 104d0c553..a25ebeece 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/IntersectionTypeBinding18.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/IntersectionTypeBinding18.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -14,6 +14,8 @@
* Bug 428019 - [1.8][compiler] Type inference failure with nested generic invocation.
* Andy Clement (GoPivotal, Inc) aclement@gopivotal.com - Contributions for
* Bug 405104 - [1.8][compiler][codegen] Implement support for serializeable lambdas
+ * Jesper S Møller - Contributions for bug 381345 : [1.8] Take care of the Java 8 major version
+ * Bug 527554 - [18.3] Compiler support for JEP 286 Local-Variable Type
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
@@ -275,6 +277,24 @@ public class IntersectionTypeBinding18 extends ReferenceBinding { // abstraction
}
@Override
+ public ReferenceBinding upwardsProjection(Scope scope, TypeBinding[] mentionedTypeVariables) {
+ ReferenceBinding[] projectedTypes = new ReferenceBinding[this.intersectingTypes.length];
+ for (int i = 0; i < this.intersectingTypes.length; ++i) {
+ projectedTypes[i] = this.intersectingTypes[i].upwardsProjection(scope, mentionedTypeVariables);
+ }
+ return (ReferenceBinding) scope.environment().createIntersectionType18(projectedTypes);
+ }
+
+ @Override
+ public ReferenceBinding downwardsProjection(Scope scope, TypeBinding[] mentionedTypeVariables) {
+ ReferenceBinding[] projectedTypes = new ReferenceBinding[this.intersectingTypes.length];
+ for (int i = 0; i < this.intersectingTypes.length; ++i) {
+ projectedTypes[i] = this.intersectingTypes[i].downwardsProjection(scope, mentionedTypeVariables);
+ }
+ return (ReferenceBinding) scope.environment().createIntersectionType18(projectedTypes);
+ }
+
+ @Override
public boolean mentionsAny(TypeBinding[] parameters, int idx) {
if (super.mentionsAny(parameters, idx))
return true;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java
index 1890b8dba..d3e8f6f6b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java
@@ -4,7 +4,7 @@
* 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
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Fraunhofer FIRST - extended API and implementation
@@ -16,6 +16,9 @@
* bug 365859 - [compiler][null] distinguish warnings based on flow analysis vs. null annotations
* bug 331649 - [compiler][null] consider null annotations for fields
* Bug 466308 - [hovering] Javadoc header for parameter is wrong with annotation-based null analysis
+ * Jesper S Møller <jesper@selskabet.org> - Contributions for
+ * Bug 527554 - [18.3] Compiler support for JEP 286 Local-Variable Type
+ *
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
@@ -332,4 +335,12 @@ public class LocalVariableBinding extends VariableBinding {
}
return null;
}
+
+ public void markInitialized() {
+ // Signals that the type is correctly set now - This is for extension in subclasses
+ }
+ public void markReferenced() {
+ // Signal that the name is used - This is for extension in subclasses
+ }
+
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java
index 01acc4179..64950c21d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2016 IBM Corporation and others.
+ * Copyright (c) 2005, 2018 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
@@ -41,6 +41,8 @@
* Bug 435805 - [1.8][compiler][null] Java 8 compiler does not recognize declaration style null annotations
* Bug 456508 - Unexpected RHS PolyTypeBinding for: <code-snippet>
* Bug 390064 - [compiler][resource] Resource leak warning missing when extending parameterized class
+ * Jesper S Møller - Contributions for bug 381345 : [1.8] Take care of the Java 8 major version
+ * Bug 527554 - [18.3] Compiler support for JEP 286 Local-Variable Type
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
@@ -490,6 +492,112 @@ public class ParameterizedTypeBinding extends ReferenceBinding implements Substi
public TypeBinding erasure() {
return this.type.erasure(); // erasure
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.compiler.lookup.TypeBinding#upwardsProjection(org.eclipse.jdt.internal.compiler.lookup.Scope, org.eclipse.jdt.internal.compiler.lookup.TypeBinding[])
+ */
+ public ReferenceBinding upwardsProjection(Scope scope, TypeBinding[] mentionedTypeVariables) {
+ TypeBinding[] typeVariables = this.arguments;
+ if (typeVariables == null) return this; // How would that be possible?
+
+ TypeBinding[] a_i_primes = new TypeBinding[typeVariables.length];
+ for (int i = 0, length = typeVariables.length; i < length; i++) {
+ TypeBinding a_i = typeVariables[i];
+
+ // If Ai does not mention any restricted type variable, then Ai' = Ai.
+ int typeVariableKind = a_i.kind();
+ if (! a_i.mentionsAny(mentionedTypeVariables, -1)) {
+ a_i_primes[i] = a_i;
+ } else if (typeVariableKind != Binding.WILDCARD_TYPE) {
+ // If Ai is a type that mentions a restricted type variable, then Ai' is a wildcard.
+ // Let U be the upward projection of Ai. There are three cases:
+ TypeBinding u = a_i.upwardsProjection(scope, mentionedTypeVariables);
+ TypeVariableBinding[] g_vars = this.type.typeVariables();
+ if (g_vars == null || g_vars.length == 0) return this; // Careful - could be a MissingTypeBinding here
+ TypeBinding b_i = g_vars[i].upperBound();
+
+ // If U is not Object,
+ // and if either
+ // * the declared bound of the ith parameter of G, Bi, mentions a type parameter of G, or
+ // * Bi is not a subtype of U,
+ // then Ai' is an upper-bounded wildcard, ? extends U.
+ if (u.id != TypeIds.T_JavaLangObject
+ && (b_i.mentionsAny(typeVariables, -1) || b_i.findSuperTypeOriginatingFrom(u) == null)) {
+ a_i_primes[i] = this.environment().createWildcard(null, i, u, null, Wildcard.EXTENDS);
+ } else {
+ TypeBinding l = a_i.downwardsProjection(scope, mentionedTypeVariables);
+ // Otherwise, if the downward projection of Ai is L,
+ // then Ai' is a lower-bounded wildcard, ? super L.
+ if (l != null) {
+ a_i_primes[i] = this.environment().createWildcard(null, i, l, null, Wildcard.SUPER);
+ } else {
+ // Otherwise, the downward projection of Ai is undefined and Ai' is an unbounded wildcard, ?.
+ a_i_primes[i] = this.environment().createWildcard(null, i, null, null, Wildcard.UNBOUND);
+ }
+ }
+ } else {
+ WildcardBinding wildcard = (WildcardBinding)a_i;
+ if (wildcard.boundKind() == Wildcard.EXTENDS) {
+ // If Ai is an upper-bounded wildcard that mentions a restricted type variable,
+ // then let U be the upward projection of the wildcard bound.
+ TypeBinding u = wildcard.bound().upwardsProjection(scope, mentionedTypeVariables);
+ // Ai' is a wildcard ? extends U.
+ a_i_primes[i] = this.environment().createWildcard(null, 0, u, null, Wildcard.EXTENDS);
+ } else if (wildcard.boundKind() == Wildcard.SUPER) {
+ // If Ai is a lower-bounded wildcard that mentions a restricted type variable,
+ TypeBinding l = wildcard.bound().downwardsProjection(scope, mentionedTypeVariables);
+ if (l != null) {
+ // then if the downward projection of the wildcard bound is L, then Ai' is a wildcard ? super L;
+ a_i_primes[i] = this.environment().createWildcard(null, 0, l, null, Wildcard.SUPER);
+ } else {
+ // if the downward projection of the wildcard bound is undefined, then Ai' is an unbounded wildcard, ?.
+ a_i_primes[i] = this.environment().createWildcard(null, 0, null, null, Wildcard.UNBOUND);
+ }
+ }
+ }
+ }
+ return this.environment.createParameterizedType(this.type, a_i_primes, this.enclosingType);
+ }
+ public ReferenceBinding downwardsProjection(Scope scope, TypeBinding[] mentionedTypeVariables) {
+ TypeBinding[] typeVariables = this.arguments;
+ if (typeVariables == null) return this; // How would that be possible?
+
+ TypeBinding[] a_i_primes = new TypeBinding[typeVariables.length];
+ for (int i = 0, length = typeVariables.length; i < length; i++) {
+ TypeBinding a_i = typeVariables[i];
+
+ // If Ai does not mention any restricted type variable, then Ai' = Ai.
+ int typeVariableKind = a_i.kind();
+ if (! a_i.mentionsAny(mentionedTypeVariables, -1)) {
+ a_i_primes[i] = a_i;
+ } else if (typeVariableKind != Binding.WILDCARD_TYPE) {
+ return null;
+ } else {
+ WildcardBinding wildcard = (WildcardBinding)a_i;
+ if (wildcard.boundKind() == Wildcard.EXTENDS) {
+ // Ai is an upper-bounded wildcard that mentions a restricted type variable,
+ TypeBinding u = wildcard.bound().downwardsProjection(scope, mentionedTypeVariables);
+ // then if the downward projection of the wildcard bound is U, then Ai' is a wildcard ? extends U;
+ if (u != null) {
+ // Ai' is a wildcard ? extends U.
+ a_i_primes[i] = this.environment().createWildcard(null, 0, u, null, Wildcard.EXTENDS);
+ } else {
+ // if the downward projection of the wildcard bound is undefined, then Ai' is undefined.
+ return null;
+ }
+ } else if (wildcard.boundKind() == Wildcard.SUPER) {
+ // If Ai is a lower-bounded wildcard that mentions a restricted type variable,
+ // then let L be the upward projection of the wildcard bound.
+ TypeBinding l = wildcard.bound().upwardsProjection(scope, mentionedTypeVariables);
+ // Ai' is a wildcard ? super L.
+ a_i_primes[i] = this.environment().createWildcard(null, 0, l, null, Wildcard.SUPER);
+ } else {
+ return null;
+ }
+ }
+ }
+ return this.environment.createParameterizedType(this.type, a_i_primes, this.enclosingType);
+ }
+
/**
* @see org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding#fieldCount()
*/
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java
index 9f4be1b2a..d8c10fac8 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java
@@ -41,6 +41,7 @@
* Jesper S Moller - Contributions for
* bug 382701 - [1.8][compiler] Implement semantic analysis of Lambda expressions & Reference expression
* bug 412153 - [1.8][compiler] Check validity of annotations which may be repeatable
+ * bug 527554 - [18.3] Compiler support for JEP 286 Local-Variable Type
* Ulrich Grave <ulrich.grave@gmx.de> - Contributions for
* bug 386692 - Missing "unused" warning on "autowired" fields
*******************************************************************************/
@@ -1743,6 +1744,7 @@ private boolean isCompatibleWith0(TypeBinding otherType, boolean useObjectShortc
case Binding.TYPE :
case Binding.PARAMETERIZED_TYPE :
case Binding.RAW_TYPE :
+ case Binding.INTERSECTION_TYPE18 :
switch (kind()) {
case Binding.GENERIC_TYPE :
case Binding.PARAMETERIZED_TYPE :
@@ -2297,6 +2299,26 @@ public char[] internalName() {
}
// SH}
+/**
+ * Perform an upwards type projection as per JLS 4.10.5
+ * @param scope Relevant scope for evaluating type projection
+ * @param mentionedTypeVariables Filter for mentioned type variabled
+ * @returns Upwards type projection of 'this', or null if downwards projection is undefined
+*/
+public ReferenceBinding upwardsProjection(Scope scope, TypeBinding[] mentionedTypeVariables) {
+ return this;
+}
+
+/**
+ * Perform a downwards type projection as per JLS 4.10.5
+ * @param scope Relevant scope for evaluating type projection
+ * @param mentionedTypeVariables Filter for mentioned type variabled
+ * @returns Downwards type projection of 'this', or null if downwards projection is undefined
+*/
+public ReferenceBinding downwardsProjection(Scope scope, TypeBinding[] mentionedTypeVariables) {
+ return this;
+}
+
void storeAnnotationHolder(Binding binding, AnnotationHolder holder) {
if (holder == null) {
SimpleLookupTable store = storedAnnotations(false, false);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java
index 454647665..5130ce71a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -32,6 +32,8 @@
* Bug 446434 - [1.8][null] Enable interned captures also when analysing null type annotations
* Jesper S Moller <jesper@selskabet.org> - Contributions for
* bug 382701 - [1.8][compiler] Implement semantic analysis of Lambda expressions & Reference expression
+ * bug 527554 - [18.3] Compiler support for JEP 286 Local-Variable Type
+ *
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
@@ -150,6 +152,9 @@ public ReferenceBinding actualType() {
return null; // overridden in ParameterizedTypeBinding & WildcardBinding
}
+//{ObjectTeams: increase visibility across AbstractOTReferenceBinding:
+protected
+// SH}
TypeBinding [] additionalBounds() {
return null; // overridden in WildcardBinding
}
@@ -284,6 +289,26 @@ public TypeBinding erasure() {
}
/**
+ * Perform an upwards type projection as per JLS 4.10.5
+ * @param scope Relevant scope for evaluating type projection
+ * @param mentionedTypeVariables Filter for mentioned type variabled
+ * @returns Upwards type projection of 'this', or null if downwards projection is undefined
+*/
+public TypeBinding upwardsProjection(Scope scope, TypeBinding[] mentionedTypeVariables) {
+ return this;
+}
+
+/**
+ * Perform a downwards type projection as per JLS 4.10.5
+ * @param scope Relevant scope for evaluating type projection
+ * @param mentionedTypeVariables Filter for mentioned type variabled
+ * @returns Downwards type projection of 'this', or null if downwards projection is undefined
+*/
+public TypeBinding downwardsProjection(Scope scope, TypeBinding[] mentionedTypeVariables) {
+ return this;
+}
+
+/**
* Find supertype which originates from a given well-known type, or null if not found
* (using id avoids triggering the load of well-known type: 73740)
* NOTE: only works for erasures of well-known types, as random other types may share
@@ -1759,7 +1784,7 @@ public SyntheticArgumentBinding[] syntheticOuterLocalVariables() {
}
/**
* Call this before descending into type details to prevent infinite recursion.
- * @return true if a recursion has already been started.
+ * @return true if a recursion was not already started.
*/
public boolean enterRecursiveFunction() {
return true;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java
index b095822bf..264cc9962 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java
@@ -4,7 +4,7 @@
* 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
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Stephan Herrmann - Contributions for
@@ -21,6 +21,7 @@
* Jesper S Moller - Contributions for
* Bug 405066 - [1.8][compiler][codegen] Implement code generation infrastructure for JSR335
* Bug 412153 - [1.8][compiler] Check validity of annotations which may be repeatable
+ * bug 527554 - [18.3] Compiler support for JEP 286 Local-Variable Type
* Andy Clement (GoPivotal, Inc) aclement@gopivotal.com - Contributions for
* Bug 405104 - [1.8][compiler][codegen] Implement support for serializeable lambdas
* Ulrich Grave <ulrich.grave@gmx.de> - Contributions for
@@ -104,6 +105,9 @@ public interface TypeConstants {
char[] LAMBDA_TYPE = "<lambda>".toCharArray(); //$NON-NLS-1$
char[] UPPER_MODULE = "MODULE".toCharArray(); //$NON-NLS-1$
+ // JEP 286
+ char[] VAR = "var".toCharArray(); //$NON-NLS-1$
+
// jsr308
char[] TYPE_USE_TARGET = "TYPE_USE".toCharArray(); //$NON-NLS-1$
char[] TYPE_PARAMETER_TARGET = "TYPE_PARAMETER".toCharArray(); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java
index 1dd7365cb..845538417 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java
@@ -1,10 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Technical University Berlin - extended API and implementation
@@ -35,6 +35,8 @@
* Bug 456487 - [1.8][null] @Nullable type variant of @NonNull-constrained type parameter causes grief
* Bug 462790 - [null] NPE in Expression.computeConversion()
* Bug 456532 - [1.8][null] ReferenceBinding.appendNullAnnotation() includes phantom annotations in error messages
+ * Jesper S Møller <jesper@selskabet.org> - Contributions for bug 381345 : [1.8] Take care of the Java 8 major version
+ * Bug 527554 - [18.3] Compiler support for JEP 286 Local-Variable Type
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
@@ -693,7 +695,20 @@ public class TypeVariableBinding extends ReferenceBinding {
public void exitRecursiveFunction() {
this.inRecursiveFunction = false;
}
+
+ // to prevent infinite recursion when inspecting recursive generics:
+ boolean inRecursiveProjectionFunction = false;
+ public boolean enterRecursiveProjectionFunction() {
+ if (this.inRecursiveProjectionFunction)
+ return false;
+ this.inRecursiveProjectionFunction = true;
+ return true;
+ }
+ public void exitRecursiveProjectionFunction() {
+ this.inRecursiveProjectionFunction = false;
+ }
+
public boolean isProperType(boolean admitCapture18) {
// handle recursive calls:
if (this.inRecursiveFunction) // be optimistic, since this node is not an inference variable
@@ -1226,4 +1241,42 @@ public class TypeVariableBinding extends ReferenceBinding {
&& this.environment.globalOptions.pessimisticNullAnalysisForFreeTypeVariablesEnabled
&& (this.tagBits & TagBits.AnnotationNullMASK) == 0;
}
+
+ public ReferenceBinding upwardsProjection(Scope scope, TypeBinding[] mentionedTypeVariables) {
+ if (enterRecursiveProjectionFunction()) {
+ try {
+ for (int i = 0; i < mentionedTypeVariables.length; ++i) {
+ if (TypeBinding.equalsEquals(this, mentionedTypeVariables[i])) {
+ TypeBinding upperBound = this.upperBound();
+ ReferenceBinding projectedUpper = ((ReferenceBinding)upperBound).upwardsProjection(scope, mentionedTypeVariables);
+ TypeBinding additionalBounds[] = this.additionalBounds();
+ if (additionalBounds == null || additionalBounds.length == 0) {
+ // Return upwards projection of upper bound
+ return projectedUpper;
+ } else {
+ // If the type variable has more than one upper bound,
+ // we'll need to make an intersection type of projections of all bounds
+ int totalBounds = 1 + additionalBounds.length;
+ ReferenceBinding[] projectedTypes = new ReferenceBinding[totalBounds];
+ projectedTypes[0] = projectedUpper;
+ for (int j = 0; j < additionalBounds.length; ++j) {
+ projectedTypes[j+1] = (ReferenceBinding)additionalBounds[j].upwardsProjection(scope, mentionedTypeVariables);
+ }
+ return (ReferenceBinding) scope.environment().createIntersectionType18(projectedTypes);
+ }
+ }
+ }
+ return this;
+ } finally {
+ exitRecursiveProjectionFunction();
+ }
+ } else {
+ return scope.getJavaLangObject();
+ }
+ }
+
+ public ReferenceBinding downwardsProjection(Scope scope, TypeBinding[] mentionedTypeVariables) {
+ return null;
+ }
+
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java
index ea981eeb6..8e76f4532 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java
@@ -260,6 +260,9 @@ public class WildcardBinding extends ReferenceBinding {
return this.genericType;
}
+//{ObjectTeams: increase visibility across AbstractOTReferenceBinding:
+ protected
+// SH}
TypeBinding[] additionalBounds() {
return this.otherBounds;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java
index 019a56bce..989370820 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java
@@ -172,6 +172,8 @@ public interface JavadocTagConstants {
// since 1.8
{},
// since 9
+ {},
+ // since 10
{}
};
public static final char[][][] INLINE_TAGS = {
@@ -194,6 +196,8 @@ public interface JavadocTagConstants {
// since 1.8
{},
// since 9
+ {},
+ // since 10
{}
};
public final static int INLINE_TAGS_LENGTH = INLINE_TAGS.length;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
index 0676e676b..ff861e4f7 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -21,7 +21,8 @@
* bug 382701 - [1.8][compiler] Implement semantic analysis of Lambda expressions & Reference expression
* bug 399695 - [1.8][compiler] [1.8][compiler] migrate parser to other syntax for default methods
* bug 384567 - [1.5][compiler] Compiler accepts illegal modifiers on package declaration
- * bug 393192 - Incomplete type hierarchy with > 10 annotations
+ * bug 393192 - Incomplete type hierarchy with > 10 annotations
+ * bug 527554 - [18.3] Compiler support for JEP 286 Local-Variable Type
* Andy Clement - Contributions for
* Bug 383624 - [1.8][compiler] Revive code generation support for type annotations (from Olivier's work)
* Bug 409250 - [1.8][compiler] Various loose ends in 308 code generation
@@ -4450,6 +4451,7 @@ protected void consumeEnterVariable() {
final int annotationsLength = annotations.length;
System.arraycopy(annotations, 0, declaration.annotations = new Annotation[annotationsLength], 0, annotationsLength);
}
+ declaration.bits |= ASTNode.IsAdditionalDeclarator;
}
declaration.type = extendedDimensions == 0 ? type : augmentTypeWithAdditionalDimensions(type, extendedDimensions, annotationsOnExtendedDimensions, false);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
index 69b66b844..48b95346a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
@@ -4,7 +4,7 @@
* 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
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Benjamin Muskalla - Contribution for bug 239066
@@ -71,6 +71,7 @@
* bug 419209 - [1.8] Repeating container annotations should be rejected in the presence of annotation it contains
* Bug 429384 - [1.8][null] implement conformance rules for null-annotated lower / upper type bounds
* Bug 416182 - [1.8][compiler][null] Contradictory null annotations not rejected
+ * bug 527554 - [18.3] Compiler support for JEP 286 Local-Variable Type
* Ulrich Grave <ulrich.grave@gmx.de> - Contributions for
* bug 386692 - Missing "unused" warning on "autowired" fields
********************************************************************************/
@@ -10110,6 +10111,103 @@ public void variableTypeCannotBeVoid(AbstractVariableDeclaration varDecl) {
varDecl.sourceStart,
varDecl.sourceEnd);
}
+public void varLocalMultipleDeclarators(AbstractVariableDeclaration varDecl) {
+ this.handle(
+ IProblem.VarLocalMultipleDeclarators,
+ NoArgument,
+ NoArgument,
+ varDecl.sourceStart,
+ varDecl.sourceEnd);
+}
+public void varLocalCannotBeArray(AbstractVariableDeclaration varDecl) {
+ this.handle(
+ IProblem.VarLocalCannotBeArray,
+ NoArgument,
+ NoArgument,
+ varDecl.sourceStart,
+ varDecl.sourceEnd);
+}
+public void varLocalReferencesItself(AbstractVariableDeclaration varDecl) {
+ this.handle(
+ IProblem.VarLocalReferencesItself,
+ NoArgument,
+ NoArgument,
+ varDecl.sourceStart,
+ varDecl.sourceEnd);
+}
+public void varLocalWithoutInitizalier(AbstractVariableDeclaration varDecl) {
+ this.handle(
+ IProblem.VarLocalWithoutInitizalier,
+ NoArgument,
+ NoArgument,
+ varDecl.sourceStart,
+ varDecl.sourceEnd);
+}
+public void varLocalInitializedToNull(AbstractVariableDeclaration varDecl) {
+ this.handle(
+ IProblem.VarLocalInitializedToNull,
+ NoArgument,
+ NoArgument,
+ varDecl.sourceStart,
+ varDecl.sourceEnd);
+}
+public void varLocalInitializedToVoid(AbstractVariableDeclaration varDecl) {
+ this.handle(
+ IProblem.VarLocalInitializedToVoid,
+ NoArgument,
+ NoArgument,
+ varDecl.sourceStart,
+ varDecl.sourceEnd);
+}
+public void varLocalCannotBeArrayInitalizers(AbstractVariableDeclaration varDecl) {
+ this.handle(
+ IProblem.VarLocalCannotBeArrayInitalizers,
+ NoArgument,
+ NoArgument,
+ varDecl.sourceStart,
+ varDecl.sourceEnd);
+}
+public void varLocalCannotBeLambda(AbstractVariableDeclaration varDecl) {
+ this.handle(
+ IProblem.VarLocalCannotBeLambda,
+ NoArgument,
+ NoArgument,
+ varDecl.sourceStart,
+ varDecl.sourceEnd);
+}
+public void varLocalCannotBeMethodReference(AbstractVariableDeclaration varDecl) {
+ this.handle(
+ IProblem.VarLocalCannotBeMethodReference,
+ NoArgument,
+ NoArgument,
+ varDecl.sourceStart,
+ varDecl.sourceEnd);
+}
+public void varIsReservedTypeName(TypeDeclaration decl) {
+ this.handle(
+ IProblem.VarIsReserved,
+ NoArgument,
+ NoArgument,
+ decl.sourceStart,
+ decl.sourceEnd);
+}
+public void varIsReservedTypeNameInFuture(ASTNode decl) {
+ this.handle(
+ IProblem.VarIsReservedInFuture,
+ NoArgument,
+ NoArgument,
+ ProblemSeverities.Warning,
+ decl.sourceStart,
+ decl.sourceEnd);
+}
+public void varIsNotAllowedHere(ASTNode astNode) {
+ this.handle(
+ IProblem.VarIsNotAllowedHere,
+ NoArgument,
+ NoArgument,
+ astNode.sourceStart,
+ astNode.sourceEnd);
+}
public void variableTypeCannotBeVoidArray(AbstractVariableDeclaration varDecl) {
this.handle(
IProblem.CannotAllocateVoidArray,
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
index 7405519e3..243a57b47 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
@@ -4,6 +4,10 @@
# 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
@@ -50,6 +54,7 @@
# Bug 412153 - [1.8][compiler] Check validity of annotations which may be repeatable
# Bug 412151 - [1.8][compiler] Check repeating annotation's collection type
# Bug 419209 - [1.8] Repeating container annotations should be rejected in the presence of annotation it contains
+# Bug 527554 - [18.3] Compiler support for JEP 286 Local-Variable Type
###############################################################################
0 = {0}
1 = super cannot be used in java.lang.Object
@@ -936,6 +941,20 @@
1459 = The type {0} from module {1} may not be accessible to clients due to missing ''requires transitive''
1460 = Must declare a named package because this compilation unit is associated to the named module ''{0}''
+# Local-Variable Type Inference
+1500 = ''var'' is not allowed in a compound declaration
+1501 = ''var'' is not allowed as an element type of an array
+1502 = Declaration using ''var'' may not contain references to itself
+1503 = Cannot use ''var'' on variable without initializer
+1504 = Cannot infer type for local variable initialized to ''null''
+1505 = Variable initializer is ''void'' -- cannot infer variable type
+1506 = Array initializer needs an explicit target-type
+1507 = Lambda expression needs an explicit target-type
+1508 = Method reference needs an explicit target-type
+1509 = ''var'' is not a valid type name
+1510 = ''var'' should not be used as an type name, since it is a reserved word from source level 10 on
+1511 = ''var'' is not allowed here
+
### ELABORATIONS
## Access restrictions
78592 = The type ''{1}'' is not API (restriction on classpath entry ''{0}'')
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java
index 6d550d9f0..5dda379a1 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -117,7 +117,7 @@ public final class AST {
* </p>
*
* @since 3.0
- * @deprecated Clients should use the {@link #JLS9} AST API instead.
+ * @deprecated Clients should use the {@link #JLS10} AST API instead.
*/
public static final int JLS2 = 2;
@@ -141,7 +141,7 @@ public final class AST {
* </p>
*
* @since 3.1
- * @deprecated Clients should use the {@link #JLS9} AST API instead.
+ * @deprecated Clients should use the {@link #JLS10} AST API instead.
*/
public static final int JLS3 = 3;
@@ -165,7 +165,7 @@ public final class AST {
* </p>
*
* @since 3.7.1
- * @deprecated Clients should use the {@link #JLS9} AST API instead.
+ * @deprecated Clients should use the {@link #JLS10} AST API instead.
*/
public static final int JLS4 = 4;
@@ -189,7 +189,7 @@ public final class AST {
* </p>
*
* @since 3.10
- * @deprecated Clients should use the {@link #JLS9} AST API instead.
+ * @deprecated Clients should use the {@link #JLS10} AST API instead.
*/
public static final int JLS8 = 8;
@@ -213,6 +213,7 @@ public final class AST {
* </p>
*
* @since 3.14
+ * @deprecated Clients should use the {@link #JLS10} AST API instead.
*/
public static final int JLS9 = 9;
@@ -222,6 +223,29 @@ public final class AST {
* @since 3.14
*/
/*package*/ static final int JLS9_INTERNAL = JLS9;
+
+ /**
+ * Constant for indicating the AST API that handles JLS10.
+ * <p>
+ * This API is capable of handling all constructs in the
+ * Java language as described in the Java Language
+ * Specification, Java SE 10 Edition (JLS10).
+ * JLS10 is a superset of all earlier versions of the
+ * Java language, and the JLS10 API can be used to manipulate
+ * programs written in all versions of the Java language
+ * up to and including Java SE 10 (aka JDK 10).
+ * </p>
+ *
+ * @since 3.14
+ */
+ public static final int JLS10 = 10;
+
+ /**
+ * Internal synonym for {@link #JLS10}. Use to alleviate
+ * deprecation warnings once JLS10 is deprecated
+ * @since 3.14
+ */
+ /*package*/ static final int JLS10_INTERNAL = JLS10;
/*
* Must not collide with a value for ICompilationUnit constants
@@ -313,7 +337,7 @@ public final class AST {
* Creates a new Java abstract syntax tree
* (AST) following the specified set of API rules.
* <p>
- * Clients should use this method specifying {@link #JLS9} as the
+ * Clients should use this method specifying {@link #JLS10} as the
* AST level in all cases, even when dealing with source of earlier JDK versions like 1.3 or 1.4.
* </p>
*
@@ -749,7 +773,7 @@ public final class AST {
null/*taskPriorities*/,
true/*taskCaseSensitive*/);
break;
- case JLS9 :
+ case JLS9_INTERNAL :
this.apiLevel = level;
// initialize a scanner
this.scanner = new Scanner(
@@ -762,6 +786,19 @@ public final class AST {
null/*taskPriorities*/,
true/*taskCaseSensitive*/);
break;
+ case JLS10_INTERNAL :
+ this.apiLevel = level;
+ // initialize a scanner
+ this.scanner = new Scanner(
+ true /*comment*/,
+ true /*whitespace*/,
+ false /*nls*/,
+ ClassFileConstants.JDK10 /*sourceLevel*/,
+ ClassFileConstants.JDK10 /*complianceLevel*/,
+ null/*taskTag*/,
+ null/*taskPriorities*/,
+ true/*taskCaseSensitive*/);
+ break;
default:
throw new IllegalArgumentException("Unsupported JLS level"); //$NON-NLS-1$
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java
index 887051d49..eaceb7bf5 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -4000,12 +4000,16 @@ class ASTConverter {
final VariableDeclarationFragment variableDeclarationFragment = convertToVariableDeclarationFragment(localDeclaration);
final VariableDeclarationStatement variableDeclarationStatement = new VariableDeclarationStatement(this.ast);
variableDeclarationStatement.fragments().add(variableDeclarationFragment);
- if (this.resolveBindings) {
- recordNodes(variableDeclarationFragment, localDeclaration);
- }
variableDeclarationStatement.setSourceRange(localDeclaration.declarationSourceStart, localDeclaration.declarationSourceEnd - localDeclaration.declarationSourceStart + 1);
Type type = convertType(localDeclaration.type);
setTypeForVariableDeclarationStatement(variableDeclarationStatement, type, variableDeclarationFragment.getExtraDimensions());
+ if (this.resolveBindings) {
+ recordNodes(variableDeclarationFragment, localDeclaration);
+ if (this.ast.apiLevel() >= AST.JLS10_INTERNAL && type.isVar()) {
+ Name varName = ((SimpleType) type).getName();
+ recordNodes(varName, localDeclaration);
+ }
+ }
if (localDeclaration.modifiersSourceStart != -1) {
setModifiers(variableDeclarationStatement, localDeclaration);
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTNode.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTNode.java
index a58026d21..eed52975d 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTNode.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTNode.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -2187,6 +2187,21 @@ public abstract class ASTNode {
}
}
/**
+ * Checks that this AST operation is not used when
+ * building JLS2, JLS3, JLS4, JLS8 or JLS9 level ASTs.
+ * <p>
+ * Use this method to prevent access to new properties that have been added in JLS10
+ * </p>
+ *
+ * @exception UnsupportedOperationException if this operation is used below JLS10
+ * @since 3.14
+ */
+ final void unsupportedBelow10() {
+ if (this.ast.apiLevel < AST.JLS10_INTERNAL) {
+ throw new UnsupportedOperationException("Operation only supported in ASTs with level JLS10 and above"); //$NON-NLS-1$
+ }
+ }
+ /**
* Checks that this AST operation is only used when
* building JLS2 level ASTs.
* <p>
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTParser.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTParser.java
index 4cd9a8f35..5093e0d3e 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTParser.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTParser.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2017 IBM Corporation and others.
+ * Copyright (c) 2004, 2018 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
@@ -240,6 +240,7 @@ public class ASTParser {
case AST.JLS4_INTERNAL:
case AST.JLS8_INTERNAL:
case AST.JLS9_INTERNAL:
+ case AST.JLS10_INTERNAL:
break;
default:
throw new IllegalArgumentException();
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java
index efee4550a..50c39e3f2 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -1927,6 +1927,9 @@ class DefaultBindingResolver extends BindingResolver {
// retrieve the old ast node
org.eclipse.jdt.internal.compiler.ast.ASTNode node = (org.eclipse.jdt.internal.compiler.ast.ASTNode) this.newAstToOldAst.get(type);
org.eclipse.jdt.internal.compiler.lookup.TypeBinding binding = null;
+ if (type.getAST().apiLevel() >= AST.JLS10_INTERNAL && type.isVar()) {
+ return resolveTypeBindingForName(((SimpleType) type).getName());
+ }
if (node != null) {
if (node instanceof Receiver) {
node = ((Receiver) node).type;
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SimpleType.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SimpleType.java
index a10c15001..d314eb4f8 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SimpleType.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SimpleType.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -244,6 +244,16 @@ public class SimpleType extends AnnotatableType {
postReplaceChild(oldChild, typeName, NAME_PROPERTY);
}
+ /**
+ * @since 3.14
+ */
+ @Override
+ public boolean isVar() {
+ unsupportedBelow10();
+ if (this.typeName == null) getName();
+ String qName = this.typeName.getFullyQualifiedName();
+ return qName != null && qName.equals("var"); //$NON-NLS-1$
+ }
/* (omit javadoc for this method)
* Method declared on ASTNode.
*/
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Type.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Type.java
index 494b2be16..13f328b08 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Type.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Type.java
@@ -1,10 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -178,6 +178,20 @@ public abstract class Type extends ASTNode {
}
/**
+ * Returns whether this type is a var. The convenience method checks
+ * whether the type is so named.
+ *
+ * @return <code>true</code> if this is a var, and
+ * <code>false</code> otherwise
+ * @exception UnsupportedOperationException if this operation is used in
+ * an AST of level less than JLS10
+ * @since 3.14
+ */
+ public boolean isVar() {
+ return false;
+ }
+
+ /**
* Returns whether this type is an intersection type
* ({@link IntersectionType}).
*
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/rewrite/ImportRewrite.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/rewrite/ImportRewrite.java
index ecb2cc28e..b84237726 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/rewrite/ImportRewrite.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/rewrite/ImportRewrite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -1372,7 +1372,7 @@ public final class ImportRewrite {
CompilationUnit usedAstRoot= this.astRoot;
if (usedAstRoot == null) {
- ASTParser parser= ASTParser.newParser(AST.JLS9);
+ ASTParser parser= ASTParser.newParser(AST.JLS10);
parser.setSource(this.compilationUnit);
parser.setFocalPosition(0); // reduced AST
parser.setResolveBindings(false);
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java
index 14f37f743..8a1c8ba3e 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -73,6 +73,12 @@ public class NaiveASTFlattener extends ASTVisitor {
*/
private static final int JLS8 = AST.JLS8;
+ /**
+ * Internal synonym for {@link AST#JLS9}. Use to alleviate
+ * deprecation warnings.
+ * @deprecated
+ * @since 3.14
+ */
private static final int JLS9 = AST.JLS9;
/**
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java
index df01a5a66..19157b95c 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java
@@ -130,6 +130,7 @@ public final class ASTRewriteAnalyzer extends ASTVisitor {
/** @deprecated using deprecated code */
private static final int JLS8_INTERNAL = AST.JLS8;
+ /** @deprecated using deprecated code */
private static final int JLS9_INTERNAL = AST.JLS9;
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java
index 80fb2372e..a37629442 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java
@@ -86,6 +86,7 @@ public class ASTRewriteFlattener extends ASTVisitor {
/** @deprecated using deprecated code */
private static final int JLS8_INTERNAL = AST.JLS8;
+ /** @deprecated using deprecated code */
private static final int JLS9_INTERNAL = AST.JLS9;
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java
index a3302ed60..1d84d519b 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -337,6 +337,7 @@ public class DefaultCodeFormatter extends CodeFormatter {
}
private ASTParser createParser(int kind) {
+ @SuppressWarnings("deprecation")
ASTParser parser = ASTParser.newParser(AST.JLS9);
if (kind == K_MODULE_INFO) {
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java
index d89773250..f5b6208c9 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -113,9 +113,11 @@
package org.eclipse.jdt.core;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
+import java.util.List;
import java.util.Map;
import org.eclipse.core.resources.IContainer;
@@ -334,7 +336,7 @@ public final class JavaCore extends Plugin {
* <p><code>"cldc1.1"</code> requires the source version to be <code>"1.3"</code> and the compliance version to be <code>"1.4"</code> or lower.</p>
* <dl>
* <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.codegen.targetPlatform"</code></dd>
- * <dt>Possible values:</dt><dd><code>{ "1.1", "cldc1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "9" }</code></dd>
+ * <dt>Possible values:</dt><dd><code>{ "1.1", "cldc1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "9", "10" }</code></dd>
* <dt>Default:</dt><dd><code>"1.2"</code></dd>
* </dl>
* @category CompilerOptionID
@@ -2043,7 +2045,7 @@ public final class JavaCore extends Plugin {
* set to the same version as the source level.</p>
* <dl>
* <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.source"</code></dd>
- * <dt>Possible values:</dt><dd><code>{ "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "9" }</code></dd>
+ * <dt>Possible values:</dt><dd><code>{ "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "10" }</code></dd>
* <dt>Default:</dt><dd><code>"1.3"</code></dd>
* </dl>
* @since 2.0
@@ -2061,7 +2063,7 @@ public final class JavaCore extends Plugin {
* should match the compliance setting.</p>
* <dl>
* <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.compliance"</code></dd>
- * <dt>Possible values:</dt><dd><code>{ "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "9" }</code></dd>
+ * <dt>Possible values:</dt><dd><code>{ "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "9", "10" }</code></dd>
* <dt>Default:</dt><dd><code>"1.4"</code></dd>
* </dl>
* @since 2.0
@@ -2968,10 +2970,28 @@ public final class JavaCore extends Plugin {
public static final String VERSION_9 = "9"; //$NON-NLS-1$
/**
* Configurable option value: {@value}.
+ * @since 3.14
+ * @category OptionValue
+ */
+ public static final String VERSION_10 = "10"; //$NON-NLS-1$
+ /**
+ * Configurable option value: {@value}.
* @since 3.4
* @category OptionValue
*/
public static final String VERSION_CLDC_1_1 = "cldc1.1"; //$NON-NLS-1$
+
+ /**
+ * Returns all {@link JavaCore}{@code #VERSION_*} levels.
+ *
+ * @return all available versions
+ * @since 3.14
+ */
+ public static List<String> getAllVersions() {
+ return Arrays.asList(VERSION_CLDC_1_1, VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4, VERSION_1_5,
+ VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9, VERSION_10);
+ }
+
/**
* Configurable option value: {@value}.
* @since 2.0
@@ -5951,6 +5971,14 @@ public final class JavaCore extends Plugin {
options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR);
options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED);
break;
+ case ClassFileConstants.MAJOR_VERSION_10:
+ options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_10);
+ options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_10);
+ options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_10);
+ options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR);
+ options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR);
+ options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED);
+ break;
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/CompilationUnitSorter.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/CompilationUnitSorter.java
index c1f5ec1c3..179f25239 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/CompilationUnitSorter.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/CompilationUnitSorter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -53,6 +53,7 @@ public final class CompilationUnitSorter {
case AST.JLS4 :
case AST.JLS8 :
case AST.JLS9 :
+ case AST.JLS10 :
break;
default :
throw new IllegalArgumentException();
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java
index 041f0796f..11aeaaaef 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -237,14 +237,7 @@ private IBinaryType getJarBinaryTypeInfo() throws CoreException, IOException, Cl
String entryName = jarRoot.getClassFilePath(Util.concatWith(pkg.names, getElementName(), '/'));
byte[] contents = getClassFileContent(jarRoot, entryName);
if (contents != null) {
- String fileName;
- String rootPath = root.getPath().toOSString();
- if (org.eclipse.jdt.internal.compiler.util.Util.isJrt(rootPath)) {
- fileName = root.getHandleIdentifier() + IDependent.JAR_FILE_ENTRY_SEPARATOR +
- root.getElementName() + IDependent.JAR_FILE_ENTRY_SEPARATOR + entryName;
- } else {
- fileName = root.getHandleIdentifier() + IDependent.JAR_FILE_ENTRY_SEPARATOR + entryName;
- }
+ String fileName = root.getHandleIdentifier() + IDependent.JAR_FILE_ENTRY_SEPARATOR + entryName;
result = new ClassFileReader(contents, fileName.toCharArray(), false);
}
} else {
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyResourceElementsOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyResourceElementsOperation.java
index fb9a39bef..2bed59b32 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyResourceElementsOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyResourceElementsOperation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -87,7 +87,7 @@ public class CopyResourceElementsOperation extends MultiOperation implements Suf
initializeASTParser();
}
private void initializeASTParser() {
- this.parser = ASTParser.newParser(AST.JLS9);
+ this.parser = ASTParser.newParser(AST.JLS10);
}
/**
* Returns the children of <code>source</code> which are affected by this operation.
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateElementInCUOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateElementInCUOperation.java
index f8705524e..5af12aa47 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateElementInCUOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateElementInCUOperation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -263,7 +263,7 @@ public abstract class CreateElementInCUOperation extends JavaModelOperation {
// ensure cu is consistent (noop if already consistent)
cu.makeConsistent(this.progressMonitor);
// create an AST for the compilation unit
- ASTParser parser = ASTParser.newParser(AST.JLS9);
+ ASTParser parser = ASTParser.newParser(AST.JLS10);
parser.setSource(cu);
return (CompilationUnit) parser.createAST(this.progressMonitor);
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeMemberOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeMemberOperation.java
index 96c26effe..440f13bbe 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeMemberOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeMemberOperation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -92,7 +92,7 @@ protected StructuralPropertyDescriptor getChildPropertyDescriptor(ASTNode parent
protected ASTNode generateElementAST(ASTRewrite rewriter, ICompilationUnit cu) throws JavaModelException {
if (this.createdNode == null) {
this.source = removeIndentAndNewLines(this.source, cu);
- ASTParser parser = ASTParser.newParser(AST.JLS9);
+ ASTParser parser = ASTParser.newParser(AST.JLS10);
parser.setSource(this.source.toCharArray());
parser.setProject(getCompilationUnit().getJavaProject());
parser.setKind(ASTParser.K_CLASS_BODY_DECLARATIONS);
@@ -192,7 +192,7 @@ protected String generateSyntaxIncorrectAST() {
buff.append(lineSeparator + " public class A {" + lineSeparator); //$NON-NLS-1$
buff.append(this.source);
buff.append(lineSeparator).append('}');
- ASTParser parser = ASTParser.newParser(AST.JLS9);
+ ASTParser parser = ASTParser.newParser(AST.JLS10);
parser.setSource(buff.toString().toCharArray());
CompilationUnit compilationUnit = (CompilationUnit) parser.createAST(null);
TypeDeclaration typeDeclaration = (TypeDeclaration) compilationUnit.types().iterator().next();
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeleteElementsOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeleteElementsOperation.java
index 0bc605c95..c74ea29fa 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeleteElementsOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeleteElementsOperation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -81,7 +81,7 @@ public class DeleteElementsOperation extends MultiOperation {
}
private void initASTParser() {
- this.parser = ASTParser.newParser(AST.JLS9);
+ this.parser = ASTParser.newParser(AST.JLS10);
}
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java
index 0b5a9a195..238d2619b 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -419,7 +419,7 @@ public class JavaModelManager implements ISaveParticipant, IContentTypeChangeLis
public static class CompilationParticipants {
- private final static int MAX_SOURCE_LEVEL = 9; // 1.1 to 1.8 and 9
+ private final static int MAX_SOURCE_LEVEL = 10 ; // 1.1 to 1.8 and 9, 10
/*
* The registered compilation participants (a table from int (source level) to Object[])
@@ -569,6 +569,8 @@ public class JavaModelManager implements ISaveParticipant, IContentTypeChangeLis
return 7;
case ClassFileConstants.MAJOR_VERSION_9:
return 8;
+ case ClassFileConstants.MAJOR_VERSION_10:
+ return 9;
default:
// all other cases including ClassFileConstants.MAJOR_VERSION_1_1
return 0;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModularClassFile.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModularClassFile.java
index df08044e1..247403a8c 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModularClassFile.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModularClassFile.java
@@ -166,14 +166,7 @@ public class ModularClassFile extends AbstractClassFile implements IModularClass
String entryName = jarRoot.getClassFilePath(Util.concatWith(pkg.names, getElementName(), '/'));
byte[] contents = getClassFileContent(jarRoot, entryName);
if (contents != null) {
- String fileName;
- String rootPath = root.getPath().toOSString();
- if (org.eclipse.jdt.internal.compiler.util.Util.isJrt(rootPath)) {
- fileName = root.getHandleIdentifier() + IDependent.JAR_FILE_ENTRY_SEPARATOR +
- root.getElementName() + IDependent.JAR_FILE_ENTRY_SEPARATOR + entryName;
- } else {
- fileName = root.getHandleIdentifier() + IDependent.JAR_FILE_ENTRY_SEPARATOR + entryName;
- }
+ String fileName = root.getHandleIdentifier() + IDependent.JAR_FILE_ENTRY_SEPARATOR + entryName;
ClassFileReader classFileReader = new ClassFileReader(contents, fileName.toCharArray(), false);
return classFileReader.getModuleDeclaration();
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java
index 9fafaa806..f70ada942 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java
@@ -1,10 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Fraunhofer FIRST - extended API and implementation
@@ -476,6 +476,12 @@ public void acceptLocalVariable(LocalVariableBinding binding, org.eclipse.jdt.in
if (parent instanceof IOTJavaElement)
parent = ((IOTJavaElement)parent).getCorrespondingJavaElement();
// SH}
+ String typeSig = null;
+ if (local.type == null || local.type.isTypeNameVar(binding.declaringScope)) {
+ typeSig = Signature.createTypeSignature(binding.type.signableName(), true);// : Util.typeSignature(local.type)
+ } else {
+ typeSig = Util.typeSignature(local.type);
+ }
localVar = new LocalVariable(
(JavaElement)parent,
new String(local.name),
@@ -483,7 +489,7 @@ public void acceptLocalVariable(LocalVariableBinding binding, org.eclipse.jdt.in
local.declarationSourceEnd,
local.sourceStart,
local.sourceEnd,
- local.type == null ? Signature.createTypeSignature(binding.type.signableName(), true) : Util.typeSignature(local.type),
+ typeSig,
local.annotations,
local.modifiers,
local.getKind() == AbstractVariableDeclaration.PARAMETER);
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Disassembler.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Disassembler.java
index e0936b494..d0baaf786 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Disassembler.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Disassembler.java
@@ -1000,6 +1000,8 @@ public class Disassembler extends ClassFileBytesDisassembler {
versionNumber = JavaCore.VERSION_1_8;
} else if (minorVersion == 0 && majorVersion == 53) {
versionNumber = JavaCore.VERSION_9;
+ } else if (minorVersion == 0 && majorVersion == 54) {
+ versionNumber = JavaCore.VERSION_10;
}
buffer.append(
Messages.bind(Messages.classfileformat_versiondetails,
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java
index 89b4ea1a4..8a66611c2 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 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
@@ -776,7 +776,7 @@ public class Util {
}
private static IClassFile getClassFile(char[] fileName) {
- int jarSeparator = CharOperation.lastIndexOf(IDependent.JAR_FILE_ENTRY_SEPARATOR, fileName);
+ int jarSeparator = CharOperation.indexOf(IDependent.JAR_FILE_ENTRY_SEPARATOR, fileName);
int pkgEnd = CharOperation.lastIndexOf('/', fileName); // pkgEnd is exclusive
if (pkgEnd == -1)
pkgEnd = CharOperation.lastIndexOf(File.separatorChar, fileName);
@@ -1531,7 +1531,7 @@ public class Util {
if (referenceBinding.isLocalType() || referenceBinding.isAnonymousType()) {
// local or anonymous type
if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(fileName)) {
- int jarSeparator = CharOperation.lastIndexOf(IDependent.JAR_FILE_ENTRY_SEPARATOR, fileName);
+ int jarSeparator = CharOperation.indexOf(IDependent.JAR_FILE_ENTRY_SEPARATOR, fileName);
int pkgEnd = CharOperation.lastIndexOf('/', fileName); // pkgEnd is exclusive
if (pkgEnd == -1)
pkgEnd = CharOperation.lastIndexOf(File.separatorChar, fileName);
diff --git a/org.eclipse.jdt.core/pom.xml b/org.eclipse.jdt.core/pom.xml
index 937db4fc4..f5cb5a51a 100644
--- a/org.eclipse.jdt.core/pom.xml
+++ b/org.eclipse.jdt.core/pom.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Copyright (c) 2012, 2017 Eclipse Foundation and others.
+ Copyright (c) 2012, 2018 Eclipse Foundation and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Distribution License v1.0
which accompanies this distribution, and is available at
@@ -18,7 +18,7 @@
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
- <version>3.13.101-SNAPSHOT</version>
+ <version>3.13.102-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<properties>
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/AbstractOTJLDNullAnnotationTest.java b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/AbstractOTJLDNullAnnotationTest.java
index 2e3c07575..79fb61ba7 100644
--- a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/AbstractOTJLDNullAnnotationTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/AbstractOTJLDNullAnnotationTest.java
@@ -90,7 +90,7 @@ public class AbstractOTJLDNullAnnotationTest extends AbstractNullAnnotationTest
default:
throw new IllegalStateException("Unsupported weavingScheme "+this.weavingScheme);
}
- if (isJRE9)
+ if (isJRE9Plus)
return new String[] {
"-javaagent:"+OTAGENT_JAR_PATH,
"-Xbootclasspath/a:"+OTRE_MIN_JAR_PATH,
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/AbstractOTJLDTest.java b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/AbstractOTJLDTest.java
index 206902b9c..a65fc820e 100644
--- a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/AbstractOTJLDTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/AbstractOTJLDTest.java
@@ -94,7 +94,7 @@ public class AbstractOTJLDTest extends AbstractComparableTest {
default:
throw new IllegalStateException("Unsupported weavingScheme "+this.weavingScheme);
}
- if (isJRE9)
+ if (isJRE9Plus)
return new String[] {
"-javaagent:"+OTAGENT_JAR_PATH,
"-Xbootclasspath/a:"+OTRE_MIN_JAR_PATH,
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/other/Java5.java b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/other/Java5.java
index 6a1de0510..198d519e4 100644
--- a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/other/Java5.java
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/other/Java5.java
@@ -4081,7 +4081,7 @@ public class Java5 extends AbstractOTJLDTest {
"}\n" +
" \n"
},
- isJRE9 ? "@IA117cfa4(left=\"one\", right=\"two\")" : "@IA117cfa4(left=one, right=two)");
+ isJRE9Plus ? "@IA117cfa4(left=\"one\", right=\"two\")" : "@IA117cfa4(left=one, right=two)");
}
// a role method has a nested custom annotation, so should its tsub - testing at runtime via reflection
@@ -4145,7 +4145,7 @@ public class Java5 extends AbstractOTJLDTest {
},
(this.weavingScheme == WeavingScheme.OTRE
? ""
- : (isJRE9 ? "@IA117cfa5_2(left=\"one\", right=@IA117cfa5_1(value=\"two\"))": "@IA117cfa5_2(left=one, right=@IA117cfa5_1(value=two))")));
+ : (isJRE9Plus ? "@IA117cfa5_2(left=\"one\", right=@IA117cfa5_1(value=\"two\"))": "@IA117cfa5_2(left=one, right=@IA117cfa5_1(value=two))")));
}
// a role method has a custom annotation with enum values, annotation was in conflict with implicit activation annotation
@@ -4310,7 +4310,7 @@ public class Java5 extends AbstractOTJLDTest {
},
(this.weavingScheme == WeavingScheme.OTRE && IS_JRE_8
? ""
- : isJRE9 ? "@IA117cfa7(value={\"one\", \"two\"})" : "@IA117cfa7(value=[one, two])"));
+ : isJRE9Plus ? "@IA117cfa7(value={\"one\", \"two\"})" : "@IA117cfa7(value=[one, two])"));
}
// a role field has a custom annotation (scalar arg), so should its tsub - testing at runtime via reflection
@@ -4365,7 +4365,7 @@ public class Java5 extends AbstractOTJLDTest {
},
(this.weavingScheme == WeavingScheme.OTRE && IS_JRE_8
? ""
- : isJRE9 ? "@IA117cfa8(value=\"val\")" : "@IA117cfa8(value=val)"));
+ : isJRE9Plus ? "@IA117cfa8(value=\"val\")" : "@IA117cfa8(value=val)"));
}
// a role field has a custom annotation (enum typed arg), so should its tsub - testing at runtime via reflection
@@ -4476,7 +4476,7 @@ public class Java5 extends AbstractOTJLDTest {
},
(this.weavingScheme == WeavingScheme.OTRE && IS_JRE_8
? ""
- : isJRE9 ? "@IA117cfa9(value={1, 2})" : "@IA117cfa9(value=[1, 2])"));
+ : isJRE9Plus ? "@IA117cfa9(value={1, 2})" : "@IA117cfa9(value=[1, 2])"));
}
// a role class extends a generic class providing type parameters
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/regression/ReportedBugs.java b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/regression/ReportedBugs.java
index 87387c8c8..06d42f7db 100644
--- a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/regression/ReportedBugs.java
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/regression/ReportedBugs.java
@@ -1539,7 +1539,7 @@ public class ReportedBugs extends AbstractOTJLDTest {
"}\n" +
" \n"
};
- String[] vmArgs = isJRE9 ? new String[]{ "--add-reads", "java.datatransfer=ALL-UNNAMED" } : new String[0];
+ String[] vmArgs = isJRE9Plus ? new String[]{ "--add-reads", "java.datatransfer=ALL-UNNAMED" } : new String[0];
runTest(files, false, "", "OK", "", false, null, true, vmArgs, getCompilerOptions(), null, true);
}

Back to the top