diff --git a/jdt-patch/e419/Feature-org.codehaus.groovy.jdt.patch/feature.xml b/jdt-patch/e419/Feature-org.codehaus.groovy.jdt.patch/feature.xml
index f17c53f41b..3bb1b49459 100644
--- a/jdt-patch/e419/Feature-org.codehaus.groovy.jdt.patch/feature.xml
+++ b/jdt-patch/e419/Feature-org.codehaus.groovy.jdt.patch/feature.xml
@@ -18,7 +18,7 @@
-
+
\'. Type \'Map\' doesn\'t seem to be designed with null type annotations in mind\n" +
- "----------\n" +
- "2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/test1/Test1.java (at line 11)\n" +
- " throw new RuntimeException(); // should not be reported as dead code, although V is a \'@NonNull Test1\'\n" +
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
- "Dead code\n" +
- "----------\n" +
- "3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/test1/Test1.java (at line 13)\n" +
- " public boolean equals(@NonNull Object other) { return false; }\n" +
- " ^^^^^^^^^^^^^^^\n" +
- "Illegal redefinition of parameter other, inherited method from Object declares this parameter as @Nullable\n" +
- "----------\n" +
+ runTest440687("-annotationpath CLASSPATH -classpath \"" + annots_dir2 + "\"",
+ File.pathSeparator + annots_dir1, // extra source path
+ "----------\n" +
+ "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/test1/Test1.java (at line 9)\n" +
+ " Test1 v = map.get(key);\n" +
+ " ^^^^^^^^^^^^\n" +
+ "Unsafe interpretation of method return type as \'@NonNull\' based on the receiver type \'@NonNull Map<@NonNull String,@NonNull Test1>\'. Type \'Map\' doesn\'t seem to be designed with null type annotations in mind\n" +
+ "----------\n" +
+ "2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/test1/Test1.java (at line 11)\n" +
+ " throw new RuntimeException(); // should not be reported as dead code, although V is a \'@NonNull Test1\'\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Dead code\n" +
+ "----------\n" +
+ "3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/test1/Test1.java (at line 13)\n" +
+ " public boolean equals(@NonNull Object other) { return false; }\n" +
+ " ^^^^^^^^^^^^^^^\n" +
+ "Illegal redefinition of parameter other, inherited method from Object declares this parameter as @Nullable\n" +
+ "----------\n" +
"3 problems (3 warnings)\n",
true);
}
@@ -964,24 +964,24 @@ public void test490010NoEeaFile2() throws IOException {
Util.zip(new File(annots_dir2), zipName);
Util.delete(annots_dir2);
- runTest440687("-annotationpath CLASSPATH -classpath \"" + zipName + "\"",
- File.pathSeparator + annots_dir1, // extra source path
- "----------\n" +
- "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/test1/Test1.java (at line 9)\n" +
- " Test1 v = map.get(key);\n" +
- " ^^^^^^^^^^^^\n" +
- "Unsafe interpretation of method return type as \'@NonNull\' based on the receiver type \'@NonNull Map<@NonNull String,@NonNull Test1>\'. Type \'Map\' doesn\'t seem to be designed with null type annotations in mind\n" +
- "----------\n" +
- "2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/test1/Test1.java (at line 11)\n" +
- " throw new RuntimeException(); // should not be reported as dead code, although V is a \'@NonNull Test1\'\n" +
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
- "Dead code\n" +
- "----------\n" +
- "3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/test1/Test1.java (at line 13)\n" +
- " public boolean equals(@NonNull Object other) { return false; }\n" +
- " ^^^^^^^^^^^^^^^\n" +
- "Illegal redefinition of parameter other, inherited method from Object declares this parameter as @Nullable\n" +
- "----------\n" +
+ runTest440687("-annotationpath CLASSPATH -classpath \"" + zipName + "\"",
+ File.pathSeparator + annots_dir1, // extra source path
+ "----------\n" +
+ "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/test1/Test1.java (at line 9)\n" +
+ " Test1 v = map.get(key);\n" +
+ " ^^^^^^^^^^^^\n" +
+ "Unsafe interpretation of method return type as \'@NonNull\' based on the receiver type \'@NonNull Map<@NonNull String,@NonNull Test1>\'. Type \'Map\' doesn\'t seem to be designed with null type annotations in mind\n" +
+ "----------\n" +
+ "2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/test1/Test1.java (at line 11)\n" +
+ " throw new RuntimeException(); // should not be reported as dead code, although V is a \'@NonNull Test1\'\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Dead code\n" +
+ "----------\n" +
+ "3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/test1/Test1.java (at line 13)\n" +
+ " public boolean equals(@NonNull Object other) { return false; }\n" +
+ " ^^^^^^^^^^^^^^^\n" +
+ "Illegal redefinition of parameter other, inherited method from Object declares this parameter as @Nullable\n" +
+ "----------\n" +
"3 problems (3 warnings)\n",
true);
}
@@ -1001,25 +1001,119 @@ public void test490010NoEeaFile3() throws IOException {
Util.zip(new File(annots_dir2), zipName);
Util.delete(annots_dir2);
- runTest440687("-annotationpath \"" + zipName + "\"",
- File.pathSeparator + annots_dir1, // extra source path
- "----------\n" +
- "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/test1/Test1.java (at line 9)\n" +
- " Test1 v = map.get(key);\n" +
- " ^^^^^^^^^^^^\n" +
- "Unsafe interpretation of method return type as \'@NonNull\' based on the receiver type \'@NonNull Map<@NonNull String,@NonNull Test1>\'. Type \'Map\' doesn\'t seem to be designed with null type annotations in mind\n" +
- "----------\n" +
- "2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/test1/Test1.java (at line 11)\n" +
- " throw new RuntimeException(); // should not be reported as dead code, although V is a \'@NonNull Test1\'\n" +
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
- "Dead code\n" +
- "----------\n" +
- "3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/test1/Test1.java (at line 13)\n" +
- " public boolean equals(@NonNull Object other) { return false; }\n" +
- " ^^^^^^^^^^^^^^^\n" +
- "Illegal redefinition of parameter other, inherited method from Object declares this parameter as @Nullable\n" +
- "----------\n" +
+ runTest440687("-annotationpath \"" + zipName + "\"",
+ File.pathSeparator + annots_dir1, // extra source path
+ "----------\n" +
+ "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/test1/Test1.java (at line 9)\n" +
+ " Test1 v = map.get(key);\n" +
+ " ^^^^^^^^^^^^\n" +
+ "Unsafe interpretation of method return type as \'@NonNull\' based on the receiver type \'@NonNull Map<@NonNull String,@NonNull Test1>\'. Type \'Map\' doesn\'t seem to be designed with null type annotations in mind\n" +
+ "----------\n" +
+ "2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/test1/Test1.java (at line 11)\n" +
+ " throw new RuntimeException(); // should not be reported as dead code, although V is a \'@NonNull Test1\'\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Dead code\n" +
+ "----------\n" +
+ "3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/test1/Test1.java (at line 13)\n" +
+ " public boolean equals(@NonNull Object other) { return false; }\n" +
+ " ^^^^^^^^^^^^^^^\n" +
+ "Illegal redefinition of parameter other, inherited method from Object declares this parameter as @Nullable\n" +
+ "----------\n" +
"3 problems (3 warnings)\n",
true);
}
+ public void testBug571055_explicit() throws IOException {
+ runTestBug571055(false, false);
+ }
+ public void testBug571055_inherit() throws IOException {
+ runTestBug571055(true, false);
+ }
+ public void testBug571055_dedicatedAnnotationPath() throws IOException {
+ runTestBug571055(false, true);
+ }
+ private void runTestBug571055(boolean inheritAnnotations, boolean dedicatedAnnotationPath) throws IOException {
+ String annots_dir = Util.getOutputDirectory() + File.separator + "annots";
+ String annots_api = annots_dir + File.separator + "api";
+ new File(annots_api).mkdirs();
+ Util.createFile(
+ annots_api + File.separator + "Foo.eea",
+ "class api/Foo\n" +
+ "m\n" +
+ " (Ljava/lang/String;)Ljava/lang/String;\n" +
+ " (L1java/lang/String;)L0java/lang/String;\n");
+ if (!inheritAnnotations) {
+ // 'manually' establish consistency:
+ String annots_impl = annots_dir + File.separator + "impl";
+ new File(annots_impl).mkdirs();
+ Util.createFile(
+ annots_impl + File.separator + "FooImpl.eea",
+ "class impl/FooImpl\n" +
+ "m\n" +
+ " (Ljava/lang/String;)Ljava/lang/String;\n" +
+ " (L1java/lang/String;)L0java/lang/String;\n");
+ }
+
+ String[] testFiles = new String[] {
+ "java/lang/annotation/ElementType.java",
+ ELEMENT_TYPE_18_CONTENT,
+ "org/eclipse/jdt/annotation/NonNull.java",
+ NONNULL_ANNOTATION_18_CONTENT,
+ "org/eclipse/jdt/annotation/Nullable.java",
+ NULLABLE_ANNOTATION_18_CONTENT,
+ "org/eclipse/jdt/annotation/DefaultLocation.java",
+ DEFAULT_LOCATION_CONTENT,
+ "api/Foo.java",
+ "package api;\n" +
+ "public interface Foo {\n" +
+ " String m(String a);\n" +
+ "}\n",
+ "impl/FooImpl.java",
+ "package impl;\n" +
+ "import api.Foo;\n" +
+ "public class FooImpl implements Foo {\n" +
+ " public String m(String a) { return null; }\n" + // ensure Foo & FooImpl are seen with consistent nullness
+ "}\n",
+ "test1/Test1.java",
+ "package test1;\n" +
+ "\n" +
+ "import api.Foo;\n" +
+ "\n" +
+ "public class Test1 {\n" +
+ " void test(Foo api) {\n" +
+ " String result = api.m(null);\n" +
+ " System.out.println(result.toUpperCase());\n" +
+ " }\n" +
+ "}\n"
+ };
+
+ String commandLine;
+ if (dedicatedAnnotationPath) {
+ commandLine = "-annotationpath \"" + annots_dir + "\" " +
+ " -1.8 -proc:none -err:+nullAnnot -warn:+null " +
+ (inheritAnnotations ? " -warn:+inheritNullAnnot ": "") +
+ " \"" + OUTPUT_DIR + "\"";
+ } else {
+ commandLine = "-annotationpath CLASSPATH " +
+ " -1.8 -proc:none -err:+nullAnnot -warn:+null " +
+ (inheritAnnotations ? " -warn:+inheritNullAnnot ": "") +
+ " -classpath \"" + annots_dir + "\" " +
+ " \"" + OUTPUT_DIR + "\"";
+ }
+
+ // expect eea-motivated problems in Test1 but no in FooImpl:
+ String expectedCompilerMessage =
+ "----------\n" +
+ "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/test1/Test1.java (at line 7)\n" +
+ " String result = api.m(null);\n" +
+ " ^^^^\n" +
+ "Null type mismatch: required '@NonNull String' but the provided value is null\n" +
+ "----------\n" +
+ "2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/test1/Test1.java (at line 8)\n" +
+ " System.out.println(result.toUpperCase());\n" +
+ " ^^^^^^\n" +
+ "Potential null pointer access: The variable result may be null at this location\n" +
+ "----------\n" +
+ "2 problems (1 error, 1 warning)\n";
+ this.runNegativeTest(testFiles, commandLine, "", expectedCompilerMessage, false);
+ }
}
diff --git a/jdt-patch/e419/org.eclipse.jdt.core/META-INF/MANIFEST.MF b/jdt-patch/e419/org.eclipse.jdt.core/META-INF/MANIFEST.MF
index 911017ff6e..abecd6f095 100644
--- a/jdt-patch/e419/org.eclipse.jdt.core/META-INF/MANIFEST.MF
+++ b/jdt-patch/e419/org.eclipse.jdt.core/META-INF/MANIFEST.MF
@@ -67,7 +67,7 @@ Export-Package: org.eclipse.jdt.core,
org.eclipse.jdt.internal.formatter.linewrap;x-internal:=true,
org.eclipse.jdt.internal.formatter.old;x-internal:=true,
org.codehaus.jdt.groovy.integration
-Require-Bundle: org.eclipse.core.resources;bundle-version="[3.12.0,4.0.0)",
+Require-Bundle: org.eclipse.core.resources;bundle-version="[3.14.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.13.0,4.0.0)",
org.eclipse.core.filesystem;bundle-version="[1.7.0,2.0.0)",
org.eclipse.text;bundle-version="[3.6.0,4.0.0)",
diff --git a/jdt-patch/e419/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java b/jdt-patch/e419/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java
index 0f85ef512f..f04669c6cf 100644
--- a/jdt-patch/e419/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java
+++ b/jdt-patch/e419/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java
@@ -156,7 +156,9 @@ public NameEnvironmentAnswer findClass(char[] typeName, String qualifiedPackageN
}
@Override
public boolean hasAnnotationFileFor(String qualifiedTypeName) {
- return this.zipFile.getEntry(qualifiedTypeName+ExternalAnnotationProvider.ANNOTATION_FILE_SUFFIX) != null;
+ if (this.zipFile == null)
+ return false;
+ return this.zipFile.getEntry(qualifiedTypeName+ExternalAnnotationProvider.ANNOTATION_FILE_SUFFIX) != null;
}
@Override
public char[][][] findTypeNames(final String qualifiedPackageName, String moduleName) {
@@ -205,7 +207,7 @@ void acceptModule(ClassFileReader reader) {
}
}
void acceptModule(byte[] content) {
- if (content == null)
+ if (content == null)
return;
ClassFileReader reader = null;
try {
@@ -235,7 +237,7 @@ public synchronized char[][] getModulesDeclaringPackage(String qualifiedPackageN
this.packageCache = new HashSet<>(41);
this.packageCache.add(Util.EMPTY_STRING);
-
+
for (Enumeration e = this.zipFile.entries(); e.hasMoreElements(); ) {
String fileName = ((ZipEntry) e.nextElement()).getName();
addToPackageCache(fileName, false);
@@ -254,7 +256,7 @@ public boolean hasCompilationUnit(String qualifiedPackageName, String moduleName
if (tail.toLowerCase().endsWith(SUFFIX_STRING_class))
return true;
}
- }
+ }
return false;
}
diff --git a/jdt-patch/e419/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java b/jdt-patch/e419/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java
index 80d9d1d20f..aa9c1d100e 100644
--- a/jdt-patch/e419/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java
+++ b/jdt-patch/e419/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java
@@ -15,6 +15,7 @@
import java.io.File;
import java.io.IOException;
+import java.util.function.Function;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
@@ -39,6 +40,11 @@ public class CompilationUnit implements ICompilationUnit {
// be written.
private boolean ignoreOptionalProblems;
private ModuleBinding moduleBinding;
+ /**
+ * annotation path can only be retrieved once the qualified type name is known.
+ * This is the provided function for computing the annotation path from that type name.
+ */
+ private Function annotationPathProvider;
public CompilationUnit(char[] contents, String fileName, String encoding) {
this(contents, fileName, encoding, null);
@@ -49,6 +55,12 @@ public CompilationUnit(char[] contents, String fileName, String encoding,
}
public CompilationUnit(char[] contents, String fileName, String encoding,
String destinationPath, boolean ignoreOptionalProblems, String modName) {
+ this(contents, fileName, encoding, destinationPath, ignoreOptionalProblems, modName, null);
+}
+public CompilationUnit(char[] contents, String fileName, String encoding, String destinationPath,
+ boolean ignoreOptionalProblems, String modName, Function annotationPathProvider)
+{
+ this.annotationPathProvider = annotationPathProvider;
this.contents = contents;
if (modName != null)
this.module = modName.toCharArray();
@@ -130,4 +142,10 @@ public ModuleBinding module(LookupEnvironment rootEnvironment) {
public String getDestinationPath() {
return this.destinationPath;
}
+@Override
+public String getExternalAnnotationPath(String qualifiedTypeName) {
+ if (this.annotationPathProvider != null)
+ return this.annotationPathProvider.apply(qualifiedTypeName);
+ return null;
+}
}
diff --git a/jdt-patch/e419/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java b/jdt-patch/e419/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java
index e1e50befc9..cf1dfedaed 100644
--- a/jdt-patch/e419/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java
+++ b/jdt-patch/e419/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java
@@ -73,6 +73,7 @@
import java.util.ResourceBundle;
import java.util.Set;
import java.util.StringTokenizer;
+import java.util.function.Function;
import org.eclipse.jdt.core.compiler.CategorizedProblem;
import org.eclipse.jdt.core.compiler.CharOperation;
@@ -92,6 +93,7 @@
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
+import org.eclipse.jdt.internal.compiler.classfmt.ExternalAnnotationProvider;
import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
import org.eclipse.jdt.internal.compiler.env.AccessRule;
import org.eclipse.jdt.internal.compiler.env.AccessRuleSet;
@@ -3483,9 +3485,28 @@ public CompilationUnit[] getCompilationUnits() {
// if we got exception during canonicalization, fall back to the name that was specified
fileName = this.filenames[i];
}
+ Function annotationPathProvider = null;
+ if (this.annotationsFromClasspath) {
+ annotationPathProvider = (String qualifiedTypeName) -> {
+ for (Classpath classpathEntry : this.checkedClasspaths) {
+ if (classpathEntry.hasAnnotationFileFor(qualifiedTypeName.replace('.', '/')))
+ return classpathEntry.getPath();
+ }
+ return null;
+ };
+ } else if (this.annotationPaths != null) {
+ annotationPathProvider = (String qualifiedTypeName) -> {
+ String eeaFileName = '/'+qualifiedTypeName.replace('.', '/')+ExternalAnnotationProvider.ANNOTATION_FILE_SUFFIX;
+ for (String annotationPath : this.annotationPaths) {
+ if (new File(annotationPath+eeaFileName).exists())
+ return annotationPath;
+ }
+ return null;
+ };
+ }
units[i] = new CompilationUnit(null, fileName, encoding, this.destinationPaths[i],
shouldIgnoreOptionalProblems(this.ignoreOptionalProblemsFromFolders, fileName.toCharArray()),
- this.modNames[i]);
+ this.modNames[i], annotationPathProvider);
}
}
}
diff --git a/jdt-patch/e419/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionNodeDetector.java b/jdt-patch/e419/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionNodeDetector.java
index 7b839bf19e..04befdd0e7 100644
--- a/jdt-patch/e419/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionNodeDetector.java
+++ b/jdt-patch/e419/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionNodeDetector.java
@@ -13,6 +13,8 @@
*******************************************************************************/
package org.eclipse.jdt.internal.codeassist.complete;
+import java.util.stream.Stream;
+
import org.eclipse.jdt.internal.compiler.*;
import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.lookup.*;
@@ -171,7 +173,7 @@ public void endVisit(QualifiedTypeReference qualifiedTypeReference, ClassScope s
}
@Override
public void endVisit(ReferenceExpression referenceExpression, BlockScope blockScope) {
- endVisit(referenceExpression);
+ endVisit(referenceExpression);
}
@Override
public void endVisit(SingleNameReference singleNameReference, BlockScope scope) {
@@ -381,8 +383,20 @@ private void endVisit(ASTNode astNode) {
&& !(astNode instanceof ConditionalExpression && ((ConditionalExpression) astNode).valueIfTrue == this.searchedNode)
&& !(astNode instanceof ConditionalExpression && ((ConditionalExpression) astNode).valueIfFalse == this.searchedNode)) {
this.parent = astNode;
+ return;
}
}
+
+ // when we have recovering node like private Map> the visitor actually endVisit on I and
+ // R when completions are requested at I. The above logic actually identify R as a parent since the R is visited
+ // and endVisited after founding that I was the searched node. This happens for all type parameters which are at
+ // index where index < n.
+ // Therefore we need to following check to fix the parent by setting the parent to the node which represents
+ // Map> when we are invoking endVisit.
+ if(this.result && astNode instanceof ParameterizedSingleTypeReference &&
+ Stream.of(((ParameterizedSingleTypeReference) astNode).typeArguments).anyMatch(n -> n == this.searchedNode)) {
+ this.parent = astNode;
+ }
}
private boolean visit(ASTNode astNode) {
if(astNode == this.searchedNode) {
diff --git a/jdt-patch/e419/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/AccessRule.java b/jdt-patch/e419/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/AccessRule.java
index d421d2e714..647bc48582 100644
--- a/jdt-patch/e419/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/AccessRule.java
+++ b/jdt-patch/e419/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/AccessRule.java
@@ -20,8 +20,8 @@ public class AccessRule {
public static final int IgnoreIfBetter = 0x02000000; // value must be greater than IProblem#ForbiddenReference and DiscouragedReference
- public char[] pattern;
- public int problemId;
+ public final char[] pattern;
+ public final int problemId;
public AccessRule(char[] pattern, int problemId) {
this(pattern, problemId, false);
diff --git a/jdt-patch/e419/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/ICompilationUnit.java b/jdt-patch/e419/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/ICompilationUnit.java
index 5e2cdfa662..7d846729cf 100644
--- a/jdt-patch/e419/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/ICompilationUnit.java
+++ b/jdt-patch/e419/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/ICompilationUnit.java
@@ -78,6 +78,6 @@ default String getDestinationPath() {
* Answers a path for external annotations that has been configured for
* the providing classpath entry, or null
.
*/
-default String getExternalAnnotationPath() { return null; }
+default String getExternalAnnotationPath(String qualifiedTypeName) { return null; }
}
diff --git a/jdt-patch/e419/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java b/jdt-patch/e419/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
index 827a12d656..17d84b8796 100644
--- a/jdt-patch/e419/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
+++ b/jdt-patch/e419/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
@@ -542,7 +542,7 @@ SourceTypeBinding buildType(SourceTypeBinding enclosingType, PackageBinding pack
environment().setAccessRestriction(sourceType, accessRestriction);
ICompilationUnit compilationUnit = this.referenceContext.compilationResult.getCompilationUnit();
if (compilationUnit != null && compilerOptions().isAnnotationBasedNullAnalysisEnabled) {
- String externalAnnotationPath = compilationUnit.getExternalAnnotationPath();
+ String externalAnnotationPath = compilationUnit.getExternalAnnotationPath(CharOperation.toString(sourceType.compoundName));
if (externalAnnotationPath != null) {
ExternalAnnotationSuperimposer.apply(sourceType, externalAnnotationPath);
}
diff --git a/jdt-patch/e419/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java b/jdt-patch/e419/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
index fd1b7f417f..dd08e0790f 100644
--- a/jdt-patch/e419/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
+++ b/jdt-patch/e419/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
@@ -2919,15 +2919,14 @@ else if (leafType == TypeBinding.VOID && methodDecl.annotations != null)
}
}
}
+ if (this.externalAnnotationProvider != null)
+ ExternalAnnotationSuperimposer.annotateMethodBinding(method, arguments, this.externalAnnotationProvider, this.environment);
if (compilerOptions.storeAnnotations)
createArgumentBindings(method, compilerOptions); // need annotations resolved already at this point
if (foundReturnTypeProblem)
return method; // but its still unresolved with a null return type & is still connected to its method declaration
method.modifiers &= ~ExtraCompilerModifiers.AccUnresolved;
- if (this.externalAnnotationProvider != null) {
- ExternalAnnotationSuperimposer.annotateMethodBinding(method, arguments, this.externalAnnotationProvider, this.environment);
- }
return method;
}
diff --git a/jdt-patch/e419/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java b/jdt-patch/e419/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java
index 937e392886..179236d111 100644
--- a/jdt-patch/e419/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java
+++ b/jdt-patch/e419/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.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
@@ -1443,6 +1443,7 @@ else if (this.tagValue == TAG_VALUE_VALUE) {
*/
protected boolean parseThrows() {
int start = this.scanner.currentPosition;
+ boolean isCompletionParser = (this.kind & COMPLETION_PARSER) != 0;
try {
Object typeRef = parseQualifiedName(true);
if (this.abort) return false; // May be aborted by specialized parser
@@ -1455,6 +1456,11 @@ protected boolean parseThrows() {
} catch (InvalidInputException ex) {
if (this.reportProblems) this.sourceParser.problemReporter().javadocInvalidThrowsClass(start, getTokenEndPosition());
}
+ if (!isCompletionParser) {
+ this.scanner.currentPosition = start;
+ this.index = start;
+ }
+ this.currentTokenType = -1;
return false;
}
diff --git a/jdt-patch/e419/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java b/jdt-patch/e419/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java
index 56c962839f..870b1ff237 100644
--- a/jdt-patch/e419/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java
+++ b/jdt-patch/e419/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java
@@ -1613,7 +1613,7 @@ public CompilationUnit convert(org.eclipse.jdt.internal.compiler.ast.Compilation
String lineDelimiter = Util.findLineSeparator(source);
if (lineDelimiter == null) lineDelimiter = System.getProperty("line.separator");//$NON-NLS-1$
message.append(lineDelimiter);
- message.append(bugs.replaceAll("\n", lineDelimiter)); //$NON-NLS-1$
+ message.append(bugs.replace("\n", lineDelimiter)); //$NON-NLS-1$
message.append(lineDelimiter);
message.append("----------------------------------- SOURCE BEGIN -------------------------------------"); //$NON-NLS-1$
message.append(lineDelimiter);
diff --git a/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathAccessRule.java b/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathAccessRule.java
index 50dcdbb386..d4cb0faae8 100644
--- a/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathAccessRule.java
+++ b/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathAccessRule.java
@@ -21,8 +21,12 @@
public class ClasspathAccessRule extends AccessRule implements IAccessRule {
+ private IPath path;
+
public ClasspathAccessRule(IPath pattern, int kind) {
this(pattern.toString().toCharArray(), toProblemId(kind));
+ // avoid IPath creation (Bug 571159):
+ this.path = pattern;
}
public ClasspathAccessRule(char[] pattern, int problemId) {
@@ -43,7 +47,11 @@ private static int toProblemId(int kind) {
@Override
public IPath getPattern() {
- return new Path(new String(this.pattern));
+ if (this.path == null) {
+ // cache the IPath (Bug 571159):
+ this.path = new Path(new String(this.pattern));
+ }
+ return this.path;
}
@Override
diff --git a/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java b/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java
index 9d3d687ca0..5891e9c512 100644
--- a/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java
+++ b/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java
@@ -1,6 +1,6 @@
// GROOVY PATCHED
/*******************************************************************************
- * 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
@@ -67,25 +67,16 @@ public abstract class AbstractImageBuilder implements ICompilerRequestor, ICompi
//2000 is best compromise between space used and speed
public static int MAX_AT_ONCE = Integer.getInteger(JavaModelManager.MAX_COMPILED_UNITS_AT_ONCE, 2000).intValue();
public final static String[] JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES = {
- IMarker.MESSAGE,
- IMarker.SEVERITY,
- IJavaModelMarker.ID,
- IMarker.CHAR_START,
- IMarker.CHAR_END,
- IMarker.LINE_NUMBER,
- IJavaModelMarker.ARGUMENTS,
- IJavaModelMarker.CATEGORY_ID,
-};
-public final static String[] JAVA_TASK_MARKER_ATTRIBUTE_NAMES = {
- IMarker.MESSAGE,
- IMarker.PRIORITY,
- IJavaModelMarker.ID,
- IMarker.CHAR_START,
- IMarker.CHAR_END,
- IMarker.LINE_NUMBER,
- IMarker.USER_EDITABLE,
- IMarker.SOURCE_ID,
-};
+ IMarker.MESSAGE,
+ IMarker.SEVERITY,
+ IJavaModelMarker.ID,
+ IMarker.CHAR_START,
+ IMarker.CHAR_END,
+ IMarker.LINE_NUMBER,
+ IJavaModelMarker.ARGUMENTS,
+ IJavaModelMarker.CATEGORY_ID,
+ };
+
public final static Integer S_ERROR = Integer.valueOf(IMarker.SEVERITY_ERROR);
public final static Integer S_WARNING = Integer.valueOf(IMarker.SEVERITY_WARNING);
public final static Integer S_INFO = Integer.valueOf(IMarker.SEVERITY_INFO);
@@ -737,16 +728,14 @@ protected void storeProblemsFor(SourceFile sourceFile, CategorizedProblem[] prob
JavaBuilder.removeProblemsAndTasksFor(this.javaBuilder.currentProject); // make this the only problem for this project
this.keepStoringProblemMarkers = false;
}
- IMarker marker = this.javaBuilder.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
- marker.setAttributes(
- new String[] {IMarker.MESSAGE, IMarker.SEVERITY, IJavaModelMarker.CATEGORY_ID, IMarker.SOURCE_ID},
- new Object[] {
- buildPathProblemMessage,
- Integer.valueOf(isInvalidClasspathError ? IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING),
- Integer.valueOf(CategorizedProblem.CAT_BUILDPATH),
- JavaBuilder.SOURCE_ID
- }
- );
+
+ Map attributes = new HashMap<>();
+ attributes.put(IMarker.MESSAGE, buildPathProblemMessage);
+ attributes.put(IMarker.SEVERITY, Integer.valueOf(isInvalidClasspathError ? IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING));
+ attributes.put(IJavaModelMarker.CATEGORY_ID, Integer.valueOf(CategorizedProblem.CAT_BUILDPATH));
+ attributes.put(IMarker.SOURCE_ID, JavaBuilder.SOURCE_ID);
+
+ this.javaBuilder.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, attributes);
// even if we're not keeping more markers, still fall through rest of the problem reporting, so that offending
// IsClassPathCorrect problem gets recorded since it may help locate the offending reference
}
@@ -787,41 +776,42 @@ protected void storeProblemsFor(SourceFile sourceFile, CategorizedProblem[] prob
}
}
}
- IMarker marker = resource.createMarker(markerType);
- String[] attributeNames = JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES;
- int standardLength = attributeNames.length;
- String[] allNames = attributeNames;
- int managedLength = managedProblem ? 0 : 1;
+ int attributesLength = JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES.length;
+ if (!managedProblem) {
+ attributesLength++;
+ }
+ // optional extra attributes
String[] extraAttributeNames = problem.getExtraMarkerAttributeNames();
- int extraLength = extraAttributeNames == null ? 0 : extraAttributeNames.length;
- if (managedLength > 0 || extraLength > 0) {
- allNames = new String[standardLength + managedLength + extraLength];
- System.arraycopy(attributeNames, 0, allNames, 0, standardLength);
- if (managedLength > 0)
- allNames[standardLength] = IMarker.SOURCE_ID;
- System.arraycopy(extraAttributeNames, 0, allNames, standardLength + managedLength, extraLength);
+ Object[] extraAttributeValues = problem.getExtraMarkerAttributeValues();
+ boolean extraAttributesExist = false;
+ if (extraAttributeNames != null && extraAttributeValues != null
+ && extraAttributeNames.length == extraAttributeValues.length) {
+ attributesLength += extraAttributeNames.length;
+ extraAttributesExist = true;
}
- Object[] allValues = new Object[allNames.length];
- // standard attributes
- int index = 0;
- allValues[index++] = problem.getMessage(); // message
- allValues[index++] = problem.isError() ? S_ERROR : problem.isWarning() ? S_WARNING : S_INFO; // severity
- allValues[index++] = Integer.valueOf(id); // ID
- allValues[index++] = Integer.valueOf(problem.getSourceStart()); // start
- allValues[index++] = Integer.valueOf(problem.getSourceEnd() + 1); // end
- allValues[index++] = Integer.valueOf(problem.getSourceLineNumber()); // line
- allValues[index++] = Util.getProblemArgumentsForMarker(problem.getArguments()); // arguments
- allValues[index++] = Integer.valueOf(problem.getCategoryID()); // category ID
+ Map attributes = new HashMap<>(attributesLength, 1.0f);
+ attributes.put(JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES[0], problem.getMessage()); //MESSAGE
+ attributes.put(JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES[1], problem.isError() ? S_ERROR : problem.isWarning() ? S_WARNING : S_INFO);//SEVERITY
+ attributes.put(JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES[2], Integer.valueOf(id));//ID
+ attributes.put(JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES[3], Integer.valueOf(problem.getSourceStart()));//CHAR_START
+ attributes.put(JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES[4], Integer.valueOf(problem.getSourceEnd() + 1));//CHAR_END,
+ attributes.put(JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES[5], Integer.valueOf(problem.getSourceLineNumber()));//LINE_NUMBER
+ attributes.put(JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES[6], Util.getProblemArgumentsForMarker(problem.getArguments()));//ARGUMENTS
+ attributes.put(JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES[7], Integer.valueOf(problem.getCategoryID()));//CATEGORY_ID
+
// SOURCE_ID attribute for JDT problems
- if (managedLength > 0)
- allValues[index++] = JavaBuilder.SOURCE_ID;
- // optional extra attributes
- if (extraLength > 0)
- System.arraycopy(problem.getExtraMarkerAttributeValues(), 0, allValues, index, extraLength);
+ if (!managedProblem) {
+ attributes.put(IMarker.SOURCE_ID, JavaBuilder.SOURCE_ID);
+ }
- marker.setAttributes(allNames, allValues);
+ if (extraAttributesExist) {
+ for (int j = 0; j < extraAttributeNames.length; j++) {
+ attributes.put(extraAttributeNames[j], extraAttributeValues[j]);
+ }
+ }
+ resource.createMarker(markerType, attributes);
if (!this.keepStoringProblemMarkers) return; // only want the one error recorded on this source file
}
@@ -835,7 +825,6 @@ protected void storeTasksFor(SourceFile sourceFile, CategorizedProblem[] tasks)
for (int i = 0, l = tasks.length; i < l; i++) {
CategorizedProblem task = tasks[i];
if (task.getID() == IProblem.Task) {
- IMarker marker = resource.createMarker(IJavaModelMarker.TASK_MARKER);
Integer priority = P_NORMAL;
String compilerPriority = task.getArguments()[2];
if (JavaCore.COMPILER_TASK_PRIORITY_HIGH.equals(compilerPriority))
@@ -843,33 +832,29 @@ protected void storeTasksFor(SourceFile sourceFile, CategorizedProblem[] tasks)
else if (JavaCore.COMPILER_TASK_PRIORITY_LOW.equals(compilerPriority))
priority = P_LOW;
- String[] attributeNames = JAVA_TASK_MARKER_ATTRIBUTE_NAMES;
- int standardLength = attributeNames.length;
- String[] allNames = attributeNames;
- String[] extraAttributeNames = task.getExtraMarkerAttributeNames();
- int extraLength = extraAttributeNames == null ? 0 : extraAttributeNames.length;
- if (extraLength > 0) {
- allNames = new String[standardLength + extraLength];
- System.arraycopy(attributeNames, 0, allNames, 0, standardLength);
- System.arraycopy(extraAttributeNames, 0, allNames, standardLength, extraLength);
- }
-
- Object[] allValues = new Object[allNames.length];
// standard attributes
- int index = 0;
- allValues[index++] = task.getMessage();
- allValues[index++] = priority;
- allValues[index++] = Integer.valueOf(task.getID());
- allValues[index++] = Integer.valueOf(task.getSourceStart());
- allValues[index++] = Integer.valueOf(task.getSourceEnd() + 1);
- allValues[index++] = Integer.valueOf(task.getSourceLineNumber());
- allValues[index++] = Boolean.FALSE;
- allValues[index++] = JavaBuilder.SOURCE_ID;
+ Map attributes = new HashMap<>();
+
+ attributes.put(IMarker.MESSAGE, task.getMessage());
+ attributes.put(IMarker.PRIORITY, priority);
+ attributes.put(IJavaModelMarker.ID, Integer.valueOf(task.getID()));
+ attributes.put(IMarker.CHAR_START, Integer.valueOf(task.getSourceStart()));
+ attributes.put(IMarker.CHAR_END, Integer.valueOf(task.getSourceEnd() + 1));
+ attributes.put(IMarker.LINE_NUMBER, Integer.valueOf(task.getSourceLineNumber()));
+ attributes.put(IMarker.USER_EDITABLE, Boolean.FALSE);
+ attributes.put(IMarker.SOURCE_ID, JavaBuilder.SOURCE_ID);
+
// optional extra attributes
- if (extraLength > 0)
- System.arraycopy(task.getExtraMarkerAttributeValues(), 0, allValues, index, extraLength);
+ String[] extraAttributeNames = task.getExtraMarkerAttributeNames();
+ Object[] extraAttributeValues = task.getExtraMarkerAttributeValues();
+ if (extraAttributeNames != null && extraAttributeValues != null
+ && extraAttributeNames.length == extraAttributeValues.length) {
+ for (int j = 0; j < extraAttributeNames.length; j++) {
+ attributes.put(extraAttributeNames[j], extraAttributeValues[j]);
+ }
+ }
- marker.setAttributes(allNames, allValues);
+ resource.createMarker(IJavaModelMarker.TASK_MARKER, attributes);
}
}
}
diff --git a/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathMultiReleaseJar.java b/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathMultiReleaseJar.java
index b86abbd3e8..b118dec72a 100644
--- a/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathMultiReleaseJar.java
+++ b/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathMultiReleaseJar.java
@@ -27,20 +27,18 @@
public class ClasspathMultiReleaseJar extends ClasspathJar {
private static final String META_INF_VERSIONS = "META-INF/versions/"; //$NON-NLS-1$
private static final int META_INF_LENGTH = META_INF_VERSIONS.length();
- String[] supportedVersions;
+ private volatile String[] supportedVersions;
ClasspathMultiReleaseJar(IFile resource, AccessRuleSet accessRuleSet, IPath externalAnnotationPath,
boolean isOnModulePath, String compliance) {
super(resource, accessRuleSet, externalAnnotationPath, isOnModulePath);
this.compliance = compliance;
- initializeVersions(this);
}
ClasspathMultiReleaseJar(String zipFilename, long lastModified, AccessRuleSet accessRuleSet,
IPath externalAnnotationPath, boolean isOnModulePath, String compliance) {
super(zipFilename, lastModified, accessRuleSet, externalAnnotationPath, isOnModulePath);
this.compliance = compliance;
- initializeVersions(this);
}
public ClasspathMultiReleaseJar(ZipFile zipFile, AccessRuleSet accessRuleSet, IPath externalAnnotationPath,
@@ -64,7 +62,7 @@ IModule initializeModule() {
try (ZipFile file = new ZipFile(this.zipFilename)){
ClassFileReader classfile = null;
try {
- for (String path : this.supportedVersions) {
+ for (String path : supportedVersions(file)) {
classfile = ClassFileReader.read(file, path.toString() + '/' + IModule.MODULE_INFO_CLASS);
if (classfile != null) {
break;
@@ -87,30 +85,28 @@ IModule initializeModule() {
return mod;
}
- private static synchronized void initializeVersions(ClasspathMultiReleaseJar jar) {
- if (jar.zipFile == null) {
- if (org.eclipse.jdt.internal.core.JavaModelManager.ZIP_ACCESS_VERBOSE) {
- System.out.println("(" + Thread.currentThread() + ") [ClasspathMultiReleaseJar.initializeVersions(String)] Creating ZipFile on " + jar.zipFilename); //$NON-NLS-1$ //$NON-NLS-2$
- }
- try {
- jar.zipFile = new ZipFile(jar.zipFilename);
- } catch (IOException e) {
- return;
- }
- jar.closeZipFileAtEnd = true;
- }
+ private static String[] initializeVersions(ZipFile zipFile, String compliance) {
int earliestJavaVersion = ClassFileConstants.MAJOR_VERSION_9;
- long latestJDK = CompilerOptions.versionToJdkLevel(jar.compliance);
+ long latestJDK = CompilerOptions.versionToJdkLevel(compliance);
int latestJavaVer = (int) (latestJDK >> 16);
List versions = new ArrayList<>();
for (int i = latestJavaVer; i >= earliestJavaVersion; i--) {
- String name = META_INF_VERSIONS+ (i - 44);
- ZipEntry entry = jar.zipFile.getEntry(name);
+ String name = META_INF_VERSIONS + (i - 44);
+ ZipEntry entry = zipFile.getEntry(name);
if (entry != null) {
versions.add(name);
}
}
- jar.supportedVersions = versions.toArray(new String[versions.size()]);
+ return versions.toArray(new String[versions.size()]);
+ }
+
+ private String[] supportedVersions(ZipFile file) {
+ String[] versions = this.supportedVersions;
+ if (versions == null) {
+ versions = initializeVersions(file, this.compliance);
+ this.supportedVersions = versions;
+ }
+ return versions;
}
@Override
@@ -142,7 +138,7 @@ public NameEnvironmentAnswer findClass(String binaryFileName, String qualifiedPa
if (!isPackage(qualifiedPackageName, moduleName)) {
return null; // most common case
}
- for (String path : this.supportedVersions) {
+ for (String path : supportedVersions(this.zipFile)) {
String s = null;
try {
s = META_INF_VERSIONS + path + "/" + binaryFileName; //$NON-NLS-1$
diff --git a/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/JavaBuilder.java b/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/JavaBuilder.java
index 84fbc599f7..7aa915eaec 100644
--- a/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/JavaBuilder.java
+++ b/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/JavaBuilder.java
@@ -239,15 +239,12 @@ protected IProject[] build(int kind, Map ignored, IProgressMonitor monitor) thro
if (DEBUG)
System.out.println(Messages.bind(Messages.build_missingSourceFile, e.missingSourceFile));
removeProblemsAndTasksFor(this.currentProject); // make this the only problem for this project
- IMarker marker = this.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
- marker.setAttributes(
- new String[] {IMarker.MESSAGE, IMarker.SEVERITY, IMarker.SOURCE_ID},
- new Object[] {
- Messages.bind(Messages.build_missingSourceFile, e.missingSourceFile),
- Integer.valueOf(IMarker.SEVERITY_ERROR),
- JavaBuilder.SOURCE_ID
- }
- );
+
+ Map attributes = new HashMap<>();
+ attributes.put(IMarker.MESSAGE, Messages.bind(Messages.build_missingSourceFile, e.missingSourceFile));
+ attributes.put(IMarker.SEVERITY, Integer.valueOf(IMarker.SEVERITY_ERROR));
+ attributes.put(IMarker.SOURCE_ID, JavaBuilder.SOURCE_ID);
+ this.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, attributes);
} finally {
for (int i = 0, l = this.participants == null ? 0 : this.participants.length; i < l; i++)
this.participants[i].buildFinished(this.javaProject);
@@ -341,16 +338,12 @@ private void createInconsistentBuildMarker(CoreException coreException) throws C
if (message == null)
message = coreException.getMessage();
- IMarker marker = this.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
- marker.setAttributes(
- new String[] {IMarker.MESSAGE, IMarker.SEVERITY, IJavaModelMarker.CATEGORY_ID, IMarker.SOURCE_ID},
- new Object[] {
- Messages.bind(Messages.build_inconsistentProject, message),
- Integer.valueOf(IMarker.SEVERITY_ERROR),
- Integer.valueOf(CategorizedProblem.CAT_BUILDPATH),
- JavaBuilder.SOURCE_ID
- }
- );
+ Map attributes = new HashMap<>();
+ attributes.put(IMarker.MESSAGE, Messages.bind(Messages.build_inconsistentProject, message));
+ attributes.put(IMarker.SEVERITY, Integer.valueOf(IMarker.SEVERITY_ERROR));
+ attributes.put(IJavaModelMarker.CATEGORY_ID, Integer.valueOf(CategorizedProblem.CAT_BUILDPATH));
+ attributes.put(IMarker.SOURCE_ID, JavaBuilder.SOURCE_ID);
+ this.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, attributes);
}
private void cleanup() {
@@ -713,16 +706,13 @@ private boolean isWorthBuilding() throws CoreException {
removeProblemsAndTasksFor(this.currentProject); // remove all compilation problems
- IMarker marker = this.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
- marker.setAttributes(
- new String[] {IMarker.MESSAGE, IMarker.SEVERITY, IJavaModelMarker.CATEGORY_ID, IMarker.SOURCE_ID},
- new Object[] {
- Messages.build_abortDueToClasspathProblems,
- Integer.valueOf(IMarker.SEVERITY_ERROR),
- Integer.valueOf(CategorizedProblem.CAT_BUILDPATH),
- JavaBuilder.SOURCE_ID
- }
- );
+ Map attributes = new HashMap<>();
+ attributes.put(IMarker.MESSAGE, Messages.build_abortDueToClasspathProblems);
+ attributes.put(IMarker.SEVERITY, Integer.valueOf(IMarker.SEVERITY_ERROR));
+ attributes.put(IJavaModelMarker.CATEGORY_ID, Integer.valueOf(CategorizedProblem.CAT_BUILDPATH));
+ attributes.put(IMarker.SOURCE_ID, JavaBuilder.SOURCE_ID);
+
+ this.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, attributes);
return false;
}
@@ -754,18 +744,16 @@ private boolean isWorthBuilding() throws CoreException {
+ " was not built"); //$NON-NLS-1$
removeProblemsAndTasksFor(this.currentProject); // make this the only problem for this project
- IMarker marker = this.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
- marker.setAttributes(
- new String[] {IMarker.MESSAGE, IMarker.SEVERITY, IJavaModelMarker.CATEGORY_ID, IMarker.SOURCE_ID},
- new Object[] {
+
+ Map attributes = new HashMap<>();
+ attributes.put(IMarker.MESSAGE,
isClasspathBroken(prereq, true)
- ? Messages.bind(Messages.build_prereqProjectHasClasspathProblems, p.getName())
- : Messages.bind(Messages.build_prereqProjectMustBeRebuilt, p.getName()),
- Integer.valueOf(IMarker.SEVERITY_ERROR),
- Integer.valueOf(CategorizedProblem.CAT_BUILDPATH),
- JavaBuilder.SOURCE_ID
- }
- );
+ ? Messages.bind(Messages.build_prereqProjectHasClasspathProblems, p.getName())
+ : Messages.bind(Messages.build_prereqProjectMustBeRebuilt, p.getName()));
+ attributes.put(IMarker.SEVERITY, Integer.valueOf(IMarker.SEVERITY_ERROR));
+ attributes.put(IJavaModelMarker.CATEGORY_ID, Integer.valueOf(CategorizedProblem.CAT_BUILDPATH));
+ attributes.put(IMarker.SOURCE_ID, JavaBuilder.SOURCE_ID);
+ this.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, attributes);
return false;
}
}
diff --git a/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/SourceFile.java b/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/SourceFile.java
index 9672297546..24df30198b 100644
--- a/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/SourceFile.java
+++ b/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/SourceFile.java
@@ -119,7 +119,7 @@ public boolean ignoreOptionalProblems() {
return this.sourceLocation.ignoreOptionalProblems;
}
@Override
-public String getExternalAnnotationPath() {
+public String getExternalAnnotationPath(String qualifiedTypeName) {
return this.sourceLocation.externalAnnotationPath;
}
String typeLocator() {
diff --git a/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/RequestorWrapper.java b/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/RequestorWrapper.java
index 338b44e67e..1c4487c304 100644
--- a/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/RequestorWrapper.java
+++ b/jdt-patch/e419/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/RequestorWrapper.java
@@ -13,6 +13,9 @@
*******************************************************************************/
package org.eclipse.jdt.internal.core.eval;
+import java.util.HashMap;
+import java.util.Map;
+
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
@@ -57,15 +60,16 @@ public boolean acceptClassFiles(ClassFile[] classFiles, char[] codeSnippetClassN
@Override
public void acceptProblem(CategorizedProblem problem, char[] fragmentSource, int fragmentKind) {
try {
- IMarker marker = ResourcesPlugin.getWorkspace().getRoot().createMarker(IJavaModelMarker.TRANSIENT_PROBLEM);
- marker.setAttribute(IJavaModelMarker.ID, problem.getID());
- marker.setAttribute(IMarker.CHAR_START, problem.getSourceStart());
- marker.setAttribute(IMarker.CHAR_END, problem.getSourceEnd() + 1);
- marker.setAttribute(IMarker.LINE_NUMBER, problem.getSourceLineNumber());
- //marker.setAttribute(IMarker.LOCATION, "#" + problem.getSourceLineNumber());
- marker.setAttribute(IMarker.MESSAGE, problem.getMessage());
- marker.setAttribute(IMarker.SEVERITY, (problem.isError() ? IMarker.SEVERITY_ERROR : problem.isWarning() ? IMarker.SEVERITY_WARNING : IMarker.SEVERITY_INFO));
- marker.setAttribute(IMarker.SOURCE_ID, JavaBuilder.SOURCE_ID);
+ Map attributes = new HashMap<>();
+ attributes.put(IJavaModelMarker.ID, problem.getID());
+ attributes.put(IMarker.CHAR_START, problem.getSourceStart());
+ attributes.put(IMarker.CHAR_END, problem.getSourceEnd() + 1);
+ attributes.put(IMarker.LINE_NUMBER, problem.getSourceLineNumber());
+ attributes.put(IMarker.MESSAGE, problem.getMessage());
+ attributes.put(IMarker.SEVERITY, (problem.isError() ? IMarker.SEVERITY_ERROR : problem.isWarning() ? IMarker.SEVERITY_WARNING : IMarker.SEVERITY_INFO));
+ attributes.put(IMarker.SOURCE_ID, JavaBuilder.SOURCE_ID);
+
+ IMarker marker = ResourcesPlugin.getWorkspace().getRoot().createMarker(IJavaModelMarker.TRANSIENT_PROBLEM, attributes);
this.requestor.acceptProblem(marker, new String(fragmentSource), fragmentKind);
} catch (CoreException e) {
e.printStackTrace();
diff --git a/jdt-patch/e419/org.eclipse.jdt.core/readme.txt b/jdt-patch/e419/org.eclipse.jdt.core/readme.txt
index f15a4e0b76..a2ee52a7a5 100644
--- a/jdt-patch/e419/org.eclipse.jdt.core/readme.txt
+++ b/jdt-patch/e419/org.eclipse.jdt.core/readme.txt
@@ -1,2 +1,3 @@
2021-01-08: d5c188d (2021-03 M1)
2021-02-08: babeca4 (2021-03 M2)
+2021-02-22: 96e9f52 (2021-03 M3)
diff --git a/pom.xml b/pom.xml
index b9f99958c7..7fe54ea513 100644
--- a/pom.xml
+++ b/pom.xml
@@ -120,7 +120,7 @@
eclipse
p2
- https://download.eclipse.org/eclipse/updates/4.19milestones
+ https://download.eclipse.org/eclipse/updates/4.19-I-builds/I20210217-1800