diff --git a/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/SealedTests.java b/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/SealedTests.java
index e79346bb6d..88ff1d2557 100644
--- a/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/SealedTests.java
+++ b/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/SealedTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2021 the original author or authors.
+ * Copyright 2009-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -121,19 +121,23 @@ public void testSealed2() {
"1. ERROR in Foo.groovy (at line 1)\n" +
"\t@groovy.transform.Sealed(permittedSubclasses=[Bar,Baz])\n" +
"\t ^^^\n" +
- "Permitted class Bar does not declare Foo as direct super class\n" +
+ (javaModelSealedSupport2()
+ ? "Permitted type Bar does not declare Foo as a direct supertype\n"
+ : "Permitted class Bar does not declare Foo as direct super class\n") +
"----------\n" +
"----------\n" +
"1. ERROR in Baz.groovy (at line 1)\n" +
"\tclass Baz extends Foo {\n" +
"\t ^^^\n" +
- "The class Baz with a sealed direct superclass or a sealed direct superinterface Foo should be declared either final, sealed, or non-sealed\n" +
+ "The class Baz with a sealed direct super" + (javaModelSealedSupport2() ? "type" : "class or a sealed direct superinterface") +
+ " Foo should be declared either final, sealed, or non-sealed\n" +
"----------\n" +
"----------\n" +
"1. ERROR in Boo.groovy (at line 1)\n" +
"\tclass Boo extends Foo {\n" +
"\t ^^^\n" +
- "The class Boo with a sealed direct superclass or a sealed direct superinterface Foo should be declared either final, sealed, or non-sealed\n" +
+ "The class Boo with a sealed direct super" + (javaModelSealedSupport2() ? "type" : "class or a sealed direct superinterface") +
+ " Foo should be declared either final, sealed, or non-sealed\n" +
"----------\n" +
"2. ERROR in Boo.groovy (at line 1)\n" +
"\tclass Boo extends Foo {\n" +
@@ -143,7 +147,9 @@ public void testSealed2() {
"3. ERROR in Boo.groovy (at line 1)\n" +
"\tclass Boo extends Foo {\n" +
"\t ^^^\n" +
- "The type Boo extending a sealed class Foo should be a permitted subtype of Foo\n" +
+ (javaModelSealedSupport2()
+ ? "The class Boo cannot extend the class Foo as it is not a permitted subtype of Foo\n"
+ : "The type Boo extending a sealed class Foo should be a permitted subtype of Foo\n") +
"----------\n");
}
@@ -176,7 +182,8 @@ public void testSealed3() {
"1. ERROR in p\\Baz.java (at line 2)\n" +
"\tclass Baz extends Foo {\n" +
"\t ^^^\n" +
- "The class Baz with a sealed direct superclass or a sealed direct superinterface Foo should be declared either final, sealed, or non-sealed\n" +
+ "The class Baz with a sealed direct super" + (javaModelSealedSupport2() ? "type" : "class or a sealed direct superinterface") +
+ " Foo should be declared either final, sealed, or non-sealed\n" +
"----------\n");
}
@@ -187,4 +194,9 @@ private static boolean javaModelSealedSupport() {
return org.eclipse.jdt.core.JavaCore.getPlugin().getBundle().getVersion()
.compareTo(org.osgi.framework.Version.parseVersion("3.28")) >= 0;
}
+
+ private static boolean javaModelSealedSupport2() {
+ return org.eclipse.jdt.core.JavaCore.getPlugin().getBundle().getVersion()
+ .compareTo(org.osgi.framework.Version.parseVersion("3.40")) >= 0;
+ }
}
diff --git a/groovy-eclipse.setup b/groovy-eclipse.setup
index 3c38bad7ce..181ab00797 100644
--- a/groovy-eclipse.setup
+++ b/groovy-eclipse.setup
@@ -311,7 +311,7 @@
+ url="https://download.eclipse.org/eclipse/updates/4.34-I-builds/I20241107-0510"/>
diff --git a/jdt-patch/e434/Feature-org.codehaus.groovy.jdt.patch/feature.xml b/jdt-patch/e434/Feature-org.codehaus.groovy.jdt.patch/feature.xml
index cc6d15d990..6e87fb5bdd 100644
--- a/jdt-patch/e434/Feature-org.codehaus.groovy.jdt.patch/feature.xml
+++ b/jdt-patch/e434/Feature-org.codehaus.groovy.jdt.patch/feature.xml
@@ -18,7 +18,7 @@
-
+
= ClassFileConstants.JDK17) {
- // add record attributes
- attributesNumber += generatePermittedTypeAttributes();
+ attributesNumber += generatePermittedSubclassesAttribute();
}
// Inner class attribute
int numberOfInnerClasses = this.innerClassesBindings == null ? 0 : this.innerClassesBindings.size();
@@ -2918,10 +2851,9 @@ private int generateNestAttributes() {
nAttrs += generateNestHostAttribute();
return nAttrs;
}
- private int generatePermittedTypeAttributes() {
- SourceTypeBinding type = this.referenceBinding;
+ private int generatePermittedSubclassesAttribute() {
int localContentsOffset = this.contentsOffset;
- ReferenceBinding[] permittedTypes = type.permittedTypes();
+ ReferenceBinding[] permittedTypes = this.referenceBinding.permittedTypes();
int l = permittedTypes != null ? permittedTypes.length : 0;
if (l == 0)
return 0;
@@ -2930,6 +2862,14 @@ private int generatePermittedTypeAttributes() {
if (exSize + localContentsOffset >= this.contents.length) {
resizeContents(exSize);
}
+ /*
+ * PermittedSubclasses_attribute {
+ u2 attribute_name_index;
+ u4 attribute_length;
+ u2 number_of_classes;
+ u2 classes[number_of_classes];
+ }
+ */
int attributeNameIndex =
this.constantPool.literalIndex(AttributeNamesConstants.PermittedSubclasses);
this.contents[localContentsOffset++] = (byte) (attributeNameIndex >> 8);
@@ -5902,7 +5842,6 @@ private int generateTypeAnnotationAttributeForTypeDeclaration() {
superInterface.getAllAnnotationContexts(AnnotationTargetTypeConstants.CLASS_EXTENDS, i, allTypeAnnotationContexts);
}
}
- // TODO: permittedTypes codegen
TypeParameter[] typeParameters = typeDeclaration.typeParameters;
if (typeParameters != null) {
for (int i = 0, max = typeParameters.length; i < max; i++) {
@@ -6104,7 +6043,7 @@ public void initialize(SourceTypeBinding aType, ClassFile parentClassFile, boole
if (aType.isAnonymousType()) {
ReferenceBinding superClass = aType.superclass;
if (superClass == null || !(superClass.isEnum() && superClass.isSealed()))
- accessFlags &= ~ClassFileConstants.AccFinal;
+ accessFlags &= ~ClassFileConstants.AccFinal;
}
int finalAbstract = ClassFileConstants.AccFinal | ClassFileConstants.AccAbstract;
if ((accessFlags & finalAbstract) == finalAbstract) {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/CompilationResult.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/CompilationResult.java
index 7060b2caa8..c51186f66d 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/CompilationResult.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/CompilationResult.java
@@ -15,6 +15,20 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler;
+import java.lang.ref.SoftReference;
+import java.util.*;
+import org.eclipse.jdt.core.compiler.CategorizedProblem;
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.core.compiler.IProblem;
+import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
+import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
+import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
+import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
+import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
+import org.eclipse.jdt.internal.compiler.parser.RecoveryScannerData;
+import org.eclipse.jdt.internal.compiler.util.Util;
+
/**
* A compilation result consists of all information returned by the compiler for
* a single compiled compilation source unit. This includes:
@@ -35,29 +49,6 @@
* specific fields and methods which were referenced, but does contain their
* declaring types and any other types used to locate such fields or methods.
*/
-import java.util.Arrays;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.jdt.core.compiler.CategorizedProblem;
-import org.eclipse.jdt.core.compiler.CharOperation;
-import org.eclipse.jdt.core.compiler.IProblem;
-import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
-import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
-import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
-import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-import org.eclipse.jdt.internal.compiler.parser.RecoveryScannerData;
-import org.eclipse.jdt.internal.compiler.util.Util;
-
@SuppressWarnings({ "rawtypes", "unchecked" })
public class CompilationResult {
@@ -88,6 +79,8 @@ public class CompilationResult {
private boolean hasMandatoryErrors;
public List annotations = new ArrayList<>(1);
private List scheduledProblems;
+ private volatile boolean cacheSource;
+ private volatile SoftReference contentRef;
private static final int[] EMPTY_LINE_ENDS = Util.EMPTY_INT_ARRAY;
private static final Comparator PROBLEM_COMPARATOR = new Comparator() {
@@ -495,4 +488,29 @@ public void materializeProblems() {
}
}
}
+
+public void cacheSource() {
+ this.cacheSource = true;
+}
+
+public char[] getContents() {
+ SoftReference cr = this.contentRef;
+ if (cr != null) {
+ char[] cachedContents = cr.get();
+ if (cachedContents != null) {
+ return cachedContents;
+ }
+ }
+ return this.compilationUnit.getContents();
+}
+
+public void cacheContents(char[] contents) {
+ if (this.cacheSource) {
+ this.contentRef = new SoftReference<>(contents);
+ }
+}
+
+public void releaseContent() {
+ this.contentRef = null;
+}
}
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/Compiler.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/Compiler.java
index 8dc0999814..b1498db4c8 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/Compiler.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/Compiler.java
@@ -17,18 +17,40 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler;
-import org.eclipse.jdt.core.compiler.*;
-import org.eclipse.jdt.internal.compiler.env.*;
-import org.eclipse.jdt.internal.compiler.impl.*;
-import org.eclipse.jdt.internal.compiler.ast.*;
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import org.eclipse.jdt.core.compiler.CategorizedProblem;
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.core.compiler.CompilationProgress;
+import org.eclipse.jdt.core.compiler.IProblem;
+import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.ImportReference;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.lookup.*;
-import org.eclipse.jdt.internal.compiler.parser.*;
-import org.eclipse.jdt.internal.compiler.problem.*;
-import org.eclipse.jdt.internal.compiler.util.*;
-
-import java.io.*;
-import java.util.*;
+import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
+import org.eclipse.jdt.internal.compiler.env.IBinaryType;
+import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
+import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
+import org.eclipse.jdt.internal.compiler.env.ISourceType;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.eclipse.jdt.internal.compiler.impl.CompilerStats;
+import org.eclipse.jdt.internal.compiler.impl.ITypeRequestor;
+import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
+import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
+import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
+import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
+import org.eclipse.jdt.internal.compiler.lookup.SourceTypeCollisionException;
+import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
+import org.eclipse.jdt.internal.compiler.parser.Parser;
+import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
+import org.eclipse.jdt.internal.compiler.problem.AbortCompilationUnit;
+import org.eclipse.jdt.internal.compiler.problem.DefaultProblem;
+import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
+import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
+import org.eclipse.jdt.internal.compiler.util.Messages;
+import org.eclipse.jdt.internal.compiler.util.Util;
public class Compiler implements ITypeRequestor, ProblemSeverities {
public Parser parser;
@@ -891,6 +913,7 @@ protected void internalBeginToCompile(ICompilationUnit[] sourceUnits, int maxUni
if (this.totalUnits < this.parseThreshold) {
parsedUnit = this.parser.parse(sourceUnits[i], unitResult);
} else {
+ unitResult.cacheSource();
parsedUnit = this.parser.dietParse(sourceUnits[i], unitResult);
}
long resolveStart = System.currentTimeMillis();
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/IProblemFactory.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/IProblemFactory.java
index a6bb739626..21980dfb75 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/IProblemFactory.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/IProblemFactory.java
@@ -14,7 +14,6 @@
package org.eclipse.jdt.internal.compiler;
import java.util.Locale;
-
import org.eclipse.jdt.core.compiler.CategorizedProblem;
/*
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ProcessTaskManager.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ProcessTaskManager.java
index 1bdb321340..7cccf43a2b 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ProcessTaskManager.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ProcessTaskManager.java
@@ -23,7 +23,6 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
-
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
import org.eclipse.jdt.internal.compiler.util.Messages;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ReadManager.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ReadManager.java
index 9f602093b5..522b71d575 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ReadManager.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ReadManager.java
@@ -24,7 +24,6 @@
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
-
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
/** Reads a list of ICompilationUnit before actually needed (ahead) **/
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/AnnotationDiscoveryVisitor.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/AnnotationDiscoveryVisitor.java
index 8998514d48..aa9b59ddce 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/AnnotationDiscoveryVisitor.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/AnnotationDiscoveryVisitor.java
@@ -15,36 +15,13 @@
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
-
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.apt.model.ElementImpl;
import org.eclipse.jdt.internal.compiler.apt.model.Factory;
import org.eclipse.jdt.internal.compiler.apt.util.ManyToMany;
-import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.Annotation;
-import org.eclipse.jdt.internal.compiler.ast.Argument;
-import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.ModuleDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.RecordComponent;
-import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.TypeParameter;
+import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
-import org.eclipse.jdt.internal.compiler.lookup.AptSourceLocalVariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
-import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
-import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
-import org.eclipse.jdt.internal.compiler.lookup.ModuleBinding;
-import org.eclipse.jdt.internal.compiler.lookup.RecordComponentBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.*;
/**
* This class is used to visit the JDT compiler internal AST to discover annotations,
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseAnnotationProcessorManager.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseAnnotationProcessorManager.java
index e16725f5d1..a7f3899534 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseAnnotationProcessorManager.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseAnnotationProcessorManager.java
@@ -18,7 +18,6 @@
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
-
import org.eclipse.jdt.internal.compiler.AbstractAnnotationProcessorManager;
import org.eclipse.jdt.internal.compiler.Compiler;
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseMessagerImpl.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseMessagerImpl.java
index 6c28ab2c90..a83b42619d 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseMessagerImpl.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseMessagerImpl.java
@@ -18,7 +18,6 @@
import javax.lang.model.element.AnnotationValue;
import javax.lang.model.element.Element;
import javax.tools.Diagnostic.Kind;
-
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.apt.model.AnnotationMemberValue;
import org.eclipse.jdt.internal.compiler.apt.model.AnnotationMirrorImpl;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseProcessingEnvImpl.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseProcessingEnvImpl.java
index 135fb7aede..74c45f22b2 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseProcessingEnvImpl.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseProcessingEnvImpl.java
@@ -18,7 +18,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-
import javax.annotation.processing.Filer;
import javax.annotation.processing.Messager;
import javax.annotation.processing.ProcessingEnvironment;
@@ -26,7 +25,6 @@
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import javax.tools.JavaFileManager;
-
import org.eclipse.jdt.internal.compiler.Compiler;
import org.eclipse.jdt.internal.compiler.apt.model.ElementsImpl;
import org.eclipse.jdt.internal.compiler.apt.model.Factory;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchAnnotationProcessorManager.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchAnnotationProcessorManager.java
index e5e904fe8e..658bf17d70 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchAnnotationProcessorManager.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchAnnotationProcessorManager.java
@@ -22,13 +22,11 @@
import java.util.List;
import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
-
import javax.annotation.processing.Processor;
import javax.lang.model.SourceVersion;
import javax.tools.JavaFileManager;
import javax.tools.StandardJavaFileManager;
import javax.tools.StandardLocation;
-
import org.eclipse.jdt.internal.compiler.batch.Main;
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchFilerImpl.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchFilerImpl.java
index 66c9a55ca8..ad4924a85b 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchFilerImpl.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchFilerImpl.java
@@ -20,17 +20,15 @@
import java.io.IOException;
import java.net.URI;
import java.util.HashSet;
-
import javax.annotation.processing.Filer;
import javax.annotation.processing.FilerException;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.tools.FileObject;
import javax.tools.JavaFileManager;
+import javax.tools.JavaFileManager.Location;
import javax.tools.JavaFileObject;
import javax.tools.StandardLocation;
-import javax.tools.JavaFileManager.Location;
-
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchMessagerImpl.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchMessagerImpl.java
index 1f0e9b2773..e0756fc393 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchMessagerImpl.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchMessagerImpl.java
@@ -20,7 +20,6 @@
import javax.lang.model.element.AnnotationValue;
import javax.lang.model.element.Element;
import javax.tools.Diagnostic.Kind;
-
import org.eclipse.jdt.core.compiler.CategorizedProblem;
import org.eclipse.jdt.internal.compiler.batch.Main;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchProcessingEnvImpl.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchProcessingEnvImpl.java
index 0643446403..df97cb6e40 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchProcessingEnvImpl.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchProcessingEnvImpl.java
@@ -23,9 +23,7 @@
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
-
import javax.tools.JavaFileManager;
-
import org.eclipse.jdt.internal.compiler.apt.util.EclipseFileManager;
import org.eclipse.jdt.internal.compiler.batch.Main;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/HookedJavaFileObject.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/HookedJavaFileObject.java
index 7776c12a89..d55d8d39cd 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/HookedJavaFileObject.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/HookedJavaFileObject.java
@@ -18,10 +18,8 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
-
import javax.tools.ForwardingJavaFileObject;
import javax.tools.JavaFileObject;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.batch.CompilationUnit;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/IProcessorProvider.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/IProcessorProvider.java
index ae4e7dc751..ccb6a6c3a3 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/IProcessorProvider.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/IProcessorProvider.java
@@ -16,7 +16,6 @@
package org.eclipse.jdt.internal.compiler.apt.dispatch;
import java.util.List;
-
import javax.annotation.processing.Processor;
/**
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/ProcessorInfo.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/ProcessorInfo.java
index 9248929bbd..283cde88b5 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/ProcessorInfo.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/ProcessorInfo.java
@@ -19,7 +19,6 @@
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-
import javax.annotation.processing.Processor;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.TypeElement;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/RoundDispatcher.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/RoundDispatcher.java
index 15131a4832..0cac394a67 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/RoundDispatcher.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/RoundDispatcher.java
@@ -20,7 +20,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.Set;
-
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/RoundEnvImpl.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/RoundEnvImpl.java
index be99d72313..56140636b1 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/RoundEnvImpl.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/RoundEnvImpl.java
@@ -19,13 +19,11 @@
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
-
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.TypeElement;
import javax.lang.model.util.ElementFilter;
-
import org.eclipse.jdt.internal.compiler.apt.model.Factory;
import org.eclipse.jdt.internal.compiler.apt.model.TypeElementImpl;
import org.eclipse.jdt.internal.compiler.apt.util.ManyToMany;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/AnnotationMirrorImpl.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/AnnotationMirrorImpl.java
index 61bf96dfe4..d89b67c383 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/AnnotationMirrorImpl.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/AnnotationMirrorImpl.java
@@ -26,7 +26,6 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.AnnotationValue;
import javax.lang.model.element.ExecutableElement;
@@ -34,7 +33,6 @@
import javax.lang.model.type.MirroredTypeException;
import javax.lang.model.type.MirroredTypesException;
import javax.lang.model.type.TypeMirror;
-
import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/AnnotationValueImpl.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/AnnotationValueImpl.java
index 60d382e1f7..70309383eb 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/AnnotationValueImpl.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/AnnotationValueImpl.java
@@ -18,13 +18,11 @@
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.AnnotationValue;
import javax.lang.model.element.AnnotationValueVisitor;
import javax.lang.model.element.VariableElement;
import javax.lang.model.type.TypeMirror;
-
import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.impl.DoubleConstant;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ArrayTypeImpl.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ArrayTypeImpl.java
index 378c71662f..ba3668030c 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ArrayTypeImpl.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ArrayTypeImpl.java
@@ -20,7 +20,6 @@
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.type.TypeVisitor;
-
import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/DeclaredTypeImpl.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/DeclaredTypeImpl.java
index f1ece38140..78ecf1d8a6 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/DeclaredTypeImpl.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/DeclaredTypeImpl.java
@@ -18,14 +18,12 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.type.TypeVisitor;
-
import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ElementImpl.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ElementImpl.java
index b258002ef8..48050396d2 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ElementImpl.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ElementImpl.java
@@ -18,7 +18,6 @@
import java.util.Collections;
import java.util.List;
import java.util.Set;
-
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
@@ -26,7 +25,6 @@
import javax.lang.model.element.Name;
import javax.lang.model.element.PackageElement;
import javax.lang.model.type.TypeMirror;
-
import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
import org.eclipse.jdt.internal.compiler.lookup.Binding;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ElementsImpl.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ElementsImpl.java
index 20b5173ccc..cf9e91cd18 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ElementsImpl.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ElementsImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2023 BEA Systems, Inc. and others
+ * Copyright (c) 2006, 2024 BEA Systems, Inc. and others
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -29,7 +29,6 @@
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-
import javax.lang.model.SourceVersion;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.AnnotationValue;
@@ -41,7 +40,6 @@
import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.util.Elements;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
@@ -49,19 +47,7 @@
import org.eclipse.jdt.internal.compiler.ast.Javadoc;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
-import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
-import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodVerifier;
-import org.eclipse.jdt.internal.compiler.lookup.ModuleBinding;
-import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TagBits;
-import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
+import org.eclipse.jdt.internal.compiler.lookup.*;
/**
* Utilities for working with java8 and earlier language elements.
@@ -72,7 +58,7 @@
public class ElementsImpl implements Elements {
// Used for parsing Javadoc comments: matches initial delimiter, followed by whitespace
- private static final Pattern INITIAL_DELIMITER = Pattern.compile("^\\s*/\\*+"); //$NON-NLS-1$
+ protected static final Pattern INITIAL_DELIMITER = Pattern.compile("^\\s*/\\*+"); //$NON-NLS-1$
protected final BaseProcessingEnvImpl _env;
@@ -342,7 +328,7 @@ public String getDocComment(Element e) {
* @param e an Element of any sort, possibly with a javadoc comment.
* @return a String, or null if the comment is not available
*/
- private char[] getUnparsedDocComment(Element e)
+ protected char[] getUnparsedDocComment(Element e)
{
Javadoc javadoc = null;
ReferenceContext referenceContext = null;
@@ -402,7 +388,8 @@ private char[] getUnparsedDocComment(Element e)
if (javadoc != null && referenceContext != null) {
char[] contents = referenceContext.compilationResult().getCompilationUnit().getContents();
if (contents != null) {
- return CharOperation.subarray(contents, javadoc.sourceStart, javadoc.sourceEnd - 1);
+ // In case of markdown, the end of line is part of the source range
+ return CharOperation.subarray(contents, javadoc.sourceStart, javadoc.isMarkdown ? javadoc.sourceEnd : javadoc.sourceEnd - 1);
}
}
return null;
@@ -415,7 +402,7 @@ private char[] getUnparsedDocComment(Element e)
* Javac's behavior with regard to tab expansion and trimming of whitespace and
* asterisks is bizarre and undocumented. We do our best here to emulate it.
*/
- private static String formatJavadoc(char[] unparsed)
+ protected static String formatJavadoc(char[] unparsed)
{
if (unparsed == null || unparsed.length < 5) { // delimiters take 5 chars
return null;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ElementsImpl9.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ElementsImpl9.java
index ed97430a69..82481c5a46 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ElementsImpl9.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ElementsImpl9.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2023 BEA Systems, Inc. and others
+ * Copyright (c) 2006, 2024 BEA Systems, Inc. and others
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -21,7 +21,7 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
-
+import java.util.regex.Matcher;
import javax.lang.model.AnnotatedConstruct;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
@@ -32,27 +32,16 @@
import javax.tools.JavaFileManager;
import javax.tools.JavaFileObject;
import javax.tools.JavaFileObject.Kind;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
-import org.eclipse.jdt.internal.compiler.lookup.BinaryModuleBinding;
-import org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ModuleBinding;
-import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.SourceModuleBinding;
-import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TagBits;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
+import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.parser.ScannerHelper;
import org.eclipse.jdt.internal.compiler.tool.EclipseFileManager;
import org.eclipse.jdt.internal.compiler.tool.PathFileObject;
import org.eclipse.jdt.internal.compiler.util.HashtableOfModule;
+import org.eclipse.jdt.internal.compiler.util.TextBlockUtil;
/**
* Utilities for working with java9 language elements.
@@ -304,4 +293,61 @@ public boolean isCompactConstructor(ExecutableElement e) {
MethodBinding methodBinding = (MethodBinding) ((ExecutableElementImpl) e)._binding;
return methodBinding.isCompactConstructor();
}
+ // Must pass a non-null, non-empty char[]
+ private boolean isTraditionalJavadoc(char[] unparsed) {
+ String[] allLines = new String(unparsed).split("\n"); //$NON-NLS-1$
+ Matcher delimiterMatcher = INITIAL_DELIMITER.matcher(allLines[0]);
+ return delimiterMatcher.find();
+ }
+ @Override
+ public String getDocComment(Element e) {
+ char[] unparsed = getUnparsedDocComment(e);
+ if (unparsed == null)
+ return null;
+ if (isTraditionalJavadoc(unparsed)) {
+ // There will be some duplication of sanity checks between
+ // isTraditionalJavadoc() and formatJavadoc()
+ // but will have to live with that.
+ return super.formatJavadoc(unparsed);
+ }
+ // 1. Get the unparsed document content and convert it to individual lines
+ // 2. Remove the /// from each line
+ // 3. Common whitespace after /// in each line is removed
+ // 4. The lines are put together with \n as delimiter and returned
+ char[][] lines = TextBlockUtil.convertTextBlockToLines(unparsed);
+ char[][] contentLines = new char[lines.length][];
+ for (int i = 0; i < lines.length; i++) {
+ char[] cs = lines[i];
+ int slashes = 0;
+ int startIdx = 0;
+ line: for (char c : cs) {
+ startIdx++;
+ switch(c) {
+ case '/':
+ slashes++;
+ if (slashes > 2)
+ break line;
+ break;
+ default:
+ if (!ScannerHelper.isWhitespace(c) || slashes == 3) {
+ break line;
+ }
+ break;
+ }
+ }
+ char[] cs2 = new char[cs.length - startIdx];
+ contentLines[i] = cs2;
+ System.arraycopy(cs, startIdx, cs2, 0, cs2.length);
+ }
+ int textBlockIndent = TextBlockUtil.getWhitespacePrefix(contentLines);
+ char[] formatTextBlock = TextBlockUtil.formatTextBlock(contentLines, textBlockIndent);
+ return new String(formatTextBlock);
+ }
+ @Override
+ public DocCommentKind getDocCommentKind(Element e) {
+ char[] unparsed = getUnparsedDocComment(e);
+ if (unparsed == null)
+ return null;
+ return isTraditionalJavadoc(unparsed) ? DocCommentKind.TRADITIONAL : DocCommentKind.END_OF_LINE;
+ }
}
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ErrorTypeElement.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ErrorTypeElement.java
index a9667e1537..bff6f8b2c9 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ErrorTypeElement.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ErrorTypeElement.java
@@ -19,7 +19,6 @@
import java.util.Collections;
import java.util.List;
import java.util.Set;
-
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
@@ -29,7 +28,6 @@
import javax.lang.model.element.TypeParameterElement;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ErrorTypeImpl.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ErrorTypeImpl.java
index cb4ab934e6..50eebab205 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ErrorTypeImpl.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ErrorTypeImpl.java
@@ -18,14 +18,12 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.type.ErrorType;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.type.TypeVisitor;
-
import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ExecutableElementImpl.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ExecutableElementImpl.java
index b597dfb2b3..8ff0a6dd4b 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ExecutableElementImpl.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ExecutableElementImpl.java
@@ -18,34 +18,13 @@
import java.util.Collections;
import java.util.List;
import java.util.Set;
-
-import javax.lang.model.element.AnnotationValue;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.ElementVisitor;
-import javax.lang.model.element.ExecutableElement;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.Name;
-import javax.lang.model.element.PackageElement;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.element.TypeParameterElement;
-import javax.lang.model.element.VariableElement;
+import javax.lang.model.element.*;
import javax.lang.model.type.TypeMirror;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Argument;
-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
-import org.eclipse.jdt.internal.compiler.lookup.AnnotationHolder;
-import org.eclipse.jdt.internal.compiler.lookup.AptBinaryLocalVariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodVerifier;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.*;
public class ExecutableElementImpl extends ElementImpl implements
ExecutableElement {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ExecutableTypeImpl.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ExecutableTypeImpl.java
index 4beec43887..5958b19672 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ExecutableTypeImpl.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ExecutableTypeImpl.java
@@ -17,13 +17,11 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-
import javax.lang.model.type.ExecutableType;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.type.TypeVariable;
import javax.lang.model.type.TypeVisitor;
-
import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/Factory.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/Factory.java
index 6be4076b79..e99a32406c 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/Factory.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/Factory.java
@@ -25,7 +25,6 @@
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
-
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
@@ -37,28 +36,10 @@
import javax.lang.model.type.NullType;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
-import org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.ElementValuePair;
-import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ModuleBinding;
-import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TagBits;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.VariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.WildcardBinding;
+import org.eclipse.jdt.internal.compiler.lookup.*;
/**
* Creates javax.lang.model wrappers around JDT internal compiler bindings.
@@ -208,14 +189,14 @@ private static void decodeModifiers(Set result, int modifiers, int[] c
try {
appendModifier(result, modifiers, checkBit, Modifier.valueOf("NON_SEALED")); //$NON-NLS-1$
} catch(IllegalArgumentException iae) {
- // Don't have JDK 15, just ignore and proceed.
+ // Don't have JDK 17, just ignore and proceed.
}
break;
case ExtraCompilerModifiers.AccSealed :
try {
appendModifier(result, modifiers, checkBit, Modifier.valueOf("SEALED")); //$NON-NLS-1$
} catch(IllegalArgumentException iae) {
- // Don't have JDK 15, just ignore and proceed.
+ // Don't have JDK 17, just ignore and proceed.
}
break;
}
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/IntersectionTypeImpl.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/IntersectionTypeImpl.java
index 3874f7d4b3..60f0370edc 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/IntersectionTypeImpl.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/IntersectionTypeImpl.java
@@ -14,15 +14,14 @@
package org.eclipse.jdt.internal.compiler.apt.model;
-import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
-import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
-
+import java.util.Arrays;
+import java.util.List;
import javax.lang.model.type.IntersectionType;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.type.TypeVisitor;
-import java.util.Arrays;
-import java.util.List;
+import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
+import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
/**
* Implementation of the WildcardType
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ModuleElementImpl.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ModuleElementImpl.java
index e78f05658f..bb367ba4c1 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ModuleElementImpl.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ModuleElementImpl.java
@@ -14,13 +14,12 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.apt.model;
-import java.util.Arrays;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.ElementVisitor;
@@ -29,7 +28,6 @@
import javax.lang.model.element.Name;
import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement;
-
import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/NoTypeImpl.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/NoTypeImpl.java
index 22294ba7da..35904d9ac5 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/NoTypeImpl.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/NoTypeImpl.java
@@ -18,13 +18,11 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Array;
import java.util.List;
-
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.type.NoType;
import javax.lang.model.type.NullType;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeVisitor;
-
import org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/PackageElementImpl.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/PackageElementImpl.java
index 47f5985e1f..20b1060cd6 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/PackageElementImpl.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/PackageElementImpl.java
@@ -20,13 +20,11 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.ElementVisitor;
import javax.lang.model.element.Name;
import javax.lang.model.element.PackageElement;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
import org.eclipse.jdt.internal.compiler.batch.FileSystem;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/PrimitiveTypeImpl.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/PrimitiveTypeImpl.java
index 4de98969d2..4e8415a44e 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/PrimitiveTypeImpl.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/PrimitiveTypeImpl.java
@@ -18,7 +18,6 @@
import javax.lang.model.type.PrimitiveType;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeVisitor;
-
import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
import org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/RecordComponentElementImpl.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/RecordComponentElementImpl.java
index a86c4df2f3..a1a3618984 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/RecordComponentElementImpl.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/RecordComponentElementImpl.java
@@ -18,7 +18,6 @@
import javax.lang.model.element.ElementVisitor;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.RecordComponentElement;
-
import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
import org.eclipse.jdt.internal.compiler.lookup.RecordComponentBinding;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypeElementImpl.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypeElementImpl.java
index 4212db5f3f..c9faaebb85 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypeElementImpl.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypeElementImpl.java
@@ -19,23 +19,10 @@
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Set;
-
import javax.lang.model.SourceVersion;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.ElementVisitor;
-import javax.lang.model.element.ExecutableElement;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.Name;
-import javax.lang.model.element.NestingKind;
-import javax.lang.model.element.PackageElement;
-import javax.lang.model.element.RecordComponentElement;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.element.TypeParameterElement;
-import javax.lang.model.element.VariableElement;
+import javax.lang.model.element.*;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypeMirrorImpl.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypeMirrorImpl.java
index 9dffc2dd1d..14e9aafe35 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypeMirrorImpl.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypeMirrorImpl.java
@@ -18,12 +18,10 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Array;
import java.util.List;
-
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.type.TypeVisitor;
-
import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
import org.eclipse.jdt.internal.compiler.lookup.Binding;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypeParameterElementImpl.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypeParameterElementImpl.java
index a6502f35b6..069b7c8bcc 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypeParameterElementImpl.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypeParameterElementImpl.java
@@ -22,7 +22,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
@@ -30,7 +29,6 @@
import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeParameterElement;
import javax.lang.model.type.TypeMirror;
-
import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypeVariableImpl.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypeVariableImpl.java
index b4f293f2b4..41bad40403 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypeVariableImpl.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypeVariableImpl.java
@@ -19,7 +19,6 @@
import javax.lang.model.type.TypeMirror;
import javax.lang.model.type.TypeVariable;
import javax.lang.model.type.TypeVisitor;
-
import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypesImpl.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypesImpl.java
index 40c26f8774..1209a6c2b8 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypesImpl.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypesImpl.java
@@ -19,7 +19,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.ArrayType;
@@ -32,20 +31,10 @@
import javax.lang.model.type.TypeMirror;
import javax.lang.model.type.WildcardType;
import javax.lang.model.util.Types;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
import org.eclipse.jdt.internal.compiler.ast.Wildcard;
-import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
-import org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.VariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.*;
/**
* Utilities for working with types (as opposed to elements).
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/VariableElementImpl.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/VariableElementImpl.java
index 826b204a06..8e83eb9cf0 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/VariableElementImpl.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/VariableElementImpl.java
@@ -19,7 +19,6 @@
import java.util.List;
import java.util.Objects;
import java.util.Set;
-
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.ElementVisitor;
@@ -27,7 +26,6 @@
import javax.lang.model.element.Name;
import javax.lang.model.element.PackageElement;
import javax.lang.model.element.VariableElement;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/WildcardTypeImpl.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/WildcardTypeImpl.java
index 31a74593e7..50ac17d625 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/WildcardTypeImpl.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/WildcardTypeImpl.java
@@ -18,7 +18,6 @@
import javax.lang.model.type.TypeMirror;
import javax.lang.model.type.TypeVisitor;
import javax.lang.model.type.WildcardType;
-
import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
import org.eclipse.jdt.internal.compiler.ast.Wildcard;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AND_AND_Expression.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AND_AND_Expression.java
index 4f04e202ef..bf4c0dce1a 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AND_AND_Expression.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AND_AND_Expression.java
@@ -19,10 +19,15 @@
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.impl.*;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.codegen.BranchLabel;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
+import org.eclipse.jdt.internal.compiler.impl.Constant;
+import org.eclipse.jdt.internal.compiler.lookup.Binding;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
/** dedicated treatment for the {@code &&} */
public class AND_AND_Expression extends BinaryExpression {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ASTNode.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
index 88d9f9c877..80050df0af 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
@@ -53,42 +53,14 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.ast.TypeReference.AnnotationPosition;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
-import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
-import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
-import org.eclipse.jdt.internal.compiler.lookup.InferenceContext18;
-import org.eclipse.jdt.internal.compiler.lookup.InvocationSite;
-import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ModuleBinding;
-import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedMethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
-import org.eclipse.jdt.internal.compiler.lookup.RecordComponentBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Scope;
-import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TagBits;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.VariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.WildcardBinding;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.eclipse.jdt.internal.compiler.impl.StringConstant;
+import org.eclipse.jdt.internal.compiler.lookup.*;
@SuppressWarnings({"rawtypes", "unchecked"})
public abstract class ASTNode implements TypeConstants, TypeIds {
@@ -110,7 +82,7 @@ public abstract class ASTNode implements TypeConstants, TypeIds {
public final static int Bit12 = 0x800; // depth (name ref, msg) | operator (operator) | has abstract methods (type decl)
public final static int Bit13 = 0x1000; // depth (name ref, msg) | operator (operator) | is secondary type (type decl)
public final static int Bit14 = 0x2000; // strictly assigned (reference lhs) | discard enclosing instance (explicit constr call) | hasBeenGenerated (type decl)
- public final static int Bit15 = 0x4000; // is unnecessary cast (expression) | is varargs (type ref) | isSubRoutineEscaping (try statement) | superAccess (javadoc allocation expression/javadoc message send/javadoc return statement)
+ public final static int Bit15 = 0x4000; // is unnecessary cast (expression) | is varargs (type ref) | IsFinallyBlockEscaping (try statement) | superAccess (javadoc allocation expression/javadoc message send/javadoc return statement)
public final static int Bit16 = 0x8000; // in javadoc comment (name ref, type ref, msg)
public final static int Bit17 = 0x10000; // compound assigned (reference lhs) | unchecked (msg, alloc, explicit constr call)
public final static int Bit18 = 0x20000; // non null (expression) | onDemand (import reference)
@@ -125,7 +97,7 @@ public abstract class ASTNode implements TypeConstants, TypeIds {
public final static int Bit27 = 0x4000000; // parenthesis count (expression)
public final static int Bit28 = 0x8000000; // parenthesis count (expression)
public final static int Bit29 = 0x10000000; // parenthesis count (expression)
- public final static int Bit30 = 0x20000000; // elseif (if statement) | try block exit (try statement) | fall-through (case statement) | ignore no effect assign (expression ref) | needScope (for statement) | isAnySubRoutineEscaping (return statement) | blockExit (synchronized statement)
+ public final static int Bit30 = 0x20000000; // elseif (if statement) | try block exit (try statement) | fall-through (case statement) | ignore no effect assign (expression ref) | needScope (for statement) | IsAnyFinallyBlockEscaping (return|yield statement) | blockExit (synchronized statement)
public final static int Bit31 = 0x40000000; // local declaration reachable (local decl) | ignore raw type check (type ref) | discard entire assignment (assignment) | isSynchronized (return statement) | thenExit (if statement)
public final static int Bit32 = 0x80000000; // reachable (statement)
@@ -214,7 +186,7 @@ public abstract class ASTNode implements TypeConstants, TypeIds {
// try statements
- public static final int IsSubRoutineEscaping = Bit15;
+ public static final int IsFinallyBlockEscaping = Bit15;
public static final int IsTryBlockExiting = Bit30;
// for type declaration
@@ -307,8 +279,8 @@ public abstract class ASTNode implements TypeConstants, TypeIds {
// for parameterized qualified/single type ref
public static final int DidResolve = Bit19;
- // for return statement
- public static final int IsAnySubRoutineEscaping = Bit30;
+ // for return & yield statements
+ public static final int IsAnyFinallyBlockEscaping = Bit30;
public static final int IsSynchronized = Bit31;
// for synchronized statement
@@ -528,6 +500,8 @@ public final boolean isFieldUseDeprecated(FieldBinding field, Scope scope, int f
// inside same unit - no report
if (scope.isDefinedInSameUnit(field.declaringClass)) return false;
+ if (sinceValueUnreached(field, scope)) return false;
+
// if context is deprecated, may avoid reporting
if (!scope.compilerOptions().reportDeprecationInsideDeprecatedCode && scope.isInsideDeprecatedCode()) return false;
return true;
@@ -578,6 +552,8 @@ public final boolean isMethodUseDeprecated(MethodBinding method, Scope scope,
// inside same unit - no report
if (scope.isDefinedInSameUnit(method.declaringClass)) return false;
+ if (sinceValueUnreached(method, scope)) return false;
+
// non explicit use and non explicitly deprecated - no report
if (!isExplicitUse &&
(method.modifiers & ClassFileConstants.AccDeprecated) == 0) {
@@ -589,6 +565,37 @@ public final boolean isMethodUseDeprecated(MethodBinding method, Scope scope,
return true;
}
+ private boolean sinceValueUnreached(Binding binding, Scope scope) {
+ if (binding instanceof TypeBinding typeBinding) {
+ if (!typeBinding.isReadyForAnnotations()) {
+ return false;
+ }
+ }
+ AnnotationBinding[] annotations = binding.getAnnotations();
+ for (AnnotationBinding annotation : annotations) {
+ if (annotation != null && annotation.getAnnotationType().id == TypeIds.T_JavaLangDeprecated) {
+ ElementValuePair[] pairs = annotation.getElementValuePairs();
+ for (ElementValuePair pair : pairs) {
+ if (CharOperation.equals(pair.getName(), TypeConstants.SINCE)) {
+ if (pair.getValue() instanceof StringConstant strConstant) {
+ try {
+ String value = strConstant.stringValue();
+ long sinceLevel = CompilerOptions.versionToJdkLevel(value);
+ long complianceLevel = scope.compilerOptions().complianceLevel;
+ if (complianceLevel < sinceLevel) {
+ return true;
+ }
+ } catch (NumberFormatException e) {
+ // do nothing and fall through
+ }
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
public boolean isSuper() {
return false;
@@ -649,6 +656,8 @@ public final boolean isTypeUseDeprecated(TypeBinding type, Scope scope) {
// inside same unit - no report
if (scope.isDefinedInSameUnit(refType)) return false;
+ if (sinceValueUnreached(refType, scope)) return false;
+
// if context is deprecated, may avoid reporting
if (!scope.compilerOptions().reportDeprecationInsideDeprecatedCode && scope.isInsideDeprecatedCode()) return false;
return true;
@@ -1066,7 +1075,7 @@ public static void resolveAnnotations(BlockScope scope, Annotation[] sourceAnnot
return annotations;
}
- /** Resolve JSR308 annotations on a type reference, array creation expression or a wildcard. Type parameters go directly to the subroutine,
+ /** Resolve JSR308 annotations on a type reference, array creation expression or a wildcard. Type parameters go directly to the method/ctor,
By construction the bindings associated with QTR, PQTR etc get resolved first and then annotations for different levels get resolved
and applied at one go. Likewise for multidimensional arrays.
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java
index 7b0c1df01b..1105d22466 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java
@@ -30,25 +30,33 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
-import java.util.List;
-
import static org.eclipse.jdt.internal.compiler.lookup.MethodBinding.PARAM_NONNULL;
+import static org.eclipse.jdt.internal.compiler.lookup.MethodBinding.PARAM_NOTOWNING;
import static org.eclipse.jdt.internal.compiler.lookup.MethodBinding.PARAM_NULLABLE;
import static org.eclipse.jdt.internal.compiler.lookup.MethodBinding.PARAM_NULLITY;
import static org.eclipse.jdt.internal.compiler.lookup.MethodBinding.PARAM_OWNING;
-import static org.eclipse.jdt.internal.compiler.lookup.MethodBinding.PARAM_NOTOWNING;
-import org.eclipse.jdt.core.compiler.*;
-import org.eclipse.jdt.internal.compiler.*;
+import java.util.List;
+import org.eclipse.jdt.core.compiler.CategorizedProblem;
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.core.compiler.IProblem;
+import org.eclipse.jdt.internal.compiler.ASTVisitor;
+import org.eclipse.jdt.internal.compiler.ClassFile;
+import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.ast.TypeReference.AnnotationPosition;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
-import org.eclipse.jdt.internal.compiler.impl.*;
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.codegen.*;
+import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
import org.eclipse.jdt.internal.compiler.lookup.*;
-import org.eclipse.jdt.internal.compiler.problem.*;
-import org.eclipse.jdt.internal.compiler.parser.*;
+import org.eclipse.jdt.internal.compiler.parser.Parser;
+import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
+import org.eclipse.jdt.internal.compiler.problem.AbortCompilationUnit;
+import org.eclipse.jdt.internal.compiler.problem.AbortMethod;
+import org.eclipse.jdt.internal.compiler.problem.AbortType;
+import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
+import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
import org.eclipse.jdt.internal.compiler.util.Util;
@SuppressWarnings({"rawtypes"})
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java
index db201eadc1..f711cbc358 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java
@@ -54,15 +54,18 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
-import static org.eclipse.jdt.internal.compiler.ast.ExpressionContext.*;
+import static org.eclipse.jdt.internal.compiler.ast.ExpressionContext.ASSIGNMENT_CONTEXT;
+import static org.eclipse.jdt.internal.compiler.ast.ExpressionContext.INVOCATION_CONTEXT;
+import static org.eclipse.jdt.internal.compiler.ast.ExpressionContext.VANILLA_CONTEXT;
import java.util.HashMap;
-
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.codegen.Opcodes;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.impl.JavaFeature;
@@ -543,7 +546,13 @@ public TypeBinding resolveType(BlockScope scope) {
protected void checkEarlyConstructionContext(BlockScope scope) {
if (JavaFeature.FLEXIBLE_CONSTRUCTOR_BODIES.isSupported(scope.compilerOptions())
&& this.type != null && this.type.resolvedType instanceof ReferenceBinding currentType) {
- TypeBinding uninitialized = scope.getMatchingUninitializedType(currentType, !currentType.isLocalType());
+ // only enclosing types of non-static member types are relevant
+ if (currentType.isStatic() || currentType.isLocalType())
+ return;
+ currentType = currentType.enclosingType();
+ if (currentType == null)
+ return;
+ TypeBinding uninitialized = scope.getMatchingUninitializedType(currentType, true);
if (uninitialized != null)
scope.problemReporter().allocationInEarlyConstructionContext(this, this.resolvedType, uninitialized);
}
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Annotation.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Annotation.java
index b7168a036b..891699de25 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Annotation.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Annotation.java
@@ -40,7 +40,6 @@
package org.eclipse.jdt.internal.compiler.ast;
import java.util.Stack;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ArrayAllocationExpression.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ArrayAllocationExpression.java
index 01b231f4c8..3587bc028e 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ArrayAllocationExpression.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ArrayAllocationExpression.java
@@ -23,13 +23,17 @@
package org.eclipse.jdt.internal.compiler.ast;
import java.util.List;
-
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.impl.*;
import org.eclipse.jdt.internal.compiler.ast.TypeReference.AnnotationCollector;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.codegen.AnnotationContext;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
+import org.eclipse.jdt.internal.compiler.impl.Constant;
+import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.TagBits;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
public class ArrayAllocationExpression extends Expression {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ArrayInitializer.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ArrayInitializer.java
index 5daf55cea1..4ce1dbbad1 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ArrayInitializer.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ArrayInitializer.java
@@ -25,11 +25,14 @@
import static org.eclipse.jdt.internal.compiler.ast.ExpressionContext.ASSIGNMENT_CONTEXT;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.impl.Constant;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
public class ArrayInitializer extends Expression {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ArrayQualifiedTypeReference.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ArrayQualifiedTypeReference.java
index 94d390a9dd..d11dd8da34 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ArrayQualifiedTypeReference.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ArrayQualifiedTypeReference.java
@@ -17,7 +17,11 @@
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
+import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
+import org.eclipse.jdt.internal.compiler.lookup.Scope;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
public class ArrayQualifiedTypeReference extends QualifiedTypeReference {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ArrayTypeReference.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ArrayTypeReference.java
index 4a7cae4e7a..2897c860a3 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ArrayTypeReference.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ArrayTypeReference.java
@@ -18,7 +18,6 @@
package org.eclipse.jdt.internal.compiler.ast;
import java.util.function.Consumer;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java
index ee98c8b742..47bd685370 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java
@@ -18,13 +18,21 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
+import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
+import org.eclipse.jdt.internal.compiler.codegen.BranchLabel;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.codegen.Opcodes;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
+import org.eclipse.jdt.internal.compiler.flow.UnconditionalFlowInfo;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.impl.Constant;
-import org.eclipse.jdt.internal.compiler.lookup.*;
-import org.eclipse.jdt.internal.compiler.ASTVisitor;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
+import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
+import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
public class AssertStatement extends Statement {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Assignment.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Assignment.java
index bc4535a153..b4e389a319 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Assignment.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Assignment.java
@@ -39,11 +39,20 @@
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.impl.Constant;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.lookup.Binding;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
+import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TagBits;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
+import org.eclipse.jdt.internal.compiler.lookup.VariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.WildcardBinding;
public class Assignment extends Expression {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/BinaryExpression.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/BinaryExpression.java
index c3064de12b..b1b9fb8316 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/BinaryExpression.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/BinaryExpression.java
@@ -17,13 +17,18 @@
package org.eclipse.jdt.internal.compiler.ast;
import java.util.List;
-
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.impl.*;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.codegen.BranchLabel;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
+import org.eclipse.jdt.internal.compiler.impl.Constant;
+import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
public class BinaryExpression extends OperatorExpression {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Block.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Block.java
index 00ef6de2f0..9601579da2 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Block.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Block.java
@@ -21,10 +21,13 @@
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
+import org.eclipse.jdt.internal.compiler.codegen.BranchLabel;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
public class Block extends Statement {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/BranchStatement.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/BranchStatement.java
index 59522dfa93..60542a47aa 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/BranchStatement.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/BranchStatement.java
@@ -13,14 +13,15 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.codegen.BranchLabel;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
public abstract class BranchStatement extends Statement {
public char[] label;
public BranchLabel targetLabel;
- public SubRoutineStatement[] subroutines;
+ public StatementWithFinallyBlock[] statementsWithFinallyBlock;
public int initStateIndex = -1;
/**
@@ -32,12 +33,6 @@ public BranchStatement(char[] label, int sourceStart,int sourceEnd) {
this.sourceEnd = sourceEnd;
}
-protected void setSubroutineSwitchExpression(SubRoutineStatement sub) {
- // Do nothing
-}
-protected void restartExceptionLabels(CodeStream codeStream) {
- // do nothing
-}
/**
* Branch code generation
*
@@ -52,21 +47,17 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream) {
// generation of code responsible for invoking the finally
// blocks in sequence
- if (this.subroutines != null){
- for (int i = 0, max = this.subroutines.length; i < max; i++){
- SubRoutineStatement sub = this.subroutines[i];
- SwitchExpression se = sub.getSwitchExpression();
- setSubroutineSwitchExpression(sub);
- boolean didEscape = sub.generateSubRoutineInvocation(currentScope, codeStream, this.targetLabel, this.initStateIndex, null);
- sub.setSwitchExpression(se);
+ if (this.statementsWithFinallyBlock != null){
+ for (int i = 0, max = this.statementsWithFinallyBlock.length; i < max; i++){
+ StatementWithFinallyBlock stmt = this.statementsWithFinallyBlock[i];
+ boolean didEscape = stmt.generateFinallyBlock(currentScope, codeStream, this.targetLabel, this.initStateIndex);
if (didEscape) {
codeStream.recordPositionsFrom(pc, this.sourceStart);
- SubRoutineStatement.reenterAllExceptionHandlers(this.subroutines, i, codeStream);
+ StatementWithFinallyBlock.reenterAllExceptionHandlers(this.statementsWithFinallyBlock, i, codeStream);
if (this.initStateIndex != -1) {
codeStream.removeNotDefinitelyAssignedVariables(currentScope, this.initStateIndex);
codeStream.addDefinitelyAssignedVariables(currentScope, this.initStateIndex);
}
- restartExceptionLabels(codeStream);
return;
}
}
@@ -74,7 +65,7 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream) {
// checkAndLoadSyntheticVars(codeStream);
codeStream.goto_(this.targetLabel);
codeStream.recordPositionsFrom(pc, this.sourceStart);
- SubRoutineStatement.reenterAllExceptionHandlers(this.subroutines, -1, codeStream);
+ StatementWithFinallyBlock.reenterAllExceptionHandlers(this.statementsWithFinallyBlock, -1, codeStream);
if (this.initStateIndex != -1) {
codeStream.removeNotDefinitelyAssignedVariables(currentScope, this.initStateIndex);
codeStream.addDefinitelyAssignedVariables(currentScope, this.initStateIndex);
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/BreakStatement.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/BreakStatement.java
index 7ae2388128..265de6f170 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/BreakStatement.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/BreakStatement.java
@@ -16,8 +16,10 @@
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.flow.*;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
+import org.eclipse.jdt.internal.compiler.flow.InsideStatementWithFinallyBlockFlowContext;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
public class BreakStatement extends BranchStatement {
@@ -44,7 +46,7 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
}
return flowInfo; // pretend it did not break since no actual target
} else if (targetContext == FlowContext.NonLocalGotoThroughSwitchContext) { // JLS 13 14.15
- currentScope.problemReporter().switchExpressionsBreakOutOfSwitchExpression(this);
+ currentScope.problemReporter().breakOutOfSwitchExpression(this);
return flowInfo; // pretend it did not break since no actual target
}
@@ -56,39 +58,38 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
this.targetLabel = targetContext.breakLabel();
FlowContext traversedContext = flowContext;
- int subCount = 0;
- this.subroutines = new SubRoutineStatement[5];
+ int stmtCount = 0;
+ this.statementsWithFinallyBlock = new StatementWithFinallyBlock[5];
do {
- SubRoutineStatement sub;
- if ((sub = traversedContext.subroutine()) != null) {
- if (subCount == this.subroutines.length) {
- System.arraycopy(this.subroutines, 0, (this.subroutines = new SubRoutineStatement[subCount*2]), 0, subCount); // grow
+ StatementWithFinallyBlock stmt;
+ if ((stmt = traversedContext.statementWithFinallyBlock()) != null) {
+ if (stmtCount == this.statementsWithFinallyBlock.length) {
+ System.arraycopy(this.statementsWithFinallyBlock, 0, (this.statementsWithFinallyBlock = new StatementWithFinallyBlock[stmtCount*2]), 0, stmtCount); // grow
}
- this.subroutines[subCount++] = sub;
- if (sub.isSubRoutineEscaping()) {
+ this.statementsWithFinallyBlock[stmtCount++] = stmt;
+ if (stmt.isFinallyBlockEscaping()) {
break;
}
}
traversedContext.recordReturnFrom(flowInfo.unconditionalInits());
traversedContext.recordBreakTo(targetContext);
- if (traversedContext instanceof InsideSubRoutineFlowContext) {
+ if (traversedContext instanceof InsideStatementWithFinallyBlockFlowContext) {
ASTNode node = traversedContext.associatedNode;
if (node instanceof TryStatement) {
TryStatement tryStatement = (TryStatement) node;
- flowInfo.addInitializationsFrom(tryStatement.subRoutineInits); // collect inits
+ flowInfo.addInitializationsFrom(tryStatement.finallyBlockInits); // collect inits
}
} else if (traversedContext == targetContext) {
- // only record break info once accumulated through subroutines, and only against target context
+ // only record break info once accumulated, and only against target context
targetContext.recordBreakFrom(flowInfo);
break;
}
} while ((traversedContext = traversedContext.getLocalParent()) != null);
- // resize subroutines
- if (subCount != this.subroutines.length) {
- System.arraycopy(this.subroutines, 0, (this.subroutines = new SubRoutineStatement[subCount]), 0, subCount);
+ if (stmtCount != this.statementsWithFinallyBlock.length) {
+ System.arraycopy(this.statementsWithFinallyBlock, 0, (this.statementsWithFinallyBlock = new StatementWithFinallyBlock[stmtCount]), 0, stmtCount);
}
return FlowInfo.DEAD_END;
}
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CaseStatement.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CaseStatement.java
index 5a18d8c809..5836da042d 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CaseStatement.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CaseStatement.java
@@ -17,7 +17,6 @@
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;
-
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.ast.Pattern.PrimitiveConversionRoute;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
@@ -44,7 +43,7 @@ public class CaseStatement extends Statement {
public BranchLabel targetLabel;
public Expression[] constantExpressions; // case with multiple expressions - if you want a under-the-hood view, use peeledLabelExpressions()
public BranchLabel[] targetLabels; // for multiple expressions
- public boolean isExpr = false;
+ public boolean isSwitchRule = false;
public SwitchStatement swich; // owning switch
public int typeSwitchIndex; // for the first pattern among this.constantExpressions
@@ -75,11 +74,16 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
int nullPatternCount = 0;
for (int i = 0, length = this.constantExpressions.length; i < length; i++) {
Expression e = this.constantExpressions[i];
- for (LocalVariableBinding local : e.bindingsWhenTrue()) {
- local.useFlag = LocalVariableBinding.USED; // these are structurally required even if not touched
+ CompilerOptions compilerOptions = currentScope.compilerOptions();
+ long sourceLevel = compilerOptions.sourceLevel;
+ boolean enablePreviewFeatures = compilerOptions.enablePreviewFeatures;
+ if (!JavaFeature.UNNAMMED_PATTERNS_AND_VARS.isSupported(sourceLevel, enablePreviewFeatures)) {
+ for (LocalVariableBinding local : e.bindingsWhenTrue()) {
+ local.useFlag = LocalVariableBinding.USED; // these are structurally required even if not touched
+ }
}
nullPatternCount += e instanceof NullLiteral ? 1 : 0;
- if (i > 0 && (e instanceof Pattern) && !JavaFeature.UNNAMMED_PATTERNS_AND_VARS.isSupported(currentScope.compilerOptions().sourceLevel, currentScope.compilerOptions().enablePreviewFeatures)) {
+ if (i > 0 && (e instanceof Pattern) && !JavaFeature.UNNAMMED_PATTERNS_AND_VARS.isSupported(sourceLevel, enablePreviewFeatures)) {
if (!(i == nullPatternCount && e instanceof TypePattern))
currentScope.problemReporter().IllegalFallThroughToPattern(e);
}
@@ -173,6 +177,16 @@ public String toString() {
*/
public ResolvedCase[] resolveCase(BlockScope scope, TypeBinding switchExpressionType, SwitchStatement switchStatement) {
this.swich = switchStatement;
+
+ if (this.isSwitchRule)
+ this.swich.switchBits |= SwitchStatement.LabeledRules;
+ else
+ this.swich.switchBits |= SwitchStatement.LabeledBlockStatementGroup;
+
+ if ((this.swich.switchBits & (SwitchStatement.LabeledRules | SwitchStatement.LabeledBlockStatementGroup)) == (SwitchStatement.LabeledRules | SwitchStatement.LabeledBlockStatementGroup)) {
+ scope.problemReporter().arrowColonMixup(this);
+ }
+
scope.enclosingCase = this; // record entering in a switch case block
if (this.constantExpressions == Expression.NO_EXPRESSIONS) {
checkDuplicateDefault(scope, switchStatement, this);
@@ -367,6 +381,8 @@ private Constant resolveCasePattern(BlockScope scope, TypeBinding caseType, Type
if (type != null) {
constant = IntConstant.fromValue(switchStatement.constantIndex);
switchStatement.caseLabelElements.add(e);
+ if (e instanceof RecordPattern)
+ switchStatement.containsRecordPatterns = true;
if (isUnguarded)
switchStatement.caseLabelElementTypes.add(type);
@@ -375,11 +391,8 @@ private Constant resolveCasePattern(BlockScope scope, TypeBinding caseType, Type
// The following code is copied from InstanceOfExpression#resolve()
// But there are enough differences to warrant a copy
if (!type.isReifiable()) {
- if (expressionType != TypeBinding.NULL && !(e instanceof RecordPattern)) {
- boolean isLegal = e.checkCastTypesCompatibility(scope, type, expressionType, e, false);
- if (!isLegal || (e.bits & ASTNode.UnsafeCast) != 0) {
- scope.problemReporter().unsafeCastInInstanceof(e, type, expressionType);
- }
+ if (!e.isApplicable(switchExpressionType, scope, e)) {
+ return Constant.NotAConstant;
}
} else if (type.isValidBinding()) {
// if not a valid binding, an error has already been reported for unresolved type
@@ -458,16 +471,15 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream) {
public StringBuilder printStatement(int tab, StringBuilder output) {
printIndent(tab, output);
if (this.constantExpressions == Expression.NO_EXPRESSIONS) {
- output.append("default "); //$NON-NLS-1$
- output.append(this.isExpr ? "->" : ":"); //$NON-NLS-1$ //$NON-NLS-2$
+ output.append("default"); //$NON-NLS-1$
} else {
output.append("case "); //$NON-NLS-1$
for (int i = 0, l = this.constantExpressions.length; i < l; ++i) {
this.constantExpressions[i].printExpression(0, output);
if (i < l -1) output.append(',');
}
- output.append(this.isExpr ? " ->" : " :"); //$NON-NLS-1$ //$NON-NLS-2$
}
+ output.append(this.isSwitchRule ? " ->" : " :"); //$NON-NLS-1$ //$NON-NLS-2$
return output;
}
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CastExpression.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CastExpression.java
index d425e13d8a..c6c6ebf3ed 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CastExpression.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CastExpression.java
@@ -41,22 +41,7 @@
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.impl.IrritantSet;
-import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.lookup.InferenceContext18;
-import org.eclipse.jdt.internal.compiler.lookup.InvocationSite;
-import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.PolymorphicMethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Scope;
-import org.eclipse.jdt.internal.compiler.lookup.TagBits;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
+import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
public class CastExpression extends Expression {
@@ -445,24 +430,21 @@ public static boolean checkUnsafeCast(Expression expression, Scope scope, TypeBi
ParameterizedTypeBinding paramCastType = (ParameterizedTypeBinding) castType;
TypeBinding[] castArguments = paramCastType.arguments;
int length = castArguments == null ? 0 : castArguments.length;
- if ((paramCastType.tagBits & (TagBits.HasDirectWildcard|TagBits.HasTypeVariable)) != 0) {
- // verify alternate cast type, substituting different type arguments
- for (int i = 0; i < length; i++) {
- if (castArguments[i].isUnboundWildcard())
- continue;
- TypeBinding[] alternateArguments;
- // need to clone for each iteration to avoid env paramtype cache interference
- System.arraycopy(paramCastType.arguments, 0, alternateArguments = new TypeBinding[length], 0, length);
- alternateArguments[i] = TypeBinding.equalsEquals(paramCastType.arguments[i], scope.getJavaLangObject()) ? scope.getJavaLangBoolean() : scope.getJavaLangObject();
- LookupEnvironment environment = scope.environment();
- ParameterizedTypeBinding alternateCastType = environment.createParameterizedType((ReferenceBinding)castType.erasure(), alternateArguments, castType.enclosingType());
- if (TypeBinding.equalsEquals(alternateCastType.findSuperTypeOriginatingFrom(expressionType), match)) {
- expression.bits |= ASTNode.UnsafeCast;
- break;
- }
+ // verify alternate cast type, substituting different type arguments
+ for (int i = 0; i < length; i++) {
+ if (castArguments[i].isUnboundWildcard())
+ continue;
+ TypeBinding[] alternateArguments;
+ // need to clone for each iteration to avoid env paramtype cache interference
+ System.arraycopy(paramCastType.arguments, 0, alternateArguments = new TypeBinding[length], 0, length);
+ alternateArguments[i] = TypeBinding.equalsEquals(paramCastType.arguments[i], scope.getJavaLangObject()) ? scope.getJavaLangBoolean() : scope.getJavaLangObject();
+ LookupEnvironment environment = scope.environment();
+ ParameterizedTypeBinding alternateCastType = environment.createParameterizedType((ReferenceBinding)castType.erasure(), alternateArguments, castType.enclosingType());
+ if (TypeBinding.equalsEquals(alternateCastType.findSuperTypeOriginatingFrom(expressionType), match)) {
+ expression.bits |= ASTNode.UnsafeCast;
+ break;
}
}
-
// Type arguments added by subtypes of S and removed by supertypes of T don't need to be checked since the type arguments aren't specified by either S or T
return true;
} else {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CharLiteral.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CharLiteral.java
index 6d1846b63e..a28256ece8 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CharLiteral.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CharLiteral.java
@@ -14,9 +14,10 @@
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.impl.*;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.impl.CharConstant;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
import org.eclipse.jdt.internal.compiler.parser.ScannerHelper;
public class CharLiteral extends NumberLiteral {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ClassLiteralAccess.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ClassLiteralAccess.java
index a51c5e257d..5cc009d515 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ClassLiteralAccess.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ClassLiteralAccess.java
@@ -15,10 +15,18 @@
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.Constant;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
+import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
+import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
+import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
public class ClassLiteralAccess extends Expression {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CombinedBinaryExpression.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CombinedBinaryExpression.java
index 5431c0e501..9d795453ad 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CombinedBinaryExpression.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CombinedBinaryExpression.java
@@ -16,7 +16,6 @@
package org.eclipse.jdt.internal.compiler.ast;
import java.util.List;
-
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CompactConstructorDeclaration.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CompactConstructorDeclaration.java
index c2f8b6a347..50babeea63 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CompactConstructorDeclaration.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CompactConstructorDeclaration.java
@@ -14,7 +14,6 @@
import java.util.ArrayList;
import java.util.List;
-
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java
index 95b75ee731..3131f56b75 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java
@@ -25,7 +25,6 @@
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
-
import org.eclipse.jdt.core.compiler.CategorizedProblem;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.compiler.IProblem;
@@ -39,16 +38,7 @@
import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.impl.IrritantSet;
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
-import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
-import org.eclipse.jdt.internal.compiler.lookup.ImportBinding;
-import org.eclipse.jdt.internal.compiler.lookup.LocalTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
-import org.eclipse.jdt.internal.compiler.lookup.ModuleBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Scope;
-import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
+import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.lookup.Substitution.NullSubstitution;
import org.eclipse.jdt.internal.compiler.parser.NLSTag;
import org.eclipse.jdt.internal.compiler.problem.AbortCompilationUnit;
@@ -187,6 +177,7 @@ public void cleanUp() {
if (this.scope != null)
this.scope.cleanUpInferenceContexts();
+ this.compilationResult.releaseContent();
}
private void cleanUp(TypeDeclaration type) {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CompoundAssignment.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CompoundAssignment.java
index b390ca578a..e3231a81b2 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CompoundAssignment.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CompoundAssignment.java
@@ -21,10 +21,14 @@
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.Constant;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
public class CompoundAssignment extends Assignment implements OperatorIds {
public int operator;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java
index a607cc5102..f887e4d997 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java
@@ -31,14 +31,27 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
-import static org.eclipse.jdt.internal.compiler.ast.ExpressionContext.*;
+import static org.eclipse.jdt.internal.compiler.ast.ExpressionContext.ASSIGNMENT_CONTEXT;
+import static org.eclipse.jdt.internal.compiler.ast.ExpressionContext.INVOCATION_CONTEXT;
+import static org.eclipse.jdt.internal.compiler.ast.ExpressionContext.VANILLA_CONTEXT;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.impl.*;
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.codegen.BranchLabel;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
+import org.eclipse.jdt.internal.compiler.flow.UnconditionalFlowInfo;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.eclipse.jdt.internal.compiler.impl.Constant;
+import org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.Binding;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
+import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
+import org.eclipse.jdt.internal.compiler.lookup.PolyTypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.Scope;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
public class ConditionalExpression extends OperatorExpression implements IPolyExpression {
@@ -61,7 +74,6 @@ public class ConditionalExpression extends OperatorExpression implements IPolyEx
private boolean isPolyExpression = false;
private TypeBinding originalValueIfTrueType;
private TypeBinding originalValueIfFalseType;
- private boolean use18specifics;
public ConditionalExpression(Expression condition, Expression valueIfTrue, Expression valueIfFalse) {
this.condition = condition;
@@ -317,10 +329,12 @@ public void generateCode(
// End of if statement
endifLabel.place();
}
- if (this.valueIfFalse.resolvedType == TypeBinding.NULL) {
- if (!this.resolvedType.isBaseType()) {
- codeStream.operandStack.pop(TypeBinding.NULL);
- codeStream.operandStack.push(this.resolvedType);
+ if (valueRequired) {
+ if (this.valueIfFalse.resolvedType == TypeBinding.NULL) {
+ if (!this.resolvedType.isBaseType()) {
+ codeStream.operandStack.pop(TypeBinding.NULL);
+ codeStream.operandStack.push(this.resolvedType);
+ }
}
}
}
@@ -457,17 +471,11 @@ public StringBuilder printExpressionNoParenthesis(int indent, StringBuilder outp
public TypeBinding resolveType(BlockScope scope) {
// JLS3 15.25
LookupEnvironment env = scope.environment();
- final long sourceLevel = scope.compilerOptions().sourceLevel;
- boolean use15specifics = sourceLevel >= ClassFileConstants.JDK1_5;
- this.use18specifics = sourceLevel >= ClassFileConstants.JDK1_8;
-
- if (this.use18specifics) {
- if (this.expressionContext == ASSIGNMENT_CONTEXT || this.expressionContext == INVOCATION_CONTEXT) {
- this.valueIfTrue.setExpressionContext(this.expressionContext);
- this.valueIfTrue.setExpectedType(this.expectedType);
- this.valueIfFalse.setExpressionContext(this.expressionContext);
- this.valueIfFalse.setExpectedType(this.expectedType);
- }
+ if (this.expressionContext == ASSIGNMENT_CONTEXT || this.expressionContext == INVOCATION_CONTEXT) {
+ this.valueIfTrue.setExpressionContext(this.expressionContext);
+ this.valueIfTrue.setExpectedType(this.expectedType);
+ this.valueIfFalse.setExpressionContext(this.expressionContext);
+ this.valueIfFalse.setExpectedType(this.expectedType);
}
if (this.constant != Constant.NotAConstant) {
@@ -519,28 +527,17 @@ public TypeBinding resolveType(BlockScope scope) {
if (this.originalValueIfFalseType == null || !this.originalValueIfFalseType.isValidBinding())
return this.resolvedType = null;
}
- // Propagate the constant value from the valueIfTrue and valueIFFalse expression if it is possible
- Constant condConstant, trueConstant, falseConstant;
- if ((condConstant = this.condition.constant) != Constant.NotAConstant
- && (trueConstant = this.valueIfTrue.constant) != Constant.NotAConstant
- && (falseConstant = this.valueIfFalse.constant) != Constant.NotAConstant) {
- // all terms are constant expression so we can propagate the constant
- // from valueIFTrue or valueIfFalse to the receiver constant
- this.constant = condConstant.booleanValue() ? trueConstant : falseConstant;
- }
if (isPolyExpression()) {
if (this.expectedType == null || !this.expectedType.isProperType(true)) {
- // We will be back here in case of a PolyTypeBinding. So, to enable
- // further processing, set it back to default.
- this.constant = Constant.NotAConstant;
return new PolyTypeBinding(this);
}
+ constantFold();
return this.resolvedType = computeConversions(scope, this.expectedType) ? this.expectedType : null;
}
TypeBinding valueIfTrueType = this.originalValueIfTrueType;
TypeBinding valueIfFalseType = this.originalValueIfFalseType;
- if (use15specifics && TypeBinding.notEquals(valueIfTrueType, valueIfFalseType)) {
+ if (TypeBinding.notEquals(valueIfTrueType, valueIfFalseType)) {
if (valueIfTrueType.isBaseType()) {
if (valueIfFalseType.isBaseType()) {
// bool ? baseType : baseType
@@ -576,6 +573,8 @@ public TypeBinding resolveType(BlockScope scope) {
}
}
}
+ constantFold();
+ Constant condConstant;
if (TypeBinding.equalsEquals(valueIfTrueType, valueIfFalseType)) { // harmed the implicit conversion
this.valueIfTrue.computeConversion(scope, valueIfTrueType, this.originalValueIfTrueType);
this.valueIfFalse.computeConversion(scope, valueIfFalseType, this.originalValueIfFalseType);
@@ -651,48 +650,27 @@ public TypeBinding resolveType(BlockScope scope) {
}
// Type references (null null is already tested)
if (valueIfTrueType.isBaseType() && valueIfTrueType != TypeBinding.NULL) {
- if (use15specifics) {
- valueIfTrueType = env.computeBoxingType(valueIfTrueType);
- } else {
- scope.problemReporter().conditionalArgumentsIncompatibleTypes(this, valueIfTrueType, valueIfFalseType);
- return null;
- }
+ valueIfTrueType = env.computeBoxingType(valueIfTrueType);
}
if (valueIfFalseType.isBaseType() && valueIfFalseType != TypeBinding.NULL) {
- if (use15specifics) {
- valueIfFalseType = env.computeBoxingType(valueIfFalseType);
- } else {
- scope.problemReporter().conditionalArgumentsIncompatibleTypes(this, valueIfTrueType, valueIfFalseType);
- return null;
- }
+ valueIfFalseType = env.computeBoxingType(valueIfFalseType);
}
- if (use15specifics) {
- // >= 1.5 : LUB(operand types) must exist
- TypeBinding commonType = null;
- if (valueIfTrueType == TypeBinding.NULL) {
- commonType = valueIfFalseType.withoutToplevelNullAnnotation(); // null on other branch invalidates any @NonNull
- } else if (valueIfFalseType == TypeBinding.NULL) {
- commonType = valueIfTrueType.withoutToplevelNullAnnotation(); // null on other branch invalidates any @NonNull
- } else {
- commonType = scope.lowerUpperBound(new TypeBinding[] { valueIfTrueType, valueIfFalseType });
- }
- if (commonType != null) {
- this.valueIfTrue.computeConversion(scope, commonType, this.originalValueIfTrueType);
- this.valueIfFalse.computeConversion(scope, commonType, this.originalValueIfFalseType);
- return this.resolvedType = commonType.capture(scope, this.sourceStart, this.sourceEnd);
- }
+
+ // >= 1.5 : LUB(operand types) must exist
+ TypeBinding commonType = null;
+ if (valueIfTrueType == TypeBinding.NULL) {
+ commonType = valueIfFalseType.withoutToplevelNullAnnotation(); // null on other branch invalidates any @NonNull
+ } else if (valueIfFalseType == TypeBinding.NULL) {
+ commonType = valueIfTrueType.withoutToplevelNullAnnotation(); // null on other branch invalidates any @NonNull
} else {
- // < 1.5 : one operand must be convertible to the other
- if (valueIfFalseType.isCompatibleWith(valueIfTrueType)) {
- this.valueIfTrue.computeConversion(scope, valueIfTrueType, this.originalValueIfTrueType);
- this.valueIfFalse.computeConversion(scope, valueIfTrueType, this.originalValueIfFalseType);
- return this.resolvedType = valueIfTrueType;
- } else if (valueIfTrueType.isCompatibleWith(valueIfFalseType)) {
- this.valueIfTrue.computeConversion(scope, valueIfFalseType, this.originalValueIfTrueType);
- this.valueIfFalse.computeConversion(scope, valueIfFalseType, this.originalValueIfFalseType);
- return this.resolvedType = valueIfFalseType;
- }
+ commonType = scope.lowerUpperBound(new TypeBinding[] { valueIfTrueType, valueIfFalseType });
}
+ if (commonType != null) {
+ this.valueIfTrue.computeConversion(scope, commonType, this.originalValueIfTrueType);
+ this.valueIfFalse.computeConversion(scope, commonType, this.originalValueIfFalseType);
+ return this.resolvedType = commonType.capture(scope, this.sourceStart, this.sourceEnd);
+ }
+
scope.problemReporter().conditionalArgumentsIncompatibleTypes(
this,
valueIfTrueType,
@@ -700,6 +678,18 @@ public TypeBinding resolveType(BlockScope scope) {
return null;
}
+ private void constantFold() {
+ // Propagate the constant value from the valueIfTrue and valueIFFalse expression if it is possible
+ Constant condConstant, trueConstant, falseConstant;
+ if ((condConstant = this.condition.constant) != Constant.NotAConstant
+ && (trueConstant = this.valueIfTrue.constant) != Constant.NotAConstant
+ && (falseConstant = this.valueIfFalse.constant) != Constant.NotAConstant) {
+ // all terms are constant expression so we can propagate the constant
+ // from valueIFTrue or valueIfFalse to the receiver constant
+ this.constant = condConstant.booleanValue() ? trueConstant : falseConstant;
+ }
+ }
+
protected boolean computeConversions(BlockScope scope, TypeBinding targetType) {
boolean ok = true;
if (this.originalValueIfTrueType != null && this.originalValueIfTrueType.isValidBinding()) {
@@ -800,9 +790,6 @@ public boolean isFunctionalType() {
@Override
public boolean isPolyExpression() throws UnsupportedOperationException {
- if (!this.use18specifics)
- return false;
-
if (this.isPolyExpression)
return true;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java
index 13bf3cc7e9..f0e048f592 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java
@@ -32,18 +32,28 @@
import java.util.ArrayList;
import java.util.List;
-
-import org.eclipse.jdt.core.compiler.*;
-import org.eclipse.jdt.internal.compiler.*;
+import org.eclipse.jdt.core.compiler.CategorizedProblem;
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.core.compiler.IProblem;
+import org.eclipse.jdt.internal.compiler.ASTVisitor;
+import org.eclipse.jdt.internal.compiler.ClassFile;
+import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.ast.TypeReference.AnnotationCollector;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.codegen.Opcodes;
+import org.eclipse.jdt.internal.compiler.codegen.StackMapFrameCodeStream;
+import org.eclipse.jdt.internal.compiler.flow.ExceptionHandlingFlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
+import org.eclipse.jdt.internal.compiler.flow.InitializationFlowContext;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.impl.JavaFeature;
import org.eclipse.jdt.internal.compiler.lookup.*;
-import org.eclipse.jdt.internal.compiler.parser.*;
-import org.eclipse.jdt.internal.compiler.problem.*;
+import org.eclipse.jdt.internal.compiler.parser.Parser;
+import org.eclipse.jdt.internal.compiler.problem.AbortMethod;
+import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
+import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
import org.eclipse.jdt.internal.compiler.util.Util;
@SuppressWarnings({"rawtypes", "unchecked"})
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ContinueStatement.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ContinueStatement.java
index d39b297b42..4e439c0c39 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ContinueStatement.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ContinueStatement.java
@@ -16,8 +16,10 @@
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.flow.*;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
+import org.eclipse.jdt.internal.compiler.flow.InsideStatementWithFinallyBlockFlowContext;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
public class ContinueStatement extends BranchStatement {
@@ -44,7 +46,7 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
}
return flowInfo; // pretend it did not continue since no actual target
} else if (targetContext == FlowContext.NonLocalGotoThroughSwitchContext) {
- currentScope.problemReporter().switchExpressionsContinueOutOfSwitchExpression(this);
+ currentScope.problemReporter().continueOutOfSwitchExpression(this);
return flowInfo; // pretend it did not continue since no actual target
}
@@ -60,38 +62,37 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
this.targetLabel = targetContext.continueLabel();
FlowContext traversedContext = flowContext;
- int subCount = 0;
- this.subroutines = new SubRoutineStatement[5];
+ int stmtCount = 0;
+ this.statementsWithFinallyBlock = new StatementWithFinallyBlock[5];
do {
- SubRoutineStatement sub;
- if ((sub = traversedContext.subroutine()) != null) {
- if (subCount == this.subroutines.length) {
- System.arraycopy(this.subroutines, 0, this.subroutines = new SubRoutineStatement[subCount*2], 0, subCount); // grow
+ StatementWithFinallyBlock stmt;
+ if ((stmt = traversedContext.statementWithFinallyBlock()) != null) {
+ if (stmtCount == this.statementsWithFinallyBlock.length) {
+ System.arraycopy(this.statementsWithFinallyBlock, 0, this.statementsWithFinallyBlock = new StatementWithFinallyBlock[stmtCount*2], 0, stmtCount); // grow
}
- this.subroutines[subCount++] = sub;
- if (sub.isSubRoutineEscaping()) {
+ this.statementsWithFinallyBlock[stmtCount++] = stmt;
+ if (stmt.isFinallyBlockEscaping()) {
break;
}
}
traversedContext.recordReturnFrom(flowInfo.unconditionalInits());
- if (traversedContext instanceof InsideSubRoutineFlowContext) {
+ if (traversedContext instanceof InsideStatementWithFinallyBlockFlowContext) {
ASTNode node = traversedContext.associatedNode;
if (node instanceof TryStatement) {
TryStatement tryStatement = (TryStatement) node;
- flowInfo.addInitializationsFrom(tryStatement.subRoutineInits); // collect inits
+ flowInfo.addInitializationsFrom(tryStatement.finallyBlockInits); // collect inits
}
} else if (traversedContext == targetContext) {
- // only record continue info once accumulated through subroutines, and only against target context
+ // only record continue info once accumulated and only against target context
targetContext.recordContinueFrom(flowContext, flowInfo);
break;
}
} while ((traversedContext = traversedContext.getLocalParent()) != null);
- // resize subroutines
- if (subCount != this.subroutines.length) {
- System.arraycopy(this.subroutines, 0, this.subroutines = new SubRoutineStatement[subCount], 0, subCount);
+ if (stmtCount != this.statementsWithFinallyBlock.length) {
+ System.arraycopy(this.statementsWithFinallyBlock, 0, this.statementsWithFinallyBlock = new StatementWithFinallyBlock[stmtCount], 0, stmtCount);
}
return FlowInfo.DEAD_END;
}
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/DoStatement.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/DoStatement.java
index 38534c6ea1..b46771256c 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/DoStatement.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/DoStatement.java
@@ -19,10 +19,17 @@
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.impl.*;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.codegen.BranchLabel;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
+import org.eclipse.jdt.internal.compiler.flow.LoopingFlowContext;
+import org.eclipse.jdt.internal.compiler.flow.UnconditionalFlowInfo;
+import org.eclipse.jdt.internal.compiler.impl.Constant;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
public class DoStatement extends Statement {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/DoubleLiteral.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/DoubleLiteral.java
index 87c58ad519..d493a3852f 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/DoubleLiteral.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/DoubleLiteral.java
@@ -15,9 +15,10 @@
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.impl.*;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.impl.DoubleConstant;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
import org.eclipse.jdt.internal.compiler.util.FloatUtil;
public class DoubleLiteral extends NumberLiteral {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/EitherOrMultiPattern.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/EitherOrMultiPattern.java
index 9d4e81fe9b..8ef74f12e1 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/EitherOrMultiPattern.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/EitherOrMultiPattern.java
@@ -54,6 +54,13 @@ public void setIsGuarded() {
this.patterns[i].setIsGuarded();
}
+ @Override
+ public void setOuterExpressionType(TypeBinding expressionType) {
+ super.setOuterExpressionType(expressionType);
+ for (int i = 0; i < this.patternsCount; i++)
+ this.patterns[i].setOuterExpressionType(expressionType);
+ }
+
@Override
public TypeBinding resolveType(BlockScope scope) {
boolean hasError = false;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/EmptyStatement.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/EmptyStatement.java
index 19762f3aac..0f9931140e 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/EmptyStatement.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/EmptyStatement.java
@@ -14,12 +14,12 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
-import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
-import org.eclipse.jdt.internal.compiler.ASTVisitor;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
public class EmptyStatement extends Statement {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java
index 2231ddf745..e6daf6c30b 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java
@@ -20,11 +20,23 @@
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.impl.*;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.codegen.BranchLabel;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
+import org.eclipse.jdt.internal.compiler.flow.UnconditionalFlowInfo;
+import org.eclipse.jdt.internal.compiler.impl.BooleanConstant;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.eclipse.jdt.internal.compiler.impl.Constant;
+import org.eclipse.jdt.internal.compiler.lookup.Binding;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
+import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.Scope;
+import org.eclipse.jdt.internal.compiler.lookup.TagBits;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
public class EqualExpression extends BinaryExpression {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java
index 15f4ce3913..0822132c48 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java
@@ -36,7 +36,6 @@
import static org.eclipse.jdt.internal.compiler.ast.ExpressionContext.INVOCATION_CONTEXT;
import java.util.Arrays;
-
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
@@ -44,25 +43,7 @@
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.JavaFeature;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
-import org.eclipse.jdt.internal.compiler.lookup.InferenceContext18;
-import org.eclipse.jdt.internal.compiler.lookup.LocalTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedMethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.RawTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Scope;
-import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TagBits;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-import org.eclipse.jdt.internal.compiler.lookup.VariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.*;
public class ExplicitConstructorCall extends Statement implements Invocation {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Expression.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Expression.java
index 5307deb2fe..d95d8055b6 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Expression.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Expression.java
@@ -36,7 +36,6 @@
import java.util.ArrayList;
import java.util.List;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
@@ -46,24 +45,7 @@
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
-import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
-import org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
-import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
-import org.eclipse.jdt.internal.compiler.lookup.InferenceContext18;
-import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Scope;
-import org.eclipse.jdt.internal.compiler.lookup.TagBits;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.VariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.WildcardBinding;
+import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.problem.ShouldNotImplement;
import org.eclipse.jdt.internal.compiler.util.Messages;
@@ -262,6 +244,10 @@ protected void updateFlowOnBooleanResult(FlowInfo flowInfo, boolean result) {
// nop
}
+public boolean hasSideEffects() {
+ return (this.constant == Constant.NotAConstant || (this.implicitConversion & TypeIds.BOXING) != 0) && !(this instanceof NullLiteral);
+}
+
/**
* Returns false if cast is not legal.
*/
@@ -1118,6 +1104,10 @@ public StringBuilder print(int indent, StringBuilder output) {
public abstract StringBuilder printExpression(int indent, StringBuilder output);
+public StringBuilder printExpression(int tab, StringBuilder output, boolean makeShort) {
+ return printExpression(tab, output);
+}
+
@Override
public StringBuilder printStatement(int indent, StringBuilder output) {
return print(indent, output).append(";"); //$NON-NLS-1$
@@ -1254,7 +1244,7 @@ public boolean forcedToBeRaw(ReferenceContext referenceContext) {
}
} else if (this instanceof SwitchExpression) {
SwitchExpression se = (SwitchExpression) this;
- for (Expression e : se.resultExpressions) {
+ for (Expression e : se.resultExpressions()) {
if (e.forcedToBeRaw(referenceContext))
return true;
}
@@ -1264,7 +1254,7 @@ public boolean forcedToBeRaw(ReferenceContext referenceContext) {
/**
* Returns an object which can be used to identify identical JSR sequence targets
- * (see TryStatement subroutine codegen)
+ * (see TryStatement finally block codegen)
* or null
if not reusable
*/
public Object reusableJSRTarget() {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FakeDefaultLiteral.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FakeDefaultLiteral.java
index 7199c2a9e7..84e6d7a648 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FakeDefaultLiteral.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FakeDefaultLiteral.java
@@ -14,7 +14,8 @@
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.impl.Constant;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
/**
* Sole purpose of {@link FakeDefaultLiteral} is to appear
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FakedTrackingVariable.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FakedTrackingVariable.java
index aadcde5a57..bf9055eb85 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FakedTrackingVariable.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FakedTrackingVariable.java
@@ -23,7 +23,6 @@
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Function;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.CompilationResult;
@@ -34,18 +33,7 @@
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
-import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Scope;
-import org.eclipse.jdt.internal.compiler.lookup.TagBits;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
+import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
import org.eclipse.jdt.internal.compiler.util.Util;
@@ -253,7 +241,7 @@ else if (expression instanceof ConditionalExpression) {
return getMoreUnsafeFromBranches((ConditionalExpression)expression, flowInfo,
branch -> getCloseTrackingVariable(branch, flowInfo, flowContext, useAnnotations));
} else if (expression instanceof SwitchExpression) {
- for (Expression re : ((SwitchExpression) expression).resultExpressions) {
+ for (Expression re : ((SwitchExpression) expression).resultExpressions()) {
FakedTrackingVariable fakedTrackingVariable = getCloseTrackingVariable(re, flowInfo, flowContext, useAnnotations);
if (fakedTrackingVariable != null) {
return fakedTrackingVariable;
@@ -356,7 +344,7 @@ public static FakedTrackingVariable preConnectTrackerAcrossAssignment(ASTNode lo
}
private static boolean containsAllocation(SwitchExpression location) {
- for (Expression re : location.resultExpressions) {
+ for (Expression re : location.resultExpressions()) {
if (containsAllocation(re))
return true;
}
@@ -403,7 +391,7 @@ private static void preConnectTrackerAcrossAssignment(ASTNode location, LocalVar
private static void preConnectTrackerAcrossAssignment(ASTNode location, LocalVariableBinding local, FlowInfo flowInfo,
SwitchExpression se, FakedTrackingVariable closeTracker, boolean useAnnotations) {
- for (Expression re : se.resultExpressions) {
+ for (Expression re : se.resultExpressions()) {
preConnectTrackerAcrossAssignment(location, local, flowInfo, closeTracker, re, useAnnotations);
}
}
@@ -899,7 +887,7 @@ else if (expression instanceof CastExpression)
local, location, branch, previousTracker));
} else if (expression instanceof SwitchExpression) {
FakedTrackingVariable mostRisky = null;
- for (Expression result : ((SwitchExpression) expression).resultExpressions) {
+ for (Expression result : ((SwitchExpression) expression).resultExpressions()) {
FakedTrackingVariable current = analyseCloseableExpression(scope, flowInfo, flowContext, useAnnotations,
local, location, result, previousTracker);
if (mostRisky == null)
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java
index db24805a2e..014d8c055e 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java
@@ -23,17 +23,20 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
-import java.util.List;
-
import static org.eclipse.jdt.internal.compiler.ast.ExpressionContext.ASSIGNMENT_CONTEXT;
+import java.util.List;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.impl.*;
import org.eclipse.jdt.internal.compiler.ast.TypeReference.AnnotationCollector;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
+import org.eclipse.jdt.internal.compiler.codegen.AnnotationContext;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.codegen.Opcodes;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FieldReference.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FieldReference.java
index 459934f1e0..75a590585e 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FieldReference.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FieldReference.java
@@ -32,25 +32,7 @@
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.Constant;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
-import org.eclipse.jdt.internal.compiler.lookup.InferenceContext18;
-import org.eclipse.jdt.internal.compiler.lookup.InvocationSite;
-import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
-import org.eclipse.jdt.internal.compiler.lookup.MissingTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemFieldBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Scope;
-import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TagBits;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-import org.eclipse.jdt.internal.compiler.lookup.VariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.*;
public class FieldReference extends Reference implements InvocationSite {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java
index bc67511959..be4f819fdd 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java
@@ -36,21 +36,7 @@
import org.eclipse.jdt.internal.compiler.flow.LoopingFlowContext;
import org.eclipse.jdt.internal.compiler.flow.UnconditionalFlowInfo;
import org.eclipse.jdt.internal.compiler.impl.Constant;
-import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.lookup.CaptureBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ImplicitNullAnnotationVerifier;
-import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TagBits;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
+import org.eclipse.jdt.internal.compiler.lookup.*;
public class ForeachStatement extends Statement {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FunctionalExpression.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FunctionalExpression.java
index 0d83b07baa..3789ec43e5 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FunctionalExpression.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FunctionalExpression.java
@@ -36,22 +36,7 @@
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
-import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
-import org.eclipse.jdt.internal.compiler.lookup.IntersectionTypeBinding18;
-import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
-import org.eclipse.jdt.internal.compiler.lookup.MethodVerifier;
-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
-import org.eclipse.jdt.internal.compiler.lookup.RawTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Scope;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBindingVisitor;
-import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.*;
public abstract class FunctionalExpression extends Expression {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/GuardedPattern.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/GuardedPattern.java
index a4317e9c06..47e6f2b846 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/GuardedPattern.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/GuardedPattern.java
@@ -76,6 +76,12 @@ public void setIsEitherOrPattern() {
this.primaryPattern.setIsEitherOrPattern();
}
+ @Override
+ public void setOuterExpressionType(TypeBinding expressionType) {
+ super.setOuterExpressionType(expressionType);
+ this.primaryPattern.setOuterExpressionType(expressionType);
+ }
+
@Override
public boolean coversType(TypeBinding type, Scope scope) {
return isUnguarded() && this.primaryPattern.coversType(type, scope);
@@ -130,7 +136,7 @@ public void traverse(ASTVisitor visitor, BlockScope scope) {
}
@Override
- protected boolean isApplicable(TypeBinding other, BlockScope scope) {
- return this.primaryPattern.isApplicable(other, scope);
+ protected boolean isApplicable(TypeBinding expressionType, BlockScope scope, ASTNode location) {
+ return this.primaryPattern.isApplicable(expressionType, scope, location);
}
}
\ No newline at end of file
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/IPolyExpression.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/IPolyExpression.java
index ce05e75055..23484a9fae 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/IPolyExpression.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/IPolyExpression.java
@@ -40,6 +40,7 @@ public interface IPolyExpression {
// Target type injection.
public void setExpectedType(TypeBinding targetType);
public TypeBinding invocationTargetType();
+ public TypeBinding expectedType();
// Compatibility checks.
public boolean isPotentiallyCompatibleWith(TypeBinding targetType, Scope scope);
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/IfStatement.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/IfStatement.java
index 9a266ec811..3091758ec6 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/IfStatement.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/IfStatement.java
@@ -20,10 +20,15 @@
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.impl.*;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.codegen.BranchLabel;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
+import org.eclipse.jdt.internal.compiler.impl.Constant;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
+import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
public class IfStatement extends Statement {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ImplicitTypeDeclaration.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ImplicitTypeDeclaration.java
index 3636a37e95..9400bf4dc5 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ImplicitTypeDeclaration.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ImplicitTypeDeclaration.java
@@ -13,7 +13,6 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.stream.Stream;
-
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ImportReference.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ImportReference.java
index 0de446aced..b6ce1f7712 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ImportReference.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ImportReference.java
@@ -15,11 +15,13 @@
import java.util.HashSet;
import java.util.Set;
-
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
+import org.eclipse.jdt.internal.compiler.lookup.ModuleBinding;
+import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
+import org.eclipse.jdt.internal.compiler.lookup.SplitPackageBinding;
public class ImportReference extends ASTNode {
@@ -33,7 +35,6 @@ public class ImportReference extends ASTNode {
public Annotation[] annotations;
// star end position
public int trailingStarPosition;
- public boolean implicit;
public ImportReference(
char[][] tokens,
@@ -58,9 +59,6 @@ public boolean isStatic() {
public char[][] getImportName() {
return this.tokens;
}
- public boolean isImplicit() {
- return this.implicit;
- }
public char[] getSimpleName() {
return this.tokens[this.tokens.length - 1];
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Initializer.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Initializer.java
index 90c7e46742..34457eb36e 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Initializer.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Initializer.java
@@ -18,10 +18,18 @@
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
-import org.eclipse.jdt.internal.compiler.lookup.*;
-import org.eclipse.jdt.internal.compiler.parser.*;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
+import org.eclipse.jdt.internal.compiler.lookup.Binding;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
+import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
+import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
+import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
+import org.eclipse.jdt.internal.compiler.lookup.Scope;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
+import org.eclipse.jdt.internal.compiler.parser.Parser;
public class Initializer extends FieldDeclaration {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java
index 490fecd919..60fd0e9a6e 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java
@@ -25,18 +25,25 @@
package org.eclipse.jdt.internal.compiler.ast;
import java.util.stream.Stream;
-
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.ast.Pattern.PrimitiveConversionRoute;
import org.eclipse.jdt.internal.compiler.ast.Pattern.TestContextRecord;
import org.eclipse.jdt.internal.compiler.ast.TypeReference.AnnotationPosition;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
+import org.eclipse.jdt.internal.compiler.codegen.BranchLabel;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.impl.JavaFeature;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.lookup.Binding;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
+import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.Scope;
+import org.eclipse.jdt.internal.compiler.lookup.TagBits;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
public class InstanceOfExpression extends OperatorExpression implements IGenerateTypeCheck {
@@ -270,6 +277,13 @@ public TypeBinding resolveType(BlockScope scope) {
if (expressionType == null || checkedType == null)
return null;
+ if (this.pattern != null) {
+ if (this.pattern.isApplicable(expressionType, scope, this)) {
+ checkForPrimitives(scope, checkedType, expressionType);
+ }
+ return this.resolvedType = TypeBinding.BOOLEAN;
+ }
+
if (!checkedType.isReifiable()) {
CompilerOptions options = scope.compilerOptions();
// Report same as before for older compliances
@@ -279,7 +293,7 @@ public TypeBinding resolveType(BlockScope scope) {
if (expressionType != TypeBinding.NULL) {
boolean isLegal = checkCastTypesCompatibility(scope, checkedType, expressionType, this.expression, true);
if (!isLegal || (this.bits & ASTNode.UnsafeCast) != 0) {
- scope.problemReporter().unsafeCastInInstanceof(this.expression, checkedType, expressionType);
+ scope.problemReporter().unsafeCastInTestingContext(this.expression, checkedType, expressionType);
} else {
checkRefForPrimitivesAndAddSecretVariable(scope, checkedType, expressionType);
}
@@ -287,17 +301,18 @@ public TypeBinding resolveType(BlockScope scope) {
}
} else if (checkedType.isValidBinding()) {
// if not a valid binding, an error has already been reported for unresolved type
- if ((expressionType != TypeBinding.NULL && expressionType.isBaseType()) // disallow autoboxing
- || checkedType.isBaseType()
- || !checkCastTypesCompatibility(scope, checkedType, expressionType, null, true)) {
- checkForPrimitives(scope, checkedType, expressionType);
- }
+ checkForPrimitives(scope, checkedType, expressionType);
}
return this.resolvedType = TypeBinding.BOOLEAN;
}
private void checkForPrimitives(BlockScope scope, TypeBinding checkedType, TypeBinding expressionType) {
+ boolean needToCheck = (expressionType != TypeBinding.NULL && expressionType.isBaseType()) // disallow autoboxing
+ || checkedType.isBaseType()
+ || !checkCastTypesCompatibility(scope, checkedType, expressionType, null, true);
+ if (!needToCheck)
+ return;
PrimitiveConversionRoute route = Pattern.findPrimitiveConversionRoute(checkedType, expressionType, scope);
this.testContextRecord = new TestContextRecord(checkedType, expressionType, route);
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/IntLiteralMinValue.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/IntLiteralMinValue.java
index 5dfed33eee..c70d81428c 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/IntLiteralMinValue.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/IntLiteralMinValue.java
@@ -13,7 +13,7 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
-import org.eclipse.jdt.internal.compiler.impl.*;
+import org.eclipse.jdt.internal.compiler.impl.IntConstant;
public class IntLiteralMinValue extends IntLiteral {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/IntersectionCastTypeReference.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/IntersectionCastTypeReference.java
index 9cb8ab99bc..0c530f8f74 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/IntersectionCastTypeReference.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/IntersectionCastTypeReference.java
@@ -19,7 +19,6 @@
import java.util.HashMap;
import java.util.Map;
-
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocArgumentExpression.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocArgumentExpression.java
index de95a42bff..f239d3e407 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocArgumentExpression.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocArgumentExpression.java
@@ -16,7 +16,10 @@
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.impl.Constant;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
+import org.eclipse.jdt.internal.compiler.lookup.Scope;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
public class JavadocArgumentExpression extends Expression {
public char[] token;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocImplicitTypeReference.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocImplicitTypeReference.java
index 384916a2c9..1c4440ea03 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocImplicitTypeReference.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocImplicitTypeReference.java
@@ -17,7 +17,12 @@
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.impl.Constant;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
+import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
+import org.eclipse.jdt.internal.compiler.lookup.Scope;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
public class JavadocImplicitTypeReference extends TypeReference {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java
index 71cd1be4b8..b8caed35c5 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java
@@ -16,7 +16,15 @@
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.impl.Constant;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
+import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
+import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding;
+import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
+import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
+import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
+import org.eclipse.jdt.internal.compiler.lookup.Scope;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
public class JavadocMessageSend extends MessageSend {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocReturnStatement.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocReturnStatement.java
index 36e1867073..b57c87623d 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocReturnStatement.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocReturnStatement.java
@@ -14,7 +14,11 @@
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
+import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
+import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
public class JavadocReturnStatement extends ReturnStatement {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocSingleNameReference.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocSingleNameReference.java
index a59e0a28e9..77b514ffa1 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocSingleNameReference.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocSingleNameReference.java
@@ -14,7 +14,11 @@
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
+import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
+import org.eclipse.jdt.internal.compiler.lookup.TagBits;
public class JavadocSingleNameReference extends SingleNameReference {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocSingleTypeReference.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocSingleTypeReference.java
index f5ca09aeb4..5650bc43cc 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocSingleTypeReference.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocSingleTypeReference.java
@@ -17,17 +17,7 @@
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.impl.Constant;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
-import org.eclipse.jdt.internal.compiler.lookup.LocalTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ModuleBinding;
-import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Scope;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.*;
public class JavadocSingleTypeReference extends SingleTypeReference implements IJavadocTypeReference {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/LabeledStatement.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/LabeledStatement.java
index 6facbe19cf..682dc0249e 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/LabeledStatement.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/LabeledStatement.java
@@ -14,9 +14,13 @@
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.codegen.BranchLabel;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
+import org.eclipse.jdt.internal.compiler.flow.LabelFlowContext;
+import org.eclipse.jdt.internal.compiler.flow.UnconditionalFlowInfo;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
public class LabeledStatement extends Statement {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java
index 69d847dcb1..a03184f714 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java
@@ -55,7 +55,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-
import org.eclipse.jdt.core.compiler.CategorizedProblem;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
@@ -72,36 +71,9 @@
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
-import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
-import org.eclipse.jdt.internal.compiler.lookup.InferenceContext18;
-import org.eclipse.jdt.internal.compiler.lookup.IntersectionTypeBinding18;
-import org.eclipse.jdt.internal.compiler.lookup.LocalTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.PolyTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Scope;
-import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Substitution;
-import org.eclipse.jdt.internal.compiler.lookup.Substitution.NullSubstitution;
-import org.eclipse.jdt.internal.compiler.lookup.SyntheticArgumentBinding;
-import org.eclipse.jdt.internal.compiler.lookup.SyntheticMethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TagBits;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-import org.eclipse.jdt.internal.compiler.lookup.WildcardBinding;
+import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.lookup.Scope.Substitutor;
+import org.eclipse.jdt.internal.compiler.lookup.Substitution.NullSubstitution;
import org.eclipse.jdt.internal.compiler.parser.Parser;
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
import org.eclipse.jdt.internal.compiler.problem.AbortCompilationUnit;
@@ -763,6 +735,7 @@ public StringBuilder printExpression(int tab, StringBuilder output) {
return printExpression(tab, output, false);
}
+ @Override
public StringBuilder printExpression(int tab, StringBuilder output, boolean makeShort) {
int parenthesesCount = (this.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
String suffix = ""; //$NON-NLS-1$
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Literal.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Literal.java
index 97357678a3..ce952e4fe1 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Literal.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Literal.java
@@ -15,8 +15,9 @@
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
-import org.eclipse.jdt.internal.compiler.impl.*;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.impl.Constant;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
public abstract class Literal extends Expression {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java
index a6192e74d7..a9d08ee11f 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java
@@ -245,7 +245,7 @@ private static Expression findPolyExpression(Expression e) {
}
if (e instanceof SwitchExpression) {
SwitchExpression se = (SwitchExpression)e;
- for (Expression re : se.resultExpressions) {
+ for (Expression re : se.resultExpressions()) {
Expression candidate = findPolyExpression(re);
if (candidate != null) return candidate;
}
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/LongLiteralMinValue.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/LongLiteralMinValue.java
index 183ca98d2b..c687a35ffa 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/LongLiteralMinValue.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/LongLiteralMinValue.java
@@ -13,7 +13,7 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
-import org.eclipse.jdt.internal.compiler.impl.*;
+import org.eclipse.jdt.internal.compiler.impl.LongConstant;
public class LongLiteralMinValue extends LongLiteral {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/MarkerAnnotation.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/MarkerAnnotation.java
index a86cd21b94..ed0e138be5 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/MarkerAnnotation.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/MarkerAnnotation.java
@@ -20,7 +20,8 @@
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
public class MarkerAnnotation extends Annotation {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/MessageSend.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/MessageSend.java
index b967f5ec25..7932215dd1 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/MessageSend.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/MessageSend.java
@@ -71,7 +71,6 @@
import java.util.HashMap;
import java.util.function.BiConsumer;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
@@ -85,37 +84,7 @@
import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.impl.IrritantSet;
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
-import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
-import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ImplicitNullAnnotationVerifier;
-import org.eclipse.jdt.internal.compiler.lookup.InferenceContext18;
-import org.eclipse.jdt.internal.compiler.lookup.InferenceVariable;
-import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodVerifier;
-import org.eclipse.jdt.internal.compiler.lookup.MissingTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedMethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.PolyParameterizedGenericMethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.PolyTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.PolymorphicMethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.RawTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Scope;
-import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TagBits;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable;
@@ -343,7 +312,7 @@ private void yieldQualifiedCheck(BlockScope currentScope) {
return;
if (!CharOperation.equals(this.selector, TypeConstants.YIELD))
return;
- currentScope.problemReporter().switchExpressionsYieldUnqualifiedMethodError(this);
+ currentScope.problemReporter().unqualifiedYieldMethod(this);
}
private void recordCallingClose(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo, Expression closeTarget) {
if (closeTarget.isThis() || closeTarget.isSuper()) {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java
index 4300189585..8bf053f810 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java
@@ -31,7 +31,6 @@
import java.util.List;
import java.util.function.BiPredicate;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.CompilationResult;
@@ -42,18 +41,7 @@
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
-import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
-import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
-import org.eclipse.jdt.internal.compiler.lookup.LocalTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MemberTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TagBits;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.parser.Parser;
import org.eclipse.jdt.internal.compiler.problem.AbortMethod;
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ModuleDeclaration.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ModuleDeclaration.java
index 5d6a595a90..44f567bafc 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ModuleDeclaration.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ModuleDeclaration.java
@@ -14,14 +14,15 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
-import static org.eclipse.jdt.internal.compiler.problem.ProblemSeverities.*;
+import static org.eclipse.jdt.internal.compiler.problem.ProblemSeverities.AbortCompilation;
+import static org.eclipse.jdt.internal.compiler.problem.ProblemSeverities.AbortCompilationUnit;
+import static org.eclipse.jdt.internal.compiler.problem.ProblemSeverities.AbortMethod;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-
import org.eclipse.jdt.core.compiler.CategorizedProblem;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.compiler.IProblem;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/NameReference.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/NameReference.java
index 1ed8cf0eed..30af219c9e 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/NameReference.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/NameReference.java
@@ -20,11 +20,18 @@
package org.eclipse.jdt.internal.compiler.ast;
import java.util.function.Predicate;
-
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
import org.eclipse.jdt.internal.compiler.impl.Constant;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.lookup.Binding;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
+import org.eclipse.jdt.internal.compiler.lookup.InferenceContext18;
+import org.eclipse.jdt.internal.compiler.lookup.InvocationSite;
+import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
+import org.eclipse.jdt.internal.compiler.lookup.Scope;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.VariableBinding;
import org.eclipse.jdt.internal.compiler.problem.AbortMethod;
public abstract class NameReference extends Reference implements InvocationSite {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/NormalAnnotation.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/NormalAnnotation.java
index e1a8a7dbf4..be3b75a887 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/NormalAnnotation.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/NormalAnnotation.java
@@ -14,7 +14,10 @@
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.lookup.Binding;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
+import org.eclipse.jdt.internal.compiler.lookup.ElementValuePair;
/**
* Normal annotation node
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/NullAnnotationMatching.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/NullAnnotationMatching.java
index 051cea830b..53015ed9e7 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/NullAnnotationMatching.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/NullAnnotationMatching.java
@@ -19,30 +19,8 @@
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
-import org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.ExternalAnnotationStatus;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.lookup.CaptureBinding;
-import org.eclipse.jdt.internal.compiler.lookup.InvocationSite;
-import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
-import org.eclipse.jdt.internal.compiler.lookup.RawTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Scope;
-import org.eclipse.jdt.internal.compiler.lookup.Substitution;
-import org.eclipse.jdt.internal.compiler.lookup.TagBits;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBindingVisitor;
-import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.VariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.WildcardBinding;
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
/**
@@ -178,7 +156,7 @@ public static int checkAssignment(BlockScope currentScope, FlowContext flowConte
} else if (expression instanceof SwitchExpression && expression.isPolyExpression()) {
// drill into all the branches:
SwitchExpression se = ((SwitchExpression) expression);
- Expression[] resExprs = se.resultExpressions.toArray(new Expression[0]);
+ Expression[] resExprs = se.resultExpressions().toArray(new Expression[0]);
Expression re = resExprs[0];
int status0 = NullAnnotationMatching.checkAssignment(currentScope, flowContext, var, flowInfo, re.nullStatus(flowInfo, flowContext), re, re.resolvedType);
boolean identicalStatus = true;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/NullLiteral.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/NullLiteral.java
index 7ea8ca3660..97ab14148f 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/NullLiteral.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/NullLiteral.java
@@ -16,11 +16,12 @@
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.codegen.*;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.Constant;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
public class NullLiteral extends MagicLiteral {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/OR_OR_Expression.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/OR_OR_Expression.java
index 603b1ceda3..d355d4fe4d 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/OR_OR_Expression.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/OR_OR_Expression.java
@@ -20,10 +20,16 @@
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.impl.*;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.codegen.BranchLabel;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
+import org.eclipse.jdt.internal.compiler.flow.UnconditionalFlowInfo;
+import org.eclipse.jdt.internal.compiler.impl.Constant;
+import org.eclipse.jdt.internal.compiler.lookup.Binding;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
//dedicated treatment for the ||
public class OR_OR_Expression extends BinaryExpression {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Pattern.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Pattern.java
index f07c01e55a..15d3fdad80 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Pattern.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Pattern.java
@@ -139,25 +139,37 @@ public TypeReference getType() {
}
// 14.30.3 Properties of Patterns: A pattern p is said to be applicable at a type T if ...
- protected boolean isApplicable(TypeBinding other, BlockScope scope) {
- TypeBinding patternType = this.resolvedType;
- if (patternType == null) // ill resolved pattern
- return false;
+ protected boolean isApplicable(TypeBinding expressionType, BlockScope scope, ASTNode location) {
+ if (expressionType == TypeBinding.NULL)
+ return true;
+ TypeReference typeRef = getType();
+ if (typeRef == null)
+ return true; // nothing to be checked for wildcard '_'
+ TypeBinding patternType = typeRef.resolvedType;
+ if (patternType == null || !patternType.isValidBinding() || !expressionType.isValidBinding())
+ return false; // problem already reported
+
// 14.30.3 Properties of Patterns doesn't allow boxing nor unboxing, primitive widening/narrowing (< JLS23)
- if (patternType.isBaseType() != other.isBaseType() && !JavaFeature.PRIMITIVES_IN_PATTERNS.isSupported(scope.compilerOptions())) {
- scope.problemReporter().incompatiblePatternType(this, other, patternType);
+ if (patternType.isBaseType() != expressionType.isBaseType() && !JavaFeature.PRIMITIVES_IN_PATTERNS.isSupported(scope.compilerOptions())) {
+ scope.problemReporter().notCompatibleTypesError(location, expressionType, patternType);
return false;
}
if (patternType.isBaseType()) {
PrimitiveConversionRoute route = Pattern.findPrimitiveConversionRoute(this.resolvedType, this.outerExpressionType, scope);
- if (!TypeBinding.equalsEquals(other, patternType)
+ if (!TypeBinding.equalsEquals(expressionType, patternType)
&& route == PrimitiveConversionRoute.NO_CONVERSION_ROUTE) {
- scope.problemReporter().incompatiblePatternType(this, other, patternType);
+ scope.problemReporter().notCompatibleTypesError(location, expressionType, patternType);
+ return false;
+ }
+ } else {
+ if (!checkCastTypesCompatibility(scope, patternType, expressionType, null, true)) {
+ scope.problemReporter().notCompatibleTypesError(location, expressionType, patternType);
+ return false;
+ }
+ if ((this.bits & ASTNode.UnsafeCast) != 0) {
+ scope.problemReporter().unsafeCastInTestingContext(location, patternType, this.outerExpressionType);
return false;
}
- } else if (!checkCastTypesCompatibility(scope, other, patternType, null, true)) {
- scope.problemReporter().incompatiblePatternType(this, other, patternType);
- return false;
}
return true;
}
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/PostfixExpression.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/PostfixExpression.java
index 8fcee0f1b1..fde6e2f02c 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/PostfixExpression.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/PostfixExpression.java
@@ -14,8 +14,8 @@
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
public class PostfixExpression extends CompoundAssignment {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/PrefixExpression.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/PrefixExpression.java
index 1702d9c86d..a73f3f7a45 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/PrefixExpression.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/PrefixExpression.java
@@ -14,7 +14,7 @@
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
public class PrefixExpression extends CompoundAssignment {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ProvidesStatement.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ProvidesStatement.java
index ef1d80783f..146b24a43f 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ProvidesStatement.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ProvidesStatement.java
@@ -17,7 +17,6 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java
index a3052713f0..74b00f54ab 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java
@@ -40,7 +40,6 @@
import static org.eclipse.jdt.internal.compiler.ast.ExpressionContext.INVOCATION_CONTEXT;
import java.util.Arrays;
-
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
@@ -49,29 +48,7 @@
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.impl.Constant;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
-import org.eclipse.jdt.internal.compiler.lookup.ImplicitNullAnnotationVerifier;
-import org.eclipse.jdt.internal.compiler.lookup.IntersectionTypeBinding18;
-import org.eclipse.jdt.internal.compiler.lookup.LocalTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.PolyTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.RawTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Scope;
-import org.eclipse.jdt.internal.compiler.lookup.TagBits;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBindingVisitor;
-import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.*;
/**
* Variation on allocation, where can optionally be specified any of:
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java
index 6ac930ce8e..be86df1435 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java
@@ -37,25 +37,7 @@
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.impl.Constant;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
-import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
-import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
-import org.eclipse.jdt.internal.compiler.lookup.MissingTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemFieldBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Scope;
-import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.SyntheticMethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TagBits;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-import org.eclipse.jdt.internal.compiler.lookup.VariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
public class QualifiedNameReference extends NameReference {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/QualifiedSuperReference.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/QualifiedSuperReference.java
index d747e21bfc..04f2649ec6 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/QualifiedSuperReference.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/QualifiedSuperReference.java
@@ -74,8 +74,13 @@ public TypeBinding resolveType(BlockScope scope) {
ReferenceBinding enclosingReceiverType = scope.enclosingReceiverType();
// interface-qualified this selects a default method in a super interface,
// but here we are only interested in supers of *enclosing instances*:
- if (enclosingReceiverType != null && !enclosingReceiverType.isInterface() && scope.isInsideEarlyConstructionContext(enclosingReceiverType, false))
- scope.problemReporter().errorExpressionInEarlyConstructionContext(this);
+ if (enclosingReceiverType != null && !enclosingReceiverType.isInterface()) {
+ TypeBinding typeToCheck = (enclosingReceiverType.isCompatibleWith(this.resolvedType))
+ ? enclosingReceiverType // cannot reference super of the current type
+ : this.resolvedType; // assumeably not a super but an outer type
+ if (scope.isInsideEarlyConstructionContext(typeToCheck, false))
+ scope.problemReporter().errorExpressionInEarlyConstructionContext(this);
+ }
return this.resolvedType = (this.currentCompatibleType.isInterface()
? this.currentCompatibleType
: this.currentCompatibleType.superclass());
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/QualifiedThisReference.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/QualifiedThisReference.java
index c9951c4091..0aecf21390 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/QualifiedThisReference.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/QualifiedThisReference.java
@@ -20,11 +20,17 @@
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.impl.JavaFeature;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
+import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
+import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
+import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
public class QualifiedThisReference extends ThisReference {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/RecordComponent.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/RecordComponent.java
index dde93ffb9a..34e234a810 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/RecordComponent.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/RecordComponent.java
@@ -17,9 +17,17 @@
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.ast.TypeReference.AnnotationCollector;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.codegen.AnnotationContext;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
+import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
+import org.eclipse.jdt.internal.compiler.lookup.RecordComponentBinding;
+import org.eclipse.jdt.internal.compiler.lookup.SyntheticMethodBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TagBits;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
public class RecordComponent extends AbstractVariableDeclaration {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/RecordPattern.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/RecordPattern.java
index e0e222faca..637d5687d7 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/RecordPattern.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/RecordPattern.java
@@ -152,7 +152,7 @@ public TypeBinding resolveType(BlockScope scope) {
}
}
TypeBinding componentType = componentBinding.type;
- if (p1.isApplicable(componentType, scope)) {
+ if (p1.isApplicable(componentType, scope, p1)) {
p1.isTotalTypeNode = p1.coversType(componentType, scope);
MethodBinding[] methods = this.resolvedType.getMethods(componentBinding.name);
if (methods != null && methods.length > 0) {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Reference.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Reference.java
index 708204c358..1412bd9d90 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Reference.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Reference.java
@@ -28,16 +28,7 @@
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.impl.JavaFeature;
-import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
-import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
-import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
-import org.eclipse.jdt.internal.compiler.lookup.Scope;
-import org.eclipse.jdt.internal.compiler.lookup.TagBits;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
+import org.eclipse.jdt.internal.compiler.lookup.*;
public abstract class Reference extends Expression {
/**
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java
index ee73869bd2..0b75c348bf 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java
@@ -66,33 +66,7 @@
import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.impl.IrritantSet;
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
-import org.eclipse.jdt.internal.compiler.lookup.ImplicitNullAnnotationVerifier;
-import org.eclipse.jdt.internal.compiler.lookup.InferenceContext18;
-import org.eclipse.jdt.internal.compiler.lookup.InvocationSite;
-import org.eclipse.jdt.internal.compiler.lookup.LocalTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedMethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.PolyTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Scope;
-import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.SyntheticArgumentBinding;
-import org.eclipse.jdt.internal.compiler.lookup.SyntheticMethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TagBits;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.parser.Parser;
import org.eclipse.jdt.internal.compiler.parser.Scanner;
@@ -151,7 +125,7 @@ private ReferenceExpression copy() {
char [] source = new char [this.sourceEnd+1];
System.arraycopy(this.text, 0, source, this.sourceStart, this.sourceEnd - this.sourceStart + 1);
parser.scanner = this.scanner;
- ReferenceExpression copy = (ReferenceExpression) parser.parseExpression(source, this.sourceStart, this.sourceEnd - this.sourceStart + 1,
+ ReferenceExpression copy = (ReferenceExpression) parser.parseReferenceExpression(source, this.sourceStart, this.sourceEnd - this.sourceStart + 1,
this.enclosingScope.referenceCompilationUnit(), false /* record line separators */);
copy.original = this;
copy.sourceStart = this.sourceStart;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java
index 3751f6012a..7da8c15cdc 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java
@@ -45,16 +45,26 @@
import static org.eclipse.jdt.internal.compiler.ast.ExpressionContext.ASSIGNMENT_CONTEXT;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
+import org.eclipse.jdt.internal.compiler.flow.InitializationFlowContext;
+import org.eclipse.jdt.internal.compiler.flow.InsideStatementWithFinallyBlockFlowContext;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.impl.Constant;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
+import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
+import org.eclipse.jdt.internal.compiler.lookup.Scope;
+import org.eclipse.jdt.internal.compiler.lookup.TagBits;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
public class ReturnStatement extends Statement {
public Expression expression;
- public SubRoutineStatement[] subroutines;
+ public StatementWithFinallyBlock[] statementsWithFinallyBlock;
public LocalVariableBinding saveValueVariable;
public int initStateIndex = -1;
private final boolean implicitReturn;
@@ -104,42 +114,42 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
methodScope.recordInitializationStates(flowInfo);
// compute the return sequence (running the finally blocks)
FlowContext traversedContext = flowContext;
- int subCount = 0;
+ int stmtCount = 0;
boolean saveValueNeeded = false;
boolean hasValueToSave = needValueStore();
boolean noAutoCloseables = true;
do {
- SubRoutineStatement sub;
- if ((sub = traversedContext.subroutine()) != null) {
- if (this.subroutines == null){
- this.subroutines = new SubRoutineStatement[5];
+ StatementWithFinallyBlock stmt;
+ if ((stmt = traversedContext.statementWithFinallyBlock()) != null) {
+ if (this.statementsWithFinallyBlock == null){
+ this.statementsWithFinallyBlock = new StatementWithFinallyBlock[5];
}
- if (subCount == this.subroutines.length) {
- System.arraycopy(this.subroutines, 0, (this.subroutines = new SubRoutineStatement[subCount*2]), 0, subCount); // grow
+ if (stmtCount == this.statementsWithFinallyBlock.length) {
+ System.arraycopy(this.statementsWithFinallyBlock, 0, (this.statementsWithFinallyBlock = new StatementWithFinallyBlock[stmtCount*2]), 0, stmtCount); // grow
}
- this.subroutines[subCount++] = sub;
- if (sub.isSubRoutineEscaping()) {
+ this.statementsWithFinallyBlock[stmtCount++] = stmt;
+ if (stmt.isFinallyBlockEscaping()) {
saveValueNeeded = false;
- this.bits |= ASTNode.IsAnySubRoutineEscaping;
+ this.bits |= ASTNode.IsAnyFinallyBlockEscaping;
break;
}
- if (sub instanceof TryStatement) {
- if (((TryStatement) sub).resources.length > 0) {
+ if (stmt instanceof TryStatement) {
+ if (((TryStatement) stmt).resources.length > 0) {
noAutoCloseables = false;
}
}
}
traversedContext.recordReturnFrom(flowInfo.unconditionalInits());
- if (traversedContext instanceof InsideSubRoutineFlowContext) {
+ if (traversedContext instanceof InsideStatementWithFinallyBlockFlowContext) {
ASTNode node = traversedContext.associatedNode;
if (node instanceof SynchronizedStatement) {
this.bits |= ASTNode.IsSynchronized;
} else if (node instanceof TryStatement) {
TryStatement tryStatement = (TryStatement) node;
- flowInfo.addInitializationsFrom(tryStatement.subRoutineInits); // collect inits
+ flowInfo.addInitializationsFrom(tryStatement.finallyBlockInits); // collect inits
if (hasValueToSave) {
- if (this.saveValueVariable == null){ // closest subroutine secret variable is used
+ if (this.saveValueVariable == null){ // closest try statememt's secret variable is used
prepareSaveValueLocation(tryStatement);
}
saveValueNeeded = true;
@@ -151,14 +161,13 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
currentScope.problemReporter().cannotReturnInInitializer(this);
return FlowInfo.DEAD_END;
} else if (traversedContext.associatedNode instanceof SwitchExpression) {
- currentScope.problemReporter().switchExpressionsReturnWithinSwitchExpression(this);
+ currentScope.problemReporter().returnOutOfSwitchExpression(this);
return FlowInfo.DEAD_END;
}
} while ((traversedContext = traversedContext.getLocalParent()) != null);
- // resize subroutines
- if ((this.subroutines != null) && (subCount != this.subroutines.length)) {
- System.arraycopy(this.subroutines, 0, (this.subroutines = new SubRoutineStatement[subCount]), 0, subCount);
+ if ((this.statementsWithFinallyBlock != null) && (stmtCount != this.statementsWithFinallyBlock.length)) {
+ System.arraycopy(this.statementsWithFinallyBlock, 0, (this.statementsWithFinallyBlock = new StatementWithFinallyBlock[stmtCount]), 0, stmtCount);
}
// secret local variable for return value (note that this can only occur in a real method)
@@ -231,19 +240,19 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream) {
// generate the expression
if (needValueStore()) {
alreadyGeneratedExpression = true;
- this.expression.generateCode(currentScope, codeStream, needValue()); // no value needed if non-returning subroutine
+ this.expression.generateCode(currentScope, codeStream, needValue()); // no value needed if non-returning method
generateStoreSaveValueIfNecessary(currentScope, codeStream);
}
// generation of code responsible for invoking the finally blocks in sequence
- if (this.subroutines != null) {
+ if (this.statementsWithFinallyBlock != null) {
Object reusableJSRTarget = this.expression == null ? (Object)TypeBinding.VOID : this.expression.reusableJSRTarget();
- for (int i = 0, max = this.subroutines.length; i < max; i++) {
- SubRoutineStatement sub = this.subroutines[i];
- boolean didEscape = sub.generateSubRoutineInvocation(currentScope, codeStream, reusableJSRTarget, this.initStateIndex, this.saveValueVariable);
+ for (int i = 0, max = this.statementsWithFinallyBlock.length; i < max; i++) {
+ StatementWithFinallyBlock stmt = this.statementsWithFinallyBlock[i];
+ boolean didEscape = stmt.generateFinallyBlock(currentScope, codeStream, reusableJSRTarget, this.initStateIndex);
if (didEscape) {
codeStream.recordPositionsFrom(pc, this.sourceStart);
- SubRoutineStatement.reenterAllExceptionHandlers(this.subroutines, i, codeStream);
+ StatementWithFinallyBlock.reenterAllExceptionHandlers(this.statementsWithFinallyBlock, i, codeStream);
return;
}
}
@@ -266,7 +275,7 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream) {
codeStream.addDefinitelyAssignedVariables(currentScope, this.initStateIndex);
}
codeStream.recordPositionsFrom(pc, this.sourceStart);
- SubRoutineStatement.reenterAllExceptionHandlers(this.subroutines, -1, codeStream);
+ StatementWithFinallyBlock.reenterAllExceptionHandlers(this.statementsWithFinallyBlock, -1, codeStream);
}
/**
@@ -293,7 +302,7 @@ private boolean needValueStore() {
public boolean needValue() {
return this.saveValueVariable != null
|| (this.bits & ASTNode.IsSynchronized) != 0
- || ((this.bits & ASTNode.IsAnySubRoutineEscaping) == 0);
+ || ((this.bits & ASTNode.IsAnyFinallyBlockEscaping) == 0);
}
public void prepareSaveValueLocation(TryStatement targetTryStatement){
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SingleMemberAnnotation.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SingleMemberAnnotation.java
index 649140aea1..cf8d251afe 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SingleMemberAnnotation.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SingleMemberAnnotation.java
@@ -16,7 +16,9 @@
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
+import org.eclipse.jdt.internal.compiler.lookup.ElementValuePair;
/**
* SingleMemberAnnotation node
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java
index 6fad432f57..2847abaca7 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java
@@ -35,24 +35,7 @@
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.impl.Constant;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
-import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
-import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
-import org.eclipse.jdt.internal.compiler.lookup.MissingTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemFieldBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Scope;
-import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TagBits;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-import org.eclipse.jdt.internal.compiler.lookup.VariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.problem.AbortMethod;
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Statement.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Statement.java
index 00ee5f5018..b189ca8771 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Statement.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Statement.java
@@ -45,8 +45,10 @@
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.ast.NullAnnotationMatching.CheckMode;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
+import org.eclipse.jdt.internal.compiler.codegen.BranchLabel;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.lookup.*;
@@ -190,12 +192,11 @@ void analyseOneArgument18(BlockScope currentScope, FlowContext flowContext, Flow
ce.internalAnalyseOneArgument18(currentScope, flowContext, expectedType, ce.valueIfTrue, flowInfo, ce.ifTrueNullStatus, expectedNonNullness, originalExpected);
ce.internalAnalyseOneArgument18(currentScope, flowContext, expectedType, ce.valueIfFalse, flowInfo, ce.ifFalseNullStatus, expectedNonNullness, originalExpected);
return;
- } else if (argument instanceof SwitchExpression && argument.isPolyExpression()) {
- SwitchExpression se = (SwitchExpression) argument;
- for (int i = 0; i < se.resultExpressions.size(); i++) {
+ } else if (argument instanceof SwitchExpression se && se.isPolyExpression()) {
+ for (Expression rExpression : se.resultExpressions()) {
se.internalAnalyseOneArgument18(currentScope, flowContext, expectedType,
- se.resultExpressions.get(i), flowInfo,
- se.resultExpressionNullStatus.get(i), expectedNonNullness, originalExpected);
+ rExpression, flowInfo,
+ rExpression.nullStatus(flowInfo, flowContext), expectedNonNullness, originalExpected);
}
return;
}
@@ -257,12 +258,11 @@ protected void checkAgainstNullTypeAnnotation(BlockScope scope, TypeBinding requ
internalCheckAgainstNullTypeAnnotation(scope, requiredType, ce.valueIfTrue, ce.ifTrueNullStatus, flowContext, flowInfo);
internalCheckAgainstNullTypeAnnotation(scope, requiredType, ce.valueIfFalse, ce.ifFalseNullStatus, flowContext, flowInfo);
return;
- } else if (expression instanceof SwitchExpression && expression.isPolyExpression()) {
- SwitchExpression se = (SwitchExpression) expression;
- for (int i = 0; i < se.resultExpressions.size(); i++) {
+ } else if (expression instanceof SwitchExpression se && se.isPolyExpression()) {
+ for (Expression rExpression : se.resultExpressions()) {
internalCheckAgainstNullTypeAnnotation(scope, requiredType,
- se.resultExpressions.get(i),
- se.resultExpressionNullStatus.get(i), flowContext, flowInfo);
+ rExpression,
+ rExpression.nullStatus(flowInfo, flowContext), flowContext, flowInfo);
}
return;
}
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SubRoutineStatement.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/StatementWithFinallyBlock.java
similarity index 59%
rename from jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SubRoutineStatement.java
rename to jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/StatementWithFinallyBlock.java
index 044cfa17df..2ad04f7c50 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SubRoutineStatement.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/StatementWithFinallyBlock.java
@@ -16,25 +16,24 @@
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
import org.eclipse.jdt.internal.compiler.codegen.ExceptionLabel;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
/**
- * Extra behavior for statements which are generating subroutines
+ * Extra behavior for statements which have a finally block - e.g., try blocks have finally; synchronized statements have hidden finally blocks that call monitorexit etc.
*/
-public abstract class SubRoutineStatement extends Statement {
+public abstract class StatementWithFinallyBlock extends Statement {
- public static void reenterAllExceptionHandlers(SubRoutineStatement[] subroutines, int max, CodeStream codeStream) {
- if (subroutines == null) return;
- if (max < 0) max = subroutines.length;
+ public static void reenterAllExceptionHandlers(StatementWithFinallyBlock[] statements, int max, CodeStream codeStream) {
+ if (statements == null) return;
+ if (max < 0) max = statements.length;
for (int i = 0; i < max; i++) {
- SubRoutineStatement sub = subroutines[i];
- sub.enterAnyExceptionHandler(codeStream);
- sub.enterDeclaredExceptionHandlers(codeStream);
+ StatementWithFinallyBlock stmt = statements[i];
+ stmt.enterAnyExceptionHandler(codeStream);
+ stmt.enterDeclaredExceptionHandlers(codeStream);
+ stmt.enterResourceExceptionHandlers(codeStream);
}
}
ExceptionLabel anyExceptionLabel;
- protected SwitchExpression switchExpression = null;
public ExceptionLabel enterAnyExceptionHandler(CodeStream codeStream) {
@@ -49,6 +48,10 @@ public void enterDeclaredExceptionHandlers(CodeStream codeStream) {
// do nothing by default
}
+ public void enterResourceExceptionHandlers(CodeStream codeStream) {
+ // do nothing by default
+ }
+
public void exitAnyExceptionHandler() {
if (this.anyExceptionLabel != null) {
this.anyExceptionLabel.placeEnd();
@@ -59,24 +62,15 @@ public void exitDeclaredExceptionHandlers(CodeStream codeStream) {
// do nothing by default
}
-
/**
- * Generate an invocation of a subroutine (e.g. jsr finally) in current context.
- * @return boolean, true
if the generated code will abrupt completion
+ * Generate the finally block in current context.
+ * @return boolean, true
if the generated code will complete abruptly.
*/
- public abstract boolean generateSubRoutineInvocation(BlockScope currentScope, CodeStream codeStream, Object targetLocation, int stateIndex, LocalVariableBinding secretLocal);
+ public abstract boolean generateFinallyBlock(BlockScope currentScope, CodeStream codeStream, Object targetLocation, int stateIndex);
- public abstract boolean isSubRoutineEscaping();
+ public abstract boolean isFinallyBlockEscaping();
public void placeAllAnyExceptionHandler() {
this.anyExceptionLabel.place();
}
-
- public SwitchExpression getSwitchExpression() {
- return this.switchExpression;
- }
-
- public void setSwitchExpression(SwitchExpression switchExpression) {
- this.switchExpression = switchExpression;
- }
-}
+}
\ No newline at end of file
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SwitchExpression.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SwitchExpression.java
index 16471b5f1c..65f2ab7c71 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SwitchExpression.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SwitchExpression.java
@@ -18,22 +18,17 @@
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.List;
-import java.util.Map;
import java.util.Set;
-import java.util.stream.Collectors;
-
import org.eclipse.jdt.core.compiler.CharOperation;
-import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.impl.Constant;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
@@ -47,28 +42,123 @@
public class SwitchExpression extends SwitchStatement implements IPolyExpression {
/* package */ TypeBinding expectedType;
- private ExpressionContext expressionContext = VANILLA_CONTEXT;
- private boolean isPolyExpression = false;
- private TypeBinding[] originalValueResultExpressionTypes;
- private TypeBinding[] finalValueResultExpressionTypes;
- /* package */ Map originalTypeMap = new HashMap<>();
-
-
+ ExpressionContext expressionContext = VANILLA_CONTEXT;
private int nullStatus = FlowInfo.UNKNOWN;
- public List resultExpressions;
- public boolean resolveAll;
- /* package */ List resultExpressionNullStatus;
- public boolean containsTry = false;
- private static Map type_map;
+ public boolean jvmStackVolatile = false;
static final char[] SECRET_YIELD_VALUE_NAME = " yieldValue".toCharArray(); //$NON-NLS-1$
- int yieldResolvedPosition = -1;
List typesOnStack;
- static {
- type_map = new HashMap<>();
- type_map.put(TypeBinding.CHAR, new TypeBinding[] {TypeBinding.CHAR, TypeBinding.INT});
- type_map.put(TypeBinding.SHORT, new TypeBinding[] {TypeBinding.SHORT, TypeBinding.BYTE, TypeBinding.INT});
- type_map.put(TypeBinding.BYTE, new TypeBinding[] {TypeBinding.BYTE, TypeBinding.INT});
+ public Result results = new Result();
+
+ class Result { // Abstraction to help with 15.28.1 determination of the type of a switch expression.
+
+ private Set rExpressions = new LinkedHashSet<>(4);
+ private Set rTypes = new HashSet<>();
+
+ // Result expressions aggregate classification - will be negated as and when the picture changes
+ private boolean allUniform = true;
+ private boolean allBoolean = true;
+ private boolean allNumeric = true;
+ private boolean allWellFormed = true; // true as long as result expression completely fail to resolve (resolvedType == null)
+
+ private TypeBinding resultType() {
+
+ if (!this.allWellFormed)
+ return null;
+
+ if (SwitchExpression.this.isPolyExpression())
+ return resolveAsType(SwitchExpression.this.expectedType);
+
+ if (this.allUniform) {
+ TypeBinding uniformType = null;
+ for (Expression rExpression : this.rExpressions)
+ uniformType = uniformType == null ? rExpression.resolvedType : NullAnnotationMatching.moreDangerousType(uniformType, rExpression.resolvedType);
+ return uniformType;
+ }
+
+ if (this.allBoolean)
+ return resolveAsType(TypeBinding.BOOLEAN);
+
+ if (this.allNumeric) {
+ for (TypeBinding type : TypeBinding.NUMERIC_TYPES) {
+ TypeBinding result = switch (type.id) {
+ case T_double, T_float, T_long, T_int -> this.rTypes.contains(type) ? type : null;
+ case T_short, T_byte, T_char -> {
+ if (this.rTypes.contains(type)) {
+ if (type.id != T_char && this.rTypes.contains(TypeBinding.CHAR))
+ yield TypeBinding.INT;
+ for (Expression rExpression : this.rExpressions) {
+ if (rExpression.resolvedType.id == T_int && rExpression.constant != Constant.NotAConstant && !rExpression.isConstantValueOfTypeAssignableToType(rExpression.resolvedType, type))
+ yield TypeBinding.INT;
+ }
+ yield type;
+ }
+ yield null;
+ }
+ default -> throw new IllegalStateException("Unexpected control flow!"); //$NON-NLS-1$;
+ };
+ if (result != null)
+ return resolveAsType(result);
+ }
+ throw new IllegalStateException("Unexpected control flow!"); //$NON-NLS-1$
+ }
+ // Non-uniform, non-boolean, non-numeric: Force to reference versions, compute lub and apply capture and we are done!
+ LookupEnvironment env = SwitchExpression.this.scope.environment();
+ TypeBinding [] resultReferenceTypes = new TypeBinding[this.rExpressions.size()];
+ int i = 0;
+ for (Expression rExpression : this.rExpressions)
+ resultReferenceTypes[i++] = rExpression.resolvedType.isBaseType() ? env.computeBoxingType(rExpression.resolvedType) : rExpression.resolvedType;
+
+ TypeBinding lub = SwitchExpression.this.scope.lowerUpperBound(resultReferenceTypes);
+ if (lub != null)
+ return resolveAsType(lub);
+
+ SwitchExpression.this.scope.problemReporter().incompatibleSwitchExpressionResults(SwitchExpression.this); // Is this unreachable ? can lub be null with only reference types ??!
+ return null;
+ }
+
+ /** Add an expression to known result expressions, gather some aggregate characteristics if in standalone context.
+ * @return a flag indicating the overall well-formedness of result expression set.
+ */
+ public boolean add(/*@NonNull*/ Expression rxpression) {
+
+ this.rExpressions.add(rxpression);
+
+ TypeBinding rxpressionType = rxpression.resolvedType;
+ if (rxpressionType == null) { // tolerate poly-expression resolving to null in the absence of target type.
+ if (!rxpression.isPolyExpression() || ((IPolyExpression) rxpression).expectedType() != null)
+ this.allWellFormed = false;
+ } else if (!rxpressionType.isValidBinding()) {
+ this.allWellFormed = false;
+ }
+
+ // Classify result expressions on an aggregate basis - needed only for well formed, non-poly switches.
+ if (!this.allWellFormed || SwitchExpression.this.isPolyExpression())
+ return this.allWellFormed;
+
+ rxpressionType = rxpressionType.unboxedType();
+ this.allUniform &= TypeBinding.equalsEquals(this.rExpressions.iterator().next().resolvedType, rxpression.resolvedType);
+ this.allBoolean &= rxpressionType.id == T_boolean;
+ this.allNumeric &= rxpressionType.isNumericType();
+
+ if (this.allNumeric) {
+ boolean definiteType = true;
+ if (rxpressionType.id == T_int && rxpression.constant != Constant.NotAConstant) {
+ int i = rxpression.constant.intValue();
+ if (i <= Character.MAX_VALUE && i >= Short.MIN_VALUE)
+ definiteType = false;
+ // else int constants may get reclassified as they undergo narrowing conversions - can't pin them yet.
+ }
+ if (definiteType)
+ this.rTypes.add(rxpressionType);
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return this.rExpressions.toString();
+ }
}
@Override
@@ -86,8 +176,8 @@ public ExpressionContext getExpressionContext() {
return this.expressionContext;
}
@Override
- protected boolean ignoreMissingDefaultCase(CompilerOptions compilerOptions, boolean isEnumSwitch) {
- return isEnumSwitch; // mandatory error if not enum in switch expressions
+ protected boolean ignoreMissingDefaultCase(CompilerOptions compilerOptions) {
+ return true;
}
@Override
protected void reportMissingEnumConstantCase(BlockScope upperScope, FieldBinding enumConstant) {
@@ -115,79 +205,15 @@ else if ((this.nullStatus & FlowInfo.POTENTIALLY_NULL) != 0)
return true; // all checking done
}
- private void computeNullStatus(FlowInfo flowInfo, FlowContext flowContext) {
- boolean precomputed = this.resultExpressionNullStatus.size() > 0;
- if (!precomputed)
- this.resultExpressionNullStatus.add(this.resultExpressions.get(0).nullStatus(flowInfo, flowContext)); int status = this.resultExpressions.get(0).nullStatus(flowInfo, flowContext);
- int combinedStatus = status;
- boolean identicalStatus = true;
- for (int i = 1, l = this.resultExpressions.size(); i < l; ++i) {
- if (!precomputed)
- this.resultExpressionNullStatus.add(this.resultExpressions.get(i).nullStatus(flowInfo, flowContext));
- int tmp = this.resultExpressions.get(i).nullStatus(flowInfo, flowContext);
- identicalStatus &= status == tmp;
- combinedStatus |= tmp;
- }
- if (identicalStatus) {
- this.nullStatus = status;
- return;
- }
- status = Expression.computeNullStatus(0, combinedStatus);
- if (status > 0)
- this.nullStatus = status;
- }
-
- @Override
- protected void completeNormallyCheck(BlockScope blockScope) {
- int sz = this.statements != null ? this.statements.length : 0;
- if (sz == 0) return;
- /* JLS 12 15.28.1 Given a switch expression, if the switch block consists of switch labeled rules
- * then it is a compile-time error if any switch labeled block can complete normally.
- */
- if ((this.switchBits & LabeledRules) != 0) {
- for (Statement stmt : this.statements) {
- if (!(stmt instanceof Block))
- continue;
- if (stmt.canCompleteNormally())
- blockScope.problemReporter().switchExpressionLastStatementCompletesNormally(stmt);
- }
- return;
- }
- /* JLS 12 15.28.1
- * If, on the other hand, the switch block consists of switch labeled statement groups, then it is a
- * compile-time error if either the last statement in the switch block can complete normally, or the
- * switch block includes one or more switch labels at the end.
- */
- Statement lastNonCaseStmt = null;
- Statement firstTrailingCaseStmt = null;
- for (int i = sz - 1; i >= 0; i--) {
- Statement stmt = this.statements[sz - 1];
- if (stmt instanceof CaseStatement)
- firstTrailingCaseStmt = stmt;
- else {
- lastNonCaseStmt = stmt;
- break;
- }
- }
- if (lastNonCaseStmt != null) {
- if (lastNonCaseStmt.canCompleteNormally())
- blockScope.problemReporter().switchExpressionLastStatementCompletesNormally(lastNonCaseStmt);
- else if (lastNonCaseStmt instanceof ContinueStatement || lastNonCaseStmt instanceof ReturnStatement) {
- blockScope.problemReporter().switchExpressionIllegalLastStatement(lastNonCaseStmt);
- }
- }
- if (firstTrailingCaseStmt != null) {
- blockScope.problemReporter().switchExpressionTrailingSwitchLabels(firstTrailingCaseStmt);
- }
- }
@Override
protected boolean needToCheckFlowInAbsenceOfDefaultBranch() { // JLS 12 16.1.8
return (this.switchBits & LabeledRules) == 0;
}
+
@Override
public Expression[] getPolyExpressions() {
List polys = new ArrayList<>();
- for (Expression e : this.resultExpressions) {
+ for (Expression e : this.results.rExpressions) {
Expression[] ea = e.getPolyExpressions();
if (ea == null || ea.length ==0) continue;
polys.addAll(Arrays.asList(ea));
@@ -196,7 +222,7 @@ public Expression[] getPolyExpressions() {
}
@Override
public boolean isPertinentToApplicability(TypeBinding targetType, MethodBinding method) {
- for (Expression e : this.resultExpressions) {
+ for (Expression e : this.results.rExpressions) {
if (!e.isPertinentToApplicability(targetType, method))
return false;
}
@@ -204,7 +230,7 @@ public boolean isPertinentToApplicability(TypeBinding targetType, MethodBinding
}
@Override
public boolean isPotentiallyCompatibleWith(TypeBinding targetType, Scope scope1) {
- for (Expression e : this.resultExpressions) {
+ for (Expression e : this.results.rExpressions) {
if (!e.isPotentiallyCompatibleWith(targetType, scope1))
return false;
}
@@ -212,7 +238,7 @@ public boolean isPotentiallyCompatibleWith(TypeBinding targetType, Scope scope1)
}
@Override
public boolean isFunctionalType() {
- for (Expression e : this.resultExpressions) {
+ for (Expression e : this.results.rExpressions) {
if (e.isFunctionalType()) // return true even for one functional type
return true;
}
@@ -261,11 +287,15 @@ private LocalVariableBinding addTypeStackVariable(CodeStream codeStream, TypeBin
lvb.declaration = new LocalDeclaration(name, 0, 0);
return lvb;
}
- private void spillOperandStack(CodeStream codeStream) {
+
+ private void spillOperandStackIfNeeded(CodeStream codeStream) {
+ int operandStackSize = codeStream.operandStack.size();
+ if (!this.jvmStackVolatile || (codeStream.stackDepth == 0 && operandStackSize == 0)) // nothing to spill and nothing to compain
+ return;
int nextResolvedPosition = this.scope.offset;
this.typesOnStack = new ArrayList<>();
int index = 0;
- while (codeStream.operandStack.size() > 0) {
+ while (operandStackSize > 0) {
TypeBinding type = codeStream.operandStack.peek();
LocalVariableBinding lvb = addTypeStackVariable(codeStream, type, TypeIds.T_undefined, index++, nextResolvedPosition);
nextResolvedPosition += switch (lvb.type.id) {
@@ -275,101 +305,52 @@ private void spillOperandStack(CodeStream codeStream) {
this.typesOnStack.add(lvb);
codeStream.store(lvb, false);
codeStream.addVariable(lvb);
+ operandStackSize = codeStream.operandStack.size();
}
- if (codeStream.stackDepth != 0 || codeStream.operandStack.size() != 0) {
+ if (codeStream.stackDepth != 0 || codeStream.operandStack.size() != 0)
codeStream.classFile.referenceBinding.scope.problemReporter().operandStackSizeInappropriate(codeStream.classFile.referenceBinding.scope.referenceContext);
- }
- // now keep a position reserved for yield result value
- this.yieldResolvedPosition = nextResolvedPosition;
- nextResolvedPosition += ((TypeBinding.equalsEquals(this.resolvedType, TypeBinding.LONG)) ||
- (TypeBinding.equalsEquals(this.resolvedType, TypeBinding.DOUBLE))) ?
- 2 : 1;
int delta = nextResolvedPosition - this.scope.offset;
this.scope.adjustLocalVariablePositions(delta, false);
}
- public void refillOperandStack(CodeStream codeStream) {
+
+ public void refillOperandStackIfNeeded(CodeStream codeStream, YieldStatement yield) {
+ if (!this.jvmStackVolatile || this.typesOnStack == null || this.typesOnStack.isEmpty() || (yield.bits & ASTNode.IsAnyFinallyBlockEscaping) != 0) // nothing spilled or no point restoring.
+ return;
+
+ if (codeStream.stackDepth != 0 || codeStream.operandStack.size() != 0)
+ codeStream.classFile.referenceBinding.scope.problemReporter().operandStackSizeInappropriate(codeStream.classFile.referenceBinding.scope.referenceContext);
+
List tos = this.typesOnStack;
- int sz = tos != null ? tos.size() : 0;
- codeStream.operandStack.clear();
- codeStream.stackDepth = 0;
- int index = sz - 1;
+ int index = tos != null ? tos.size() - 1 : -1;
while (index >= 0) {
LocalVariableBinding lvb = tos.get(index--);
codeStream.load(lvb);
-// lvb.recordInitializationEndPC(codeStream.position);
-// codeStream.removeVariable(lvb);
}
}
+
private void removeStoredTypes(CodeStream codeStream) {
List tos = this.typesOnStack;
- int sz = tos != null ? tos.size() : 0;
- int index = sz - 1;
+ int index = tos != null ? tos.size() -1 : - 1;
while (index >= 0) {
LocalVariableBinding lvb = tos.get(index--);
codeStream.removeVariable(lvb);
}
}
+
@Override
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
- if (this.containsTry) {
- spillOperandStack(codeStream);
- }
+ spillOperandStackIfNeeded(codeStream);
super.generateCode(currentScope, codeStream);
- if (this.containsTry) {
+ if (this.jvmStackVolatile)
removeStoredTypes(codeStream);
- }
- if (!valueRequired) {
- // switch expression is saved to a variable that is not used. We need to pop the generated value from the stack
+ if (!valueRequired) { // switch expression result discarded (saved to a variable that is not used.)
switch(postConversionType(currentScope).id) {
- case TypeIds.T_long :
- case TypeIds.T_double :
- codeStream.pop2();
- break;
- case TypeIds.T_void :
- break;
- default :
- codeStream.pop();
- break;
+ case TypeIds.T_long, TypeIds.T_double -> codeStream.pop2();
+ default -> codeStream.pop();
}
- } else {
- if (!this.isPolyExpression()) // not in invocation or assignment contexts
- codeStream.generateImplicitConversion(this.implicitConversion);
- }
- }
- protected boolean computeConversions(BlockScope blockScope, TypeBinding targetType) {
- boolean ok = true;
- for (int i = 0, l = this.resultExpressions.size(); i < l; ++i) {
- ok &= computeConversionsResultExpressions(blockScope, targetType, this.originalValueResultExpressionTypes[i], this.resultExpressions.get(i));
- }
- return ok;
- }
- private boolean computeConversionsResultExpressions(BlockScope blockScope, TypeBinding targetType, TypeBinding resultExpressionType,
- Expression resultExpression) {
- if (resultExpressionType != null && resultExpressionType.isValidBinding()) {
- if (resultExpression.isConstantValueOfTypeAssignableToType(resultExpressionType, targetType)
- || resultExpressionType.isCompatibleWith(targetType)) {
-
- resultExpression.computeConversion(blockScope, targetType, resultExpressionType);
- if (resultExpressionType.needsUncheckedConversion(targetType)) {
- blockScope.problemReporter().unsafeTypeConversion(resultExpression, resultExpressionType, targetType);
- }
- if (resultExpression instanceof CastExpression
- && (resultExpression.bits & (ASTNode.UnnecessaryCast|ASTNode.DisableUnnecessaryCastCheck)) == 0) {
- CastExpression.checkNeedForAssignedCast(blockScope, targetType, (CastExpression) resultExpression);
- }
- } else if (isBoxingCompatible(resultExpressionType, targetType, resultExpression, blockScope)) {
- resultExpression.computeConversion(blockScope, targetType, resultExpressionType);
- if (resultExpression instanceof CastExpression
- && (resultExpression.bits & (ASTNode.UnnecessaryCast|ASTNode.DisableUnnecessaryCastCheck)) == 0) {
- CastExpression.checkNeedForAssignedCast(blockScope, targetType, (CastExpression) resultExpression);
- }
- } else {
- blockScope.problemReporter().typeMismatchError(resultExpressionType, targetType, resultExpression, null);
- return false;
- }
- }
- return true;
+ } else if (!this.isPolyExpression())
+ codeStream.generateImplicitConversion(this.implicitConversion);
}
@Override
@@ -380,299 +361,89 @@ public void resolve(BlockScope upperScope) {
@Override
public TypeBinding resolveType(BlockScope upperScope) {
try {
- int resultExpressionsCount;
if (this.constant != Constant.NotAConstant) {
this.constant = Constant.NotAConstant;
-
- // A switch expression is a poly expression if it appears in an assignment context or an invocation context (5.2, 5.3).
- // Otherwise, it is a standalone expression.
- if (this.expressionContext == ASSIGNMENT_CONTEXT || this.expressionContext == INVOCATION_CONTEXT) {
- for (Expression e : this.resultExpressions) {
- //Where a poly switch expression appears in a context of a particular kind with target type T,
- //its result expressions similarly appear in a context of the same kind with target type T.
- e.setExpressionContext(this.expressionContext);
- e.setExpectedType(this.expectedType);
- }
- }
-
- if (this.originalTypeMap == null)
- this.originalTypeMap = new HashMap<>();
- super.resolve(upperScope);
-
- if (this.statements == null || this.statements.length == 0) {
- // Report Error JLS 13 15.28.1 The switch block must not be empty.
- upperScope.problemReporter().switchExpressionEmptySwitchBlock(this);
- return null;
- }
-
- resultExpressionsCount = this.resultExpressions != null ? this.resultExpressions.size() : 0;
- if (resultExpressionsCount == 0) {
- // Report Error JLS 13 15.28.1
- // It is a compile-time error if a switch expression has no result expressions.
- upperScope.problemReporter().switchExpressionNoResultExpressions(this);
- return null;
- }
-
- if (this.originalValueResultExpressionTypes == null) {
- this.originalValueResultExpressionTypes = new TypeBinding[resultExpressionsCount];
- this.finalValueResultExpressionTypes = new TypeBinding[resultExpressionsCount];
- for (int i = 0; i < resultExpressionsCount; ++i) {
- this.finalValueResultExpressionTypes[i] = this.originalValueResultExpressionTypes[i] =
- this.resultExpressions.get(i).resolvedType;
- }
- }
- if (isPolyExpression()) { //The type of a poly switch expression is the same as its target type.
- if (this.expectedType == null || !this.expectedType.isProperType(true)) {
- return new PolyTypeBinding(this);
- }
- return this.resolvedType = computeConversions(this.scope, this.expectedType) ? this.expectedType : null;
- }
- // fall through
- } else {
- // re-resolving of poly expression:
- resultExpressionsCount = this.resultExpressions != null ? this.resultExpressions.size() : 0;
- if (resultExpressionsCount == 0)
- return this.resolvedType = null; // error flagging would have been done during the earlier phase.
- for (int i = 0; i < resultExpressionsCount; i++) {
- Expression resultExpr = this.resultExpressions.get(i);
- TypeBinding origType = this.originalTypeMap.get(resultExpr);
- // NB: if origType == null we assume that initial resolving failed hard, rendering re-resolving impossible
- if (origType != null && origType.kind() == Binding.POLY_TYPE) {
- this.finalValueResultExpressionTypes[i] = this.originalValueResultExpressionTypes[i] =
- resultExpr.resolveTypeExpecting(upperScope, this.expectedType);
- }
- // This is a kludge and only way completion can tell this node to resolve all
- // resultExpressions. Ideal solution is to remove all other expressions except
- // the one that contain the completion node.
- if (this.resolveAll) continue;
- if (resultExpr.resolvedType == null || !resultExpr.resolvedType.isValidBinding())
- return this.resolvedType = null;
- }
- this.resolvedType = computeConversions(this.scope, this.expectedType) ? this.expectedType : null;
- // fall through
- }
-
- if (resultExpressionsCount == 1)
- return this.resolvedType = this.originalValueResultExpressionTypes[0];
-
- boolean typeUniformAcrossAllArms = true;
- TypeBinding tmp = this.originalValueResultExpressionTypes[0];
- for (int i = 1, l = this.originalValueResultExpressionTypes.length; i < l; ++i) {
- TypeBinding originalType = this.originalValueResultExpressionTypes[i];
- if (originalType != null && TypeBinding.notEquals(tmp, originalType)) {
- typeUniformAcrossAllArms = false;
- break;
- }
- }
- // If the result expressions all have the same type (which may be the null type),
- // then that is the type of the switch expression.
- if (typeUniformAcrossAllArms) {
- tmp = this.originalValueResultExpressionTypes[0];
- for (int i = 1; i < resultExpressionsCount; ++i) {
- if (this.originalValueResultExpressionTypes[i] != null)
- tmp = NullAnnotationMatching.moreDangerousType(tmp, this.originalValueResultExpressionTypes[i]);
- }
- return this.resolvedType = tmp;
- }
-
- boolean typeBbolean = true;
- for (TypeBinding t : this.originalValueResultExpressionTypes) {
- if (t != null)
- typeBbolean &= t.id == T_boolean || t.id == T_JavaLangBoolean;
- }
- LookupEnvironment env = this.scope.environment();
- /*
- * Otherwise, if the type of each result expression is boolean or Boolean,
- * an unboxing conversion (5.1.8) is applied to each result expression of type Boolean,
- * and the switch expression has type boolean.
- */
- if (typeBbolean) {
- for (int i = 0; i < resultExpressionsCount; ++i) {
- if (this.originalValueResultExpressionTypes[i] == null) continue;
- if (this.originalValueResultExpressionTypes[i].id == T_boolean) continue;
- this.finalValueResultExpressionTypes[i] = env.computeBoxingType(this.originalValueResultExpressionTypes[i]);
- this.resultExpressions.get(i).computeConversion(this.scope, this.finalValueResultExpressionTypes[i], this.originalValueResultExpressionTypes[i]);
+ super.resolve(upperScope); // drills down into switch block, which will cause yield expressions to be discovered and added to `this.results`
+ if (this.results.rExpressions.size() == 0) {
+ upperScope.problemReporter().unyieldingSwitchExpression(this);
+ return this.resolvedType = null;
}
- return this.resolvedType = TypeBinding.BOOLEAN;
+ if (isPolyExpression() && (this.expectedType == null || !this.expectedType.isProperType(true)))
+ return new PolyTypeBinding(this);
+ } else { // re-resolve poly-expression against the eventual target type.
+ for (Expression rExpression : this.results.rExpressions)
+ if (rExpression.isPolyExpression())
+ rExpression.resolveTypeExpecting(upperScope, this.expectedType);
}
-
- /*
- * Otherwise, if the type of each result expression is convertible to a numeric type (5.1.8), the type
- * of the switch expression is given by numeric promotion (5.6.3) applied to the result expressions.
- */
- boolean typeNumeric = true;
- TypeBinding resultNumeric = null;
- HashSet typeSet = new HashSet<>();
- /* JLS 13 5.6 Numeric Contexts
- * An expression appears in a numeric context if it is one of:....
- * ...8. a result expression of a standalone switch expression (15.28.1),
- * where all the result expressions are convertible to a numeric type
- * If any expression is of a reference type, it is subjected to unboxing conversion (5.1.8).
- */
- for (int i = 0; i < resultExpressionsCount; ++i) {
- TypeBinding originalType = this.originalValueResultExpressionTypes[i];
- if (originalType == null) continue;
- tmp = originalType.isNumericType() ? originalType : env.computeBoxingType(originalType);
- if (!tmp.isNumericType()) {
- typeNumeric = false;
- break;
- }
- typeSet.add(TypeBinding.wellKnownType(this.scope, tmp.id));
- }
- if (typeNumeric) {
- /* If any result expression is of type double, then other result expressions that are not of type double
- * are widened to double.
- * Otherwise, if any result expression is of type float, then other result expressions that are not of
- * type float are widened to float.
- * Otherwise, if any result expression is of type long, then other result expressions that are not of
- * type long are widened to long.
- */
- TypeBinding[] dfl = new TypeBinding[]{// do not change the order JLS 13 5.6
- TypeBinding.DOUBLE,
- TypeBinding.FLOAT,
- TypeBinding.LONG};
- for (TypeBinding binding : dfl) {
- if (typeSet.contains(binding)) {
- resultNumeric = binding;
- break;
- }
- }
-
- /* Otherwise, if any expression appears in a numeric array context or a numeric arithmetic context,
- * rather than a numeric choice context, then the promoted type is int and other expressions that are
- * not of type int undergo widening primitive conversion to int. - not applicable since numeric choice context.
- * [Note: A numeric choice context is a numeric context that is either a numeric conditional expression or
- * a standalone switch expression where all the result expressions are convertible to a numeric type.]
- */
-
- /* Otherwise, if any result expression is of type int and is not a constant expression, the other
- * result expressions that are not of type int are widened to int.
- */
- resultNumeric = resultNumeric != null ? resultNumeric : check_nonconstant_int();
-
- resultNumeric = resultNumeric != null ? resultNumeric : // one among the first few rules applied.
- getResultNumeric(typeSet); // check the rest
- typeSet = null; // hey gc!
- for (int i = 0; i < resultExpressionsCount; ++i) {
- this.resultExpressions.get(i).computeConversion(this.scope,
- resultNumeric, this.originalValueResultExpressionTypes[i]);
- this.finalValueResultExpressionTypes[i] = resultNumeric;
- }
- // After the conversion(s), if any, value set conversion (5.1.13) is then applied to each result expression.
- return this.resolvedType = resultNumeric;
- }
-
- /* Otherwise, boxing conversion (5.1.7) is applied to each result expression that has a primitive type,
- * after which the type of the switch expression is the result of applying capture conversion (5.1.10)
- * to the least upper bound (4.10.4) of the types of the result expressions.
- */
- for (int i = 0; i < resultExpressionsCount; ++i) {
- TypeBinding finalType = this.finalValueResultExpressionTypes[i];
- if (finalType != null && finalType.isBaseType())
- this.finalValueResultExpressionTypes[i] = env.computeBoxingType(finalType);
- }
- TypeBinding commonType = this.scope.lowerUpperBound(this.finalValueResultExpressionTypes);
- if (commonType != null) {
- for (int i = 0, l = this.resultExpressions.size(); i < l; ++i) {
- if (this.originalValueResultExpressionTypes[i] == null) continue;
- this.resultExpressions.get(i).computeConversion(this.scope, commonType, this.originalValueResultExpressionTypes[i]);
- this.finalValueResultExpressionTypes[i] = commonType;
- }
- return this.resolvedType = commonType.capture(this.scope, this.sourceStart, this.sourceEnd);
- }
- this.scope.problemReporter().switchExpressionIncompatibleResultExpressions(this);
- return null;
+ return this.resolvedType = this.results.resultType();
} finally {
if (this.scope != null) this.scope.enclosingCase = null; // no longer inside switch case block
}
}
- private TypeBinding check_nonconstant_int() {
- for (int i = 0, l = this.resultExpressions.size(); i < l; ++i) {
- Expression e = this.resultExpressions.get(i);
- TypeBinding type = this.originalValueResultExpressionTypes[i];
- if (type != null && type.id == T_int && e.constant == Constant.NotAConstant)
- return TypeBinding.INT;
- }
- return null;
- }
- private boolean areAllIntegerResultExpressionsConvertibleToTargetType(TypeBinding targetType) {
- for (int i = 0, l = this.resultExpressions.size(); i < l; ++i) {
- Expression e = this.resultExpressions.get(i);
- TypeBinding t = this.originalValueResultExpressionTypes[i];
- if (!TypeBinding.equalsEquals(t, TypeBinding.INT)) continue;
- if (!e.isConstantValueOfTypeAssignableToType(t, targetType))
- return false;
+
+ // We have resolved the switch expression to be if type `switchType'. Allow result expressions to adapt.
+ // Return the type after applying capture conversion.
+ private TypeBinding resolveAsType(TypeBinding switchType) {
+ for (Expression rExpression : this.results.rExpressions) {
+ if (rExpression.resolvedType != null && rExpression.resolvedType.isValidBinding()) {
+ if (rExpression.isConstantValueOfTypeAssignableToType(rExpression.resolvedType, switchType) || rExpression.resolvedType.isCompatibleWith(switchType)) {
+ rExpression.computeConversion(this.scope, switchType, rExpression.resolvedType);
+ if (rExpression.resolvedType.needsUncheckedConversion(switchType))
+ this.scope.problemReporter().unsafeTypeConversion(rExpression, rExpression.resolvedType, switchType);
+ if (rExpression instanceof CastExpression && (rExpression.bits & (ASTNode.UnnecessaryCast | ASTNode.DisableUnnecessaryCastCheck)) == 0)
+ CastExpression.checkNeedForAssignedCast(this.scope, switchType, (CastExpression) rExpression);
+ } else if (isBoxingCompatible(rExpression.resolvedType, switchType, rExpression, this.scope)) {
+ rExpression.computeConversion(this.scope, switchType, rExpression.resolvedType);
+ if (rExpression instanceof CastExpression && (rExpression.bits & (ASTNode.UnnecessaryCast | ASTNode.DisableUnnecessaryCastCheck)) == 0)
+ CastExpression.checkNeedForAssignedCast(this.scope, switchType, (CastExpression) rExpression);
+ } else {
+ this.scope.problemReporter().typeMismatchError(rExpression.resolvedType, switchType, rExpression, null);
+ return null;
+ }
+ }
}
- return true;
+ return switchType.capture(this.scope, this.sourceStart, this.sourceEnd);
}
+
+
@Override
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
flowInfo = super.analyseCode(currentScope, flowContext, flowInfo);
- this.resultExpressionNullStatus = new ArrayList<>(0);
- final CompilerOptions compilerOptions = currentScope.compilerOptions();
- if (compilerOptions.enableSyntacticNullAnalysisForFields) {
- for (Expression re : this.resultExpressions) {
- this.resultExpressionNullStatus.add(re.nullStatus(flowInfo, flowContext));
- // wipe information that was meant only for this result expression:
- flowContext.expireNullCheckedFieldInfo();
+ if ((this.switchBits & LabeledRules) != 0) { // 15.28.1
+ for (Statement stmt : this.statements) {
+ if (stmt instanceof Block && stmt.canCompleteNormally())
+ currentScope.problemReporter().switchExpressionBlockCompletesNormally(stmt);
}
+ } else {
+ Statement ultimateStmt = this.statements[this.statements.length - 1]; // length guaranteed > 0
+ if (ultimateStmt.canCompleteNormally())
+ currentScope.problemReporter().switchExpressionBlockCompletesNormally(ultimateStmt);
}
- computeNullStatus(flowInfo, flowContext);
- return flowInfo;
- }
-
- private TypeBinding check_csb(Set typeSet, TypeBinding candidate) {
- if (!typeSet.contains(candidate))
- return null;
- TypeBinding[] allowedTypes = SwitchExpression.type_map.get(candidate);
- Set allowedSet = Arrays.stream(allowedTypes).collect(Collectors.toSet());
-
- if (!allowedSet.containsAll(typeSet))
- return null;
+ if (currentScope.compilerOptions().enableSyntacticNullAnalysisForFields)
+ flowContext.expireNullCheckedFieldInfo(); // wipe information that was meant only for this result expression:
- return areAllIntegerResultExpressionsConvertibleToTargetType(candidate) ?
- candidate : null;
- }
- private TypeBinding getResultNumeric(Set typeSet) {
- // note: if an expression has a type integer, then it will be a constant
- // since non-constant integers are already processed before reaching here.
-
- /* Otherwise, if any expression is of type short, and every other expression is either of type short,
- * or of type byte, or a constant expression of type int with a value that is representable in the
- * type short, then T is short, the byte expressions undergo widening primitive conversion to short,
- * and the int expressions undergo narrowing primitive conversion to short.\
- *
- * Otherwise, if any expression is of type byte, and every other expression is either of type byte or a
- * constant expression of type int with a value that is representable in the type byte, then T is byte
- * and the int expressions undergo narrowing primitive conversion to byte.
- *
- * Otherwise, if any expression is of type char, and every other expression is either of type char or a
- * constant expression of type int with a value that is representable in the type char, then T is char
- * and the int expressions undergo narrowing primitive conversion to char.
- *
- * Otherwise, T is int and all the expressions that are not of type int undergo widening
- * primitive conversion to int.
- */
-
- // DO NOT Change the order below [as per JLS 13 5.6 ].
- TypeBinding[] csb = new TypeBinding[] {TypeBinding.SHORT, TypeBinding.BYTE, TypeBinding.CHAR};
- for (TypeBinding c : csb) {
- TypeBinding result = check_csb(typeSet, c);
- if (result != null)
- return result;
+ int status = this.results.rExpressions.iterator().next().nullStatus(flowInfo, flowContext);
+ int combinedStatus = status;
+ boolean identicalStatus = true;
+ for (Expression rExpression : this.results.rExpressions) {
+ status = rExpression.nullStatus(flowInfo, flowContext);
+ identicalStatus &= combinedStatus == status;
+ combinedStatus |= status;
}
- /* Otherwise, all the result expressions that are not of type int are widened to int. */
- return TypeBinding.INT;
+ if (identicalStatus) {
+ this.nullStatus = status;
+ return flowInfo;
+ }
+ status = Expression.computeNullStatus(0, combinedStatus);
+ if (status > 0)
+ this.nullStatus = status;
+ return flowInfo;
}
+
@Override
public boolean isPolyExpression() {
- if (this.isPolyExpression)
- return true;
- // JLS 13 15.28.1 A switch expression is a poly expression if it appears in an assignment context or
- // an invocation context (5.2, 5.3). Otherwise, it is a standalone expression.
- return this.isPolyExpression = this.expressionContext == ASSIGNMENT_CONTEXT ||
- this.expressionContext == INVOCATION_CONTEXT;
+ return this.expressionContext == ASSIGNMENT_CONTEXT || this.expressionContext == INVOCATION_CONTEXT;
}
@Override
public boolean isTrulyExpression() {
@@ -683,7 +454,7 @@ public boolean isCompatibleWith(TypeBinding left, Scope skope) {
if (!isPolyExpression())
return super.isCompatibleWith(left, skope);
- for (Expression e : this.resultExpressions) {
+ for (Expression e : this.results.rExpressions) {
if (!e.isCompatibleWith(left, skope))
return false;
}
@@ -694,7 +465,7 @@ public boolean isBoxingCompatibleWith(TypeBinding targetType, Scope skope) {
if (!isPolyExpression())
return super.isBoxingCompatibleWith(targetType, skope);
- for (Expression e : this.resultExpressions) {
+ for (Expression e : this.results.rExpressions) {
if (!(e.isCompatibleWith(targetType, skope) || e.isBoxingCompatibleWith(targetType, skope)))
return false;
}
@@ -706,29 +477,29 @@ public boolean sIsMoreSpecific(TypeBinding s, TypeBinding t, Scope skope) {
return true;
if (!isPolyExpression())
return false;
- for (Expression e : this.resultExpressions) {
+ for (Expression e : this.results.rExpressions) {
if (!e.sIsMoreSpecific(s, t, skope))
return false;
}
return true;
}
+
+ @Override
+ public StringBuilder printExpression(int tab, StringBuilder output, boolean makeShort) {
+ if (!makeShort) {
+ return super.printExpression(tab, output);
+ } else {
+ printIndent(tab, output).append("switch ("); //$NON-NLS-1$
+ return this.expression.printExpression(0, output).append(") { ... }"); //$NON-NLS-1$
+ }
+ }
+
@Override
public TypeBinding expectedType() {
return this.expectedType;
}
- @Override
- public void traverse(
- ASTVisitor visitor,
- BlockScope blockScope) {
-
- if (visitor.visit(this, blockScope)) {
- this.expression.traverse(visitor, blockScope);
- if (this.statements != null) {
- int statementsLength = this.statements.length;
- for (int i = 0; i < statementsLength; i++)
- this.statements[i].traverse(visitor, this.scope);
- }
- }
- visitor.endVisit(this, blockScope);
+
+ public Set resultExpressions() {
+ return this.results.rExpressions;
}
}
\ No newline at end of file
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java
index fdd30bbc2c..e5b681457f 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java
@@ -19,16 +19,18 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
-import static org.eclipse.jdt.internal.compiler.ClassFile.CONSTANT_BOOTSTRAP__PRIMITIVE_CLASS;
import static org.eclipse.jdt.internal.compiler.ClassFile.CONSTANT_BOOTSTRAP__GET_STATIC_FINAL;
+import static org.eclipse.jdt.internal.compiler.ClassFile.CONSTANT_BOOTSTRAP__PRIMITIVE_CLASS;
import java.lang.invoke.ConstantBootstraps;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import java.util.function.Function;
import java.util.function.IntPredicate;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.ast.CaseStatement.ResolvedCase;
@@ -53,7 +55,6 @@
import org.eclipse.jdt.internal.compiler.lookup.SyntheticMethodBinding;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
@SuppressWarnings("rawtypes")
@@ -86,6 +87,7 @@ public static record SingletonBootstrap(String id, char[] selector, char[] signa
public int switchBits;
public boolean containsPatterns;
+ public boolean containsRecordPatterns;
public boolean containsNull;
boolean nullProcessed = false;
BranchLabel switchPatternRestartTarget;
@@ -103,6 +105,7 @@ public static record SingletonBootstrap(String id, char[] selector, char[] signa
public final static int TotalPattern = ASTNode.Bit3;
public final static int Exhaustive = ASTNode.Bit4;
public final static int QualifiedEnum = ASTNode.Bit5;
+ public final static int LabeledBlockStatementGroup = ASTNode.Bit6;
// for switch on strings
private static final char[] SecretStringVariableName = " switchDispatchString".toCharArray(); //$NON-NLS-1$
@@ -365,8 +368,7 @@ public boolean visit(TNode node) {
}
}
if (node.type instanceof ReferenceBinding ref && ref.isSealed()) {
- List allAllowedTypes = ref.getAllEnumerableReferenceTypes();
- this.covers &= isExhaustiveWithCaseTypes(allAllowedTypes, availableTypes);
+ this.covers &= caseElementsCoverSealedType(ref, availableTypes);
return this.covers;
}
this.covers = false;
@@ -401,9 +403,6 @@ protected int getFallThroughState(Statement stmt, BlockScope blockScope) {
}
return FALLTHROUGH;
}
- protected void completeNormallyCheck(BlockScope blockScope) {
- // do nothing
- }
protected boolean needToCheckFlowInAbsenceOfDefaultBranch() {
return !this.isExhaustive();
}
@@ -416,7 +415,6 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
}
SwitchFlowContext switchContext =
new SwitchFlowContext(flowContext, this, (this.breakLabel = new BranchLabel()), true, true);
- switchContext.isExpression = this instanceof SwitchExpression;
CompilerOptions compilerOptions = currentScope.compilerOptions();
@@ -477,19 +475,6 @@ else if ((statement.bits & ASTNode.DocumentedFallthrough) == 0) { // the case is
complaintLevel = initialComplaintLevel; // reset complaint
fallThroughState = this.containsPatterns ? FALLTHROUGH : CASE;
} else {
- if (!isTrulyExpression() &&
- compilerOptions.complianceLevel >= ClassFileConstants.JDK14 &&
- statement instanceof YieldStatement &&
- ((YieldStatement) statement).isImplicit) {
- YieldStatement y = (YieldStatement) statement;
- Expression e = ((YieldStatement) statement).expression;
- /* JLS 13 14.11.2
- Switch labeled rules in switch statements differ from those in switch expressions (15.28).
- In switch statements they must be switch labeled statement expressions, ... */
- if (!y.expression.statementExpression()) {
- this.scope.problemReporter().invalidExpressionAsStatement(e);
- }
- }
fallThroughState = getFallThroughState(statement, currentScope); // reset below if needed
}
if ((complaintLevel = statement.complainIfUnreachable(caseInits, this.scope, complaintLevel, true)) < Statement.COMPLAINED_UNREACHABLE) {
@@ -505,7 +490,6 @@ Switch labeled rules in switch statements differ from those in switch expression
}
}
}
- completeNormallyCheck(currentScope);
}
final TypeBinding resolvedTypeBinding = this.expression.resolvedType;
@@ -823,13 +807,6 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream) {
int max = localKeysCopy[constantCount - 1];
int min = localKeysCopy[0];
if ((long) (constantCount * 2.5) > ((long) max - (long) min)) {
-
- // work-around 1.3 VM bug, if max>0x7FFF0000, must use lookup bytecode
- // see http://dev.eclipse.org/bugs/show_bug.cgi?id=21557
- if (max > 0x7FFF0000 && currentScope.compilerOptions().complianceLevel < ClassFileConstants.JDK1_4) {
- codeStream.lookupswitch(defaultLabel, this.constants, sortedIndexes, caseLabels);
-
- } else {
codeStream.tableswitch(
defaultLabel,
min,
@@ -838,7 +815,6 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream) {
sortedIndexes,
this.constMapping,
caseLabels);
- }
} else {
codeStream.lookupswitch(defaultLabel, this.constants, sortedIndexes, caseLabels);
}
@@ -885,7 +861,6 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream) {
if (this.preSwitchInitStateIndex != -1) {
codeStream.removeNotDefinitelyAssignedVariables(currentScope, this.preSwitchInitStateIndex);
}
- defaultLabel.place();
/* a default case is not needed for an exhaustive switch expression
* we need to handle the default case to throw an error in order to make the stack map consistent.
* All cases will return a value on the stack except the missing default case.
@@ -894,9 +869,10 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream) {
CompilerOptions compilerOptions = this.scope != null ? this.scope.compilerOptions() : null;
if (compilerOptions.complianceLevel >= ClassFileConstants.JDK19) {
// since 19 we have MatchException for this
- if (codeStream.lastAbruptCompletion != codeStream.position) {
+ if (this.statements.length > 0 && this.statements[this.statements.length - 1].canCompleteNormally()) {
codeStream.goto_(this.breakLabel); // hop, skip and jump over match exception throw.
}
+ defaultLabel.place();
codeStream.newJavaLangMatchException();
codeStream.dup();
codeStream.aconst_null();
@@ -905,6 +881,7 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream) {
codeStream.athrow();
} else {
// old style using IncompatibleClassChangeError:
+ defaultLabel.place();
codeStream.newJavaLangIncompatibleClassChangeError();
codeStream.dup();
codeStream.invokeJavaLangIncompatibleClassChangeErrorDefaultConstructor();
@@ -1108,11 +1085,9 @@ boolean isAllowedType(TypeBinding type) {
@Override
public void resolve(BlockScope upperScope) {
try {
- boolean isEnumSwitch = false;
boolean isStringSwitch = false;
TypeBinding expressionType = this.expression.resolveType(upperScope);
CompilerOptions compilerOptions = upperScope.compilerOptions();
- boolean isEnhanced = checkAndSetEnhanced(upperScope, expressionType);
if (expressionType != null) {
this.expression.computeConversion(upperScope, expressionType, expressionType);
checkType: {
@@ -1128,15 +1103,11 @@ public void resolve(BlockScope upperScope) {
if (expressionType.isCompatibleWith(TypeBinding.INT))
break checkType;
} else if (expressionType.isEnum()) {
- isEnumSwitch = true;
- if (compilerOptions.complianceLevel < ClassFileConstants.JDK1_5) {
- upperScope.problemReporter().incorrectSwitchType(this.expression, expressionType); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=360317
- }
break checkType;
} else if (!this.containsPatterns && !this.containsNull && upperScope.isBoxingCompatibleWith(expressionType, TypeBinding.INT)) {
this.expression.computeConversion(upperScope, TypeBinding.INT, expressionType);
break checkType;
- } else if (compilerOptions.complianceLevel >= ClassFileConstants.JDK1_7 && expressionType.id == TypeIds.T_JavaLangString) {
+ } else if (expressionType.id == TypeIds.T_JavaLangString) {
if (this.containsPatterns || this.containsNull) {
isStringSwitch = !JavaFeature.PATTERN_MATCHING_IN_SWITCH.isSupported(compilerOptions);
this.isNonTraditional = true;
@@ -1291,65 +1262,100 @@ && defaultFound && isExhaustive()) {
if (this.dispatchPatternCopy == null) {
addSecretPatternSwitchVariables(upperScope);
}
- reportMixingCaseTypes();
- // check default case for non-enum switch:
- boolean flagged = checkAndFlagDefaultSealed(upperScope, compilerOptions);
- if (!flagged && this.defaultCase == null) {
- if (ignoreMissingDefaultCase(compilerOptions, isEnumSwitch) && isEnumSwitch) {
- upperScope.methodScope().hasMissingSwitchDefault = true;
- } else {
- if (!isEnumSwitch && !isExhaustive()) {
+ complainIfNotExhaustiveSwitch(upperScope, expressionType, compilerOptions);
+
+ } finally {
+ if (this.scope != null) this.scope.enclosingCase = null; // no longer inside switch case block
+ }
+ }
+ private void complainIfNotExhaustiveSwitch(BlockScope upperScope, TypeBinding selectorType, CompilerOptions compilerOptions) {
+
+ boolean isEnhanced = isEnhancedSwitch(upperScope, selectorType);
+ if (selectorType != null && selectorType.isEnum()) {
+ if (isEnhanced)
+ this.switchBits |= SwitchStatement.Exhaustive; // negated below if found otherwise
+ if (this.defaultCase != null && !compilerOptions.reportMissingEnumCaseDespiteDefault)
+ return;
+
+ int constantCount = this.otherConstants == null ? 0 : this.otherConstants.length;
+ if (!((this.switchBits & TotalPattern) != 0) &&
+ ((this.containsPatterns || this.containsNull) ||
+ (constantCount >= this.caseCount &&
+ constantCount != ((ReferenceBinding)selectorType).enumConstantCount()))) {
+ Set unenumeratedConstants = unenumeratedConstants((ReferenceBinding) selectorType, constantCount);
+ if (unenumeratedConstants.size() != 0) {
+ this.switchBits &= ~SwitchStatement.Exhaustive;
+ if (!(this.defaultCase != null && (this.defaultCase.bits & DocumentedCasesOmitted) != 0)) {
if (isEnhanced)
upperScope.problemReporter().enhancedSwitchMissingDefaultCase(this.expression);
- else
- upperScope.problemReporter().missingDefaultCase(this, isEnumSwitch, expressionType);
- }
- }
- }
- // Exhaustiveness check for enum switch
- if (isEnumSwitch && compilerOptions.complianceLevel >= ClassFileConstants.JDK1_5) {
- if (this.defaultCase == null || compilerOptions.reportMissingEnumCaseDespiteDefault) {
- int constantCount = this.otherConstants == null ? 0 : this.otherConstants.length;
- if (isEnhanced)
- this.switchBits |= SwitchStatement.Exhaustive; // negated below if found otherwise
- if (!((this.switchBits & TotalPattern) != 0) &&
- ((this.containsPatterns || this.containsNull) ||
- (constantCount >= this.caseCount &&
- constantCount != ((ReferenceBinding)expressionType).enumConstantCount()))) {
- FieldBinding[] enumFields = ((ReferenceBinding) expressionType.erasure()).fields();
- for (int i = 0, max = enumFields.length; i < max; i++) {
- FieldBinding enumConstant = enumFields[i];
- if ((enumConstant.modifiers & ClassFileConstants.AccEnum) == 0) continue;
- findConstant : {
- for (int j = 0; j < constantCount; j++) {
- if ((enumConstant.id + 1) == this.otherConstants[j].c.intValue()) // zero should not be returned see bug 141810
- break findConstant;
- }
- this.switchBits &= ~SwitchStatement.Exhaustive;
- // enum constant did not get referenced from switch
- boolean suppress = (this.defaultCase != null && (this.defaultCase.bits & DocumentedCasesOmitted) != 0);
- if (!suppress) {
- if (isEnhanced)
- upperScope.problemReporter().enhancedSwitchMissingDefaultCase(this.expression);
- else
- reportMissingEnumConstantCase(upperScope, enumConstant);
- }
+ else {
+ for (FieldBinding enumConstant : unenumeratedConstants) {
+ reportMissingEnumConstantCase(upperScope, enumConstant);
}
}
}
}
- if (this.defaultCase == null) {
- if (ignoreMissingDefaultCase(compilerOptions, isEnumSwitch)) {
- upperScope.methodScope().hasMissingSwitchDefault = true;
- } else {
- upperScope.problemReporter().missingDefaultCase(this, isEnumSwitch, expressionType);
+ }
+
+ if (this.defaultCase == null) {
+ if (ignoreMissingDefaultCase(compilerOptions)) {
+ upperScope.methodScope().hasMissingSwitchDefault = true;
+ } else {
+ upperScope.problemReporter().missingDefaultCase(this, true, selectorType);
+ }
+ }
+ return;
+ }
+
+ if (isExhaustive() || this.defaultCase != null || selectorType == null) {
+ if (isEnhanced)
+ this.switchBits |= SwitchStatement.Exhaustive;
+ return;
+ }
+
+ if (JavaFeature.PATTERN_MATCHING_IN_SWITCH.isSupported(compilerOptions) && selectorType.isSealed() && caseElementsCoverSealedType((ReferenceBinding) selectorType, this.caseLabelElementTypes)) {
+ this.switchBits |= SwitchStatement.Exhaustive;
+ return;
+ }
+
+ if (selectorType.isRecordWithComponents() && this.containsRecordPatterns && caseElementsCoverRecordType(upperScope, compilerOptions, (ReferenceBinding) selectorType)) {
+ this.switchBits |= SwitchStatement.Exhaustive;
+ return;
+ }
+
+ if (!isExhaustive()) {
+ if (isEnhanced)
+ upperScope.problemReporter().enhancedSwitchMissingDefaultCase(this.expression);
+ else
+ upperScope.problemReporter().missingDefaultCase(this, false, selectorType);
+ }
+ }
+
+ // Return the set of enumerations belonging to the selector enum type that are NOT listed in case statements.
+ private Set unenumeratedConstants(ReferenceBinding enumType, int constantCount) {
+ FieldBinding[] enumFields = ((ReferenceBinding) enumType.erasure()).fields();
+ Set unenumerated = new HashSet<>(Arrays.asList(enumFields));
+ for (int i = 0, max = enumFields.length; i < max; i++) {
+ FieldBinding enumConstant = enumFields[i];
+ if ((enumConstant.modifiers & ClassFileConstants.AccEnum) == 0) {
+ unenumerated.remove(enumConstant);
+ continue;
+ }
+ for (int j = 0; j < constantCount; j++) {
+ if (TypeBinding.equalsEquals(this.otherConstants[j].e.resolvedType, enumType)) {
+ if (this.otherConstants[j].e instanceof NameReference reference) {
+ FieldBinding field = reference.fieldBinding();
+ int intValue = field.original().id + 1;
+ if ((enumConstant.id + 1) == intValue) { // zero should not be returned see bug 141810
+ unenumerated.remove(enumConstant);
+ break;
+ }
}
}
}
- } finally {
- if (this.scope != null) this.scope.enclosingCase = null; // no longer inside switch case block
}
+ return unenumerated;
}
private boolean isCaseStmtNullDefault(CaseStatement caseStmt) {
return caseStmt != null
@@ -1366,9 +1372,9 @@ private boolean isExhaustive() {
return (this.switchBits & SwitchStatement.Exhaustive) != 0;
}
- private boolean checkAndSetEnhanced(BlockScope upperScope, TypeBinding expressionType) {
+ private boolean isEnhancedSwitch(BlockScope upperScope, TypeBinding expressionType) {
if (JavaFeature.PATTERN_MATCHING_IN_SWITCH.isSupported(upperScope.compilerOptions())
- && expressionType != null && !(this instanceof SwitchExpression )) {
+ && expressionType != null && !(this instanceof SwitchExpression)) {
boolean acceptableType = !expressionType.isEnum();
switch (expressionType.id) {
@@ -1392,7 +1398,7 @@ private boolean checkAndSetEnhanced(BlockScope upperScope, TypeBinding expressio
return true;
}
}
- if (expressionType != null && JavaFeature.PRIMITIVES_IN_PATTERNS.isSupported(upperScope.compilerOptions())) {
+ if (expressionType != null && !(this instanceof SwitchExpression) && JavaFeature.PRIMITIVES_IN_PATTERNS.isSupported(upperScope.compilerOptions())) {
switch (expressionType.id) {
case TypeIds.T_float:
case TypeIds.T_double:
@@ -1407,89 +1413,47 @@ private boolean checkAndSetEnhanced(BlockScope upperScope, TypeBinding expressio
}
return false;
}
- private boolean checkAndFlagDefaultSealed(BlockScope skope, CompilerOptions compilerOptions) {
- if (this.defaultCase != null) { // mark covered as a side effect (since covers is intro in 406)
- this.switchBits |= SwitchStatement.Exhaustive;
- return false;
- }
- boolean checkSealed = this.containsPatterns
- && JavaFeature.SEALED_CLASSES.isSupported(compilerOptions)
- && JavaFeature.PATTERN_MATCHING_IN_SWITCH.isSupported(compilerOptions)
- && this.expression.resolvedType instanceof ReferenceBinding;
- if (!checkSealed) return false;
- ReferenceBinding ref = (ReferenceBinding) this.expression.resolvedType;
- if (!(ref.isClass() || ref.isInterface() || ref.isTypeVariable() || ref.isIntersectionType()))
- return false;
- if (ref instanceof TypeVariableBinding) {
- TypeVariableBinding tvb = (TypeVariableBinding) ref;
- ref = tvb.firstBound instanceof ReferenceBinding ? (ReferenceBinding) tvb.firstBound : ref;
- }
- if (ref.isRecord()) {
- boolean isRecordPattern = false;
- for (Pattern pattern : this.caseLabelElements) {
- if (pattern instanceof RecordPattern) {
- isRecordPattern = true;
- break;
- }
- }
- if (isRecordPattern)
- return checkAndFlagDefaultRecord(skope, compilerOptions, ref);
- }
- if (!ref.isSealed()) return false;
- if (!isExhaustiveWithCaseTypes(ref.getAllEnumerableReferenceTypes(), this.caseLabelElementTypes)) {
- if (this instanceof SwitchExpression) // non-exhaustive switch expressions will be flagged later.
- return false;
- skope.problemReporter().enhancedSwitchMissingDefaultCase(this.expression);
- return true;
- }
- this.switchBits |= SwitchStatement.Exhaustive;
- return false;
- }
- private boolean checkAndFlagDefaultRecord(BlockScope skope, CompilerOptions compilerOptions, ReferenceBinding ref) {
- RecordComponentBinding[] comps = ref.components();
- List allallowedTypes = new ArrayList<>();
- allallowedTypes.add(ref);
- if (comps == null || comps.length == 0) {
- if (!isExhaustiveWithCaseTypes(allallowedTypes, this.caseLabelElementTypes)) {
- skope.problemReporter().enhancedSwitchMissingDefaultCase(this.expression);
- return true;
- }
- return false;
- }
- // non-zero components
- RNode head = new RNode(ref);
+
+ private boolean caseElementsCoverRecordType(BlockScope skope, CompilerOptions compilerOptions, ReferenceBinding recordType) {
+ RNode head = new RNode(recordType);
for (Pattern pattern : this.caseLabelElements) {
head.addPattern(pattern);
}
CoverageCheckerVisitor ccv = new CoverageCheckerVisitor();
head.traverse(ccv);
- if (!ccv.covers) {
- skope.problemReporter().enhancedSwitchMissingDefaultCase(this.expression);
- return true; // not exhaustive, error flagged
- }
- this.switchBits |= SwitchStatement.Exhaustive;
- return false;
+ return ccv.covers;
}
- private boolean isExhaustiveWithCaseTypes(List allAllowedTypes, List listedTypes) {
- int pendingTypes = allAllowedTypes.size();
- for (ReferenceBinding pt : allAllowedTypes) {
- /* Per JLS 14.11.1.1: A type T that names an abstract sealed class or sealed interface is covered
- if every permitted direct subclass or subinterface of it is covered. These subtypes are already
- added to allAllowedTypes and subject to cover test.
- */
- if (pt.isAbstract() && pt.isSealed()) {
- --pendingTypes;
+
+ private boolean caseElementsCoverSealedType(ReferenceBinding sealedType, List listedTypes) {
+ List allAllowedTypes = sealedType.getAllEnumerableAvatars();
+ Iterator iterator = allAllowedTypes.iterator();
+ while (iterator.hasNext()) {
+ ReferenceBinding next = iterator.next();
+ if (next.isAbstract() && next.isSealed()) {
+ /* Per JLS 14.11.1.1: A type T that names an abstract sealed class or sealed interface is covered
+ if every permitted direct subclass or subinterface of it is covered. These subtypes are already
+ added to allAllowedTypes and subject to cover test.
+ */
+ iterator.remove();
continue;
}
+ if (next.isEnum()) {
+ int constantCount = this.otherConstants == null ? 0 : this.otherConstants.length;
+ Set unenumeratedConstants = unenumeratedConstants(next, constantCount);
+ if (unenumeratedConstants.size() == 0) {
+ iterator.remove();
+ continue;
+ }
+ }
for (TypeBinding type : listedTypes) {
// permits specifies classes, not parameterizations
- if (pt.erasure().isCompatibleWith(type.erasure())) {
- --pendingTypes;
+ if (next.erasure().isCompatibleWith(type.erasure())) {
+ iterator.remove();
break;
}
}
}
- return pendingTypes == 0;
+ return allAllowedTypes.size() == 0;
}
private boolean needPatternDispatchCopy() {
if (this.containsPatterns || (this.switchBits & QualifiedEnum) != 0)
@@ -1525,33 +1489,14 @@ private void addSecretPatternSwitchVariables(BlockScope upperScope) {
protected void reportMissingEnumConstantCase(BlockScope upperScope, FieldBinding enumConstant) {
upperScope.problemReporter().missingEnumConstantCase(this, enumConstant);
}
- protected boolean ignoreMissingDefaultCase(CompilerOptions compilerOptions, boolean isEnumSwitch) {
+ protected boolean ignoreMissingDefaultCase(CompilerOptions compilerOptions) {
return compilerOptions.getSeverity(CompilerOptions.MissingDefaultCase) == ProblemSeverities.Ignore;
}
@Override
public boolean isTrulyExpression() {
return false;
}
- private void reportMixingCaseTypes() {
- if (this.caseCount == 0) {
- if (this.defaultCase != null && this.defaultCase.isExpr)
- this.switchBits |= LabeledRules;
- return;
- }
- if (this.cases[0] == null)
- return;
- boolean isExpr = this.cases[0].isExpr;
- if (isExpr) this.switchBits |= LabeledRules;
- for (int i = 1, l = this.caseCount; i < l; ++i) {
- if (this.cases[i].isExpr != isExpr) {
- this.scope.problemReporter().switchExpressionMixedCase(this.cases[i]);
- return;
- }
- }
- if (this.defaultCase != null && this.defaultCase.isExpr != isExpr) {
- this.scope.problemReporter().switchExpressionMixedCase(this.defaultCase);
- }
- }
+
private void reportDuplicateCase(final Statement duplicate,
final Statement original,
int length) {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SynchronizedStatement.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SynchronizedStatement.java
index 863d676822..cef936eed7 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SynchronizedStatement.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SynchronizedStatement.java
@@ -16,12 +16,18 @@
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
+import org.eclipse.jdt.internal.compiler.codegen.BranchLabel;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
+import org.eclipse.jdt.internal.compiler.flow.InsideStatementWithFinallyBlockFlowContext;
import org.eclipse.jdt.internal.compiler.impl.Constant;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-public class SynchronizedStatement extends SubRoutineStatement {
+public class SynchronizedStatement extends StatementWithFinallyBlock { // comes with a hidden finally block that contains the monitorexit sequence
public Expression expression;
public Block block;
@@ -66,7 +72,7 @@ public FlowInfo analyseCode(
flowInfo =
this.block.analyseCode(
this.scope,
- new InsideSubRoutineFlowContext(flowContext, this),
+ new InsideStatementWithFinallyBlockFlowContext(flowContext, this),
expressionFlowInfo);
this.mergedSynchronizedInitStateIndex =
@@ -81,7 +87,7 @@ public FlowInfo analyseCode(
}
@Override
-public boolean isSubRoutineEscaping() {
+public boolean isFinallyBlockEscaping() {
return false;
}
@@ -168,10 +174,10 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream) {
}
/**
- * @see SubRoutineStatement#generateSubRoutineInvocation(BlockScope, CodeStream, Object, int, LocalVariableBinding)
+ * @see StatementWithFinallyBlock#generateFinallyBlock(BlockScope, CodeStream, Object, int)
*/
@Override
-public boolean generateSubRoutineInvocation(BlockScope currentScope, CodeStream codeStream, Object targetLocation, int stateIndex, LocalVariableBinding secretLocal) {
+public boolean generateFinallyBlock(BlockScope currentScope, CodeStream codeStream, Object targetLocation, int stateIndex) {
codeStream.load(this.synchroVariable);
codeStream.monitorexit();
exitAnyExceptionHandler();
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TextBlock.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TextBlock.java
index 8675c3cd82..601391b855 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TextBlock.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TextBlock.java
@@ -12,12 +12,6 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jdt.core.compiler.CharOperation;
-import org.eclipse.jdt.core.compiler.InvalidInputException;
-import org.eclipse.jdt.internal.compiler.parser.ScannerHelper;
import org.eclipse.jdt.internal.compiler.util.Util;
public class TextBlock extends StringLiteral {
@@ -31,272 +25,6 @@ private TextBlock(char[] token, int start, int end, int lineNumber, int endLineN
public static TextBlock createTextBlock(char[] token, int start, int end, int lineNumber, int endLineNumber) {
return new TextBlock(token, start,end, lineNumber, endLineNumber);
}
- public static char[][] convertTextBlockToLines(char[] all) {
- // 1. Normalize, i.e. convert all CR CRLF to LF
- all = normalize(all);
- // 2. Split into lines. Consider both \n and \r as line separators
- char[][] lines = CharOperation.splitOn('\n', all);
- int size = lines.length;
- List list = new ArrayList<>(lines.length);
- for(int i = 0; i < lines.length; i++) {
- char[] line = lines[i];
- if (i + 1 == size && line.length == 0) {
- list.add(line);
- break;
- }
- char[][] sub = CharOperation.splitOn('\r', line);
- if (sub.length == 0) {
- list.add(line);
- } else {
- for (char[] cs : sub) {
- list.add(cs);
- }
- }
- }
- size = list.size();
- lines = list.toArray(new char[size][]);
- return lines;
- }
- public static int getTextBlockIndent(char[][] lines) {
- int prefix = -1;
- int size = lines.length;
- for(int i = 0; i < size; i++) {
- char[] line = lines[i];
- boolean blank = true;
- int whitespaces = 0;
- for (char c : line) {
- if (blank) {
- if (ScannerHelper.isWhitespace(c)) {
- whitespaces++;
- } else {
- blank = false;
- }
- }
- }
- // The last line with closing delimiter is part of the
- // determining line list even if empty
- if (!blank || (i+1 == size)) {
- if (prefix < 0 || whitespaces < prefix) {
- prefix = whitespaces;
- }
- }
- }
- return prefix == -1 ? 0 : prefix;
- }
- public static int getIndentForFragments(char[][] fragments) {
- int prefix = -1;
- for(int index = 0; index < fragments.length; index++) {
- char[][] lines = convertTextBlockToLines(fragments[index]);
- int size = lines.length;
- for(int i = 0; i < size; i++) {
- if (index > 0 && i == 0) {
- continue;
- }
- char[] line = lines[i];
- boolean blank = true;
- int whitespaces = 0;
- for (char c : line) {
- if (blank) {
- if (ScannerHelper.isWhitespace(c)) {
- whitespaces++;
- } else {
- blank = false;
- }
- }
- }
- // The last line with closing delimiter is part of the
- // determining line list even if empty
- if (!blank || (i+1 == size)) {
- if (prefix < 0 || whitespaces < prefix) {
- prefix = whitespaces;
- }
- }
- }
- }
- return prefix == -1 ? 0 : prefix;
- }
- public static char[] formatTextBlock(char[] all, int indent, boolean followsExp, boolean precedesExp) {
- char[][] lines = convertTextBlockToLines(all);
- return formatTextBlock(lines, indent, followsExp, precedesExp);
- }
- public static char[] formatTextBlock(char[][] lines, int indent) {
- return formatTextBlock(lines, indent, false, false);
- }
- public static char[] formatTextBlock(char[][] lines, int indent, boolean followsExp, boolean precedesExp) {
- // Handle incidental white space
- // Split into lines and identify determining lines
- // Remove the common white space prefix
- // Handle escape sequences that are not already done in getNextToken0()
- int size = lines.length;
- StringBuilder result = new StringBuilder();
- boolean newLine = false;
- for(int i = 0; i < size; i++) {
- if (i > 0)
- followsExp = false;
- char[] l = lines[i];
- int length = l.length;
- int prefix = followsExp ? 0 : indent;
- // Remove the common prefix from each line
- // And remove all trailing whitespace
- // Finally append the \n at the end of the line (except the last line)
- int trail = length;
- // Only the last line is really prefixed to the embedded
- // expression in a string template
- if (!precedesExp || i < (size -1)) {
- for(;trail > 0;) {
- if (!ScannerHelper.isWhitespace(l[trail-1])) {
- break;
- }
- trail--;
- }
- }
- if (i >= (size -1)) {
- if (newLine) result.append('\n');
- if (trail < prefix)
- continue;
- newLine = getLineContent(result, l, prefix, trail-1, false, true);
- } else {
- if (i > 0 && newLine)
- result.append('\n');
- if (trail <= prefix) {
- newLine = true;
- } else {
- boolean merge = length > 0 && l[length - 1] == '\\';
- newLine = getLineContent(result, l, prefix, trail-1, merge, false);
- }
- }
- }
- return result.toString().toCharArray();
- }
- private static char[] normalize(char[] content) {
- StringBuilder result = new StringBuilder();
- boolean isCR = false;
- for (char c : content) {
- switch (c) {
- case '\r':
- result.append(c);
- isCR = true;
- break;
- case '\n':
- if (!isCR) {
- result.append(c);
- }
- isCR = false;
- break;
- default:
- result.append(c);
- isCR = false;
- break;
- }
- }
- return result.toString().toCharArray();
- }
- // This method is for handling the left over escaped characters during the first
- // scanning (scanForStringLiteral). Admittedly this goes over the text block
- // content again char by char, but this is required in order to correctly
- // treat all the white space and line endings
- private static boolean getLineContent(StringBuilder result, char[] line, int start, int end, boolean merge, boolean lastLine) {
- int lastPointer = 0;
- for(int i = start; i < end;) {
- char c = line[i];
- if (c != '\\') {
- i++;
- continue;
- }
- if (i < end) {
- if (lastPointer + 1 <= i) {
- result.append(CharOperation.subarray(line, lastPointer == 0 ? start : lastPointer, i));
- }
- char next = line[++i];
- switch (next) {
- case '\\' :
- result.append('\\');
- if (i == end)
- merge = false;
- break;
- case 's' :
- result.append(' ');
- break;
- case '"':
- result.append('"');
- break;
- case 'b' :
- result.append('\b');
- break;
- case 'n' :
- result.append('\n');
- break;
- case 'r' :
- result.append('\r');
- break;
- case 't' :
- result.append('\t');
- break;
- case 'f' :
- result.append('\f');
- break;
- default :
- // Direct copy from Scanner#scanEscapeCharacter
- int pos = i + 1;
- int number = ScannerHelper.getHexadecimalValue(next);
- if (number >= 0 && number <= 7) {
- boolean zeroToThreeNot = number > 3;
- try {
- if (pos <= end && ScannerHelper.isDigit(next = line[pos])) {
- pos++;
- int digit = ScannerHelper.getHexadecimalValue(next);
- if (digit >= 0 && digit <= 7) {
- number = (number * 8) + digit;
- if (pos <= end && ScannerHelper.isDigit(next = line[pos])) {
- pos++;
- if (zeroToThreeNot) {
- // has read \NotZeroToThree OctalDigit Digit --> ignore last character
- } else {
- digit = ScannerHelper.getHexadecimalValue(next);
- if (digit >= 0 && digit <= 7){ // has read \ZeroToThree OctalDigit OctalDigit
- number = (number * 8) + digit;
- } else {
- // has read \ZeroToThree OctalDigit NonOctalDigit --> ignore last character
- }
- }
- } else {
- // has read \OctalDigit NonDigit--> ignore last character
- }
- } else {
- // has read \OctalDigit NonOctalDigit--> ignore last character
- }
- } else {
- // has read \OctalDigit --> ignore last character
- }
- } catch (InvalidInputException e) {
- // Unlikely as this has already been processed in scanForStringLiteral()
- }
- if (number < 255) {
- next = (char) number;
- }
- result.append(next);
- lastPointer = i = pos;
- continue;
- } else {
- // Dealing with just '\'
- result.append(c);
- lastPointer = i;
- continue;
- }
- }
- lastPointer = ++i;
- }
- }
- end = merge ? end : end >= line.length ? end : end + 1;
- char[] chars = lastPointer == 0 ?
- CharOperation.subarray(line, start, end) :
- CharOperation.subarray(line, lastPointer, end);
- // The below check is because CharOperation.subarray tend to return null when the
- // boundaries produce a zero sized char[]
- if (chars != null && chars.length > 0)
- result.append(chars);
- return (!merge && !lastLine);
- }
@Override
public StringBuilder printExpression(int indent, StringBuilder output) {
output.append("\"\"\"\n"); //$NON-NLS-1$
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ThisReference.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ThisReference.java
index 00daeb26c8..25ffc2c9f9 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ThisReference.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ThisReference.java
@@ -19,12 +19,17 @@
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.codegen.*;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.impl.JavaFeature;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
+import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
+import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
+import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
public class ThisReference extends Reference {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TrueLiteral.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TrueLiteral.java
index 86c395fae9..dd62c435ab 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TrueLiteral.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TrueLiteral.java
@@ -14,8 +14,8 @@
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
import org.eclipse.jdt.internal.compiler.codegen.BranchLabel;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
import org.eclipse.jdt.internal.compiler.impl.BooleanConstant;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TryStatement.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TryStatement.java
index d47d75cc72..6e45a3b492 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TryStatement.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TryStatement.java
@@ -1,3 +1,4 @@
+// GROOVY PATCHED
/*******************************************************************************
* Copyright (c) 2000, 2024 IBM Corporation and others.
*
@@ -36,15 +37,25 @@
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
+import org.eclipse.jdt.internal.compiler.codegen.BranchLabel;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.codegen.ConstantPool;
+import org.eclipse.jdt.internal.compiler.codegen.ExceptionLabel;
+import org.eclipse.jdt.internal.compiler.codegen.MultiCatchExceptionLabel;
+import org.eclipse.jdt.internal.compiler.codegen.StackMapFrameCodeStream;
+import org.eclipse.jdt.internal.compiler.flow.ExceptionHandlingFlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FinallyFlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
+import org.eclipse.jdt.internal.compiler.flow.InsideStatementWithFinallyBlockFlowContext;
+import org.eclipse.jdt.internal.compiler.flow.UnconditionalFlowInfo;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.impl.Constant;
+import org.eclipse.jdt.internal.compiler.impl.JavaFeature;
import org.eclipse.jdt.internal.compiler.lookup.*;
-public class TryStatement extends SubRoutineStatement {
+public class TryStatement extends StatementWithFinallyBlock {
- static final char[] SECRET_RETURN_ADDRESS_NAME = " returnAddress".toCharArray(); //$NON-NLS-1$
static final char[] SECRET_ANY_HANDLER_NAME = " anyExceptionHandler".toCharArray(); //$NON-NLS-1$
static final char[] SECRET_PRIMARY_EXCEPTION_VARIABLE_NAME = " primaryException".toCharArray(); //$NON-NLS-1$
static final char[] SECRET_CAUGHT_THROWABLE_VARIABLE_NAME = " caughtThrowable".toCharArray(); //$NON-NLS-1$;
@@ -59,27 +70,25 @@ public class TryStatement extends SubRoutineStatement {
public Block finallyBlock;
BlockScope scope;
- public UnconditionalFlowInfo subRoutineInits;
+ public UnconditionalFlowInfo finallyBlockInits;
ReferenceBinding[] caughtExceptionTypes;
boolean[] catchExits;
- BranchLabel subRoutineStartLabel;
+ BranchLabel finallyBlockStartLabel;
public LocalVariableBinding anyExceptionVariable,
- returnAddressVariable,
secretReturnValue;
ExceptionLabel[] declaredExceptionLabels; // only set while generating code
- // for inlining/optimizing JSR instructions
+ // for sharing finally blocks - behavior disabled by https://bugs.eclipse.org/bugs/show_bug.cgi?id=404146; can be enabled only by an undocumented option.
private Object[] reusableJSRTargets;
private BranchLabel[] reusableJSRSequenceStartLabels;
private int[] reusableJSRStateIndexes;
private int reusableJSRTargetsCount = 0;
- private static final int NO_FINALLY = 0; // no finally block
- private static final int FINALLY_SUBROUTINE = 1; // finally is generated as a subroutine (using jsr/ret bytecodes)
+ private static final int NO_FINALLY = 0; // no finally block
private static final int FINALLY_DOES_NOT_COMPLETE = 2; // non returning finally is optimized with only one instance of finally block
- private static final int FINALLY_INLINE = 3; // finally block must be inlined since cannot use jsr/ret bytecodes >1.5
+ private static final int FINALLY_INLINE = 3; // finally block must be inlined
// for local variables table attributes
int mergedInitStateIndex = -1;
@@ -97,11 +106,11 @@ public class TryStatement extends SubRoutineStatement {
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
// Consider the try block and catch block so as to compute the intersection of initializations and
- // the minimum exit relative depth amongst all of them. Then consider the subroutine, and append its
- // initialization to the try/catch ones, if the subroutine completes normally. If the subroutine does not
+ // the minimum exit relative depth amongst all of them. Then consider the finally block, and append its
+ // initialization to the try/catch ones, if the finally block completes normally. If it does not
// complete, then only keep this result for the rest of the analysis
- // process the finally block (subroutine) - create a context for the subroutine
+ // process the finally block - create a context for it
this.preTryInitStateIndex =
currentScope.methodScope().recordInitializationStates(flowInfo);
@@ -115,16 +124,13 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
if (this.caughtThrowableVariable != null) {
this.caughtThrowableVariable.useFlag = LocalVariableBinding.USED;
}
- if (this.returnAddressVariable != null) { // TODO (philippe) if subroutine is escaping, unused
- this.returnAddressVariable.useFlag = LocalVariableBinding.USED;
- }
int resourcesLength = this.resources.length;
if (resourcesLength > 0) {
this.postResourcesInitStateIndexes = new int[resourcesLength];
}
- if (this.subRoutineStartLabel == null) {
+ if (this.finallyBlockStartLabel == null) {
// no finally block -- this is a simplified copy of the else part
if (flowContext instanceof FinallyFlowContext) {
// if this TryStatement sits inside another TryStatement, establish the wiring so that
@@ -171,7 +177,12 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
}
}
if (localVariableBinding != null) {
- localVariableBinding.useFlag = LocalVariableBinding.USED; // Is implicitly used anyways.
+ CompilerOptions compilerOptions = currentScope.compilerOptions();
+ long sourceLevel = compilerOptions.sourceLevel;
+ boolean enablePreviewFeatures = compilerOptions.enablePreviewFeatures;
+ if (!JavaFeature.UNNAMMED_PATTERNS_AND_VARS.isSupported(sourceLevel, enablePreviewFeatures)) {
+ localVariableBinding.useFlag = LocalVariableBinding.USED; // Is implicitly used anyways.
+ }
}
MethodBinding closeMethod = findCloseMethod(resource, resolvedType);
if (closeMethod != null && closeMethod.isValidBinding() && closeMethod.returnType.id == TypeIds.T_void) {
@@ -229,11 +240,11 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
return tryInfo;
} else {
- InsideSubRoutineFlowContext insideSubContext;
+ InsideStatementWithFinallyBlockFlowContext insideSubContext;
FinallyFlowContext finallyContext;
- UnconditionalFlowInfo subInfo;
+ UnconditionalFlowInfo finallyInfo;
// analyse finally block first
- insideSubContext = new InsideSubRoutineFlowContext(flowContext, this);
+ insideSubContext = new InsideStatementWithFinallyBlockFlowContext(flowContext, this);
if (flowContext instanceof FinallyFlowContext) {
// if this TryStatement sits inside another TryStatement, establish the wiring so that
// FlowContext.markFinallyNullStatus can report into initsOnFinally of the outer try context:
@@ -253,7 +264,7 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
flowInfo);
insideSubContext.initsOnFinally = handlingContext.initsOnFinally;
- subInfo =
+ finallyInfo =
this.finallyBlock
.analyseCode(
currentScope,
@@ -261,19 +272,19 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
flowInfo.nullInfoLessUnconditionalCopy())
.unconditionalInits();
handlingContext.conditionalLevel = 0; // start collection initsOnFinally only after analysing the finally block
- if (subInfo == FlowInfo.DEAD_END) {
- this.bits |= ASTNode.IsSubRoutineEscaping;
+ if (finallyInfo == FlowInfo.DEAD_END) {
+ this.bits |= ASTNode.IsFinallyBlockEscaping;
this.scope.problemReporter().finallyMustCompleteNormally(this.finallyBlock);
} else {
// for resource analysis we need the finallyInfo in these nested scopes:
- FlowInfo finallyInfo = subInfo.copy();
- this.tryBlock.scope.finallyInfo = finallyInfo;
+ FlowInfo finallyInfoCopy = finallyInfo.copy();
+ this.tryBlock.scope.finallyInfo = finallyInfoCopy;
if (this.catchBlocks != null) {
for (int i = 0; i < this.catchBlocks.length; i++)
- this.catchBlocks[i].scope.finallyInfo = finallyInfo;
+ this.catchBlocks[i].scope.finallyInfo = finallyInfoCopy;
}
}
- this.subRoutineInits = subInfo;
+ this.finallyBlockInits = finallyInfo;
// only try blocks initialize that member - may consider creating a
// separate class if needed
@@ -368,12 +379,12 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
this.naturalExitMergeInitStateIndex =
currentScope.methodScope().recordInitializationStates(tryInfo);
- if (subInfo == FlowInfo.DEAD_END) {
+ if (finallyInfo == FlowInfo.DEAD_END) {
this.mergedInitStateIndex =
- currentScope.methodScope().recordInitializationStates(subInfo);
- return subInfo;
+ currentScope.methodScope().recordInitializationStates(finallyInfo);
+ return finallyInfo;
} else {
- FlowInfo mergedInfo = tryInfo.addInitializationsFrom(subInfo);
+ FlowInfo mergedInfo = tryInfo.addInitializationsFrom(finallyInfo);
this.mergedInitStateIndex =
currentScope.methodScope().recordInitializationStates(mergedInfo);
return mergedInfo;
@@ -463,7 +474,7 @@ private boolean isUncheckedCatchBlock(int catchBlock) {
@Override
public ExceptionLabel enterAnyExceptionHandler(CodeStream codeStream) {
- if (this.subRoutineStartLabel == null)
+ if (this.finallyBlockStartLabel == null)
return null;
return super.enterAnyExceptionHandler(codeStream);
}
@@ -473,6 +484,10 @@ public void enterDeclaredExceptionHandlers(CodeStream codeStream) {
for (int i = 0, length = this.declaredExceptionLabels == null ? 0 : this.declaredExceptionLabels.length; i < length; i++) {
this.declaredExceptionLabels[i].placeStart();
}
+}
+
+@Override
+public void enterResourceExceptionHandlers(CodeStream codeStream) {
int resourceCount = this.resources.length;
if (resourceCount > 0 && this.resourceExceptionLabels != null) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=375248
// Reinstall handlers
@@ -484,7 +499,7 @@ public void enterDeclaredExceptionHandlers(CodeStream codeStream) {
@Override
public void exitAnyExceptionHandler() {
- if (this.subRoutineStartLabel == null)
+ if (this.finallyBlockStartLabel == null)
return;
super.exitAnyExceptionHandler();
}
@@ -497,31 +512,24 @@ public void exitDeclaredExceptionHandlers(CodeStream codeStream) {
}
private int finallyMode() {
- if (this.subRoutineStartLabel == null) {
+ if (this.finallyBlockStartLabel == null) {
return NO_FINALLY;
- } else if (isSubRoutineEscaping()) {
+ } else if (isFinallyBlockEscaping()) {
return FINALLY_DOES_NOT_COMPLETE;
} else {
return FINALLY_INLINE;
}
}
-/**
- * Try statement code generation with or without jsr bytecode use
- * post 1.5 target level, cannot use jsr bytecode, must instead inline finally block
- * returnAddress is only allocated if jsr is allowed
- */
+
@Override
public void generateCode(BlockScope currentScope, CodeStream codeStream) {
if ((this.bits & ASTNode.IsReachable) == 0) {
return;
}
- boolean isStackMapFrameCodeStream = codeStream instanceof StackMapFrameCodeStream;
+
// in case the labels needs to be reinitialized
// when the code generation is restarted in wide mode
this.anyExceptionLabel = null;
- this.reusableJSRTargets = null;
- this.reusableJSRSequenceStartLabels = null;
- this.reusableJSRTargetsCount = 0;
int pc = codeStream.position;
int finallyMode = finallyMode();
@@ -548,8 +556,8 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream) {
} else {
exceptionLabels = null;
}
- if (this.subRoutineStartLabel != null) {
- this.subRoutineStartLabel.initialize(codeStream);
+ if (this.finallyBlockStartLabel != null) {
+ this.finallyBlockStartLabel.initialize(codeStream);
enterAnyExceptionHandler(codeStream);
}
// generate the try block
@@ -669,7 +677,6 @@ Our initialization type state is the same as it was at the end of the just concl
// place end positions of user-defined exception labels
if (tryBlockHasSomeCode) {
- // natural exit may require subroutine invocation (if finally != null)
BranchLabel naturalExitLabel = new BranchLabel(codeStream);
BranchLabel postCatchesFinallyLabel = null;
boolean patternAccessorsMayThrow = codeStream.patternAccessorsMayThrow(this.tryBlock.scope);
@@ -681,7 +688,6 @@ Our initialization type state is the same as it was at the end of the just concl
if ((this.bits & ASTNode.IsTryBlockExiting) == 0) {
int position = codeStream.position;
switch(finallyMode) {
- case FINALLY_SUBROUTINE :
case FINALLY_INLINE :
requiresNaturalExit = true;
if (this.naturalExitMergeInitStateIndex != -1) {
@@ -698,7 +704,7 @@ Our initialization type state is the same as it was at the end of the just concl
codeStream.goto_(naturalExitLabel);
break;
case FINALLY_DOES_NOT_COMPLETE :
- codeStream.goto_(this.subRoutineStartLabel);
+ codeStream.goto_(this.finallyBlockStartLabel);
break;
}
@@ -753,9 +759,7 @@ Our initialization type state is the same as it was at the end of the just concl
switch(finallyMode) {
case FINALLY_INLINE :
// inlined finally here can see all merged variables
- if (isStackMapFrameCodeStream) {
- ((StackMapFrameCodeStream) codeStream).pushStateIndex(this.naturalExitMergeInitStateIndex);
- }
+ ((StackMapFrameCodeStream) codeStream).pushStateIndex(this.naturalExitMergeInitStateIndex);
if (this.catchExitInitStateIndexes[i] != -1) {
codeStream.removeNotDefinitelyAssignedVariables(currentScope, this.catchExitInitStateIndexes[i]);
codeStream.addDefinitelyAssignedVariables(currentScope, this.catchExitInitStateIndexes[i]);
@@ -763,13 +767,9 @@ Our initialization type state is the same as it was at the end of the just concl
// entire sequence for finally is associated to finally block
this.finallyBlock.generateCode(this.scope, codeStream);
codeStream.goto_(postCatchesFinallyLabel);
- if (isStackMapFrameCodeStream) {
- ((StackMapFrameCodeStream) codeStream).popStateIndex();
- }
+ ((StackMapFrameCodeStream) codeStream).popStateIndex();
+
break;
- case FINALLY_SUBROUTINE :
- requiresNaturalExit = true;
- //$FALL-THROUGH$
case NO_FINALLY :
if (this.naturalExitMergeInitStateIndex != -1) {
codeStream.removeNotDefinitelyAssignedVariables(currentScope, this.naturalExitMergeInitStateIndex);
@@ -778,21 +778,17 @@ Our initialization type state is the same as it was at the end of the just concl
codeStream.goto_(naturalExitLabel);
break;
case FINALLY_DOES_NOT_COMPLETE :
- codeStream.goto_(this.subRoutineStartLabel);
+ codeStream.goto_(this.finallyBlockStartLabel);
break;
}
}
}
}
- // extra handler for trailing natural exit (will be fixed up later on when natural exit is generated below)
- ExceptionLabel naturalExitExceptionHandler = requiresNaturalExit && (finallyMode == FINALLY_SUBROUTINE)
- ? new ExceptionLabel(codeStream, null)
- : null;
// addition of a special handler so as to ensure that any uncaught exception (or exception thrown
// inside catch blocks) will run the finally block
int finallySequenceStartPC = codeStream.position;
- if (this.subRoutineStartLabel != null && this.anyExceptionLabel.getCount() != 0) {
+ if (this.finallyBlockStartLabel != null && this.anyExceptionLabel.getCount() != 0) {
codeStream.pushExceptionOnStack(this.scope.getJavaLangThrowable());
if (this.preTryInitStateIndex != -1) {
// reset initialization state, as for a normal catch block
@@ -800,75 +796,38 @@ Our initialization type state is the same as it was at the end of the just concl
codeStream.addDefinitelyAssignedVariables(currentScope, this.preTryInitStateIndex);
}
placeAllAnyExceptionHandler();
- if (naturalExitExceptionHandler != null) naturalExitExceptionHandler.place();
switch(finallyMode) {
- case FINALLY_SUBROUTINE :
- // any exception handler
- codeStream.store(this.anyExceptionVariable, false);
- codeStream.jsr(this.subRoutineStartLabel);
- codeStream.recordPositionsFrom(finallySequenceStartPC, this.finallyBlock.sourceStart);
- int position = codeStream.position;
- codeStream.throwAnyException(this.anyExceptionVariable);
- codeStream.recordPositionsFrom(position, this.finallyBlock.sourceEnd);
- // subroutine
- this.subRoutineStartLabel.place();
- codeStream.pushExceptionOnStack(this.scope.getJavaLangThrowable());
- position = codeStream.position;
- codeStream.store(this.returnAddressVariable, false);
- codeStream.recordPositionsFrom(position, this.finallyBlock.sourceStart);
- this.finallyBlock.generateCode(this.scope, codeStream);
- position = codeStream.position;
- codeStream.ret(this.returnAddressVariable.resolvedPosition);
- codeStream.recordPositionsFrom(
- position,
- this.finallyBlock.sourceEnd);
- // the ret bytecode is part of the subroutine
- break;
case FINALLY_INLINE :
// any exception handler
codeStream.store(this.anyExceptionVariable, false);
codeStream.addVariable(this.anyExceptionVariable);
codeStream.recordPositionsFrom(finallySequenceStartPC, this.finallyBlock.sourceStart);
- // subroutine
this.finallyBlock.generateCode(currentScope, codeStream);
- position = codeStream.position;
+ int position = codeStream.position;
codeStream.throwAnyException(this.anyExceptionVariable);
codeStream.removeVariable(this.anyExceptionVariable);
if (this.preTryInitStateIndex != -1) {
codeStream.removeNotDefinitelyAssignedVariables(currentScope, this.preTryInitStateIndex);
}
- this.subRoutineStartLabel.place();
+ this.finallyBlockStartLabel.place();
codeStream.recordPositionsFrom(position, this.finallyBlock.sourceEnd);
break;
case FINALLY_DOES_NOT_COMPLETE :
// any exception handler
codeStream.pop();
- this.subRoutineStartLabel.place();
+ this.finallyBlockStartLabel.place();
codeStream.recordPositionsFrom(finallySequenceStartPC, this.finallyBlock.sourceStart);
- // subroutine
this.finallyBlock.generateCode(this.scope, codeStream);
break;
}
- // will naturally fall into subsequent code after subroutine invocation
+ // will naturally fall into subsequent code after finally block execution
if (requiresNaturalExit) {
switch(finallyMode) {
- case FINALLY_SUBROUTINE :
- naturalExitLabel.place();
- int position = codeStream.position;
- naturalExitExceptionHandler.placeStart();
- codeStream.jsr(this.subRoutineStartLabel);
- naturalExitExceptionHandler.placeEnd();
- codeStream.recordPositionsFrom(
- position,
- this.finallyBlock.sourceEnd);
- break;
case FINALLY_INLINE :
// inlined finally here can see all merged variables
- if (isStackMapFrameCodeStream) {
- ((StackMapFrameCodeStream) codeStream).pushStateIndex(this.naturalExitMergeInitStateIndex);
- }
+ ((StackMapFrameCodeStream) codeStream).pushStateIndex(this.naturalExitMergeInitStateIndex);
if (this.naturalExitMergeInitStateIndex != -1) {
codeStream.removeNotDefinitelyAssignedVariables(currentScope, this.naturalExitMergeInitStateIndex);
codeStream.addDefinitelyAssignedVariables(currentScope, this.naturalExitMergeInitStateIndex);
@@ -877,16 +836,14 @@ Our initialization type state is the same as it was at the end of the just concl
// entire sequence for finally is associated to finally block
this.finallyBlock.generateCode(this.scope, codeStream);
if (postCatchesFinallyLabel != null) {
- position = codeStream.position;
+ int position = codeStream.position;
// entire sequence for finally is associated to finally block
codeStream.goto_(postCatchesFinallyLabel);
codeStream.recordPositionsFrom(
position,
this.finallyBlock.sourceEnd);
}
- if (isStackMapFrameCodeStream) {
- ((StackMapFrameCodeStream) codeStream).popStateIndex();
- }
+ ((StackMapFrameCodeStream) codeStream).popStateIndex();
break;
case FINALLY_DOES_NOT_COMPLETE :
break;
@@ -899,12 +856,12 @@ Our initialization type state is the same as it was at the end of the just concl
postCatchesFinallyLabel.place();
}
} else {
- // no subroutine, simply position end label (natural exit == end)
+ // no finally block, simply position end label (natural exit == end)
naturalExitLabel.place();
}
} else {
// try block had no effect, only generate the body of the finally block if any
- if (this.subRoutineStartLabel != null) {
+ if (this.finallyBlockStartLabel != null) {
this.finallyBlock.generateCode(this.scope, codeStream);
}
}
@@ -974,44 +931,9 @@ private boolean isDuplicateResourceReference(int index) {
return false;
}
-/**
- * @see SubRoutineStatement#generateSubRoutineInvocation(BlockScope, CodeStream, Object, int, LocalVariableBinding)
- */
-@Override
-public boolean generateSubRoutineInvocation(BlockScope currentScope, CodeStream codeStream, Object targetLocation, int stateIndex, LocalVariableBinding secretLocal) {
-
- int resourceCount = this.resources.length;
- if (resourceCount > 0 && this.resourceExceptionLabels != null) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=375248
- for (int i = resourceCount; i > 0; --i) {
- // Disarm the handlers and take care of resource closure.
- this.resourceExceptionLabels[i].placeEnd();
- BranchLabel exitLabel = new BranchLabel(codeStream);
- int invokeCloseStartPc = codeStream.position; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=343785
- generateCodeSnippet(this.resources[i - 1], codeStream, exitLabel, false);
- codeStream.recordPositionsFrom(invokeCloseStartPc, this.tryBlock.sourceEnd);
- exitLabel.place();
- }
- this.resourceExceptionLabels[0].placeEnd(); // outermost should end here as well, will start again on enter
- }
-
- boolean isStackMapFrameCodeStream = codeStream instanceof StackMapFrameCodeStream;
- int finallyMode = finallyMode();
- switch(finallyMode) {
- case FINALLY_DOES_NOT_COMPLETE :
- if (this.switchExpression != null) {
- exitAnyExceptionHandler();
- exitDeclaredExceptionHandlers(codeStream);
- this.finallyBlock.generateCode(currentScope, codeStream);
- return true;
- }
- codeStream.goto_(this.subRoutineStartLabel);
- return true;
-
- case NO_FINALLY :
- exitDeclaredExceptionHandlers(codeStream);
- return false;
- }
- // optimize subroutine invocation sequences, using the targetLocation (if any)
+// Disabled behavior enabled only by an undocumented option. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=404146
+private boolean reusedFinallyBlock(CodeStream codeStream, Object targetLocation, int stateIndex) {
+ // optimize finally block generation, using the targetLocation (if any)
CompilerOptions options = this.scope.compilerOptions();
if (options.shareCommonFinallyBlocks && targetLocation != null) {
boolean reuseTargetLocation = true;
@@ -1030,7 +952,7 @@ public boolean generateSubRoutineInvocation(BlockScope currentScope, CodeStream
continue nextReusableTarget;
}
// current target has been used in the past, simply branch to its label
- if ((this.reusableJSRStateIndexes[i] != stateIndex) && finallyMode == FINALLY_INLINE) {
+ if ((this.reusableJSRStateIndexes[i] != stateIndex) && finallyMode() == FINALLY_INLINE) {
reuseTargetLocation = false;
break nextReusableTarget;
} else {
@@ -1056,29 +978,55 @@ public boolean generateSubRoutineInvocation(BlockScope currentScope, CodeStream
this.reusableJSRSequenceStartLabels[this.reusableJSRTargetsCount++] = reusableJSRSequenceStartLabel;
}
}
- if (finallyMode == FINALLY_INLINE) {
- if (isStackMapFrameCodeStream) {
- ((StackMapFrameCodeStream) codeStream).pushStateIndex(stateIndex);
+ return false;
+}
+/**
+ * @see StatementWithFinallyBlock#generateFinallyBlock(BlockScope, CodeStream, Object, int)
+ */
+@Override
+public boolean generateFinallyBlock(BlockScope currentScope, CodeStream codeStream, Object targetLocation, int stateIndex) {
+
+ int resourceCount = this.resources.length;
+ if (resourceCount > 0 && this.resourceExceptionLabels != null) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=375248
+ for (int i = resourceCount; i > 0; --i) {
+ // Disarm the handlers and take care of resource closure.
+ this.resourceExceptionLabels[i].placeEnd();
+ BranchLabel exitLabel = new BranchLabel(codeStream);
+ int invokeCloseStartPc = codeStream.position; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=343785
+ generateCodeSnippet(this.resources[i - 1], codeStream, exitLabel, false);
+ codeStream.recordPositionsFrom(invokeCloseStartPc, this.tryBlock.sourceEnd);
+ exitLabel.place();
}
- // cannot use jsr bytecode, then simply inline the subroutine
- // inside try block, ensure to deactivate all catch block exception handlers while inlining finally block
+ this.resourceExceptionLabels[0].placeEnd(); // outermost should end here as well, will start again on enter
+ }
+
+ int finallyMode = finallyMode();
+ switch (finallyMode) {
+ case FINALLY_DOES_NOT_COMPLETE:
+ codeStream.goto_(this.finallyBlockStartLabel);
+ return true;
+ case NO_FINALLY:
+ exitDeclaredExceptionHandlers(codeStream);
+ return false;
+ }
+
+ /********* Begin: undocumented behavior off by default ******* */
+ if (reusedFinallyBlock( codeStream, targetLocation, stateIndex))
+ return true;
+ /********* End: undocumented behavior off by default ******* */
+
+ if (finallyMode == FINALLY_INLINE) {
+ ((StackMapFrameCodeStream) codeStream).pushStateIndex(stateIndex);
exitAnyExceptionHandler();
exitDeclaredExceptionHandlers(codeStream);
this.finallyBlock.generateCode(currentScope, codeStream);
- if (isStackMapFrameCodeStream) {
- ((StackMapFrameCodeStream) codeStream).popStateIndex();
- }
- } else {
- // classic subroutine invocation, distinguish case of non-returning subroutine
- codeStream.jsr(this.subRoutineStartLabel);
- exitAnyExceptionHandler();
- exitDeclaredExceptionHandlers(codeStream);
+ ((StackMapFrameCodeStream) codeStream).popStateIndex();
}
return false;
}
@Override
-public boolean isSubRoutineEscaping() {
- return (this.bits & ASTNode.IsSubRoutineEscaping) != 0;
+public boolean isFinallyBlockEscaping() {
+ return (this.bits & ASTNode.IsFinallyBlockEscaping) != 0;
}
@Override
@@ -1123,9 +1071,16 @@ public StringBuilder printStatement(int indent, StringBuilder output) {
public void resolve(BlockScope upperScope) {
// special scope for secret locals optimization.
this.scope = new BlockScope(upperScope);
-
+ /* GROOVY edit
+ if (upperScope.enclosingSwitchExpression() instanceof SwitchExpression swich)
+ */
+ var swich = upperScope.enclosingSwitchExpression();
+ if (swich != null) {
+ // GROOVY end
+ swich.jvmStackVolatile = true; // ought to prepare for any raised exception blowing up the the operand stack to smithereens
+ }
BlockScope finallyScope = null;
- BlockScope resourceManagementScope = null; // Single scope to hold all resources and additional secret variables.
+ BlockScope resourceManagementScope = null; // Single scope to hold all resources and additional secret variables.
int resourceCount = this.resources.length;
if (resourceCount > 0) {
resourceManagementScope = new BlockScope(this.scope);
@@ -1188,7 +1143,7 @@ public void resolve(BlockScope upperScope) {
// provision for returning and forcing the finally block to run
MethodScope methodScope = this.scope.methodScope();
- this.subRoutineStartLabel = new BranchLabel();
+ this.finallyBlockStartLabel = new BranchLabel();
this.anyExceptionVariable =
new LocalVariableBinding(TryStatement.SECRET_ANY_HANDLER_NAME, this.scope.getJavaLangThrowable(), ClassFileConstants.AccDefault, false);
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java
index 4b7f2b81cb..aa65bb9401 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java
@@ -33,16 +33,30 @@
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
-
-import org.eclipse.jdt.core.compiler.*;
-import org.eclipse.jdt.internal.compiler.*;
-import org.eclipse.jdt.internal.compiler.impl.*;
+import org.eclipse.jdt.core.compiler.CategorizedProblem;
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.core.compiler.IProblem;
+import org.eclipse.jdt.internal.compiler.ASTVisitor;
+import org.eclipse.jdt.internal.compiler.ClassFile;
+import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
+import org.eclipse.jdt.internal.compiler.flow.InitializationFlowContext;
+import org.eclipse.jdt.internal.compiler.flow.UnconditionalFlowInfo;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.eclipse.jdt.internal.compiler.impl.JavaFeature;
+import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
+import org.eclipse.jdt.internal.compiler.impl.StringConstant;
import org.eclipse.jdt.internal.compiler.lookup.*;
-import org.eclipse.jdt.internal.compiler.parser.*;
-import org.eclipse.jdt.internal.compiler.problem.*;
+import org.eclipse.jdt.internal.compiler.parser.Parser;
+import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
+import org.eclipse.jdt.internal.compiler.problem.AbortCompilationUnit;
+import org.eclipse.jdt.internal.compiler.problem.AbortMethod;
+import org.eclipse.jdt.internal.compiler.problem.AbortType;
+import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
+import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
import org.eclipse.jdt.internal.compiler.util.SimpleSetOfCharArray;
import org.eclipse.jdt.internal.compiler.util.Util;
@@ -1056,7 +1070,7 @@ public void manageEnclosingInstanceAccessIfNecessary(BlockScope currentScope, Fl
Scope outerScope = currentScope.parent;
if (!methodScope.isConstructorCall) {
nestedType.addSyntheticArgumentAndField(nestedType.enclosingType());
- outerScope = outerScope.enclosingClassScope();
+ outerScope = outerScope.enclosingInstanceScope();
earlySeen = methodScope.isInsideEarlyConstructionContext(nestedType.enclosingType(), false);
}
if (JavaFeature.FLEXIBLE_CONSTRUCTOR_BODIES.isSupported(currentScope.compilerOptions())) {
@@ -1074,6 +1088,8 @@ public void manageEnclosingInstanceAccessIfNecessary(BlockScope currentScope, Fl
earlySeen = cs.insideEarlyConstructionContext;
}
outerScope = outerScope.parent;
+ if (outerScope instanceof MethodScope ms && ms.isStatic)
+ break;
}
}
}
@@ -1349,7 +1365,9 @@ public void resolve() {
this.scope.problemReporter().missingDeprecatedAnnotationForType(this);
}
if ((annotationTagBits & TagBits.AnnotationFunctionalInterface) != 0) {
- if(!this.binding.isFunctionalInterface(this.scope)) {
+ if (this.binding.isSealed()) {
+ this.scope.problemReporter().functionalInterfaceMayNotBeSealed(this);
+ } else if (!this.binding.isFunctionalInterface(this.scope)) {
this.scope.problemReporter().notAFunctionalInterface(this);
}
}
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TypeParameter.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TypeParameter.java
index 2fd8cbeb2c..694046e6d3 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TypeParameter.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TypeParameter.java
@@ -19,7 +19,6 @@
package org.eclipse.jdt.internal.compiler.ast;
import java.util.List;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.ast.TypeReference.AnnotationCollector;
@@ -27,19 +26,7 @@
import org.eclipse.jdt.internal.compiler.codegen.AnnotationContext;
import org.eclipse.jdt.internal.compiler.codegen.AnnotationTargetTypeConstants;
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
-import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Scope;
-import org.eclipse.jdt.internal.compiler.lookup.TagBits;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.*;
public class TypeParameter extends AbstractVariableDeclaration {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TypePattern.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TypePattern.java
index 1eb31bbc5b..38a822204e 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TypePattern.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TypePattern.java
@@ -18,20 +18,10 @@
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.impl.JavaFeature;
-import org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
-import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.RecordComponentBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Scope;
-import org.eclipse.jdt.internal.compiler.lookup.TagBits;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.*;
public class TypePattern extends Pattern implements IGenerateTypeCheck {
@@ -155,7 +145,7 @@ public void generateTestingConversion(BlockScope scope, CodeStream codeStream) {
case WIDENING_REFERENCE_AND_UNBOXING_COVERSION_AND_WIDENING_PRIMITIVE_CONVERSION:
int rhsUnboxed = TypeIds.box2primitive(provided.superclass().id);
codeStream.generateUnboxingConversion(rhsUnboxed);
- this.computeConversion(scope, TypeBinding.wellKnownBaseType(rhsUnboxed), expected);
+ this.computeConversion(scope, expected, TypeBinding.wellKnownBaseType(rhsUnboxed));
codeStream.generateImplicitConversion(this.implicitConversion);
break;
case NARROWING_AND_UNBOXING_CONVERSION:
@@ -212,7 +202,11 @@ public boolean dominates(Pattern p) {
return false;
if (p.resolvedType == null || this.resolvedType == null)
return false;
- return p.resolvedType.erasure().isSubtypeOf(this.resolvedType.erasure(), false);
+
+ if (p.resolvedType.isSubtypeOf(this.resolvedType, false))
+ return true;
+
+ return p.resolvedType.erasure().findSuperTypeOriginatingFrom(this.resolvedType.erasure()) != null;
}
@Override
@@ -244,8 +238,11 @@ public TypeBinding resolveType(BlockScope scope) {
this.local.resolve(scope, true);
if (this.local.binding != null) {
this.local.binding.modifiers |= ExtraCompilerModifiers.AccOutOfFlowScope; // start out this way, will be BlockScope.include'd when definitely assigned
- if (enclosingPattern != null)
- this.local.binding.useFlag = LocalVariableBinding.USED; // syntactically required even if untouched
+ CompilerOptions compilerOptions = scope.compilerOptions();
+ if (!JavaFeature.UNNAMMED_PATTERNS_AND_VARS.isSupported(compilerOptions.sourceLevel, compilerOptions.enablePreviewFeatures)) {
+ if (enclosingPattern != null)
+ this.local.binding.useFlag = LocalVariableBinding.USED; // syntactically required even if untouched
+ }
if (this.local.type != null)
this.resolvedType = this.local.binding.type;
}
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TypeReference.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TypeReference.java
index 42d66fdccc..1e02242bb5 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TypeReference.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TypeReference.java
@@ -42,7 +42,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.ast.NullAnnotationMatching.CheckMode;
@@ -53,22 +52,7 @@
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.impl.Constant;
-import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
-import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Scope;
-import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Substitution;
-import org.eclipse.jdt.internal.compiler.lookup.TagBits;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
+import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
public abstract class TypeReference extends Expression {
@@ -573,9 +557,6 @@ && isTypeUseDeprecated(type, scope)) {
public boolean isTypeReference() {
return true;
}
-public boolean isImplicit() {
- return false;
-}
public boolean isWildcard() {
return false;
}
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/UnaryExpression.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/UnaryExpression.java
index f15cb60366..f022c2f517 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/UnaryExpression.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/UnaryExpression.java
@@ -17,11 +17,16 @@
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.impl.*;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.codegen.BranchLabel;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
+import org.eclipse.jdt.internal.compiler.impl.BooleanConstant;
+import org.eclipse.jdt.internal.compiler.impl.Constant;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
public class UnaryExpression extends OperatorExpression {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java
index 90f81191f2..e0a895c707 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java
@@ -20,11 +20,16 @@
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.impl.*;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.codegen.BranchLabel;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
+import org.eclipse.jdt.internal.compiler.flow.LoopingFlowContext;
+import org.eclipse.jdt.internal.compiler.impl.Constant;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
public class WhileStatement extends Statement {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Wildcard.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Wildcard.java
index 2f2915df4c..2ed6275715 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Wildcard.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Wildcard.java
@@ -23,7 +23,13 @@
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.lookup.Binding;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
+import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
+import org.eclipse.jdt.internal.compiler.lookup.Scope;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.WildcardBinding;
/**
* Node to represent Wildcard
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/YieldStatement.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/YieldStatement.java
index fdb4ca5390..aad443020e 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/YieldStatement.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/YieldStatement.java
@@ -14,20 +14,18 @@
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
-import org.eclipse.jdt.internal.compiler.flow.*;
-import org.eclipse.jdt.internal.compiler.impl.Constant;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
+import org.eclipse.jdt.internal.compiler.flow.InsideStatementWithFinallyBlockFlowContext;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
public class YieldStatement extends BranchStatement {
public Expression expression;
public SwitchExpression switchExpression;
-
public boolean isImplicit;
- static final char[] SECRET_YIELD_RESULT_VALUE_NAME = " secretYieldValue".toCharArray(); //$NON-NLS-1$
- private LocalVariableBinding secretYieldResultValue = null;
public YieldStatement(Expression expression, int sourceStart, int sourceEnd) {
super(null, sourceStart, sourceEnd);
@@ -36,188 +34,146 @@ public YieldStatement(Expression expression, int sourceStart, int sourceEnd) {
@Override
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
- // this.switchExpression != null true here.
-
- // here requires to generate a sequence of finally blocks invocations depending corresponding
- // to each of the traversed try statements, so that execution will terminate properly.
-
- // lookup the null label, this should answer the returnContext - for implicit yields, the nesting
- // doesn't occur since it immediately follow '->' and hence identical to default break - ie the
- // immediate breakable context is guaranteed to be the one intended;
- // while explicit yield should move up the parent to the switch expression.
- FlowContext targetContext = flowContext.getTargetContextForYield(!this.isImplicit);
+ /* Lookup target context: since an implicit yield immediately follows '->', it cannot be wrapped by another context,
+ so the immediate breakable context is guaranteed to be the one intended, while explicit yield should move up the parents
+ to the immediate enclosing switch **expression**
+ */
+ FlowContext targetContext = flowContext.getTargetContextForYield(this.isImplicit);
flowInfo = this.expression.analyseCode(currentScope, flowContext, flowInfo);
this.expression.checkNPEbyUnboxing(currentScope, flowContext, flowInfo);
- if (flowInfo.reachMode() == FlowInfo.REACHABLE && currentScope.compilerOptions().isAnnotationBasedNullAnalysisEnabled)
- checkAgainstNullAnnotation(currentScope, flowContext, flowInfo, this.expression);
targetContext.recordAbruptExit();
targetContext.expireNullCheckedFieldInfo();
- this.initStateIndex =
- currentScope.methodScope().recordInitializationStates(flowInfo);
+ this.initStateIndex = currentScope.methodScope().recordInitializationStates(flowInfo);
this.targetLabel = targetContext.breakLabel();
FlowContext traversedContext = flowContext;
- int subCount = 0;
- this.subroutines = new SubRoutineStatement[5];
+ int finallys = 0;
+ this.statementsWithFinallyBlock = new StatementWithFinallyBlock[5];
do {
- SubRoutineStatement sub;
- if ((sub = traversedContext.subroutine()) != null) {
- if (subCount == this.subroutines.length) {
- System.arraycopy(this.subroutines, 0, (this.subroutines = new SubRoutineStatement[subCount*2]), 0, subCount); // grow
- }
- this.subroutines[subCount++] = sub;
- if (sub.isSubRoutineEscaping()) {
+ StatementWithFinallyBlock stmt;
+ if ((stmt = traversedContext.statementWithFinallyBlock()) != null) {
+ if (finallys == this.statementsWithFinallyBlock.length)
+ System.arraycopy(this.statementsWithFinallyBlock, 0, (this.statementsWithFinallyBlock = new StatementWithFinallyBlock[finallys*2]), 0, finallys); // grow
+ this.statementsWithFinallyBlock[finallys++] = stmt;
+ if (stmt.isFinallyBlockEscaping()) {
+ this.bits |= ASTNode.IsAnyFinallyBlockEscaping;
break;
}
}
traversedContext.recordReturnFrom(flowInfo.unconditionalInits());
traversedContext.recordBreakTo(targetContext);
- if (traversedContext instanceof InsideSubRoutineFlowContext) {
- ASTNode node = traversedContext.associatedNode;
- if (node instanceof TryStatement) {
- flowInfo.addInitializationsFrom(((TryStatement) node).subRoutineInits); // collect inits
+ if (traversedContext instanceof InsideStatementWithFinallyBlockFlowContext) {
+ if (traversedContext.associatedNode instanceof TryStatement ts) {
+ flowInfo.addInitializationsFrom(ts.finallyBlockInits); // collect inits
}
} else if (traversedContext == targetContext) {
- // only record break info once accumulated through subroutines, and only against target context
targetContext.recordBreakFrom(flowInfo);
break;
}
} while ((traversedContext = traversedContext.getLocalParent()) != null);
- // resize subroutines
- if (subCount != this.subroutines.length) {
- System.arraycopy(this.subroutines, 0, (this.subroutines = new SubRoutineStatement[subCount]), 0, subCount);
- }
- return FlowInfo.DEAD_END;
-}
-
-@Override
-protected void setSubroutineSwitchExpression(SubRoutineStatement sub) {
- sub.setSwitchExpression(this.switchExpression);
-}
+ if (finallys != this.statementsWithFinallyBlock.length)
+ System.arraycopy(this.statementsWithFinallyBlock, 0, (this.statementsWithFinallyBlock = new StatementWithFinallyBlock[finallys]), 0, finallys);
-protected void addSecretYieldResultValue(BlockScope scope) {
- SwitchExpression se = this.switchExpression;
- if (se == null || !se.containsTry)
- return;
- LocalVariableBinding local = new LocalVariableBinding(
- YieldStatement.SECRET_YIELD_RESULT_VALUE_NAME,
- se.resolvedType,
- ClassFileConstants.AccDefault,
- false);
- local.setConstant(Constant.NotAConstant);
- local.useFlag = LocalVariableBinding.USED;
- local.declaration = new LocalDeclaration(YieldStatement.SECRET_YIELD_RESULT_VALUE_NAME, 0, 0);
- assert se.yieldResolvedPosition >= 0;
- local.resolvedPosition = se.yieldResolvedPosition;
- assert local.resolvedPosition < scope.maxOffset;
- scope.addLocalVariable(local);
- this.secretYieldResultValue = local;
+ return FlowInfo.DEAD_END;
}
-@Override
-protected void restartExceptionLabels(CodeStream codeStream) {
- SubRoutineStatement.reenterAllExceptionHandlers(this.subroutines, -1, codeStream);
+private void adjustOperandStackTopIfNeeded(CodeStream codeStream) { // See https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3135
+ if (this.expression.resolvedType == TypeBinding.NULL) {
+ if (!this.switchExpression.resolvedType.isBaseType()) { // no opcode called for to align the types, but we need to adjust the notion of type of TOS.
+ codeStream.operandStack.pop(TypeBinding.NULL);
+ codeStream.operandStack.push(this.switchExpression.resolvedType);
+ }
+ }
}
@Override
public void generateCode(BlockScope currentScope, CodeStream codeStream) {
- if ((this.bits & ASTNode.IsReachable) == 0) {
+
+ if ((this.bits & ASTNode.IsReachable) == 0)
return;
- }
- boolean generateExpressionResultCodeExpanded = false;
- if (this.switchExpression != null && this.switchExpression.containsTry && this.switchExpression.resolvedType != null ) {
- generateExpressionResultCodeExpanded = true;
- addSecretYieldResultValue(currentScope);
- assert this.secretYieldResultValue != null;
- codeStream.record(this.secretYieldResultValue);
- SingleNameReference lhs = new SingleNameReference(this.secretYieldResultValue.name, 0);
- lhs.binding = this.secretYieldResultValue;
- lhs.bits &= ~ASTNode.RestrictiveFlagMASK; // clear bits
- lhs.bits |= Binding.LOCAL;
- lhs.bits |= ASTNode.IsSecretYieldValueUsage;
- ((LocalVariableBinding) lhs.binding).markReferenced(); // TODO : Can be skipped?
- Assignment assignment = new Assignment(lhs, this.expression, 0);
- assignment.generateCode(currentScope, codeStream);
+
+ if (this.switchExpression != null)
+ this.switchExpression.refillOperandStackIfNeeded(codeStream, this);
+
+ int pc = codeStream.position;
+ boolean expressionGenerationDeferred = true; // If possible defer generating the expression to until after inlining of enclosing try's finally {}
+ if (this.expression.hasSideEffects() || this.statementsWithFinallyBlock.length == 0) { // can't defer or no need to defer
+ expressionGenerationDeferred = false;
+ boolean valueRequired = this.switchExpression != null && (this.bits & ASTNode.IsAnyFinallyBlockEscaping) == 0; // no value needed if finally completes abruptly or for a statement switch
+ this.expression.generateCode(currentScope, codeStream, valueRequired);
+ if (valueRequired)
+ adjustOperandStackTopIfNeeded(codeStream);
} else {
- this.expression.generateCode(currentScope, codeStream, this.switchExpression != null);
+ codeStream.nop(); // prevent exception ranges from being empty on account of deferral : try { yield 42; } catch (Exception ex) {} ...
}
- int pc = codeStream.position;
- // generation of code responsible for invoking the finally
- // blocks in sequence
- if (this.subroutines != null){
- for (int i = 0, max = this.subroutines.length; i < max; i++){
- SubRoutineStatement sub = this.subroutines[i];
- SwitchExpression se = sub.getSwitchExpression();
- setSubroutineSwitchExpression(sub);
- boolean didEscape = sub.generateSubRoutineInvocation(currentScope, codeStream, this.targetLabel, this.initStateIndex, null);
- sub.setSwitchExpression(se);
- if (didEscape) {
- if (generateExpressionResultCodeExpanded) {
- codeStream.removeVariable(this.secretYieldResultValue);
- }
- codeStream.recordPositionsFrom(pc, this.sourceStart);
- SubRoutineStatement.reenterAllExceptionHandlers(this.subroutines, i, codeStream);
- if (this.initStateIndex != -1) {
- codeStream.removeNotDefinitelyAssignedVariables(currentScope, this.initStateIndex);
- codeStream.addDefinitelyAssignedVariables(currentScope, this.initStateIndex);
- }
- restartExceptionLabels(codeStream);
- return;
+
+ // inline finally blocks in sequence
+ for (int i = 0, max = this.statementsWithFinallyBlock.length; i < max; i++) {
+ StatementWithFinallyBlock stmt = this.statementsWithFinallyBlock[i];
+ boolean didEscape = stmt.generateFinallyBlock(currentScope, codeStream, this.expression.reusableJSRTarget(), this.initStateIndex);
+ if (didEscape) {
+ codeStream.recordPositionsFrom(pc, this.sourceStart);
+ StatementWithFinallyBlock.reenterAllExceptionHandlers(this.statementsWithFinallyBlock, i, codeStream);
+ if (this.initStateIndex != -1) {
+ codeStream.removeNotDefinitelyAssignedVariables(currentScope, this.initStateIndex);
+ codeStream.addDefinitelyAssignedVariables(currentScope, this.initStateIndex);
}
+ return;
}
}
- if (generateExpressionResultCodeExpanded) {
- this.switchExpression.refillOperandStack(codeStream);
- codeStream.load(this.secretYieldResultValue);
- codeStream.removeVariable(this.secretYieldResultValue);
+
+ if (expressionGenerationDeferred) {
+ this.expression.generateCode(currentScope, codeStream, this.switchExpression != null);
+ adjustOperandStackTopIfNeeded(codeStream);
}
+
codeStream.goto_(this.targetLabel);
- codeStream.recordPositionsFrom(pc, this.sourceStart);
- SubRoutineStatement.reenterAllExceptionHandlers(this.subroutines, -1, codeStream);
if (this.initStateIndex != -1) {
codeStream.removeNotDefinitelyAssignedVariables(currentScope, this.initStateIndex);
codeStream.addDefinitelyAssignedVariables(currentScope, this.initStateIndex);
}
+ codeStream.recordPositionsFrom(pc, this.sourceStart);
+ StatementWithFinallyBlock.reenterAllExceptionHandlers(this.statementsWithFinallyBlock, -1, codeStream);
}
@Override
public void resolve(BlockScope scope) {
- if (this.switchExpression != null || this.isImplicit) {
- if (this.switchExpression == null && this.isImplicit && !this.expression.statementExpression()) {
- if (scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK14) {
- /* JLS 13 14.11.2
- Switch labeled rules in switch statements differ from those in switch expressions (15.28).
- In switch statements they must be switch labeled statement expressions, ... */
- scope.problemReporter().invalidExpressionAsStatement(this.expression);
- return;
- }
+ if (this.switchExpression == null) {
+ this.switchExpression = scope.enclosingSwitchExpression();
+ if (this.switchExpression != null && this.switchExpression.isPolyExpression()) {
+ this.expression.setExpressionContext(this.switchExpression.expressionContext); // result expressions feature in same context ...
+ this.expression.setExpectedType(this.switchExpression.expectedType); // ... with the same target type
}
- } else {
- if (scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK14) {
- scope.problemReporter().switchExpressionsYieldOutsideSwitchExpression(this);
+ }
+
+ this.expression.resolveType(scope);
+ if (this.switchExpression != null) {
+ this.switchExpression.results.add(this.expression);
+ }
+
+ if (this.isImplicit) {
+ if (this.switchExpression == null && !this.expression.statementExpression()) {
+ scope.problemReporter().invalidExpressionAsStatement(this.expression);
}
+ } else if (this.switchExpression == null) {
+ scope.problemReporter().yieldOutsideSwitchExpression(this);
}
- TypeBinding type = this.expression.resolveType(scope);
- if (this.switchExpression != null && type != null)
- this.switchExpression.originalTypeMap.put(this.expression, type);
}
@Override
public StringBuilder printStatement(int tab, StringBuilder output) {
- if (!this.isImplicit)
- printIndent(tab, output).append("yield"); //$NON-NLS-1$
if (this.isImplicit) {
this.expression.print(tab, output);
} else {
- output.append(' ');
+ printIndent(tab, output).append("yield "); //$NON-NLS-1$
this.expression.printExpression(tab, output);
}
return output.append(';');
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/BasicModule.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/BasicModule.java
index b811cee157..2173013c37 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/BasicModule.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/BasicModule.java
@@ -14,7 +14,6 @@
package org.eclipse.jdt.internal.compiler.batch;
import java.util.Arrays;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.ExportsStatement;
import org.eclipse.jdt.internal.compiler.ast.ModuleDeclaration;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java
index bab9dac7d9..18ae5d338a 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java
@@ -17,6 +17,21 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.batch;
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Function;
+import java.util.stream.Stream;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
@@ -36,22 +51,6 @@
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
import org.eclipse.jdt.internal.compiler.util.Util;
-import java.io.File;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.nio.file.FileVisitResult;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.SimpleFileVisitor;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.function.Function;
-import java.util.stream.Stream;
-
@SuppressWarnings({"rawtypes", "unchecked"})
public class ClasspathDirectory extends ClasspathLocation {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java
index 7de81432b7..3a0d3cd2bb 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java
@@ -27,7 +27,6 @@
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.batch.FileSystem.Classpath;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
@@ -35,11 +34,11 @@
import org.eclipse.jdt.internal.compiler.classfmt.ExternalAnnotationDecorator;
import org.eclipse.jdt.internal.compiler.classfmt.ExternalAnnotationProvider;
import org.eclipse.jdt.internal.compiler.env.AccessRuleSet;
+import org.eclipse.jdt.internal.compiler.env.IBinaryType;
import org.eclipse.jdt.internal.compiler.env.IModule;
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
-import org.eclipse.jdt.internal.compiler.env.IBinaryType;
-import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
import org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.ExternalAnnotationStatus;
+import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
import org.eclipse.jdt.internal.compiler.util.ManifestAnalyzer;
import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
import org.eclipse.jdt.internal.compiler.util.Util;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247.java
index 8b828fc6e0..e9212e833e 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247.java
@@ -26,7 +26,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.batch.FileSystem.Classpath;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247Jdk12.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247Jdk12.java
index aa488bc89b..4492a78588 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247Jdk12.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247Jdk12.java
@@ -27,7 +27,6 @@
import java.util.List;
import java.util.Map;
import java.util.function.Function;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.batch.FileSystem.Classpath;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathJmod.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathJmod.java
index f6079766b3..c9db9de7c5 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathJmod.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathJmod.java
@@ -20,7 +20,6 @@
import java.util.HashSet;
import java.util.List;
import java.util.zip.ZipEntry;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.batch.FileSystem.Classpath;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
@@ -28,9 +27,9 @@
import org.eclipse.jdt.internal.compiler.classfmt.ExternalAnnotationDecorator;
import org.eclipse.jdt.internal.compiler.classfmt.ExternalAnnotationProvider;
import org.eclipse.jdt.internal.compiler.env.AccessRuleSet;
+import org.eclipse.jdt.internal.compiler.env.IBinaryType;
import org.eclipse.jdt.internal.compiler.env.IModule;
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
-import org.eclipse.jdt.internal.compiler.env.IBinaryType;
import org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.ExternalAnnotationStatus;
import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
import org.eclipse.jdt.internal.compiler.util.Util;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathJrt.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathJrt.java
index 9e0957de01..7d4d428e1f 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathJrt.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathJrt.java
@@ -29,7 +29,6 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.zip.ZipFile;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathJsr199.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathJsr199.java
index fcff3f78b2..2e88aec470 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathJsr199.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathJsr199.java
@@ -25,10 +25,8 @@
import java.util.Iterator;
import java.util.List;
import java.util.Set;
-
import javax.tools.JavaFileManager;
import javax.tools.JavaFileObject;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.batch.FileSystem.Classpath;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathLocation.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathLocation.java
index 3cab64ed4e..7604025818 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathLocation.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathLocation.java
@@ -21,7 +21,6 @@
import java.util.List;
import java.util.Set;
import java.util.function.Function;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
import org.eclipse.jdt.internal.compiler.env.AccessRuleSet;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathMultiReleaseJar.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathMultiReleaseJar.java
index 2195c3da00..420e7dbb3e 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathMultiReleaseJar.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathMultiReleaseJar.java
@@ -11,7 +11,6 @@
import java.util.Enumeration;
import java.util.HashSet;
import java.util.zip.ZipEntry;
-
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
import org.eclipse.jdt.internal.compiler.classfmt.ExternalAnnotationDecorator;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathSourceJar.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathSourceJar.java
index 4314437df4..d394a2cb94 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathSourceJar.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathSourceJar.java
@@ -14,10 +14,9 @@
package org.eclipse.jdt.internal.compiler.batch;
import java.io.File;
-import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.util.zip.ZipEntry;
-
import org.eclipse.jdt.internal.compiler.env.AccessRuleSet;
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
import org.eclipse.jdt.internal.compiler.util.Util;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java
index 0889543668..277ef39609 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java
@@ -16,7 +16,6 @@
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;
import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/FileFinder.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/FileFinder.java
index 188b7a7b6b..91a1a7889f 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/FileFinder.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/FileFinder.java
@@ -16,7 +16,6 @@
import java.io.File;
import java.util.ArrayList;
import java.util.List;
-
import org.eclipse.jdt.internal.compiler.env.IModule;
public class FileFinder {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/FileSystem.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/FileSystem.java
index 4369867e74..ff32d8b856 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/FileSystem.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/FileSystem.java
@@ -34,27 +34,25 @@
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.zip.ZipFile;
-
import javax.lang.model.SourceVersion;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.eclipse.jdt.internal.compiler.classfmt.ExternalAnnotationDecorator;
import org.eclipse.jdt.internal.compiler.env.AccessRuleSet;
-import org.eclipse.jdt.internal.compiler.env.IModulePathEntry;
import org.eclipse.jdt.internal.compiler.env.IModule;
import org.eclipse.jdt.internal.compiler.env.IModuleAwareNameEnvironment;
+import org.eclipse.jdt.internal.compiler.env.IModulePathEntry;
+import org.eclipse.jdt.internal.compiler.env.IUpdatableModule;
+import org.eclipse.jdt.internal.compiler.env.IUpdatableModule.UpdateKind;
+import org.eclipse.jdt.internal.compiler.env.IUpdatableModule.UpdatesByKind;
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.lookup.ModuleBinding;
import org.eclipse.jdt.internal.compiler.parser.Parser;
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
-import org.eclipse.jdt.internal.compiler.env.IUpdatableModule;
-import org.eclipse.jdt.internal.compiler.env.IUpdatableModule.UpdateKind;
-import org.eclipse.jdt.internal.compiler.env.IUpdatableModule.UpdatesByKind;
-import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.util.JRTUtil;
import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
import org.eclipse.jdt.internal.compiler.util.Util;
@@ -295,7 +293,13 @@ public static Classpath getClasspath(String classpathName, String encoding, Acce
return getClasspath(classpathName, encoding, false, accessRuleSet, null, options, release);
}
public static Classpath getJrtClasspath(String jdkHome, String encoding, AccessRuleSet accessRuleSet, Map options) {
- return new ClasspathJrt(new File(convertPathSeparators(jdkHome)), true, accessRuleSet, null);
+ ClasspathJrt classpathJrt = new ClasspathJrt(new File(convertPathSeparators(jdkHome)), true, accessRuleSet, null);
+ try {
+ classpathJrt.initialize();
+ } catch (IOException e) {
+ // Broken entry, but let clients have it anyway.
+ }
+ return classpathJrt;
}
public static Classpath getOlderSystemRelease(String jdkHome, String release, AccessRuleSet accessRuleSet) {
return isJRE12Plus ?
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/Main.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/Main.java
index cc21bb551c..4c3ca0aad7 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/Main.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/Main.java
@@ -35,21 +35,7 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.batch;
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.LineNumberReader;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.io.StringReader;
-import java.io.UnsupportedEncodingException;
+import java.io.*;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -57,25 +43,10 @@
import java.nio.file.Paths;
import java.text.DateFormat;
import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
+import java.util.*;
import java.util.Map.Entry;
-import java.util.MissingResourceException;
-import java.util.Properties;
-import java.util.ResourceBundle;
-import java.util.Set;
-import java.util.StringTokenizer;
import java.util.function.Function;
import java.util.stream.IntStream;
-
import org.eclipse.jdt.core.compiler.CategorizedProblem;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.compiler.CompilationProgress;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ModuleFinder.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ModuleFinder.java
index 7a970f5e7e..6a36f108ea 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ModuleFinder.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ModuleFinder.java
@@ -24,15 +24,14 @@
import java.util.jar.Manifest;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
-
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
import org.eclipse.jdt.internal.compiler.batch.FileSystem.Classpath;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
import org.eclipse.jdt.internal.compiler.env.IModule;
-import org.eclipse.jdt.internal.compiler.env.PackageExportImpl;
import org.eclipse.jdt.internal.compiler.env.IModule.IPackageExport;
+import org.eclipse.jdt.internal.compiler.env.PackageExportImpl;
import org.eclipse.jdt.internal.compiler.parser.Parser;
import org.eclipse.jdt.internal.compiler.util.JRTUtil;
import org.eclipse.jdt.internal.compiler.util.Util;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java
index 9b692bb1f2..b9f84d38ff 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java
@@ -15,12 +15,22 @@
package org.eclipse.jdt.internal.compiler.classfmt;
import java.util.Arrays;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.Annotation;
import org.eclipse.jdt.internal.compiler.codegen.ConstantPool;
-import org.eclipse.jdt.internal.compiler.env.*;
-import org.eclipse.jdt.internal.compiler.impl.*;
+import org.eclipse.jdt.internal.compiler.env.ClassSignature;
+import org.eclipse.jdt.internal.compiler.env.EnumConstantSignature;
+import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation;
+import org.eclipse.jdt.internal.compiler.env.IBinaryElementValuePair;
+import org.eclipse.jdt.internal.compiler.impl.BooleanConstant;
+import org.eclipse.jdt.internal.compiler.impl.ByteConstant;
+import org.eclipse.jdt.internal.compiler.impl.CharConstant;
+import org.eclipse.jdt.internal.compiler.impl.DoubleConstant;
+import org.eclipse.jdt.internal.compiler.impl.FloatConstant;
+import org.eclipse.jdt.internal.compiler.impl.IntConstant;
+import org.eclipse.jdt.internal.compiler.impl.LongConstant;
+import org.eclipse.jdt.internal.compiler.impl.ShortConstant;
+import org.eclipse.jdt.internal.compiler.impl.StringConstant;
import org.eclipse.jdt.internal.compiler.lookup.TagBits;
import org.eclipse.jdt.internal.compiler.util.CharDeduplication;
import org.eclipse.jdt.internal.compiler.util.Util;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java
index 77a5090592..d93ad08048 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java
@@ -26,21 +26,10 @@
import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.function.Predicate;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.codegen.AnnotationTargetTypeConstants;
import org.eclipse.jdt.internal.compiler.codegen.AttributeNamesConstants;
-import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation;
-import org.eclipse.jdt.internal.compiler.env.IBinaryElementValuePair;
-import org.eclipse.jdt.internal.compiler.env.IBinaryField;
-import org.eclipse.jdt.internal.compiler.env.IBinaryMethod;
-import org.eclipse.jdt.internal.compiler.env.IBinaryModule;
-import org.eclipse.jdt.internal.compiler.env.IBinaryNestedType;
-import org.eclipse.jdt.internal.compiler.env.IBinaryType;
-import org.eclipse.jdt.internal.compiler.env.IBinaryTypeAnnotation;
-import org.eclipse.jdt.internal.compiler.env.IModule;
-import org.eclipse.jdt.internal.compiler.env.IRecordComponent;
-import org.eclipse.jdt.internal.compiler.env.ITypeAnnotationWalker;
+import org.eclipse.jdt.internal.compiler.env.*;
import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.ExternalAnnotationStatus;
import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
@@ -71,7 +60,7 @@ public class ClassFileReader extends ClassFileStruct implements IBinaryType {
private InnerClassInfo[] innerInfos;
private final char[][] interfaceNames;
private final int interfacesCount;
- private final char[][] permittedSubtypesNames;
+ private char[][] permittedSubtypesNames;
private int permittedSubtypesCount;
private MethodInfo[] methods;
private final int methodsCount;
@@ -404,7 +393,6 @@ public ClassFileReader(byte[] classFileBytes, char[] fileName, boolean fullyInit
char[] enclosingTypeNam = null;
char[] sourceFileNam = null;
char[] signatur = null;
- char[][] permittedSubtypesNam = null;
for (int i = 0; i < attributesCount; i++) {
int utf8Offset = this.constantPoolOffsets[u2At(readOffset)];
@@ -538,11 +526,9 @@ public ClassFileReader(byte[] classFileBytes, char[] fileName, boolean fullyInit
if (this.permittedSubtypesCount != 0) {
accessFlag |= ExtraCompilerModifiers.AccSealed;
offset += 2;
- permittedSubtypesNam = new char[this.permittedSubtypesCount][];
+ this.permittedSubtypesNames = new char[this.permittedSubtypesCount][];
for (int j = 0; j < this.permittedSubtypesCount; j++) {
- utf8Offset =
- this.constantPoolOffsets[u2At(this.constantPoolOffsets[u2At(offset)] + 1)];
- permittedSubtypesNam[j] = CharDeduplication.intern(utf8At(utf8Offset + 3, u2At(utf8Offset + 1)));
+ this.permittedSubtypesNames[j] = CharDeduplication.intern(getConstantClassNameAt(u2At(offset)));
offset += 2;
}
}
@@ -559,7 +545,6 @@ public ClassFileReader(byte[] classFileBytes, char[] fileName, boolean fullyInit
this.enclosingTypeName = enclosingTypeNam;
this.sourceFileName = sourceFileNam;
this.signature = signatur;
- this.permittedSubtypesNames= permittedSubtypesNam;
if (fullyInitialize) {
initialize();
}
@@ -813,7 +798,7 @@ public char[][] getInterfaceNames() {
}
@Override
-public char[][] getPermittedSubtypeNames() {
+public char[][] getPermittedSubtypesNames() {
return this.permittedSubtypesNames;
}
@@ -1126,14 +1111,14 @@ && hasStructuralTypeAnnotationChanges(getTypeAnnotations(), newClassFile.getType
return true;
}
- // permitted sub-types
- char[][] newPermittedSubtypeNames = newClassFile.getPermittedSubtypeNames();
- if (this.permittedSubtypesNames != newPermittedSubtypeNames) {
- int newPermittedSubtypesLength = newPermittedSubtypeNames == null ? 0 : newPermittedSubtypeNames.length;
+ // permitted subtypes
+ char[][] newPermittedSubtypesNames = newClassFile.getPermittedSubtypesNames();
+ if (this.permittedSubtypesNames != newPermittedSubtypesNames) {
+ int newPermittedSubtypesLength = newPermittedSubtypesNames == null ? 0 : newPermittedSubtypesNames.length;
if (newPermittedSubtypesLength != this.permittedSubtypesCount)
return true;
for (int i = 0, max = this.permittedSubtypesCount; i < max; i++)
- if (!CharOperation.equals(this.permittedSubtypesNames[i], newPermittedSubtypeNames[i]))
+ if (!CharOperation.equals(this.permittedSubtypesNames[i], newPermittedSubtypesNames[i]))
return true;
}
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ElementValuePairInfo.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ElementValuePairInfo.java
index b064be60f7..73b090dd61 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ElementValuePairInfo.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ElementValuePairInfo.java
@@ -15,7 +15,6 @@
package org.eclipse.jdt.internal.compiler.classfmt;
import java.util.Arrays;
-
import org.eclipse.jdt.core.compiler.CharOperation;
public class ElementValuePairInfo implements org.eclipse.jdt.internal.compiler.env.IBinaryElementValuePair {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ExternalAnnotationDecorator.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ExternalAnnotationDecorator.java
index f1603397dd..0e9e340e0d 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ExternalAnnotationDecorator.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ExternalAnnotationDecorator.java
@@ -21,7 +21,6 @@
import java.net.URI;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
-
import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation;
import org.eclipse.jdt.internal.compiler.env.IBinaryField;
import org.eclipse.jdt.internal.compiler.env.IBinaryMethod;
@@ -143,8 +142,8 @@ public char[] getSuperclassName() {
}
@Override
- public char[][] getPermittedSubtypeNames() {
- return this.inputType.getPermittedSubtypeNames();
+ public char[][] getPermittedSubtypesNames() {
+ return this.inputType.getPermittedSubtypesNames();
}
@Override
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ExternalAnnotationProvider.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ExternalAnnotationProvider.java
index e2fcc659da..77c7ce9685 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ExternalAnnotationProvider.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ExternalAnnotationProvider.java
@@ -15,6 +15,8 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.classfmt;
+import static org.eclipse.jdt.internal.compiler.util.Util.*;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -22,7 +24,6 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation;
import org.eclipse.jdt.internal.compiler.env.IBinaryElementValuePair;
@@ -32,8 +33,6 @@
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
import org.eclipse.jdt.internal.compiler.util.Util;
-import static org.eclipse.jdt.internal.compiler.util.Util.*;
-
public class ExternalAnnotationProvider {
public static final String ANNOTATION_FILE_EXTENSION= "eea"; //$NON-NLS-1$
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ModuleInfo.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ModuleInfo.java
index c81b7077c9..ce25cb56a1 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ModuleInfo.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ModuleInfo.java
@@ -15,7 +15,6 @@
import java.net.URI;
import java.util.Arrays;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation;
import org.eclipse.jdt.internal.compiler.env.IBinaryModule;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/TypeAnnotationInfo.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/TypeAnnotationInfo.java
index c1c1087373..520c27368a 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/TypeAnnotationInfo.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/TypeAnnotationInfo.java
@@ -15,7 +15,6 @@
package org.eclipse.jdt.internal.compiler.classfmt;
import java.util.Arrays;
-
import org.eclipse.jdt.internal.compiler.codegen.AnnotationTargetTypeConstants;
import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation;
import org.eclipse.jdt.internal.compiler.env.IBinaryTypeAnnotation;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java
index 37fd2d9f97..c2a820147c 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java
@@ -38,24 +38,10 @@
import java.util.Stack;
import java.util.function.Predicate;
import java.util.function.Supplier;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ClassFile;
import org.eclipse.jdt.internal.compiler.CompilationResult;
-import org.eclipse.jdt.internal.compiler.ast.ASTNode;
-import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.AllocationExpression;
-import org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression;
-import org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall;
-import org.eclipse.jdt.internal.compiler.ast.Expression;
-import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.FunctionalExpression;
-import org.eclipse.jdt.internal.compiler.ast.LambdaExpression;
-import org.eclipse.jdt.internal.compiler.ast.OperatorIds;
-import org.eclipse.jdt.internal.compiler.ast.ReferenceExpression;
-import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.TypeReference;
+import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.codegen.OperandStack.OperandCategory;
import org.eclipse.jdt.internal.compiler.flow.UnconditionalFlowInfo;
@@ -5758,30 +5744,6 @@ public void ixor() {
this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ixor;
}
-final public void jsr(BranchLabel lbl) {
- if (this.wideMode) {
- jsr_w(lbl);
- return;
- }
- this.countLabels = 0;
- if (this.classFileOffset >= this.bCodeStream.length) {
- resizeByteArray();
- }
- this.position++;
- this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_jsr;
- lbl.branch();
-}
-
-final public void jsr_w(BranchLabel lbl) {
- this.countLabels = 0;
- if (this.classFileOffset >= this.bCodeStream.length) {
- resizeByteArray();
- }
- this.position++;
- this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_jsr_w;
- lbl.branchWide();
-}
-
public void l2d() {
this.countLabels = 0;
if (this.classFileOffset >= this.bCodeStream.length) {
@@ -7247,26 +7209,6 @@ private final void resizeByteArray() {
System.arraycopy(this.bCodeStream, 0, this.bCodeStream = new byte[requiredSize], 0, length);
}
-final public void ret(int index) {
- this.countLabels = 0;
- if (index > 255) { // Widen
- if (this.classFileOffset + 3 >= this.bCodeStream.length) {
- resizeByteArray();
- }
- this.position += 2;
- this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_wide;
- this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ret;
- writeUnsignedShort(index);
- } else { // Don't Widen
- if (this.classFileOffset + 1 >= this.bCodeStream.length) {
- resizeByteArray();
- }
- this.position += 2;
- this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ret;
- this.bCodeStream[this.classFileOffset++] = (byte) index;
- }
-}
-
public void return_() {
this.countLabels = 0;
if (this.classFileOffset >= this.bCodeStream.length) {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/MultiCatchExceptionLabel.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/MultiCatchExceptionLabel.java
index be1bde25e1..6ba79024f1 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/MultiCatchExceptionLabel.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/MultiCatchExceptionLabel.java
@@ -17,8 +17,8 @@
package org.eclipse.jdt.internal.compiler.codegen;
import org.eclipse.jdt.internal.compiler.ast.Annotation;
-import org.eclipse.jdt.internal.compiler.ast.UnionTypeReference;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
+import org.eclipse.jdt.internal.compiler.ast.UnionTypeReference;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
public class MultiCatchExceptionLabel extends ExceptionLabel {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/OperandStack.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/OperandStack.java
index 2413b5222e..dd3cdf2730 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/OperandStack.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/OperandStack.java
@@ -16,7 +16,6 @@
import java.util.Stack;
import java.util.function.Supplier;
-
import org.eclipse.jdt.internal.compiler.ClassFile;
import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
@@ -264,6 +263,20 @@ public void dup2_x2() {
}
}
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append('[');
+ for (int i = 0, length = size(); i < length; i++) {
+ if (i != 0)
+ sb.append(", "); //$NON-NLS-1$
+ TypeBinding type = this.stack.get(i);
+ sb.append(type.shortReadableName());
+ }
+ sb.append("]\n"); //$NON-NLS-1$
+ return sb.toString();
+ }
+
public static class NullStack extends OperandStack {
public NullStack() {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/StackMapFrame.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/StackMapFrame.java
index fd7eeee702..d2f68fc494 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/StackMapFrame.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/StackMapFrame.java
@@ -16,7 +16,6 @@
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
-
import org.eclipse.jdt.internal.compiler.lookup.Scope;
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/StackMapFrameCodeStream.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/StackMapFrameCodeStream.java
index 1fa593a313..863f387551 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/StackMapFrameCodeStream.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/StackMapFrameCodeStream.java
@@ -18,7 +18,6 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ClassFile;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/TypeAnnotationCodeStream.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/TypeAnnotationCodeStream.java
index 2a8879a07d..2d0e6a1479 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/TypeAnnotationCodeStream.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/TypeAnnotationCodeStream.java
@@ -20,7 +20,6 @@
import java.util.ArrayList;
import java.util.List;
-
import org.eclipse.jdt.internal.compiler.ClassFile;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/VerificationTypeInfo.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/VerificationTypeInfo.java
index bff0e6e8b7..7832858e52 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/VerificationTypeInfo.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/VerificationTypeInfo.java
@@ -15,7 +15,6 @@
import java.util.ArrayList;
import java.util.List;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
import org.eclipse.jdt.internal.compiler.lookup.Scope;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/ClassSignature.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/ClassSignature.java
index 217426359f..7ccddd8e3c 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/ClassSignature.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/ClassSignature.java
@@ -15,7 +15,6 @@
package org.eclipse.jdt.internal.compiler.env;
import java.util.Arrays;
-
import org.eclipse.jdt.core.compiler.CharOperation;
/**
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/EnumConstantSignature.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/EnumConstantSignature.java
index c8a3ccda52..3219e6dacf 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/EnumConstantSignature.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/EnumConstantSignature.java
@@ -15,7 +15,6 @@
package org.eclipse.jdt.internal.compiler.env;
import java.util.Arrays;
-
import org.eclipse.jdt.core.compiler.CharOperation;
/**
* Represents a reference to a enum constant in the class file.
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/IBinaryType.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/IBinaryType.java
index 9eae6b5d25..cce631129c 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/IBinaryType.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/IBinaryType.java
@@ -18,7 +18,6 @@
package org.eclipse.jdt.internal.compiler.env;
import java.net.URI;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.ExternalAnnotationStatus;
import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
@@ -95,13 +94,13 @@ public interface IBinaryType extends IGenericType, IBinaryInfo {
char[][] getInterfaceNames();
/**
- * Answer the unresolved names of the receiver's permitted sub types
+ * Answer the unresolved names of the receiver's permitted subtypes in the
+ * class file format as specified in section 4.2 of the Java 2 VM spec
* or null if the array is empty.
*
- * A name is a simple name or a qualified, dot separated name.
- * For example, Hashtable or java.util.Hashtable.
+ * For example, java.lang.String is java/lang/String.
*/
-default char[][] getPermittedSubtypeNames() {
+default char[][] getPermittedSubtypesNames() {
return null;
}
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/IModule.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/IModule.java
index 11998aa7c8..78fead836e 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/IModule.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/IModule.java
@@ -14,7 +14,6 @@
package org.eclipse.jdt.internal.compiler.env;
import java.util.jar.Manifest;
-
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
public interface IModule {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/IModuleAwareNameEnvironment.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/IModuleAwareNameEnvironment.java
index 5bd5584fcb..093af6cf38 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/IModuleAwareNameEnvironment.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/IModuleAwareNameEnvironment.java
@@ -14,7 +14,6 @@
package org.eclipse.jdt.internal.compiler.env;
import java.util.function.Predicate;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.lookup.ModuleBinding;
import org.eclipse.jdt.internal.compiler.util.SimpleSetOfCharArray;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/IUpdatableModule.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/IUpdatableModule.java
index 1c39e246d1..70a6749371 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/IUpdatableModule.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/IUpdatableModule.java
@@ -17,7 +17,6 @@
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.util.SimpleSetOfCharArray;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/NameEnvironmentAnswer.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/NameEnvironmentAnswer.java
index 6f6496c40b..208f4bba66 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/NameEnvironmentAnswer.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/NameEnvironmentAnswer.java
@@ -14,7 +14,6 @@
package org.eclipse.jdt.internal.compiler.env;
import java.util.Arrays;
-
import org.eclipse.jdt.internal.compiler.lookup.ModuleBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/flow/ExceptionHandlingFlowContext.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/flow/ExceptionHandlingFlowContext.java
index 3d1ee67ccb..8eeccfb7ff 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/flow/ExceptionHandlingFlowContext.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/flow/ExceptionHandlingFlowContext.java
@@ -21,14 +21,13 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-
-import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
+import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Argument;
-import org.eclipse.jdt.internal.compiler.ast.UnionTypeReference;
-import org.eclipse.jdt.internal.compiler.ast.SubRoutineStatement;
+import org.eclipse.jdt.internal.compiler.ast.StatementWithFinallyBlock;
import org.eclipse.jdt.internal.compiler.ast.TryStatement;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
+import org.eclipse.jdt.internal.compiler.ast.UnionTypeReference;
import org.eclipse.jdt.internal.compiler.codegen.ObjectCache;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
import org.eclipse.jdt.internal.compiler.lookup.CatchParameterBinding;
@@ -311,19 +310,19 @@ public void recordReturnFrom(UnconditionalFlowInfo flowInfo) {
}
/**
- * Exception handlers (with no finally block) are also included with subroutine
- * only once (in case parented with true InsideSubRoutineFlowContext).
- * Standard management of subroutines need to also operate on intermediate
+ * Exception handlers (with no finally block) are also included with statement with finally block
+ * only once (in case parented with true InsideStatementWithFinallyBlockFlowContext).
+ * Standard management of statements with finally blocks need to also operate on intermediate
* exception handlers.
- * @see org.eclipse.jdt.internal.compiler.flow.FlowContext#subroutine()
+ * @see org.eclipse.jdt.internal.compiler.flow.FlowContext#statementWithFinallyBlock()
*/
@Override
-public SubRoutineStatement subroutine() {
- if (this.associatedNode instanceof SubRoutineStatement) {
- // exception handler context may be child of InsideSubRoutineFlowContext, which maps to same handler
- if (this.parent.subroutine() == this.associatedNode)
+public StatementWithFinallyBlock statementWithFinallyBlock() {
+ if (this.associatedNode instanceof StatementWithFinallyBlock) {
+ // exception handler context may be child of InsideStatementWithFinallyBlockFlowContext, which maps to same handler
+ if (this.parent.statementWithFinallyBlock() == this.associatedNode)
return null;
- return (SubRoutineStatement) this.associatedNode;
+ return (StatementWithFinallyBlock) this.associatedNode;
}
return null;
}
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/flow/FinallyFlowContext.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/flow/FinallyFlowContext.java
index cbf65ca5ee..fc59e146c5 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/flow/FinallyFlowContext.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/flow/FinallyFlowContext.java
@@ -67,7 +67,7 @@ public FinallyFlowContext(FlowContext parent, ASTNode associatedNode, ExceptionH
/**
* Given some contextual initialization info (derived from a try block or a catch block), this
- * code will check that the subroutine context does not also initialize a final variable potentially set
+ * code will check that the finally context does not also initialize a final variable potentially set
* redundantly.
*/
public void complainOnDeferredChecks(FlowInfo flowInfo, BlockScope scope) {
@@ -101,9 +101,7 @@ public void complainOnDeferredChecks(FlowInfo flowInfo, BlockScope scope) {
if (complained) {
FlowContext currentContext = this.getLocalParent();
while (currentContext != null) {
- //if (currentContext.isSubRoutine()) {
currentContext.removeFinalAssignmentIfAny(this.finalAssignments[i]);
- //}
currentContext = currentContext.getLocalParent();
}
}
@@ -242,11 +240,6 @@ public String individualToString() {
return buffer.toString();
}
- @Override
- public boolean isSubRoutine() {
- return true;
- }
-
@Override
protected boolean recordFinalAssignment(
VariableBinding binding,
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/flow/FlowContext.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/flow/FlowContext.java
index bffbac02a5..72b61ba760 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/flow/FlowContext.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/flow/FlowContext.java
@@ -28,35 +28,11 @@
package org.eclipse.jdt.internal.compiler.flow;
import java.util.ArrayList;
-
import org.eclipse.jdt.core.compiler.CharOperation;
-import org.eclipse.jdt.internal.compiler.ast.ASTNode;
-import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.Expression;
-import org.eclipse.jdt.internal.compiler.ast.FakedTrackingVariable;
-import org.eclipse.jdt.internal.compiler.ast.LabeledStatement;
-import org.eclipse.jdt.internal.compiler.ast.LambdaExpression;
-import org.eclipse.jdt.internal.compiler.ast.NullAnnotationMatching;
-import org.eclipse.jdt.internal.compiler.ast.Reference;
-import org.eclipse.jdt.internal.compiler.ast.SingleNameReference;
-import org.eclipse.jdt.internal.compiler.ast.SubRoutineStatement;
-import org.eclipse.jdt.internal.compiler.ast.SwitchExpression;
-import org.eclipse.jdt.internal.compiler.ast.ThrowStatement;
-import org.eclipse.jdt.internal.compiler.ast.TryStatement;
-import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.codegen.BranchLabel;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.lookup.CatchParameterBinding;
-import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
-import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Scope;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-import org.eclipse.jdt.internal.compiler.lookup.VariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.*;
/**
* Reflects the context of code analysis, keeping track of enclosing
@@ -192,7 +168,7 @@ public FieldBinding[] nullCheckedFields() {
count = 0;
for (int i=0; iConsumers are free to use {@code sourceLevel} or this
+ * {@code requestedSourceVersion} value to decide of their behavior.
+ * May be {@code null}.
+ */
+ public String requestedSourceVersion;
/** VM target level, refers to a JDK version, e.g. {@link ClassFileConstants#JDK1_4} */
public long targetJDK;
/** Source encoding format */
@@ -714,6 +723,8 @@ public static String optionKeyFromIrritant(int irritant) {
return OPTION_ReportHiddenCatchBlock;
case UnusedLocalVariable :
return OPTION_ReportUnusedLocal;
+ case UnusedLambdaParameter:
+ return OPTION_ReportUnusedLambdaParameter;
case UnusedArgument :
return OPTION_ReportUnusedParameter;
case UnusedExceptionParameter :
@@ -1190,6 +1201,7 @@ public static String warningTokenFromIrritant(int irritant) {
case UnusedImport :
case UnusedLabel :
case UnusedLocalVariable :
+ case UnusedLambdaParameter :
case UnusedObjectAllocation :
case UnusedArgument : // OPTION_ReportUnusedParameter
case UnusedPrivateMember :
@@ -1359,6 +1371,7 @@ public Map getMap() {
optionsMap.put(OPTION_ReportDeprecationWhenOverridingDeprecatedMethod, this.reportDeprecationWhenOverridingDeprecatedMethod ? ENABLED : DISABLED);
optionsMap.put(OPTION_ReportHiddenCatchBlock, getSeverityString(MaskedCatchBlock));
optionsMap.put(OPTION_ReportUnusedLocal, getSeverityString(UnusedLocalVariable));
+ optionsMap.put(OPTION_ReportUnusedLambdaParameter, getSeverityString(UnusedLambdaParameter));
optionsMap.put(OPTION_ReportUnusedParameter, getSeverityString(UnusedArgument));
optionsMap.put(OPTION_ReportUnusedExceptionParameter, getSeverityString(UnusedExceptionParameter));
optionsMap.put(OPTION_ReportUnusedImport, getSeverityString(UnusedImport));
@@ -1783,7 +1796,7 @@ public void set(Map optionsMap) {
long level = versionToJdkLevel(optionValue);
if (level != 0) this.complianceLevel = level;
}
- if ((optionValue = optionsMap.get(OPTION_Source)) != null) {
+ if ((this.requestedSourceVersion = optionValue = optionsMap.get(OPTION_Source)) != null) {
long level = versionToJdkLevel(optionValue);
if (level != 0) this.sourceLevel = level;
}
@@ -1944,6 +1957,7 @@ public void set(Map optionsMap) {
if ((optionValue = optionsMap.get(OPTION_ReportTerminalDeprecation)) != null) updateSeverity(UsingTerminallyDeprecatedAPI, optionValue);
if ((optionValue = optionsMap.get(OPTION_ReportHiddenCatchBlock)) != null) updateSeverity(MaskedCatchBlock, optionValue);
if ((optionValue = optionsMap.get(OPTION_ReportUnusedLocal)) != null) updateSeverity(UnusedLocalVariable, optionValue);
+ if ((optionValue = optionsMap.get(OPTION_ReportUnusedLambdaParameter)) != null) updateSeverity(UnusedLambdaParameter, optionValue);
if ((optionValue = optionsMap.get(OPTION_ReportUnusedParameter)) != null) updateSeverity(UnusedArgument, optionValue);
if ((optionValue = optionsMap.get(OPTION_ReportUnusedExceptionParameter)) != null) updateSeverity(UnusedExceptionParameter, optionValue);
if ((optionValue = optionsMap.get(OPTION_ReportUnusedImport)) != null) updateSeverity(UnusedImport, optionValue);
@@ -2332,6 +2346,7 @@ public String toString() {
buf.append("\n\t- removal: ").append(getSeverityString(UsingTerminallyDeprecatedAPI)); //$NON-NLS-1$
buf.append("\n\t- masked catch block: ").append(getSeverityString(MaskedCatchBlock)); //$NON-NLS-1$
buf.append("\n\t- unused local variable: ").append(getSeverityString(UnusedLocalVariable)); //$NON-NLS-1$
+ buf.append("\n\t- unused lambda parameter: ").append(getSeverityString(UnusedLambdaParameter)); //$NON-NLS-1$
buf.append("\n\t- unused parameter: ").append(getSeverityString(UnusedArgument)); //$NON-NLS-1$
buf.append("\n\t- unused exception parameter: ").append(getSeverityString(UnusedExceptionParameter)); //$NON-NLS-1$
buf.append("\n\t- unused import: ").append(getSeverityString(UnusedImport)); //$NON-NLS-1$
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java
index 5f22ad875b..a6f7409093 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java
@@ -140,7 +140,8 @@ public class IrritantSet {
|CompilerOptions.UnstableAutoModuleName
|CompilerOptions.PreviewFeatureUsed)
.set(CompilerOptions.InsufficientResourceManagement
- |CompilerOptions.IncompatibleOwningContract);
+ |CompilerOptions.IncompatibleOwningContract
+ |CompilerOptions.UnusedLambdaParameter);
// default errors IF AnnotationBasedNullAnalysis is enabled:
COMPILER_DEFAULT_ERRORS.set(
CompilerOptions.NullSpecViolation
@@ -178,7 +179,8 @@ public class IrritantSet {
.set(CompilerOptions.DeadCode)
.set(CompilerOptions.UnusedObjectAllocation)
.set(CompilerOptions.UnusedTypeParameter)
- .set(CompilerOptions.RedundantSpecificationOfTypeArguments);
+ .set(CompilerOptions.RedundantSpecificationOfTypeArguments)
+ .set(CompilerOptions.UnusedLambdaParameter);
STATIC_METHOD
.set(CompilerOptions.MethodCanBePotentiallyStatic);
RESOURCE
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/JavaFeature.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/JavaFeature.java
index 125d8729f5..9ad5ec3873 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/JavaFeature.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/JavaFeature.java
@@ -56,7 +56,7 @@ public enum JavaFeature {
SEALED_CLASSES(ClassFileConstants.JDK17,
Messages.bind(Messages.sealed_types),
- new char[][] {TypeConstants.SEALED, TypeConstants.PERMITS},
+ new char[][] {TypeConstants.SEALED, TypeConstants.NON_SEALED, TypeConstants.PERMITS},
false),
PATTERN_MATCHING_IN_SWITCH(ClassFileConstants.JDK21,
Messages.bind(Messages.pattern_matching_switch),
@@ -94,7 +94,7 @@ public enum JavaFeature {
* Individual exceptions from old rules
* - MethodScope.findField()
- Scope.getBinding(char[], int, InvocationSite, boolean)
* Main code gen change in TypeDeclaration.manageEnclosingInstanceAccessIfNecessary()
- * Only if feature is actually supported, we will generate special synthetid args & fields
+ * Only if feature is actually supported, we will generate special synthetic args and fields
* Uses some feature-specific help from BlockScope.getEmulationPath()
*
*/
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/AnnotatableTypeSystem.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/AnnotatableTypeSystem.java
index c3567c74bf..b49ac17f46 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/AnnotatableTypeSystem.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/AnnotatableTypeSystem.java
@@ -289,7 +289,7 @@ public TypeBinding getAnnotatedType(TypeBinding type, AnnotationBinding[][] anno
return annotatedType;
}
- /* Private subroutine for public APIs. Create an annotated version of the type. To materialize the annotated version, we can't use new since
+ /* Private method for public APIs. Create an annotated version of the type. To materialize the annotated version, we can't use new since
this is a general purpose method designed to deal type bindings of all types. "Clone" the incoming type, specializing for any enclosing type
that may itself be possibly be annotated. This is so the binding for @Outer Outer.Inner != Outer.@Inner Inner != @Outer Outer.@Inner Inner.
Likewise so the bindings for @Readonly List<@NonNull String> != @Readonly List<@Nullable String> != @Readonly List<@Interned String>
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java
index 857cc6fc9b..0a14db160f 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java
@@ -14,7 +14,6 @@
package org.eclipse.jdt.internal.compiler.lookup;
import java.util.Arrays;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.Annotation;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/AptBinaryLocalVariableBinding.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/AptBinaryLocalVariableBinding.java
index 8f305320eb..30510f2844 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/AptBinaryLocalVariableBinding.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/AptBinaryLocalVariableBinding.java
@@ -15,7 +15,6 @@
import java.util.Arrays;
import java.util.Objects;
-
import org.eclipse.jdt.core.compiler.CharOperation;
public class AptBinaryLocalVariableBinding extends LocalVariableBinding {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java
index c2fe228003..fd0685a7bc 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java
@@ -33,7 +33,6 @@
import java.util.List;
import java.util.Set;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ClassFile;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BinaryModuleBinding.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BinaryModuleBinding.java
index a282b6f083..c5fa89b022 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BinaryModuleBinding.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BinaryModuleBinding.java
@@ -16,7 +16,6 @@
import java.net.URI;
import java.util.LinkedHashMap;
import java.util.stream.Stream;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation;
@@ -25,8 +24,8 @@
import org.eclipse.jdt.internal.compiler.env.IModule.IModuleReference;
import org.eclipse.jdt.internal.compiler.env.IModule.IPackageExport;
import org.eclipse.jdt.internal.compiler.env.IModule.IService;
-import org.eclipse.jdt.internal.compiler.util.Util;
import org.eclipse.jdt.internal.compiler.env.IModuleAwareNameEnvironment;
+import org.eclipse.jdt.internal.compiler.util.Util;
public class BinaryModuleBinding extends ModuleBinding {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java
index 0cfb81d63d..a5ff9987f2 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java
@@ -52,7 +52,6 @@
import java.net.URI;
import java.util.ArrayList;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.Annotation;
import org.eclipse.jdt.internal.compiler.classfmt.AnnotationInfo;
@@ -63,17 +62,7 @@
import org.eclipse.jdt.internal.compiler.classfmt.NonNullDefaultAwareTypeAnnotationWalker;
import org.eclipse.jdt.internal.compiler.classfmt.TypeAnnotationWalker;
import org.eclipse.jdt.internal.compiler.codegen.ConstantPool;
-import org.eclipse.jdt.internal.compiler.env.ClassSignature;
-import org.eclipse.jdt.internal.compiler.env.EnumConstantSignature;
-import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation;
-import org.eclipse.jdt.internal.compiler.env.IBinaryElementValuePair;
-import org.eclipse.jdt.internal.compiler.env.IBinaryField;
-import org.eclipse.jdt.internal.compiler.env.IBinaryMethod;
-import org.eclipse.jdt.internal.compiler.env.IBinaryNestedType;
-import org.eclipse.jdt.internal.compiler.env.IBinaryType;
-import org.eclipse.jdt.internal.compiler.env.IBinaryTypeAnnotation;
-import org.eclipse.jdt.internal.compiler.env.IRecordComponent;
-import org.eclipse.jdt.internal.compiler.env.ITypeAnnotationWalker;
+import org.eclipse.jdt.internal.compiler.env.*;
import org.eclipse.jdt.internal.compiler.impl.BooleanConstant;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.impl.Constant;
@@ -103,7 +92,7 @@ public class BinaryTypeBinding extends ReferenceBinding {
protected ReferenceBinding superclass;
protected ReferenceBinding enclosingType;
protected ReferenceBinding[] superInterfaces;
- protected ReferenceBinding[] permittedSubtypes;
+ protected ReferenceBinding[] permittedTypes;
protected FieldBinding[] fields;
protected RecordComponentBinding[] components;
protected MethodBinding[] methods;
@@ -274,7 +263,7 @@ public BinaryTypeBinding(BinaryTypeBinding prototype) {
this.superclass = prototype.superclass;
this.enclosingType = prototype.enclosingType;
this.superInterfaces = prototype.superInterfaces;
- this.permittedSubtypes = prototype.permittedSubtypes;
+ this.permittedTypes = prototype.permittedTypes;
this.fields = prototype.fields;
this.components = prototype.components;
this.methods = prototype.methods;
@@ -454,7 +443,7 @@ void cachePartsFrom(IBinaryType binaryType, boolean needFieldsAndMethods) {
// and still want to use binaries passed that point (e.g. type hierarchy resolver, see bug 63748).
this.typeVariables = Binding.NO_TYPE_VARIABLES;
this.superInterfaces = Binding.NO_SUPERINTERFACES;
- this.permittedSubtypes = Binding.NO_PERMITTEDTYPES;
+ this.permittedTypes = Binding.NO_PERMITTED_TYPES;
// must retrieve member types in case superclass/interfaces need them
this.memberTypes = Binding.NO_MEMBER_TYPES;
@@ -560,31 +549,16 @@ void cachePartsFrom(IBinaryType binaryType, boolean needFieldsAndMethods) {
types.toArray(this.superInterfaces);
this.tagBits |= TagBits.HasUnresolvedSuperinterfaces;
}
-
- this.permittedSubtypes = Binding.NO_PERMITTEDTYPES;
- if (!wrapper.atEnd()) {
- // attempt to find each permitted type if it exists in the cache (otherwise - resolve it when requested)
- java.util.ArrayList types = new java.util.ArrayList(2);
- short rank = 0;
- do {
- types.add(this.environment.getTypeFromTypeSignature(wrapper, typeVars, this, missingTypeNames, toplevelWalker.toSupertype(rank++, wrapper.peekFullType())));
- } while (!wrapper.atEnd());
- this.permittedSubtypes = new ReferenceBinding[types.size()];
- types.toArray(this.permittedSubtypes);
- this.extendedTagBits |= ExtendedTagBits.HasUnresolvedPermittedSubtypes;
- }
-
}
- // fall back, in case we haven't got them from signature
- char[][] permittedSubtypeNames = binaryType.getPermittedSubtypeNames();
- if (this.permittedSubtypes == Binding.NO_PERMITTEDTYPES && permittedSubtypeNames != null) {
+ char[][] permittedSubtypesNames = binaryType.getPermittedSubtypesNames();
+ if (permittedSubtypesNames != null) {
this.modifiers |= ExtraCompilerModifiers.AccSealed;
- int size = permittedSubtypeNames.length;
+ int size = permittedSubtypesNames.length;
if (size > 0) {
- this.permittedSubtypes = new ReferenceBinding[size];
+ this.permittedTypes = new ReferenceBinding[size];
for (short i = 0; i < size; i++)
- // attempt to find each superinterface if it exists in the cache (otherwise - resolve it when requested)
- this.permittedSubtypes[i] = this.environment.getTypeFromConstantPoolName(permittedSubtypeNames[i], 0, -1, false, missingTypeNames, toplevelWalker.toSupertype(i, null));
+ // attempt to find each permitted type if it exists in the cache (otherwise - resolve it when requested)
+ this.permittedTypes[i] = this.environment.getTypeFromConstantPoolName(permittedSubtypesNames[i], 0, -1, false, missingTypeNames);
}
}
boolean canUseNullTypeAnnotations = this.environment.globalOptions.isAnnotationBasedNullAnalysisEnabled && this.environment.globalOptions.sourceLevel >= ClassFileConstants.JDK1_8;
@@ -598,12 +572,6 @@ void cachePartsFrom(IBinaryType binaryType, boolean needFieldsAndMethods) {
break;
}
}
- for (TypeBinding permsub : this.permittedSubtypes) {
- if (permsub.hasNullTypeAnnotations()) {
- this.externalAnnotationStatus = ExternalAnnotationStatus.TYPE_IS_ANNOTATED;
- break;
- }
- }
}
}
@@ -2617,13 +2585,12 @@ public ReferenceBinding[] superInterfaces() {
public ReferenceBinding[] permittedTypes() {
if (!isPrototype()) {
- return this.permittedSubtypes = this.prototype.permittedTypes();
+ return this.permittedTypes = this.prototype.permittedTypes();
}
- for (int i = this.permittedSubtypes.length; --i >= 0;)
- this.permittedSubtypes[i] = (ReferenceBinding) resolveType(this.permittedSubtypes[i], this.environment, false);
+ for (int i = this.permittedTypes.length; --i >= 0;)
+ this.permittedTypes[i] = (ReferenceBinding) resolveType(this.permittedTypes[i], this.environment, false); // re-resolution seems harmless
- // Note: unlike for superinterfaces() hierarchy check not required here since these are subtypes
- return this.permittedSubtypes;
+ return this.permittedTypes;
}
@Override
public TypeVariableBinding[] typeVariables() {
@@ -2693,17 +2660,17 @@ public String toString() {
buffer.append("NULL SUPERINTERFACES"); //$NON-NLS-1$
}
- if (this.permittedSubtypes != null) {
- if (this.permittedSubtypes != Binding.NO_PERMITTEDTYPES) {
+ if (this.permittedTypes != null) {
+ if (this.permittedTypes != Binding.NO_PERMITTED_TYPES) {
buffer.append("\n\tpermits : "); //$NON-NLS-1$
- for (int i = 0, length = this.permittedSubtypes.length; i < length; i++) {
- if (i > 0)
+ for (int i = 0, length = this.permittedTypes.length; i < length; i++) {
+ if (i > 0)
buffer.append(", "); //$NON-NLS-1$
- buffer.append((this.permittedSubtypes[i] != null) ? this.permittedSubtypes[i].debugName() : "NULL TYPE"); //$NON-NLS-1$
+ buffer.append((this.permittedTypes[i] != null) ? this.permittedTypes[i].debugName() : "NULL TYPE"); //$NON-NLS-1$
}
}
} else {
- buffer.append("NULL PERMITTEDSUBTYPES"); //$NON-NLS-1$
+ buffer.append("NULL PERMITTED SUBTYPES"); //$NON-NLS-1$
}
if (this.enclosingType != null) {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/Binding.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/Binding.java
index 34073261c3..c1beb405a4 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/Binding.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/Binding.java
@@ -62,7 +62,7 @@ public abstract class Binding {
public static final ReferenceBinding[] ANY_EXCEPTION = new ReferenceBinding[] { null }; // special handler for all exceptions
public static final FieldBinding[] NO_FIELDS = new FieldBinding[0];
public static final MethodBinding[] NO_METHODS = new MethodBinding[0];
- public static final ReferenceBinding[] NO_PERMITTEDTYPES = new ReferenceBinding[0];
+ public static final ReferenceBinding[] NO_PERMITTED_TYPES = new ReferenceBinding[0];
public static final ReferenceBinding[] NO_SUPERINTERFACES = new ReferenceBinding[0];
public static final ReferenceBinding[] NO_MEMBER_TYPES = new ReferenceBinding[0];
public static final TypeVariableBinding[] NO_TYPE_VARIABLES = new TypeVariableBinding[0];
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java
index b46d9c0eda..ab897083c9 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java
@@ -35,7 +35,6 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
@@ -324,7 +323,8 @@ void computeLocalVariablePositions(int ilocal, int initOffset, CodeStream codeSt
// could be optimized out, but does need to preserve unread variables ?
if (!generateCurrentLocalVar) {
if ((local.declaration != null && compilerOptions().preserveAllLocalVariables) ||
- local.isPatternVariable()) { // too much voodoo around pattern codegen. Having warned, just treat them as used.
+ local.isPatternVariable() || // too much voodoo around pattern codegen. Having warned, just treat them as used.
+ local.isResourceVariable()) {
generateCurrentLocalVar = true; // force it to be preserved in the generated code
if (local.useFlag == LocalVariableBinding.UNUSED)
local.useFlag = LocalVariableBinding.USED;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java
index f8ed82ef4d..c0833acc58 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java
@@ -19,20 +19,9 @@
import static java.util.function.Function.identity;
import static java.util.stream.Collectors.toMap;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.Map.Entry;
-import java.util.Set;
import java.util.stream.Stream;
-
import org.eclipse.jdt.internal.compiler.ast.Wildcard;
import org.eclipse.jdt.internal.compiler.util.Tuples.Pair;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
index 210778ac1e..f23989aa0e 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
@@ -33,26 +33,11 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
import java.util.Map;
-import java.util.Set;
-
import org.eclipse.jdt.core.compiler.CharOperation;
-import org.eclipse.jdt.internal.compiler.ast.ASTNode;
-import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.LambdaExpression;
-import org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression;
-import org.eclipse.jdt.internal.compiler.ast.RecordComponent;
-import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference;
-import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.TypeParameter;
-import org.eclipse.jdt.internal.compiler.ast.TypeReference;
+import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
@@ -107,7 +92,7 @@ void buildAnonymousTypeBinding(SourceTypeBinding enclosingType, ReferenceBinding
}
}
anonymousType.typeBits |= inheritedBits;
- anonymousType.setPermittedTypes(Binding.NO_PERMITTEDTYPES); // JLS 15 JEP 360 Preview - Sec 15.9.5
+ anonymousType.setPermittedTypes(Binding.NO_PERMITTED_TYPES);
if (supertype.isInterface()) {
anonymousType.setSuperClass(getJavaLangObject());
anonymousType.setSuperInterfaces(new ReferenceBinding[] { supertype });
@@ -119,7 +104,7 @@ void buildAnonymousTypeBinding(SourceTypeBinding enclosingType, ReferenceBinding
anonymousType.tagBits |= TagBits.HierarchyHasProblems;
anonymousType.setSuperInterfaces(Binding.NO_SUPERINTERFACES);
} if (supertype.isSealed()) {
- problemReporter().sealedAnonymousClassCannotExtendSealedType(typeReference, supertype);
+ problemReporter().anonymousClassCannotExtendSealedType(typeReference, supertype);
anonymousType.tagBits |= TagBits.HierarchyHasProblems;
anonymousType.setSuperInterfaces(Binding.NO_SUPERINTERFACES);
}
@@ -127,7 +112,6 @@ void buildAnonymousTypeBinding(SourceTypeBinding enclosingType, ReferenceBinding
} else {
anonymousType.setSuperClass(supertype);
anonymousType.setSuperInterfaces(Binding.NO_SUPERINTERFACES);
- checkForEnumSealedPreview(supertype, anonymousType);
TypeReference typeReference = this.referenceContext.allocation.type;
if (typeReference != null) { // no check for enum constant body
this.referenceContext.superclass = typeReference;
@@ -150,7 +134,7 @@ void buildAnonymousTypeBinding(SourceTypeBinding enclosingType, ReferenceBinding
anonymousType.tagBits |= TagBits.HierarchyHasProblems;
anonymousType.setSuperClass(getJavaLangObject());
} else if (supertype.isSealed()) {
- problemReporter().sealedAnonymousClassCannotExtendSealedType(typeReference, supertype);
+ problemReporter().anonymousClassCannotExtendSealedType(typeReference, supertype);
anonymousType.tagBits |= TagBits.HierarchyHasProblems;
anonymousType.setSuperClass(getJavaLangObject());
}
@@ -163,27 +147,6 @@ void buildAnonymousTypeBinding(SourceTypeBinding enclosingType, ReferenceBinding
anonymousType.verifyMethods(environment().methodVerifier());
}
- private void checkForEnumSealedPreview(ReferenceBinding supertype, LocalTypeBinding anonymousType) {
- if (!JavaFeature.SEALED_CLASSES.isSupported(compilerOptions())
- || !supertype.isEnum()
- || !(supertype instanceof SourceTypeBinding))
- return;
-
- SourceTypeBinding sourceSuperType = (SourceTypeBinding) supertype;
- ReferenceBinding[] permTypes = sourceSuperType.permittedTypes();
- int sz = permTypes == null ? 0 : permTypes.length;
- if (sz == 0) {
- permTypes = new ReferenceBinding[] {anonymousType};
- } else {
- System.arraycopy(permTypes, 0,
- permTypes = new ReferenceBinding[sz + 1], 0,
- sz);
- permTypes[sz] = anonymousType;
- }
- anonymousType.modifiers |= ClassFileConstants.AccFinal; // JLS 15 / sealed preview/Sec 8.9.1
- sourceSuperType.setPermittedTypes(permTypes);
- }
-
void buildComponents() {
SourceTypeBinding sourceType = this.referenceContext.binding;
if (!sourceType.isRecord()) return;
@@ -332,7 +295,7 @@ private LocalTypeBinding buildLocalType(SourceTypeBinding enclosingType, Package
this.referenceContext.initializerScope = new MethodScope(this, this.referenceContext, false);
// build the binding or the local type
- LocalTypeBinding localType = new LocalTypeBinding(this, enclosingType, innermostSwitchCase());
+ LocalTypeBinding localType = new LocalTypeBinding(this, enclosingType, enclosingSwitchLabel());
this.referenceContext.binding = localType;
checkAndSetModifiers();
buildTypeVariables();
@@ -390,7 +353,6 @@ void buildLocalTypeBinding(SourceTypeBinding enclosingType) {
LocalTypeBinding localType = buildLocalType(enclosingType, enclosingType.fPackage);
connectTypeHierarchy();
- connectImplicitPermittedTypes();
if (compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) {
checkParameterizedTypeBounds();
checkParameterizedSuperTypeCollisions();
@@ -629,13 +591,12 @@ private void checkAndSetModifiers() {
CompilerOptions options = compilerOptions();
boolean is16Plus = compilerOptions().sourceLevel >= ClassFileConstants.JDK16;
boolean isSealedSupported = JavaFeature.SEALED_CLASSES.isSupported(options);
- boolean flagSealedNonModifiers = isSealedSupported &&
- (modifiers & (ExtraCompilerModifiers.AccSealed | ExtraCompilerModifiers.AccNonSealed)) != 0;
+ boolean hierarchySealed = (modifiers & (ExtraCompilerModifiers.AccSealed | ExtraCompilerModifiers.AccNonSealed)) != 0;
switch (modifiers & (ExtraCompilerModifiers.AccSealed | ExtraCompilerModifiers.AccNonSealed | ClassFileConstants.AccFinal)) {
case ExtraCompilerModifiers.AccSealed, ExtraCompilerModifiers.AccNonSealed, ClassFileConstants.AccFinal, ClassFileConstants.AccDefault : break;
default :
- problemReporter().IllegalModifierCombinationForType(sourceType);
+ problemReporter().illegalModifierCombinationForType(sourceType);
break;
}
if (sourceType.isRecord()) {
@@ -673,7 +634,7 @@ private void checkAndSetModifiers() {
}
final int UNEXPECTED_MODIFIERS =~(ClassFileConstants.AccEnum | ClassFileConstants.AccStrictfp);
if ((modifiers & ExtraCompilerModifiers.AccJustFlag & UNEXPECTED_MODIFIERS) != 0
- || flagSealedNonModifiers) {
+ || hierarchySealed) {
problemReporter().illegalModifierForLocalEnumDeclaration(sourceType);
return;
}
@@ -694,8 +655,19 @@ private void checkAndSetModifiers() {
if (compilerOptions().complianceLevel < ClassFileConstants.JDK9)
modifiers |= ClassFileConstants.AccFinal;
// set AccEnum flag for anonymous body of enum constants
- if (this.referenceContext.allocation.type == null)
+ if (this.referenceContext.allocation.type == null) {
modifiers |= ClassFileConstants.AccEnum;
+ // 8.1.1.4 local enum classes are implicitly static - we can't trust isLocalType() which answers true for all anonymous types.
+ Scope scope = this;
+ while ((scope = scope.parent) != null) {
+ if (scope instanceof MethodScope methodScope) {
+ if (methodScope.referenceContext instanceof TypeDeclaration)
+ continue;
+ modifiers |= ClassFileConstants.AccStatic;
+ break;
+ }
+ }
+ }
} else if (this.parent.referenceContext() instanceof TypeDeclaration) {
TypeDeclaration typeDecl = (TypeDeclaration) this.parent.referenceContext();
if (TypeDeclaration.kind(typeDecl.modifiers) == TypeDeclaration.INTERFACE_DECL) {
@@ -773,7 +745,7 @@ private void checkAndSetModifiers() {
| ClassFileConstants.AccStrictfp | ClassFileConstants.AccAnnotation
| ((is16Plus && this.parent instanceof ClassScope) ? ClassFileConstants.AccStatic : 0));
if ((realModifiers & UNEXPECTED_MODIFIERS) != 0
- || flagSealedNonModifiers)
+ || hierarchySealed)
problemReporter().localStaticsIllegalVisibilityModifierForInterfaceLocalType(sourceType);
// if ((modifiers & ClassFileConstants.AccStatic) != 0) {
// problemReporter().recordIllegalStaticModifierForLocalClassOrInterface(sourceType);
@@ -795,24 +767,23 @@ private void checkAndSetModifiers() {
modifiers |= ClassFileConstants.AccSynthetic;
}
modifiers |= ClassFileConstants.AccAbstract;
- } else if ((realModifiers & ClassFileConstants.AccEnum) != 0) {
+ } else if ((realModifiers & ClassFileConstants.AccEnum) != 0) {
// detect abnormal cases for enums
if (isMemberType) { // includes member types defined inside local types
- final int UNEXPECTED_MODIFIERS = ~(ClassFileConstants.AccPublic | ClassFileConstants.AccPrivate | ClassFileConstants.AccProtected | ClassFileConstants.AccStatic | ClassFileConstants.AccStrictfp | ClassFileConstants.AccEnum);
- if ((realModifiers & UNEXPECTED_MODIFIERS) != 0 || flagSealedNonModifiers) {
+ final int UNEXPECTED_MODIFIERS = ~(ClassFileConstants.AccPublic | ClassFileConstants.AccPrivate
+ | ClassFileConstants.AccProtected | ClassFileConstants.AccStatic
+ | ClassFileConstants.AccStrictfp | ClassFileConstants.AccEnum);
+ if ((realModifiers & UNEXPECTED_MODIFIERS) != 0 || hierarchySealed) {
problemReporter().illegalModifierForMemberEnum(sourceType);
modifiers &= ~ClassFileConstants.AccAbstract; // avoid leaking abstract modifier
realModifiers &= ~ClassFileConstants.AccAbstract;
// modifiers &= ~(realModifiers & UNEXPECTED_MODIFIERS);
// realModifiers = modifiers & ExtraCompilerModifiers.AccJustFlag;
}
- } else if (sourceType.isLocalType()) {
-// if (flagSealedNonModifiers)
-// problemReporter().illegalModifierForLocalEnum(sourceType);
- // each enum constant is an anonymous local type and its modifiers were already checked as an enum constant field
- } else {
- final int UNEXPECTED_MODIFIERS = ~(ClassFileConstants.AccPublic | ClassFileConstants.AccStrictfp | ClassFileConstants.AccEnum);
- if ((realModifiers & UNEXPECTED_MODIFIERS) != 0 || flagSealedNonModifiers)
+ } else if (!sourceType.isLocalType()) { // local types already handled earlier.
+ final int UNEXPECTED_MODIFIERS = ~(ClassFileConstants.AccPublic | ClassFileConstants.AccStrictfp
+ | ClassFileConstants.AccEnum);
+ if ((realModifiers & UNEXPECTED_MODIFIERS) != 0 || hierarchySealed)
problemReporter().illegalModifierForEnum(sourceType);
}
if (!sourceType.isAnonymousType()) {
@@ -827,14 +798,16 @@ private void checkAndSetModifiers() {
TypeDeclaration typeDeclaration = this.referenceContext;
FieldDeclaration[] fields = typeDeclaration.fields;
int fieldsLength = fields == null ? 0 : fields.length;
- if (fieldsLength == 0) break checkAbstractEnum; // has no constants so must implement the method itself
+ if (fieldsLength == 0)
+ break checkAbstractEnum; // has no constants so must implement the method itself
AbstractMethodDeclaration[] methods = typeDeclaration.methods;
int methodsLength = methods == null ? 0 : methods.length;
// TODO (kent) cannot tell that the superinterfaces are empty or that their methods are implemented
boolean definesAbstractMethod = typeDeclaration.superInterfaces != null;
for (int i = 0; i < methodsLength && !definesAbstractMethod; i++)
definesAbstractMethod = methods[i].isAbstract();
- if (!definesAbstractMethod) break checkAbstractEnum; // all methods have bodies
+ if (!definesAbstractMethod)
+ break checkAbstractEnum; // all methods have bodies
boolean needAbstractBit = false;
for (int i = 0; i < fieldsLength; i++) {
FieldDeclaration fieldDecl = fields[i];
@@ -846,8 +819,10 @@ private void checkAndSetModifiers() {
}
}
}
- // tag this enum as abstract since an abstract method must be implemented AND all enum constants define an anonymous body
- // as a result, each of its anonymous constants will see it as abstract and must implement each inherited abstract method
+ // tag this enum as abstract since an abstract method must be implemented AND all enum constants
+ // define an anonymous body
+ // as a result, each of its anonymous constants will see it as abstract and must implement each
+ // inherited abstract method
if (needAbstractBit) {
modifiers |= ClassFileConstants.AccAbstract;
}
@@ -912,7 +887,7 @@ private void checkAndSetModifiers() {
} else if (sourceType.isLocalType()) {
final int UNEXPECTED_MODIFIERS = ~(ClassFileConstants.AccAbstract | ClassFileConstants.AccFinal | ClassFileConstants.AccStrictfp
| ((is16Plus && this.parent instanceof ClassScope) ? ClassFileConstants.AccStatic : 0));
- if ((realModifiers & UNEXPECTED_MODIFIERS) != 0 || flagSealedNonModifiers)
+ if ((realModifiers & UNEXPECTED_MODIFIERS) != 0 || hierarchySealed)
problemReporter().illegalModifierForLocalClass(sourceType);
} else {
final int UNEXPECTED_MODIFIERS = ~(ClassFileConstants.AccPublic | ClassFileConstants.AccAbstract | ClassFileConstants.AccFinal | ClassFileConstants.AccStrictfp);
@@ -1200,7 +1175,7 @@ private boolean connectSuperclass() {
if (sourceType.id == TypeIds.T_JavaLangObject) { // handle the case of redefining java.lang.Object up front
sourceType.setSuperClass(null);
sourceType.setSuperInterfaces(Binding.NO_SUPERINTERFACES);
- sourceType.setPermittedTypes(Binding.NO_PERMITTEDTYPES);
+ sourceType.setPermittedTypes(Binding.NO_PERMITTED_TYPES);
if (!sourceType.isClass())
problemReporter().objectMustBeClass(sourceType);
if (this.referenceContext.superclass != null || (this.referenceContext.superInterfaces != null && this.referenceContext.superInterfaces.length > 0))
@@ -1234,6 +1209,14 @@ private boolean connectSuperclass() {
} else {
return connectRecordSuperclass();
}
+ } else if (superclass.isSealed() && sourceType.isLocalType()) {
+ sourceType.setSuperClass(superclass);
+ problemReporter().localTypeMayNotBePermittedType(sourceType, superclassRef, superclass);
+ return false;
+ } else if (superclass.isSealed() && !(sourceType.isFinal() || sourceType.isSealed() || sourceType.isNonSealed())) {
+ sourceType.setSuperClass(superclass);
+ problemReporter().permittedTypeNeedsModifier(sourceType, this.referenceContext, superclass);
+ return false;
} else if ((superclass.tagBits & TagBits.HierarchyHasProblems) != 0
|| !superclassRef.resolvedType.isValidBinding()) {
sourceType.setSuperClass(superclass);
@@ -1295,85 +1278,92 @@ private boolean connectEnumSuperclass() {
}
return !foundCycle;
}
- private void connectImplicitPermittedTypes(SourceTypeBinding sourceType) {
- List types = new ArrayList<>();
- for (TypeDeclaration typeDecl : this.referenceCompilationUnit().types) {
- types.addAll(sourceType.collectAllTypeBindings(typeDecl, this.compilationUnitScope()));
- }
- Set permSubTypes = new LinkedHashSet<>();
- for (ReferenceBinding type : types) {
- if (!TypeBinding.equalsEquals(type, sourceType) && type.findSuperTypeOriginatingFrom(sourceType) != null) {
- permSubTypes.add(type);
- }
- }
- if (sourceType.isSealed() && sourceType.isLocalType()) {
- // bug xxxx flag Error and return;
- }
- if (permSubTypes.size() == 0) {
- if (!sourceType.isLocalType() && !sourceType.isRecord() && !sourceType.isEnum()) // error flagged already
- problemReporter().sealedSealedTypeMissingPermits(sourceType, this.referenceContext);
- return;
- }
- sourceType.setPermittedTypes(permSubTypes.toArray(new ReferenceBinding[0]));
- }
- void connectImplicitPermittedTypes() {
- TypeDeclaration typeDecl = this.referenceContext;
- SourceTypeBinding sourceType = typeDecl.binding;
- if (sourceType.id == TypeIds.T_JavaLangObject) // already handled
- return;
- if (sourceType.isSealed() && (typeDecl.permittedTypes == null ||
- typeDecl.permittedTypes.length == 0 || typeDecl.permittedTypes[0].isImplicit())) {
- connectImplicitPermittedTypes(sourceType);
- }
- ReferenceBinding[] memberTypes = sourceType.memberTypes;
- if (memberTypes != null && memberTypes != Binding.NO_MEMBER_TYPES) {
- for (ReferenceBinding memberType : memberTypes)
- ((SourceTypeBinding) memberType).scope.connectImplicitPermittedTypes();
+
+ /* Check that the permitted subtype and the sealed type are located in close proximity: either in the same module (if the superclass is in a named module)
+ * or in the same package (if the superclass is in the unnamed module)
+ * Return true, if all is well. Report error and return false otherwise,
+ */
+ private boolean checkSealingProximity(ReferenceBinding subType, TypeReference subTypeReference, ReferenceBinding sealedType) {
+ final PackageBinding sealedTypePackage = sealedType.getPackage();
+ final ModuleBinding sealedTypeModule = sealedType.module();
+ if (subType.getPackage() != sealedTypePackage) {
+ if (sealedTypeModule.isUnnamed())
+ problemReporter().permittedTypeOutsideOfPackage(subType, sealedType, subTypeReference, sealedTypePackage);
+ else if (subType.module() != sealedTypeModule)
+ problemReporter().permittedTypeOutsideOfModule(subType, sealedType, subTypeReference, sealedTypeModule);
}
+ return true;
}
+
void connectPermittedTypes() {
SourceTypeBinding sourceType = this.referenceContext.binding;
- sourceType.setPermittedTypes(Binding.NO_PERMITTEDTYPES);
- if (sourceType.id == TypeIds.T_JavaLangObject || sourceType.isEnum()) // already handled
- return;
if (this.referenceContext.permittedTypes != null) {
+ sourceType.setPermittedTypes(Binding.NO_PERMITTED_TYPES);
try {
sourceType.tagBits |= TagBits.SealingTypeHierarchy;
+ if (!sourceType.isSealed())
+ problemReporter().missingSealedModifier(sourceType, this.referenceContext);
int length = this.referenceContext.permittedTypes.length;
ReferenceBinding[] permittedTypeBindings = new ReferenceBinding[length];
int count = 0;
nextPermittedType : for (int i = 0; i < length; i++) {
TypeReference permittedTypeRef = this.referenceContext.permittedTypes[i];
ReferenceBinding permittedType = findPermittedtype(permittedTypeRef);
- if (permittedType == null) { // detected cycle
+ if (permittedType == null || !permittedType.isValidBinding()) {
continue nextPermittedType;
}
- if (!isPermittedTypeInAllowedFormat(sourceType, permittedTypeRef, permittedType))
- continue nextPermittedType;
- // check for simple interface collisions
- // Check for a duplicate interface once the name is resolved, otherwise we may be confused (i.e. a.b.I and c.d.I)
+ if (sourceType.isClass()) {
+ ReferenceBinding superClass = permittedType.superclass();
+ superClass = superClass == null ? null : superClass.actualType();
+ if (!TypeBinding.equalsEquals(sourceType, superClass))
+ problemReporter().sealedClassNotDirectSuperClassOf(permittedType, permittedTypeRef, sourceType);
+ } else if (sourceType.isInterface()) {
+ ReferenceBinding[] superInterfaces = permittedType.superInterfaces();
+ boolean hierarchyOK = false;
+ if (superInterfaces != null) {
+ for (ReferenceBinding superInterface : superInterfaces) {
+ superInterface = superInterface == null ? null : superInterface.actualType();
+ if (TypeBinding.equalsEquals(sourceType, superInterface)) {
+ hierarchyOK = true;
+ break;
+ }
+ }
+ if (!hierarchyOK)
+ problemReporter().sealedInterfaceNotDirectSuperInterfaceOf(permittedType, permittedTypeRef, sourceType);
+ }
+ }
+
+ checkSealingProximity(permittedType, permittedTypeRef, sourceType);
+
for (int j = 0; j < i; j++) {
if (TypeBinding.equalsEquals(permittedTypeBindings[j], permittedType)) {
- problemReporter().sealedDuplicateTypeInPermits(sourceType, permittedTypeRef, permittedType);
+ problemReporter().duplicatePermittedType(permittedTypeRef, permittedType);
continue nextPermittedType;
}
}
- // only want to reach here when no errors are reported
permittedTypeBindings[count++] = permittedType;
}
- // hold onto all correctly resolved superinterfaces
if (count > 0) {
if (count != length)
System.arraycopy(permittedTypeBindings, 0, permittedTypeBindings = new ReferenceBinding[count], 0, count);
sourceType.setPermittedTypes(permittedTypeBindings);
} else {
- sourceType.setPermittedTypes(Binding.NO_PERMITTEDTYPES);
+ sourceType.setPermittedTypes(Binding.NO_PERMITTED_TYPES);
}
} finally {
sourceType.tagBits &= ~TagBits.SealingTypeHierarchy;
}
+ } else {
+ ReferenceBinding[] permittedTypes = sourceType.permittedTypes();
+ if (permittedTypes == null || permittedTypes.length == 0) {
+ sourceType.setPermittedTypes(Binding.NO_PERMITTED_TYPES);
+ if (sourceType.isSealed()) {
+ if (!sourceType.isLocalType() && !sourceType.isRecord() && !sourceType.isEnum()) // error flagged alread
+ problemReporter().missingPermitsClause(sourceType, this.referenceContext);
+ }
+ }
}
ReferenceBinding[] memberTypes = sourceType.memberTypes;
if (memberTypes != null && memberTypes != Binding.NO_MEMBER_TYPES) {
@@ -1382,29 +1372,6 @@ void connectPermittedTypes() {
}
}
- private boolean isPermittedTypeInAllowedFormat(SourceTypeBinding sourceType, TypeReference permittedTypeRef,
- ReferenceBinding permittedType) {
- if (!(permittedType.isMemberType() && permittedTypeRef instanceof SingleTypeReference))
- return true;
- ReferenceBinding enclosingType = permittedType.enclosingType();
- while (enclosingType != null) {
- if (TypeBinding.equalsEquals(sourceType, enclosingType)) {
- CompilationUnitScope cu = this.compilationUnitScope();
- if (cu.imports != null || cu.imports.length > 0) {
- for (ImportBinding ib : cu.imports) {
- Binding resolvedImport = cu.resolveSingleImport(ib, Binding.TYPE);
- if (resolvedImport instanceof TypeBinding &&
- TypeBinding.equalsEquals(permittedType, (TypeBinding) resolvedImport))
- return true;
- }
- }
- return false;
- }
- enclosingType = enclosingType.enclosingType();
- }
- return true;
- }
-
private boolean connectRecordSuperclass() {
SourceTypeBinding sourceType = this.referenceContext.binding;
ReferenceBinding rootRecordType = getJavaLangRecord();
@@ -1428,70 +1395,89 @@ private boolean connectRecordSuperclass() {
// GROOVY private->protected
protected boolean connectSuperInterfaces() {
SourceTypeBinding sourceType = this.referenceContext.binding;
- sourceType.setSuperInterfaces(Binding.NO_SUPERINTERFACES);
- if (this.referenceContext.superInterfaces == null) {
- if (sourceType.isAnnotationType() && compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) { // do not connect if source < 1.5 as annotation already got flagged as syntax error) {
- ReferenceBinding annotationType = getJavaLangAnnotationAnnotation();
- boolean foundCycle = detectHierarchyCycle(sourceType, annotationType, null);
- sourceType.setSuperInterfaces(new ReferenceBinding[] { annotationType });
- return !foundCycle;
- }
- return true;
- }
- if (sourceType.id == TypeIds.T_JavaLangObject) // already handled the case of redefining java.lang.Object
- return true;
-
+ boolean hasSealedSupertype = sourceType.superclass == null ? false : sourceType.superclass.isSealed();
boolean noProblems = true;
- int length = this.referenceContext.superInterfaces.length;
- ReferenceBinding[] interfaceBindings = new ReferenceBinding[length];
- int count = 0;
- nextInterface : for (int i = 0; i < length; i++) {
- TypeReference superInterfaceRef = this.referenceContext.superInterfaces[i];
- ReferenceBinding superInterface = findSupertype(superInterfaceRef);
- if (superInterface == null) { // detected cycle
- sourceType.tagBits |= TagBits.HierarchyHasProblems;
- noProblems = false;
- continue nextInterface;
+ try {
+ sourceType.setSuperInterfaces(Binding.NO_SUPERINTERFACES);
+ if (this.referenceContext.superInterfaces == null) {
+ if (sourceType.isAnnotationType() && compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) { // do not connect if source < 1.5 as annotation already got flagged as syntax error) {
+ ReferenceBinding annotationType = getJavaLangAnnotationAnnotation();
+ boolean foundCycle = detectHierarchyCycle(sourceType, annotationType, null);
+ sourceType.setSuperInterfaces(new ReferenceBinding[] { annotationType });
+ return !foundCycle;
+ }
+ return true;
}
+ if (sourceType.id == TypeIds.T_JavaLangObject) // already handled the case of redefining java.lang.Object
+ return true;
- // check for simple interface collisions
- // Check for a duplicate interface once the name is resolved, otherwise we may be confused (i.e. a.b.I and c.d.I)
- for (int j = 0; j < i; j++) {
- if (TypeBinding.equalsEquals(interfaceBindings[j], superInterface)) {
- problemReporter().duplicateSuperinterface(sourceType, superInterfaceRef, superInterface);
+ int length = this.referenceContext.superInterfaces.length;
+ ReferenceBinding[] interfaceBindings = new ReferenceBinding[length];
+ int count = 0;
+ nextInterface : for (int i = 0; i < length; i++) {
+ TypeReference superInterfaceRef = this.referenceContext.superInterfaces[i];
+ ReferenceBinding superInterface = findSupertype(superInterfaceRef);
+ if (superInterface == null) { // detected cycle
sourceType.tagBits |= TagBits.HierarchyHasProblems;
noProblems = false;
continue nextInterface;
}
+
+ if (superInterface.isSealed())
+ hasSealedSupertype = true;
+
+ // check for simple interface collisions
+ // Check for a duplicate interface once the name is resolved, otherwise we may be confused (i.e. a.b.I and c.d.I)
+ for (int j = 0; j < i; j++) {
+ if (TypeBinding.equalsEquals(interfaceBindings[j], superInterface)) {
+ problemReporter().duplicateSuperinterface(sourceType, superInterfaceRef, superInterface);
+ sourceType.tagBits |= TagBits.HierarchyHasProblems;
+ noProblems = false;
+ continue nextInterface;
+ }
+ }
+ if (!superInterface.isInterface() && (superInterface.tagBits & TagBits.HasMissingType) == 0) {
+ problemReporter().superinterfaceMustBeAnInterface(sourceType, superInterfaceRef, superInterface);
+ sourceType.tagBits |= TagBits.HierarchyHasProblems;
+ noProblems = false;
+ continue nextInterface;
+ } else if (superInterface.isAnnotationType()){
+ problemReporter().annotationTypeUsedAsSuperinterface(sourceType, superInterfaceRef, superInterface);
+ }
+ if ((superInterface.tagBits & TagBits.HasDirectWildcard) != 0) {
+ problemReporter().superTypeCannotUseWildcard(sourceType, superInterfaceRef, superInterface);
+ sourceType.tagBits |= TagBits.HierarchyHasProblems;
+ noProblems = false;
+ continue nextInterface;
+ }
+ if ((superInterface.tagBits & TagBits.HierarchyHasProblems) != 0
+ || !superInterfaceRef.resolvedType.isValidBinding()) {
+ sourceType.tagBits |= TagBits.HierarchyHasProblems; // propagate if missing supertype
+ noProblems &= superInterfaceRef.resolvedType.isValidBinding();
+ }
+ if (superInterface.isSealed() && sourceType.isLocalType()) {
+ problemReporter().localTypeMayNotBePermittedType(sourceType, superInterfaceRef, superInterface);
+ noProblems = false;
+ } else if (superInterface.isSealed() && !(sourceType.isFinal() || sourceType.isSealed() || sourceType.isNonSealed())) {
+ problemReporter().permittedTypeNeedsModifier(sourceType, this.referenceContext, superInterface);
+ noProblems = false;
+ }
+
+ // only want to reach here when no errors are reported
+ sourceType.typeBits |= (superInterface.typeBits & TypeIds.InheritableBits);
+ interfaceBindings[count++] = superInterface;
}
- if (!superInterface.isInterface() && (superInterface.tagBits & TagBits.HasMissingType) == 0) {
- problemReporter().superinterfaceMustBeAnInterface(sourceType, superInterfaceRef, superInterface);
- sourceType.tagBits |= TagBits.HierarchyHasProblems;
- noProblems = false;
- continue nextInterface;
- } else if (superInterface.isAnnotationType()){
- problemReporter().annotationTypeUsedAsSuperinterface(sourceType, superInterfaceRef, superInterface);
- }
- if ((superInterface.tagBits & TagBits.HasDirectWildcard) != 0) {
- problemReporter().superTypeCannotUseWildcard(sourceType, superInterfaceRef, superInterface);
- sourceType.tagBits |= TagBits.HierarchyHasProblems;
- noProblems = false;
- continue nextInterface;
+ // hold onto all correctly resolved superinterfaces
+ if (count > 0) {
+ if (count != length)
+ System.arraycopy(interfaceBindings, 0, interfaceBindings = new ReferenceBinding[count], 0, count);
+ sourceType.setSuperInterfaces(interfaceBindings);
}
- if ((superInterface.tagBits & TagBits.HierarchyHasProblems) != 0
- || !superInterfaceRef.resolvedType.isValidBinding()) {
- sourceType.tagBits |= TagBits.HierarchyHasProblems; // propagate if missing supertype
- noProblems &= superInterfaceRef.resolvedType.isValidBinding();
+ } finally {
+ if (sourceType.isNonSealed() && !hasSealedSupertype) {
+ if (!sourceType.isRecord() && !sourceType.isLocalType() && !sourceType.isEnum() && !sourceType.isSealed()) // avoid double jeopardy
+ problemReporter().disallowedNonSealedModifier(sourceType, this.referenceContext);
}
- // only want to reach here when no errors are reported
- sourceType.typeBits |= (superInterface.typeBits & TypeIds.InheritableBits);
- interfaceBindings[count++] = superInterface;
- }
- // hold onto all correctly resolved superinterfaces
- if (count > 0) {
- if (count != length)
- System.arraycopy(interfaceBindings, 0, interfaceBindings = new ReferenceBinding[count], 0, count);
- sourceType.setSuperInterfaces(interfaceBindings);
}
return noProblems;
}
@@ -1699,7 +1685,7 @@ private ReferenceBinding findSupertype(TypeReference typeReference) {
} catch (AbortCompilation e) {
SourceTypeBinding sourceType = this.referenceContext.binding;
if (sourceType.superInterfaces == null) sourceType.setSuperInterfaces(Binding.NO_SUPERINTERFACES); // be more resilient for hierarchies (144976)
- if (sourceType.permittedTypes == null) sourceType.setPermittedTypes(Binding.NO_PERMITTEDTYPES);
+ if (sourceType.permittedTypes == null) sourceType.setPermittedTypes(Binding.NO_PERMITTED_TYPES);
e.updateContext(typeReference, referenceCompilationUnit().compilationResult);
throw e;
} finally {
@@ -1724,10 +1710,10 @@ private ReferenceBinding findPermittedtype(TypeReference typeReference) {
}
typeReference.bits |= ASTNode.IgnoreRawTypeCheck;
ReferenceBinding permittedType = (ReferenceBinding) typeReference.resolveType(this);
- return permittedType;
+ return permittedType != null ? permittedType.actualType() : permittedType; // while permitted classes/interfaces cannot be parameterized with type arguments, they are not raw either
} catch (AbortCompilation e) {
SourceTypeBinding sourceType = this.referenceContext.binding;
- if (sourceType.permittedTypes == null) sourceType.setPermittedTypes(Binding.NO_PERMITTEDTYPES);
+ if (sourceType.permittedTypes == null) sourceType.setPermittedTypes(Binding.NO_PERMITTED_TYPES);
e.updateContext(typeReference, referenceCompilationUnit().compilationResult);
throw e;
} finally {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java
index d97ee6ec95..b8749862d0 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java
@@ -28,16 +28,23 @@
import java.util.Map;
import java.util.Set;
import java.util.function.Predicate;
-
import org.eclipse.jdt.core.compiler.CharOperation;
-import org.eclipse.jdt.internal.compiler.ast.*;
+import org.eclipse.jdt.internal.compiler.ast.ASTNode;
+import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.ImportReference;
+import org.eclipse.jdt.internal.compiler.ast.Invocation;
+import org.eclipse.jdt.internal.compiler.ast.ModuleDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
import org.eclipse.jdt.internal.compiler.env.IUpdatableModule;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.impl.JavaFeature;
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
-import org.eclipse.jdt.internal.compiler.util.*;
+import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
+import org.eclipse.jdt.internal.compiler.util.HashtableOfType;
+import org.eclipse.jdt.internal.compiler.util.ObjectVector;
public class CompilationUnitScope extends Scope {
@@ -277,14 +284,20 @@ void checkAndSetImports() {
int numberOfImports = numberOfStatements + defaultImports.length;
for (int i = 0; i < numberOfStatements; i++) {
ImportReference importReference = this.referenceContext.imports[i];
- if ((importReference.bits & ASTNode.OnDemand) != 0 && !importReference.isStatic()) {
- if (CharOperation.equals(TypeConstants.JAVA_LANG, importReference.tokens)) {
- numberOfImports--;
- } else if ((importReference.modifiers & ClassFileConstants.AccModule) != 0 &&
- this.referenceContext.isSimpleCompilationUnit() &&
- CharOperation.equals(TypeConstants.JAVA_BASE, importReference.tokens)) {
- numberOfImports--;
- }
+ if ((importReference.bits & ASTNode.OnDemand) != 0) {
+ if (importReference.isStatic()) {
+ if (CharOperation.equals(TypeConstants.JAVA_IO_IO, importReference.tokens)) {
+ numberOfImports--;
+ }
+ } else {
+ if (CharOperation.equals(TypeConstants.JAVA_LANG, importReference.tokens)) {
+ numberOfImports--;
+ } else if ((importReference.modifiers & ClassFileConstants.AccModule) != 0 &&
+ this.referenceContext.isSimpleCompilationUnit() &&
+ CharOperation.equals(TypeConstants.JAVA_BASE, importReference.tokens)) {
+ numberOfImports--;
+ }
+ }
}
}
ImportBinding[] resolvedImports = new ImportBinding[numberOfImports];
@@ -303,6 +316,7 @@ void checkAndSetImports() {
return false;
}
return (CharOperation.equals(TypeConstants.JAVA_LANG, imp.tokens) ||
+ (CharOperation.equals(TypeConstants.JAVA_IO_IO, imp.tokens) && imp.isStatic()) ||
((imp.modifiers & ClassFileConstants.AccModule) != 0
&& CharOperation.equals(TypeConstants.JAVA_BASE, imp.tokens)));
};
@@ -475,8 +489,6 @@ void sealTypeHierarchy() {
for (SourceTypeBinding sourceType : this.topLevelTypes) {
sourceType.scope.connectPermittedTypes();
}
- for (SourceTypeBinding topLevelType : this.topLevelTypes)
- topLevelType.scope.connectImplicitPermittedTypes();
}
void integrateAnnotationsInHierarchy() {
// Only now that all hierarchy information is built we're ready for ...
@@ -839,13 +851,24 @@ private MethodBinding findStaticMethod(ReferenceBinding currentType, char[] sele
}
// GROOVY package->protected
protected ImportBinding[] getDefaultImports() {
+ ImportBinding javaIOImport = null;
if (JavaFeature.IMPLICIT_CLASSES_AND_INSTANCE_MAIN_METHODS.isSupported(this.environment.globalOptions) &&
this.referenceContext.isSimpleCompilationUnit()) {
ModuleBinding module = this.environment.getModule(CharOperation.concatWith(TypeConstants.JAVA_BASE, '.'));
+ Binding javaioIO = findSingleImport(TypeConstants.JAVA_IO_IO, Binding.TYPE, false);
+ if (javaioIO != null) {
+ javaIOImport = new ImportBinding(TypeConstants.JAVA_IO_IO, true, javaioIO, null) {
+ @Override
+ public boolean isStatic() {
+ return true;
+ }
+ };
+ }
if (module != null) {
ImportBinding javaBase = new ImportBinding(TypeConstants.JAVA_BASE, true, module, null);
// No need for the java.lang.* as module java.base covers it
- return new ImportBinding[] {javaBase};
+ return javaIOImport != null ? new ImportBinding[] {javaBase, javaIOImport}:
+ new ImportBinding[] {javaBase};
// this module import is not cached, there shouldn't be many files needing it.
}
}
@@ -855,7 +878,10 @@ protected ImportBinding[] getDefaultImports() {
Binding importBinding = this.environment.getTopLevelPackage(TypeConstants.JAVA);
if (importBinding != null)
importBinding = ((PackageBinding) importBinding).getTypeOrPackage(TypeConstants.JAVA_LANG[1], module(), false);
-
+ ImportBinding[] implicitImports = javaIOImport != null ? new ImportBinding[2] : new ImportBinding[1];
+ if (javaIOImport != null) {
+ implicitImports[1] = javaIOImport;
+ }
if (importBinding == null || !importBinding.isValidBinding()) {
// create a proxy for the missing BinaryType
problemReporter().isClassPathCorrect(
@@ -864,8 +890,11 @@ protected ImportBinding[] getDefaultImports() {
this.environment.missingClassFileLocation, false, null/*resolving j.l.O is not specific to any referencing type*/);
BinaryTypeBinding missingObject = this.environment.createMissingType(null, TypeConstants.JAVA_LANG_OBJECT);
importBinding = missingObject.fPackage;
+ implicitImports[0] = new ImportBinding(TypeConstants.JAVA_LANG, true, importBinding, null);
+ return implicitImports;
}
- return this.environment.root.defaultImports = new ImportBinding[] {new ImportBinding(TypeConstants.JAVA_LANG, true, importBinding, null)};
+ implicitImports[0] = new ImportBinding(TypeConstants.JAVA_LANG, true, importBinding, null);
+ return this.environment.root.defaultImports = implicitImports;
}
// NOT Public API
public final Binding getImport(char[][] compoundName, boolean onDemand, int modifiers) {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ConstraintExceptionFormula.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ConstraintExceptionFormula.java
index d7d0c3e327..04e33d0866 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ConstraintExceptionFormula.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ConstraintExceptionFormula.java
@@ -21,7 +21,6 @@
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
-
import org.eclipse.jdt.internal.compiler.ast.FunctionalExpression;
import org.eclipse.jdt.internal.compiler.ast.LambdaExpression;
import org.eclipse.jdt.internal.compiler.ast.ReferenceExpression;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ConstraintExpressionFormula.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ConstraintExpressionFormula.java
index 2bce82c25e..3ee7f51ec0 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ConstraintExpressionFormula.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ConstraintExpressionFormula.java
@@ -21,17 +21,7 @@
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
-
-import org.eclipse.jdt.internal.compiler.ast.Argument;
-import org.eclipse.jdt.internal.compiler.ast.ConditionalExpression;
-import org.eclipse.jdt.internal.compiler.ast.Expression;
-import org.eclipse.jdt.internal.compiler.ast.ExpressionContext;
-import org.eclipse.jdt.internal.compiler.ast.Invocation;
-import org.eclipse.jdt.internal.compiler.ast.LambdaExpression;
-import org.eclipse.jdt.internal.compiler.ast.MessageSend;
-import org.eclipse.jdt.internal.compiler.ast.ReferenceExpression;
-import org.eclipse.jdt.internal.compiler.ast.SwitchExpression;
-import org.eclipse.jdt.internal.compiler.ast.Wildcard;
+import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.SuspendedInferenceRecord;
/**
@@ -158,9 +148,9 @@ public Object reduce(InferenceContext18 inferenceContext) throws InferenceFailur
};
} else if (this.left instanceof SwitchExpression) {
SwitchExpression se = (SwitchExpression) this.left;
- ConstraintFormula[] cfs = new ConstraintFormula[se.resultExpressions.size()];
+ ConstraintFormula[] cfs = new ConstraintFormula[se.resultExpressions().size()];
int i = 0;
- for (Expression re : se.resultExpressions) {
+ for (Expression re : se.resultExpressions()) {
cfs[i++] = new ConstraintExpressionFormula(re, this.right, this.relation, this.isSoft);
}
return cfs;
@@ -552,7 +542,7 @@ Collection inputVariables(final InferenceContext18 context) {
} else if (this.left instanceof SwitchExpression && this.left.isPolyExpression()) {
SwitchExpression expr = (SwitchExpression) this.left;
Set variables = new LinkedHashSet<>();
- for (Expression re : expr.resultExpressions) {
+ for (Expression re : expr.resultExpressions()) {
variables.addAll(new ConstraintExpressionFormula(re, this.right, COMPATIBLE).inputVariables(context));
}
return variables;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ConstraintTypeFormula.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ConstraintTypeFormula.java
index 7b7346deac..432a70e482 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ConstraintTypeFormula.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ConstraintTypeFormula.java
@@ -17,7 +17,6 @@
import java.util.ArrayList;
import java.util.List;
-
import org.eclipse.jdt.internal.compiler.ast.Invocation;
import org.eclipse.jdt.internal.compiler.ast.Wildcard;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ElementValuePair.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ElementValuePair.java
index 72ddc15e3b..9ae8aa2fbc 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ElementValuePair.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ElementValuePair.java
@@ -15,7 +15,13 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
-import org.eclipse.jdt.internal.compiler.ast.*;
+import org.eclipse.jdt.internal.compiler.ast.Annotation;
+import org.eclipse.jdt.internal.compiler.ast.ArrayInitializer;
+import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess;
+import org.eclipse.jdt.internal.compiler.ast.Expression;
+import org.eclipse.jdt.internal.compiler.ast.FieldReference;
+import org.eclipse.jdt.internal.compiler.ast.NameReference;
+import org.eclipse.jdt.internal.compiler.ast.Reference;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.impl.Constant;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ExternalAnnotationSuperimposer.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ExternalAnnotationSuperimposer.java
index ae7e323598..a2291494de 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ExternalAnnotationSuperimposer.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ExternalAnnotationSuperimposer.java
@@ -20,7 +20,6 @@
import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
-
import org.eclipse.jdt.internal.compiler.ast.Argument;
import org.eclipse.jdt.internal.compiler.classfmt.ExternalAnnotationProvider;
import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ExtraCompilerModifiers.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ExtraCompilerModifiers.java
index aa7b0fdd1a..c28b24760d 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ExtraCompilerModifiers.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ExtraCompilerModifiers.java
@@ -57,5 +57,5 @@ public interface ExtraCompilerModifiers { // modifier constant
final int AccImplementing = ASTNode.Bit30; // record fact a method implements another one (it is concrete and overrides an abstract one)
final int AccImplicitlyDeclared = ASTNode.Bit30; // used for implicitly declared classes
final int AccGenericSignature = ASTNode.Bit31; // record fact a type/method/field involves generics in its signature (and need special signature attr)
- final int AccOutOfFlowScope = ASTNode.Bit29;
+ final int AccOutOfFlowScope = ASTNode.Bit29; // used to signal pattern binding variables not being live.
}
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ImplicitNullAnnotationVerifier.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ImplicitNullAnnotationVerifier.java
index a8a32fefc7..8da5132c9b 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ImplicitNullAnnotationVerifier.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ImplicitNullAnnotationVerifier.java
@@ -17,7 +17,6 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/InferenceContext18.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/InferenceContext18.java
index 96595c5f56..f3ff9a39ec 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/InferenceContext18.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/InferenceContext18.java
@@ -14,29 +14,9 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
+import java.util.*;
import org.eclipse.jdt.core.compiler.CharOperation;
-import org.eclipse.jdt.internal.compiler.ast.AllocationExpression;
-import org.eclipse.jdt.internal.compiler.ast.ConditionalExpression;
-import org.eclipse.jdt.internal.compiler.ast.Expression;
-import org.eclipse.jdt.internal.compiler.ast.FunctionalExpression;
-import org.eclipse.jdt.internal.compiler.ast.Invocation;
-import org.eclipse.jdt.internal.compiler.ast.LambdaExpression;
-import org.eclipse.jdt.internal.compiler.ast.RecordPattern;
-import org.eclipse.jdt.internal.compiler.ast.ReferenceExpression;
-import org.eclipse.jdt.internal.compiler.ast.SwitchExpression;
-import org.eclipse.jdt.internal.compiler.ast.Wildcard;
+import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants.BoundCheckStatus;
import org.eclipse.jdt.internal.compiler.util.Sorting;
@@ -599,7 +579,7 @@ private ReductionResult addJDK_8153748ConstraintsFromExpression(Expression argum
} else if (argument instanceof SwitchExpression) {
SwitchExpression se = (SwitchExpression) argument;
ReductionResult result = ReductionResult.FALSE;
- for (Expression re : se.resultExpressions) {
+ for (Expression re : se.resultExpressions()) {
result = addJDK_8153748ConstraintsFromExpression(re, parameter, method, substitution);
if (result == ReductionResult.FALSE)
break;
@@ -743,7 +723,7 @@ private boolean addConstraintsToC_OneExpr(Expression expri, Set applicablePermTypes = new ArrayList<>();
- for (ReferenceBinding pt : permTypes) {
- ReferenceBinding permittedTypeAvatar = pt;
- if (pt.isRawType()) {
- ReferenceBinding ptRef = pt.actualType();
- ReferenceBinding enclosingType1 = ptRef.enclosingType();
- if (enclosingType1 != null) {
- // don't use TypeSystem.getParameterizedType below as this is just for temporary check.
- ParameterizedTypeBinding ptb = new ParameterizedTypeBinding(ptRef, this.arguments, ptRef.enclosingType(), this.environment);
- ptb.superclass();
- ptb.superInterfaces();
- permittedTypeAvatar = ptb;
+ List permittedTypes = new ArrayList<>();
+ for (ReferenceBinding pt : this.type.permittedTypes()) {
+ TypeBinding sooper = pt.findSuperTypeOriginatingFrom(this);
+ if (sooper == null || !sooper.isValidBinding() || sooper.isProvablyDistinct(this))
+ continue;
+ TypeBinding current = this;
+ Map map = new HashMap<>();
+ do {
+ if (sooper.isParameterizedType() && current.isParameterizedType()) {
+ for (int i = 0, length = sooper.typeArguments().length; i < length; i++) {
+ TypeBinding t = sooper.typeArguments()[i];
+ if (t instanceof TypeVariableBinding tvb) {
+ map.put(tvb, current.typeArguments()[i]);
+ }
+ }
}
- }
- if (permittedTypeAvatar.isCompatibleWith(this))
- applicablePermTypes.add(pt);
+ current = current.enclosingType();
+ sooper = sooper.enclosingType();
+ } while (current != null);
+
+ Substitution substitution = new Substitution() {
+ @Override
+ public LookupEnvironment environment() {
+ return ParameterizedTypeBinding.this.environment;
+ }
+ @Override
+ public boolean isRawSubstitution() {
+ return false;
+ }
+ @Override
+ public TypeBinding substitute(TypeVariableBinding typeVariable) {
+ TypeBinding retVal = map.get(typeVariable.unannotated());
+ if (retVal == null) {
+ retVal = ParameterizedTypeBinding.this.environment.createWildcard((ReferenceBinding) typeVariable.declaringElement, typeVariable.rank, null, null, Wildcard.UNBOUND);
+ map.put(typeVariable, retVal);
+ }
+ return retVal;
+ }
+ };
+ permittedTypes.add((ReferenceBinding) Scope.substitute(substitution, pt));
}
- return applicablePermTypes.toArray(new ReferenceBinding[0]);
+
+ return permittedTypes.toArray(new ReferenceBinding[0]);
}
@Override
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/PolyTypeBinding.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/PolyTypeBinding.java
index 82e59da9fa..1321945527 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/PolyTypeBinding.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/PolyTypeBinding.java
@@ -17,7 +17,6 @@
package org.eclipse.jdt.internal.compiler.lookup;
import org.eclipse.jdt.internal.compiler.ast.Expression;
-import org.eclipse.jdt.internal.compiler.ast.LambdaExpression;
public class PolyTypeBinding extends TypeBinding {
@@ -75,8 +74,7 @@ public char[] readableName() {
@Override
public char[] shortReadableName() {
- return this.expression instanceof LambdaExpression ?
- ((LambdaExpression) this.expression).printExpression(0, new StringBuilder(), true).toString().toCharArray() : readableName();
+ return this.expression.printExpression(0, new StringBuilder(), true).toString().toCharArray();
}
@Override
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java
index f7f390d0ff..07343f825e 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java
@@ -15,7 +15,6 @@
package org.eclipse.jdt.internal.compiler.lookup;
import java.lang.reflect.Field;
-
import org.eclipse.jdt.core.compiler.CharOperation;
@SuppressWarnings("rawtypes")
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/RawTypeBinding.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/RawTypeBinding.java
index 97a04883ce..a4e0006352 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/RawTypeBinding.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/RawTypeBinding.java
@@ -22,7 +22,6 @@
package org.eclipse.jdt.internal.compiler.lookup;
import java.util.Set;
-
import org.eclipse.jdt.core.compiler.CharOperation;
/**
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java
index ba9099ffed..6125e14bf3 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java
@@ -53,20 +53,18 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
+import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.LambdaExpression;
import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.NullAnnotationMatching;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-import org.eclipse.jdt.internal.compiler.impl.JavaFeature;
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable;
@@ -2109,11 +2107,6 @@ public ReferenceBinding superclass() {
return null;
}
-@Override
-public ReferenceBinding[] permittedTypes() {
- return Binding.NO_PERMITTEDTYPES;
-}
-
@Override
public ReferenceBinding[] superInterfaces() {
return Binding.NO_SUPERINTERFACES;
@@ -2377,10 +2370,8 @@ public MethodBinding getSingleAbstractMethod(Scope scope, boolean replaceWildcar
return this.singleAbstractMethod[index];
} else {
this.singleAbstractMethod = new MethodBinding[2];
- // Sec 9.8 of sealed preview - A functional interface is an interface that is not declared sealed...
- if (JavaFeature.SEALED_CLASSES.isSupported(scope.compilerOptions())
- && this.isSealed())
- return this.singleAbstractMethod[index] = samProblemBinding;
+ if (this.isSealed())
+ return this.singleAbstractMethod[index] = samProblemBinding; // JLS 9.8
}
if (this.compoundName != null)
@@ -2556,24 +2547,24 @@ public boolean hasEnclosingInstanceContext() {
return false;
}
-@Override
-public List getAllEnumerableReferenceTypes() {
+public List getAllEnumerableAvatars() {
if (!isSealed())
- return Collections.emptyList();
+ throw new UnsupportedOperationException("Operation valid only on sealed types!"); //$NON-NLS-1$
Set permSet = new HashSet<>(Arrays.asList(permittedTypes()));
- if (isClass() && (!isAbstract()))
+ if (isClass() && canBeInstantiated())
permSet.add(this);
Set oldSet = new HashSet<>(permSet);
do {
for (ReferenceBinding type : permSet) {
- oldSet.addAll(Arrays.asList(type.permittedTypes()));
+ if (type.isSealed())
+ oldSet.addAll(Arrays.asList(type.permittedTypes()));
}
Set tmp = oldSet;
oldSet = permSet;
permSet = tmp;
} while (oldSet.size() != permSet.size());
- return Arrays.asList(permSet.toArray(new ReferenceBinding[0]));
+ return new ArrayList<>(permSet);
}
// 5.1.6.1 Allowed Narrowing Reference Conversion
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/Scope.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/Scope.java
index fed443c289..c9d349e604 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/Scope.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/Scope.java
@@ -65,10 +65,15 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.function.Function;
import java.util.function.Supplier;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
@@ -1149,6 +1154,18 @@ public final ClassScope enclosingClassScope() {
return null; // may answer null if no type around
}
+ public ClassScope enclosingInstanceScope() {
+ Scope scope = this;
+ while (true) {
+ scope = scope.parent;
+ if (scope == null || scope instanceof MethodScope ms && ms.isStatic) {
+ return null;
+ } else if (scope instanceof ClassScope cs) {
+ return cs;
+ }
+ }
+ }
+
public final ClassScope enclosingTopMostClassScope() {
Scope scope = this;
while (scope != null) {
@@ -3816,18 +3833,41 @@ public boolean hasErasedCandidatesCollisions(TypeBinding one, TypeBinding two, M
}
/**
- * Returns the immediately enclosing switchCase statement (carried by closest blockScope),
+ * Returns the immediately enclosing case statement (carried by closest blockScope),
*/
- public CaseStatement innermostSwitchCase() {
+ public CaseStatement enclosingSwitchLabel() {
Scope scope = this;
do {
- if (scope instanceof BlockScope)
- return ((BlockScope) scope).enclosingCase;
+ if (scope instanceof BlockScope bs)
+ return bs.enclosingCase;
scope = scope.parent;
} while (scope != null);
return null;
}
+ /**
+ * Returns the immediately enclosing switch expression (carried by closest blockScope),
+ */
+ public SwitchExpression enclosingSwitchExpression() {
+ Scope current = this;
+ do {
+ switch(current.kind) {
+ case METHOD_SCOPE :
+ case CLASS_SCOPE :
+ case COMPILATION_UNIT_SCOPE :
+ case MODULE_SCOPE :
+ return null;
+ case BLOCK_SCOPE: {
+ BlockScope bs = (BlockScope) current;
+ if (bs.enclosingCase != null && bs.enclosingCase.swich instanceof SwitchExpression se)
+ return se;
+ break;
+ }
+ }
+ } while ((current = current.parent) != null);
+ return null;
+ }
+
// Tie break IS running to determine the most specific method binding.
protected boolean isAcceptableMethod(MethodBinding one, MethodBinding two) {
TypeBinding[] oneParams = one.parameters;
@@ -5770,6 +5810,8 @@ public TypeBinding getMatchingUninitializedType(TypeBinding targetClass, boolean
|| (currentTarget instanceof ReferenceBinding currentRefBind && !currentRefBind.hasEnclosingInstanceContext())) {
break;
}
+ if (currentTarget.isStatic() || currentTarget.isLocalType())
+ break;
currentTarget = currentTarget.enclosingType();
}
currentEnclosing = currentEnclosing.parent.classScope();
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SortedCompoundNameVector.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SortedCompoundNameVector.java
index f6d2a7d4b8..5589fc8404 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SortedCompoundNameVector.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SortedCompoundNameVector.java
@@ -14,7 +14,6 @@
package org.eclipse.jdt.internal.compiler.lookup;
import java.util.Arrays;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.util.SortedCharArrays;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SortedSimpleNameVector.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SortedSimpleNameVector.java
index 2cd0179488..a8930bbd24 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SortedSimpleNameVector.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SortedSimpleNameVector.java
@@ -14,7 +14,6 @@
package org.eclipse.jdt.internal.compiler.lookup;
import java.util.Arrays;
-
import org.eclipse.jdt.internal.compiler.util.SortedCharArrays;
/**
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SourceModuleBinding.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SourceModuleBinding.java
index aaa78bed80..b6186780d4 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SourceModuleBinding.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SourceModuleBinding.java
@@ -17,7 +17,6 @@
import java.util.LinkedHashMap;
import java.util.function.IntFunction;
import java.util.stream.Stream;
-
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.ModuleDeclaration;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
index b640af00b1..7931ab4797 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
@@ -56,36 +56,19 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
-import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
-import java.util.LinkedHashMap;
import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-
import org.eclipse.jdt.core.compiler.CharOperation;
-import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy;
-import org.eclipse.jdt.internal.compiler.ast.ASTNode;
-import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.Annotation;
-import org.eclipse.jdt.internal.compiler.ast.Argument;
-import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.LambdaExpression;
-import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.RecordComponent;
-import org.eclipse.jdt.internal.compiler.ast.ReferenceExpression;
-import org.eclipse.jdt.internal.compiler.ast.SwitchStatement;
-import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.TypeParameter;
-import org.eclipse.jdt.internal.compiler.ast.TypeReference;
+import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.ast.TypeReference.AnnotationPosition;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.classfmt.ExternalAnnotationProvider;
@@ -1170,239 +1153,49 @@ private void checkAnnotationsInType() {
void faultInTypesForFieldsAndMethods() {
if (!isPrototype()) throw new IllegalStateException();
- checkPermitsInType();
+ if (!this.isLocalType())
+ complainIfUnpermittedSubtyping(); // this has nothing to do with fields and methods but time is ripe for this check.
checkAnnotationsInType();
internalFaultInTypeForFieldsAndMethods();
}
-private Map.Entry getFirstSealedSuperTypeOrInterface(TypeDeclaration typeDecl) {
- boolean isAnySuperTypeSealed = typeDecl.superclass != null && this.superclass != null ? this.superclass.isSealed() : false;
- if (isAnySuperTypeSealed)
- return new AbstractMap.SimpleEntry<>(typeDecl.superclass, this.superclass);
+private boolean isAnUnpermittedSubtypeOf(ReferenceBinding superType) {
- ReferenceBinding[] superInterfaces1 = this.superInterfaces();
- int l = superInterfaces1 != null ? superInterfaces1.length : 0;
- for (int i = 0; i < l; ++i) {
- ReferenceBinding superInterface = superInterfaces1[i];
- if (superInterface.isSealed()) {
- return new AbstractMap.SimpleEntry<>(typeDecl.superInterfaces[i], superInterface);
- }
+ if (superType == null || !superType.isSealed())
+ return false;
+
+ for (ReferenceBinding permittedType : superType.actualType().permittedTypes()) {
+ if (TypeBinding.equalsEquals(this, permittedType))
+ return false;
}
- return null;
+
+ return true;
}
-// TODO: Optimize the multiple loops - defer until the feature becomes standard.
-private void checkPermitsInType() {
+private void complainIfUnpermittedSubtyping() {
+
+ // Diagnose unauthorized subtyping: This cannot be correctly hoisted into ClassScope.{ connectSuperclass() | connectSuperInterfaces() | connectPermittedTypes() }
+ // but can be taken up now
+
TypeDeclaration typeDecl = this.scope.referenceContext;
- if (this.isInterface()) {
- if (isSealed() && isNonSealed()) {
- this.scope.problemReporter().sealedInterfaceIsSealedAndNonSealed(this, typeDecl);
- return;
- }
- }
- boolean hasPermittedTypes = this.permittedTypes != null && this.permittedTypes.length > 0;
- if (hasPermittedTypes) {
- if (!this.isSealed())
- this.scope.problemReporter().sealedMissingSealedModifier(this, typeDecl);
- ModuleBinding sourceModuleBinding = this.module();
- boolean isUnnamedModule = sourceModuleBinding.isUnnamed();
- if (isUnnamedModule) {
- PackageBinding sourceTypePackage = this.getPackage();
- for (int i =0, l = this.permittedTypes.length; i < l; i++) {
- ReferenceBinding permType = this.permittedTypes[i];
- if (!permType.isValidBinding()) continue;
- if (sourceTypePackage != permType.getPackage()) {
- TypeReference permittedTypeRef = typeDecl.permittedTypes[i];
- this.scope.problemReporter().sealedPermittedTypeOutsideOfPackage(permType, this, permittedTypeRef, sourceTypePackage);
- }
- }
- } else {
- for (int i = 0, l = this.permittedTypes.length; i < l; i++) {
- ReferenceBinding permType = this.permittedTypes[i];
- if (!permType.isValidBinding()) continue;
- ModuleBinding permTypeModule = permType.module();
- if (permTypeModule != null && sourceModuleBinding != permTypeModule) {
- TypeReference permittedTypeRef = typeDecl.permittedTypes[i];
- this.scope.problemReporter().sealedPermittedTypeOutsideOfModule(permType, this, permittedTypeRef, sourceModuleBinding);
- }
- }
- }
+ if (this.isAnUnpermittedSubtypeOf(this.superclass)) {
+ this.scope.problemReporter().sealedSupertypeDoesNotPermit(this, typeDecl.superclass, this.superclass);
}
- Map.Entry sealedEntry = getFirstSealedSuperTypeOrInterface(typeDecl);
- boolean foundSealedSuperTypeOrInterface = sealedEntry != null;
- if (this.isLocalType()) {
- if (this.isSealed() || this.isNonSealed())
- return; // already handled elsewhere
- if (foundSealedSuperTypeOrInterface) {
- this.scope.problemReporter().sealedLocalDirectSuperTypeSealed(this, sealedEntry.getKey(), sealedEntry.getValue());
- return;
- }
- } else if (this.isNonSealed()) {
- if (!foundSealedSuperTypeOrInterface) {
- if (this.isClass() && !this.isRecord()) // record to give only illegal modifier error.
- this.scope.problemReporter().sealedDisAllowedNonSealedModifierInClass(this, typeDecl);
- else if (this.isInterface())
- this.scope.problemReporter().sealedDisAllowedNonSealedModifierInInterface(this, typeDecl);
- }
- }
- if (foundSealedSuperTypeOrInterface) {
- if (!(this.isFinal() || this.isSealed() || this.isNonSealed())) {
- if (this.isClass())
- this.scope.problemReporter().sealedMissingClassModifier(this, typeDecl, sealedEntry.getValue());
- else if (this.isInterface())
- this.scope.problemReporter().sealedMissingInterfaceModifier(this, typeDecl, sealedEntry.getValue());
- }
- if (!typeDecl.isRecord() && typeDecl.superclass != null && !checkPermitsAndAdd(this.superclass)) {
- reportSealedSuperTypeDoesNotPermitProblem(typeDecl.superclass, this.superclass);
- }
- for (int i = 0, l = this.superInterfaces.length; i < l; ++i) {
- ReferenceBinding superInterface = this.superInterfaces[i];
- if (superInterface != null && !checkPermitsAndAdd(superInterface)) {
- TypeReference superInterfaceRef = typeDecl.superInterfaces[i];
- reportSealedSuperTypeDoesNotPermitProblem(superInterfaceRef, superInterface);
- }
+ for (int i = 0, l = this.superInterfaces.length; i < l; ++i) {
+ ReferenceBinding superInterface = this.superInterfaces[i];
+ if (this.isAnUnpermittedSubtypeOf(superInterface)) {
+ TypeReference superInterfaceRef = typeDecl.superInterfaces[i];
+ this.scope.problemReporter().sealedSupertypeDoesNotPermit(this, superInterfaceRef, superInterface);
}
}
+
for (ReferenceBinding memberType : this.memberTypes)
- ((SourceTypeBinding) memberType).checkPermitsInType();
+ ((SourceTypeBinding) memberType).complainIfUnpermittedSubtyping();
- if (this.scope.referenceContext.permittedTypes == null) {
- // Ignore implicitly permitted case
- return;
- }
- // In case of errors, be safe.
- int l = this.permittedTypes.length <= this.scope.referenceContext.permittedTypes.length ?
- this.permittedTypes.length : this.scope.referenceContext.permittedTypes.length;
- for (int i = 0; i < l; i++) {
- TypeReference permittedTypeRef = this.scope.referenceContext.permittedTypes[i];
- ReferenceBinding permittedType = this.permittedTypes[i];
- if (permittedType == null || !permittedType.isValidBinding())
- continue;
- if (this.isClass()) {
- ReferenceBinding permSuperType = permittedType.superclass();
- permSuperType = permSuperType.actualType();
- if (!TypeBinding.equalsEquals(this, permSuperType)) {
- this.scope.problemReporter().sealedNotDirectSuperClass(permittedType, permittedTypeRef, this);
- continue;
- }
- } else if (this.isInterface()) {
- ReferenceBinding[] permSuperInterfaces = permittedType.superInterfaces();
- boolean foundSuperInterface = false;
- if (permSuperInterfaces != null) {
- for (ReferenceBinding psi : permSuperInterfaces) {
- psi = psi.actualType();
- if (TypeBinding.equalsEquals(this, psi)) {
- foundSuperInterface = true;
- break;
- }
- }
- if (!foundSuperInterface) {
- this.scope.problemReporter().sealedNotDirectSuperInterface(permittedType, permittedTypeRef, this);
- continue;
- }
- }
- }
- }
return;
}
-private void reportSealedSuperTypeDoesNotPermitProblem(TypeReference superTypeRef, TypeBinding superType) {
- ModuleBinding sourceModuleBinding = this.module();
- boolean isUnnamedModule = sourceModuleBinding.isUnnamed();
- boolean isClass = false;
- if (superType.isClass()) {
- isClass = true;
- }
- boolean sealedSuperTypeDoesNotPermit = false;
- ReferenceBinding superReferenceBinding = null;
- if (superType instanceof ReferenceBinding) {
- superReferenceBinding = (ReferenceBinding) superType;
- if (isUnnamedModule) {
- PackageBinding superTypePackage = superReferenceBinding.getPackage();
- PackageBinding pkg = this.getPackage();
- sealedSuperTypeDoesNotPermit = pkg!= null && pkg.equals(superTypePackage);
- } else {
- ModuleBinding superTypeModule = superReferenceBinding.module();
- ModuleBinding mod = this.module();
- sealedSuperTypeDoesNotPermit = mod!= null && mod.equals(superTypeModule);
- }
- }
- if (sealedSuperTypeDoesNotPermit) {
- if (isClass) {
- this.scope.problemReporter().sealedSuperClassDoesNotPermit(this, superTypeRef, superType);
- } else {
- this.scope.problemReporter().sealedSuperInterfaceDoesNotPermit(this, superTypeRef, superType);
- }
- } else {
- if (superReferenceBinding instanceof SourceTypeBinding && isUnnamedModule) {
- PackageBinding superTypePackage = superReferenceBinding.getPackage();
- if (isClass) {
- this.scope.problemReporter().sealedSuperClassInDifferentPackage(this, superTypeRef, superType, superTypePackage);
- } else {
- this.scope.problemReporter().sealedSuperInterfaceInDifferentPackage(this, superTypeRef, superType, superTypePackage);
- }
- } else {
- if (isClass) {
- this.scope.problemReporter().sealedSuperClassDisallowed(this, superTypeRef, superType);
- } else {
- this.scope.problemReporter().sealedSuperInterfaceDisallowed(this, superTypeRef, superType);
- }
- }
- }
-}
-
-public List collectAllTypeBindings(TypeDeclaration typeDecl, CompilationUnitScope unitScope) {
- class TypeBindingsCollector extends ASTVisitor {
- List types = new ArrayList<>();
- @Override
- public boolean visit(
- TypeDeclaration localTypeDeclaration,
- BlockScope scope1) {
- checkAndAddBinding(localTypeDeclaration.binding);
- return true;
- }
- @Override
- public boolean visit(
- TypeDeclaration memberTypeDeclaration,
- ClassScope scope1) {
- checkAndAddBinding(memberTypeDeclaration.binding);
- return true;
- }
- @Override
- public boolean visit(
- TypeDeclaration typeDeclaration,
- CompilationUnitScope scope1) {
- checkAndAddBinding(typeDeclaration.binding);
- return true; // do nothing by default, keep traversing
- }
- private void checkAndAddBinding(SourceTypeBinding stb) {
- if (stb != null)
- this.types.add(stb);
- }
- }
- TypeBindingsCollector typeCollector = new TypeBindingsCollector();
- typeDecl.traverse(typeCollector, unitScope);
- return typeCollector.types;
-}
-
-private boolean checkPermitsAndAdd(ReferenceBinding superType) {
- if (superType == null
- || superType.equals(this.scope.getJavaLangObject())
- || !superType.isSealed())
- return true;
- if (superType.isSealed()) {
- superType = superType.actualType();
- ReferenceBinding[] superPermittedTypes = superType.permittedTypes();
- for (ReferenceBinding permittedType : superPermittedTypes) {
- permittedType = permittedType.actualType();
- if (permittedType.isValidBinding() && TypeBinding.equalsEquals(this, permittedType))
- return true;
- }
- }
- return false;
-}
-
@Override
public RecordComponentBinding[] components() {
if (!this.isRecordDeclaration)
@@ -3359,6 +3152,22 @@ public ReferenceBinding[] setPermittedTypes(ReferenceBinding [] permittedTypes)
return this.permittedTypes = permittedTypes;
}
+private void setImplicitPermittedType(SourceTypeBinding permittedType) {
+ ReferenceBinding[] typesPermitted = this.permittedTypes();
+ int sz = typesPermitted == null ? 0 : typesPermitted.length;
+ if (this.scope.referenceCompilationUnit() == permittedType.scope.referenceCompilationUnit()) {
+ if (sz == 0) {
+ typesPermitted = new ReferenceBinding[] { permittedType };
+ } else {
+ System.arraycopy(typesPermitted, 0, typesPermitted = new ReferenceBinding[sz + 1], 0, sz);
+ typesPermitted[sz] = permittedType;
+ }
+ this.setPermittedTypes(typesPermitted);
+ } else if (sz == 0) {
+ this.setPermittedTypes(Binding.NO_PERMITTED_TYPES);
+ }
+}
+
/**
* Propagates writes to all annotated variants so the clones evolve along.
*/
@@ -3373,6 +3182,11 @@ public ReferenceBinding setSuperClass(ReferenceBinding superClass) {
annotatedType.superclass = superClass;
}
}
+ if (superClass != null && superClass.actualType() instanceof SourceTypeBinding sourceSuperType && sourceSuperType.isSealed() && sourceSuperType.scope.referenceContext.permittedTypes == null) {
+ sourceSuperType.setImplicitPermittedType(this);
+ if (this.isAnonymousType() && superClass.isEnum())
+ this.modifiers |= ClassFileConstants.AccFinal;
+ }
return this.superclass = superClass;
}
@@ -3390,6 +3204,12 @@ public ReferenceBinding[] setSuperInterfaces(ReferenceBinding [] superInterfaces
annotatedType.superInterfaces = superInterfaces;
}
}
+ for (int i = 0, length = superInterfaces == null ? 0 : superInterfaces.length; i < length; i++) {
+ ReferenceBinding superInterface = superInterfaces[i];
+ if (superInterface.actualType() instanceof SourceTypeBinding sourceSuperType && sourceSuperType.isSealed() && sourceSuperType.scope.referenceContext.permittedTypes == null) {
+ sourceSuperType.setImplicitPermittedType(this);
+ }
+ }
return this.superInterfaces = superInterfaces;
}
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SplitPackageBinding.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SplitPackageBinding.java
index ee1dc7a62f..f61f2f9688 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SplitPackageBinding.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SplitPackageBinding.java
@@ -19,7 +19,6 @@
import java.util.List;
import java.util.Set;
import java.util.function.Consumer;
-
import org.eclipse.jdt.core.compiler.CharOperation;
public class SplitPackageBinding extends PackageBinding {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SyntheticMethodBinding.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SyntheticMethodBinding.java
index 728f94ee94..d49df8d099 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SyntheticMethodBinding.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SyntheticMethodBinding.java
@@ -20,7 +20,6 @@
package org.eclipse.jdt.internal.compiler.lookup;
import java.util.stream.Stream;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java
index 3746eafca0..594ea2ecf6 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java
@@ -1,5 +1,6 @@
+// GROOVY PATCHED
/*******************************************************************************
- * Copyright (c) 2000, 2023 IBM Corporation and others.
+ * Copyright (c) 2000, 2024 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -38,11 +39,9 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
-import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.Wildcard;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
@@ -103,6 +102,8 @@ abstract public class TypeBinding extends Binding {
public final static VoidTypeBinding VOID = new VoidTypeBinding();
+ public final static TypeBinding [] NUMERIC_TYPES = // // Order sensitive to determine the type in numeric promotion
+ new TypeBinding [] {TypeBinding.DOUBLE, TypeBinding.FLOAT, TypeBinding.LONG, TypeBinding.INT, TypeBinding.SHORT, TypeBinding.BYTE, TypeBinding.CHAR };
public TypeBinding() {
super();
@@ -682,6 +683,20 @@ public boolean isBoxedPrimitiveType() {
}
}
+public TypeBinding unboxedType() {
+ return switch (this.id) {
+ case TypeIds.T_JavaLangBoolean -> TypeBinding.BOOLEAN;
+ case TypeIds.T_JavaLangByte -> TypeBinding.BYTE;
+ case TypeIds.T_JavaLangCharacter -> TypeBinding.CHAR;
+ case TypeIds.T_JavaLangShort -> TypeBinding.SHORT;
+ case TypeIds.T_JavaLangDouble -> TypeBinding.DOUBLE;
+ case TypeIds.T_JavaLangFloat -> TypeBinding.FLOAT;
+ case TypeIds.T_JavaLangInteger -> TypeBinding.INT;
+ case TypeIds.T_JavaLangLong -> TypeBinding.LONG;
+ default -> this;
+ };
+}
+
/**
* Returns true if parameterized type AND not of the form {@code List>}
*/
@@ -704,6 +719,10 @@ public boolean isRecord() {
return false;
}
+public boolean isRecordWithComponents() { // do records without components make sense ??
+ return isRecord() && components() != null && components().length > 0; // GROOVY edit
+}
+
/* Answer true if the receiver type can be assigned to the argument type (right)
*/
public boolean isCompatibleWith(TypeBinding right) {
@@ -1760,7 +1779,7 @@ public ReferenceBinding superclass() {
}
public ReferenceBinding[] permittedTypes() {
- return Binding.NO_PERMITTEDTYPES;
+ return Binding.NO_PERMITTED_TYPES;
}
public ReferenceBinding[] superInterfaces() {
@@ -1811,9 +1830,4 @@ public boolean isNonDenotable() {
public boolean isSealed() {
return false;
}
-
-public List getAllEnumerableReferenceTypes() {
- return Collections.emptyList();
-}
-
}
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java
index 7bf3164ab1..3897dc2442 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java
@@ -130,6 +130,7 @@ public interface TypeConstants {
// JEP 360 Sealed
char[] PERMITS = "permits".toCharArray(); //$NON-NLS-1$
char[] SEALED = "sealed".toCharArray(); //$NON-NLS-1$
+ char[] NON_SEALED = "non-sealed".toCharArray(); //$NON-NLS-1$
String KEYWORD_EXTENDS = "extends"; //$NON-NLS-1$
String IMPLEMENTS = "implements"; //$NON-NLS-1$
@@ -157,7 +158,7 @@ public interface TypeConstants {
char[] SPRING = "springframework".toCharArray(); //$NON-NLS-1$
// Constant compound names
- char[][] JAVA_BASE = {JAVA, BASE};
+ char[][] JAVA_BASE = {JAVA, BASE};
char[][] JAVA_LANG = {JAVA, LANG};
char[][] JAVA_IO = {JAVA, IO};
char[][] JAVA_LANG_ANNOTATION = {JAVA, LANG, ANNOTATION};
@@ -224,6 +225,7 @@ public interface TypeConstants {
char[][] JAVA_IO_IOEXCEPTION = new char[][] { JAVA, IO, "IOException".toCharArray()};//$NON-NLS-1$
char[][] JAVA_IO_OBJECTOUTPUTSTREAM = new char[][] { JAVA, IO, "ObjectOutputStream".toCharArray()}; //$NON-NLS-1$
char[][] JAVA_IO_OBJECTINPUTSTREAM = new char[][] { JAVA, IO, "ObjectInputStream".toCharArray()}; //$NON-NLS-1$
+ char[][] JAVA_IO_IO = new char[][] {JAVA, IO, "IO".toCharArray()}; //$NON-NLS-1$
char[][] JAVA_NIO_FILE_FILES = new char[][] { JAVA, "nio".toCharArray(), "file".toCharArray(), "Files".toCharArray() }; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
// javax.rmi.CORBA.Stub
char[][] JAVAX_RMI_CORBA_STUB = new char[][] {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/TypeSystem.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/TypeSystem.java
index e403cbcd52..c7de83d7ea 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/TypeSystem.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/TypeSystem.java
@@ -22,7 +22,6 @@
import java.util.HashMap;
import java.util.function.Consumer;
import java.util.function.Supplier;
-
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable;
import org.eclipse.jdt.internal.compiler.util.Util;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java
index d61b7108cc..22e3782929 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java
@@ -43,18 +43,18 @@
package org.eclipse.jdt.internal.compiler.lookup;
import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.function.Consumer;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.Annotation;
import org.eclipse.jdt.internal.compiler.ast.NullAnnotationMatching;
-import org.eclipse.jdt.internal.compiler.ast.NullAnnotationMatching.CheckMode;
import org.eclipse.jdt.internal.compiler.ast.TypeParameter;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.ast.Wildcard;
+import org.eclipse.jdt.internal.compiler.ast.NullAnnotationMatching.CheckMode;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants.BoundCheckStatus;
@@ -155,7 +155,7 @@ private TypeConstants.BoundCheckStatus internalBoundCheck(Substitution substitut
return BoundCheckStatus.OK;
BoundCheckStatus nullStatus = BoundCheckStatus.OK;
- boolean checkNullAnnotations = scope.environment().usesNullTypeAnnotations() && (location == null || (location.bits & ASTNode.InsideJavadoc) == 0);
+ boolean checkNullAnnotations = scope != null && scope.environment().usesNullTypeAnnotations() && (location == null || (location.bits & ASTNode.InsideJavadoc) == 0);
if (argumentType.kind() == Binding.WILDCARD_TYPE) {
WildcardBinding wildcard = (WildcardBinding) argumentType;
@@ -745,6 +745,29 @@ public boolean isSealed() {
return false;
}
+
+ @Override
+ public ReferenceBinding[] permittedTypes() {
+ Set permittedTypes = new HashSet<>();
+ if (this.superclass != null && this.superclass.isSealed()) {
+ for (ReferenceBinding pt : this.superclass.permittedTypes()) {
+ if (boundCheck(null, pt, null, null) != BoundCheckStatus.MISMATCH)
+ permittedTypes.add(pt);
+ }
+ }
+ if (this.superInterfaces != null && this.superInterfaces != Binding.NO_SUPERINTERFACES) {
+ for (int i = 0, length = this.superInterfaces.length; i < length; i++) {
+ if (this.superInterfaces[i].isSealed()) {
+ for (ReferenceBinding pt : this.superInterfaces[i].permittedTypes()) {
+ if (boundCheck(null, pt, null, null) != BoundCheckStatus.MISMATCH)
+ permittedTypes.add(pt);
+ }
+ }
+ }
+ }
+ return permittedTypes.toArray(new ReferenceBinding[0]);
+ }
+
// /**
// * Returns the original type variable for a given variable.
// * Only different from receiver for type variables of generic methods of parameterized types
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java
index a2e14d3e1f..2a69d855e2 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java
@@ -29,7 +29,6 @@
import java.util.List;
import java.util.Set;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.Annotation;
import org.eclipse.jdt.internal.compiler.ast.Wildcard;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java
index 1e102e5a90..378489a710 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java
@@ -24,7 +24,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.compiler.InvalidInputException;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
@@ -180,9 +179,15 @@ protected boolean commentParse() {
int lastStarPosition = -1;
// Init scanner position
+ this.markdown = this.source[this.javadocStart + 1] == '/';
this.linePtr = getLineNumber(this.firstTagPosition);
- int realStart = this.linePtr==1 ? this.javadocStart : this.scanner.getLineEnd(this.linePtr-1)+1;
- if (realStart < this.javadocStart) realStart = this.javadocStart;
+ int realStart = this.javadocStart;
+ if (!this.markdown) {
+ realStart = this.linePtr==1 ? this.javadocStart : this.scanner.getLineEnd(this.linePtr-1)+1;
+ if (realStart < this.javadocStart) realStart = this.javadocStart;
+ } else {
+ this.linePtr = getLineNumber(realStart);
+ }
this.scanner.resetTo(realStart, this.javadocEnd);
this.index = realStart;
if (realStart == this.javadocStart) {
@@ -191,7 +196,6 @@ protected boolean commentParse() {
}
int previousPosition = this.index;
char nextCharacter = 0;
- this.markdown = this.source[this.javadocStart + 1] == '/';
this.markdownHelper = IMarkdownCommentHelper.create(this);
if (realStart == this.javadocStart) {
nextCharacter = readChar(); // second '*' or '/'
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/IMarkdownCommentHelper.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/IMarkdownCommentHelper.java
index 5ee6b613b0..279c7cd9c8 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/IMarkdownCommentHelper.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/IMarkdownCommentHelper.java
@@ -138,8 +138,9 @@ public void recordFenceChar(char previous, char next, boolean lineStarted) {
int required = this.insideFencedCodeBlock ? this.fenceLength : 3;
if (++this.fenceCharCount == required) {
this.insideFencedCodeBlock^=true;
- this.fenceLength = this.fenceCharCount;
}
+ if (this.insideFencedCodeBlock && this.fenceCharCount >= this.fenceLength)
+ this.fenceLength = this.fenceCharCount;
}
@Override
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java
index 454507f805..ec096bc468 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java
@@ -16,27 +16,9 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.compiler.InvalidInputException;
-import org.eclipse.jdt.internal.compiler.ast.ASTNode;
-import org.eclipse.jdt.internal.compiler.ast.Expression;
-import org.eclipse.jdt.internal.compiler.ast.IJavadocTypeReference;
-import org.eclipse.jdt.internal.compiler.ast.Javadoc;
-import org.eclipse.jdt.internal.compiler.ast.JavadocAllocationExpression;
-import org.eclipse.jdt.internal.compiler.ast.JavadocArgumentExpression;
-import org.eclipse.jdt.internal.compiler.ast.JavadocArrayQualifiedTypeReference;
-import org.eclipse.jdt.internal.compiler.ast.JavadocArraySingleTypeReference;
-import org.eclipse.jdt.internal.compiler.ast.JavadocFieldReference;
-import org.eclipse.jdt.internal.compiler.ast.JavadocImplicitTypeReference;
-import org.eclipse.jdt.internal.compiler.ast.JavadocMessageSend;
-import org.eclipse.jdt.internal.compiler.ast.JavadocModuleReference;
-import org.eclipse.jdt.internal.compiler.ast.JavadocQualifiedTypeReference;
-import org.eclipse.jdt.internal.compiler.ast.JavadocReturnStatement;
-import org.eclipse.jdt.internal.compiler.ast.JavadocSingleNameReference;
-import org.eclipse.jdt.internal.compiler.ast.JavadocSingleTypeReference;
-import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.TypeReference;
+import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.util.Util;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java
index 2218d63ac6..2a81d0a194 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java
@@ -245,8 +245,8 @@ public static char[][][] levelTagsToChar3d(LevelTags[] input) {
public static final char[][][] IN_SNIPPET_TAGS = {
- // since 18
- { TAG_HIGHLIGHT, TAG_REPLACE, TAG_LINK }
+ //since 18
+ { TAG_HIGHLIGHT, TAG_REPLACE, TAG_LINK }
};
public final static int IN_SNIPPET_TAGS_LENGTH = IN_SNIPPET_TAGS.length;
public final static int INLINE_TAGS_LENGTH = INLINE_TAGS.length;
@@ -261,40 +261,40 @@ public static char[][][] levelTagsToChar3d(LevelTags[] input) {
public final static short TAG_TYPE_IN_SNIPPET = 4;
public final static short TAG_TYPE_INLINE_BLOCK = (short) (TAG_TYPE_INLINE | TAG_TYPE_BLOCK);
public static final short[] JAVADOC_TAG_TYPE = {
- TAG_TYPE_NONE, // NO_TAG_VALUE = 0;
- TAG_TYPE_BLOCK, // TAG_DEPRECATED_VALUE = 1;
- TAG_TYPE_BLOCK, // TAG_PARAM_VALUE = 2;
- TAG_TYPE_BLOCK, // TAG_RETURN_VALUE = 3;
- TAG_TYPE_BLOCK, // TAG_THROWS_VALUE = 4;
- TAG_TYPE_BLOCK, // TAG_EXCEPTION_VALUE = 5;
- TAG_TYPE_BLOCK, // TAG_SEE_VALUE = 6;
- TAG_TYPE_INLINE, // TAG_LINK_VALUE = 7;
- TAG_TYPE_INLINE, // TAG_LINKPLAIN_VALUE = 8;
- TAG_TYPE_INLINE, // TAG_INHERITDOC_VALUE = 9;
- TAG_TYPE_INLINE, // TAG_VALUE_VALUE = 10;
- TAG_TYPE_BLOCK, // TAG_CATEGORY_VALUE = 11;
- TAG_TYPE_BLOCK, // TAG_AUTHOR_VALUE = 12;
- TAG_TYPE_BLOCK, // TAG_SERIAL_VALUE = 13;
- TAG_TYPE_BLOCK, // TAG_SERIAL_DATA_VALUE = 14;
- TAG_TYPE_BLOCK, // TAG_SERIAL_FIELD_VALUE = 15;
- TAG_TYPE_BLOCK, // TAG_SINCE_VALUE = 16;
- TAG_TYPE_BLOCK, // TAG_VERSION_VALUE = 17;
- TAG_TYPE_INLINE, // TAG_CODE_VALUE = 18;
- TAG_TYPE_INLINE, // TAG_LITERAL_VALUE = 19;
- TAG_TYPE_INLINE, // TAG_DOC_ROOT_VALUE = 20;
- TAG_TYPE_INLINE, // TAG_DOC_SYSTEM_PROPERTY = 21
- TAG_TYPE_BLOCK, // TAG_USES_VALUE = 22;
- TAG_TYPE_BLOCK, // TAG_PROVIDES_VALUE = 23;
- TAG_TYPE_BLOCK, // TAG_HIDDEN_VALUE = 24;
- TAG_TYPE_INLINE, // TAG_INDEX_VALUE = 25;
- TAG_TYPE_INLINE, // TAG_SUMMARY_VALUE = 26;
- TAG_TYPE_BLOCK, // TAG_API_NOTE = 27;
- TAG_TYPE_BLOCK, // TAG_IMPL_SPEC = 28;
- TAG_TYPE_BLOCK, // TAG_IMPL_NOTE = 29;
- TAG_TYPE_INLINE, // TAG_SNIPPET_VALUE = 30;
- TAG_TYPE_IN_SNIPPET,// TAG_HIGHLIGHT_VALUE = 31;
- TAG_TYPE_IN_SNIPPET,// TAG_HIGHLIGHT_VALUE = 32;
- };
+ TAG_TYPE_NONE, // NO_TAG_VALUE = 0;
+ TAG_TYPE_BLOCK, // TAG_DEPRECATED_VALUE = 1;
+ TAG_TYPE_BLOCK, // TAG_PARAM_VALUE = 2;
+ TAG_TYPE_BLOCK, // TAG_RETURN_VALUE = 3;
+ TAG_TYPE_BLOCK, // TAG_THROWS_VALUE = 4;
+ TAG_TYPE_BLOCK, // TAG_EXCEPTION_VALUE = 5;
+ TAG_TYPE_BLOCK, // TAG_SEE_VALUE = 6;
+ TAG_TYPE_INLINE, // TAG_LINK_VALUE = 7;
+ TAG_TYPE_INLINE, // TAG_LINKPLAIN_VALUE = 8;
+ TAG_TYPE_INLINE, // TAG_INHERITDOC_VALUE = 9;
+ TAG_TYPE_INLINE, // TAG_VALUE_VALUE = 10;
+ TAG_TYPE_BLOCK, // TAG_CATEGORY_VALUE = 11;
+ TAG_TYPE_BLOCK, // TAG_AUTHOR_VALUE = 12;
+ TAG_TYPE_BLOCK, // TAG_SERIAL_VALUE = 13;
+ TAG_TYPE_BLOCK, // TAG_SERIAL_DATA_VALUE = 14;
+ TAG_TYPE_BLOCK, // TAG_SERIAL_FIELD_VALUE = 15;
+ TAG_TYPE_BLOCK, // TAG_SINCE_VALUE = 16;
+ TAG_TYPE_BLOCK, // TAG_VERSION_VALUE = 17;
+ TAG_TYPE_INLINE, // TAG_CODE_VALUE = 18;
+ TAG_TYPE_INLINE, // TAG_LITERAL_VALUE = 19;
+ TAG_TYPE_INLINE, // TAG_DOC_ROOT_VALUE = 20;
+ TAG_TYPE_INLINE, // TAG_DOC_SYSTEM_PROPERTY = 21
+ TAG_TYPE_BLOCK, // TAG_USES_VALUE = 22;
+ TAG_TYPE_BLOCK, // TAG_PROVIDES_VALUE = 23;
+ TAG_TYPE_BLOCK, // TAG_HIDDEN_VALUE = 24;
+ TAG_TYPE_INLINE, // TAG_INDEX_VALUE = 25;
+ TAG_TYPE_INLINE, // TAG_SUMMARY_VALUE = 26;
+ TAG_TYPE_BLOCK, // TAG_API_NOTE = 27;
+ TAG_TYPE_BLOCK, // TAG_IMPL_SPEC = 28;
+ TAG_TYPE_BLOCK, // TAG_IMPL_NOTE = 29;
+ TAG_TYPE_INLINE, // TAG_SNIPPET_VALUE = 30;
+ TAG_TYPE_IN_SNIPPET,// TAG_HIGHLIGHT_VALUE = 31;
+ TAG_TYPE_IN_SNIPPET,// TAG_HIGHLIGHT_VALUE = 32;
+ };
// Same as above with a single difference for TAG_RETURN_VALUE
// which can now be both TAG_TYPE_BLOCK and TAG_TYPE_INLINE => TAG_TYPE_INLINE_BLOCK
// Should this become complex, meaning multiple JLS levels requiring different support,
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Parser.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Parser.java
index 3414de2b25..8c86bd290c 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Parser.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Parser.java
@@ -38,21 +38,11 @@
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.Stack;
+import java.lang.Runtime.Version;
+import java.util.*;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.stream.Stream;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.compiler.InvalidInputException;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
@@ -944,7 +934,7 @@ protected int actFromTokenOrSynthetic(int previousAct) {
private boolean tolerateDefaultClassMethods = false;
private boolean processingLambdaParameterList = false;
private boolean expectTypeAnnotation = false;
-private boolean reparsingLambdaExpression = false;
+private boolean reparsingFunctionalExpression = false;
private Map recordNestedMethodLevels;
private Map recordPatternSwitches;
@@ -1177,7 +1167,7 @@ protected void checkAndSetModifiers(int flag){
problemReporter().StrictfpNotRequired(this.scanner.startPosition, this.scanner.currentPosition - 1);
}
- if ((this.modifiers & flag) != 0){ // duplicate modifier
+ if ((this.modifiers & flag) != 0) { // duplicate modifier
this.modifiers |= ExtraCompilerModifiers.AccAlternateModifierProblem;
}
this.modifiers |= flag;
@@ -1187,10 +1177,6 @@ protected void checkAndSetModifiers(int flag){
if (this.currentElement != null) {
this.currentElement.addModifier(flag, this.modifiersSourceStart);
}
- if (flag == ExtraCompilerModifiers.AccSealed || flag == ExtraCompilerModifiers.AccNonSealed) {
- problemReporter().validateJavaFeatureSupport(JavaFeature.SEALED_CLASSES, this.scanner.startPosition,
- this.scanner.currentPosition - 1);
- }
}
public void checkComment() {
@@ -6683,6 +6669,18 @@ protected void consumeZeroTypeAnnotations() {
// Name ::= SimpleName
// TypeAnnotationsopt ::= $empty
pushOnTypeAnnotationLengthStack(0); // signal absence of @308 annotations.
+ if (this.currentElement instanceof RecoveredAnnotation ann) {
+ if (ann.parent instanceof RecoveredMethod meth
+ && !meth.foundOpeningBrace
+ && this.currentToken == TokenNameRPAREN) {
+ // take note of an incomplete annotation "@Ann(v=)":
+ meth.incompleteParameterAnnotationSeen = true;
+ }
+ if (this.identifierPtr > ann.identifierPtr) {
+ ann.hasPendingMemberValueName = true;
+ ann.errorToken = this.currentToken;
+ }
+ }
}
// BEGIN_AUTOGENERATED_REGION_CONSUME_RULE
// This method is part of an automatic generation : do NOT edit-modify
@@ -9418,7 +9416,7 @@ private void consumeTextBlock() {
private TextBlock createTextBlock(char[] allchars, int start, int end) {
TextBlock textBlock;
if (this.recordStringLiterals &&
- !this.reparsingLambdaExpression &&
+ !this.reparsingFunctionalExpression &&
this.checkExternalizeStrings &&
this.lastPosistion < this.scanner.currentPosition &&
!this.statementRecoveryActivated) {
@@ -9473,7 +9471,7 @@ protected void consumeCaseLabelExpr() {
if (!this.parsingJava14Plus) {
problemReporter().arrowInCaseStatementsNotSupported(caseStatement);
}
- caseStatement.isExpr = true;
+ caseStatement.isSwitchRule = true;
}
protected void consumeDefaultLabelExpr() {
// SwitchLabelDefaultExpr ::= 'default' '->'
@@ -9482,88 +9480,7 @@ protected void consumeDefaultLabelExpr() {
if (!this.parsingJava14Plus) {
problemReporter().arrowInCaseStatementsNotSupported(defaultStatement);
}
- defaultStatement.isExpr = true;
-}
-protected void collectResultExpressionsYield(SwitchExpression s) {
- if (s.resultExpressions != null)
- return; // already calculated.
-
- class ResultExpressionsCollector extends ASTVisitor {
- Stack targetSwitchExpressions;
- Stack tryStatements;
- public ResultExpressionsCollector(SwitchExpression se) {
- if (this.targetSwitchExpressions == null)
- this.targetSwitchExpressions = new Stack<>();
- this.targetSwitchExpressions.push(se);
- }
- @Override
- public boolean visit(SwitchExpression switchExpression, BlockScope blockScope) {
- if (switchExpression.resultExpressions == null)
- switchExpression.resultExpressions = new ArrayList<>(0);
- this.targetSwitchExpressions.push(switchExpression);
- return false;
- }
- @Override
- public void endVisit(SwitchExpression switchExpression, BlockScope blockScope) {
- this.targetSwitchExpressions.pop();
- }
- @Override
- public boolean visit(YieldStatement yieldStatement, BlockScope blockScope) {
- SwitchExpression targetSwitchExpression = this.targetSwitchExpressions.peek();
- if (yieldStatement.expression != null) {
- targetSwitchExpression.resultExpressions.add(yieldStatement.expression);
- yieldStatement.switchExpression = this.targetSwitchExpressions.peek();
- } else {
- // flag an error while resolving
- yieldStatement.switchExpression = targetSwitchExpression;
- }
- return true;
- }
- @Override
- public boolean visit(SwitchStatement stmt, BlockScope blockScope) {
- return true;
- }
- @Override
- public boolean visit(TypeDeclaration stmt, BlockScope blockScope) {
- return false;
- }
- @Override
- public boolean visit(LambdaExpression stmt, BlockScope blockScope) {
- return false;
- }
- @Override
- public boolean visit(TryStatement stmt, BlockScope blockScope) {
- if (this.tryStatements == null)
- this.tryStatements = new Stack<>();
- this.tryStatements.push(stmt);
- SwitchExpression targetSwitchExpression = this.targetSwitchExpressions.peek();
- targetSwitchExpression.containsTry = true;
- return true;
- }
- @Override
- public void endVisit(TryStatement stmt, BlockScope blockScope) {
- this.tryStatements.pop();
- }
- }
- s.resultExpressions = new ArrayList<>(0); // indicates processed
- int l = s.statements == null ? 0 : s.statements.length;
- for (int i = 0; i < l; ++i) {
- Statement stmt = s.statements[i];
- if (stmt instanceof CaseStatement caseStatement) {
- if (!caseStatement.isExpr) continue;
- stmt = s.statements[++i];
- if (stmt instanceof Expression expression && expression.isTrulyExpression()) {
- s.resultExpressions.add(expression);
- continue;
- } else if (stmt instanceof ThrowStatement) {
- // TODO: Throw Expression Processing. Anything to be done here for resolve?
- continue;
- }
- }
- // break statement and block statement of SwitchLabelRule or block statement of ':'
- ResultExpressionsCollector reCollector = new ResultExpressionsCollector(s);
- stmt.traverse(reCollector, null);
- }
+ defaultStatement.isSwitchRule = true;
}
protected void consumeSwitchExpression() {
// SwitchExpression ::= 'switch' '(' Expression ')' OpenBlock SwitchExpressionBlock
@@ -9574,7 +9491,6 @@ protected void consumeSwitchExpression() {
if (!this.parsingJava14Plus) {
problemReporter().switchExpressionsNotSupported(s);
}
- collectResultExpressionsYield(s);
pushOnExpressionStack(s);
}
}
@@ -9885,7 +9801,7 @@ protected void consumeToken(int type) {
case TokenNameStringLiteral :
StringLiteral stringLiteral;
if (this.recordStringLiterals &&
- !this.reparsingLambdaExpression &&
+ !this.reparsingFunctionalExpression &&
this.checkExternalizeStrings &&
this.lastPosistion < this.scanner.currentPosition &&
!this.statementRecoveryActivated) {
@@ -9951,7 +9867,6 @@ protected void consumeToken(int type) {
pushOnIntStack(this.scanner.startPosition);
break;
case TokenNameRestrictedIdentifierpermits:
- problemReporter().validateJavaFeatureSupport(JavaFeature.SEALED_CLASSES, this.scanner.startPosition,this.scanner.currentPosition - 1);
pushOnIntStack(this.scanner.startPosition);
break;
case TokenNamecase :
@@ -11616,7 +11531,7 @@ public void getMethodBodies(CompilationUnitDeclaration unit) {
CompilationResult compilationResult = unit.compilationResult;
char[] contents = this.readManager != null
? this.readManager.getContents(compilationResult.compilationUnit)
- : compilationResult.compilationUnit.getContents();
+ : compilationResult.getContents();
this.scanner.setSource(contents, compilationResult);
if (this.javadocParser != null && this.javadocParser.checkDocComment) {
@@ -12848,6 +12763,21 @@ public CompilationUnitDeclaration parse(
compilationResult,
0);
+ var problemReporterContext = this.problemReporter.referenceContext;
+ this.problemReporter.referenceContext = this.referenceContext;
+ if (this.problemReporter != null && this.options != null && this.options.requestedSourceVersion != null && !this.options.requestedSourceVersion.isBlank()) {
+ try {
+ var requestedVersion = Version.parse(this.options.requestedSourceVersion);
+ var latestVersion = Version.parse(CompilerOptions.getLatestVersion());
+ if (requestedVersion.compareTo(latestVersion) > 0) {
+ this.problemReporter.tooRecentJavaVersion(requestedVersion.toString(), latestVersion.toString());
+ }
+ } catch (Exception ex) {
+ this.problemReporter.abortDueToInternalError(ex.getMessage());
+ }
+ }
+ this.problemReporter.referenceContext = problemReporterContext;
+
/* scanners initialization */
char[] contents;
try {
@@ -12856,6 +12786,7 @@ public CompilationUnitDeclaration parse(
problemReporter().cannotReadSource(this.compilationUnit, abortException, this.options.verbose);
contents = CharOperation.NO_CHAR; // pretend empty from thereon
}
+ compilationResult.cacheContents(contents);
this.scanner.setSource(contents);
this.compilationUnit.sourceEnd = this.scanner.source.length - 1;
if (end != -1) this.scanner.resetTo(start, end);
@@ -13148,7 +13079,7 @@ public boolean visit(TypeDeclaration memberTypeDeclaration, ClassScope scope) {
public Expression parseLambdaExpression(char[] source, int offset, int length, CompilationUnitDeclaration unit, boolean recordLineSeparators) {
this.haltOnSyntaxError = true; // unexposed/unshared object, no threading concerns.
- this.reparsingLambdaExpression = true;
+ this.reparsingFunctionalExpression = true;
return parseExpression(source, offset, length, unit, recordLineSeparators);
}
@@ -13175,6 +13106,10 @@ public char[][] parsePackageDeclaration(char[] source, CompilationResult result)
return this.compilationUnit.currentPackage == null ? null : this.compilationUnit.currentPackage.getImportName();
}
+public Expression parseReferenceExpression(char[] source, int offset, int length, CompilationUnitDeclaration unit, boolean recordLineSeparators) {
+ this.reparsingFunctionalExpression = true;
+ return parseExpression(source, offset, length, unit, recordLineSeparators);
+}
public Expression parseExpression(char[] source, int offset, int length, CompilationUnitDeclaration unit, boolean recordLineSeparators) {
initialize();
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredAnnotation.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredAnnotation.java
index adcc3d7554..2de80c2dc2 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredAnnotation.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredAnnotation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others.
+ * Copyright (c) 2008, 2024 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,16 +13,7 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.parser;
-import org.eclipse.jdt.internal.compiler.ast.ASTNode;
-import org.eclipse.jdt.internal.compiler.ast.Annotation;
-import org.eclipse.jdt.internal.compiler.ast.Expression;
-import org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation;
-import org.eclipse.jdt.internal.compiler.ast.MemberValuePair;
-import org.eclipse.jdt.internal.compiler.ast.NormalAnnotation;
-import org.eclipse.jdt.internal.compiler.ast.SingleMemberAnnotation;
-import org.eclipse.jdt.internal.compiler.ast.SingleNameReference;
-import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.TypeReference;
+import org.eclipse.jdt.internal.compiler.ast.*;
public class RecoveredAnnotation extends RecoveredElement {
public static final int MARKER = 0;
@@ -30,12 +21,13 @@ public class RecoveredAnnotation extends RecoveredElement {
public static final int SINGLE_MEMBER = 2;
private int kind;
- private final int identifierPtr;
+ final int identifierPtr;
private final int identifierLengthPtr;
private final int sourceStart;
public boolean hasPendingMemberValueName;
public int memberValuPairEqualEnd = -1;
public Annotation annotation;
+ public int errorToken;
public RecoveredAnnotation(int identifierPtr, int identifierLengthPtr, int sourceStart, RecoveredElement parent, int bracketBalance) {
super(parent, bracketBalance);
@@ -79,16 +71,24 @@ public void updateFromParserState() {
boolean needUpdateRParenPos = false;
MemberValuePair pendingMemberValueName = null;
+ Expression singleValue = null;
if (this.hasPendingMemberValueName && this.identifierPtr < parser.identifierPtr) {
char[] memberValueName = parser.identifierStack[this.identifierPtr + 1];
long pos = parser.identifierPositionStack[this.identifierPtr + 1];
int start = (int) (pos >>> 32);
int end = (int)pos;
- int valueEnd = this.memberValuPairEqualEnd > -1 ? this.memberValuPairEqualEnd : end;
- SingleNameReference fakeExpression = new SingleNameReference(RecoveryScanner.FAKE_IDENTIFIER, (((long) valueEnd + 1) << 32) + (valueEnd));
- pendingMemberValueName = new MemberValuePair(memberValueName, start, end, fakeExpression);
+ if (this.errorToken == TerminalTokens.TokenNameDOT) {
+ // do we need to consult identifierLengthStack to pull more than one name segment?
+ char[][] qname = new char[][] { memberValueName, RecoveryScanner.FAKE_IDENTIFIER };
+ singleValue = new QualifiedNameReference(qname, new long[] {pos,pos}, start, end);
+ this.kind = SINGLE_MEMBER;
+ } else {
+ int valueEnd = this.memberValuPairEqualEnd > -1 ? this.memberValuPairEqualEnd : end;
+ SingleNameReference fakeExpression = new SingleNameReference(RecoveryScanner.FAKE_IDENTIFIER, (((long) valueEnd + 1) << 32) + (valueEnd));
+ pendingMemberValueName = new MemberValuePair(memberValueName, start, end, fakeExpression);
+ }
}
parser.identifierPtr = this.identifierPtr;
parser.identifierLengthPtr = this.identifierLengthPtr;
@@ -145,9 +145,10 @@ public void updateFromParserState() {
break;
case SINGLE_MEMBER:
- if (parser.expressionPtr > -1) {
- Expression memberValue = parser.expressionStack[parser.expressionPtr--];
-
+ Expression memberValue = singleValue != null ? singleValue
+ : parser.expressionPtr > -1 ? parser.expressionStack[parser.expressionPtr--]
+ : null;
+ if (memberValue != null) {
SingleMemberAnnotation singleMemberAnnotation = new SingleMemberAnnotation(typeReference, this.sourceStart);
singleMemberAnnotation.memberValue = memberValue;
singleMemberAnnotation.declarationSourceEnd = memberValue.sourceEnd;
@@ -200,6 +201,10 @@ public void setKind(int kind) {
this.kind = kind;
}
+ public int sourceStart() {
+ return this.sourceStart;
+ }
+
@Override
public int sourceEnd() {
if (this.annotation == null) {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredBlock.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredBlock.java
index aeca66c39b..0955d01a65 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredBlock.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredBlock.java
@@ -14,11 +14,10 @@
import java.util.HashSet;
import java.util.Set;
-
-import org.eclipse.jdt.core.compiler.*;
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Argument;
-import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.Block;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
import org.eclipse.jdt.internal.compiler.ast.ForeachStatement;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredElement.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredElement.java
index 16b46aceb6..17af048265 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredElement.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredElement.java
@@ -17,16 +17,7 @@
/**
* Internal structure for parsing recovery
*/
-import org.eclipse.jdt.internal.compiler.ast.ASTNode;
-import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.Block;
-import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.ImportReference;
-import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.ModuleDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.ModuleStatement;
-import org.eclipse.jdt.internal.compiler.ast.Statement;
-import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.util.Util;
public class RecoveredElement {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredField.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredField.java
index 6af3c43bc6..2da6deefc8 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredField.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredField.java
@@ -18,19 +18,7 @@
*/
import java.util.HashSet;
import java.util.Set;
-
-import org.eclipse.jdt.internal.compiler.ast.ASTNode;
-import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.AllocationExpression;
-import org.eclipse.jdt.internal.compiler.ast.Annotation;
-import org.eclipse.jdt.internal.compiler.ast.ArrayInitializer;
-import org.eclipse.jdt.internal.compiler.ast.ArrayQualifiedTypeReference;
-import org.eclipse.jdt.internal.compiler.ast.ArrayTypeReference;
-import org.eclipse.jdt.internal.compiler.ast.Expression;
-import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.Statement;
-import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.*;
public class RecoveredField extends RecoveredElement {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredInitializer.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredInitializer.java
index 597170efee..2eac69ebd0 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredInitializer.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredInitializer.java
@@ -14,8 +14,7 @@
package org.eclipse.jdt.internal.compiler.parser;
import java.util.Set;
-
-import org.eclipse.jdt.core.compiler.*;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.Block;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredLocalVariable.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredLocalVariable.java
index 3a2a178f90..af5c82bc1c 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredLocalVariable.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredLocalVariable.java
@@ -18,11 +18,10 @@
*/
import java.util.HashSet;
import java.util.Set;
-
+import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.Annotation;
import org.eclipse.jdt.internal.compiler.ast.ArrayQualifiedTypeReference;
import org.eclipse.jdt.internal.compiler.ast.ArrayTypeReference;
-import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.Expression;
import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Statement;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredMethod.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredMethod.java
index af2ff69e7e..9e5dea4a78 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredMethod.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredMethod.java
@@ -15,26 +15,11 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.parser;
+import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
-
-import org.eclipse.jdt.core.compiler.*;
-import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.Annotation;
-import org.eclipse.jdt.internal.compiler.ast.Argument;
-import org.eclipse.jdt.internal.compiler.ast.ASTNode;
-import org.eclipse.jdt.internal.compiler.ast.Block;
-import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall;
-import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.MemberValuePair;
-import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.Statement;
-import org.eclipse.jdt.internal.compiler.ast.SuperReference;
-import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.TypeParameter;
-import org.eclipse.jdt.internal.compiler.ast.TypeReference;
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
import org.eclipse.jdt.internal.compiler.util.Util;
@@ -64,6 +49,8 @@ public class RecoveredMethod extends RecoveredElement implements TerminalTokens
RecoveredAnnotation[] pendingAnnotations;
int pendingAnnotationCount;
+ public boolean incompleteParameterAnnotationSeen = false;
+
public RecoveredMethod(AbstractMethodDeclaration methodDeclaration, RecoveredElement parent, int bracketBalance, Parser parser){
super(parent, bracketBalance, parser);
this.methodDeclaration = methodDeclaration;
@@ -113,6 +100,10 @@ public RecoveredElement add(Block nestedBlockDeclaration, int bracketBalanceValu
*/
@Override
public RecoveredElement add(FieldDeclaration fieldDeclaration, int bracketBalanceValue) {
+ if (recoverAsArgument(fieldDeclaration)) {
+ resetPendingModifiers();
+ return this;
+ }
resetPendingModifiers();
/* local variables inside method can only be final and non void */
@@ -149,6 +140,37 @@ public RecoveredElement add(FieldDeclaration fieldDeclaration, int bracketBalanc
// still inside method, treat as local variable
return this; // ignore
}
+
+private boolean recoverAsArgument(FieldDeclaration fieldDeclaration) {
+ if (!this.foundOpeningBrace
+ && this.methodDeclaration.declarationSourceEnd == 0
+ && this.incompleteParameterAnnotationSeen) { // misparsed parameter?
+ long position = ((long) fieldDeclaration.sourceStart << 32)+fieldDeclaration.sourceEnd;
+ Argument arg = new Argument(fieldDeclaration.name, position, fieldDeclaration.type, fieldDeclaration.modifiers);
+ if (this.methodDeclaration.arguments == null) {
+ this.methodDeclaration.arguments = new Argument[] { arg };
+ } else {
+ int len = this.methodDeclaration.arguments.length;
+ this.methodDeclaration.arguments = Arrays.copyOf(this.methodDeclaration.arguments, len+1);
+ this.methodDeclaration.arguments[len] = arg;
+ }
+ int annotCount = this.pendingAnnotationCount;
+ if (this.pendingAnnotations != null) {
+ int end = 0;
+ arg.annotations = new Annotation[annotCount];
+ for (int i = 0; i < this.pendingAnnotationCount; i++) {
+ arg.annotations[i] = this.pendingAnnotations[i].annotation;
+ if (i == 0)
+ arg.declarationSourceStart = arg.annotations[i].sourceStart;
+ end = arg.sourceEnd;
+ }
+ if (end > 0)
+ this.methodDeclaration.bodyStart = end + 1;
+ }
+ return true;
+ }
+ return false;
+}
/*
* Record a local declaration - regular method should have been created a block body
*/
@@ -622,6 +644,11 @@ public RecoveredElement addAnnotationName(int identifierPtr, int identifierLengt
this.pendingAnnotations = new RecoveredAnnotation[5];
this.pendingAnnotationCount = 0;
} else {
+ if (this.pendingAnnotationCount > 0) {
+ RecoveredAnnotation lastAnnot = this.pendingAnnotations[this.pendingAnnotationCount-1];
+ if (lastAnnot.sourceStart() == annotationStart)
+ return this;
+ }
if (this.pendingAnnotationCount == this.pendingAnnotations.length) {
System.arraycopy(
this.pendingAnnotations,
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredStatement.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredStatement.java
index 903e47b371..44b0c0ed6f 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredStatement.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredStatement.java
@@ -18,7 +18,6 @@
*/
import java.util.HashSet;
import java.util.Set;
-
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.Block;
import org.eclipse.jdt.internal.compiler.ast.ForeachStatement;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredType.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredType.java
index 47eaa52204..e0fb2107f7 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredType.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredType.java
@@ -18,19 +18,7 @@
import java.util.HashSet;
import java.util.Set;
-
-import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.ASTNode;
-import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.Annotation;
-import org.eclipse.jdt.internal.compiler.ast.Block;
-import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.Initializer;
-import org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression;
-import org.eclipse.jdt.internal.compiler.ast.Statement;
-import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.TypeParameter;
-import org.eclipse.jdt.internal.compiler.ast.TypeReference;
+import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
/**
@@ -340,23 +328,26 @@ public int bodyEnd(){
if (this.bodyEnd == 0) return this.typeDeclaration.declarationSourceEnd;
return this.bodyEnd;
}
-public boolean bodyStartsAtHeaderEnd(){
- if (this.typeDeclaration.superInterfaces == null){
- if (this.typeDeclaration.superclass == null){
- if(this.typeDeclaration.typeParameters == null) {
- return this.typeDeclaration.bodyStart == this.typeDeclaration.sourceEnd+1;
+
+public boolean bodyStartsAtHeaderEnd() {
+ if (this.typeDeclaration.permittedTypes == null) {
+ if (this.typeDeclaration.superInterfaces == null) {
+ if (this.typeDeclaration.superclass == null) {
+ if (this.typeDeclaration.typeParameters == null) {
+ return this.typeDeclaration.bodyStart == this.typeDeclaration.sourceEnd + 1;
+ } else {
+ return this.typeDeclaration.bodyStart == this.typeDeclaration.typeParameters[this.typeDeclaration.typeParameters.length - 1].sourceEnd + 1;
+ }
} else {
- return this.typeDeclaration.bodyStart == this.typeDeclaration.typeParameters[this.typeDeclaration.typeParameters.length-1].sourceEnd+1;
+ return this.typeDeclaration.bodyStart == this.typeDeclaration.superclass.sourceEnd + 1;
}
} else {
- return this.typeDeclaration.bodyStart == this.typeDeclaration.superclass.sourceEnd+1;
+ return this.typeDeclaration.bodyStart
+ == this.typeDeclaration.superInterfaces[this.typeDeclaration.superInterfaces.length - 1].sourceEnd + 1;
}
} else {
- if (this.typeDeclaration.permittedTypes != null)
- return this.typeDeclaration.bodyStart
- == this.typeDeclaration.permittedTypes[this.typeDeclaration.permittedTypes.length-1].sourceEnd+1;
return this.typeDeclaration.bodyStart
- == this.typeDeclaration.superInterfaces[this.typeDeclaration.superInterfaces.length-1].sourceEnd+1;
+ == this.typeDeclaration.permittedTypes[this.typeDeclaration.permittedTypes.length - 1].sourceEnd + 1;
}
}
/*
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredUnit.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredUnit.java
index 5cd686a5a7..8d4bcb29ee 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredUnit.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredUnit.java
@@ -18,17 +18,7 @@
*/
import java.util.HashSet;
import java.util.Set;
-
-import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.ASTNode;
-import org.eclipse.jdt.internal.compiler.ast.Block;
-import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.ExportsStatement;
-import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.ImportReference;
-import org.eclipse.jdt.internal.compiler.ast.Initializer;
-import org.eclipse.jdt.internal.compiler.ast.ModuleDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.*;
public class RecoveredUnit extends RecoveredElement {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Scanner.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Scanner.java
index 2760d441ae..8b539c17be 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Scanner.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Scanner.java
@@ -190,7 +190,7 @@ enum ScanContext {
private VanguardParser vanguardParser;
ConflictedParser activeParser = null;
private boolean consumingEllipsisAnnotations = false;
- protected boolean multiCaseLabelComma = false;
+ public boolean multiCaseLabelComma = false;
public static final int RoundBracket = 0;
public static final int SquareBracket = 1;
@@ -5615,9 +5615,6 @@ int disambiguatedRestrictedIdentifierWhen(int restrictedIdentifierToken) {
TokenNameIdentifier : TokenNameRestrictedIdentifierWhen;
}
int disambiguatedRestrictedIdentifierYield(int restrictedIdentifierToken) {
- // and here's the kludge
- if (restrictedIdentifierToken != TokenNameRestrictedIdentifierYield)
- return restrictedIdentifierToken;
if (this.sourceLevel < ClassFileConstants.JDK14)
return TokenNameIdentifier;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/ScannerHelper.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/ScannerHelper.java
index 78cc30c741..a2523a7cfa 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/ScannerHelper.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/ScannerHelper.java
@@ -17,7 +17,6 @@
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.IOException;
-
import org.eclipse.jdt.core.compiler.InvalidInputException;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/AbortCompilationUnit.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/AbortCompilationUnit.java
index ab0807ac63..313bce99de 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/AbortCompilationUnit.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/AbortCompilationUnit.java
@@ -14,7 +14,6 @@
package org.eclipse.jdt.internal.compiler.problem;
import java.io.IOException;
-
import org.eclipse.jdt.core.compiler.CategorizedProblem;
import org.eclipse.jdt.internal.compiler.CompilationResult;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/DefaultProblemFactory.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/DefaultProblemFactory.java
index e4030abbc3..6bcb8eeff9 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/DefaultProblemFactory.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/DefaultProblemFactory.java
@@ -17,8 +17,8 @@
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
-
-import org.eclipse.jdt.core.compiler.*;
+import org.eclipse.jdt.core.compiler.CategorizedProblem;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.compiler.IProblemFactory;
import org.eclipse.jdt.internal.compiler.util.HashtableOfInt;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
index 8814fb691f..e0d1d9ae8d 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
@@ -88,7 +88,6 @@
import java.util.Set;
import java.util.function.Supplier;
import java.util.stream.Collectors;
-
import org.eclipse.jdt.core.compiler.CategorizedProblem;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.compiler.IProblem;
@@ -96,76 +95,7 @@
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy;
import org.eclipse.jdt.internal.compiler.IProblemFactory;
-import org.eclipse.jdt.internal.compiler.ast.ASTNode;
-import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.AllocationExpression;
-import org.eclipse.jdt.internal.compiler.ast.Annotation;
-import org.eclipse.jdt.internal.compiler.ast.AnnotationMethodDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.Argument;
-import org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression;
-import org.eclipse.jdt.internal.compiler.ast.ArrayInitializer;
-import org.eclipse.jdt.internal.compiler.ast.ArrayQualifiedTypeReference;
-import org.eclipse.jdt.internal.compiler.ast.ArrayReference;
-import org.eclipse.jdt.internal.compiler.ast.ArrayTypeReference;
-import org.eclipse.jdt.internal.compiler.ast.Assignment;
-import org.eclipse.jdt.internal.compiler.ast.BinaryExpression;
-import org.eclipse.jdt.internal.compiler.ast.Block;
-import org.eclipse.jdt.internal.compiler.ast.BranchStatement;
-import org.eclipse.jdt.internal.compiler.ast.CaseStatement;
-import org.eclipse.jdt.internal.compiler.ast.CastExpression;
-import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess;
-import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.CompoundAssignment;
-import org.eclipse.jdt.internal.compiler.ast.ConditionalExpression;
-import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.EqualExpression;
-import org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall;
-import org.eclipse.jdt.internal.compiler.ast.Expression;
-import org.eclipse.jdt.internal.compiler.ast.ExpressionContext;
-import org.eclipse.jdt.internal.compiler.ast.FakedTrackingVariable;
-import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.FieldReference;
-import org.eclipse.jdt.internal.compiler.ast.FunctionalExpression;
-import org.eclipse.jdt.internal.compiler.ast.ImportReference;
-import org.eclipse.jdt.internal.compiler.ast.Initializer;
-import org.eclipse.jdt.internal.compiler.ast.InstanceOfExpression;
-import org.eclipse.jdt.internal.compiler.ast.LabeledStatement;
-import org.eclipse.jdt.internal.compiler.ast.LambdaExpression;
-import org.eclipse.jdt.internal.compiler.ast.Literal;
-import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.MemberValuePair;
-import org.eclipse.jdt.internal.compiler.ast.MessageSend;
-import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.ModuleDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.ModuleReference;
-import org.eclipse.jdt.internal.compiler.ast.NameReference;
-import org.eclipse.jdt.internal.compiler.ast.NullAnnotationMatching;
-import org.eclipse.jdt.internal.compiler.ast.NullLiteral;
-import org.eclipse.jdt.internal.compiler.ast.OpensStatement;
-import org.eclipse.jdt.internal.compiler.ast.PackageVisibilityStatement;
-import org.eclipse.jdt.internal.compiler.ast.ParameterizedQualifiedTypeReference;
-import org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference;
-import org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression;
-import org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference;
-import org.eclipse.jdt.internal.compiler.ast.QualifiedSuperReference;
-import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference;
-import org.eclipse.jdt.internal.compiler.ast.Receiver;
-import org.eclipse.jdt.internal.compiler.ast.RecordComponent;
-import org.eclipse.jdt.internal.compiler.ast.RecordPattern;
-import org.eclipse.jdt.internal.compiler.ast.Reference;
-import org.eclipse.jdt.internal.compiler.ast.ReferenceExpression;
-import org.eclipse.jdt.internal.compiler.ast.ReturnStatement;
-import org.eclipse.jdt.internal.compiler.ast.SingleNameReference;
-import org.eclipse.jdt.internal.compiler.ast.Statement;
-import org.eclipse.jdt.internal.compiler.ast.SwitchExpression;
-import org.eclipse.jdt.internal.compiler.ast.SwitchStatement;
-import org.eclipse.jdt.internal.compiler.ast.ThisReference;
-import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.TypeParameter;
-import org.eclipse.jdt.internal.compiler.ast.TypeReference;
-import org.eclipse.jdt.internal.compiler.ast.UnaryExpression;
-import org.eclipse.jdt.internal.compiler.ast.Wildcard;
+import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
@@ -176,40 +106,8 @@
import org.eclipse.jdt.internal.compiler.impl.JavaFeature;
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
import org.eclipse.jdt.internal.compiler.impl.StringConstant;
-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.CaptureBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
-import org.eclipse.jdt.internal.compiler.lookup.ElementValuePair;
-import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
-import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
-import org.eclipse.jdt.internal.compiler.lookup.InvocationSite;
-import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
-import org.eclipse.jdt.internal.compiler.lookup.ModuleBinding;
-import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.RecordComponentBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Scope;
-import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.SplitPackageBinding;
-import org.eclipse.jdt.internal.compiler.lookup.SyntheticArgumentBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TagBits;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
+import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants.DangerousMethod;
-import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.VariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.WildcardBinding;
import org.eclipse.jdt.internal.compiler.parser.JavadocTagConstants;
import org.eclipse.jdt.internal.compiler.parser.Parser;
import org.eclipse.jdt.internal.compiler.parser.RecoveryScanner;
@@ -304,6 +202,9 @@ public static int getIrritant(int problemID) {
case IProblem.LocalVariableIsNeverUsed :
return CompilerOptions.UnusedLocalVariable;
+ case IProblem.LambdaParameterIsNeverUsed :
+ return CompilerOptions.UnusedLambdaParameter;
+
case IProblem.ArgumentIsNeverUsed :
return CompilerOptions.UnusedArgument;
@@ -808,6 +709,7 @@ public static int getProblemCategory(int severity, int problemID) {
return CategorizedProblem.CAT_NAME_SHADOWING_CONFLICT;
case CompilerOptions.UnusedLocalVariable :
+ case CompilerOptions.UnusedLambdaParameter :
case CompilerOptions.UnusedArgument :
case CompilerOptions.UnusedExceptionParameter :
case CompilerOptions.UnusedImport :
@@ -925,6 +827,16 @@ public void abortDueToNotSupportedJavaVersion(String notSupportedVersion, String
0,
0);
}
+public void tooRecentJavaVersion(String notSupportedVersion, String firstSupportedVersion) {
+ String[] args = new String[] {notSupportedVersion, firstSupportedVersion};
+ this.handle(
+ IProblem.JavaVersionTooRecent,
+ args,
+ args,
+ ProblemSeverities.Warning,
+ 0,
+ 0);
+}
public void abstractMethodCannotBeOverridden(SourceTypeBinding type, MethodBinding concreteMethod) {
this.handle(
@@ -1770,9 +1682,6 @@ public int computeSeverity(int problemID){
switch (problemID) {
case IProblem.VarargsConflict :
- case IProblem.SwitchExpressionsYieldUnqualifiedMethodWarning:
- case IProblem.SwitchExpressionsYieldRestrictedGeneralWarning:
- case IProblem.SwitchExpressionsYieldTypeDeclarationWarning:
case IProblem.StrictfpNotRequired:
return ProblemSeverities.Warning;
case IProblem.TypeCollidesWithPackage :
@@ -3455,7 +3364,7 @@ public void illegalVisibilityModifierCombinationForField(ReferenceBinding type,
fieldDecl.sourceStart,
fieldDecl.sourceEnd);
}
-public void IllegalModifierCombinationForType(SourceTypeBinding type) {
+public void illegalModifierCombinationForType(SourceTypeBinding type) {
String[] arguments = new String[] {new String(type.sourceName())};
this.handle(
IProblem.IllegalModifierCombinationForType,
@@ -5011,7 +4920,7 @@ else if (type instanceof ArrayBinding) {
}
}
- if (type.isParameterizedType()) {
+ if (!(type instanceof MissingTypeBinding)) {
List missingTypes = type.collectMissingTypes(null);
if (missingTypes != null) {
ReferenceContext savedContext = this.referenceContext;
@@ -5342,82 +5251,7 @@ public void isClassPathCorrect(char[][] wellKnownTypeName, CompilationUnitDeclar
private boolean isIdentifier(int token) {
return token == TerminalTokens.TokenNameIdentifier;
}
-private boolean isRestrictedIdentifier(int token) {
- switch(token) {
- case TerminalTokens.TokenNameRestrictedIdentifierYield:
- case TerminalTokens.TokenNameRestrictedIdentifierrecord:
- case TerminalTokens.TokenNameRestrictedIdentifiersealed:
- case TerminalTokens.TokenNameRestrictedIdentifierpermits:
- case TerminalTokens.TokenNameRestrictedIdentifierWhen:
- return true;
- default: return false;
- }
-}
-private boolean isKeyword(int token) {
- switch(token) {
- case TerminalTokens.TokenNameabstract:
- case TerminalTokens.TokenNameassert:
- case TerminalTokens.TokenNamebyte:
- case TerminalTokens.TokenNamebreak:
- case TerminalTokens.TokenNameboolean:
- case TerminalTokens.TokenNamecase:
- case TerminalTokens.TokenNamechar:
- case TerminalTokens.TokenNamecatch:
- case TerminalTokens.TokenNameclass:
- case TerminalTokens.TokenNamecontinue:
- case TerminalTokens.TokenNamedo:
- case TerminalTokens.TokenNamedouble:
- case TerminalTokens.TokenNamedefault:
- case TerminalTokens.TokenNameelse:
- case TerminalTokens.TokenNameextends:
- case TerminalTokens.TokenNamefor:
- case TerminalTokens.TokenNamefinal:
- case TerminalTokens.TokenNamefloat:
- case TerminalTokens.TokenNamefalse:
- case TerminalTokens.TokenNamefinally:
- case TerminalTokens.TokenNameif:
- case TerminalTokens.TokenNameint:
- case TerminalTokens.TokenNameimport:
- case TerminalTokens.TokenNameinterface:
- case TerminalTokens.TokenNameimplements:
- case TerminalTokens.TokenNameinstanceof:
- case TerminalTokens.TokenNamelong:
- case TerminalTokens.TokenNamenew:
- case TerminalTokens.TokenNamenon_sealed:
- case TerminalTokens.TokenNamenull:
- case TerminalTokens.TokenNamenative:
- case TerminalTokens.TokenNamepublic:
- case TerminalTokens.TokenNamepackage:
- case TerminalTokens.TokenNameprivate:
- case TerminalTokens.TokenNameprotected:
- case TerminalTokens.TokenNamereturn:
- case TerminalTokens.TokenNameshort:
- case TerminalTokens.TokenNamesuper:
- case TerminalTokens.TokenNamestatic:
- case TerminalTokens.TokenNameswitch:
- case TerminalTokens.TokenNamestrictfp:
- case TerminalTokens.TokenNamesynchronized:
- case TerminalTokens.TokenNametry:
- case TerminalTokens.TokenNamethis:
- case TerminalTokens.TokenNametrue:
- case TerminalTokens.TokenNamethrow:
- case TerminalTokens.TokenNamethrows:
- case TerminalTokens.TokenNametransient:
- case TerminalTokens.TokenNamevoid:
- case TerminalTokens.TokenNamevolatile:
- case TerminalTokens.TokenNamewhile:
- return true;
- case TerminalTokens.TokenNameRestrictedIdentifierYield:
- case TerminalTokens.TokenNameRestrictedIdentifierrecord:
- case TerminalTokens.TokenNameRestrictedIdentifiersealed:
- case TerminalTokens.TokenNameRestrictedIdentifierpermits:
- case TerminalTokens.TokenNameRestrictedIdentifierWhen:
- // making explicit - not a (restricted) keyword but restricted identifier.
- //$FALL-THROUGH$
- default:
- return false;
- }
-}
+
private boolean isLiteral(int token) {
return Scanner.isLiteral(token);
}
@@ -7539,7 +7373,7 @@ public void noSuchEnclosingInstance(TypeBinding targetType, ASTNode location, bo
location.sourceStart,
location instanceof LambdaExpression ? ((LambdaExpression)location).diagnosticsSourceEnd() : location.sourceEnd);
}
-public void notCompatibleTypesError(EqualExpression expression, TypeBinding leftType, TypeBinding rightType) {
+public void notCompatibleTypesError(ASTNode location, TypeBinding leftType, TypeBinding rightType) {
String leftName = new String(leftType.readableName());
String rightName = new String(rightType.readableName());
String leftShortName = new String(leftType.shortReadableName());
@@ -7548,28 +7382,18 @@ public void notCompatibleTypesError(EqualExpression expression, TypeBinding left
leftShortName = leftName;
rightShortName = rightName;
}
- this.handle(
- IProblem.IncompatibleTypesInEqualityOperator,
- new String[] {leftName, rightName },
- new String[] {leftShortName, rightShortName },
- expression.sourceStart,
- expression.sourceEnd);
-}
-public void notCompatibleTypesError(Expression expression, TypeBinding leftType, TypeBinding rightType) {
- String leftName = new String(leftType.readableName());
- String rightName = new String(rightType.readableName());
- String leftShortName = new String(leftType.shortReadableName());
- String rightShortName = new String(rightType.shortReadableName());
- if (leftShortName.equals(rightShortName)){
- leftShortName = leftName;
- rightShortName = rightName;
+ int problemId = IProblem.IncompatibleTypesInEqualityOperator;
+ if (location instanceof Pattern p && p.getEnclosingPattern() instanceof RecordPattern) {
+ problemId = IProblem.PatternTypeMismatch;
+ } else if (location instanceof InstanceOfExpression) {
+ problemId = IProblem.IncompatibleTypesInConditionalOperator;
}
this.handle(
- IProblem.IncompatibleTypesInConditionalOperator,
+ problemId,
new String[] {leftName, rightName },
new String[] {leftShortName, rightShortName },
- expression.sourceStart,
- expression.sourceEnd);
+ location.sourceStart,
+ location.sourceEnd);
}
public void notCompatibleTypesErrorInForeach(Expression expression, TypeBinding leftType, TypeBinding rightType) {
String leftName = new String(leftType.readableName());
@@ -7789,7 +7613,7 @@ public void parseError(
String[] possibleTokens) {
if (possibleTokens.length == 0) { //no suggestion available
- if (isKeyword(currentToken)) {
+ if (Scanner.isKeyword(currentToken)) {
String[] arguments = new String[] {new String(currentTokenSource)};
this.handle(
IProblem.ParsingErrorOnKeywordNoSuggestion,
@@ -7822,7 +7646,7 @@ public void parseError(
list.append('"');
}
- if (isKeyword(currentToken)) {
+ if (Scanner.isKeyword(currentToken)) {
String[] arguments = new String[] {new String(currentTokenSource), list.toString()};
this.handle(
IProblem.ParsingErrorOnKeyword,
@@ -8678,14 +8502,14 @@ private void syntaxError(
return;
}
String eTokenName;
- if (isKeyword(currentKind) ||
+ if (Scanner.isKeyword(currentKind) ||
isLiteral(currentKind) ||
isIdentifier(currentKind)) {
eTokenName = new String(currentTokenSource);
} else {
eTokenName = errorTokenName;
}
- if (isRestrictedIdentifier(currentKind))
+ if (TerminalTokens.isRestrictedKeyword(currentKind))
eTokenName = replaceIfSynthetic(eTokenName);
String[] arguments;
@@ -8793,21 +8617,21 @@ public void typeCastError(CastExpression expression, TypeBinding leftType, TypeB
expression.sourceStart,
expression.sourceEnd);
}
-public void unsafeCastInInstanceof(Expression expression, TypeBinding leftType, TypeBinding rightType) {
- String leftName = new String(leftType.readableName());
- String rightName = new String(rightType.readableName());
- String leftShortName = new String(leftType.shortReadableName());
- String rightShortName = new String(rightType.shortReadableName());
- if (leftShortName.equals(rightShortName)){
- leftShortName = leftName;
- rightShortName = rightName;
+public void unsafeCastInTestingContext(ASTNode location, TypeBinding castType, TypeBinding expressionType) {
+ String castName = new String(castType.readableName());
+ String exprName = new String(expressionType.readableName());
+ String castShortName = new String(castType.shortReadableName());
+ String exprShortName = new String(expressionType.shortReadableName());
+ if (castShortName.equals(exprShortName)){
+ castShortName = castName;
+ exprShortName = exprName;
}
this.handle(
IProblem.UnsafeCast,
- new String[] { rightName, leftName },
- new String[] { rightShortName, leftShortName },
- expression.sourceStart,
- expression.sourceEnd);
+ new String[] { exprName, castName },
+ new String[] { exprShortName, castShortName },
+ location.sourceStart,
+ location.sourceEnd);
}
public void typeCollidesWithEnclosingType(TypeDeclaration typeDecl) {
String[] arguments = new String[] {new String(typeDecl.name)};
@@ -9693,6 +9517,18 @@ public void unusedLocalVariable(LocalDeclaration localDecl) {
localDecl.sourceStart,
localDecl.sourceEnd);
}
+public void unusedLambdaParameter(LocalDeclaration localDecl) {
+ int severity = computeSeverity(IProblem.LambdaParameterIsNeverUsed);
+ if (severity == ProblemSeverities.Ignore) return;
+ String[] arguments = new String[] {new String(localDecl.name)};
+ this.handle(
+ IProblem.LambdaParameterIsNeverUsed,
+ arguments,
+ arguments,
+ severity,
+ localDecl.sourceStart,
+ localDecl.sourceEnd);
+}
public void unusedObjectAllocation(AllocationExpression allocationExpression) {
this.handle(
IProblem.UnusedObjectAllocation,
@@ -9969,7 +9805,7 @@ public boolean validateRestrictedKeywords(char[] name, ASTNode node) {
close();
}
}
-//Returns true if the problem is handled and reported (only errors considered and not warnings)
+// Returns true if the problem is handled and reported (only errors considered and not warnings)
public boolean validateJavaFeatureSupport(JavaFeature feature, int sourceStart, int sourceEnd) {
boolean versionInRange = feature.getCompliance() <= this.options.sourceLevel;
String version = CompilerOptions.versionFromJdkLevel(feature.getCompliance());
@@ -11940,24 +11776,15 @@ public void moduleDoesNotReadOther(ImportReference importReference, ModuleBindin
importReference.sourceStart,
importReference.sourceEnd);
}
-public void switchExpressionIncompatibleResultExpressions(SwitchExpression expression) {
- TypeBinding type = expression.resultExpressions.get(0).resolvedType;
+public void incompatibleSwitchExpressionResults(SwitchExpression expression) {
this.handle(
IProblem.SwitchExpressionsYieldIncompatibleResultExpressionTypes,
- new String[] {new String(type.readableName())},
- new String[] {new String(type.shortReadableName())},
- expression.sourceStart,
- expression.sourceEnd);
-}
-public void switchExpressionEmptySwitchBlock(SwitchExpression expression) {
- this.handle(
- IProblem.SwitchExpressionsYieldEmptySwitchBlock,
NoArgument,
NoArgument,
expression.sourceStart,
expression.sourceEnd);
}
-public void switchExpressionNoResultExpressions(SwitchExpression expression) {
+public void unyieldingSwitchExpression(SwitchExpression expression) {
this.handle(
IProblem.SwitchExpressionsYieldNoResultExpression,
NoArgument,
@@ -11965,15 +11792,7 @@ public void switchExpressionNoResultExpressions(SwitchExpression expression) {
expression.sourceStart,
expression.sourceEnd);
}
-public void switchExpressionSwitchLabeledBlockCompletesNormally(Block block) {
- this.handle(
- IProblem.SwitchExpressionaYieldSwitchLabeledBlockCompletesNormally,
- NoArgument,
- NoArgument,
- block.sourceEnd - 1,
- block.sourceEnd);
-}
-public void switchExpressionLastStatementCompletesNormally(Statement stmt) {
+public void switchExpressionBlockCompletesNormally(Statement stmt) {
this.handle(
IProblem.SwitchExpressionaYieldSwitchLabeledBlockCompletesNormally,
NoArgument,
@@ -11981,23 +11800,7 @@ public void switchExpressionLastStatementCompletesNormally(Statement stmt) {
stmt.sourceEnd - 1,
stmt.sourceEnd);
}
-public void switchExpressionIllegalLastStatement(Statement stmt) {
- this.handle(
- IProblem.SwitchExpressionsYieldIllegalLastStatement,
- NoArgument,
- NoArgument,
- stmt.sourceStart,
- stmt.sourceEnd);
-}
-public void switchExpressionTrailingSwitchLabels(Statement stmt) {
- this.handle(
- IProblem.SwitchExpressionsYieldTrailingSwitchLabels,
- NoArgument,
- NoArgument,
- stmt.sourceStart,
- stmt.sourceEnd);
-}
-public void switchExpressionMixedCase(ASTNode statement) {
+public void arrowColonMixup(ASTNode statement) {
this.handle(
IProblem.SwitchPreviewMixedCase,
NoArgument,
@@ -12005,24 +11808,7 @@ public void switchExpressionMixedCase(ASTNode statement) {
statement.sourceStart,
statement.sourceEnd);
}
-// Is this redundant ?? See switchExpressionsBreakOutOfSwitchExpression
-public void switchExpressionBreakNotAllowed(ASTNode statement) {
- this.handle(
- IProblem.SwitchExpressionsYieldBreakNotAllowed,
- NoArgument,
- NoArgument,
- statement.sourceStart,
- statement.sourceEnd);
-}
-public void switchExpressionsYieldUnqualifiedMethodWarning(ASTNode statement) {
- this.handle(
- IProblem.SwitchExpressionsYieldUnqualifiedMethodWarning,
- NoArgument,
- NoArgument,
- statement.sourceStart,
- statement.sourceEnd);
-}
-public void switchExpressionsYieldUnqualifiedMethodError(ASTNode statement) {
+public void unqualifiedYieldMethod(ASTNode statement) {
this.handle(
IProblem.SwitchExpressionsYieldUnqualifiedMethodError,
NoArgument,
@@ -12030,7 +11816,7 @@ public void switchExpressionsYieldUnqualifiedMethodError(ASTNode statement) {
statement.sourceStart,
statement.sourceEnd);
}
-public void switchExpressionsYieldOutsideSwitchExpression(ASTNode statement) {
+public void yieldOutsideSwitchExpression(ASTNode statement) {
this.handle(
IProblem.SwitchExpressionsYieldOutsideSwitchExpression,
NoArgument,
@@ -12038,38 +11824,6 @@ public void switchExpressionsYieldOutsideSwitchExpression(ASTNode statement) {
statement.sourceStart,
statement.sourceEnd);
}
-public void switchExpressionsYieldRestrictedGeneralWarning(ASTNode statement) {
- this.handle(
- IProblem.SwitchExpressionsYieldRestrictedGeneralWarning,
- NoArgument,
- NoArgument,
- statement.sourceStart,
- statement.sourceEnd);
-}
-public void switchExpressionsYieldIllegalStatement(ASTNode statement) {
- this.handle(
- IProblem.SwitchExpressionsYieldIllegalStatement,
- NoArgument,
- NoArgument,
- statement.sourceStart,
- statement.sourceEnd);
-}
-public void switchExpressionsYieldTypeDeclarationWarning(ASTNode statement) {
- this.handle(
- IProblem.SwitchExpressionsYieldTypeDeclarationWarning,
- NoArgument,
- NoArgument,
- statement.sourceStart,
- statement.sourceEnd);
-}
-public void switchExpressionsYieldTypeDeclarationError(ASTNode statement) {
- this.handle(
- IProblem.SwitchExpressionsYieldTypeDeclarationError,
- NoArgument,
- NoArgument,
- statement.sourceStart,
- statement.sourceEnd);
-}
public void multiConstantCaseLabelsNotSupported(ASTNode statement) {
this.handle(
IProblem.MultiConstantCaseLabelsNotSupported,
@@ -12094,7 +11848,7 @@ public void switchExpressionsNotSupported(ASTNode statement) {
statement.sourceStart,
statement.sourceEnd);
}
-public void switchExpressionsBreakOutOfSwitchExpression(ASTNode statement) {
+public void breakOutOfSwitchExpression(ASTNode statement) {
this.handle(
IProblem.SwitchExpressionsBreakOutOfSwitchExpression,
NoArgument,
@@ -12102,7 +11856,7 @@ public void switchExpressionsBreakOutOfSwitchExpression(ASTNode statement) {
statement.sourceStart,
statement.sourceEnd);
}
-public void switchExpressionsContinueOutOfSwitchExpression(ASTNode statement) {
+public void continueOutOfSwitchExpression(ASTNode statement) {
this.handle(
IProblem.SwitchExpressionsContinueOutOfSwitchExpression,
NoArgument,
@@ -12110,7 +11864,7 @@ public void switchExpressionsContinueOutOfSwitchExpression(ASTNode statement) {
statement.sourceStart,
statement.sourceEnd);
}
-public void switchExpressionsReturnWithinSwitchExpression(ASTNode statement) {
+public void returnOutOfSwitchExpression(ASTNode statement) {
this.handle(
IProblem.SwitchExpressionsReturnWithinSwitchExpression,
NoArgument,
@@ -12414,140 +12168,80 @@ public void illegalModifierForLocalEnumDeclaration(SourceTypeBinding type) {
type.sourceStart(),
type.sourceEnd());
}
-private void sealedMissingModifier(int problem, SourceTypeBinding type, TypeDeclaration typeDecl, TypeBinding superTypeBinding) {
+
+public void permittedTypeNeedsModifier(SourceTypeBinding type, TypeDeclaration typeDecl, TypeBinding superTypeBinding) {
String name = new String(type.sourceName());
String superTypeFullName = new String(superTypeBinding.readableName());
String superTypeShortName = new String(superTypeBinding.shortReadableName());
if (superTypeShortName.equals(name)) superTypeShortName = superTypeFullName;
this.handle(
- problem,
+ type.isClass() ? IProblem.SealedMissingClassModifier : IProblem.SealedMissingInterfaceModifier,
new String[] {superTypeFullName, name},
new String[] {superTypeShortName, name},
typeDecl.sourceStart,
typeDecl.sourceEnd);
}
-public void sealedMissingClassModifier(SourceTypeBinding type, TypeDeclaration typeDecl, TypeBinding superTypeBinding) {
- sealedMissingModifier(IProblem.SealedMissingClassModifier, type, typeDecl, superTypeBinding);
-}
-public void sealedMissingInterfaceModifier(SourceTypeBinding type, TypeDeclaration typeDecl, TypeBinding superTypeBinding) {
- sealedMissingModifier(IProblem.SealedMissingInterfaceModifier, type, typeDecl, superTypeBinding);
-}
-public void sealedDisAllowedNonSealedModifierInClass(SourceTypeBinding type, TypeDeclaration typeDecl) {
+public void disallowedNonSealedModifier(SourceTypeBinding type, TypeDeclaration typeDecl) {
String name = new String(type.sourceName());
this.handle(
- IProblem.SealedDisAllowedNonSealedModifierInClass,
+ type.isClass() ? IProblem.SealedDisAllowedNonSealedModifierInClass : IProblem.SealedDisAllowedNonSealedModifierInInterface,
new String[] { name },
new String[] { name },
typeDecl.sourceStart,
typeDecl.sourceEnd);
}
-private void sealedSuperTypeDoesNotPermit(int problem, SourceTypeBinding type, TypeReference superType, TypeBinding superTypeBinding) {
- String name = new String(type.sourceName());
- String superTypeFullName = new String(superTypeBinding.readableName());
- String superTypeShortName = new String(superTypeBinding.shortReadableName());
- if (superTypeShortName.equals(name)) superTypeShortName = superTypeFullName;
- this.handle(
- problem,
- new String[] {name, superTypeFullName},
- new String[] {name, superTypeShortName},
- superType.sourceStart,
- superType.sourceEnd);
-}
-
-public void sealedSuperTypeInDifferentPackage(int problem, SourceTypeBinding type, TypeReference curType, TypeBinding superTypeBinding, PackageBinding superPackageBinding) {
- String typeName = new String(type.sourceName);
- String name = new String(superTypeBinding.sourceName());
- String packageName = superPackageBinding.compoundName == CharOperation.NO_CHAR_CHAR ? "default" : //$NON-NLS-1$
- CharOperation.toString(superPackageBinding.compoundName);
- String[] arguments = new String[] {typeName, packageName, name};
- this.handle(problem,
- arguments,
- arguments,
- curType.sourceStart,
- curType.sourceEnd);
-}
-
-public void sealedSuperTypeDisallowed(int problem, SourceTypeBinding type, TypeReference curType, TypeBinding superTypeBinding) {
- String typeName = new String(type.sourceName);
- String name = new String(superTypeBinding.sourceName());
- String[] arguments = new String[] {typeName, name};
- this.handle(problem,
- arguments,
- arguments,
- curType.sourceStart,
- curType.sourceEnd);
-}
-
-public void sealedSuperClassDoesNotPermit(SourceTypeBinding type, TypeReference superType, TypeBinding superTypeBinding) {
- sealedSuperTypeDoesNotPermit(IProblem.SealedSuperClassDoesNotPermit, type, superType, superTypeBinding);
-}
-
-public void sealedSuperClassInDifferentPackage(SourceTypeBinding type, TypeReference curType, TypeBinding superTypeBinding, PackageBinding superPackageBinding) {
- sealedSuperTypeInDifferentPackage(IProblem.SealedSuperTypeInDifferentPackage, type, curType, superTypeBinding, superPackageBinding);
-}
-
-public void sealedSuperClassDisallowed(SourceTypeBinding type, TypeReference curType, TypeBinding superTypeBinding) {
- sealedSuperTypeDisallowed(IProblem.SealedSuperTypeDisallowed, type, curType, superTypeBinding);
-}
-
-public void sealedSuperInterfaceDoesNotPermit(SourceTypeBinding type, TypeReference superType, TypeBinding superTypeBinding) {
+public void sealedSupertypeDoesNotPermit(SourceTypeBinding type, TypeReference superType, TypeBinding superTypeBinding) {
String name = new String(type.sourceName());
String superTypeFullName = new String(superTypeBinding.readableName());
String superTypeShortName = new String(superTypeBinding.shortReadableName());
- String keyword = type.isClass() ? new String(TypeConstants.IMPLEMENTS) : new String(TypeConstants.KEYWORD_EXTENDS);
if (superTypeShortName.equals(name)) superTypeShortName = superTypeFullName;
- this.handle(
- IProblem.SealedSuperInterfaceDoesNotPermit,
- new String[] {name, superTypeFullName, keyword},
- new String[] {name, superTypeShortName, keyword},
- superType.sourceStart,
- superType.sourceEnd);
-}
-
-public void sealedSuperInterfaceInDifferentPackage(SourceTypeBinding type, TypeReference curType, TypeBinding superTypeBinding, PackageBinding superPackageBinding) {
- sealedSuperTypeInDifferentPackage(IProblem.SealedSuperTypeInDifferentPackage, type, curType, superTypeBinding, superPackageBinding);
-}
-
-public void sealedSuperInterfaceDisallowed(SourceTypeBinding type, TypeReference curType, TypeBinding superTypeBinding) {
- sealedSuperTypeDisallowed(IProblem.SealedSuperTypeDisallowed, type, curType, superTypeBinding);
+ if (superTypeBinding.isClass()) {
+ this.handle(
+ IProblem.SealedSuperClassDoesNotPermit,
+ new String[] {name, superTypeFullName},
+ new String[] {name, superTypeShortName},
+ superType.sourceStart,
+ superType.sourceEnd);
+ } else {
+ String keyword = type.isClass() ? new String(TypeConstants.IMPLEMENTS) : new String(TypeConstants.KEYWORD_EXTENDS);
+ this.handle(
+ IProblem.SealedSuperInterfaceDoesNotPermit,
+ new String[] {name, superTypeFullName, keyword},
+ new String[] {name, superTypeShortName, keyword},
+ superType.sourceStart,
+ superType.sourceEnd);
+ }
}
-public void sealedMissingSealedModifier(SourceTypeBinding type, ASTNode node) {
+public void missingSealedModifier(SourceTypeBinding type, ASTNode node) {
String name = new String(type.sourceName());
this.handle(IProblem.SealedMissingSealedModifier, new String[] { name }, new String[] { name }, node.sourceStart,
node.sourceEnd);
}
-public void sealedDuplicateTypeInPermits(SourceTypeBinding type, TypeReference reference, ReferenceBinding superType) {
+public void duplicatePermittedType(TypeReference reference, ReferenceBinding superType) {
this.handle(
IProblem.SealedDuplicateTypeInPermits,
- new String[] {
- new String(superType.readableName()),
- new String(type.sourceName())},
- new String[] {
- new String(superType.shortReadableName()),
- new String(type.sourceName())},
+ new String[] { new String(superType.readableName()) },
+ new String[] { new String(superType.shortReadableName()) },
reference.sourceStart,
reference.sourceEnd);
}
-public void sealedNotDirectSuperClass(ReferenceBinding type, TypeReference reference, SourceTypeBinding superType) {
- this.handle(
- IProblem.SealedNotDirectSuperClass,
- new String[] {
- new String(type.sourceName()),
- new String(superType.readableName())},
- new String[] {
- new String(type.sourceName()),
- new String(superType.readableName())},
- reference.sourceStart,
- reference.sourceEnd);
+public void sealedClassNotDirectSuperClassOf(ReferenceBinding type, TypeReference reference, SourceTypeBinding superType) {
+ if ((type.tagBits & TagBits.HierarchyHasProblems) == 0 && (superType.tagBits & TagBits.HierarchyHasProblems) == 0) {
+ this.handle(IProblem.SealedNotDirectSuperClass,
+ new String[] { new String(type.sourceName()), new String(superType.readableName()) },
+ new String[] { new String(type.sourceName()), new String(superType.readableName()) },
+ reference.sourceStart, reference.sourceEnd);
+ }
}
-public void sealedPermittedTypeOutsideOfModule(ReferenceBinding permType, SourceTypeBinding type, ASTNode node, ModuleBinding moduleBinding) {
+
+public void permittedTypeOutsideOfModule(ReferenceBinding permType, ReferenceBinding sealedType, ASTNode node, ModuleBinding moduleBinding) {
String permTypeName = new String(permType.sourceName);
- String name = new String(type.sourceName());
+ String name = new String(sealedType.sourceName());
String moduleName = new String(moduleBinding.name());
String[] arguments = new String[] {permTypeName, moduleName, name};
this.handle(IProblem.SealedPermittedTypeOutsideOfModule,
@@ -12556,15 +12250,10 @@ public void sealedPermittedTypeOutsideOfModule(ReferenceBinding permType, Source
node.sourceStart,
node.sourceEnd);
}
-public void sealedPermittedTypeOutsideOfModule(SourceTypeBinding type, ASTNode node) {
- String name = new String(type.sourceName());
- this.handle(IProblem.SealedPermittedTypeOutsideOfModule, new String[] { name }, new String[] { name },
- node.sourceStart, node.sourceEnd);
-}
-public void sealedPermittedTypeOutsideOfPackage(ReferenceBinding permType, SourceTypeBinding type, ASTNode node, PackageBinding packageBinding) {
+public void permittedTypeOutsideOfPackage(ReferenceBinding permType, ReferenceBinding sealedType, ASTNode node, PackageBinding packageBinding) {
String permTypeName = new String(permType.sourceName);
- String name = new String(type.sourceName());
+ String name = new String(sealedType.sourceName());
String packageName = packageBinding.compoundName == CharOperation.NO_CHAR_CHAR ? "default" : //$NON-NLS-1$
CharOperation.toString(packageBinding.compoundName);
String[] arguments = new String[] {permTypeName, packageName, name};
@@ -12575,45 +12264,22 @@ public void sealedPermittedTypeOutsideOfPackage(ReferenceBinding permType, Sourc
node.sourceEnd);
}
-public void sealedSealedTypeMissingPermits(SourceTypeBinding type, ASTNode node) {
+public void missingPermitsClause(SourceTypeBinding type, ASTNode node) {
String name = new String(type.sourceName());
this.handle(IProblem.SealedSealedTypeMissingPermits, new String[] { name }, new String[] { name }, node.sourceStart,
node.sourceEnd);
}
-public void sealedInterfaceIsSealedAndNonSealed(SourceTypeBinding type, ASTNode node) {
- String name = new String(type.sourceName());
- this.handle(IProblem.SealedInterfaceIsSealedAndNonSealed,
- new String[] { name },
- new String[] { name },
- node.sourceStart,
- node.sourceEnd);
-}
-
-public void sealedDisAllowedNonSealedModifierInInterface(SourceTypeBinding type, TypeDeclaration typeDecl) {
- String name = new String(type.sourceName());
- this.handle(
- IProblem.SealedDisAllowedNonSealedModifierInInterface,
- new String[] { name },
- new String[] { name },
- typeDecl.sourceStart,
- typeDecl.sourceEnd);
-}
-
-public void sealedNotDirectSuperInterface(ReferenceBinding type, TypeReference reference, SourceTypeBinding superType) {
- this.handle(
- IProblem.SealedNotDirectSuperInterface,
- new String[] {
- new String(type.sourceName()),
- new String(superType.readableName())},
- new String[] {
- new String(type.sourceName()),
- new String(superType.readableName())},
- reference.sourceStart,
- reference.sourceEnd);
+public void sealedInterfaceNotDirectSuperInterfaceOf(ReferenceBinding type, TypeReference reference, SourceTypeBinding superType) {
+ if ((type.tagBits & TagBits.HierarchyHasProblems) == 0 && (superType.tagBits & TagBits.HierarchyHasProblems) == 0) {
+ this.handle(IProblem.SealedNotDirectSuperInterface,
+ new String[] { new String(type.sourceName()), new String(superType.readableName()) },
+ new String[] { new String(type.sourceName()), new String(superType.readableName()) },
+ reference.sourceStart, reference.sourceEnd);
+ }
}
-public void sealedLocalDirectSuperTypeSealed(SourceTypeBinding type, TypeReference superclass, TypeBinding superTypeBinding) {
+public void localTypeMayNotBePermittedType(SourceTypeBinding type, TypeReference superclass, TypeBinding superTypeBinding) {
String name = new String(type.sourceName());
String superTypeFullName = new String(superTypeBinding.readableName());
String superTypeShortName = new String(superTypeBinding.shortReadableName());
@@ -12625,7 +12291,8 @@ public void sealedLocalDirectSuperTypeSealed(SourceTypeBinding type, TypeReferen
superclass.sourceStart,
superclass.sourceEnd);
}
-public void sealedAnonymousClassCannotExtendSealedType(TypeReference reference, TypeBinding type) {
+
+public void anonymousClassCannotExtendSealedType(TypeReference reference, TypeBinding type) {
this.handle(
IProblem.SealedAnonymousClassCannotExtendSealedType,
new String[] {new String(type.readableName())},
@@ -12633,6 +12300,17 @@ public void sealedAnonymousClassCannotExtendSealedType(TypeReference reference,
reference.sourceStart,
reference.sourceEnd);
}
+
+public void functionalInterfaceMayNotBeSealed(TypeDeclaration type) {
+ TypeBinding binding = type.binding;
+ this.handle(
+ IProblem.FunctionalInterfaceMayNotbeSealed,
+ new String[] {new String(binding.readableName()), },
+ new String[] {new String(binding.shortReadableName()),},
+ type.sourceStart,
+ type.sourceEnd);
+}
+
public void StrictfpNotRequired(int sourceStart, int sourceEnd) {
this.handle(
IProblem.StrictfpNotRequired,
@@ -12735,14 +12413,6 @@ public void recordPatternSignatureMismatch(TypeBinding type, ASTNode element) {
element.sourceStart,
element.sourceEnd);
}
-public void incompatiblePatternType(ASTNode element, TypeBinding type, TypeBinding expected) {
- this.handle(
- IProblem.PatternTypeMismatch,
- new String[] {new String(type.readableName()), new String(expected.readableName())},
- new String[] {new String(type.shortReadableName()), new String(expected.readableName())},
- element.sourceStart,
- element.sourceEnd);
-}
public void cannotInferRecordPatternTypes(RecordPattern pattern) {
String arguments [] = new String [] { pattern.toString() };
this.handle(
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/messages.properties b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/messages.properties
index 06008e016d..b1d22ac876 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/messages.properties
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/messages.properties
@@ -294,6 +294,7 @@
272 = Text block is not properly closed with the delimiter
280 = Discouraged access: {0}
+281 = The value of the lambda parameter {0} is not used
300 = The interface {0} cannot define an initializer
301 = Duplicate modifier for the type {0}
@@ -907,6 +908,7 @@
1107 = The Java feature ''{0}'' is only available with source level {1} and above
1108 = You are using an API that is part of a preview feature and may be removed in future
1109 = Compiling for Java version ''{0}'' is no longer supported. Minimal supported version is ''{1}''
+1110 = Compiling for Java version ''{0}'' is not supported yet. Using ''{1}'' instead
# more programming problems:
1200 = Unlikely argument type {0} for {1} on a {2}
1201 = Unlikely argument type for equals(): {0} seems to be unrelated to {2}
@@ -1012,46 +1014,48 @@
1513 = 'var' cannot be used with type arguments
# Switch-Expressions Java 12 Preview
-1600 = Incompatible switch results expressions {0}
-1601 = A switch expression should have a non-empty switch block
-1602 = A switch expression should have at least one result expression
-1603 = A switch labeled block in a switch expression should not complete normally
-1604 = The last statement of a switch block in a switch expression should not complete normally
-1605 = Trailing switch labels are not allowed in a switch expression.
-1606 = Mixing of different kinds of case statements '->' and ':' is not allowed within a switch
-1607 = A switch expression should have a default case
-1608 = Switch expressions are allowed only at source level 12 or above
-1609 = Switch Case Labels with '->' are allowed only at source level 12 or above
-1610 = Break of a switch expression should have a value
-1611 = A Switch expression should cover all possible values
-1612 = 'continue' or 'return' cannot be the last statement in a Switch expression case body
+###[obsolete] 1600 = Incompatible switch results expressions {0}
+###[obsolete] 1601 = A switch expression should have a non-empty switch block
+###[obsolete] 1602 = A switch expression should have at least one result expression
+###[obsolete] 1603 = A switch labeled block in a switch expression should not complete normally
+###[obsolete] 1604 = The last statement of a switch block in a switch expression should not complete normally
+###[obsolete] 1605 = Trailing switch labels are not allowed in a switch expression.
+###[obsolete] 1606 = Mixing of different kinds of case statements '->' and ':' is not allowed within a switch
+###[obsolete] 1607 = A switch expression should have a default case
+###[obsolete] 1608 = Switch expressions are allowed only at source level 12 or above
+###[obsolete] 1609 = Switch Case Labels with '->' are allowed only at source level 12 or above
+###[obsolete] 1610 = Break of a switch expression should have a value
+###[obsolete] 1611 = A Switch expression should cover all possible values
+###[obsolete] 1612 = 'continue' or 'return' cannot be the last statement in a Switch expression case body
# Switch-Expressions Java 14
-1700 = Incompatible switch results expressions {0}
-1701 = A switch expression should have a non-empty switch block
+1700 = Incompatible results expressions in switch
+###[obsolete] 1701 = A switch expression should have a non-empty switch block
1702 = A switch expression should have at least one result expression
1703 = A switch labeled block in a switch expression should not complete normally
-1704 = The last statement of a switch block in a switch expression should not complete normally
-1705 = Trailing switch labels are not allowed in a switch expression.
-1706 = Mixing of different kinds of case statements '->' and ':' is not allowed within a switch
+###[obsolete] 1704 = The last statement of a switch block in a switch expression should not complete normally
+###[obsolete] 1705 = Trailing switch labels are not allowed in a switch expression.
+1706 = Mixing of '->' and ':' case statement styles is not allowed within a switch
1707 = A switch expression should have a default case
-1708 = yield of a switch expression should have a value
+###[obsolete] 1708 = yield of a switch expression should have a value
1709 = A Switch expression should cover all possible values
-1710 = 'continue' or 'return' cannot be the last statement in a Switch expression case body
-1711 = break out of switch expression not allowed
-1712 = yield may be disallowed in future - qualify method calls to avoid this message
+###[obsolete] 1710 = 'continue' or 'return' cannot be the last statement in a Switch expression case body
+###[obsolete] 1711 = break out of switch expression not allowed
+###[obsolete] 1712 = yield may be disallowed in future - qualify method calls to avoid this message
1713 = restricted identifier yield not allowed here - method calls need to be qualified
1714 = yield outside of switch expression
-1715 = yield is a restricted keyword and may be disallowed in future
-1716 = yield statement is illegal here
-1717 = yield may be a restricted identifier in future and may be disallowed as a type name
-1718 = yield is a restricted identifier and cannot be used as type name
+###[obsolete] 1715 = yield is a restricted keyword and may be disallowed in future
+###[obsolete] 1716 = yield statement is illegal here
+###[obsolete] 1717 = yield may be a restricted identifier in future and may be disallowed as a type name
+###[obsolete] 1718 = yield is a restricted identifier and cannot be used as type name
1719 = Multi-constant case labels supported from Java 14 onwards only
1720 = Arrow in case statement supported from Java 14 onwards only
1721 = Switch Expressions are supported from Java 14 onwards only
1722 = Breaking out of switch expressions not permitted
1723 = Continue out of switch expressions not permitted
1724 = Return within switch expressions not permitted
+
+
# Java 15 Preview - begin
# Records
1730 = Illegal modifier for the record {0}; only public, private, protected, static, final and strictfp are permitted
@@ -1129,25 +1133,26 @@
# Java 16
1820 = {0} is a value-based type which is a discouraged argument for the synchronized statement
-# Java 15 Preview - cont
-1850 = The class {1} with a sealed direct superclass or a sealed direct superinterface {0} should be declared either final, sealed, or non-sealed
-1851 = A class {0} declared as non-sealed should have either a sealed direct superclass or a sealed direct superinterface
-1852 = The type {0} extending a sealed class {1} should be a permitted subtype of {1}
-1853 = The type {0} that {2} a sealed interface {1} should be a permitted subtype of {1}
+# Sealed types - Java 17
+1850 = The class {1} with a sealed direct supertype {0} should be declared either final, sealed, or non-sealed
+1851 = The non-sealed class {0} must have a sealed direct supertype
+1852 = The class {0} cannot extend the class {1} as it is not a permitted subtype of {1}
+1853 = The type {0} that {2} the sealed interface {1} should be a permitted subtype of {1}
1854 = A type declaration {0} that has a permits clause should have a sealed modifier
1855 = The interface {1} with a sealed direct superinterface {0} should be declared either sealed or non-sealed
-1856 = Duplicate type {0} for the type {1} in the permits clause
-1857 = Permitted class {0} does not declare {1} as direct super class
+1856 = Duplicate permitted type {0}
+1857 = Permitted type {0} does not declare {1} as a direct supertype
1858 = Permitted type {0} in a named module {1} should be declared in the same module {1} of declaring type {2}
1859 = Permitted type {0} in an unnamed module should be declared in the same package {1} of declaring type {2}
-1860 = Sealed class or interface lacks the permits clause and no class or interface from the same compilation unit declares {0} as its direct superclass or superinterface
-1861 = An interface {0} is declared both sealed and non-sealed
-1862 = An interface {0} declared as non-sealed should have a sealed direct superinterface
+1860 = Sealed type {0} lacks a permits clause and no type from the same compilation unit declares {0} as its direct supertype
+###[obsolete] 1861 = An interface {0} is declared both sealed and non-sealed
+1862 = The non-sealed interface {0} must have a sealed direct superinterface
1863 = Permitted type {0} does not declare {1} as direct super interface
-1864 = A local class {1} cannot have a sealed direct superclass or a sealed direct superinterface {0}
+1864 = The local type {1} may not have a sealed supertype {0}
1865 = An anonymous class cannot subclass a sealed type {0}
-1866 = Sealed type {2} and sub type {0} in an unnamed module should be declared in the same package {1}
-1867 = Sealed type {1} cannot be super type of {0} as it is from a different package or split package or module
+###[obsolete] 1866 = Sealed type {2} and sub type {0} in an unnamed module should be declared in the same package {1}
+###[obsolete] 1867 = Sealed type {1} cannot be super type of {0} as it is from a different package or split package or module
+1868 = A functional interface may not be declared sealed
# Switch Patterns - Java 21
1900 = Local variable {0} referenced from a guard must be final or effectively final
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/Archive.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/Archive.java
index 73b55cee43..b3bc201bc3 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/Archive.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/Archive.java
@@ -26,7 +26,6 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
-
import org.eclipse.jdt.internal.compiler.util.JRTUtil;
/**
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/ArchiveFileObject.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/ArchiveFileObject.java
index 09626e4659..43058523c1 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/ArchiveFileObject.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/ArchiveFileObject.java
@@ -25,11 +25,9 @@
import java.nio.charset.Charset;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
-
import javax.lang.model.element.Modifier;
import javax.lang.model.element.NestingKind;
import javax.tools.JavaFileObject;
-
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseBatchRequestor.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseBatchRequestor.java
index eb21f23e64..0e63154858 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseBatchRequestor.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseBatchRequestor.java
@@ -15,7 +15,6 @@
import javax.tools.DiagnosticListener;
import javax.tools.JavaFileObject;
-
import org.eclipse.jdt.core.compiler.CategorizedProblem;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.ICompilerRequestor;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseCompiler.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseCompiler.java
index c6c4c40f32..e423b8a552 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseCompiler.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseCompiler.java
@@ -30,7 +30,6 @@
import java.util.Locale;
import java.util.Set;
import java.util.WeakHashMap;
-
import javax.annotation.processing.Processor;
import javax.lang.model.SourceVersion;
import javax.tools.DiagnosticListener;
@@ -39,7 +38,6 @@
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
import javax.tools.StandardLocation;
-
import org.eclipse.jdt.internal.compiler.batch.Main;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseCompilerImpl.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseCompilerImpl.java
index fbb8d0bb2e..3ebe575228 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseCompilerImpl.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseCompilerImpl.java
@@ -37,7 +37,6 @@
import java.util.Map;
import java.util.Optional;
import java.util.stream.Stream;
-
import javax.annotation.processing.Processor;
import javax.tools.Diagnostic;
import javax.tools.DiagnosticListener;
@@ -46,7 +45,6 @@
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
import javax.tools.StandardLocation;
-
import org.eclipse.jdt.core.compiler.CategorizedProblem;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.compiler.CompilationProgress;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseCompilerRequestor.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseCompilerRequestor.java
index 28fcf01cf7..516ded99ca 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseCompilerRequestor.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseCompilerRequestor.java
@@ -16,7 +16,6 @@
import javax.tools.DiagnosticListener;
import javax.tools.JavaFileObject;
-
import org.eclipse.jdt.core.compiler.CategorizedProblem;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.batch.BatchCompilerRequestor;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseDiagnostic.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseDiagnostic.java
index 26aa09be1e..cbd1b6e37d 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseDiagnostic.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseDiagnostic.java
@@ -15,10 +15,8 @@
import java.io.File;
import java.util.Locale;
-
import javax.tools.Diagnostic;
import javax.tools.JavaFileObject;
-
import org.eclipse.jdt.core.compiler.CategorizedProblem;
import org.eclipse.jdt.internal.compiler.problem.DefaultProblem;
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseFileManager.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseFileManager.java
index 765dbb9825..9ad9b94caf 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseFileManager.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseFileManager.java
@@ -24,29 +24,13 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.Objects;
-import java.util.ResourceBundle;
-import java.util.ServiceLoader;
-import java.util.Set;
-import java.util.StringTokenizer;
-
+import java.util.*;
import javax.lang.model.SourceVersion;
import javax.tools.FileObject;
import javax.tools.JavaFileObject;
import javax.tools.JavaFileObject.Kind;
import javax.tools.StandardJavaFileManager;
import javax.tools.StandardLocation;
-
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
import org.eclipse.jdt.internal.compiler.batch.FileSystem;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseFileObject.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseFileObject.java
index c870341251..323b9e7455 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseFileObject.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseFileObject.java
@@ -15,27 +15,12 @@
package org.eclipse.jdt.internal.compiler.tool;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.Writer;
+import java.io.*;
import java.net.URI;
import java.nio.charset.Charset;
-
import javax.lang.model.element.Modifier;
import javax.lang.model.element.NestingKind;
import javax.tools.SimpleJavaFileObject;
-
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/ExceptionDiagnostic.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/ExceptionDiagnostic.java
index 5afe834969..b22b7f78d8 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/ExceptionDiagnostic.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/ExceptionDiagnostic.java
@@ -14,7 +14,6 @@
package org.eclipse.jdt.internal.compiler.tool;
import java.util.Locale;
-
import javax.tools.Diagnostic;
import javax.tools.JavaFileObject;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/JrtFileSystem.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/JrtFileSystem.java
index c475f2946a..5910a0ad96 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/JrtFileSystem.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/JrtFileSystem.java
@@ -33,9 +33,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.zip.ZipException;
-
import javax.tools.JavaFileObject;
-
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
import org.eclipse.jdt.internal.compiler.tool.ModuleLocationHandler.ModuleLocationWrapper;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/ModuleLocationHandler.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/ModuleLocationHandler.java
index e751a4519e..9a72071bda 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/ModuleLocationHandler.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/ModuleLocationHandler.java
@@ -23,7 +23,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-
import javax.tools.JavaFileManager.Location;
import javax.tools.StandardLocation;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/PathFileObject.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/PathFileObject.java
index af6e2e0ce9..288504bc82 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/PathFileObject.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/PathFileObject.java
@@ -23,11 +23,9 @@
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
-
import javax.lang.model.element.Modifier;
import javax.lang.model.element.NestingKind;
import javax.tools.JavaFileObject;
-
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/Util.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/Util.java
index d710d4157e..213bcb06ea 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/Util.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/Util.java
@@ -23,7 +23,6 @@
import java.nio.charset.IllegalCharsetNameException;
import java.nio.charset.UnsupportedCharsetException;
import java.util.ArrayList;
-
import javax.tools.FileObject;
/**
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/HashtableOfObject.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/HashtableOfObject.java
index 1976b30c50..9919c4c832 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/HashtableOfObject.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/HashtableOfObject.java
@@ -14,7 +14,6 @@
package org.eclipse.jdt.internal.compiler.util;
import java.util.Arrays;
-
import org.eclipse.jdt.core.compiler.CharOperation;
/**
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/JRTUtil.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/JRTUtil.java
index c58937029d..19265d1fd1 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/JRTUtil.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/JRTUtil.java
@@ -21,23 +21,13 @@
import java.io.UncheckedIOException;
import java.net.URI;
import java.nio.channels.ClosedByInterruptException;
-import java.nio.file.FileSystem;
-import java.nio.file.FileSystemAlreadyExistsException;
-import java.nio.file.FileSystemNotFoundException;
-import java.nio.file.FileSystems;
-import java.nio.file.FileVisitResult;
-import java.nio.file.Files;
-import java.nio.file.NoSuchFileException;
-import java.nio.file.Path;
-import java.nio.file.ProviderNotFoundException;
-import java.nio.file.SimpleFileVisitor;
+import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Predicate;
-
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/JrtFileSystem.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/JrtFileSystem.java
index 8a33f3432f..2f3b126d41 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/JrtFileSystem.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/JrtFileSystem.java
@@ -30,7 +30,6 @@
import java.util.Map;
import java.util.function.Predicate;
import java.util.stream.Stream;
-
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
@@ -326,7 +325,7 @@ synchronized void cachePackage(String packageName, String module) {
}
/**
- * @return JDK release string (something like 1.8.0_05) read from the "release" file from JDK home
+ * @return JDK release string (something like 1.8.0_05
) read from the "release" file from JDK home
* directory
*/
public String getJdkRelease() {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/Sorting.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/Sorting.java
index 262cdcbfd6..78e5395218 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/Sorting.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/Sorting.java
@@ -15,7 +15,6 @@
import java.util.Arrays;
import java.util.Comparator;
-
import org.eclipse.jdt.internal.compiler.lookup.InferenceVariable;
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/TextBlockUtil.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/TextBlockUtil.java
new file mode 100644
index 0000000000..5e0642812c
--- /dev/null
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/TextBlockUtil.java
@@ -0,0 +1,272 @@
+/*******************************************************************************
+ * Copyright (c) 2024 IBM Corporation.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.compiler.util;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.core.compiler.InvalidInputException;
+import org.eclipse.jdt.internal.compiler.parser.ScannerHelper;
+
+public class TextBlockUtil {
+
+ private static char[] normalize(char[] content) {
+ StringBuilder result = new StringBuilder();
+ boolean isCR = false;
+ for (char c : content) {
+ switch (c) {
+ case '\r':
+ result.append(c);
+ isCR = true;
+ break;
+ case '\n':
+ if (!isCR) {
+ result.append(c);
+ }
+ isCR = false;
+ break;
+ default:
+ result.append(c);
+ isCR = false;
+ break;
+ }
+ }
+ return result.toString().toCharArray();
+ }
+ // This method is for handling the left over escaped characters during the first
+ // scanning (scanForStringLiteral). Admittedly this goes over the text block
+ // content again char by char, but this is required in order to correctly
+ // treat all the white space and line endings
+ private static boolean getLineContent(StringBuilder result, char[] line, int start, int end, boolean merge, boolean lastLine) {
+ int lastPointer = 0;
+ for(int i = start; i < end;) {
+ char c = line[i];
+ if (c != '\\') {
+ i++;
+ continue;
+ }
+ if (i < end) {
+ if (lastPointer + 1 <= i) {
+ result.append(CharOperation.subarray(line, lastPointer == 0 ? start : lastPointer, i));
+ }
+ char next = line[++i];
+ switch (next) {
+ case '\\' :
+ result.append('\\');
+ if (i == end)
+ merge = false;
+ break;
+ case 's' :
+ result.append(' ');
+ break;
+ case '"':
+ result.append('"');
+ break;
+ case 'b' :
+ result.append('\b');
+ break;
+ case 'n' :
+ result.append('\n');
+ break;
+ case 'r' :
+ result.append('\r');
+ break;
+ case 't' :
+ result.append('\t');
+ break;
+ case 'f' :
+ result.append('\f');
+ break;
+ default :
+ // Direct copy from Scanner#scanEscapeCharacter
+ int pos = i + 1;
+ int number = ScannerHelper.getHexadecimalValue(next);
+ if (number >= 0 && number <= 7) {
+ boolean zeroToThreeNot = number > 3;
+ try {
+ if (pos <= end && ScannerHelper.isDigit(next = line[pos])) {
+ pos++;
+ int digit = ScannerHelper.getHexadecimalValue(next);
+ if (digit >= 0 && digit <= 7) {
+ number = (number * 8) + digit;
+ if (pos <= end && ScannerHelper.isDigit(next = line[pos])) {
+ pos++;
+ if (zeroToThreeNot) {
+ // has read \NotZeroToThree OctalDigit Digit --> ignore last character
+ } else {
+ digit = ScannerHelper.getHexadecimalValue(next);
+ if (digit >= 0 && digit <= 7){ // has read \ZeroToThree OctalDigit OctalDigit
+ number = (number * 8) + digit;
+ } else {
+ // has read \ZeroToThree OctalDigit NonOctalDigit --> ignore last character
+ }
+ }
+ } else {
+ // has read \OctalDigit NonDigit--> ignore last character
+ }
+ } else {
+ // has read \OctalDigit NonOctalDigit--> ignore last character
+ }
+ } else {
+ // has read \OctalDigit --> ignore last character
+ }
+ } catch (InvalidInputException e) {
+ // Unlikely as this has already been processed in scanForStringLiteral()
+ }
+ if (number < 255) {
+ next = (char) number;
+ }
+ result.append(next);
+ lastPointer = i = pos;
+ continue;
+ } else {
+ // Dealing with just '\'
+ result.append(c);
+ lastPointer = i;
+ continue;
+ }
+ }
+ lastPointer = ++i;
+ }
+ }
+ end = merge ? end : end >= line.length ? end : end + 1;
+ char[] chars = lastPointer == 0 ?
+ CharOperation.subarray(line, start, end) :
+ CharOperation.subarray(line, lastPointer, end);
+ // The below check is because CharOperation.subarray tend to return null when the
+ // boundaries produce a zero sized char[]
+ if (chars != null && chars.length > 0)
+ result.append(chars);
+ return (!merge && !lastLine);
+ }
+ /**
+ * Converts the given string content into separate lines by
+ *
+ * - Normalizing all the CR and CRLT to LF
+ * - Split them with LF as delimiters
+ *
+ * @param all
+ * @return an array or lines, each line represented by char[]
+ */
+ public static char[][] convertTextBlockToLines(char[] all) {
+ // 1. Normalize, i.e. convert all CR CRLF to LF
+ all = normalize(all);
+ // 2. Split into lines. Consider both \n and \r as line separators
+ char[][] lines = CharOperation.splitOn('\n', all);
+ int size = lines.length;
+ List list = new ArrayList<>(lines.length);
+ for(int i = 0; i < lines.length; i++) {
+ char[] line = lines[i];
+ if (i + 1 == size && line.length == 0) {
+ list.add(line);
+ break;
+ }
+ char[][] sub = CharOperation.splitOn('\r', line);
+ if (sub.length == 0) {
+ list.add(line);
+ } else {
+ for (char[] cs : sub) {
+ list.add(cs);
+ }
+ }
+ }
+ size = list.size();
+ lines = list.toArray(new char[size][]);
+ return lines;
+ }
+ /**
+ * Computes the common whitespace prefix of the given set of lines
+ * and returns. Only non empty lines, except the last line, are
+ * considered for this.
+ *
+ * @param lines
+ * @return the common whitespace prefix
+ */
+ public static int getWhitespacePrefix(char[][] lines) {
+ int prefix = -1;
+ int size = lines.length;
+ for(int i = 0; i < size; i++) {
+ char[] line = lines[i];
+ boolean blank = true;
+ int whitespaces = 0;
+ for (char c : line) {
+ if (blank) {
+ if (ScannerHelper.isWhitespace(c)) {
+ whitespaces++;
+ } else {
+ blank = false;
+ }
+ }
+ }
+ // The last line with closing delimiter is part of the
+ // determining line list even if empty
+ if (!blank || (i+1 == size)) {
+ if (prefix < 0 || whitespaces < prefix) {
+ prefix = whitespaces;
+ }
+ }
+ }
+ return prefix == -1 ? 0 : prefix;
+ }
+
+ public static char[] formatTextBlock(char[][] lines, int indent) {
+ return formatTextBlock(lines, indent, false, false);
+ }
+ public static char[] formatTextBlock(char[][] lines, int indent, boolean followsExp, boolean precedesExp) {
+ // Handle incidental white space
+ // Split into lines and identify determining lines
+ // Remove the common white space prefix
+ // Handle escape sequences that are not already done in getNextToken0()
+ int size = lines.length;
+ StringBuilder result = new StringBuilder();
+ boolean newLine = false;
+ for(int i = 0; i < size; i++) {
+ if (i > 0)
+ followsExp = false;
+ char[] l = lines[i];
+ int length = l.length;
+ int prefix = followsExp ? 0 : indent;
+ // Remove the common prefix from each line
+ // And remove all trailing whitespace
+ // Finally append the \n at the end of the line (except the last line)
+ int trail = length;
+ // Only the last line is really prefixed to the embedded
+ // expression in a string template
+ if (!precedesExp || i < (size -1)) {
+ for(;trail > 0;) {
+ if (!ScannerHelper.isWhitespace(l[trail-1])) {
+ break;
+ }
+ trail--;
+ }
+ }
+ if (i >= (size -1)) {
+ if (newLine) result.append('\n');
+ if (trail < prefix)
+ continue;
+ newLine = getLineContent(result, l, prefix, trail-1, false, true);
+ } else {
+ if (i > 0 && newLine)
+ result.append('\n');
+ if (trail <= prefix) {
+ newLine = true;
+ } else {
+ boolean merge = length > 0 && l[length - 1] == '\\';
+ newLine = getLineContent(result, l, prefix, trail-1, merge, false);
+ }
+ }
+ }
+ return result.toString().toCharArray();
+ }
+}
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/Util.java b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/Util.java
index 4e2281fd30..40f106f11f 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/Util.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/Util.java
@@ -35,7 +35,6 @@
import java.util.StringTokenizer;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ClassFile;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder.mockcompiler/.settings/org.eclipse.jdt.ui.prefs b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder.mockcompiler/.settings/org.eclipse.jdt.ui.prefs
index ab1a682988..240c95e1a7 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder.mockcompiler/.settings/org.eclipse.jdt.ui.prefs
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder.mockcompiler/.settings/org.eclipse.jdt.ui.prefs
@@ -1,5 +1,10 @@
eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+org.eclipse.jdt.ui.ignorelowercasenames=true
+org.eclipse.jdt.ui.importorder=
+org.eclipse.jdt.ui.ondemandthreshold=10
+org.eclipse.jdt.ui.staticondemandthreshold=10
+sp_cleanup.add_all=false
sp_cleanup.add_default_serial_version_id=true
sp_cleanup.add_generated_serial_version_id=false
sp_cleanup.add_missing_annotations=false
@@ -9,30 +14,79 @@ sp_cleanup.add_missing_nls_tags=false
sp_cleanup.add_missing_override_annotations=true
sp_cleanup.add_missing_override_annotations_interface_methods=true
sp_cleanup.add_serial_version_id=false
+sp_cleanup.also_simplify_lambda=false
sp_cleanup.always_use_blocks=true
sp_cleanup.always_use_parentheses_in_expressions=false
sp_cleanup.always_use_this_for_non_static_field_access=false
sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.array_with_curly=false
+sp_cleanup.arrays_fill=false
+sp_cleanup.bitwise_conditional_expression=false
+sp_cleanup.boolean_literal=false
+sp_cleanup.boolean_value_rather_than_comparison=false
+sp_cleanup.break_loop=false
+sp_cleanup.collection_cloning=false
+sp_cleanup.comparing_on_criteria=false
+sp_cleanup.comparison_statement=false
+sp_cleanup.controlflow_merge=false
sp_cleanup.convert_functional_interfaces=false
sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.convert_to_enhanced_for_loop_if_loop_var_used=false
+sp_cleanup.convert_to_switch_expressions=false
sp_cleanup.correct_indentation=false
+sp_cleanup.do_while_rather_than_while=false
+sp_cleanup.double_negation=false
+sp_cleanup.else_if=false
+sp_cleanup.embedded_if=false
+sp_cleanup.evaluate_nullable=false
+sp_cleanup.extract_increment=false
sp_cleanup.format_source_code=false
sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.hash=false
+sp_cleanup.if_condition=false
sp_cleanup.insert_inferred_type_arguments=false
+sp_cleanup.instanceof=false
+sp_cleanup.instanceof_keyword=false
+sp_cleanup.invert_equals=false
+sp_cleanup.join=false
+sp_cleanup.lazy_logical_operator=false
sp_cleanup.make_local_variable_final=false
sp_cleanup.make_parameters_final=false
sp_cleanup.make_private_fields_final=true
sp_cleanup.make_type_abstract_if_missing_method=false
sp_cleanup.make_variable_declarations_final=false
+sp_cleanup.map_cloning=false
+sp_cleanup.merge_conditional_blocks=false
+sp_cleanup.multi_catch=false
sp_cleanup.never_use_blocks=false
sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.no_string_creation=false
+sp_cleanup.no_super=false
+sp_cleanup.number_suffix=false
+sp_cleanup.objects_equals=false
sp_cleanup.on_save_use_additional_actions=true
-sp_cleanup.organize_imports=false
+sp_cleanup.one_if_rather_than_duplicate_blocks_that_fall_through=false
+sp_cleanup.operand_factorization=false
+sp_cleanup.organize_imports=true
+sp_cleanup.overridden_assignment=false
+sp_cleanup.overridden_assignment_move_decl=false
+sp_cleanup.plain_replacement=false
+sp_cleanup.precompile_regex=false
+sp_cleanup.primitive_comparison=false
+sp_cleanup.primitive_parsing=false
+sp_cleanup.primitive_rather_than_wrapper=false
+sp_cleanup.primitive_serialization=false
+sp_cleanup.pull_out_if_from_if_else=false
+sp_cleanup.pull_up_assignment=false
+sp_cleanup.push_down_negation=false
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.reduce_indentation=false
+sp_cleanup.redundant_comparator=false
+sp_cleanup.redundant_falling_through_block_end=false
sp_cleanup.remove_private_constructors=true
sp_cleanup.remove_redundant_modifiers=false
sp_cleanup.remove_redundant_semicolons=true
@@ -40,23 +94,60 @@ sp_cleanup.remove_redundant_type_arguments=true
sp_cleanup.remove_trailing_whitespaces=true
sp_cleanup.remove_trailing_whitespaces_all=true
sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_array_creation=false
sp_cleanup.remove_unnecessary_casts=true
sp_cleanup.remove_unnecessary_nls_tags=true
sp_cleanup.remove_unused_imports=true
sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_method_parameters=false
sp_cleanup.remove_unused_private_fields=true
sp_cleanup.remove_unused_private_members=false
sp_cleanup.remove_unused_private_methods=true
sp_cleanup.remove_unused_private_types=true
+sp_cleanup.replace_deprecated_calls=false
+sp_cleanup.return_expression=false
+sp_cleanup.simplify_boolean_if_else=false
+sp_cleanup.simplify_lambda_expression_and_method_ref=false
+sp_cleanup.single_used_field=false
sp_cleanup.sort_members=false
sp_cleanup.sort_members_all=false
+sp_cleanup.standard_comparison=false
+sp_cleanup.static_inner_class=false
+sp_cleanup.strictly_equal_or_different=false
+sp_cleanup.stringbuffer_to_stringbuilder=false
+sp_cleanup.stringbuilder=false
+sp_cleanup.stringbuilder_for_local_vars=false
+sp_cleanup.stringconcat_stringbuffer_stringbuilder=false
+sp_cleanup.stringconcat_to_textblock=false
+sp_cleanup.substring=false
+sp_cleanup.switch=false
+sp_cleanup.system_property=false
+sp_cleanup.system_property_boolean=false
+sp_cleanup.system_property_file_encoding=false
+sp_cleanup.system_property_file_separator=false
+sp_cleanup.system_property_javaspecversion=false
+sp_cleanup.system_property_javaversion=false
+sp_cleanup.system_property_line_separator=false
+sp_cleanup.system_property_path_separator=false
+sp_cleanup.ternary_operator=false
+sp_cleanup.try_with_resource=false
+sp_cleanup.unlooped_while=false
+sp_cleanup.unreachable_block=false
sp_cleanup.update_ibm_copyright_to_current_year=true
sp_cleanup.use_anonymous_class_creation=false
+sp_cleanup.use_autoboxing=false
sp_cleanup.use_blocks=false
sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_directly_map_method=false
sp_cleanup.use_lambda=false
sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_string_is_blank=false
sp_cleanup.use_this_for_non_static_field_access=false
sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
sp_cleanup.use_this_for_non_static_method_access=false
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
+sp_cleanup.use_unboxing=false
+sp_cleanup.use_var=false
+sp_cleanup.useless_continue=false
+sp_cleanup.useless_return=false
+sp_cleanup.valueof_rather_than_instantiation=false
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder.mockcompiler/META-INF/MANIFEST.MF b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder.mockcompiler/META-INF/MANIFEST.MF
index 802d4f8c7e..41ecd36247 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder.mockcompiler/META-INF/MANIFEST.MF
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder.mockcompiler/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.core.tests.builder.mockcompiler; singleton:=true
-Bundle-Version: 1.0.0.qualifier
+Bundle-Version: 1.0.100.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Fragment-Host: org.eclipse.jdt.core
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder.mockcompiler/pom.xml b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder.mockcompiler/pom.xml
index f0f232d05d..f593853f66 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder.mockcompiler/pom.xml
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder.mockcompiler/pom.xml
@@ -20,6 +20,6 @@
../tests-pom/
org.eclipse.jdt.core.tests.builder.mockcompiler
- 1.0.0-SNAPSHOT
+ 1.0.100-SNAPSHOT
eclipse-plugin
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder.mockcompiler/src/org/eclipse/jdt/core/tests/builder/mockcompiler/MockCompilerFactory.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder.mockcompiler/src/org/eclipse/jdt/core/tests/builder/mockcompiler/MockCompilerFactory.java
index e72e2d34b0..ac5fb40d72 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder.mockcompiler/src/org/eclipse/jdt/core/tests/builder/mockcompiler/MockCompilerFactory.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder.mockcompiler/src/org/eclipse/jdt/core/tests/builder/mockcompiler/MockCompilerFactory.java
@@ -16,7 +16,6 @@
import java.util.HashSet;
import java.util.Set;
import java.util.function.Consumer;
-
import org.eclipse.jdt.core.compiler.CategorizedProblem;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.Compiler;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/.settings/org.eclipse.jdt.ui.prefs b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/.settings/org.eclipse.jdt.ui.prefs
index ab1a682988..240c95e1a7 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/.settings/org.eclipse.jdt.ui.prefs
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/.settings/org.eclipse.jdt.ui.prefs
@@ -1,5 +1,10 @@
eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+org.eclipse.jdt.ui.ignorelowercasenames=true
+org.eclipse.jdt.ui.importorder=
+org.eclipse.jdt.ui.ondemandthreshold=10
+org.eclipse.jdt.ui.staticondemandthreshold=10
+sp_cleanup.add_all=false
sp_cleanup.add_default_serial_version_id=true
sp_cleanup.add_generated_serial_version_id=false
sp_cleanup.add_missing_annotations=false
@@ -9,30 +14,79 @@ sp_cleanup.add_missing_nls_tags=false
sp_cleanup.add_missing_override_annotations=true
sp_cleanup.add_missing_override_annotations_interface_methods=true
sp_cleanup.add_serial_version_id=false
+sp_cleanup.also_simplify_lambda=false
sp_cleanup.always_use_blocks=true
sp_cleanup.always_use_parentheses_in_expressions=false
sp_cleanup.always_use_this_for_non_static_field_access=false
sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.array_with_curly=false
+sp_cleanup.arrays_fill=false
+sp_cleanup.bitwise_conditional_expression=false
+sp_cleanup.boolean_literal=false
+sp_cleanup.boolean_value_rather_than_comparison=false
+sp_cleanup.break_loop=false
+sp_cleanup.collection_cloning=false
+sp_cleanup.comparing_on_criteria=false
+sp_cleanup.comparison_statement=false
+sp_cleanup.controlflow_merge=false
sp_cleanup.convert_functional_interfaces=false
sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.convert_to_enhanced_for_loop_if_loop_var_used=false
+sp_cleanup.convert_to_switch_expressions=false
sp_cleanup.correct_indentation=false
+sp_cleanup.do_while_rather_than_while=false
+sp_cleanup.double_negation=false
+sp_cleanup.else_if=false
+sp_cleanup.embedded_if=false
+sp_cleanup.evaluate_nullable=false
+sp_cleanup.extract_increment=false
sp_cleanup.format_source_code=false
sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.hash=false
+sp_cleanup.if_condition=false
sp_cleanup.insert_inferred_type_arguments=false
+sp_cleanup.instanceof=false
+sp_cleanup.instanceof_keyword=false
+sp_cleanup.invert_equals=false
+sp_cleanup.join=false
+sp_cleanup.lazy_logical_operator=false
sp_cleanup.make_local_variable_final=false
sp_cleanup.make_parameters_final=false
sp_cleanup.make_private_fields_final=true
sp_cleanup.make_type_abstract_if_missing_method=false
sp_cleanup.make_variable_declarations_final=false
+sp_cleanup.map_cloning=false
+sp_cleanup.merge_conditional_blocks=false
+sp_cleanup.multi_catch=false
sp_cleanup.never_use_blocks=false
sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.no_string_creation=false
+sp_cleanup.no_super=false
+sp_cleanup.number_suffix=false
+sp_cleanup.objects_equals=false
sp_cleanup.on_save_use_additional_actions=true
-sp_cleanup.organize_imports=false
+sp_cleanup.one_if_rather_than_duplicate_blocks_that_fall_through=false
+sp_cleanup.operand_factorization=false
+sp_cleanup.organize_imports=true
+sp_cleanup.overridden_assignment=false
+sp_cleanup.overridden_assignment_move_decl=false
+sp_cleanup.plain_replacement=false
+sp_cleanup.precompile_regex=false
+sp_cleanup.primitive_comparison=false
+sp_cleanup.primitive_parsing=false
+sp_cleanup.primitive_rather_than_wrapper=false
+sp_cleanup.primitive_serialization=false
+sp_cleanup.pull_out_if_from_if_else=false
+sp_cleanup.pull_up_assignment=false
+sp_cleanup.push_down_negation=false
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.reduce_indentation=false
+sp_cleanup.redundant_comparator=false
+sp_cleanup.redundant_falling_through_block_end=false
sp_cleanup.remove_private_constructors=true
sp_cleanup.remove_redundant_modifiers=false
sp_cleanup.remove_redundant_semicolons=true
@@ -40,23 +94,60 @@ sp_cleanup.remove_redundant_type_arguments=true
sp_cleanup.remove_trailing_whitespaces=true
sp_cleanup.remove_trailing_whitespaces_all=true
sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_array_creation=false
sp_cleanup.remove_unnecessary_casts=true
sp_cleanup.remove_unnecessary_nls_tags=true
sp_cleanup.remove_unused_imports=true
sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_method_parameters=false
sp_cleanup.remove_unused_private_fields=true
sp_cleanup.remove_unused_private_members=false
sp_cleanup.remove_unused_private_methods=true
sp_cleanup.remove_unused_private_types=true
+sp_cleanup.replace_deprecated_calls=false
+sp_cleanup.return_expression=false
+sp_cleanup.simplify_boolean_if_else=false
+sp_cleanup.simplify_lambda_expression_and_method_ref=false
+sp_cleanup.single_used_field=false
sp_cleanup.sort_members=false
sp_cleanup.sort_members_all=false
+sp_cleanup.standard_comparison=false
+sp_cleanup.static_inner_class=false
+sp_cleanup.strictly_equal_or_different=false
+sp_cleanup.stringbuffer_to_stringbuilder=false
+sp_cleanup.stringbuilder=false
+sp_cleanup.stringbuilder_for_local_vars=false
+sp_cleanup.stringconcat_stringbuffer_stringbuilder=false
+sp_cleanup.stringconcat_to_textblock=false
+sp_cleanup.substring=false
+sp_cleanup.switch=false
+sp_cleanup.system_property=false
+sp_cleanup.system_property_boolean=false
+sp_cleanup.system_property_file_encoding=false
+sp_cleanup.system_property_file_separator=false
+sp_cleanup.system_property_javaspecversion=false
+sp_cleanup.system_property_javaversion=false
+sp_cleanup.system_property_line_separator=false
+sp_cleanup.system_property_path_separator=false
+sp_cleanup.ternary_operator=false
+sp_cleanup.try_with_resource=false
+sp_cleanup.unlooped_while=false
+sp_cleanup.unreachable_block=false
sp_cleanup.update_ibm_copyright_to_current_year=true
sp_cleanup.use_anonymous_class_creation=false
+sp_cleanup.use_autoboxing=false
sp_cleanup.use_blocks=false
sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_directly_map_method=false
sp_cleanup.use_lambda=false
sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_string_is_blank=false
sp_cleanup.use_this_for_non_static_field_access=false
sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
sp_cleanup.use_this_for_non_static_method_access=false
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
+sp_cleanup.use_unboxing=false
+sp_cleanup.use_var=false
+sp_cleanup.useless_continue=false
+sp_cleanup.useless_return=false
+sp_cleanup.valueof_rather_than_instantiation=false
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/META-INF/MANIFEST.MF b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/META-INF/MANIFEST.MF
index 44d87654e4..36d181b9c7 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/META-INF/MANIFEST.MF
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/META-INF/MANIFEST.MF
@@ -14,7 +14,6 @@ Require-Bundle: org.junit;bundle-version="3.8.1",
org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)",
org.eclipse.test;bundle-version="[3.6.0,4.0.0)",
org.eclipse.test.performance;bundle-version="[3.1.0,4.0.0)",
- org.eclipse.jdt.annotation;bundle-version="[1.1.0,2.0.0)";resolution:=optional,
org.eclipse.jdt.annotation;bundle-version="[2.0.0,3.0.0)";resolution:=optional
Bundle-RequiredExecutionEnvironment: JavaSE-17
Eclipse-BundleShape: dir
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AbstractLeakTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AbstractLeakTest.java
index 9aa043fd8b..ac77bf7edf 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AbstractLeakTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AbstractLeakTest.java
@@ -25,7 +25,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AbstractMethodTests.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AbstractMethodTests.java
index 8b9ae5ba9c..e371d1adde 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AbstractMethodTests.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AbstractMethodTests.java
@@ -19,9 +19,7 @@
import java.io.StringWriter;
import java.util.Arrays;
import java.util.Comparator;
-
-import junit.framework.*;
-
+import junit.framework.Test;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AnnotationDependencyTests.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AnnotationDependencyTests.java
index 83fb8ea450..b4da162ae7 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AnnotationDependencyTests.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AnnotationDependencyTests.java
@@ -17,22 +17,19 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.builder;
-import java.io.File;
+import java.io.IOException;
import junit.framework.Test;
-
import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.compiler.CategorizedProblem;
+import org.eclipse.jdt.core.tests.compiler.regression.AbstractNullAnnotationTest;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-import org.osgi.framework.Bundle;
/**
* Tests to verify that annotation changes cause recompilation of dependent types.
@@ -145,17 +142,19 @@ private void addAnnotationType() {
void setupProjectForNullAnnotations() throws JavaModelException {
// add the org.eclipse.jdt.annotation library (bin/ folder or jar) to the project:
- Bundle[] bundles = Platform.getBundles("org.eclipse.jdt.annotation","[1.1.0,2.0.0)");
- File bundleFile = FileLocator.getBundleFileLocation(bundles[0]).get();
- String annotationsLib = bundleFile.isDirectory() ? bundleFile.getPath()+"/bin" : bundleFile.getPath();
- IJavaProject javaProject = env.getJavaProject(this.projectPath);
- IClasspathEntry[] rawClasspath = javaProject.getRawClasspath();
- int len = rawClasspath.length;
- System.arraycopy(rawClasspath, 0, rawClasspath = new IClasspathEntry[len+1], 0, len);
- rawClasspath[len] = JavaCore.newLibraryEntry(new Path(annotationsLib), null, null);
- javaProject.setRawClasspath(rawClasspath, null);
-
- javaProject.setOption(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED);
+ try {
+ String annotationsLib = AbstractNullAnnotationTest.getAnnotationV1LibPath();
+ IJavaProject javaProject = env.getJavaProject(this.projectPath);
+ IClasspathEntry[] rawClasspath = javaProject.getRawClasspath();
+ int len = rawClasspath.length;
+ System.arraycopy(rawClasspath, 0, rawClasspath = new IClasspathEntry[len+1], 0, len);
+ rawClasspath[len] = JavaCore.newLibraryEntry(new Path(annotationsLib), null, null);
+ javaProject.setRawClasspath(rawClasspath, null);
+
+ javaProject.setOption(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED);
+ } catch (IOException ioe) {
+ throw new JavaModelException(ioe, -13);
+ }
}
/**
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BasicBuildTests.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BasicBuildTests.java
index 031337dc67..5f3528b4d9 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BasicBuildTests.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BasicBuildTests.java
@@ -30,9 +30,7 @@
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
-
-import junit.framework.*;
-
+import junit.framework.Test;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
@@ -49,10 +47,10 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.compiler.CategorizedProblem;
import org.eclipse.jdt.core.tests.builder.mockcompiler.MockCompilerFactory;
import org.eclipse.jdt.core.tests.builder.mockcompiler.MockCompilerFactory.MockCompiler;
import org.eclipse.jdt.core.tests.util.Util;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug530366Test.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug530366Test.java
index 2ce83f0666..6b3325d86b 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug530366Test.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug530366Test.java
@@ -18,7 +18,7 @@
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Paths;
-
+import junit.framework.Test;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
@@ -26,7 +26,6 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.compiler.CategorizedProblem;
import org.eclipse.jdt.core.tests.util.Util;
-import junit.framework.Test;
public class Bug530366Test extends BuilderTests {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug531382Test.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug531382Test.java
index bdb1edb261..44b52cd1a0 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug531382Test.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug531382Test.java
@@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.builder;
+import junit.framework.Test;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.CoreException;
@@ -25,8 +26,6 @@
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.core.builder.AbstractImageBuilder;
-import junit.framework.Test;
-
public class Bug531382Test extends BuilderTests {
private IPath project;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug544921Test.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug544921Test.java
index 5ffa764741..cdbec202be 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug544921Test.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug544921Test.java
@@ -13,12 +13,11 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.builder;
+import junit.framework.Test;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.tests.util.Util;
-import junit.framework.Test;
-
public class Bug544921Test extends BuilderTests {
public Bug544921Test(String name) {
super(name);
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug549457Test.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug549457Test.java
index 2f3b1c1e7a..9bcca265af 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug549457Test.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug549457Test.java
@@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.builder;
+import junit.framework.Test;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
@@ -28,8 +29,6 @@
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.core.JavaProject;
-import junit.framework.Test;
-
public class Bug549457Test extends BuilderTests {
private IPath project;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug549646Test.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug549646Test.java
index f661339d08..9d1461bcd7 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug549646Test.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug549646Test.java
@@ -13,14 +13,13 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.builder;
+import junit.framework.Test;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-import junit.framework.Test;
-
public class Bug549646Test extends BuilderTests {
public Bug549646Test(String name) {
super(name);
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug561287Test.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug561287Test.java
index 5a167f18e2..81aba321df 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug561287Test.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug561287Test.java
@@ -13,14 +13,13 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.builder;
+import junit.framework.Test;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.core.builder.AbstractImageBuilder;
-import junit.framework.Test;
-
public class Bug561287Test extends BuilderTests {
public Bug561287Test(String name) {
super(name);
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug562420Test.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug562420Test.java
index 7756442520..4943aaf11a 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug562420Test.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug562420Test.java
@@ -14,6 +14,7 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.builder;
+import junit.framework.Test;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
@@ -21,8 +22,6 @@
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-import junit.framework.Test;
-
public class Bug562420Test extends BuilderTests {
public Bug562420Test(String name) {
super(name);
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug564905Test.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug564905Test.java
index abfb2346ff..a55a0af225 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug564905Test.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug564905Test.java
@@ -21,7 +21,7 @@
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
-
+import junit.framework.Test;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -33,7 +33,6 @@
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.tests.util.Util;
-import junit.framework.Test;
public class Bug564905Test extends BuilderTests {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug571363Test.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug571363Test.java
index 726fb39c47..ab8079b1aa 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug571363Test.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug571363Test.java
@@ -16,14 +16,13 @@
import java.io.File;
import java.io.IOException;
import java.net.URL;
-
+import junit.framework.Test;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.tests.util.Util;
-import junit.framework.Test;
public class Bug571363Test extends BuilderTests {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java
index 4bd8a4c557..d6f72bbd9d 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java
@@ -13,7 +13,9 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.builder;
-import static org.eclipse.jdt.core.tests.util.AbstractCompilerTest.*;
+import static org.eclipse.jdt.core.tests.util.AbstractCompilerTest.F_12;
+import static org.eclipse.jdt.core.tests.util.AbstractCompilerTest.F_9;
+import static org.eclipse.jdt.core.tests.util.AbstractCompilerTest.getPossibleComplianceLevels;
import java.io.FileInputStream;
import java.io.IOException;
@@ -25,6 +27,8 @@
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.List;
+import junit.framework.Test;
+import junit.framework.TestSuite;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.IClasspathEntry;
@@ -37,9 +41,6 @@
import org.eclipse.jdt.internal.compiler.Compiler;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
/**
* Base class for Java image builder tests
*/
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests11.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests11.java
index 3586462d05..8609adcd37 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests11.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests11.java
@@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.builder;
+import junit.framework.Test;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
@@ -20,8 +21,6 @@
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import junit.framework.Test;
-
/**
* Test tries to compile trivial snippet with --release option on Java 11 as host
*/
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuildpathTests.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuildpathTests.java
index 69fcced568..bc9b6bf4d5 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuildpathTests.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuildpathTests.java
@@ -20,7 +20,7 @@
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
-
+import junit.framework.Test;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -40,8 +40,6 @@
import org.eclipse.jdt.internal.core.JavaModelManager;
import org.eclipse.jdt.internal.core.JavaProject;
-import junit.framework.Test;
-
@SuppressWarnings({"unchecked", "rawtypes"})
public class BuildpathTests extends BuilderTests {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/CompressedWriterTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/CompressedWriterTest.java
index 0188e5670f..01b5d078a6 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/CompressedWriterTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/CompressedWriterTest.java
@@ -18,12 +18,10 @@
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.util.Arrays;
-
+import junit.framework.Test;
import org.eclipse.jdt.internal.core.builder.CompressedReader;
import org.eclipse.jdt.internal.core.builder.CompressedWriter;
-import junit.framework.Test;
-
public class CompressedWriterTest extends BuilderTests {
private CompressedWriter writer;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/CopyResourceTests.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/CopyResourceTests.java
index 58d2a067f3..1fe4c16962 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/CopyResourceTests.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/CopyResourceTests.java
@@ -13,7 +13,7 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.builder;
-import junit.framework.*;
+import junit.framework.Test;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.tests.util.Util;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/DependencyTests.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/DependencyTests.java
index 1afd8bec1f..9034e70d83 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/DependencyTests.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/DependencyTests.java
@@ -14,7 +14,6 @@
package org.eclipse.jdt.core.tests.builder;
import junit.framework.Test;
-
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/EfficiencyTests.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/EfficiencyTests.java
index 02237c6eae..ef22d6fe6c 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/EfficiencyTests.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/EfficiencyTests.java
@@ -13,7 +13,7 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.builder;
-import junit.framework.*;
+import junit.framework.Test;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.tests.util.Util;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ErrorsTests.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ErrorsTests.java
index 2bca1e0cb1..573208511a 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ErrorsTests.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ErrorsTests.java
@@ -21,9 +21,7 @@
import java.util.Arrays;
import java.util.Comparator;
import java.util.Hashtable;
-
import junit.framework.Test;
-
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ExecutionTests.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ExecutionTests.java
index 0cc33c5ca5..23a06cfeac 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ExecutionTests.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ExecutionTests.java
@@ -13,7 +13,7 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.builder;
-import junit.framework.*;
+import junit.framework.Test;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.tests.util.Util;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/FriendDependencyTests.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/FriendDependencyTests.java
index 0f8cdc472a..6a3887f97d 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/FriendDependencyTests.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/FriendDependencyTests.java
@@ -13,10 +13,8 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.builder;
-import junit.framework.Test;
-
import java.util.Map;
-
+import junit.framework.Test;
import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable;
import org.eclipse.jdt.internal.core.JavaModelManager;
import org.eclipse.jdt.internal.core.builder.ReferenceCollection;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/GetResourcesTests.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/GetResourcesTests.java
index 4d96d4921c..8560fd60a1 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/GetResourcesTests.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/GetResourcesTests.java
@@ -17,7 +17,6 @@
import java.io.StringWriter;
import java.util.Arrays;
import java.util.Comparator;
-
import junit.framework.Test;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/IncrementalTests.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/IncrementalTests.java
index 1e728adad9..b6b56c6550 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/IncrementalTests.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/IncrementalTests.java
@@ -14,9 +14,7 @@
package org.eclipse.jdt.core.tests.builder;
import java.util.Hashtable;
-
import junit.framework.Test;
-
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
@@ -1666,4 +1664,65 @@ public final class Child extends Parent {
env.removeProject(projectPath);
}
+ public void testExhaustiveness() throws JavaModelException {
+ String javaVersion = System.getProperty("java.version");
+ if (javaVersion != null && JavaCore.compareJavaVersions(javaVersion, "18") < 0)
+ return;
+
+ IPath projectPath = env.addProject("Project", "18");
+ env.addExternalJars(projectPath, Util.getJavaClassLibs());
+
+ // remove old package fragment root so that names don't collide
+ env.removePackageFragmentRoot(projectPath, "");
+
+ IPath root = env.addPackageFragmentRoot(projectPath, "src");
+ env.setOutputFolder(projectPath, "bin");
+
+ IPath pathToX = env.addClass(root, "", "X",
+ """
+ public class X {
+
+ public static void main(String[] args) {
+ E e = E.getE();
+
+ String s = switch (e) {
+ case A -> "A";
+ case B -> "B";
+ case C -> "C";
+ };
+ System.out.println(s);
+ }
+ }
+ """);
+
+ env.addClass(root, "", "E",
+ """
+ public enum E {
+ A, B, C;
+ static E getE() {
+ return C;
+ }
+ }
+ """);
+
+ fullBuild(projectPath);
+ expectingNoProblems();
+ executeClass(projectPath, "X", "C", "");
+
+ env.addClass(root, "", "E",
+ """
+ public enum E {
+ A, B, C, D;
+ static E getE() {
+ return D;
+ }
+ }
+ """);
+
+
+ incrementalBuild(projectPath);
+ expectingSpecificProblemFor(pathToX, new Problem("E", "A Switch expression should cover all possible values", pathToX, 100, 101, CategorizedProblem.CAT_SYNTAX, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$
+ env.removeProject(projectPath);
+ }
+
}
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/IncrementalTests18.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/IncrementalTests18.java
index 49aec360d5..16cd12e0b3 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/IncrementalTests18.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/IncrementalTests18.java
@@ -15,9 +15,7 @@
import java.io.File;
import java.io.IOException;
-
import junit.framework.Test;
-
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/LeakTestsAfter9.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/LeakTestsAfter9.java
index f9c569a8bf..fe55890924 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/LeakTestsAfter9.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/LeakTestsAfter9.java
@@ -13,9 +13,8 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.builder;
-import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-
import junit.framework.Test;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
public class LeakTestsAfter9 extends AbstractLeakTest {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/LeakTestsBefore9.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/LeakTestsBefore9.java
index 05dca1ac94..1b3729486f 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/LeakTestsBefore9.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/LeakTestsBefore9.java
@@ -13,9 +13,8 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.builder;
-import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-
import junit.framework.Test;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
public class LeakTestsBefore9 extends AbstractLeakTest {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/MultiProjectTests.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/MultiProjectTests.java
index ff54e8e7e1..5539f73bec 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/MultiProjectTests.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/MultiProjectTests.java
@@ -14,7 +14,7 @@
package org.eclipse.jdt.core.tests.builder;
import java.util.Hashtable;
-
+import junit.framework.Test;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
@@ -28,8 +28,6 @@
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.test.OrderedTestSuite;
-import junit.framework.Test;
-
@SuppressWarnings({"rawtypes", "unchecked"})
public class MultiProjectTests extends BuilderTests {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/MultiSourceFolderAndOutputFolderTests.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/MultiSourceFolderAndOutputFolderTests.java
index 70a32574b9..ac2c164621 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/MultiSourceFolderAndOutputFolderTests.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/MultiSourceFolderAndOutputFolderTests.java
@@ -13,8 +13,7 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.builder;
-import junit.framework.*;
-
+import junit.framework.Test;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.JavaModelException;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/OutputFolderTests.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/OutputFolderTests.java
index 7da9c868fe..43a730327d 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/OutputFolderTests.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/OutputFolderTests.java
@@ -13,8 +13,7 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.builder;
-import junit.framework.*;
-
+import junit.framework.Test;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.tests.util.Util;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/PackageInfoTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/PackageInfoTest.java
index 76af70f3ee..ad6abd620a 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/PackageInfoTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/PackageInfoTest.java
@@ -17,9 +17,7 @@
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Arrays;
-
import junit.framework.Test;
-
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/PackageTests.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/PackageTests.java
index 693a4b3f83..21b0d842e3 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/PackageTests.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/PackageTests.java
@@ -14,9 +14,7 @@
package org.eclipse.jdt.core.tests.builder;
import java.io.File;
-
-import junit.framework.*;
-
+import junit.framework.Test;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ParticipantBuildTests.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ParticipantBuildTests.java
index bb4e9864a3..5888438fe5 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ParticipantBuildTests.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ParticipantBuildTests.java
@@ -15,16 +15,41 @@
import static org.junit.Assert.assertArrayEquals;
-import java.io.*;
-import java.util.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
import java.util.concurrent.atomic.AtomicInteger;
-import junit.framework.*;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.resources.*;
-import org.eclipse.jdt.core.*;
-import org.eclipse.jdt.core.compiler.*;
-import org.eclipse.jdt.core.dom.*;
+import junit.framework.Test;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.compiler.BuildContext;
+import org.eclipse.jdt.core.compiler.CategorizedProblem;
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.core.compiler.CompilationParticipant;
+import org.eclipse.jdt.core.compiler.IProblem;
+import org.eclipse.jdt.core.dom.AST;
+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.IAnnotationBinding;
+import org.eclipse.jdt.core.dom.IMemberValuePairBinding;
+import org.eclipse.jdt.core.dom.IMethodBinding;
+import org.eclipse.jdt.core.dom.ITypeBinding;
+import org.eclipse.jdt.core.dom.IVariableBinding;
import org.eclipse.jdt.core.tests.builder.participants.TestCompilationParticipant1;
import org.eclipse.jdt.core.tests.builder.participants.TestCompilationParticipant2;
import org.eclipse.jdt.core.tests.builder.participants.TestCompilationParticipant3;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ReferenceCollectionTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ReferenceCollectionTest.java
index 2312604e09..8e98a67663 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ReferenceCollectionTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ReferenceCollectionTest.java
@@ -18,12 +18,10 @@
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Collections;
-
+import junit.framework.Test;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.core.builder.ReferenceCollection;
-import junit.framework.Test;
-
public class ReferenceCollectionTest extends BuilderTests {
public ReferenceCollectionTest(String name) {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/StateTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/StateTest.java
index ebefc8675f..fa84e07c13 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/StateTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/StateTest.java
@@ -24,7 +24,7 @@
import java.util.Arrays;
import java.util.Map;
import java.util.Set;
-
+import junit.framework.Test;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IncrementalProjectBuilder;
@@ -47,8 +47,6 @@
import org.eclipse.jdt.internal.core.builder.ReferenceCollection;
import org.eclipse.jdt.internal.core.builder.State;
-import junit.framework.Test;
-
public class StateTest extends BuilderTests {
public StateTest(String name) {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/StaticFinalTests.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/StaticFinalTests.java
index 7a6f77556a..54a74bb68d 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/StaticFinalTests.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/StaticFinalTests.java
@@ -13,7 +13,7 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.builder;
-import junit.framework.*;
+import junit.framework.Test;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.tests.util.Util;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/TestAttributeBuilderTests.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/TestAttributeBuilderTests.java
index e05cb78d6c..23d1a0a8ca 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/TestAttributeBuilderTests.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/TestAttributeBuilderTests.java
@@ -14,12 +14,11 @@
package org.eclipse.jdt.core.tests.builder;
import java.util.HashMap;
-
+import junit.framework.Test;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.tests.util.Util;
-import junit.framework.Test;
public class TestAttributeBuilderTests extends BuilderTests {
static {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java
index b1315d77b9..d2f0a434ae 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java
@@ -13,23 +13,39 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.builder;
+import java.io.File;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.jobs.Job;
-
-import org.eclipse.jdt.core.*;
+import org.eclipse.jdt.core.IAccessRule;
+import org.eclipse.jdt.core.IClasspathAttribute;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaModelMarker;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
import org.eclipse.jdt.core.tests.util.Util;
-
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.core.ClasspathEntry;
import org.eclipse.jdt.internal.core.JavaModelManager;
import org.eclipse.jdt.internal.core.JavaProject;
-import java.io.*;
-import java.nio.charset.StandardCharsets;
-import java.util.*;
-
public class TestingEnvironment {
private boolean isOpen = false;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/participants/ParticipantBase.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/participants/ParticipantBase.java
index 44619e08a9..1a2a2950c0 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/participants/ParticipantBase.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/participants/ParticipantBase.java
@@ -15,7 +15,6 @@
import java.io.ByteArrayInputStream;
import java.util.Optional;
-
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.compiler.BuildContext;
import org.eclipse.jdt.core.compiler.CompilationParticipant;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/participants/TestCompilationParticipant1.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/participants/TestCompilationParticipant1.java
index 7cde1983ba..564edcfa99 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/participants/TestCompilationParticipant1.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/participants/TestCompilationParticipant1.java
@@ -13,7 +13,7 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.builder.participants;
-import org.eclipse.jdt.core.compiler.*;
+import org.eclipse.jdt.core.compiler.CompilationParticipant;
/**
* Participant that depends on {@link TestCompilationParticipant3}
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/participants/TestCompilationParticipant2.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/participants/TestCompilationParticipant2.java
index 352cf0e75f..249feb1181 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/participants/TestCompilationParticipant2.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/participants/TestCompilationParticipant2.java
@@ -13,7 +13,7 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.builder.participants;
-import org.eclipse.jdt.core.compiler.*;
+import org.eclipse.jdt.core.compiler.CompilationParticipant;
/**
* Participant without dependency on other participants
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/participants/TestCompilationParticipant3.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/participants/TestCompilationParticipant3.java
index 8a646f3334..49bb64a5d6 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/participants/TestCompilationParticipant3.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/participants/TestCompilationParticipant3.java
@@ -13,7 +13,7 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.builder.participants;
-import org.eclipse.jdt.core.compiler.*;
+import org.eclipse.jdt.core.compiler.CompilationParticipant;
/**
* Participant that depends on {@link TestCompilationParticipant2}
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/.settings/org.eclipse.jdt.ui.prefs b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/.settings/org.eclipse.jdt.ui.prefs
index cc05ab3605..abebd98cc6 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/.settings/org.eclipse.jdt.ui.prefs
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/.settings/org.eclipse.jdt.ui.prefs
@@ -1,6 +1,10 @@
-#Thu Nov 04 13:38:45 EDT 2010
eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+org.eclipse.jdt.ui.ignorelowercasenames=true
+org.eclipse.jdt.ui.importorder=
+org.eclipse.jdt.ui.ondemandthreshold=10
+org.eclipse.jdt.ui.staticondemandthreshold=10
+sp_cleanup.add_all=false
sp_cleanup.add_default_serial_version_id=true
sp_cleanup.add_generated_serial_version_id=false
sp_cleanup.add_missing_annotations=false
@@ -10,47 +14,140 @@ sp_cleanup.add_missing_nls_tags=false
sp_cleanup.add_missing_override_annotations=true
sp_cleanup.add_missing_override_annotations_interface_methods=true
sp_cleanup.add_serial_version_id=false
+sp_cleanup.also_simplify_lambda=false
sp_cleanup.always_use_blocks=true
sp_cleanup.always_use_parentheses_in_expressions=false
sp_cleanup.always_use_this_for_non_static_field_access=false
sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.array_with_curly=false
+sp_cleanup.arrays_fill=false
+sp_cleanup.bitwise_conditional_expression=false
+sp_cleanup.boolean_literal=false
+sp_cleanup.boolean_value_rather_than_comparison=false
+sp_cleanup.break_loop=false
+sp_cleanup.collection_cloning=false
+sp_cleanup.comparing_on_criteria=false
+sp_cleanup.comparison_statement=false
+sp_cleanup.controlflow_merge=false
+sp_cleanup.convert_functional_interfaces=false
sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.convert_to_enhanced_for_loop_if_loop_var_used=false
+sp_cleanup.convert_to_switch_expressions=false
sp_cleanup.correct_indentation=false
+sp_cleanup.do_while_rather_than_while=false
+sp_cleanup.double_negation=false
+sp_cleanup.else_if=false
+sp_cleanup.embedded_if=false
+sp_cleanup.evaluate_nullable=false
+sp_cleanup.extract_increment=false
sp_cleanup.format_source_code=false
sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.hash=false
+sp_cleanup.if_condition=false
+sp_cleanup.insert_inferred_type_arguments=false
+sp_cleanup.instanceof=false
+sp_cleanup.instanceof_keyword=false
+sp_cleanup.invert_equals=false
+sp_cleanup.join=false
+sp_cleanup.lazy_logical_operator=false
sp_cleanup.make_local_variable_final=false
sp_cleanup.make_parameters_final=false
sp_cleanup.make_private_fields_final=true
sp_cleanup.make_type_abstract_if_missing_method=false
sp_cleanup.make_variable_declarations_final=false
+sp_cleanup.map_cloning=false
+sp_cleanup.merge_conditional_blocks=false
+sp_cleanup.multi_catch=false
sp_cleanup.never_use_blocks=false
sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.no_string_creation=false
+sp_cleanup.no_super=false
+sp_cleanup.number_suffix=false
+sp_cleanup.objects_equals=false
sp_cleanup.on_save_use_additional_actions=true
-sp_cleanup.organize_imports=false
+sp_cleanup.one_if_rather_than_duplicate_blocks_that_fall_through=false
+sp_cleanup.operand_factorization=false
+sp_cleanup.organize_imports=true
+sp_cleanup.overridden_assignment=false
+sp_cleanup.overridden_assignment_move_decl=false
+sp_cleanup.plain_replacement=false
+sp_cleanup.precompile_regex=false
+sp_cleanup.primitive_comparison=false
+sp_cleanup.primitive_parsing=false
+sp_cleanup.primitive_rather_than_wrapper=false
+sp_cleanup.primitive_serialization=false
+sp_cleanup.pull_out_if_from_if_else=false
+sp_cleanup.pull_up_assignment=false
+sp_cleanup.push_down_negation=false
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.reduce_indentation=false
+sp_cleanup.redundant_comparator=false
+sp_cleanup.redundant_falling_through_block_end=false
sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_redundant_modifiers=false
+sp_cleanup.remove_redundant_semicolons=false
+sp_cleanup.remove_redundant_type_arguments=false
sp_cleanup.remove_trailing_whitespaces=true
sp_cleanup.remove_trailing_whitespaces_all=true
sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_array_creation=false
sp_cleanup.remove_unnecessary_casts=false
sp_cleanup.remove_unnecessary_nls_tags=false
sp_cleanup.remove_unused_imports=false
sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_method_parameters=false
sp_cleanup.remove_unused_private_fields=true
sp_cleanup.remove_unused_private_members=false
sp_cleanup.remove_unused_private_methods=true
sp_cleanup.remove_unused_private_types=true
+sp_cleanup.replace_deprecated_calls=false
+sp_cleanup.return_expression=false
+sp_cleanup.simplify_boolean_if_else=false
+sp_cleanup.simplify_lambda_expression_and_method_ref=false
+sp_cleanup.single_used_field=false
sp_cleanup.sort_members=false
sp_cleanup.sort_members_all=false
+sp_cleanup.standard_comparison=false
+sp_cleanup.static_inner_class=false
+sp_cleanup.strictly_equal_or_different=false
+sp_cleanup.stringbuffer_to_stringbuilder=false
+sp_cleanup.stringbuilder=false
+sp_cleanup.stringbuilder_for_local_vars=false
+sp_cleanup.stringconcat_stringbuffer_stringbuilder=false
+sp_cleanup.stringconcat_to_textblock=false
+sp_cleanup.substring=false
+sp_cleanup.switch=false
+sp_cleanup.system_property=false
+sp_cleanup.system_property_boolean=false
+sp_cleanup.system_property_file_encoding=false
+sp_cleanup.system_property_file_separator=false
+sp_cleanup.system_property_javaspecversion=false
+sp_cleanup.system_property_javaversion=false
+sp_cleanup.system_property_line_separator=false
+sp_cleanup.system_property_path_separator=false
+sp_cleanup.ternary_operator=false
+sp_cleanup.try_with_resource=false
+sp_cleanup.unlooped_while=false
+sp_cleanup.unreachable_block=false
sp_cleanup.update_ibm_copyright_to_current_year=true
+sp_cleanup.use_anonymous_class_creation=false
+sp_cleanup.use_autoboxing=false
sp_cleanup.use_blocks=false
sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_directly_map_method=false
+sp_cleanup.use_lambda=false
sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_string_is_blank=false
sp_cleanup.use_this_for_non_static_field_access=false
sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
sp_cleanup.use_this_for_non_static_method_access=false
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
+sp_cleanup.use_unboxing=false
+sp_cleanup.use_var=false
+sp_cleanup.useless_continue=false
+sp_cleanup.useless_return=false
+sp_cleanup.valueof_rather_than_instantiation=false
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF
index 740a11849d..7f6c34a4b9 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF
@@ -22,7 +22,6 @@ Require-Bundle: org.junit;bundle-version="3.8.1",
org.eclipse.test;bundle-version="[3.6.0,4.0.0)",
org.eclipse.test.performance;bundle-version="[3.10.0,4.0.0)",
org.eclipse.core.resources;bundle-version="[3.21.0,4.0.0)",
- org.eclipse.jdt.annotation;bundle-version="[1.1.0,2.0.0)";resolution:=optional,
org.eclipse.jdt.annotation;bundle-version="[2.0.0,3.0.0)";resolution:=optional
Import-Package: jakarta.annotation;version="[2.1.0,3.0.0)"
Bundle-RequiredExecutionEnvironment: JavaSE-17
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/build.properties b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/build.properties
index cfa629f680..1693443f0a 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/build.properties
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/build.properties
@@ -17,7 +17,8 @@ bin.includes = test.xml,\
.,\
META-INF/,\
plugin.properties,\
- workspace/
+ workspace/,\
+ lib/org.eclipse.jdt.annotation_1.2.100.v20241001-0914.jar
source.. = src/
output.. = bin/
src.includes = about.html
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/lib/org.eclipse.jdt.annotation_1.2.100.v20241001-0914.jar b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/lib/org.eclipse.jdt.annotation_1.2.100.v20241001-0914.jar
new file mode 100644
index 0000000000..5db80bf239
Binary files /dev/null and b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/lib/org.eclipse.jdt.annotation_1.2.100.v20241001-0914.jar differ
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/CharDeduplicationTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/CharDeduplicationTest.java
index 3982827bd9..c2495f5331 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/CharDeduplicationTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/CharDeduplicationTest.java
@@ -24,12 +24,10 @@
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.LongStream;
-
-import org.eclipse.jdt.core.tests.junit.extension.TestCase;
-import org.eclipse.jdt.internal.compiler.util.CharDeduplication;
-
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.eclipse.jdt.core.tests.junit.extension.TestCase;
+import org.eclipse.jdt.internal.compiler.util.CharDeduplication;
public class CharDeduplicationTest extends TestCase {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/DeduplicationUtilTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/DeduplicationUtilTest.java
index fb914bd939..0b9e729f45 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/DeduplicationUtilTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/DeduplicationUtilTest.java
@@ -16,12 +16,10 @@
import java.util.Arrays;
import java.util.List;
import java.util.function.Supplier;
-
-import org.eclipse.jdt.core.tests.junit.extension.TestCase;
-import org.eclipse.jdt.internal.core.util.DeduplicationUtil;
-
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.eclipse.jdt.core.tests.junit.extension.TestCase;
+import org.eclipse.jdt.internal.core.util.DeduplicationUtil;
public class DeduplicationUtilTest extends TestCase {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/IrritantSetTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/IrritantSetTest.java
index 89168c741d..82cd29b871 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/IrritantSetTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/IrritantSetTest.java
@@ -13,11 +13,10 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler;
-import org.eclipse.jdt.core.tests.junit.extension.TestCase;
-import org.eclipse.jdt.internal.compiler.impl.IrritantSet;
-
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.eclipse.jdt.core.tests.junit.extension.TestCase;
+import org.eclipse.jdt.internal.compiler.impl.IrritantSet;
public class IrritantSetTest extends TestCase {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/map/CharArrayMapperTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/map/CharArrayMapperTest.java
index d977b1968a..e0fdd676c7 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/map/CharArrayMapperTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/map/CharArrayMapperTest.java
@@ -18,16 +18,14 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
-
+import junit.framework.Test;
+import junit.framework.TestSuite;
import org.eclipse.jdt.core.tests.junit.extension.TestCase;
import org.eclipse.jdt.internal.compiler.util.CharArrayHashMap;
import org.eclipse.jdt.internal.compiler.util.CharArrayMap;
import org.eclipse.jdt.internal.compiler.util.CharArrayMapper;
import org.eclipse.jdt.internal.compiler.util.CharDelegateMap;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
public class CharArrayMapperTest extends TestCase {
public CharArrayMapperTest(String testName) {
super(testName);
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractCompletionTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractCompletionTest.java
index e5c8b3d767..f8a77be0f2 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractCompletionTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractCompletionTest.java
@@ -14,14 +14,16 @@
package org.eclipse.jdt.core.tests.compiler.parser;
import java.util.Locale;
-
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
+import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.codeassist.complete.CompletionOnMemberAccess;
import org.eclipse.jdt.internal.codeassist.complete.CompletionParser;
import org.eclipse.jdt.internal.codeassist.complete.CompletionScanner;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
-import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
+import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Initializer;
@@ -32,9 +34,6 @@
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
-import org.eclipse.jdt.core.compiler.CharOperation;
-import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
-import org.eclipse.jdt.core.tests.util.Util;
public abstract class AbstractCompletionTest extends AbstractCompilerTest {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSelectionTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSelectionTest.java
index 94a796db91..269a2eac67 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSelectionTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSelectionTest.java
@@ -14,13 +14,15 @@
package org.eclipse.jdt.core.tests.compiler.parser;
import java.util.Locale;
-
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
+import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.codeassist.select.SelectionParser;
import org.eclipse.jdt.internal.codeassist.select.SelectionScanner;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
-import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
+import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Block;
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
@@ -31,9 +33,6 @@
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
-import org.eclipse.jdt.core.compiler.CharOperation;
-import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
-import org.eclipse.jdt.core.tests.util.Util;
public abstract class AbstractSelectionTest extends AbstractCompilerTest {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSyntaxTreeTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSyntaxTreeTest.java
index 3936585a6b..5027da99bf 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSyntaxTreeTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSyntaxTreeTest.java
@@ -20,7 +20,6 @@
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Locale;
-
import org.eclipse.jdt.core.compiler.CategorizedProblem;
import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
import org.eclipse.jdt.core.tests.util.Util;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AnnotationCompletionParserTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AnnotationCompletionParserTest.java
index 1caff14a6c..35766c8132 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AnnotationCompletionParserTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AnnotationCompletionParserTest.java
@@ -15,9 +15,7 @@
import java.util.Map;
-
import junit.framework.Test;
-
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AnnotationDietRecoveryTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AnnotationDietRecoveryTest.java
index 74684811d4..18ba54146a 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AnnotationDietRecoveryTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AnnotationDietRecoveryTest.java
@@ -15,9 +15,7 @@
import java.util.Locale;
import java.util.Map;
-
import junit.framework.Test;
-
import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.codeassist.complete.CompletionParser;
@@ -40,6 +38,10 @@ public class AnnotationDietRecoveryTest extends AbstractCompilerTest {
private static final boolean CHECK_ALL_PARSE = true;
public static boolean optimizeStringLiterals = false;
+ static {
+// TESTS_NAMES = new String[] { "test0025" };
+ }
+
public AnnotationDietRecoveryTest(String testName){
super(testName);
}
@@ -1212,7 +1214,7 @@ public void test0024() {
"public class X {\n" +
" public X() {\n" +
" }\n" +
- " void foo(int param1) {\n" +
+ " void foo(int param1, @AnAnnotation(name) int param2) {\n" +
" }\n" +
"}\n";
@@ -1222,7 +1224,7 @@ public void test0024() {
" public X() {\n" +
" super();\n" +
" }\n" +
- " void foo(int param1) {\n" +
+ " void foo(int param1, @AnAnnotation(name) int param2) {\n" +
" }\n" +
"}\n";
@@ -1231,7 +1233,13 @@ public void test0024() {
expectedDietUnitToString;
String expectedCompletionDietUnitToString =
- expectedDietUnitToString;
+ "package a;\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " }\n" +
+ " void foo(int param1) {\n" +
+ " }\n" +
+ "}\n";
String testName = "";
checkParse(
@@ -1256,7 +1264,7 @@ public void test0025() {
"public class X {\n" +
" public X() {\n" +
" }\n" +
- " void foo(int param1) {\n" +
+ " void foo(int param1, @AnAnnotation(name = $missing$) int param2) {\n" +
" }\n" +
"}\n";
@@ -1266,7 +1274,7 @@ public void test0025() {
" public X() {\n" +
" super();\n" +
" }\n" +
- " void foo(int param1) {\n" +
+ " void foo(int param1, @AnAnnotation(name = $missing$) int param2) {\n" +
" }\n" +
"}\n";
@@ -1274,7 +1282,13 @@ public void test0025() {
expectedDietUnitToString;
String expectedCompletionDietUnitToString =
- expectedDietUnitToString;
+ "package a;\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " }\n" +
+ " void foo(int param1) {\n" +
+ " }\n" +
+ "}\n";
String testName = "";
checkParse(
@@ -1299,7 +1313,7 @@ public void test0026() {
"public class X {\n" +
" public X() {\n" +
" }\n" +
- " void foo(int param1) {\n" +
+ " void foo(int param1, @AnAnnotation @AnAnnotation1(name1 = \"a\",name2 = $missing$) int param2) {\n" +
" }\n" +
"}\n";
@@ -1309,7 +1323,7 @@ public void test0026() {
" public X() {\n" +
" super();\n" +
" }\n" +
- " void foo(int param1) {\n" +
+ " void foo(int param1, @AnAnnotation @AnAnnotation1(name1 = \"a\",name2 = $missing$) int param2) {\n" +
" }\n" +
"}\n";
@@ -1317,7 +1331,13 @@ public void test0026() {
expectedDietUnitToString;
String expectedCompletionDietUnitToString =
- expectedDietUnitToString;
+ "package a;\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " }\n" +
+ " void foo(int param1) {\n" +
+ " }\n" +
+ "}\n";
String testName = "";
checkParse(
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest.java
index 0ffda81af7..9d0b381a9c 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest.java
@@ -14,7 +14,6 @@
package org.eclipse.jdt.core.tests.compiler.parser;
import junit.framework.Test;
-
import org.eclipse.jdt.internal.codeassist.complete.InvalidCursorLocation;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java
index c5a67965da..cc26d4ffda 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java
@@ -15,7 +15,6 @@
package org.eclipse.jdt.core.tests.compiler.parser;
import junit.framework.Test;
-
import org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietCompletionTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietCompletionTest.java
index 95a31bba31..63c2d0fa8b 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietCompletionTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietCompletionTest.java
@@ -14,7 +14,6 @@
package org.eclipse.jdt.core.tests.compiler.parser;
import junit.framework.Test;
-
import org.eclipse.jdt.internal.codeassist.complete.InvalidCursorLocation;
public class DietCompletionTest extends AbstractCompletionTest {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java
index 40f4bd99df..b817b3f7b2 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java
@@ -14,9 +14,7 @@
package org.eclipse.jdt.core.tests.compiler.parser;
import java.util.Locale;
-
import junit.framework.Test;
-
import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.codeassist.complete.CompletionParser;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DocumentElementParserTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DocumentElementParserTest.java
index 60294655a2..d7f960392a 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DocumentElementParserTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DocumentElementParserTest.java
@@ -14,7 +14,6 @@
package org.eclipse.jdt.core.tests.compiler.parser;
import java.util.Locale;
-
import org.eclipse.jdt.core.compiler.CategorizedProblem;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DualParseSyntaxErrorTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DualParseSyntaxErrorTest.java
index 76aa0c2cae..7fbeb163f2 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DualParseSyntaxErrorTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DualParseSyntaxErrorTest.java
@@ -16,7 +16,6 @@
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Locale;
-
import org.eclipse.jdt.core.compiler.CategorizedProblem;
import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
import org.eclipse.jdt.core.tests.util.Util;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/EnumCompletionParserTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/EnumCompletionParserTest.java
index 487089a185..a98cacc6bd 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/EnumCompletionParserTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/EnumCompletionParserTest.java
@@ -15,9 +15,7 @@
import java.util.Map;
-
import junit.framework.Test;
-
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/EnumDietRecoveryTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/EnumDietRecoveryTest.java
index cb0733ac82..9568f5ed3c 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/EnumDietRecoveryTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/EnumDietRecoveryTest.java
@@ -15,7 +15,6 @@
import java.util.Locale;
import java.util.Map;
-
import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.codeassist.complete.CompletionParser;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericDietRecoveryTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericDietRecoveryTest.java
index b28326a788..e1c7c0e630 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericDietRecoveryTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericDietRecoveryTest.java
@@ -17,7 +17,6 @@
import java.util.Locale;
import java.util.Map;
-
import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.codeassist.complete.CompletionParser;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericsCompletionParserTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericsCompletionParserTest.java
index 26b6855c59..e8df3922c2 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericsCompletionParserTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericsCompletionParserTest.java
@@ -14,9 +14,7 @@
package org.eclipse.jdt.core.tests.compiler.parser;
import java.util.Map;
-
import junit.framework.Test;
-
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
@SuppressWarnings({ "unchecked", "rawtypes" })
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/JavadocCompletionParserTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/JavadocCompletionParserTest.java
index 8f47442d60..f720ee8f7c 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/JavadocCompletionParserTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/JavadocCompletionParserTest.java
@@ -16,9 +16,7 @@
import java.util.Locale;
import java.util.Map;
import java.util.StringTokenizer;
-
import junit.framework.Test;
-
import org.eclipse.jdt.internal.codeassist.complete.CompletionJavadoc;
import org.eclipse.jdt.internal.codeassist.complete.CompletionOnJavadocTag;
import org.eclipse.jdt.internal.codeassist.complete.CompletionParser;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/LambdaExpressionSyntaxTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/LambdaExpressionSyntaxTest.java
index 1b4e8d303f..9501870f86 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/LambdaExpressionSyntaxTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/LambdaExpressionSyntaxTest.java
@@ -16,7 +16,6 @@
import java.io.File;
import java.io.IOException;
import junit.framework.Test;
-
import org.eclipse.jdt.core.tests.util.CompilerTestSetup;
@SuppressWarnings({ "rawtypes" })
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/MarkdownCompletionParserTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/MarkdownCompletionParserTest.java
index caea480cbd..05b414427b 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/MarkdownCompletionParserTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/MarkdownCompletionParserTest.java
@@ -16,9 +16,7 @@
import java.util.Locale;
import java.util.Map;
import java.util.StringTokenizer;
-
import junit.framework.Test;
-
import org.eclipse.jdt.internal.codeassist.complete.CompletionJavadoc;
import org.eclipse.jdt.internal.codeassist.complete.CompletionOnJavadocTag;
import org.eclipse.jdt.internal.codeassist.complete.CompletionParser;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ModuleDeclarationSyntaxTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ModuleDeclarationSyntaxTest.java
index eba8e24387..59f77e84af 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ModuleDeclarationSyntaxTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ModuleDeclarationSyntaxTest.java
@@ -14,13 +14,11 @@
package org.eclipse.jdt.core.tests.compiler.parser;
import java.io.IOException;
-
+import junit.framework.Test;
import org.eclipse.jdt.core.tests.util.CompilerTestSetup;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-import junit.framework.Test;
-
public class ModuleDeclarationSyntaxTest extends AbstractSyntaxTreeTest {
public ModuleDeclarationSyntaxTest(String name, String referenceCompiler,
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest.java
index 7eb91f142c..a741d75094 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest.java
@@ -15,7 +15,6 @@
import java.util.Hashtable;
import java.util.Map;
-
import org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest1_7.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest1_7.java
index fa56093a9c..3554eb4fd9 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest1_7.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest1_7.java
@@ -15,9 +15,7 @@
import java.util.Locale;
import java.util.Map;
-
import junit.framework.Test;
-
import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.compiler.CompilationResult;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/PatternMatchingSelectionTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/PatternMatchingSelectionTest.java
index fb71e96767..d481376801 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/PatternMatchingSelectionTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/PatternMatchingSelectionTest.java
@@ -13,11 +13,10 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.parser;
+import junit.framework.Test;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import junit.framework.Test;
-
public class PatternMatchingSelectionTest extends AbstractSelectionTest {
static {
// TESTS_NUMBERS = new int[] { 1 };
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ReferenceExpressionSyntaxTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ReferenceExpressionSyntaxTest.java
index dc50fe3dd8..2d6c3681e2 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ReferenceExpressionSyntaxTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ReferenceExpressionSyntaxTest.java
@@ -16,7 +16,6 @@
import java.io.File;
import java.io.IOException;
import junit.framework.Test;
-
import org.eclipse.jdt.core.tests.util.CompilerTestSetup;
@SuppressWarnings({ "rawtypes" })
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/RunCompletionParserTests.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/RunCompletionParserTests.java
index 453c92abd4..36320340e5 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/RunCompletionParserTests.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/RunCompletionParserTests.java
@@ -15,14 +15,12 @@
import java.util.ArrayList;
import java.util.List;
-
+import junit.framework.Test;
+import junit.framework.TestSuite;
import org.eclipse.jdt.core.tests.junit.extension.TestCase;
import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
@SuppressWarnings({ "unchecked", "rawtypes" })
public class RunCompletionParserTests extends junit.framework.TestCase {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionJavadocTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionJavadocTest.java
index 2103c28a88..dc18284ad1 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionJavadocTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionJavadocTest.java
@@ -15,7 +15,7 @@
import java.util.Locale;
import java.util.Map;
-
+import junit.framework.Test;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.codeassist.select.SelectionJavadoc;
import org.eclipse.jdt.internal.codeassist.select.SelectionParser;
@@ -37,8 +37,6 @@
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
-import junit.framework.Test;
-
/**
* Class to test selection in Javadoc comments.
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=54968"
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionMarkdownTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionMarkdownTest.java
index 6df23d9bee..cfbb9b3d37 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionMarkdownTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionMarkdownTest.java
@@ -15,7 +15,7 @@
import java.util.Locale;
import java.util.Map;
-
+import junit.framework.Test;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.codeassist.select.SelectionJavadoc;
import org.eclipse.jdt.internal.codeassist.select.SelectionParser;
@@ -37,8 +37,6 @@
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
-import junit.framework.Test;
-
@SuppressWarnings({ "unchecked", "rawtypes" })
public class SelectionMarkdownTest extends AbstractSelectionTest {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest10.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest10.java
index 5ed1fbe246..e40446eda7 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest10.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest10.java
@@ -15,9 +15,8 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.parser;
-import org.eclipse.jdt.core.JavaModelException;
-
import junit.framework.Test;
+import org.eclipse.jdt.core.JavaModelException;
public class SelectionParserTest10 extends AbstractSelectionTest {
static {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest12.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest12.java
index 21b8dc8fe6..a49f5acdf1 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest12.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest12.java
@@ -13,9 +13,8 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.parser;
-import org.eclipse.jdt.core.JavaModelException;
-
import junit.framework.Test;
+import org.eclipse.jdt.core.JavaModelException;
public class SelectionParserTest12 extends AbstractSelectionTest {
static {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest13.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest13.java
index 7573841857..ea69892ad3 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest13.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest13.java
@@ -13,9 +13,8 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.parser;
-import org.eclipse.jdt.core.JavaModelException;
-
import junit.framework.Test;
+import org.eclipse.jdt.core.JavaModelException;
public class SelectionParserTest13 extends AbstractSelectionTest {
static {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest18.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest18.java
index a0d6e786c4..0949a34719 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest18.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest18.java
@@ -13,9 +13,8 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.parser;
-import org.eclipse.jdt.core.JavaModelException;
-
import junit.framework.Test;
+import org.eclipse.jdt.core.JavaModelException;
public class SelectionParserTest18 extends AbstractSelectionTest {
static {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest9.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest9.java
index c96f67973f..61e446b260 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest9.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest9.java
@@ -13,9 +13,8 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.parser;
-import org.eclipse.jdt.core.JavaModelException;
-
import junit.framework.Test;
+import org.eclipse.jdt.core.JavaModelException;
public class SelectionParserTest9 extends AbstractSelectionTest {
static {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionTest2.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionTest2.java
index 2270f501e4..a86f06020a 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionTest2.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionTest2.java
@@ -14,14 +14,13 @@
package org.eclipse.jdt.core.tests.compiler.parser;
import java.util.Locale;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.codeassist.select.SelectionParser;
import org.eclipse.jdt.internal.codeassist.select.SelectionScanner;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
-import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
+import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Initializer;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SingleCompletionTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SingleCompletionTest.java
index b503ee295b..02d965897d 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SingleCompletionTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SingleCompletionTest.java
@@ -14,7 +14,6 @@
package org.eclipse.jdt.core.tests.compiler.parser;
import java.lang.reflect.InvocationTargetException;
-
import junit.framework.TestCase;
/**
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java
index ea146e1a7a..f290cfdc0c 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java
@@ -15,9 +15,7 @@
import java.util.Locale;
import java.util.Map;
-
import junit.framework.Test;
-
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.compiler.CategorizedProblem;
import org.eclipse.jdt.core.compiler.CharOperation;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/StatementRecoveryTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/StatementRecoveryTest.java
index 5a6fbfcbf3..3b7a7fed34 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/StatementRecoveryTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/StatementRecoveryTest.java
@@ -14,9 +14,7 @@
package org.eclipse.jdt.core.tests.compiler.parser;
import java.util.Locale;
-
import junit.framework.Test;
-
import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.compiler.CompilationResult;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/StatementRecoveryTest_1_5.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/StatementRecoveryTest_1_5.java
index aa9c14af65..b37e6f3f45 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/StatementRecoveryTest_1_5.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/StatementRecoveryTest_1_5.java
@@ -15,9 +15,7 @@
import java.util.Locale;
import java.util.Map;
-
import junit.framework.Test;
-
import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.compiler.CompilationResult;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/StringLiteralTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/StringLiteralTest.java
index df340d8bce..49d63718cb 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/StringLiteralTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/StringLiteralTest.java
@@ -1,14 +1,12 @@
package org.eclipse.jdt.core.tests.compiler.parser;
import java.util.List;
-
+import junit.framework.TestCase;
import org.eclipse.jdt.internal.compiler.ast.CharLiteral;
import org.eclipse.jdt.internal.compiler.ast.ExtendedStringLiteral;
import org.eclipse.jdt.internal.compiler.ast.StringLiteral;
import org.eclipse.jdt.internal.compiler.ast.StringLiteralConcatenation;
-import junit.framework.TestCase;
-
public class StringLiteralTest extends TestCase {
public void testAppend() {
StringLiteral l1 = new StringLiteral(new char[] { 'a' }, 2, 3, 4);
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SyntaxErrorTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SyntaxErrorTest.java
index 7ace4ce4cf..f1f2b2fb2a 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SyntaxErrorTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SyntaxErrorTest.java
@@ -14,7 +14,6 @@
package org.eclipse.jdt.core.tests.compiler.parser;
import java.util.Locale;
-
import org.eclipse.jdt.core.compiler.CategorizedProblem;
import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
import org.eclipse.jdt.core.tests.util.Util;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java
index 4de1a26c99..53c7c579fc 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java
@@ -18,15 +18,13 @@
import java.util.ArrayList;
import java.util.List;
-
+import junit.framework.Test;
+import junit.framework.TestSuite;
import org.eclipse.jdt.core.tests.compiler.regression.JEP286ReservedWordTest;
import org.eclipse.jdt.core.tests.junit.extension.TestCase;
import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
/**
* Run all parser regression tests
*/
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TypeAnnotationSyntaxTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TypeAnnotationSyntaxTest.java
index 4f2a40076d..9046b97a3e 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TypeAnnotationSyntaxTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TypeAnnotationSyntaxTest.java
@@ -26,17 +26,7 @@
import junit.framework.Test;
import org.eclipse.jdt.core.tests.util.CompilerTestSetup;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.ast.Annotation;
-import org.eclipse.jdt.internal.compiler.ast.Argument;
-import org.eclipse.jdt.internal.compiler.ast.ArrayTypeReference;
-import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation;
-import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.NormalAnnotation;
-import org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference;
-import org.eclipse.jdt.internal.compiler.ast.SingleMemberAnnotation;
-import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference;
-import org.eclipse.jdt.internal.compiler.ast.TypeReference;
+import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ASTImplTests.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ASTImplTests.java
index daece46ee1..2f409d9fa7 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ASTImplTests.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ASTImplTests.java
@@ -14,26 +14,11 @@
package org.eclipse.jdt.core.tests.compiler.regression;
import junit.framework.Test;
-
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
-import org.eclipse.jdt.internal.compiler.ast.Argument;
-import org.eclipse.jdt.internal.compiler.ast.BinaryExpression;
-import org.eclipse.jdt.internal.compiler.ast.CharLiteral;
-import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.CombinedBinaryExpression;
-import org.eclipse.jdt.internal.compiler.ast.ExtendedStringLiteral;
-import org.eclipse.jdt.internal.compiler.ast.JavadocSingleTypeReference;
-import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation;
-import org.eclipse.jdt.internal.compiler.ast.MemberValuePair;
-import org.eclipse.jdt.internal.compiler.ast.NormalAnnotation;
-import org.eclipse.jdt.internal.compiler.ast.SingleMemberAnnotation;
-import org.eclipse.jdt.internal.compiler.ast.SingleNameReference;
-import org.eclipse.jdt.internal.compiler.ast.StringLiteral;
-import org.eclipse.jdt.internal.compiler.ast.StringLiteralConcatenation;
+import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.batch.CompilationUnit;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractBatchCompilerTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractBatchCompilerTest.java
index 03db79c588..8dc9fb52c2 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractBatchCompilerTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractBatchCompilerTest.java
@@ -21,7 +21,6 @@
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.ArrayList;
-
import org.eclipse.jdt.core.compiler.CompilationProgress;
import org.eclipse.jdt.core.compiler.batch.BatchCompiler;
import org.eclipse.jdt.core.tests.util.Util;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractComparableTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractComparableTest.java
index eeb34632cd..af8a668507 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractComparableTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractComparableTest.java
@@ -20,10 +20,8 @@
package org.eclipse.jdt.core.tests.compiler.regression;
import java.util.Map;
-
-import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-
import junit.framework.Test;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
@SuppressWarnings({ "unchecked", "rawtypes" })
public class AbstractComparableTest extends AbstractRegressionTest {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractModuleCompilationTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractModuleCompilationTest.java
index 738ef09d3f..01c796c31c 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractModuleCompilationTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractModuleCompilationTest.java
@@ -27,10 +27,8 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-
import junit.framework.AssertionFailedError;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
public abstract class AbstractModuleCompilationTest extends AbstractBatchCompilerTest {
@@ -130,7 +128,7 @@ protected Set runConformModuleTest(String[] testFiles, String commandLin
protected Set runConformModuleTest(String[] testFiles, String commandLine, String expectedFailureOutOutputString, String expectedFailureErrOutputString, boolean shouldFlushOutputDirectory, String output,
JavacTestOptions options, String javacCommandLine) {
runConformTest(testFiles, commandLine, expectedFailureOutOutputString, expectedFailureErrOutputString, shouldFlushOutputDirectory);
- if (RUN_JAVAC) {
+ if (shouldRunJavac()) {
File outputDir = new File(output);
final Set outFiles = new HashSet<>();
walkOutFiles(output, outFiles, true);
@@ -214,7 +212,7 @@ protected void runNegativeModuleTest(String[] testFiles, String commandLine, Str
void runNegativeModuleTest(String[] testFiles, String commandLine, String expectedFailureOutOutputString, String expectedFailureErrOutputString, boolean shouldFlushOutputDirectory, String javacErrorMatch,
String output, JavacTestOptions options) {
runNegativeTest(testFiles, commandLine, expectedFailureOutOutputString, expectedFailureErrOutputString, shouldFlushOutputDirectory);
- if (RUN_JAVAC) {
+ if (shouldRunJavac()) {
String[] testFileNames = new String[testFiles.length/2];
for (int i = 0; i < testFileNames.length; i++) {
testFileNames[i] = testFiles[i*2];
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractNullAnnotationTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractNullAnnotationTest.java
index 9b6c6edda8..a66a72c4f1 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractNullAnnotationTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractNullAnnotationTest.java
@@ -15,11 +15,11 @@
import java.io.File;
import java.io.IOException;
+import java.net.URL;
import java.util.Map;
-
import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.osgi.framework.Bundle;
@@ -90,16 +90,24 @@ protected void setUpAnnotationLib() throws IOException {
int len = defaultLibs.length;
this.LIBS = new String[len+1];
System.arraycopy(defaultLibs, 0, this.LIBS, 0, len);
- String version = this.complianceLevel >= ClassFileConstants.JDK1_8 ? "[2.0.0,3.0.0)" : "[1.1.0,2.0.0)";
- Bundle[] bundles = org.eclipse.jdt.core.tests.compiler.Activator.getPackageAdmin().getBundles("org.eclipse.jdt.annotation", version);
- File bundleFile = FileLocator.getBundleFileLocation(bundles[0]).get();
- if (bundleFile.isDirectory())
- this.LIBS[len] = bundleFile.getPath()+"/bin";
- else
- this.LIBS[len] = bundleFile.getPath();
+ this.LIBS[len] = getAnnotationLibPath();
}
}
+ protected String getAnnotationLibPath() throws IOException {
+ Bundle bundle = Platform.getBundle("org.eclipse.jdt.annotation");
+ File bundleFile = FileLocator.getBundleFileLocation(bundle).get();
+ if (bundleFile.isDirectory())
+ return bundleFile.getPath()+"/bin";
+ else
+ return bundleFile.getPath();
+ }
+
+ public static String getAnnotationV1LibPath() throws IOException {
+ URL libEntry = Platform.getBundle("org.eclipse.jdt.core.tests.compiler").getEntry("/lib/org.eclipse.jdt.annotation_1.2.100.v20241001-0914.jar");
+ return FileLocator.toFileURL(libEntry).getPath();
+ }
+
// Conditionally augment problem detection settings
static boolean setNullRelatedOptions = true;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
index 32acd25484..0c79b36d87 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
@@ -23,34 +23,16 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.PrintWriter;
+import java.io.*;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
+import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-
+import junit.framework.Test;
+import junit.framework.TestSuite;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
@@ -559,18 +541,24 @@ static int minorFromRawVersion (String version, String rawVersion) {
}
if (version == JavaCore.VERSION_21) {
switch (rawVersion) {
- case "21": return 0;
+ case "21": return 0000;
+ case "21.0.1": return 0100;
+ case "21.0.2": return 0200;
}
}
if (version == JavaCore.VERSION_22) {
- if ("22".equals(rawVersion)) {
- return 0000;
+ switch (rawVersion) {
+ case "22": return 0000;
+ case "22.0.1": return 0100;
+ case "22.0.2": return 0200;
}
}
if (version == JavaCore.VERSION_23) {
switch(rawVersion) {
case "23-ea", "23":
return 0000;
+ case "23.0.1": return 0100;
+ case "23.0.2": return 0200;
}
}
throw new RuntimeException("unknown raw javac version: " + rawVersion);
@@ -802,28 +790,28 @@ public boolean clears(int mismatch) {
return this.mismatchType == 0 || (this.mismatchType & mismatch) == mismatch; // one excuse can clear multiple mismatches
}
public static Excuse
- EclipseHasSomeMoreWarnings = RUN_JAVAC ?
- new Excuse(MismatchType.EclipseWarningsJavacNone) : null,
- EclipseWarningConfiguredAsError = RUN_JAVAC ?
- new Excuse(MismatchType.EclipseErrorsJavacWarnings | MismatchType.EclipseErrorsJavacNone) : null,
- JavacCompilesBogusReferencedFileAgain = RUN_JAVAC ?
- new Excuse(MismatchType.EclipseErrorsJavacNone) : null,
+ EclipseHasSomeMoreWarnings =
+ new Excuse(MismatchType.EclipseWarningsJavacNone),
+ EclipseWarningConfiguredAsError =
+ new Excuse(MismatchType.EclipseErrorsJavacWarnings | MismatchType.EclipseErrorsJavacNone),
+ JavacCompilesBogusReferencedFileAgain =
+ new Excuse(MismatchType.EclipseErrorsJavacNone),
// bugs not found on javac bug site, but points to a javac bug.
- JavacDoesNotCompileCorrectSource = RUN_JAVAC ?
- new JavacHasABug(MismatchType.JavacErrorsEclipseNone) : null,
+ JavacDoesNotCompileCorrectSource =
+ new JavacHasABug(MismatchType.JavacErrorsEclipseNone),
/* A General Excuse - Revisit periodically */
- JavacCompilesIncorrectSource = RUN_JAVAC ?
+ JavacCompilesIncorrectSource =
new JavacHasABug(MismatchType.EclipseErrorsJavacNone |
MismatchType.EclipseErrorsJavacWarnings |
- MismatchType.EclipseWarningsJavacNone) : null,
- JavacGeneratesIncorrectCode = RUN_JAVAC ?
- new JavacHasABug(MismatchType.StandardOutputMismatch) : null,
- JavacHasWarningsEclipseNotConfigured = RUN_JAVAC ?
- new JavacHasABug(MismatchType.JavacWarningsEclipseNone) : null,
- JavacHasErrorsEclipseHasWarnings = RUN_JAVAC ?
- new JavacHasABug(MismatchType.JavacErrorsEclipseWarnings) : null,
- JavacHasErrorsEclipseHasNone = RUN_JAVAC ?
- new JavacHasABug(MismatchType.JavacErrorsEclipseNone) : null;
+ MismatchType.EclipseWarningsJavacNone),
+ JavacGeneratesIncorrectCode =
+ new JavacHasABug(MismatchType.StandardOutputMismatch),
+ JavacHasWarningsEclipseNotConfigured =
+ new JavacHasABug(MismatchType.JavacWarningsEclipseNone),
+ JavacHasErrorsEclipseHasWarnings =
+ new JavacHasABug(MismatchType.JavacErrorsEclipseWarnings),
+ JavacHasErrorsEclipseHasNone =
+ new JavacHasABug(MismatchType.JavacErrorsEclipseNone);
}
Excuse excuseFor(JavacCompiler compiler) {
return null;
@@ -834,88 +822,88 @@ public static class DubiousOutcome extends Excuse {
super(mismatchType);
}
public static DubiousOutcome
- EclipseErrorsJavacNone = RUN_JAVAC ?
- new DubiousOutcome(MismatchType.EclipseErrorsJavacNone) : null,
- JavacErrorsEclipseNone = RUN_JAVAC ?
- new DubiousOutcome(MismatchType.JavacErrorsEclipseNone) : null,
- JDK8319461 = RUN_JAVAC ? // https://bugs.openjdk.org/browse/JDK-8319461
- new DubiousOutcome(MismatchType.JavacErrorsEclipseNone) : null;
+ EclipseErrorsJavacNone =
+ new DubiousOutcome(MismatchType.EclipseErrorsJavacNone),
+ JavacErrorsEclipseNone =
+ new DubiousOutcome(MismatchType.JavacErrorsEclipseNone),
+ JDK8319461 = // https://bugs.openjdk.org/browse/JDK-8319461
+ new DubiousOutcome(MismatchType.JavacErrorsEclipseNone);
}
public static class EclipseHasABug extends Excuse {
EclipseHasABug(int mismatchType) {
super(mismatchType);
}
public static EclipseHasABug
- EclipseBug159851 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=159851
+ EclipseBug159851 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=159851
new EclipseHasABug(MismatchType.JavacErrorsEclipseNone) {
@Override
Excuse excuseFor(JavacCompiler compiler) {
return compiler.compliance < ClassFileConstants.JDK1_7 ? this : null;
}
- } : null,
- EclipseBug177715 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=177715
+ },
+ EclipseBug177715 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=177715
new EclipseHasABug(MismatchType.JavacErrorsEclipseNone) {
@Override
Excuse excuseFor(JavacCompiler compiler) {
return compiler.compliance < ClassFileConstants.JDK1_8 ? this : null; // in 1.8 rejected by both compilers
}
- } : null,
- EclipseBug207935 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=207935
- new EclipseHasABug(MismatchType.EclipseErrorsJavacNone | MismatchType.EclipseWarningsJavacNone) : null,
- EclipseBug216558 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=216558
- new EclipseHasABug(MismatchType.JavacErrorsEclipseNone) : null,
- EclipseBug235550 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=235550
- new EclipseHasABug(MismatchType.JavacErrorsEclipseNone) : null,
- EclipseBug235809 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=235809
- new EclipseHasABug(MismatchType.StandardOutputMismatch) : null,
- EclipseBug236217 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=236217
+ },
+ EclipseBug207935 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=207935
+ new EclipseHasABug(MismatchType.EclipseErrorsJavacNone | MismatchType.EclipseWarningsJavacNone),
+ EclipseBug216558 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=216558
+ new EclipseHasABug(MismatchType.JavacErrorsEclipseNone),
+ EclipseBug235550 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=235550
+ new EclipseHasABug(MismatchType.JavacErrorsEclipseNone),
+ EclipseBug235809 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=235809
+ new EclipseHasABug(MismatchType.StandardOutputMismatch),
+ EclipseBug236217 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=236217
new EclipseHasABug(MismatchType.JavacErrorsEclipseNone) {
@Override
Excuse excuseFor(JavacCompiler compiler) {
return compiler.compliance < ClassFileConstants.JDK1_8 ? this : null; // in 1.8 accepted by both compilers
}
- } : null,
- EclipseBug236236 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=236236
+ },
+ EclipseBug236236 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=236236
new EclipseHasABug(MismatchType.EclipseErrorsJavacNone) {
@Override
Excuse excuseFor(JavacCompiler compiler) {
return compiler.compliance > ClassFileConstants.JDK1_5 ? this : null;
}
- }: null,
- EclipseBug236242 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=236242
+ },
+ EclipseBug236242 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=236242
new EclipseHasABug(MismatchType.EclipseErrorsJavacWarnings) {
@Override
Excuse excuseFor(JavacCompiler compiler) {
return compiler.compliance == ClassFileConstants.JDK1_7 ? this : null;
}
- }: null,
- EclipseBug236243 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=236243
+ },
+ EclipseBug236243 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=236243
new EclipseHasABug(MismatchType.EclipseErrorsJavacNone) {
@Override
Excuse excuseFor(JavacCompiler compiler) {
return compiler.compliance > ClassFileConstants.JDK1_6 ? this : null;
}
- }: null,
- EclipseBug236379 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=236379
+ },
+ EclipseBug236379 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=236379
new EclipseHasABug(MismatchType.EclipseWarningsJavacNone) {
@Override
Excuse excuseFor(JavacCompiler compiler) {
return compiler.compliance > ClassFileConstants.JDK1_5 ? null : this;
}
- }: null,
- EclipseBug424410 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=424410
- new EclipseHasABug(MismatchType.JavacErrorsEclipseNone) : null,
- EclipseBug427719 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=427719
- new EclipseHasABug(MismatchType.JavacErrorsEclipseWarnings) : null,
- EclipseBug421922 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=421922
- new EclipseHasABug(MismatchType.EclipseErrorsJavacNone) : null,
- EclipseBug428061 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=428061
+ },
+ EclipseBug424410 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=424410
+ new EclipseHasABug(MismatchType.JavacErrorsEclipseNone),
+ EclipseBug427719 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=427719
+ new EclipseHasABug(MismatchType.JavacErrorsEclipseWarnings),
+ EclipseBug421922 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=421922
+ new EclipseHasABug(MismatchType.EclipseErrorsJavacNone),
+ EclipseBug428061 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=428061
new EclipseHasABug(MismatchType.JavacErrorsEclipseNone |
- MismatchType.JavacErrorsEclipseWarnings) : null,
- EclipseBug510528 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=510528
- new EclipseHasABug(MismatchType.JavacErrorsEclipseNone) : null,
- EclipseBug531531 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=531531
- new EclipseHasABug(MismatchType.EclipseErrorsJavacNone) : null;
+ MismatchType.JavacErrorsEclipseWarnings),
+ EclipseBug510528 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=510528
+ new EclipseHasABug(MismatchType.JavacErrorsEclipseNone),
+ EclipseBug531531 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=531531
+ new EclipseHasABug(MismatchType.EclipseErrorsJavacNone);
}
// Justification based upon:
// - Eclipse bugs opened to investigate differences and closed as INVALID
@@ -929,96 +917,96 @@ public static class EclipseJustification extends Excuse {
super(mismatchType);
}
public static final EclipseJustification
- EclipseBug72704 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=72704
- new EclipseJustification(MismatchType.EclipseErrorsJavacNone) : null,
- EclipseBug83902 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=83902
+ EclipseBug72704 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=72704
+ new EclipseJustification(MismatchType.EclipseErrorsJavacNone),
+ EclipseBug83902 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=83902
new EclipseJustification(MismatchType.EclipseWarningsJavacNone) {
@Override
Excuse excuseFor(JavacCompiler compiler) {
return compiler.compliance > ClassFileConstants.JDK1_5 ? this : null;
}
- } : null,
- EclipseBug83902b = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=83902
- new EclipseJustification(MismatchType.JavacErrorsEclipseWarnings) : null,
- EclipseBug95021 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=95021
+ },
+ EclipseBug83902b = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=83902
+ new EclipseJustification(MismatchType.JavacErrorsEclipseWarnings),
+ EclipseBug95021 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=95021
new EclipseJustification(MismatchType.JavacErrorsEclipseNone) {
@Override
Excuse excuseFor(JavacCompiler compiler) {
return compiler.compliance == ClassFileConstants.JDK1_7 ? this : null;
}
// WORK consider adding reversed pivots
- } : null,
- EclipseBug126712 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=126712 & http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6342411
+ },
+ EclipseBug126712 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=126712 & http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6342411
new EclipseJustification(MismatchType.StandardOutputMismatch) {
@Override
Excuse excuseFor(JavacCompiler compiler) {
return compiler.compliance > ClassFileConstants.JDK1_5 ? this : null;
}
// WORK consider adding reversed pivots
- } : null,
- EclipseBug126744 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=126744
- new EclipseJustification(MismatchType.JavacErrorsEclipseNone) : null,
- EclipseBug151275 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=151275
+ },
+ EclipseBug126744 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=126744
+ new EclipseJustification(MismatchType.JavacErrorsEclipseNone),
+ EclipseBug151275 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=151275
new EclipseJustification(MismatchType.JavacErrorsEclipseNone) {
@Override
Excuse excuseFor(JavacCompiler compiler) {
return compiler.compliance < ClassFileConstants.JDK1_7 ? this : null;
}
- } : null,
- EclipseBug159214 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=159214
+ },
+ EclipseBug159214 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=159214
new EclipseJustification(MismatchType.EclipseErrorsJavacNone) {
@Override
Excuse excuseFor(JavacCompiler compiler) {
return compiler.compliance == ClassFileConstants.JDK1_6 ? this : null;
}
// WORK consider adding reversed pivots
- } : null,
- EclipseBug169017 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=169017
+ },
+ EclipseBug169017 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=169017
new EclipseJustification(MismatchType.JavacErrorsEclipseNone) {
@Override
Excuse excuseFor(JavacCompiler compiler) {
return compiler.compliance > ClassFileConstants.JDK1_5 ? this : null;
}
// WORK consider adding reversed pivots
- } : null,
- EclipseBug180789 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=180789
- new EclipseJustification(MismatchType.EclipseErrorsJavacWarnings) : null,
- EclipseBug218677 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=218677
+ },
+ EclipseBug180789 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=180789
+ new EclipseJustification(MismatchType.EclipseErrorsJavacWarnings),
+ EclipseBug218677 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=218677
new EclipseJustification(MismatchType.EclipseErrorsJavacNone) {
@Override
Excuse excuseFor(JavacCompiler compiler) {
return compiler.compliance > ClassFileConstants.JDK1_6 ? this : null;
}
// WORK consider adding reversed pivots
- } : null,
- EclipseBug234815 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=234815
+ },
+ EclipseBug234815 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=234815
new EclipseJustification(MismatchType.JavacErrorsEclipseNone) {
@Override
Excuse excuseFor(JavacCompiler compiler) {
return compiler.compliance < ClassFileConstants.JDK1_7 ? this : null;
}
- }: null,
- EclipseBug235543 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=235543
- new EclipseJustification(MismatchType.EclipseErrorsJavacNone) : null,
- EclipseBug235546 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=235546
- new EclipseJustification(MismatchType.JavacErrorsEclipseNone) : null,
- EclipseBug449063 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=449063
- new EclipseJustification(MismatchType.StandardOutputMismatch) : null,
- EclipseBug561549 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=561549
+ },
+ EclipseBug235543 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=235543
+ new EclipseJustification(MismatchType.EclipseErrorsJavacNone),
+ EclipseBug235546 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=235546
+ new EclipseJustification(MismatchType.JavacErrorsEclipseNone),
+ EclipseBug449063 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=449063
+ new EclipseJustification(MismatchType.StandardOutputMismatch),
+ EclipseBug561549 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=561549
new EclipseJustification(MismatchType.EclipseErrorsJavacNone) {
@Override
Excuse excuseFor(JavacCompiler compiler) {
return compiler.compliance > ClassFileConstants.JDK9 ? this : null;
}
- } : null;
+ };
public static final EclipseJustification
- EclipseJustification0001 = RUN_JAVAC ?
+ EclipseJustification0001 =
new EclipseJustification(MismatchType.EclipseErrorsJavacNone) {
@Override
Excuse excuseFor(JavacCompiler compiler) {
return compiler.compliance < ClassFileConstants.JDK1_7 ? this : null;
}
- } : null;
+ };
/* javac 1.6- properly detects duplicate attributes in annotations in the
* simplest case (AnnotationTest#18b) but fails on a slightly more
* complex one where the duplicate is within an embedded annotation;
@@ -1091,39 +1079,39 @@ Excuse excuseFor(JavacCompiler compiler) {
}
// bugs that we know precisely of
public static JavacHasABug
- JavacBug4094180 = RUN_JAVAC ? // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4094180
- new JavacHasABug(MismatchType.EclipseErrorsJavacNone) : null,
- JavacBug4660984 = RUN_JAVAC ? // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4660984 & https://bugs.eclipse.org/bugs/show_bug.cgi?id=235555
- new JavacHasABug(MismatchType.JavacErrorsEclipseNone) : null,
- JavacBug5042462 = RUN_JAVAC ? // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5042462 & https://bugs.eclipse.org/bugs/show_bug.cgi?id=208873
+ JavacBug4094180 = // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4094180
+ new JavacHasABug(MismatchType.EclipseErrorsJavacNone),
+ JavacBug4660984 = // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4660984 & https://bugs.eclipse.org/bugs/show_bug.cgi?id=235555
+ new JavacHasABug(MismatchType.JavacErrorsEclipseNone),
+ JavacBug5042462 = // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5042462 & https://bugs.eclipse.org/bugs/show_bug.cgi?id=208873
new JavacHasABug(
MismatchType.JavacErrorsEclipseNone,
- ClassFileConstants.JDK1_7, 0 /* 1.7.0 b17 */) : null,
- JavacBug5061359 = RUN_JAVAC ? // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5061359
+ ClassFileConstants.JDK1_7, 0 /* 1.7.0 b17 */),
+ JavacBug5061359 = // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5061359
new JavacHasABug(
MismatchType.EclipseErrorsJavacNone,
- ClassFileConstants.JDK1_7, 0 /* 1.7.0 b03 */) : null,
- JavacBug6302954 = RUN_JAVAC ? // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6302954 & https://bugs.eclipse.org/bugs/show_bug.cgi?id=98379
+ ClassFileConstants.JDK1_7, 0 /* 1.7.0 b03 */),
+ JavacBug6302954 = // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6302954 & https://bugs.eclipse.org/bugs/show_bug.cgi?id=98379
new JavacHasABug(
MismatchType.JavacErrorsEclipseNone,
- ClassFileConstants.JDK1_7, 0 /* 1.7.0 b03 */) : null,
- JavacBug6400189 = RUN_JAVAC ? // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6400189 & https://bugs.eclipse.org/bugs/show_bug.cgi?id=106744 & https://bugs.eclipse.org/bugs/show_bug.cgi?id=167952
+ ClassFileConstants.JDK1_7, 0 /* 1.7.0 b03 */),
+ JavacBug6400189 = // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6400189 & https://bugs.eclipse.org/bugs/show_bug.cgi?id=106744 & https://bugs.eclipse.org/bugs/show_bug.cgi?id=167952
new JavacHasABug(
MismatchType.EclipseErrorsJavacNone) {
@Override
Excuse excuseFor(JavacCompiler compiler) {
return compiler.compliance == ClassFileConstants.JDK1_6 ? this : null;
}
- } : null,
- JavacBug6500701 = RUN_JAVAC ? // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6500701 & https://bugs.eclipse.org/bugs/show_bug.cgi?id=209779
+ },
+ JavacBug6500701 = // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6500701 & https://bugs.eclipse.org/bugs/show_bug.cgi?id=209779
new JavacHasABug(
MismatchType.StandardOutputMismatch,
- ClassFileConstants.JDK1_7, 0) : null,
- JavacBug6531075 = RUN_JAVAC ? // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6531075
+ ClassFileConstants.JDK1_7, 0),
+ JavacBug6531075 = // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6531075
new JavacHasABug(
MismatchType.StandardOutputMismatch,
- ClassFileConstants.JDK1_7, 0) : null, // fixed in jdk7 b27; unfortunately, we do not have a distinct minor for this, hence former jdk7s will report an unused excuse
- JavacBug6569404 = RUN_JAVAC ? // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6569404
+ ClassFileConstants.JDK1_7, 0), // fixed in jdk7 b27; unfortunately, we do not have a distinct minor for this, hence former jdk7s will report an unused excuse
+ JavacBug6569404 = // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6569404
new JavacHasABug(
MismatchType.JavacErrorsEclipseNone) {
@Override
@@ -1131,68 +1119,72 @@ Excuse excuseFor(JavacCompiler compiler) {
// present only in javac6 between 1.6.0_10_b08 and EOL
return (compiler.compliance == ClassFileConstants.JDK1_6 && compiler.minor >= 10) ? this : null;
}
- } : null,
- JavacBug6557661 = RUN_JAVAC ? // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6557661 & https://bugs.eclipse.org/bugs/show_bug.cgi?id=129261
+ },
+ JavacBug6557661 = // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6557661 & https://bugs.eclipse.org/bugs/show_bug.cgi?id=129261
new JavacHasABug(
- MismatchType.EclipseErrorsJavacNone) : null,
- JavacBug6573446 = RUN_JAVAC ? // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6573446 & https://bugs.eclipse.org/bugs/show_bug.cgi?id=190945
+ MismatchType.EclipseErrorsJavacNone),
+ JavacBug6573446 = // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6573446 & https://bugs.eclipse.org/bugs/show_bug.cgi?id=190945
new JavacHasABug(
- MismatchType.EclipseErrorsJavacNone) : null,
- JavacBug6575821 = RUN_JAVAC ? // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6575821
+ MismatchType.EclipseErrorsJavacNone),
+ JavacBug6575821 = // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6575821
new JavacHasABug(
MismatchType.JavacErrorsEclipseNone,
- ClassFileConstants.JDK1_6, 10 /* 1.6.0_10_b08 or better - maybe before */) : null,
- JavacBug8033810 = RUN_JAVAC ? // https://bugs.openjdk.java.net/browse/JDK-8033810
- new JavacHasABug(MismatchType.EclipseErrorsJavacNone) : null,
- JavacBug8144673 = RUN_JAVAC ? // https://bugs.openjdk.java.net/browse/JDK-8144673
- new JavacHasABug(MismatchType.JavacErrorsEclipseNone, ClassFileConstants.JDK9, 0100) : null,
- JavacBug8204534 = RUN_JAVAC ? // https://bugs.openjdk.java.net/browse/JDK-8204534
- new JavacHasABug(MismatchType.EclipseErrorsJavacNone, ClassFileConstants.JDK11, 0000) : null,
- JavacBug8207032 = RUN_JAVAC ? // https://bugs.openjdk.java.net/browse/JDK-8207032
- new JavacHasABug(MismatchType.EclipseErrorsJavacNone, ClassFileConstants.JDK11, 0000) : null,
- JavacBug8044196 = RUN_JAVAC ? // likely https://bugs.openjdk.java.net/browse/JDK-8044196, intermittently masked by https://bugs.openjdk.java.net/browse/JDK-8029161
- new JavacHasABug(MismatchType.EclipseErrorsJavacNone, ClassFileConstants.JDK9, 0000, true) : null,
- JavacBug6337964 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=112433
- new JavacHasABug(MismatchType.JavacErrorsEclipseNone, ClassFileConstants.JDK1_6, 1045/*guessed*/, true) : null,
- JavacBug8144832 = RUN_JAVAC ? // https://bugs.openjdk.java.net/browse/JDK-8144832
- new JavacHasABug(MismatchType.JavacErrorsEclipseNone, ClassFileConstants.JDK9, 0000) : null,
- JavacBug8179483_switchExpression = RUN_JAVAC ? // https://bugs.openjdk.java.net/browse/JDK-8179483
- new JavacBug8179483(" --release 13 --enable-preview -Xlint:-preview") : null,
- JavacBug8221413_switchExpression = RUN_JAVAC ? // https://bugs.openjdk.java.net/browse/JDK-8221413
- new JavacBug8221413(" --release 12 --enable-preview -Xlint:-preview") : null,
- JavacBug8226510_switchExpression = RUN_JAVAC ? // https://bugs.openjdk.java.net/browse/JDK-8226510
- new JavacBug8226510(" --release 12 --enable-preview -Xlint:-preview") : null,
- JavacBug8299416 = RUN_JAVAC ? // https://bugs.openjdk.java.net/browse/JDK-8299416
- new JavacBugExtraJavacOptionsPlusMismatch(" --release 20 --enable-preview -Xlint:-preview",
- MismatchType.EclipseErrorsJavacNone| MismatchType.EclipseErrorsJavacWarnings) : null,
- JavacBug8336255 = RUN_JAVAC ? // https://bugs.openjdk.org/browse/JDK-8336255
+ ClassFileConstants.JDK1_6, 10 /* 1.6.0_10_b08 or better - maybe before */),
+ JavacBug8033810 = // https://bugs.openjdk.java.net/browse/JDK-8033810
+ new JavacHasABug(MismatchType.EclipseErrorsJavacNone),
+ JavacBug8144673 = // https://bugs.openjdk.java.net/browse/JDK-8144673
+ new JavacHasABug(MismatchType.JavacErrorsEclipseNone, ClassFileConstants.JDK9, 0100),
+ JavacBug8204534 = // https://bugs.openjdk.java.net/browse/JDK-8204534
+ new JavacHasABug(MismatchType.EclipseErrorsJavacNone, ClassFileConstants.JDK11, 0000),
+ JavacBug8207032 = // https://bugs.openjdk.java.net/browse/JDK-8207032
+ new JavacHasABug(MismatchType.EclipseErrorsJavacNone, ClassFileConstants.JDK11, 0000),
+ JavacBug8044196 = // likely https://bugs.openjdk.java.net/browse/JDK-8044196, intermittently masked by https://bugs.openjdk.java.net/browse/JDK-8029161
+ new JavacHasABug(MismatchType.EclipseErrorsJavacNone, ClassFileConstants.JDK9, 0000, true),
+ JavacBug6337964 = // https://bugs.eclipse.org/bugs/show_bug.cgi?id=112433
+ new JavacHasABug(MismatchType.JavacErrorsEclipseNone, ClassFileConstants.JDK1_6, 1045/*guessed*/, true),
+ JavacBug8144832 = // https://bugs.openjdk.java.net/browse/JDK-8144832
+ new JavacHasABug(MismatchType.JavacErrorsEclipseNone, ClassFileConstants.JDK9, 0000),
+ JavacBug8179483_switchExpression = // https://bugs.openjdk.java.net/browse/JDK-8179483
+ new JavacBug8179483(" --release 23 --enable-preview -Xlint:-preview"),
+ JavacBug8221413_switchExpression = // https://bugs.openjdk.java.net/browse/JDK-8221413
+ new JavacBug8221413(" --release 12 --enable-preview -Xlint:-preview"),
+ JavacBug8226510_switchExpression = // https://bugs.openjdk.java.net/browse/JDK-8226510
+ new JavacBug8226510(" --release 12 --enable-preview -Xlint:-preview"),
+// JavacBug8299416 = // https://bugs.openjdk.java.net/browse/JDK-8299416 was active only in some builds of JDK 20
+ JavacBug8336255 = // https://bugs.openjdk.org/browse/JDK-8336255
new JavacBugExtraJavacOptionsPlusMismatch(" --release 23 --enable-preview -Xlint:-preview",
- MismatchType.JavacErrorsEclipseNone) : null;
+ MismatchType.JavacErrorsEclipseNone),
+ JavacBug8337980 = // https://bugs.openjdk.org/browse/JDK-8337980
+ new JavacHasABug(MismatchType.EclipseErrorsJavacNone /* add pivot JDK24 */),
+ JavacBug8343306 = // https://bugs.openjdk.org/browse/JDK-8343306
+ new JavacHasABug(MismatchType.EclipseErrorsJavacNone /* add pivot JDK24 */),
+ JavacBug8341408 = // https://bugs.openjdk.org/browse/JDK-8341408
+ new JavacBug8341408();
// bugs that have been fixed but that we've not identified
public static JavacHasABug
- JavacBugFixed_6_10 = RUN_JAVAC ?
+ JavacBugFixed_6_10 =
new JavacHasABug(
0 /* all */,
- ClassFileConstants.JDK1_6, 1000 /* 1.6.0_10_b08 or better - maybe before */) : null,
- JavacBugFixed_6_10_b24 = RUN_JAVAC ?
+ ClassFileConstants.JDK1_6, 1000 /* 1.6.0_10_b08 or better - maybe before */),
+ JavacBugFixed_6_10_b24 =
new JavacHasABug(
0 /* all */,
- ClassFileConstants.JDK1_6, 1010 /* 1.6.0_10_b24 or better - maybe before */) : null,
- JavacBugFixed_7 = RUN_JAVAC ?
+ ClassFileConstants.JDK1_6, 1010 /* 1.6.0_10_b24 or better - maybe before */),
+ JavacBugFixed_7 =
new JavacHasABug(
0 /* all */,
- ClassFileConstants.JDK1_7, 0 /* 1.7.0_b24 or better - maybe before */) : null,
- JavacBugFixed_901 = RUN_JAVAC ?
+ ClassFileConstants.JDK1_7, 0 /* 1.7.0_b24 or better - maybe before */),
+ JavacBugFixed_901 =
new JavacHasABug(
0 /* all */,
- ClassFileConstants.JDK9, 0100 /* 9.0.1 or better */) : null;
+ ClassFileConstants.JDK9, 0100 /* 9.0.1 or better */);
// bugs that have neither been fixed nor formally identified but which outcomes are obvious enough to clear any doubts
public static JavacHasABug
- JavacThrowsAnException = RUN_JAVAC ? // some of these are transient - that is, depend on the system on which the test is run, aka stack overflow
+ JavacThrowsAnException = // some of these are transient - that is, depend on the system on which the test is run, aka stack overflow
new JavacHasABug(
- MismatchType.JavacErrorsEclipseNone) : null,
- JavacThrowsAnExceptionForJava_1_5_0_16 = RUN_JAVAC ?
+ MismatchType.JavacErrorsEclipseNone),
+ JavacThrowsAnExceptionForJava_1_5_0_16 =
new JavacHasABug(
MismatchType.JavacErrorsEclipseNone) {
@Override
@@ -1200,27 +1192,25 @@ Excuse excuseFor(JavacCompiler compiler) {
return compiler.compliance != ClassFileConstants.JDK1_5 ||
compiler.minor != 1600 ? null : this;
}
- }: null,
- JavacThrowsAnExceptionForJava_since9_EclipseWarns = RUN_JAVAC ?
+ },
+ JavacThrowsAnExceptionForJava_since9_EclipseWarns =
new JavacHasABug(
MismatchType.JavacErrorsEclipseWarnings) {
@Override
Excuse excuseFor(JavacCompiler compiler) {
return compiler.compliance < ClassFileConstants.JDK9 ? null : this;
}
- }: null;
+ };
public static JavacHasABug
- NoWarningForMissingJavadocTag = RUN_JAVAC ?
- new JavacHasABug(MismatchType.EclipseErrorsJavacNone)
- : null,
- NoWarningForDuplicateJavadocTag = RUN_JAVAC ?
- new JavacHasABug(MismatchType.EclipseErrorsJavacNone)
- : null;
+ NoWarningForMissingJavadocTag =
+ new JavacHasABug(MismatchType.EclipseErrorsJavacNone),
+ NoWarningForDuplicateJavadocTag =
+ new JavacHasABug(MismatchType.EclipseErrorsJavacNone);
}
public static class JavacBug8179483 extends JavacHasABug {
String extraJavacOptions;
public JavacBug8179483(String extraJavacOptions) {
- super(MismatchType.EclipseErrorsJavacWarnings);
+ super(MismatchType.EclipseErrorsJavacNone);
this.extraJavacOptions = extraJavacOptions;
}
@Override
@@ -1261,6 +1251,12 @@ String getCompilerOptions() {
return super.getCompilerOptions() + this.extraJavacOptions;
}
}
+ public static class JavacBug8341408 extends JavacBugExtraJavacOptionsPlusMismatch {
+ public JavacBug8341408() {
+ super("--enable-preview -source 23 -Xlint:-preview", MismatchType.StandardOutputMismatch);
+// FIXME this.pivotCompliance = ClassFileConstants.JDK24;
+ }
+ }
}
// PREMATURE: Logger helps us monitor processes outputs (standard and error);
@@ -1346,6 +1342,59 @@ public void run() {
public AbstractRegressionTest(String name) {
super(name);
}
+
+ /* argument 'inheritedDepth' is not exposed in original API, therefore these helpers are copied below with this arg added */
+ protected static void buildMinimalComplianceTestSuite(int minimalCompliance, int inheritedDepth, TestSuite suite, Class> evaluationTestClass) {
+ int complianceLevels = getPossibleComplianceLevels();
+ for (int[] map : complianceTestLevelMapping) {
+ if ((complianceLevels & map[0]) != 0) {
+ long complianceLevelForJavaVersion = ClassFileConstants.getComplianceLevelForJavaVersion(map[1]);
+ checkCompliance(evaluationTestClass, minimalCompliance, suite, complianceLevels, inheritedDepth, map[0], map[1], getVersionString(complianceLevelForJavaVersion));
+ }
+ }
+ }
+ protected static void checkCompliance(Class> evaluationTestClass, int minimalCompliance, TestSuite suite, int complianceLevels, int inheritedDepth,
+ int abstractCompilerTestCompliance, int classFileConstantsVersion, String release) {
+ int lev = complianceLevels & abstractCompilerTestCompliance;
+ if (lev != 0) {
+ if (lev < minimalCompliance) {
+ System.err.println("Cannot run "+evaluationTestClass.getName()+" at compliance " + release + "!");
+ } else {
+ suite.addTest(buildUniqueComplianceTestSuite(evaluationTestClass, ClassFileConstants.getComplianceLevelForJavaVersion(classFileConstantsVersion), inheritedDepth));
+ }
+ }
+ }
+ public static Test buildUniqueComplianceTestSuite(Class> evaluationTestClass, long uniqueCompliance, int inheritedDepth) {
+ long highestLevel = highestComplianceLevels();
+ if (highestLevel < uniqueCompliance) {
+ String complianceString;
+ if (highestLevel == ClassFileConstants.JDK10)
+ complianceString = "10";
+ else if (highestLevel == ClassFileConstants.JDK9)
+ complianceString = "9";
+ else if (highestLevel <= CompilerOptions.getFirstSupportedJdkLevel())
+ complianceString = CompilerOptions.getFirstSupportedJavaVersion();
+ else {
+ highestLevel = ClassFileConstants.getLatestJDKLevel();
+ if (highestLevel > 0) {
+ complianceString = CompilerOptions.versionFromJdkLevel(highestLevel);
+ } else {
+ complianceString = "unknown";
+ }
+
+ }
+
+ System.err.println("Cannot run "+evaluationTestClass.getName()+" at compliance "+complianceString+"!");
+ return new TestSuite();
+ }
+ TestSuite complianceSuite = new RegressionTestSetup(uniqueCompliance);
+ List tests = buildTestsList(evaluationTestClass, inheritedDepth);
+ for (int index=0, size=tests.size(); index();
- String jdkRoots = System.getProperty("jdk.roots");
- if (jdkRoots == null) {
- javacCompilers.add(new JavacCompiler(jdkRootDirPath.toString()));
- } else {
- StringTokenizer tokenizer = new StringTokenizer(jdkRoots, File.pathSeparator);
- while (tokenizer.hasMoreTokens()) {
- javacCompilers.add(new JavacCompiler(tokenizer.nextToken()));
- }
- }
+ private void setupJavac() throws Exception {
+ // WORK make all needed inits once and for all
+ if (isFirst()) {
+ if (javacFullLog == null) {
+ // One time initialization of javac related concerns
+ // compute command lines and extract javac version
+ JAVAC_OUTPUT_DIR = new File(JAVAC_OUTPUT_DIR_NAME);
+ // WORK simplify jdk.root out
+ String jdkRootDirectory = System.getProperty("jdk.root");
+ if (jdkRootDirectory == null) {
+ jdkRootDirPath = (new Path(Util.getJREDirectory())); // requires java >= 9
+ } else {
+ jdkRootDirPath = new Path(jdkRootDirectory);
}
- // per class initialization
- CURRENT_CLASS_NAME = getClass().getName();
- dualPrintln("***************************************************************************");
- System.out.print("* Comparison with Sun Javac compiler for class ");
- dualPrintln(CURRENT_CLASS_NAME.substring(CURRENT_CLASS_NAME.lastIndexOf('.')+1) +
- " (" + TESTS_COUNTERS.get(CURRENT_CLASS_NAME) + " tests)");
+
+ StringBuilder cmdLineHeader = new StringBuilder(jdkRootDirPath.
+ append("bin").append(JAVA_NAME).toString()); // PREMATURE replace JAVA_NAME and JAVAC_NAME with locals? depends on potential reuse
+ javaCommandLineHeader = cmdLineHeader.toString();
+ cmdLineHeader = new StringBuilder(jdkRootDirPath.
+ append("bin").append(JAVAC_NAME).toString());
+ cmdLineHeader.append(" -classpath . ");
+ // start with the current directory which contains the source files
+ String version = JavacCompiler.getVersion(cmdLineHeader.toString());
+ cmdLineHeader.append(" -d ");
+ cmdLineHeader.append(JAVAC_OUTPUT_DIR_NAME.indexOf(" ") != -1 ? "\"" + JAVAC_OUTPUT_DIR_NAME + "\"" : JAVAC_OUTPUT_DIR_NAME);
+ String firstSupportedVersion = CompilerOptions.getFirstSupportedJavaVersion();
+ cmdLineHeader.append(" -source " + firstSupportedVersion + " -deprecation -Xlint "); // enable recommended warnings
+ // WORK new javac system does not do that... reconsider
+ // REVIEW consider enabling all warnings instead? Philippe does not see
+ // this as ez to use (too many changes in logs)
+ javacCommandLineHeader = cmdLineHeader.toString();
+ new File(Util.getOutputDirectory()).mkdirs();
+ // TODO maxime check why this happens to miss in some cases
+ // WORK if we keep a full log, it should not mix javac versions...
+ javacFullLogFileName = Util.getOutputDirectory() + File.separatorChar +
+ version.replace(' ', '_') + "_" +
+ (new SimpleDateFormat("yyyyMMdd_HHmmss")).format(new Date()) +
+ ".txt";
+ javacFullLog =
+ new PrintWriter(new FileOutputStream(javacFullLogFileName)); // static that is initialized once, closed at process end
+ javacFullLog.println(version); // so that the contents is self sufficient
System.out.println("***************************************************************************");
- DIFF_COUNTERS[0] = 0;
- DIFF_COUNTERS[1] = 0;
- DIFF_COUNTERS[2] = 0;
+ System.out.println("* Sun Javac compiler output archived into file:");
+ System.out.println("* " + javacFullLogFileName);
+ System.out.println("***************************************************************************");
+ javacCompilers = new ArrayList<>();
+ String jdkRoots = System.getProperty("jdk.roots");
+ if (jdkRoots == null) {
+ javacCompilers.add(new JavacCompiler(jdkRootDirPath.toString()));
+ } else {
+ StringTokenizer tokenizer = new StringTokenizer(jdkRoots, File.pathSeparator);
+ while (tokenizer.hasMoreTokens()) {
+ javacCompilers.add(new JavacCompiler(tokenizer.nextToken()));
+ }
+ }
}
+ // per class initialization
+ CURRENT_CLASS_NAME = getClass().getName();
+ dualPrintln("***************************************************************************");
+ System.out.print("* Comparison with Sun Javac compiler for class ");
+ dualPrintln(CURRENT_CLASS_NAME.substring(CURRENT_CLASS_NAME.lastIndexOf('.')+1) +
+ " (" + TESTS_COUNTERS.get(CURRENT_CLASS_NAME) + " tests)");
+ System.out.println("***************************************************************************");
+ DIFF_COUNTERS[0] = 0;
+ DIFF_COUNTERS[1] = 0;
+ DIFF_COUNTERS[2] = 0;
}
}
@@ -4094,7 +4150,7 @@ protected void tearDown() throws Exception {
Util.flushDirectoryContent(libDir);
}
super.tearDown();
- if (RUN_JAVAC) {
+ if (shouldRunJavac()) {
if (JAVAC_OUTPUT_DIR.exists()) {
Util.flushDirectoryContent(JAVAC_OUTPUT_DIR);
}
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest9.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest9.java
index 496592a596..869a418832 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest9.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest9.java
@@ -16,7 +16,6 @@
import java.io.File;
import java.util.HashMap;
import java.util.Map;
-
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.compiler.CompilationResult;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java
index 6d926945a2..dff14025be 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java
@@ -20,12 +20,10 @@
package org.eclipse.jdt.core.tests.compiler.regression;
import java.util.Map;
-
+import junit.framework.Test;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-import junit.framework.*;
-
@SuppressWarnings({ "unchecked", "rawtypes" })
public class AmbiguousMethodTest extends AbstractComparableTest {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java
index 7470b3d02d..135fd371db 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java
@@ -39,9 +39,7 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
-
import junit.framework.Test;
-
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.ToolFactory;
import org.eclipse.jdt.core.compiler.CategorizedProblem;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java
index 729752045c..63c88b5f46 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java
@@ -17,9 +17,7 @@
package org.eclipse.jdt.core.tests.compiler.regression;
import java.io.File;
import java.util.Map;
-
import junit.framework.Test;
-
import org.eclipse.jdt.core.ToolFactory;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.core.util.ClassFileBytesDisassembler;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssertionTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssertionTest.java
index 46fcf009f3..57c58ceb5b 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssertionTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssertionTest.java
@@ -13,9 +13,8 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-
import junit.framework.Test;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
@SuppressWarnings({ "rawtypes" })
public class AssertionTest extends AbstractRegressionTest {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest.java
index c313823475..fb59cf44a1 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest.java
@@ -17,13 +17,11 @@
package org.eclipse.jdt.core.tests.compiler.regression;
import java.util.Map;
-
+import junit.framework.Test;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-import junit.framework.Test;
-
@SuppressWarnings({ "unchecked", "rawtypes" })
public class AssignmentTest extends AbstractRegressionTest {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest_1_5.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest_1_5.java
index 6dafc7c59e..d68a3497c1 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest_1_5.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest_1_5.java
@@ -14,10 +14,8 @@
package org.eclipse.jdt.core.tests.compiler.regression;
import java.util.Map;
-
-import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-
import junit.framework.Test;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
@SuppressWarnings({ "unchecked", "rawtypes" })
public class AssignmentTest_1_5 extends AbstractRegressionTest {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest_1_7.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest_1_7.java
index d8b1b4bfbe..2508aa7456 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest_1_7.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest_1_7.java
@@ -14,10 +14,8 @@
package org.eclipse.jdt.core.tests.compiler.regression;
import java.util.Map;
-
-import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-
import junit.framework.Test;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
@SuppressWarnings({ "unchecked", "rawtypes" })
public class AssignmentTest_1_7 extends AbstractRegressionTest {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AutoBoxingTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AutoBoxingTest.java
index 2d87860892..be2c6c4261 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AutoBoxingTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AutoBoxingTest.java
@@ -15,9 +15,7 @@
import java.io.File;
import java.util.Map;
-
import junit.framework.Test;
-
import org.eclipse.jdt.core.ToolFactory;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.core.util.ClassFileBytesDisassembler;
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AutomaticModuleNamingTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AutomaticModuleNamingTest.java
index ccde5f7f52..b134464f78 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AutomaticModuleNamingTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AutomaticModuleNamingTest.java
@@ -17,10 +17,8 @@
import static org.eclipse.jdt.internal.compiler.env.AutomaticModuleNaming.determineAutomaticModuleNameFromFileName;
import java.io.File;
-
-import org.eclipse.jdt.core.tests.util.Util;
-
import junit.framework.Test;
+import org.eclipse.jdt.core.tests.util.Util;
public class AutomaticModuleNamingTest extends AbstractRegressionTest {
static {
diff --git a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
index 2fc06ed506..8ce9a1197d 100644
--- a/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
+++ b/jdt-patch/e434/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
@@ -47,9 +47,7 @@
import java.text.MessageFormat;
import java.util.Iterator;
import java.util.List;
-
import junit.framework.Test;
-
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
@@ -57,9 +55,9 @@
import org.eclipse.jdt.internal.compiler.batch.ClasspathDirectory;
import org.eclipse.jdt.internal.compiler.batch.ClasspathJar;
import org.eclipse.jdt.internal.compiler.batch.FileSystem;
+import org.eclipse.jdt.internal.compiler.batch.FileSystem.Classpath;
import org.eclipse.jdt.internal.compiler.batch.Main;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.batch.FileSystem.Classpath;
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
@@ -1153,6 +1151,7 @@ public void test013() {
"