Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2021-05-25 08:47:07 +0000
committerStephan Herrmann2021-05-25 08:47:07 +0000
commit4e09976270ea0b88bdaefc548757f995874d9a25 (patch)
tree8098502b3583142fcc90ceff28f947e166f38ec3
parent4548a116c294f1be558a4e0f208c4f7ec25f370a (diff)
downloadorg.eclipse.objectteams-4e09976270ea0b88bdaefc548757f995874d9a25.tar.gz
org.eclipse.objectteams-4e09976270ea0b88bdaefc548757f995874d9a25.tar.xz
org.eclipse.objectteams-4e09976270ea0b88bdaefc548757f995874d9a25.zip
update jdt.core to I20210524-1800
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java106
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java31
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_9.java56
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SealedTypesTests.java93
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java7
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java1
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter_15Test.java68
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ConverterTestSetup.java4
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java297
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests16_2.java330
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests18.java34
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests9.java38
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs15Tests.java35
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs16Tests.java33
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java3
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/MementoTests.java23
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java60
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/JavaSearchBugs/src/b573388/C.java4
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/JavaSearchBugs/src/b573388/R.java4
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/JavaSearchBugs/src/b573388/X.java8
-rw-r--r--org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java63
-rw-r--r--org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties132
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java97
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java6
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java6
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DoStatement.java10
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java3
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java11
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java9
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NullAnnotationMatching.java13
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java21
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java5
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java11
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java9
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java18
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java6
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java3
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java4
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TextBlock.java18
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/util/DOMASTUtil.java15
-rw-r--r--org.eclipse.jdt.core/forceQualifierUpdate.txt3
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java3
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/MementoTokenizer.java4
-rw-r--r--org.eclipse.jdt.core/pom.xml63
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchPattern.java55
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/Nd.java30
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/RawGrowableArray.java11
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/util/CharArrayMap.java3
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java4
49 files changed, 1559 insertions, 312 deletions
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 167b2bff6..a7eca695e 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
@@ -652,7 +652,7 @@ public void test012(){
" --processor-module-path <directories separated by " + File.pathSeparator + ">\n" +
" specify module path where annotation processors\n" +
" can be found\n" +
- " --system <jdk> Override location of system modules\n" +
+ " --system <jdk> Override location of system modules\n" +
" --add-exports <module>/<package>=<other-module>(,<other-module>)*\n" +
" specify additional package exports clauses to the\n" +
" given modules\n" +
@@ -664,8 +664,7 @@ public void test012(){
" resolved to be root modules\n" +
" --limit-modules <module>(,<module>)*\n" +
" specify the observable module names\n" +
- " --release <release>\n" +
- " compile for a specific VM version\n" +
+ " --release <release> compile for a specific VM version\n" +
" \n" +
" Compliance options:\n" +
" -1.3 use 1.3 compliance (-source 1.3 -target 1.1)\n" +
@@ -712,18 +711,18 @@ public void test012(){
" reported as errors\n" +
" \n" +
" Info options:\n" +
- " -info:<warnings separated by ,> convert exactly the listed warnings\n" +
+ " -info:<warnings separated by ,> convert exactly the listed warnings\n" +
" to be reported as infos\n" +
- " -info:+<warnings separated by ,> enable additional warnings to be\n" +
+ " -info:+<warnings separated by ,> enable additional warnings to be\n" +
" reported as infos\n" +
- " -info:-<warnings separated by ,> disable specific warnings to be\n" +
+ " -info:-<warnings separated by ,> disable specific warnings to be\n" +
" reported as infos\n" +
" \n" +
" Setting warning, error or info options using properties file:\n" +
" -properties <file> set warnings/errors/info option based on the properties\n" +
- " file contents. This option can be used with -nowarn,\n" +
- " -err:.., -info: or -warn:.. options, but the last one\n" +
- " on the command line sets the options to be used.\n" +
+ " file contents. This option can be used with -nowarn,\n" +
+ " -err:.., -info: or -warn:.. options, but the last one\n" +
+ " on the command line sets the options to be used.\n" +
" \n" +
" Debug options:\n" +
" -g[:lines,vars,source] custom debug info\n" +
@@ -829,11 +828,11 @@ public void test012b(){
" -deprecation + deprecation outside deprecated code\n" +
" -nowarn -warn:none disable all warnings and infos\n" +
" -nowarn:[<directories separated by " + File.pathSeparator+ ">]\n" +
- " specify directories from which optional problems should\n" +
- " be ignored\n" +
- " -warn:<warnings separated by ,> enable exactly the listed warnings\n" +
- " -warn:+<warnings separated by ,> enable additional warnings\n" +
- " -warn:-<warnings separated by ,> disable specific warnings\n" +
+ " specify directories from which optional problems\n" +
+ " should be ignored\n" +
+ " -warn:<warnings separated by ,> enable exactly the listed warnings\n" +
+ " -warn:+<warnings separated by ,> enable additional warnings\n" +
+ " -warn:-<warnings separated by ,> disable specific warnings\n" +
//{ObjectTeams: new options (marked individually as //OT: )
//OT (2x):
" abstractrelevantrole + abstract relevant role (OTJLD 2.5(b))\n" +
@@ -855,7 +854,7 @@ public void test012b(){
" (OTJLD 2.1.2(b)\n" +
" bindingconventions + discouraged use of import / import base\n" +
" (OTJLD 2.1.2(d))\n" +
- " bindingtosystemclass + trying to bind a role to a system class\n" +
+ " bindingtosystemclass + trying to bind a role to a system class\n" +
//:TO
" boxing autoboxing conversion\n" +
" charConcat + char[] in String concat\n" +
@@ -886,7 +885,7 @@ public void test012b(){
//OT:
" fragilecallin + replace callin not providing expected result\n" +
" (OTJLD 4.3(e))\n" +
- " hashCode missing hashCode() method when overriding equals()\n" +
+ " hashCode missing hashCode() method when overriding equals()\n" +
//OT:
" hiddenLiftingProblem + a lifting that is not directly visible in source\n" +
" code could fail at runtime (OTJLD 2.3.5)\n" +
@@ -904,42 +903,45 @@ public void test012b(){
" invalidJavadoc all warnings for malformed javadoc tags\n" +
" invalidJavadocTag validate javadoc tag arguments\n" +
" invalidJavadocTagDep validate deprecated references in javadoc tag args\n" +
- " invalidJavadocTagNotVisible validate non-visible references in javadoc\n" +
- " tag args\n" +
- " invalidJavadocVisibility(<visibility>) specify visibility modifier\n" +
- " for malformed javadoc tag warnings\n" +
+ " invalidJavadocTagNotVisible\n" +
+ " validate non-visible references in javadoc tag args\n" +
+ " invalidJavadocVisibility(<visibility>)\n" +
+ " specify visibility modifier for malformed javadoc\n" +
+ " tag warnings\n" +
" javadoc invalid javadoc\n" +
" localHiding local variable hiding another variable\n" +
" maskedCatchBlock + hidden catch block\n" +
" missingJavadocTags missing Javadoc tags\n" +
" missingJavadocTagsOverriding missing Javadoc tags in overriding methods\n" +
" missingJavadocTagsMethod missing Javadoc tags for method type parameter\n" +
- " missingJavadocTagsVisibility(<visibility>) specify visibility modifier\n" +
- " for missing javadoc tags warnings\n" +
- " missingJavadocComments missing Javadoc comments\n" +
- " missingJavadocCommentsOverriding missing Javadoc tags in overriding\n" +
- " methods\n" +
+ " missingJavadocTagsVisibility(<visibility>)\n" +
+ " specify visibility modifier for missing javadoc\n" +
+ " tags warnings\n" +
+ " missingJavadocComments missing Javadoc comments\n" +
+ " missingJavadocCommentsOverriding\n" +
+ " missing Javadoc tags in overriding methods\n" +
" missingJavadocCommentsVisibility(<visibility>) specify visibility\n" +
- " modifier for missing javadoc comments warnings\n" +
+ " modifier for missing javadoc comments warnings\n" +
" module + module related problems.\n" +
" nls string literal lacking non-nls tag //$NON-NLS-<n>$\n" +
" noEffectAssign + assignment without effect\n" +
" null potential missing or redundant null check\n" +
- " nullAnnot(<annot. names separated by |>) annotation based null analysis,\n" +
+ " nullAnnot(<annot. names separated by |>)\n" +
+ " annotation based null analysis,\n" +
" nullable|nonnull|nonnullbydefault annotation types\n" +
" optionally specified using fully qualified names.\n" +
- " Enabling this option enables all null-annotation\n" +
- " related sub-options. These can be individually\n" +
- " controlled using options listed below.\n" +
+ " Enabling this option enables all null-annotation\n" +
+ " related sub-options. These can be individually\n" +
+ " controlled using options listed below.\n" +
" nullAnnotConflict conflict between null annotation specified\n" +
- " and nullness inferred. Is effective only with\n" +
- " nullAnnot option enabled.\n" +
+ " and nullness inferred. Is effective only with\n" +
+ " nullAnnot option enabled.\n" +
" nullAnnotRedundant redundant specification of null annotation. Is\n" +
- " effective only with nullAnnot option enabled.\n" +
+ " effective only with nullAnnot option enabled.\n" +
" nullDereference + missing null check\n" +
- " nullUncheckedConversion unchecked conversion from non-annotated type\n" +
- " to @NonNull type. Is effective only with\n" +
- " nullAnnot option enabled.\n" +
+ " nullUncheckedConversion unchecked conversion from non-annotated type\n" +
+ " to @NonNull type. Is effective only with\n" +
+ " nullAnnot option enabled.\n" +
" over-ann missing @Override annotation (superclass)\n" +
" paramAssign assignment to a parameter\n" +
" pkgDefaultMethod + attempt to override package-default method\n" +
@@ -965,39 +967,39 @@ public void test012b(){
" syncOverride missing synchronized in synchr. method override\n" +
" syntacticAnalysis perform syntax-based null analysis for fields\n" +
" syntheticAccess synthetic access for innerclass\n" +
- " tasks(<tags separated by |>) tasks identified by tags inside comments\n" +
+ " tasks(<tags separated by |>) tasks identified by tags inside comments\n" +
" typeHiding + type parameter hiding another type\n" +
- " unavoidableGenericProblems + ignore unavoidable type safety problems\n" +
- " due to raw APIs\n" +
+ " unavoidableGenericProblems + ignore unavoidable type safety problems\n" +
+ " due to raw APIs\n" +
" unchecked + unchecked type operation\n" +
" unlikelyCollectionMethodArgumentType\n" +
" + unlikely argument type for collection method\n" +
" declaring an Object parameter\n" +
- " unlikelyEqualsArgumentType unlikely argument type for method equals()\n" +
+ " unlikelyEqualsArgumentType unlikely argument type for method equals()\n" +
" unnecessaryElse unnecessary else clause\n" +
" unqualifiedField unqualified reference to field\n" +
" unused macro for unusedAllocation, unusedArgument,\n" +
- " unusedImport, unusedLabel, unusedLocal,\n" +
- " unusedPrivate, unusedThrown, and unusedTypeArgs,\n" +
- " unusedExceptionParam\n"+
+ " unusedImport, unusedLabel, unusedLocal,\n" +
+ " unusedPrivate, unusedThrown, and unusedTypeArgs,\n" +
+ " unusedExceptionParam\n" +
" unusedAllocation allocating an object that is not used\n" +
" unusedArgument unread method parameter\n" +
" unusedExceptionParam unread exception parameter\n" +
" unusedImport + unused import declaration\n" +
" unusedLabel + unused label\n" +
" unusedLocal + unread local variable\n" +
- " unusedParam unused parameter\n" +
- " unusedParamOverriding unused parameter for overriding method\n" +
- " unusedParamImplementing unused parameter for implementing method\n" +
- " unusedParamIncludeDoc unused parameter documented in comment tag\n" +
+ " unusedParam unused parameter\n" +
+ " unusedParamOverriding unused parameter for overriding method\n" +
+ " unusedParamImplementing unused parameter for implementing method\n" +
+ " unusedParamIncludeDoc unused parameter documented in comment tag\n" +
" unusedPrivate + unused private member declaration\n" +
" unusedThrown unused declared thrown exception\n" +
- " unusedThrownWhenOverriding unused declared thrown exception in \n" +
- " overriding method\n" +
- " unusedThrownIncludeDocComment unused declared thrown exception,\n" +
- " documented in a comment tag\n" +
+ " unusedThrownWhenOverriding unused declared thrown exception in \n" +
+ " overriding method\n" +
+ " unusedThrownIncludeDocComment unused declared thrown exception,\n" +
+ " documented in a comment tag\n" +
" unusedThrownExemptExceptionThrowable unused declared thrown exception,\n" +
- " exempt Exception and Throwable\n" +
+ " exempt Exception and Throwable\n" +
" unusedTypeArgs + unused type arguments for method and constructor\n" +
" uselessTypeCheck unnecessary cast/instanceof operation\n" +
" varargsCast + varargs argument need explicit cast\n" +
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 eacb3faf5..17698127a 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
@@ -52895,6 +52895,29 @@ public void testBug543480WithoutNullPointerExceptionDuringBytecodeGeneration() {
}
}
+public void testBugBug571785_001() {
+ if (this.complianceLevel >= ClassFileConstants.JDK1_8) {
+ runConformTest(
+ new String[] {
+ "Test.java",
+ "import java.util.Collection;\n"+
+ "\n" +
+ "public class Test {\n" +
+ " public static void main(String[] args) {\n" +
+ " new testclass();\n" +
+ " }\n" +
+ "}\n" +
+ "class testclass {\n" +
+ " public void update(final Collection<? extends byte[]> inputs) {\n" +
+ " inputs.forEach(this::update);\n" +
+ " }\n" +
+ " public void update(final byte[] input) {\n" +
+ " }\n" +
+ "}\n"
+ });
+ }
+}
+
protected void assertCompileTimes(final List<Duration> shortTimes, final double factor, final List<Duration> longTimes) {
final double shortTimesAverage = minExcludingBoundaries(shortTimes);
final double longTimesAverage = minExcludingBoundaries(longTimes);
@@ -52902,8 +52925,12 @@ protected void assertCompileTimes(final List<Duration> shortTimes, final double
+ longTimesAverage + "ms should be less than " + factor + "x the minimum short compile time " + shortTimesAverage +"ms\n"
+ "long compile times: "+longTimes+"\n"
+ "short compile times: "+shortTimes;
- assertTrue(message,longTimesAverage < factor*shortTimesAverage);
- System.out.println(message);
+ if (PERFORMANCE_ASSERTS) {
+ assertTrue(message,longTimesAverage < factor*shortTimesAverage);
+ System.out.println(message);
+ } else if (longTimesAverage >= factor*shortTimesAverage) {
+ System.out.println(message);
+ }
}
protected double minExcludingBoundaries(final List<Duration> durations) {
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_9.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_9.java
index ba91a25c7..946948485 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_9.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_9.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2016, 2018 IBM Corporation.
+ * Copyright (c) 2016, 2021 IBM Corporation.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -23,7 +23,7 @@ import junit.framework.Test;
public class GenericsRegressionTest_9 extends AbstractRegressionTest9 {
static {
-// TESTS_NAMES = new String[] { "testBug488663_006" };
+// TESTS_NAMES = new String[] { "testBug551913_001", "testBug551913_002" };
// TESTS_NUMBERS = new int[] { 40, 41, 43, 45, 63, 64 };
// TESTS_RANGE = new int[] { 11, -1 };
}
@@ -670,6 +670,58 @@ public void testBug533644() {
};
runner.runConformTest();
}
+//As All non-private methods of an anonymous class instantiated with '<>' must be treated as being annotated with @override,
+//"Remove redundant type arguments" error should be reported if all the non-private methods defined in the anonymous class
+//are also present in the parent class.
+public void testBug551913_001() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_ReportRedundantSpecificationOfTypeArguments, CompilerOptions.ERROR);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " int foo() {\n" +
+ " java.util.HashSet<String> a = new java.util.HashSet<>();\n" +
+ " java.util.HashSet<String> b = new java.util.HashSet<String>(a) {\n" +
+ " private static final long serialVersionUID = 1L;\n" +
+ " public int x() {return 10;}\n" +
+ " };\n" +
+ " return 10;\n" +
+ " }\n\n" +
+ " public static void main(String[] args) {\n" +
+ " X abc= new X();\n" +
+ " System.out.println(abc.foo());" +
+ " }" +
+ "}",
+ },"10", options);
+}
+// As All non-private methods of an anonymous class instantiated with '<>' must be treated as being annotated with @override,
+// "Remove redundant type arguments" error should be reported if all the non-private methods defined in the anonymous class
+// are also present in the parent class.
+public void testBug551913_002() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_ReportRedundantSpecificationOfTypeArguments, CompilerOptions.ERROR);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " void foo() {\n" +
+ " java.util.HashSet<String> a = new java.util.HashSet<>();\n" +
+ " java.util.HashSet<String> b = new java.util.HashSet<String>(a) {\n" +
+ " private static final long serialVersionUID = 1L;\n" +
+ " public String toString() {return null;}\n" +
+ " };\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " java.util.HashSet<String> b = new java.util.HashSet<String>(a) {\n" +
+ " ^^^^^^^\n" +
+ "Redundant specification of type arguments <String>\n" +
+ "----------\n",
+ null, true, options);
+}
public static Class<GenericsRegressionTest_9> testClass() {
return GenericsRegressionTest_9.class;
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SealedTypesTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SealedTypesTests.java
index 56dd197dc..71bc44479 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SealedTypesTests.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SealedTypesTests.java
@@ -31,7 +31,7 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
static {
// TESTS_NUMBERS = new int [] { 40 };
// TESTS_RANGE = new int[] { 1, -1 };
-// TESTS_NAMES = new String[] { "testBug572205"};
+ TESTS_NAMES = new String[] { "testBug573450"};
}
public static Class<?> testClass() {
@@ -5867,5 +5867,96 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"Sealed class or interface lacks the permits clause and no class or interface from the same compilation unit declares Shape as its direct superclass or superinterface\n" +
"----------\n");
}
+ public void testBug573450_001() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "sealed interface Foo permits Foo.Bar {\n" +
+ " interface Interface {}\n" +
+ " record Bar() implements Foo, Interface { }\n" +
+ "}\n" +
+ "public class X { \n" +
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}",
+ },
+ "0");
+ }
+ public void testBug573450_002() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "interface Interface {}\n" +
+ "sealed interface Foo extends Interface permits Foo.Bar {\n" +
+ " record Bar() implements Foo, Interface {}\n" +
+ "}\n" +
+ "public class X { \n" +
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}"
+ },
+ "0");
+ }
+ public void testBug573450_003() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "sealed interface Interface extends Foo{}\n" +
+ "sealed interface Foo extends Interface permits Foo.Bar, Interface {\n" +
+ " record Bar() implements Foo, Interface {} \n" +
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " sealed interface Interface extends Foo{}\n" +
+ " ^^^^^^^^^\n" +
+ "The hierarchy of the type Interface is inconsistent\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 2)\n" +
+ " sealed interface Foo extends Interface permits Foo.Bar, Interface {\n" +
+ " ^^^^^^^^^\n" +
+ "Cycle detected: a cycle exists in the type hierarchy between Foo and Interface\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 3)\n" +
+ " record Bar() implements Foo, Interface {} \n" +
+ " ^^^\n" +
+ "The hierarchy of the type Bar is inconsistent\n" +
+ "----------\n");
+ }
+ public void testBug573450_004() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public sealed class X permits X.Y {\n" +
+ " final class Y extends X {}\n" +
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}"
+ },
+ "0");
+ }
+ public void testBug573450_005() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public sealed class X permits Y {\n" +
+ " final class Y extends X {}\n" +
+ "}"
+ },
+ "----------\n"
+ + "1. ERROR in X.java (at line 1)\n"
+ + " public sealed class X permits Y {\n"
+ + " ^\n"
+ + "Y cannot be resolved to a type\n"
+ + "----------\n"
+ + "2. ERROR in X.java (at line 2)\n"
+ + " final class Y extends X {}\n"
+ + " ^\n"
+ + "The type Y extending a sealed class X should be a permitted subtype of X\n"
+ + "----------\n");
+ }
}
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 10a0ded99..420d53fb7 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
@@ -197,11 +197,6 @@ public static Test suite() {
// add 14 specific test here (check duplicates)
ArrayList since_14 = new ArrayList();
since_14.add(SwitchExpressionsYieldTest.class);
-/*{ObjectTeams: wrong in JDT
- since_14.add(RecordsRestrictedClassTest.class);
- since_14.add(PatternMatching16Test.class);
- since_14.add(JavadocTestForRecord.class);
-SH} */
since_14.add(BatchCompilerTest_14.class);
// add 15 specific test here (check duplicates)
@@ -219,11 +214,9 @@ SH} */
since_16.add(PreviewFeatureTest.class);
since_16.add(ValueBasedAnnotationTests.class);
since_16.add(BatchCompilerTest_16.class);
-//{ObjectTeams: moved
since_16.add(RecordsRestrictedClassTest.class);
since_16.add(PatternMatching16Test.class);
since_16.add(JavadocTestForRecord.class);
-// SH}
// Build final test suite
TestSuite all = new TestSuite(TestAll.class.getName());
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 55a127fa2..a705a2bef 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
@@ -50,6 +50,7 @@ public class AbstractCompilerTest extends TestCase {
public static final int F_16 = 0x2000;
public static final boolean RUN_JAVAC = CompilerOptions.ENABLED.equals(System.getProperty("run.javac"));
+ public static final boolean PERFORMANCE_ASSERTS = !CompilerOptions.DISABLED.equals(System.getProperty("jdt.performance.asserts"));
private static final int UNINITIALIZED = -1;
private static final int NONE = 0;
private static int possibleComplianceLevels = UNINITIALIZED;
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter_15Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter_15Test.java
index 373bc83ca..52673d8e1 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter_15Test.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter_15Test.java
@@ -28,6 +28,7 @@ import org.eclipse.jdt.core.dom.ASTParser;
import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.Expression;
+import org.eclipse.jdt.core.dom.FieldDeclaration;
import org.eclipse.jdt.core.dom.IBinding;
import org.eclipse.jdt.core.dom.IMethodBinding;
import org.eclipse.jdt.core.dom.ITypeBinding;
@@ -670,12 +671,12 @@ public class ASTConverter_15Test extends ConverterTestSetup {
"public class X {\n" +
" public String test001() {\n" +
" String s = \"\"\"\n" +
- " <html>\n" +
+ " <html>\n" +
" <body>\n" +
" <p>Hello, world</p>\n" +
" </body>\n" +
- " </html>\n" +
- " \"\"\";\n" +
+ " </html>\n" +
+ " \"\"\";\n" +
" System.out.println(s);" +
" return s;\n" +
" }" +
@@ -703,12 +704,11 @@ public class ASTConverter_15Test extends ConverterTestSetup {
String literal = ((TextBlock) initializer).getLiteralValue();
assertEquals("literal value not correct",
- " <html>\n" +
- " <body>\n" +
- " <p>Hello, world</p>\n" +
- " </body>\n" +
- " </html>\n" +
- " ",
+ " <html>\n" +
+ " <body>\n" +
+ " <p>Hello, world</p>\n" +
+ " </body>\n" +
+ " </html>\n",
literal);
}
@@ -726,8 +726,8 @@ public class ASTConverter_15Test extends ConverterTestSetup {
" <body>\n" +
" <p>Hello, world</p>\n" +
" </body>\n" +
- " </html>\n" +
- " \"\"\";\n" +
+ " </html>\n" +
+ "\"\"\";\n" +
" System.out.println(s);" +
" return s;\n" +
" }" +
@@ -762,8 +762,8 @@ public class ASTConverter_15Test extends ConverterTestSetup {
" <body>\n" +
" <p>Hello, world</p>\n" +
" </body>\n" +
- " </html>\n" +
- " \"\"\"",
+ " </html>\n" +
+ "\"\"\"",
escapedValue);
String literal = ((TextBlock) initializer).getLiteralValue();
@@ -772,8 +772,8 @@ public class ASTConverter_15Test extends ConverterTestSetup {
" <body>\n" +
" <p>Hello, world</p>\n" +
" </body>\n" +
- " </html>\n" +
- " ",
+ " </html>\n" +
+ "",
literal);
}
@@ -1218,4 +1218,42 @@ public class ASTConverter_15Test extends ConverterTestSetup {
javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
}
}
+ public void testBug571461() throws JavaModelException {
+ if (!isJRE15) {
+ System.err.println("Test "+getName()+" requires a JRE 15");
+ return;
+ }
+ String contents =
+ "public class X {\n"
+ + " String example = \"\"\"\n"
+ + " Example text\"\"\";\n"
+ + " final String expected = \"Example text\";\n"
+ + "}" ;
+ this.workingCopy = getWorkingCopy("/Converter_15/src/X.java", true/*resolve*/);
+ ASTNode node = buildAST(
+ contents,
+ this.workingCopy);
+ assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
+ CompilationUnit compilationUnit = (CompilationUnit) node;
+ assertProblemsSize(compilationUnit, 0);
+ node = getASTNode(compilationUnit, 0, 0, 0);
+ assertEquals("Text block statement", node.getNodeType(), ASTNode.FIELD_DECLARATION);
+ FieldDeclaration field = (FieldDeclaration) node;
+ List fragments = field.fragments();
+ assertEquals("Incorrect no of fragments", 1, fragments.size());
+ node = (ASTNode) fragments.get(0);
+ assertEquals("Switch statement", node.getNodeType(), ASTNode.VARIABLE_DECLARATION_FRAGMENT);
+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) node;
+ Expression initializer = fragment.getInitializer();
+ assertTrue("Initializer is not a TextBlock", initializer instanceof TextBlock);
+ String escapedValue = ((TextBlock) initializer).getEscapedValue();
+
+ assertTrue("String should not be empty", escapedValue.length() != 0);
+ assertTrue("String should start with \"\"\"", escapedValue.startsWith("\"\"\""));
+
+ String literal = ((TextBlock) initializer).getLiteralValue();
+ assertEquals("literal value not correct",
+ "Example text",
+ literal);
+ }
}
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 24f025c36..33dae1132 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,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2020 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -757,6 +757,8 @@ public abstract class ConverterTestSetup extends AbstractASTTests {
Initializer initializer = (Initializer) bodyDeclaration;
Block block = initializer.getBody();
return (ASTNode) block.statements().get(statementIndex);
+ } else if (bodyDeclaration instanceof FieldDeclaration) {
+ return bodyDeclaration;
}
return null;
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java
index ec723935d..0411c067d 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java
@@ -26078,4 +26078,301 @@ public void testBug496354() throws Exception {
"val2[ANNOTATION_ATTRIBUTE_REF]{val2=, LT;, I, val2, null, 52}",
requestor.getResults());
}
+public void testBug573632() throws Exception {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "Completion/src/Foo.java",
+ "package test;\n" +
+ "public class Foo {\n" +
+ " Foo f;\n" +
+ " public void foo() {\n" +
+ " if (f != null) {\n" +
+ " f.\n" +
+ " f = null;\n" +
+ " }\n" +
+ " };\n" +
+ "}\n");
+
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "f.";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, 60}\n" +
+ "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), 60}\n" +
+ "f[FIELD_REF]{f, LFoo;, LFoo;, f, null, 60}\n" +
+ "finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, 60}\n" +
+ "foo[METHOD_REF]{foo(), LFoo;, ()V, foo, null, 60}\n" +
+ "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class;, getClass, null, 60}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, 60}\n" +
+ "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, 60}\n" +
+ "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, 60}\n" +
+ "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, 60}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, 60}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), 60}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), 60}",
+ requestor.getResults());
+}
+public void testBug573632a() throws Exception {
+ // variation: nested ifs
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "Completion/src/Foo.java",
+ "package test;\n" +
+ "public class Foo {\n" +
+ " Foo f;\n" +
+ " public void foo() {\n" +
+ " if (f != null) {\n" +
+ " if (f != null) {\n" +
+ " f.\n" +
+ " f = null;\n" +
+ " }\n" +
+ " }\n" +
+ " };\n" +
+ "}\n");
+
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "f.";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, 60}\n" +
+ "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), 60}\n" +
+ "f[FIELD_REF]{f, LFoo;, LFoo;, f, null, 60}\n" +
+ "finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, 60}\n" +
+ "foo[METHOD_REF]{foo(), LFoo;, ()V, foo, null, 60}\n" +
+ "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class;, getClass, null, 60}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, 60}\n" +
+ "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, 60}\n" +
+ "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, 60}\n" +
+ "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, 60}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, 60}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), 60}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), 60}",
+ requestor.getResults());
+}
+public void testBug573632b() throws Exception {
+ // variation: for
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "Completion/src/Foo.java",
+ "package test;\n" +
+ "public class Foo {\n" +
+ " Foo f;\n" +
+ " public void foo() {\n" +
+ " for (int i = 0; f != null; i++) {\n" +
+ " f.\n" +
+ " f = null;\n" +
+ " }\n" +
+ " };\n" +
+ "}\n");
+
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "f.";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, 60}\n" +
+ "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), 60}\n" +
+ "f[FIELD_REF]{f, LFoo;, LFoo;, f, null, 60}\n" +
+ "finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, 60}\n" +
+ "foo[METHOD_REF]{foo(), LFoo;, ()V, foo, null, 60}\n" +
+ "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class;, getClass, null, 60}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, 60}\n" +
+ "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, 60}\n" +
+ "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, 60}\n" +
+ "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, 60}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, 60}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), 60}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), 60}",
+ requestor.getResults());
+}
+public void testBug573632c() throws Exception {
+ // variation: while
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "Completion/src/Foo.java",
+ "package test;\n" +
+ "public class Foo {\n" +
+ " Foo f;\n" +
+ " public void foo() {\n" +
+ " while (f != null) {\n" +
+ " f.\n" +
+ " f = null;\n" +
+ " }\n" +
+ " };\n" +
+ "}\n");
+
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "f.";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, 60}\n" +
+ "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), 60}\n" +
+ "f[FIELD_REF]{f, LFoo;, LFoo;, f, null, 60}\n" +
+ "finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, 60}\n" +
+ "foo[METHOD_REF]{foo(), LFoo;, ()V, foo, null, 60}\n" +
+ "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class;, getClass, null, 60}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, 60}\n" +
+ "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, 60}\n" +
+ "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, 60}\n" +
+ "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, 60}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, 60}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), 60}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), 60}",
+ requestor.getResults());
+}
+public void testBug573702() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "Completion/src/App.java",
+ "import java.util.Collection;\n" +
+ "import java.util.Map;\n" +
+ "\n" +
+ "interface ObjectProperty<T> {\n" +
+ " void addListener(SingleFireInvalidationListener singleFireInvalidationListener);\n" +
+ "}\n" +
+ "class SingleFireInvalidationListener {\n" +
+ " public SingleFireInvalidationListener(Collection<String> list) { }\n" +
+ "}\n" +
+ "public class App {\n" +
+ "\n" +
+ " public static void boo(Map<String, String> data) {\n" +
+ " System.out.println(\"PopOver direct buffer delayed patch installation started\");\n" +
+ " App.getDataProperty().addListener(new SingleFireInvalidationListener(data.values()));\n" +
+ " System.out.println(\"PopOver direct buffer delayed patch installation done\");\n" +
+ " }\n" +
+ "\n" +
+ " public static ObjectProperty<Map<String, String>> getDataProperty() {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n");
+
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "new SingleFireInvalidationListener(data";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "data[LOCAL_VARIABLE_REF]{data, null, LMap;, data, null, 56}",
+ requestor.getResults());
+}
+public void testBug573702_fieldRef() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "Completion/src/App.java",
+ "import java.util.Collection;\n" +
+ "import java.util.Map;\n" +
+ "\n" +
+ "interface ObjectProperty<T> {\n" +
+ " void addListener(SingleFireInvalidationListener singleFireInvalidationListener);\n" +
+ "}\n" +
+ "class SingleFireInvalidationListener {\n" +
+ " public SingleFireInvalidationListener(Collection<String> list) { }\n" +
+ "}\n" +
+ "public class App {\n" +
+ " Map<String, String> data;\n" +
+ " public void boo() {\n" +
+ " System.out.println(\"PopOver direct buffer delayed patch installation started\");\n" +
+ " App.getDataProperty().addListener(new SingleFireInvalidationListener(this.data.values()));\n" +
+ " System.out.println(\"PopOver direct buffer delayed patch installation done\");\n" +
+ " }\n" +
+ "\n" +
+ " public static ObjectProperty<Map<String, String>> getDataProperty() {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n");
+
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "new SingleFireInvalidationListener(this.data";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "data[FIELD_REF]{data, LApp;, LMap;, data, null, 64}",
+ requestor.getResults());
+}
+public void testBug573702_qualifiedName() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "Completion/src/App.java",
+ "import java.util.Collection;\n" +
+ "import java.util.Map;\n" +
+ "\n" +
+ "interface ObjectProperty<T> {\n" +
+ " void addListener(SingleFireInvalidationListener singleFireInvalidationListener);\n" +
+ "}\n" +
+ "class SingleFireInvalidationListener {\n" +
+ " public SingleFireInvalidationListener(Collection<String> list) { }\n" +
+ "}\n" +
+ "public class App {\n" +
+ " static Map<String, String> data;\n" +
+ " public void boo() {\n" +
+ " System.out.println(\"PopOver direct buffer delayed patch installation started\");\n" +
+ " App.getDataProperty().addListener(new SingleFireInvalidationListener(App.data.values()));\n" +
+ " System.out.println(\"PopOver direct buffer delayed patch installation done\");\n" +
+ " }\n" +
+ "\n" +
+ " public static ObjectProperty<Map<String, String>> getDataProperty() {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n");
+
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "new SingleFireInvalidationListener(App.data";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "data[FIELD_REF]{data, LApp;, LMap;, data, null, 55}",
+ requestor.getResults());
+}
+public void testBug573702_qualifiedName_firstSegment() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "Completion/src/App.java",
+ "import java.util.Collection;\n" +
+ "import java.util.Map;\n" +
+ "\n" +
+ "interface ObjectProperty<T> {\n" +
+ " void addListener(SingleFireInvalidationListener singleFireInvalidationListener);\n" +
+ "}\n" +
+ "class SingleFireInvalidationListener {\n" +
+ " public SingleFireInvalidationListener(Collection<String> list) { }\n" +
+ "}\n" +
+ "public class App {\n" +
+ " static Map<String, String> data;\n" +
+ " public void boo() {\n" +
+ " System.out.println(\"PopOver direct buffer delayed patch installation started\");\n" +
+ " App.getDataProperty().addListener(new SingleFireInvalidationListener(App.data.values()));\n" +
+ " System.out.println(\"PopOver direct buffer delayed patch installation done\");\n" +
+ " }\n" +
+ "\n" +
+ " public static ObjectProperty<Map<String, String>> getDataProperty() {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n");
+
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "new SingleFireInvalidationListener(App";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "App[TYPE_REF]{App, , LApp;, null, null, 56}",
+ requestor.getResults());
+}
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests16_2.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests16_2.java
index e1c4ef0ef..30272c259 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests16_2.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests16_2.java
@@ -46,9 +46,9 @@ public class CompletionTests16_2 extends AbstractJavaModelCompletionTests {
this.workingCopies = new ICompilationUnit[1];
this.workingCopies[0] = getWorkingCopy("/Completion/src/X.java",
"public seal class X permits Y{\n"
- + " public static void main(String[] args){\n"
- + " interf;\n}\n}\n"
- + " ");
+ + " public static void main(String[] args){\n"
+ + " interf;\n}\n}\n"
+ + " ");
this.workingCopies[0].getJavaProject(); // assuming single project for all working copies
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
requestor.allowAllRequiredProposals();
@@ -65,9 +65,9 @@ public class CompletionTests16_2 extends AbstractJavaModelCompletionTests {
this.workingCopies = new ICompilationUnit[1];
this.workingCopies[0] = getWorkingCopy("/Completion/src/X.java",
"public seal class X permits Y{\n"
- + " public static void main(String[] args){\n"
- + " enu;\n}\n}\n"
- + " ");
+ + " public static void main(String[] args){\n"
+ + " enu;\n}\n}\n"
+ + " ");
this.workingCopies[0].getJavaProject(); // assuming single project for all working copies
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
requestor.allowAllRequiredProposals();
@@ -86,11 +86,11 @@ public class CompletionTests16_2 extends AbstractJavaModelCompletionTests {
this.workingCopies[0] = getWorkingCopy(
"/Completion/src/Point.java",
"public class Point {\n" +
- "private void method(Object o) throws Exception{\n" +
- "if ((o instanceof fina Record xvar )) \n" +
- "{\n" +
- "}\n" +
- "}\n" +
+ "private void method(Object o) throws Exception{\n" +
+ "if ((o instanceof fina Record xvar )) \n" +
+ "{\n" +
+ "}\n" +
+ "}\n" +
"}");
this.workingCopies[0].getJavaProject(); // assuming single project for all working copies
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
@@ -105,34 +105,292 @@ public class CompletionTests16_2 extends AbstractJavaModelCompletionTests {
}
// completion for final keyword in instanceof pattern variable at higher relevance than Fin* classes
- public void test004() throws JavaModelException {
- this.workingCopies = new ICompilationUnit[2];
- this.workingCopies[0] = getWorkingCopy(
- "/Completion/src/Point.java",
- "public class Point {\n" +
- "private void method(Object o) throws Exception{\n" +
- "if ((o instanceof fina Record xvar )) \n" +
- "{\n" +
+ public void test004() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[2];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/Point.java",
+ "public class Point {\n" +
+ "private void method(Object o) throws Exception{\n" +
+ "if ((o instanceof fina Record xvar )) \n" +
+ "{\n" +
+ "}\n" +
+ "}\n" +
+ "}");
+ this.workingCopies[1] = getWorkingCopy(
+ "/Completion/src/Bug460411.java",
+ "package abc;" +
+ "public class FinalCl {\n"+
+ "}\n");
+ this.workingCopies[0].getJavaProject(); // assuming single project for all working copies
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "fina";
+ int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults("FinalCl[TYPE_REF]{abc.FinalCl, abc, Labc.FinalCl;, null, null, "+(R_DEFAULT+R_RESOLVED+R_INTERESTING+R_NON_RESTRICTED+R_EXPECTED_TYPE)+"}\n"
+ + "final[KEYWORD]{final, null, null, final, null, "+(R_DEFAULT+R_RESOLVED+R_INTERESTING+R_CASE+R_NON_RESTRICTED+R_FINAL+R_EXPECTED_TYPE)+"}",
+ requestor.getResults());
+
+
+ }
+
+ // completion for instanceof pattern variable for false condition - inside the instanceof block
+ public void test005() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/Point.java",
+ "public class Point {\n" +
+ "private void method(Object o) throws Exception{\n" +
+ "if (!(o instanceof Record xvar )) \n" +
+ "{\n" +
+ " System.out.println(xvar.);\n" +
+ " throw new Exception();\n" +
+ "}\n" +
+
+ "}\n" +
+
+ "}");
+ this.workingCopies[0].getJavaProject(); // assuming single project for all working copies
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "xvar.";
+ int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults("",
+ requestor.getResults());
+
+ }
+ // completion for instanceof pattern variable for true condition - outside the instanceof block
+ public void test006() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/Point.java",
+ "public class Point {\n" +
+ "private void method(Object o) throws Exception{\n" +
+ "if ((o instanceof Record xvar )) \n" +
+ "{\n" +
+ " throw new Exception();\n" +
+ "}\n" +
+ " System.out.println(xvar.);\n" +
+ "}\n" +
+
+ "}");
+ this.workingCopies[0].getJavaProject(); // assuming single project for all working copies
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "xvar.";
+ int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults("",
+ requestor.getResults());
+
+ }
+ // completion for instanceof pattern variable for false condition - outside the instanceof block - in do-while loop
+ public void test007() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/Point.java",
+ "public class Point {\n" +
+ "private void method(Object o) throws Exception{\n" +
+ "do { \n" +
+ "} while (!(o instanceof Record var1));\n" +
+ "System.out.println(var1.);\n" +
+
"}\n" +
+
+ "}");
+ this.workingCopies[0].getJavaProject(); // assuming single project for all working copies
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "var1.";
+ int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults("finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, 55}\n"
+ + "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, 55}\n"
+ + "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, 55}\n"
+ + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, 55}\n"
+ + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), 55}\n"
+ + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), 55}\n"
+ + "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, 60}\n"
+ + "equals[METHOD_REF]{equals(), Ljava.lang.Record;, (Ljava.lang.Object;)Z, equals, (obj), 60}\n"
+ + "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<+Ljava.lang.Object;>;, getClass, null, 60}\n"
+ + "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Record;, ()I, hashCode, null, 90}\n"
+ + "toString[METHOD_REF]{toString(), Ljava.lang.Record;, ()Ljava.lang.String;, toString, null, 90}",
+ requestor.getResults());
+ }
+ // completion for instanceof pattern variable - double negation
+ public void test008() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/Point.java",
+ "public class Point {\n" +
+ "private void method(Object o) throws Exception{\n" +
+ "if (!!(o instanceof Record xvar )) \n" +
+ "{\n" +
+ " throw new Exception();\n" +
+ "}\n" +
+ " System.out.println(xvar.);\n" +
+ "}\n" +
+
+ "}");
+ this.workingCopies[0].getJavaProject(); // assuming single project for all working copies
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "xvar.";
+ int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults("",
+ requestor.getResults());
+
+ }
+ // completion for instanceof pattern variable - triple negation
+ public void test009() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/Point.java",
+ "public class Point {\n" +
+ "private void method(Object o) throws Exception{\n" +
+ "if (!!!(o instanceof Record xvar )) \n" +
+ "{\n" +
+ " throw new Exception();\n" +
+ "}\n" +
+ " System.out.println(xvar.);\n" +
+ "}\n" +
+
+ "}");
+ this.workingCopies[0].getJavaProject(); // assuming single project for all working copies
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "xvar.";
+ int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults("finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, 55}\n"
+ + "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, 55}\n"
+ + "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, 55}\n"
+ + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, 55}\n"
+ + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), 55}\n"
+ + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), 55}\n"
+ + "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, 60}\n"
+ + "equals[METHOD_REF]{equals(), Ljava.lang.Record;, (Ljava.lang.Object;)Z, equals, (obj), 60}\n"
+ + "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<+Ljava.lang.Object;>;, getClass, null, 60}\n"
+ + "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Record;, ()I, hashCode, null, 90}\n"
+ + "toString[METHOD_REF]{toString(), Ljava.lang.Record;, ()Ljava.lang.String;, toString, null, 90}",
+ requestor.getResults());
+
+ }
+ // completion for instanceof pattern variable - double negation
+ public void test010() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/Point.java",
+ "public class Point {\n" +
+ "private void method(Object o) throws Exception{\n" +
+ "if (!!(o instanceof Record xvar )) \n" +
+ "{\n" +
+ " System.out.println(xvar.);\n" +
+ "}\n" +
+
"}\n" +
- "}");
- this.workingCopies[1] = getWorkingCopy(
- "/Completion/src/Bug460411.java",
- "package abc;" +
- "public class FinalCl {\n"+
- "}\n");
- this.workingCopies[0].getJavaProject(); // assuming single project for all working copies
- CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
- requestor.allowAllRequiredProposals();
- String str = this.workingCopies[0].getSource();
- String completeBehind = "fina";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
- this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("FinalCl[TYPE_REF]{abc.FinalCl, abc, Labc.FinalCl;, null, null, "+(R_DEFAULT+R_RESOLVED+R_INTERESTING+R_NON_RESTRICTED+R_EXPECTED_TYPE)+"}\n"
- + "final[KEYWORD]{final, null, null, final, null, "+(R_DEFAULT+R_RESOLVED+R_INTERESTING+R_CASE+R_NON_RESTRICTED+R_FINAL+R_EXPECTED_TYPE)+"}",
- requestor.getResults());
+ "}");
+ this.workingCopies[0].getJavaProject(); // assuming single project for all working copies
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "xvar.";
+ int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults("finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, 55}\n"
+ + "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, 55}\n"
+ + "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, 55}\n"
+ + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, 55}\n"
+ + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), 55}\n"
+ + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), 55}\n"
+ + "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, 60}\n"
+ + "equals[METHOD_REF]{equals(), Ljava.lang.Record;, (Ljava.lang.Object;)Z, equals, (obj), 60}\n"
+ + "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<+Ljava.lang.Object;>;, getClass, null, 60}\n"
+ + "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Record;, ()I, hashCode, null, 90}\n"
+ + "toString[METHOD_REF]{toString(), Ljava.lang.Record;, ()Ljava.lang.String;, toString, null, 90}",
+ requestor.getResults());
+
+ }
+ // completion for instanceof pattern variable for false condition
+ public void test011() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/Point.java",
+ "public class Point {\n" +
+ "private void method(Object o) throws Exception{\n" +
+ "if (!(o instanceof Record xvar )) \n" +
+ "{\n" +
+ " throw new Exception();\n" +
+ "}\n" +
+ " System.out.println(xvar.);\n" +
+ "}\n" +
- }
+ "}");
+ this.workingCopies[0].getJavaProject(); // assuming single project for all working copies
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "xvar.";
+ int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults("finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, 55}\n"
+ + "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, 55}\n"
+ + "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, 55}\n"
+ + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, 55}\n"
+ + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), 55}\n"
+ + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), 55}\n"
+ + "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, 60}\n"
+ + "equals[METHOD_REF]{equals(), Ljava.lang.Record;, (Ljava.lang.Object;)Z, equals, (obj), 60}\n"
+ + "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<+Ljava.lang.Object;>;, getClass, null, 60}\n"
+ + "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Record;, ()I, hashCode, null, 90}\n"
+ + "toString[METHOD_REF]{toString(), Ljava.lang.Record;, ()Ljava.lang.String;, toString, null, 90}",
+ requestor.getResults());
+ }
+
+ // completion for instanceof pattern variable for true condition
+ public void test012() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/Point.java",
+ "public class Point {\n" +
+ "private void method(Object o) {\n" +
+ "if ((o instanceof Record xvar )) \n" +
+ "{\n" +
+ " System.out.println(xvar.);\n" +
+ "}\n" +
+
+ "}\n" +
+
+ "}");
+ this.workingCopies[0].getJavaProject(); // assuming single project for all working copies
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "xvar.";
+ int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults("finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, 55}\n"
+ + "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, 55}\n"
+ + "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, 55}\n"
+ + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, 55}\n"
+ + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), 55}\n"
+ + "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), 55}\n"
+ + "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, 60}\n"
+ + "equals[METHOD_REF]{equals(), Ljava.lang.Record;, (Ljava.lang.Object;)Z, equals, (obj), 60}\n"
+ + "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<+Ljava.lang.Object;>;, getClass, null, 60}\n"
+ + "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Record;, ()I, hashCode, null, 90}\n"
+ + "toString[METHOD_REF]{toString(), Ljava.lang.Record;, ()Ljava.lang.String;, toString, null, 90}",
+ requestor.getResults());
+
+ }
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests18.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests18.java
index 214ca75a0..a3bbcbcc7 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests18.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests18.java
@@ -4984,4 +4984,38 @@ public void testBug573105_OnLambdaParamAtMethodInvocationInsideLambdaInCondition
assertTrue(String.format("Result doesn''t contain method foo (%s)", result),
result.contains("foo[METHOD_REF]{foo(), LBug573105$Element;, ()Ljava.net.URI;, foo, null, 60}\n"));
}
+public void testBug482663() throws Exception {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/CompletionParserResumeFailure.java",
+ "import java.util.Map;\n" +
+ "import java.util.stream.Stream;\n" +
+ "class Path {}\n" +
+ "public class CompletionParserResumeFailure\n" +
+ "{\n" +
+ " Stream<Path> list(Path dir) throws IOException { return null; }\n" +
+ " public void freeze()\n" +
+ " {\n" +
+ " list(null).map(p -> new Object()\n" +
+ " {\n" +
+ " public String name = p.getFileName().toString();\n" +
+ " public Map<String, Date> clients = p;\n" +
+ " });\n" +
+ " }\n" +
+ "}\n");
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "Date";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, new NullProgressMonitor());
+
+ assertResults(
+ "DateFormat[TYPE_REF]{java.text.DateFormat, java.text, Ljava.text.DateFormat;, null, null, 69}\n" +
+ "DateFormatSymbols[TYPE_REF]{java.text.DateFormatSymbols, java.text, Ljava.text.DateFormatSymbols;, null, null, 69}\n" +
+ "Date[TYPE_REF]{java.sql.Date, java.sql, Ljava.sql.Date;, null, null, 73}\n" +
+ "Date[TYPE_REF]{java.util.Date, java.util, Ljava.util.Date;, null, null, 73}",
+ requestor.getResults());
+}
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests9.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests9.java
index 6a9596b01..a9420b7ba 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests9.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests9.java
@@ -1636,4 +1636,42 @@ public void testBug560606() throws CoreException {
deleteProject(project1);
}
}
+public void testBug573632d() throws Exception {
+ IJavaProject project1 = createJavaProject("Completion9_1", new String[] {"src"}, new String[] {"JCL19_LIB", "org.eclipse.jdt.core.tests.model.TEST_CONTAINER"}, "bin", "9");
+ try {
+ project1.open(null);
+ CompletionResult result = complete(
+ "/Completion9_1/src/Foo.java",
+ "package test;\n" +
+ "import java.io.InputStream;\n" +
+ "public class Foo {\n" +
+ " Foo f;\n" +
+ " public void foo() {\n" +
+ " InputStream is = new InputStream(null);\n" +
+ " try (is) {\n" +
+ " f.\n" +
+ " f = null;\n" +
+ " }\n" +
+ " };\n" +
+ "}\n",
+ "f.");
+ assertResults(
+ "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, 60}\n" +
+ "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), 60}\n" +
+ "f[FIELD_REF]{f, LFoo;, LFoo;, f, null, 60}\n" +
+ "finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, 60}\n" +
+ "foo[METHOD_REF]{foo(), LFoo;, ()V, foo, null, 60}\n" +
+ "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<+Ljava.lang.Object;>;, getClass, null, 60}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, 60}\n" +
+ "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, 60}\n" +
+ "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, 60}\n" +
+ "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, 60}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, 60}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), 60}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), 60}",
+ result.proposals);
+ } finally {
+ deleteProject(project1);
+ }
+}
} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs15Tests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs15Tests.java
index 6db3722c3..54fbd1dcf 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs15Tests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs15Tests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2020 IBM Corporation and others.
+ * Copyright (c) 2020, 2021 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
@@ -621,6 +621,39 @@ public class JavaSearchBugs15Tests extends AbstractJavaSearchTests {
"src/X.java void Point.method() [comp_] EXACT_MATCH");
}
+ //
+ public void testBug572467() throws CoreException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Point.java",
+ "public record Point(int comp_) { \n" +
+ " public Point {\n" +
+ " comp_=11;\n" +
+ " }\n" +
+ "public void method ( ) { \n"+
+ " int var1=comp_;\n" +
+ " int var2=comp_;\n" +
+ " int var3=this.comp_;\n" +
+ " int accMethod=this.comp_();\n" +
+ "} \n"+
+ "}\n"
+ );
+
+ String str = this.workingCopies[0].getSource();
+ String selection = "comp_";
+ int start = str.lastIndexOf(selection);
+ int length = selection.length();
+
+ IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length);
+ assertTrue(elements.length ==1);
+ assertTrue(elements[0] instanceof IField);
+ search(elements[0], REFERENCES, EXACT_RULE);
+ assertSearchResults(
+ "src/Point.java Point(int) [comp_] EXACT_MATCH\n" +
+ "src/Point.java void Point.method() [comp_] EXACT_MATCH\n" +
+ "src/Point.java void Point.method() [comp_] EXACT_MATCH\n" +
+ "src/Point.java void Point.method() [comp_] EXACT_MATCH\n" +
+ "src/Point.java void Point.method() [comp_()] EXACT_MATCH");
+ }
//selection - select CC type
public void testBug558812_018() throws CoreException {
this.workingCopies = new ICompilationUnit[1];
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs16Tests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs16Tests.java
index c78cf3095..f0f85e3f2 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs16Tests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs16Tests.java
@@ -456,6 +456,39 @@ public class JavaSearchBugs16Tests extends AbstractJavaSearchTests {
""
);
}
+ public void testBug573388 () throws CoreException {
+ this.workingCopies = new ICompilationUnit[3];
+ this.workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b573388/X.java",
+ "package b573388;\n\n" +
+ "public class X {\n"+
+ "public static void main() {\n" +
+ " R r= new R(7);\n"+
+ " C c= new C();\n"+
+ "}\n"+
+ "}\n"
+ );
+ this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b573388/C.java",
+ "package b573388;\n\n" +
+ "public class C {\n"+
+ "}\n"
+ );
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b573388/R.java",
+ "package b573388;\n\n" +
+ "public record R(int a) {\n"+
+ "}\n"
+ );
+ String str = this.workingCopies[2].getSource();
+ String selection = "X";
+ int start = str.indexOf(selection);
+ int length = selection.length();
+ IJavaElement[] elements = this.workingCopies[2].codeSelect(start, length);
+ SourceType st = (SourceType)elements[0];
+ new SearchEngine(this.workingCopies).searchDeclarationsOfReferencedTypes(st, this.resultCollector, null);
+ assertSearchResults(
+ "src/b573388/R.java b573388.R [R] EXACT_MATCH\n" +
+ "src/b573388/C.java b573388.C [C] EXACT_MATCH"
+ );
+ }
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java
index ba3424dca..5240defcb 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2020 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -8900,6 +8900,7 @@ public void testBug185452() throws CoreException {
"src/b142044 b142044\n" +
"src/b163984 b163984\n" +
"src/b201064 b201064\n" +
+ "src/b573388 b573388\n" +
"src/b81556 b81556\n" +
"src/b81556/a b81556.a\n" +
"src/b86380 b86380\n" +
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/MementoTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/MementoTests.java
index 5656166e1..1fc074015 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/MementoTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/MementoTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -951,4 +951,25 @@ public void testEmptyAttribute() throws CoreException, IOException {
deleteProject("Test");
}
}
+public void testBug573147() throws CoreException, IOException {
+ try {
+ createJavaProject("Test`", new String[] {"src"}, null, "bin", "1.8", false);
+ createFile(
+ "/Test`/src/X.java",
+ "public class X<T> {\n" +
+ " void foo() {\n" +
+ " X<String> var = null;\n" +
+ " }\n" +
+ "}"
+ );
+ ILocalVariable localVar = getLocalVariable(getCompilationUnit("/Test`/src/X.java"), "var", "var");
+ String memento = localVar.getHandleIdentifier();
+ IJavaElement restored = JavaCore.create(memento);
+ assertNotNull("element should not be null", restored);
+ String restoredMemento = restored.getHandleIdentifier();
+ assertEquals("Unexpected restored memento", memento, restoredMemento);
+ } finally {
+ deleteProject("Test`");
+ }
+}
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java
index cd8e17d93..d4fe75147 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -56,7 +56,7 @@ public class TypeHierarchyTests extends ModifyingResourceTests {
ITypeHierarchy typeHierarchy;
static {
-// TESTS_NAMES= new String[] { "testBug329663a" };
+// TESTS_NAMES= new String[] { "testBug573450" };
}
public static Test suite() {
return buildModelTestSuite(TypeHierarchyTests.class, BYTECODE_DECLARATION_ORDER);
@@ -3393,5 +3393,61 @@ public void testBug457813() throws CoreException {
}
}
+public void testBug573450_001() throws CoreException {
+ if (!isJRE16) return;
+ try {
+ IJavaProject proj = createJava16Project("P", new String[] {"src"});
+ proj.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ createFolder("/P/src/hierarchy");
+ createFile(
+ "/P/src/hierarchy/X.java",
+ "@SuppressWarnings(\"preview\")\n" +
+ "public sealed class X permits X.Y {\n" +
+ " final class Y extends X {}\n" +
+ "}"
+ );
+ IType type = getCompilationUnit("P", "src", "hierarchy", "X.java").getType("X");
+ assertTrue("Type should exist!", type.exists());
+ ITypeHierarchy hierarchy = type.newTypeHierarchy(null); // when bug occurred a stack overflow happened here...
+ assertHierarchyEquals(
+ "Focus: X [in X.java [in hierarchy [in src [in P]]]]\n" +
+ "Super types:\n" +
+ " Object [in Object.class [in java.lang [in <module:java.base>]]]\n" +
+ "Sub types:\n" +
+ " Y [in X [in X.java [in hierarchy [in src [in P]]]]]\n",
+ hierarchy);
+ } finally {
+ deleteProject("P");
+ }
+}
+
+public void testBug573450_002() throws CoreException {
+ if (!isJRE16) return;
+ try {
+ IJavaProject proj = createJava16Project("P", new String[] {"src"});
+ proj.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ createFolder("/P/src/hierarchy");
+ createFile(
+ "/P/src/hierarchy/Foo.java",
+ "@SuppressWarnings(\"preview\")\n" +
+ "sealed interface Foo permits Foo.Bar {\n" +
+ " interface Interface {}\n" +
+ " record Bar() implements Foo, Interface {}\n" +
+ "}"
+ );
+ IType type1 = getCompilationUnit("P", "src", "hierarchy", "Foo.java").getType("Foo");
+ assertTrue("Type should exist!", type1.exists());
+ ITypeHierarchy hierarchy1 = type1.newTypeHierarchy(null);
+ assertHierarchyEquals(
+ "Focus: Foo [in Foo.java [in hierarchy [in src [in P]]]]\n" +
+ "Super types:\n" +
+ "Sub types:\n" +
+ " Bar [in Foo [in Foo.java [in hierarchy [in src [in P]]]]]\n",
+ hierarchy1);
+ } finally {
+ deleteProject("P");
+ }
+}
+
}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearchBugs/src/b573388/C.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearchBugs/src/b573388/C.java
new file mode 100644
index 000000000..ff6dec738
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/workspace/JavaSearchBugs/src/b573388/C.java
@@ -0,0 +1,4 @@
+package b573388;
+
+public class C {
+}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearchBugs/src/b573388/R.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearchBugs/src/b573388/R.java
new file mode 100644
index 000000000..247b0966a
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/workspace/JavaSearchBugs/src/b573388/R.java
@@ -0,0 +1,4 @@
+package b573388;
+
+public record R(int a) {
+}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearchBugs/src/b573388/X.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearchBugs/src/b573388/X.java
new file mode 100644
index 000000000..f4fa221f8
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/workspace/JavaSearchBugs/src/b573388/X.java
@@ -0,0 +1,8 @@
+package b573388;
+
+public class XA {
+ public static void main(String[] args) {
+ R r= new R(7);
+ C c= new C();
+ }
+}
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 1a9f0d9ca..81f3fe73d 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
@@ -3253,51 +3253,50 @@ public void configure(String[] argv) {
}
}
/** Translates any supported standard version starting at 1.3 up-to latest into the corresponding constant from CompilerOptions */
-@SuppressWarnings("nls")
private String optionStringToVersion(String currentArg) {
switch (currentArg) {
- case "1.3": return CompilerOptions.VERSION_1_3;
- case "1.4": return CompilerOptions.VERSION_1_4;
- case "1.5":
- case "5":
- case "5.0":
+ case "1.3": return CompilerOptions.VERSION_1_3; //$NON-NLS-1$
+ case "1.4": return CompilerOptions.VERSION_1_4; //$NON-NLS-1$
+ case "1.5": //$NON-NLS-1$
+ case "5": //$NON-NLS-1$
+ case "5.0": //$NON-NLS-1$
return CompilerOptions.VERSION_1_5;
- case "1.6":
- case "6":
- case "6.0":
+ case "1.6": //$NON-NLS-1$
+ case "6": //$NON-NLS-1$
+ case "6.0": //$NON-NLS-1$
return CompilerOptions.VERSION_1_6;
- case "1.7":
- case "7":
- case "7.0":
+ case "1.7": //$NON-NLS-1$
+ case "7": //$NON-NLS-1$
+ case "7.0": //$NON-NLS-1$
return CompilerOptions.VERSION_1_7;
- case "1.8":
- case "8":
- case "8.0":
+ case "1.8": //$NON-NLS-1$
+ case "8": //$NON-NLS-1$
+ case "8.0": //$NON-NLS-1$
return CompilerOptions.VERSION_1_8;
- case "1.9":
- case "9":
- case "9.0":
+ case "1.9": //$NON-NLS-1$
+ case "9": //$NON-NLS-1$
+ case "9.0": //$NON-NLS-1$
return CompilerOptions.VERSION_9;
- case "10":
- case "10.0":
+ case "10": //$NON-NLS-1$
+ case "10.0": //$NON-NLS-1$
return CompilerOptions.VERSION_10;
- case "11":
- case "11.0":
+ case "11": //$NON-NLS-1$
+ case "11.0": //$NON-NLS-1$
return CompilerOptions.VERSION_11;
- case "12":
- case "12.0":
+ case "12": //$NON-NLS-1$
+ case "12.0": //$NON-NLS-1$
return CompilerOptions.VERSION_12;
- case "13":
- case "13.0":
+ case "13": //$NON-NLS-1$
+ case "13.0": //$NON-NLS-1$
return CompilerOptions.VERSION_13;
- case "14":
- case "14.0":
+ case "14": //$NON-NLS-1$
+ case "14.0": //$NON-NLS-1$
return CompilerOptions.VERSION_14;
- case "15":
- case "15.0":
+ case "15": //$NON-NLS-1$
+ case "15.0": //$NON-NLS-1$
return CompilerOptions.VERSION_15;
- case "16":
- case "16.0":
+ case "16": //$NON-NLS-1$
+ case "16.0": //$NON-NLS-1$
return CompilerOptions.VERSION_16;
default:
return null;
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties
index 90cd0b3f8..bda0c07df 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties
@@ -9,19 +9,19 @@
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
-# IBM Corporation - initial API and implementation
-# Benjamin Muskalla - Contribution for bug 239066
-# Stephan Herrmann - Contributions for
-# bug 236385 - [compiler] Warn for potential programming problem if an object is created but not used
-# bug 295551 - Add option to automatically promote all warnings to errors
-# bug 359721 - [options] add command line option for new warning token "resource"
-# bug 365208 - [compiler][batch] command line options for annotation based null analysis
-# bug 374605 - Unreasonable warning for enum-based switch statements
-# bug 388281 - [compiler][null] inheritance of null annotations as an option
-# bug 440687 - [compiler][batch][null] improve command line option for external annotations
-# Bug 408815 - [batch][null] Add CLI option for COMPILER_PB_SYNTACTIC_NULL_ANALYSIS_FOR_FIELDS
-# Alan Moraes <alan@kelon.org> - Contribution for bug 383644
-# Jesper S Moller - Contribution for bug 407297 - [1.8][compiler] Control generation of parameter names by option
+# IBM Corporation - initial API and implementation
+# Benjamin Muskalla - Contribution for bug 239066
+# Stephan Herrmann - Contributions for
+# bug 236385 - [compiler] Warn for potential programming problem if an object is created but not used
+# bug 295551 - Add option to automatically promote all warnings to errors
+# bug 359721 - [options] add command line option for new warning token "resource"
+# bug 365208 - [compiler][batch] command line options for annotation based null analysis
+# bug 374605 - Unreasonable warning for enum-based switch statements
+# bug 388281 - [compiler][null] inheritance of null annotations as an option
+# bug 440687 - [compiler][batch][null] improve command line option for external annotations
+# Bug 408815 - [batch][null] Add CLI option for COMPILER_PB_SYNTACTIC_NULL_ANALYSIS_FOR_FIELDS
+# Alan Moraes <alan@kelon.org> - Contribution for bug 383644
+# Jesper S Moller - Contribution for bug 407297 - [1.8][compiler] Control generation of parameter names by option
###############################################################################
### JavaBatchCompiler messages.
@@ -230,7 +230,7 @@ misc.usage = {1} {2}\n\
\ --processor-module-path <directories separated by {0}>\n\
\ specify module path where annotation processors\n\
\ can be found\n\
-\ --system <jdk> Override location of system modules\n\
+\ --system <jdk> Override location of system modules\n\
\ --add-exports <module>/<package>=<other-module>(,<other-module>)*\n\
\ specify additional package exports clauses to the\n\
\ given modules\n\
@@ -242,8 +242,7 @@ misc.usage = {1} {2}\n\
\ resolved to be root modules\n\
\ --limit-modules <module>(,<module>)*\n\
\ specify the observable module names\n\
-\ --release <release>\n\
-\ compile for a specific VM version\n\
+\ --release <release> compile for a specific VM version\n\
\ \n\
\ Compliance options:\n\
\ -1.3 use 1.3 compliance (-source 1.3 -target 1.1)\n\
@@ -288,18 +287,18 @@ misc.usage = {1} {2}\n\
\ reported as errors\n\
\ \n\
\ Info options:\n\
-\ -info:<warnings separated by ,> convert exactly the listed warnings\n\
+\ -info:<warnings separated by ,> convert exactly the listed warnings\n\
\ to be reported as infos\n\
-\ -info:+<warnings separated by ,> enable additional warnings to be\n\
+\ -info:+<warnings separated by ,> enable additional warnings to be\n\
\ reported as infos\n\
-\ -info:-<warnings separated by ,> disable specific warnings to be\n\
+\ -info:-<warnings separated by ,> disable specific warnings to be\n\
\ reported as infos\n\
\ \n\
\ Setting warning, error or info options using properties file:\n\
\ -properties <file> set warnings/errors/info option based on the properties\n\
-\ file contents. This option can be used with -nowarn,\n\
-\ -err:.., -info: or -warn:.. options, but the last one\n\
-\ on the command line sets the options to be used.\n\
+\ file contents. This option can be used with -nowarn,\n\
+\ -err:.., -info: or -warn:.. options, but the last one\n\
+\ on the command line sets the options to be used.\n\
\ \n\
\ Debug options:\n\
\ -g[:lines,vars,source] custom debug info\n\
@@ -377,11 +376,11 @@ misc.usage.warn = {1} {2}\n\
\ -deprecation + deprecation outside deprecated code\n\
\ -nowarn -warn:none disable all warnings and infos\n\
\ -nowarn:[<directories separated by {0}>]\n\
-\ specify directories from which optional problems should\n\
-\ be ignored\n\
-\ -warn:<warnings separated by ,> enable exactly the listed warnings\n\
-\ -warn:+<warnings separated by ,> enable additional warnings\n\
-\ -warn:-<warnings separated by ,> disable specific warnings\n\
+\ specify directories from which optional problems\n\
+\ should be ignored\n\
+\ -warn:<warnings separated by ,> enable exactly the listed warnings\n\
+\ -warn:+<warnings separated by ,> enable additional warnings\n\
+\ -warn:-<warnings separated by ,> disable specific warnings\n\
\ abstractrelevantrole + abstract relevant role (OTJLD 2.5(b))\n\
\ adaptDeprecated + adapting a deprecated type/method\n\
\ all enable all warnings\n\
@@ -399,7 +398,7 @@ misc.usage.warn = {1} {2}\n\
\ (OTJLD 2.1.2(b)\n\
\ bindingconventions + discouraged use of import / import base\n\
\ (OTJLD 2.1.2(d))\n\
-\ bindingtosystemclass + trying to bind a role to a system class\n\
+\ bindingtosystemclass + trying to bind a role to a system class\n\
\ boxing autoboxing conversion\n\
\ charConcat + char[] in String concat\n\
\ compareIdentical + comparing identical expressions\n\
@@ -425,7 +424,7 @@ misc.usage.warn = {1} {2}\n\
\ forbidden + use of types matching a forbidden access rule\n\
\ fragilecallin + replace callin not providing expected result\n\
\ (OTJLD 4.3(e))\n\
-\ hashCode missing hashCode() method when overriding equals()\n\
+\ hashCode missing hashCode() method when overriding equals()\n\
\ hiddenLiftingProblem + a lifting that is not directly visible in source\n\
\ code could fail at runtime (OTJLD 2.3.5)\n\
\ hiding macro for fieldHiding, localHiding, typeHiding and\n\
@@ -441,42 +440,45 @@ misc.usage.warn = {1} {2}\n\
\ invalidJavadoc all warnings for malformed javadoc tags\n\
\ invalidJavadocTag validate javadoc tag arguments\n\
\ invalidJavadocTagDep validate deprecated references in javadoc tag args\n\
-\ invalidJavadocTagNotVisible validate non-visible references in javadoc\n\
-\ tag args\n\
-\ invalidJavadocVisibility(<visibility>) specify visibility modifier\n\
-\ for malformed javadoc tag warnings\n\
+\ invalidJavadocTagNotVisible\n\
+\ validate non-visible references in javadoc tag args\n\
+\ invalidJavadocVisibility(<visibility>)\n\
+\ specify visibility modifier for malformed javadoc\n\
+\ tag warnings\n\
\ javadoc invalid javadoc\n\
\ localHiding local variable hiding another variable\n\
\ maskedCatchBlock + hidden catch block\n\
\ missingJavadocTags missing Javadoc tags\n\
\ missingJavadocTagsOverriding missing Javadoc tags in overriding methods\n\
\ missingJavadocTagsMethod missing Javadoc tags for method type parameter\n\
-\ missingJavadocTagsVisibility(<visibility>) specify visibility modifier\n\
-\ for missing javadoc tags warnings\n\
-\ missingJavadocComments missing Javadoc comments\n\
-\ missingJavadocCommentsOverriding missing Javadoc tags in overriding\n\
-\ methods\n\
+\ missingJavadocTagsVisibility(<visibility>)\n\
+\ specify visibility modifier for missing javadoc\n\
+\ tags warnings\n\
+\ missingJavadocComments missing Javadoc comments\n\
+\ missingJavadocCommentsOverriding\n\
+\ missing Javadoc tags in overriding methods\n\
\ missingJavadocCommentsVisibility(<visibility>) specify visibility\n\
-\ modifier for missing javadoc comments warnings\n\
+\ modifier for missing javadoc comments warnings\n\
\ module + module related problems.\n\
\ nls string literal lacking non-nls tag //$NON-NLS-<n>$\n\
\ noEffectAssign + assignment without effect\n\
\ null potential missing or redundant null check\n\
-\ nullAnnot(<annot. names separated by |>) annotation based null analysis,\n\
+\ nullAnnot(<annot. names separated by |>)\n\
+\ annotation based null analysis,\n\
\ nullable|nonnull|nonnullbydefault annotation types\n\
\ optionally specified using fully qualified names.\n\
-\ Enabling this option enables all null-annotation\n\
-\ related sub-options. These can be individually\n\
-\ controlled using options listed below.\n\
+\ Enabling this option enables all null-annotation\n\
+\ related sub-options. These can be individually\n\
+\ controlled using options listed below.\n\
\ nullAnnotConflict conflict between null annotation specified\n\
-\ and nullness inferred. Is effective only with\n\
-\ nullAnnot option enabled.\n\
+\ and nullness inferred. Is effective only with\n\
+\ nullAnnot option enabled.\n\
\ nullAnnotRedundant redundant specification of null annotation. Is\n\
-\ effective only with nullAnnot option enabled.\n\
+\ effective only with nullAnnot option enabled.\n\
\ nullDereference + missing null check\n\
-\ nullUncheckedConversion unchecked conversion from non-annotated type\n\
-\ to @NonNull type. Is effective only with\n\
-\ nullAnnot option enabled.\n\
+\ nullUncheckedConversion unchecked conversion from non-annotated type\n\
+\ to @NonNull type. Is effective only with\n\
+\ nullAnnot option enabled.\n\
\ over-ann missing @Override annotation (superclass)\n\
\ paramAssign assignment to a parameter\n\
\ pkgDefaultMethod + attempt to override package-default method\n\
@@ -501,39 +503,39 @@ misc.usage.warn = {1} {2}\n\
\ syncOverride missing synchronized in synchr. method override\n\
\ syntacticAnalysis perform syntax-based null analysis for fields\n\
\ syntheticAccess synthetic access for innerclass\n\
-\ tasks(<tags separated by |>) tasks identified by tags inside comments\n\
+\ tasks(<tags separated by |>) tasks identified by tags inside comments\n\
\ typeHiding + type parameter hiding another type\n\
-\ unavoidableGenericProblems + ignore unavoidable type safety problems\n\
-\ due to raw APIs\n\
+\ unavoidableGenericProblems + ignore unavoidable type safety problems\n\
+\ due to raw APIs\n\
\ unchecked + unchecked type operation\n\
\ unlikelyCollectionMethodArgumentType\n\
\ + unlikely argument type for collection method\n\
\ declaring an Object parameter\n\
-\ unlikelyEqualsArgumentType unlikely argument type for method equals()\n\
+\ unlikelyEqualsArgumentType unlikely argument type for method equals()\n\
\ unnecessaryElse unnecessary else clause\n\
\ unqualifiedField unqualified reference to field\n\
\ unused macro for unusedAllocation, unusedArgument,\n\
-\ unusedImport, unusedLabel, unusedLocal,\n\
-\ unusedPrivate, unusedThrown, and unusedTypeArgs,\n\
-\ unusedExceptionParam\n\
+\ unusedImport, unusedLabel, unusedLocal,\n\
+\ unusedPrivate, unusedThrown, and unusedTypeArgs,\n\
+\ unusedExceptionParam\n\
\ unusedAllocation allocating an object that is not used\n\
\ unusedArgument unread method parameter\n\
\ unusedExceptionParam unread exception parameter\n\
\ unusedImport + unused import declaration\n\
\ unusedLabel + unused label\n\
\ unusedLocal + unread local variable\n\
-\ unusedParam unused parameter\n\
-\ unusedParamOverriding unused parameter for overriding method\n\
-\ unusedParamImplementing unused parameter for implementing method\n\
-\ unusedParamIncludeDoc unused parameter documented in comment tag\n\
+\ unusedParam unused parameter\n\
+\ unusedParamOverriding unused parameter for overriding method\n\
+\ unusedParamImplementing unused parameter for implementing method\n\
+\ unusedParamIncludeDoc unused parameter documented in comment tag\n\
\ unusedPrivate + unused private member declaration\n\
\ unusedThrown unused declared thrown exception\n\
-\ unusedThrownWhenOverriding unused declared thrown exception in \n\
-\ overriding method\n\
-\ unusedThrownIncludeDocComment unused declared thrown exception,\n\
-\ documented in a comment tag\n\
+\ unusedThrownWhenOverriding unused declared thrown exception in \n\
+\ overriding method\n\
+\ unusedThrownIncludeDocComment unused declared thrown exception,\n\
+\ documented in a comment tag\n\
\ unusedThrownExemptExceptionThrowable unused declared thrown exception,\n\
-\ exempt Exception and Throwable\n\
+\ exempt Exception and Throwable\n\
\ unusedTypeArgs + unused type arguments for method and constructor\n\
\ uselessTypeCheck unnecessary cast/instanceof operation\n\
\ varargsCast + varargs argument need explicit cast\n\
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 1cfb61378..80b427441 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
@@ -4315,8 +4315,8 @@ protected void consumeSwitchLabeledBlock() {
protected int fetchNextToken() throws InvalidInputException {
int token = this.scanner.getNextToken();
if (!this.diet && token != TerminalTokens.TokenNameEOF) {
- if (!requireExtendedRecovery() && this.expressionPtr == -1) {
- if (this.scanner.currentPosition > this.cursorLocation) {
+ if (!requireExtendedRecovery() && this.scanner.currentPosition > this.cursorLocation) {
+ if (!hasPendingExpression(token)) {
this.scanner.eofPosition = this.cursorLocation + 1; // revert to old strategy where we stop parsing right at the cursor
// stop immediately or deferred?
@@ -4331,6 +4331,26 @@ protected int fetchNextToken() throws InvalidInputException {
}
return token;
}
+private boolean hasPendingExpression(int token) {
+ if (this.expressionPtr == -1)
+ return false;
+ if (token == TerminalTokens.TokenNameDOT) {
+ // at '.' we are more eager to send early EOF to avoid seeing a qualified type reference in this pattern:
+ // foo.|
+ // bar ...
+ Expression expression = this.expressionStack[this.expressionPtr];
+ int elPtr = this.elementPtr;
+ while (elPtr >= 0) {
+ if (this.elementKindStack[elPtr] == K_BLOCK_DELIMITER) {
+ if (this.elementObjectInfoStack[elPtr] == expression) {
+ return false; // top expr on expressionStack belongs to a block statement (e.g., an if-condition)
+ }
+ }
+ elPtr--;
+ }
+ }
+ return true;
+}
@Override
protected void consumeToken(int token) {
if(this.isFirst) {
@@ -4611,10 +4631,19 @@ protected void consumeToken(int token) {
if (kind == K_CONTROL_STATEMENT_DELIMITER) {
int info = topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER);
popElement(K_CONTROL_STATEMENT_DELIMITER);
- if (info == IF) {
- pushOnElementStack(K_BLOCK_DELIMITER, IF, this.expressionStack[this.expressionPtr]);
- } else {
- pushOnElementStack(K_BLOCK_DELIMITER, info);
+ switch (info) {
+ case IF:
+ // include top-expression of these just for the benefit of hasPendingExpression():
+ // (TRY is not included, even Java9-t-w-r doesn't own an *expression*)
+ case FOR:
+ case WHILE:
+ if (this.expressionPtr > -1) {
+ pushOnElementStack(K_BLOCK_DELIMITER, info, this.expressionStack[this.expressionPtr]);
+ break;
+ }
+ //$FALL-THROUGH$
+ default:
+ pushOnElementStack(K_BLOCK_DELIMITER, info);
}
} else {
switch(previous) {
@@ -5755,11 +5784,61 @@ protected TypeReference getTypeReferenceForGenericType(int dim, int identifierLe
}
@Override
protected NameReference getUnspecifiedReference(boolean rejectTypeAnnotations) {
- NameReference nameReference = super.getUnspecifiedReference(rejectTypeAnnotations);
+ // code copied from super, but conditionally creating CompletionOn* nodes:
+
+ /* build a (unspecified) NameReference which may be qualified*/
+ if (rejectTypeAnnotations) { // Compensate for overpermissive grammar.
+ consumeNonTypeUseName();
+ }
+ int length;
+ NameReference ref;
+ if ((length = this.identifierLengthStack[this.identifierLengthPtr--]) == 1) {
+ // single variable reference
+ char[] token = this.identifierStack[this.identifierPtr];
+ long position = this.identifierPositionStack[this.identifierPtr--];
+ int start = (int) (position >>> 32), end = (int) position;
+ if (this.assistNode == null && start < this.cursorLocation && end >= this.cursorLocation) {
+ ref = new CompletionOnSingleNameReference(token, position, isInsideAttributeValue());
+ this.assistNode = ref;
+ } else {
+ ref = new SingleNameReference(token, position);
+ }
+ } else {
+ //Qualified variable reference
+ char[][] tokens = new char[length][];
+ this.identifierPtr -= length;
+ System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
+ long[] positions = new long[length];
+ System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
+ int start = (int) (positions[0] >>> 32), end = (int) positions[length-1];
+ if (this.assistNode == null && start < this.cursorLocation && end >= this.cursorLocation) {
+ // find the token at cursorLocation:
+ int previousCount = 0;
+ for (int i=0; i<length; i++) {
+ if (((int) positions[i]) < this.cursorLocation)
+ previousCount = i + 1;
+ }
+ if (previousCount > 0) {
+ char[][] subset = new char[previousCount][];
+ System.arraycopy(tokens, 0, subset, 0, previousCount);
+ ref = new CompletionOnQualifiedNameReference(subset, tokens[previousCount], positions, isInsideAttributeValue());
+ } else {
+ // with only one token up-to cursorLocation avoid a bogus qualifiedNameReference (simply skipping the remainder):
+ ref = new CompletionOnSingleNameReference(tokens[0], positions[0], isInsideAttributeValue());
+ }
+ this.assistNode = ref;
+ } else {
+ ref =
+ new QualifiedNameReference(tokens,
+ positions,
+ (int) (this.identifierPositionStack[this.identifierPtr + 1] >> 32), // sourceStart
+ (int) this.identifierPositionStack[this.identifierPtr + length]); // sourceEnd
+ }
+ }
if (this.record) {
- recordReference(nameReference);
+ recordReference(ref);
}
- return nameReference;
+ return ref;
}
@Override
protected void consumePostfixExpression() {
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java
index 40d0007cc..3027f01fd 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2019 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -361,6 +361,10 @@ public RecoveredElement buildInitialRecoveryState(){
} else if ((stmt instanceof ForeachStatement) && ((ForeachStatement) stmt).action == null) {
element = element.add(stmt, 0);
this.lastCheckPoint = stmt.sourceEnd + 1;
+ } else if (stmt.containsPatternVariable()) {
+ element.add(stmt, 0);
+ this.lastCheckPoint = stmt.sourceEnd + 1;
+ this.isOrphanCompletionNode = false;
}
}
continue;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java
index eec972aa2..ae65c4250 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2020 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -841,6 +841,10 @@ public void checkTypeArgumentRedundancy(ParameterizedTypeBinding allocationType,
if (TypeBinding.notEquals(inferredTypes[i], allocationType.arguments[i]))
return;
}
+ reportTypeArgumentRedundancyProblem(allocationType, scope);
+}
+
+protected void reportTypeArgumentRedundancyProblem(ParameterizedTypeBinding allocationType, final BlockScope scope) {
scope.problemReporter().redundantSpecificationOfTypeArguments(this.type, allocationType.arguments);
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DoStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DoStatement.java
index 2a8217732..8bd10b461 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DoStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DoStatement.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2020 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -227,14 +227,14 @@ public StringBuffer printStatement(int indent, StringBuffer output) {
@Override
public void resolve(BlockScope scope) {
- if (this.condition.containsPatternVariable()) {
+ if (containsPatternVariable()) {
this.condition.collectPatternVariablesToScope(null, scope);
LocalVariableBinding[] patternVariablesInFalseScope = this.condition.getPatternVariablesWhenFalse();
TypeBinding type = this.condition.resolveTypeExpecting(scope, TypeBinding.BOOLEAN);
this.condition.computeConversion(scope, type, type);
if (this.action != null) {
this.action.resolve(scope);
- this.action.promotePatternVariablesIfApplicable(patternVariablesInFalseScope,
+ this.action.promotePatternVariablesIfApplicable(patternVariablesInFalseScope,
() -> !this.action.breaksOut(null));
}
} else {
@@ -246,6 +246,10 @@ public void resolve(BlockScope scope) {
}
@Override
+public boolean containsPatternVariable() {
+ return this.condition.containsPatternVariable();
+}
+@Override
public void traverse(ASTVisitor visitor, BlockScope scope) {
if (visitor.visit(this, scope)) {
if (this.action != null) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java
index 19ddff8ca..5e846512e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java
@@ -984,9 +984,6 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean
public void addPatternVariables(BlockScope scope, CodeStream codeStream) {
// Nothing by default
}
-public boolean containsPatternVariable() {
- return false;
-}
protected LocalDeclaration getPatternVariableIntroduced() {
return null;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java
index 39cd4a105..e5fb611b7 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2020 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -271,7 +271,7 @@ public class ForStatement extends Statement {
this.initializations[i].generateCode(this.scope, codeStream);
}
}
- if (this.condition != null && this.condition.containsPatternVariable()) {
+ if (containsPatternVariable()) {
this.condition.addPatternVariables(currentScope, codeStream);
}
Constant cst = this.condition == null ? null : this.condition.optimizedBooleanConstant();
@@ -412,7 +412,7 @@ public class ForStatement extends Statement {
LocalVariableBinding[] patternVariablesInTrueScope = null;
LocalVariableBinding[] patternVariablesInFalseScope = null;
- if (this.condition != null && this.condition.containsPatternVariable()) {
+ if (containsPatternVariable()) {
this.condition.collectPatternVariablesToScope(null, upperScope);
patternVariablesInTrueScope = this.condition.getPatternVariablesWhenTrue();
patternVariablesInFalseScope = this.condition.getPatternVariablesWhenFalse();
@@ -442,6 +442,11 @@ public class ForStatement extends Statement {
}
@Override
+ public boolean containsPatternVariable() {
+ return this.condition != null && this.condition.containsPatternVariable();
+ }
+
+ @Override
public void traverse(
ASTVisitor visitor,
BlockScope blockScope) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java
index 56d12f79d..9eff87b2a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2020 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -288,7 +288,7 @@ private void resolveIfStatement(BlockScope scope) {
}
@Override
public void resolve(BlockScope scope) {
- if (this.condition.containsPatternVariable()) {
+ if (containsPatternVariable()) {
this.condition.collectPatternVariablesToScope(null, scope);
LocalVariableBinding[] patternVariablesInTrueScope = this.condition.getPatternVariablesWhenTrue();
LocalVariableBinding[] patternVariablesInFalseScope = this.condition.getPatternVariablesWhenFalse();
@@ -313,6 +313,11 @@ public void resolve(BlockScope scope) {
}
@Override
+public boolean containsPatternVariable() {
+ return this.condition.containsPatternVariable();
+}
+
+@Override
public void traverse(ASTVisitor visitor, BlockScope blockScope) {
if (visitor.visit(this, blockScope)) {
this.condition.traverse(visitor, blockScope);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NullAnnotationMatching.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NullAnnotationMatching.java
index 6a7c7101c..e05a54c8f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NullAnnotationMatching.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NullAnnotationMatching.java
@@ -793,16 +793,15 @@ public class NullAnnotationMatching {
return mainType;
}
- @SuppressWarnings("nls")
@Override
public String toString() {
- if (this == NULL_ANNOTATIONS_OK) return "OK";
- if (this == NULL_ANNOTATIONS_MISMATCH) return "MISMATCH";
- if (this == NULL_ANNOTATIONS_OK_NONNULL) return "OK NonNull";
- if (this == NULL_ANNOTATIONS_UNCHECKED) return "UNCHECKED";
+ if (this == NULL_ANNOTATIONS_OK) return "OK"; //$NON-NLS-1$
+ if (this == NULL_ANNOTATIONS_MISMATCH) return "MISMATCH"; //$NON-NLS-1$
+ if (this == NULL_ANNOTATIONS_OK_NONNULL) return "OK NonNull"; //$NON-NLS-1$
+ if (this == NULL_ANNOTATIONS_UNCHECKED) return "UNCHECKED"; //$NON-NLS-1$
StringBuilder buf = new StringBuilder();
- buf.append("Analysis result: severity="+this.severity);
- buf.append(" nullStatus="+this.nullStatus);
+ buf.append("Analysis result: severity="+this.severity); //$NON-NLS-1$
+ buf.append(" nullStatus="+this.nullStatus); //$NON-NLS-1$
return buf.toString();
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java
index 17f14a4fc..35c7b9a1c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2020 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -941,4 +941,23 @@ public class QualifiedAllocationExpression extends AllocationExpression {
}
visitor.endVisit(this, scope);
}
+ @Override
+ protected void reportTypeArgumentRedundancyProblem(ParameterizedTypeBinding allocationType, final BlockScope scope) {
+ if (checkDiamondOperatorCanbeRemoved(scope)) {
+ scope.problemReporter().redundantSpecificationOfTypeArguments(this.type, allocationType.arguments);
+ }
+ }
+ private boolean checkDiamondOperatorCanbeRemoved(final BlockScope scope) {
+ if (this.anonymousType != null &&
+ this.anonymousType.methods != null &&
+ this.anonymousType.methods.length > 0) {
+ //diamond operator is allowed for anonymous types only from java 9
+ if (scope.compilerOptions().complianceLevel < ClassFileConstants.JDK9) return false;
+ for (AbstractMethodDeclaration method : this.anonymousType.methods) {
+ if ( method.binding != null && (method.binding.modifiers & ExtraCompilerModifiers.AccOverriding) == 0)
+ return false;
+ }
+ }
+ return true;
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java
index 41d20a0ee..0c13cbd1f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2020 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -606,6 +606,9 @@ public Constant[] resolveCase(BlockScope scope, TypeBinding testType, SwitchStat
public TypeBinding resolveExpressionType(BlockScope scope) {
return null;
}
+public boolean containsPatternVariable() {
+ return false;
+}
/**
* Implementation of {@link org.eclipse.jdt.internal.compiler.lookup.InvocationSite#invocationTargetType}
* suitable at this level. Subclasses should override as necessary.
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java
index 028c1f65a..f816d5ad6 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2020 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -192,7 +192,7 @@ public class WhileStatement extends Statement {
if ((this.bits & IsReachable) == 0) {
return;
}
- if (this.condition != null && this.condition.containsPatternVariable()) {
+ if (containsPatternVariable()) {
this.condition.addPatternVariables(currentScope, codeStream);
}
int pc = codeStream.position;
@@ -275,7 +275,7 @@ public class WhileStatement extends Statement {
@Override
public void resolve(BlockScope scope) {
- if (this.condition.containsPatternVariable()) {
+ if (containsPatternVariable()) {
this.condition.collectPatternVariablesToScope(null, scope);
LocalVariableBinding[] patternVariablesInTrueScope = this.condition.getPatternVariablesWhenTrue();
LocalVariableBinding[] patternVariablesInFalseScope = this.condition.getPatternVariablesWhenFalse();
@@ -297,6 +297,11 @@ public class WhileStatement extends Statement {
}
@Override
+ public boolean containsPatternVariable() {
+ return this.condition != null && this.condition.containsPatternVariable();
+ }
+
+ @Override
public StringBuffer printStatement(int tab, StringBuffer output) {
printIndent(tab, output).append("while ("); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java
index 4db95b58d..c00d78a11 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java
@@ -46,6 +46,8 @@
* Bug 412153 - [1.8][compiler] Check validity of annotations which may be repeatable
* Sebastian Zarnekow - Contributions for
* bug 544921 - [performance] Poor performance with large source files
+ * Alexander Lehmann - Contributions for
+ * bug 566258 - Intermittent NPE in APT RoundDispatcher
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
@@ -2102,10 +2104,9 @@ public ReferenceBinding[] memberTypes() {
* is sorted, too.
*/
ReferenceBinding [] members = this.prototype.memberTypes();
- int memberTypesLength = members == null ? 0 : members.length;
- if (memberTypesLength > 0) {
- this.memberTypes = new ReferenceBinding[memberTypesLength];
- for (int i = 0; i < memberTypesLength; i++)
+ if (members != null) {
+ this.memberTypes = new ReferenceBinding[members.length];
+ for (int i = 0; i < members.length; i++)
this.memberTypes[i] = this.environment.createMemberType(members[i], this);
}
this.tagBits &= ~TagBits.HasUnresolvedMemberTypes;
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 79c99526e..20ab6bfaf 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, 2019 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -633,4 +633,20 @@ public class CaptureBinding extends TypeVariableBinding {
}
}
// SH}
+
+
+ @Override
+ public char[] signature() /* Ljava/lang/Object; */ {
+ if (this.signature != null)
+ return this.signature;
+
+ if (this.firstBound instanceof ArrayBinding) {
+ this.signature = constantPoolName();
+ } else {
+ this.signature = CharOperation.concat('L', constantPoolName(), ';');
+ }
+ return this.signature;
+
+ }
+
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
index 8230a7379..b841290e2 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2020 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -2532,9 +2532,9 @@ public class ClassScope extends Scope {
environment().typesBeingConnected.add(sourceType);
boolean noProblems = connectSuperclass();
noProblems &= connectSuperInterfaces();
- connectPermittedTypes();
environment().typesBeingConnected.remove(sourceType);
sourceType.tagBits |= TagBits.EndHierarchyCheck;
+ connectPermittedTypes();
noProblems &= connectTypeVariables(this.referenceContext.typeParameters, false);
sourceType.tagBits |= TagBits.TypeVariablesAreConnected;
if (noProblems && sourceType.isHierarchyInconsistent())
@@ -2613,9 +2613,9 @@ public class ClassScope extends Scope {
environment().typesBeingConnected.add(sourceType);
boolean noProblems = connectSuperclass();
noProblems &= connectSuperInterfaces();
- connectPermittedTypes();
environment().typesBeingConnected.remove(sourceType);
sourceType.tagBits |= TagBits.EndHierarchyCheck;
+ connectPermittedTypes();
noProblems &= connectTypeVariables(this.referenceContext.typeParameters, false);
sourceType.tagBits |= TagBits.TypeVariablesAreConnected;
if (noProblems && sourceType.isHierarchyInconsistent())
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java
index a145a4763..d3bc31cb9 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java
@@ -65,7 +65,6 @@ public class ModuleBinding extends Binding implements IUpdatableModule {
private static final char[] UNNAMED_READABLE_NAME = "<unnamed>".toCharArray(); //$NON-NLS-1$
- @SuppressWarnings("synthetic-access")
UnNamedModule(LookupEnvironment env) {
super(env);
}
@@ -167,7 +166,7 @@ public class ModuleBinding extends Binding implements IUpdatableModule {
public HashtableOfPackage<PlainPackageBinding> declaredPackages;
/** Constructor for the unnamed module. */
- private ModuleBinding(LookupEnvironment env) {
+ ModuleBinding(LookupEnvironment env) {
this.moduleName = ModuleBinding.UNNAMED;
this.environment = env;
this.requires = Binding.NO_MODULES;
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 c6879b9b0..a2ebd5771 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
@@ -3464,7 +3464,9 @@ class ASTConverter {
if (this.resolveBindings) {
this.recordNodes(literal, expression);
}
- literal.internalSetEscapedValue(new String(this.compilationUnitSource, sourceStart, length));
+ literal.internalSetEscapedValue(
+ new String(this.compilationUnitSource, sourceStart, length),
+ new String(expression.source()));
literal.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
return literal;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TextBlock.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TextBlock.java
index 4cc1d2c39..9fa324602 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TextBlock.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TextBlock.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2019, 2020 IBM Corporation and others.
+ * Copyright (c) 2019, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -76,6 +76,12 @@ public class TextBlock extends Expression {
private String escapedValue = "\"\"";//$NON-NLS-1$
/**
+ * The literal string without the quotes and the applicable preceding and
+ * trailing whitespace if any ; defaults to empty string.
+ */
+ private String literalValue = "";//$NON-NLS-1$
+
+ /**
* Creates a new unparented TextBlock node owned by the given AST.
* By default, the TextBlock denotes the empty string.
* <p>
@@ -190,14 +196,15 @@ public class TextBlock extends Expression {
}
/* (omit javadoc for this method)
- * This method is a copy of setEscapedValue(String) that doesn't do any validation.
+ * This method is does what setEscapedValue(String) does but without any validation.
+ * In addition, it also sets the literalValue property.
*/
- void internalSetEscapedValue(String token) {
+ void internalSetEscapedValue(String token, String literal) {
preValueChange(ESCAPED_VALUE_PROPERTY);
this.escapedValue = token;
+ this.literalValue = literal;
postValueChange(ESCAPED_VALUE_PROPERTY);
}
-
/**
* Returns the value of this literal node.
* <p>
@@ -217,6 +224,9 @@ public class TextBlock extends Expression {
* @since 3.24
*/
public String getLiteralValue() {
+ if (!this.literalValue.isEmpty()) {
+ return this.literalValue;
+ }
char[] escaped = getEscapedValue().toCharArray();
int len = escaped.length;
if (len < 7) {
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/util/DOMASTUtil.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/util/DOMASTUtil.java
index 3d45d3c96..e0180f144 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/util/DOMASTUtil.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/util/DOMASTUtil.java
@@ -148,23 +148,16 @@ public class DOMASTUtil {
@SuppressWarnings("deprecation")
public static void checkASTLevel(int level) {
+ // Clients can use AST.JLS_Latest
+ if(level >=AST.JLS8 && level <= AST.JLS_Latest )
+ return;
switch (level) {
case AST.JLS2 :
case AST.JLS3 :
case AST.JLS4 :
- case AST.JLS8 :
- case AST.JLS9 :
- case AST.JLS10 :
- case AST.JLS11 :
- case AST.JLS12 :
- case AST.JLS13 :
- case AST.JLS14 :
- case AST.JLS15 :
- case AST.JLS16 :
return;
}
- throw new IllegalArgumentException();
-
+ throw new IllegalArgumentException(Integer.toString(level));
}
}
diff --git a/org.eclipse.jdt.core/forceQualifierUpdate.txt b/org.eclipse.jdt.core/forceQualifierUpdate.txt
index c044c2e8c..bc9b99d25 100644
--- a/org.eclipse.jdt.core/forceQualifierUpdate.txt
+++ b/org.eclipse.jdt.core/forceQualifierUpdate.txt
@@ -3,4 +3,5 @@ Bug 418646 - org.eclipse.jdt.core does not provide an artifact with classifier '
Bug 436266 - Use RC3 (plus) version of JDT compiler to build RC4
Bug 551547 - The library org.eclipse.jdt.core.compiler.batch_*.jar should be signed
Bug 549687 - Local ecj build has a SHA-256 digest error for org/eclipse/jdt/internal/compiler/apt/model/PackageElementImpl.class
-Bug 566471 - I20200828-0150 - Comparator Errors Found \ No newline at end of file
+Bug 566471 - I20200828-0150 - Comparator Errors Found
+Bug 573283 - don't include javax15api.jar in jdt binaries \ No newline at end of file
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java
index 05f9fe301..69efe66f8 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2020 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -203,6 +203,7 @@ public abstract class JavaElement extends PlatformObject implements IJavaElement
for (int i = 0, length = mementoName.length(); i < length; i++) {
char character = mementoName.charAt(i);
switch (character) {
+ case JEM_MODULE:
case JEM_ESCAPE:
case JEM_COUNT:
case JEM_JAVAPROJECT:
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/MementoTokenizer.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/MementoTokenizer.java
index 4b376f010..efab1e6e6 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/MementoTokenizer.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/MementoTokenizer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2018 IBM Corporation and others.
+ * Copyright (c) 2004, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -127,8 +127,6 @@ public class MementoTokenizer {
if (buffer == null) buffer = new StringBuffer();
buffer.append(this.memento, start, this.index - start);
start = ++this.index;
- if (this.memento[this.index] == JavaElement.JEM_MODULE)
- return buffer.toString();
break;
case JavaElement.JEM_COUNT:
case JavaElement.JEM_JAVAPROJECT:
diff --git a/org.eclipse.jdt.core/pom.xml b/org.eclipse.jdt.core/pom.xml
index f6d8ab215..6c1ba3cf9 100644
--- a/org.eclipse.jdt.core/pom.xml
+++ b/org.eclipse.jdt.core/pom.xml
@@ -227,6 +227,69 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>3.2.0</version>
+ <executions>
+ <!--
+ Replace '\' Windows file separators by '/' in order to expand the new property 'compiler-message-properties'
+ into a string literal in Maven Enforcer rule 'evaluateBeanshell' further below
+ -->
+ <execution>
+ <id>compiler-message-properties</id>
+ <goals>
+ <goal>regex-property</goal>
+ </goals>
+ <configuration>
+ <name>compiler-message-properties</name>
+ <value>${project.basedir}/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties</value>
+ <regex>\\</regex>
+ <replacement>/</replacement>
+ <failIfNoMatch>false</failIfNoMatch>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>no-tabs-in-compiler-messages</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <evaluateBeanshell>
+ <message>
+ Compiler message resource file ${compiler-message-properties} must not contain tab characters, please use spaces instead!
+ </message>
+ <condition><![CDATA[
+ FileReader fileReader = new FileReader("${compiler-message-properties}");
+ BufferedReader bufferReader = new BufferedReader(fileReader);
+ boolean containsTab = false;
+ String line;
+ while((line = bufferReader.readLine()) != null) {
+ if (line.contains("\t")) {
+ if (!containsTab) {
+ System.out.println("Lines containing tab characters detected in resource file:");
+ containsTab = true;
+ }
+ System.out.println(line);
+ }
+ }
+ fileReader.close();
+ bufferReader.close();
+ !containsTab
+ ]]></condition>
+ </evaluateBeanshell>
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
</project>
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchPattern.java
index 9530fbf46..f8255fdeb 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchPattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchPattern.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2020 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -19,8 +19,19 @@ import java.util.regex.Pattern;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.jdt.core.*;
-import org.eclipse.jdt.core.compiler.*;
+import org.eclipse.jdt.core.Flags;
+import org.eclipse.jdt.core.IField;
+import org.eclipse.jdt.core.IImportDeclaration;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IModularClassFile;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.ITypeParameter;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.Signature;
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.core.compiler.InvalidInputException;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.env.AccessRuleSet;
import org.eclipse.jdt.internal.compiler.parser.Scanner;
@@ -34,7 +45,21 @@ import org.eclipse.jdt.internal.core.search.IndexQueryRequestor;
import org.eclipse.jdt.internal.core.search.JavaSearchScope;
import org.eclipse.jdt.internal.core.search.StringOperation;
import org.eclipse.jdt.internal.core.search.indexing.IIndexConstants;
-import org.eclipse.jdt.internal.core.search.matching.*;
+import org.eclipse.jdt.internal.core.search.matching.AndPattern;
+import org.eclipse.jdt.internal.core.search.matching.ConstructorPattern;
+import org.eclipse.jdt.internal.core.search.matching.FieldPattern;
+import org.eclipse.jdt.internal.core.search.matching.LocalVariablePattern;
+import org.eclipse.jdt.internal.core.search.matching.MatchLocator;
+import org.eclipse.jdt.internal.core.search.matching.MethodPattern;
+import org.eclipse.jdt.internal.core.search.matching.ModulePattern;
+import org.eclipse.jdt.internal.core.search.matching.OrPattern;
+import org.eclipse.jdt.internal.core.search.matching.PackageDeclarationPattern;
+import org.eclipse.jdt.internal.core.search.matching.PackageReferencePattern;
+import org.eclipse.jdt.internal.core.search.matching.QualifiedTypeDeclarationPattern;
+import org.eclipse.jdt.internal.core.search.matching.SuperTypeReferencePattern;
+import org.eclipse.jdt.internal.core.search.matching.TypeDeclarationPattern;
+import org.eclipse.jdt.internal.core.search.matching.TypeParameterPattern;
+import org.eclipse.jdt.internal.core.search.matching.TypeReferencePattern;
import org.eclipse.objectteams.otdt.core.IOTJavaElement;
import org.eclipse.objectteams.otdt.internal.core.AbstractCalloutMapping;
import org.eclipse.objectteams.otdt.internal.core.CalloutMapping;
@@ -2036,6 +2061,28 @@ public static SearchPattern createPattern(IJavaElement element, int limitTo, int
typeSignature,
limitTo,
matchRule);
+
+ //If field is record's component, create a OR pattern comprising of record's component and its accessor methods
+ IType declaringType = field.getDeclaringType();
+ try {
+ if( declaringType.isRecord()){
+ MethodPattern accessorMethodPattern = new MethodPattern(name,
+ declaringQualification,
+ declaringSimpleName,
+ typeQualification,
+ typeSimpleName,
+ null,
+ null,
+ field.getDeclaringType(),
+ limitTo,
+ matchRule);
+
+ searchPattern= new OrPattern(searchPattern,accessorMethodPattern);
+ }
+ } catch (JavaModelException e1) {
+ // continue with previous searchPattern
+ }
+
break;
case IJavaElement.IMPORT_DECLARATION :
String elementName = element.getElementName();
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/Nd.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/Nd.java
index 13f027630..30aa62f34 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/Nd.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/Nd.java
@@ -361,12 +361,11 @@ public final class Nd {
releaseWriteLock(0, false);
}
- @SuppressWarnings("nls")
public void releaseWriteLock(int establishReadLocks, boolean flush) {
synchronized (this.mutex) {
Thread current = Thread.currentThread();
if (current != this.writeLockOwner) {
- throw new IllegalStateException("Index wasn't locked by this thread!!!");
+ throw new IllegalStateException("Index wasn't locked by this thread!!!"); //$NON-NLS-1$
}
this.writeLockOwner = null;
}
@@ -511,13 +510,12 @@ public final class Nd {
return this.fTraces.size();
}
- @SuppressWarnings("nls")
public void write(String threadName) {
- System.out.println("Thread: '" + threadName + "': " + this.fReadLocks + " readlocks, " + this.fWriteLocks + " writelocks");
+ System.out.println("Thread: '" + threadName + "': " + this.fReadLocks + " readlocks, " + this.fWriteLocks + " writelocks"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
for (StackTraceElement[] trace : this.fTraces) {
- System.out.println(" Stacktrace:");
+ System.out.println(" Stacktrace:"); //$NON-NLS-1$
for (StackTraceElement ste : trace) {
- System.out.println(" " + ste);
+ System.out.println(" " + ste); //$NON-NLS-1$
}
}
}
@@ -555,16 +553,15 @@ public final class Nd {
}
// For debugging lock issues
- @SuppressWarnings("nls")
static void decReadLock(Map<Thread, DebugLockInfo> lockDebugging) throws AssertionError {
DebugLockInfo info = getLockInfo(lockDebugging);
if (info.fReadLocks <= 0) {
outputReadLocks(lockDebugging);
- throw new AssertionError("Superfluous releaseReadLock");
+ throw new AssertionError("Superfluous releaseReadLock"); //$NON-NLS-1$
}
if (info.fWriteLocks != 0) {
outputReadLocks(lockDebugging);
- throw new AssertionError("Releasing readlock while holding write lock");
+ throw new AssertionError("Releasing readlock while holding write lock"); //$NON-NLS-1$
}
if (--info.fReadLocks == 0) {
lockDebugging.remove(Thread.currentThread());
@@ -574,15 +571,14 @@ public final class Nd {
}
// For debugging lock issues
- @SuppressWarnings("nls")
private void incWriteLock(int giveupReadLocks) throws AssertionError {
DebugLockInfo info = getLockInfo(this.fLockDebugging);
if (info.fReadLocks != giveupReadLocks) {
outputReadLocks(this.fLockDebugging);
- throw new AssertionError("write lock with " + giveupReadLocks + " readlocks, expected " + info.fReadLocks);
+ throw new AssertionError("write lock with " + giveupReadLocks + " readlocks, expected " + info.fReadLocks); //$NON-NLS-1$ //$NON-NLS-2$
}
if (info.fWriteLocks != 0)
- throw new AssertionError("Duplicate write lock");
+ throw new AssertionError("Duplicate write lock"); //$NON-NLS-1$
info.fWriteLocks++;
}
@@ -600,13 +596,12 @@ public final class Nd {
}
// For debugging lock issues
- @SuppressWarnings("nls")
private long reportBlockedWriteLock(long start, int giveupReadLocks) {
long now= System.currentTimeMillis();
if (now >= start + BLOCKED_WRITE_LOCK_OUTPUT_INTERVAL) {
System.out.println();
- System.out.println("Blocked writeLock");
- System.out.println(" lockcount= " + this.lockCount + ", giveupReadLocks=" + giveupReadLocks + ", waitingReaders=" + this.waitingReaders);
+ System.out.println("Blocked writeLock"); //$NON-NLS-1$
+ System.out.println(" lockcount= " + this.lockCount + ", giveupReadLocks=" + giveupReadLocks + ", waitingReaders=" + this.waitingReaders); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
outputReadLocks(this.fLockDebugging);
start= now;
}
@@ -614,14 +609,13 @@ public final class Nd {
}
// For debugging lock issues
- @SuppressWarnings("nls")
private static void outputReadLocks(Map<Thread, DebugLockInfo> lockDebugging) {
- System.out.println("--------------------- Lock Debugging -------------------------");
+ System.out.println("--------------------- Lock Debugging -------------------------"); //$NON-NLS-1$
for (Thread th: lockDebugging.keySet()) {
DebugLockInfo info = lockDebugging.get(th);
info.write(th.getName());
}
- System.out.println("---------------------------------------------------------------");
+ System.out.println("---------------------------------------------------------------"); //$NON-NLS-1$
}
// For debugging lock issues
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/RawGrowableArray.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/RawGrowableArray.java
index e3ed5c94c..b2c488cdc 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/RawGrowableArray.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/RawGrowableArray.java
@@ -113,7 +113,7 @@ public final class RawGrowableArray {
ARRAY_HEADER_BYTES = type.size();
}
- private static class GrowableBlockHeader {
+ static class GrowableBlockHeader {
public static final FieldInt ARRAY_SIZE;
public static final FieldInt ALLOCATED_SIZE;
public static final int GROWABLE_BLOCK_HEADER_BYTES;
@@ -134,10 +134,13 @@ public final class RawGrowableArray {
MAX_GROWABLE_SIZE = (Database.MAX_SINGLE_BLOCK_MALLOC_SIZE - GROWABLE_BLOCK_HEADER_BYTES)
/ Database.PTR_SIZE;
}
+
+ static StructDef<GrowableBlockHeader> getType() {
+ return type;
+ }
}
- @SuppressWarnings("synthetic-access")
- private static final class MetaBlockHeader extends GrowableBlockHeader {
+ static final class MetaBlockHeader extends GrowableBlockHeader {
/**
* Holds the number of pages used for the metablock. Note that the start of the metablock array needs to be
* 4-byte aligned. Since all malloc calls are always 2 bytes away from 4-byte alignment, we need to use at
@@ -149,7 +152,7 @@ public final class RawGrowableArray {
private static final StructDef<MetaBlockHeader> type;
static {
- type = StructDef.createAbstract(MetaBlockHeader.class, GrowableBlockHeader.type);
+ type = StructDef.createAbstract(MetaBlockHeader.class, GrowableBlockHeader.getType());
METABLOCK_NUM_PAGES = type.addShort();
type.done();
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/util/CharArrayMap.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/util/CharArrayMap.java
index c46beafbd..74a64e37b 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/util/CharArrayMap.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/util/CharArrayMap.java
@@ -104,11 +104,10 @@ public final class CharArrayMap<V> {
return result;
}
- @SuppressWarnings("nls")
@Override
public String toString() {
String slice = new String(this.buffer, this.start, this.length);
- return "'" + slice + "'@(" + this.start + "," + this.length + ")";
+ return "'" + slice + "'@(" + this.start + "," + this.length + ")"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java
index b52e8a86a..db99ce239 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2020 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -1785,6 +1785,8 @@ protected IType lookupType(ReferenceBinding typeBinding) {
acceptFlag = NameLookup.ACCEPT_ENUMS;
} else if (typeBinding.isInterface()) {
acceptFlag = NameLookup.ACCEPT_INTERFACES;
+ } else if (typeBinding.isRecord()) {
+ acceptFlag = NameLookup.ACCEPT_RECORDS;
} else if (typeBinding.isClass()) {
acceptFlag = NameLookup.ACCEPT_CLASSES;
}

Back to the top