diff --git a/groovy-eclipse.setup b/groovy-eclipse.setup
index c91014cb8b..05e5a191e3 100644
--- a/groovy-eclipse.setup
+++ b/groovy-eclipse.setup
@@ -301,7 +301,7 @@
+ url="https://download.eclipse.org/eclipse/updates/4.26-I-builds/I20221109-1850"/>
diff --git a/jdt-patch/e426/Feature-org.codehaus.groovy.jdt.patch/feature.xml b/jdt-patch/e426/Feature-org.codehaus.groovy.jdt.patch/feature.xml
index ad528fe97a..a3dd30ec60 100644
--- a/jdt-patch/e426/Feature-org.codehaus.groovy.jdt.patch/feature.xml
+++ b/jdt-patch/e426/Feature-org.codehaus.groovy.jdt.patch/feature.xml
@@ -18,7 +18,7 @@
-
+
, T) of type X\n" +
"----------\n" +
- (this.complianceLevel < ClassFileConstants.JDK1_8
- ?
- "3. WARNING in X.java (at line 8)\n" +
- " foo(l, iae);\n" +
- " ^\n" +
- "Type safety: The expression of type List needs unchecked conversion to conform to List>\n"
- :
- "3. ERROR in X.java (at line 8)\n" +
- " foo(l, iae);\n" +
- " ^^^^^^^^^^^\n" +
- "Unhandled exception type Throwable\n" + // new error since 1.8 (bug 473657)
- "----------\n" +
- "4. WARNING in X.java (at line 8)\n" +
- " foo(l, iae);\n" +
- " ^\n" +
- "Type safety: The expression of type List needs unchecked conversion to conform to List>\n"
- ) +
+ "3. WARNING in X.java (at line 8)\n" +
+ " foo(l, iae);\n" +
+ " ^\n" +
+ "Type safety: The expression of type List needs unchecked conversion to conform to List>\n" +
"----------\n");
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=258798 - variation
@@ -50690,23 +50677,10 @@ public void test1437() {
" ^^^^^^^^^^^^^\n" +
"Type safety: Unchecked invocation X(List, IllegalArgumentException) of the generic constructor X(List, T) of type X\n" +
"----------\n" +
- (this.complianceLevel < ClassFileConstants.JDK1_8
- ?
- "3. WARNING in X.java (at line 8)\n" +
- " new X(l, iae);\n" +
- " ^\n" +
- "Type safety: The expression of type List needs unchecked conversion to conform to List>\n"
- :
- "3. ERROR in X.java (at line 8)\n" +
- " new X(l, iae);\n" +
- " ^^^^^^^^^^^^^\n" +
- "Unhandled exception type Throwable\n" + // new error since 1.8 (bug 473657)
- "----------\n" +
- "4. WARNING in X.java (at line 8)\n" +
- " new X(l, iae);\n" +
- " ^\n" +
- "Type safety: The expression of type List needs unchecked conversion to conform to List>\n"
- ) +
+ "3. WARNING in X.java (at line 8)\n" +
+ " new X(l, iae);\n" +
+ " ^\n" +
+ "Type safety: The expression of type List needs unchecked conversion to conform to List>\n" +
"----------\n");
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=258798 - variation
@@ -50738,23 +50712,10 @@ public void test1438() {
" ^^^^^^^^^^^^^^^\n" +
"Type safety: Unchecked invocation X(List, IllegalArgumentException) of the generic constructor X(List, T) of type X\n" +
"----------\n" +
- (this.complianceLevel < ClassFileConstants.JDK1_8
- ?
- "3. WARNING in X.java (at line 8)\n" +
- " new X(l, iae){};\n" +
- " ^\n" +
- "Type safety: The expression of type List needs unchecked conversion to conform to List>\n"
- :
- "3. ERROR in X.java (at line 8)\n" +
- " new X(l, iae){};\n" +
- " ^^^^^^^^^^^^^^^\n" +
- "Unhandled exception type Throwable\n" + // new error since 1.8 (bug 473657)
- "----------\n" +
- "4. WARNING in X.java (at line 8)\n" +
- " new X(l, iae){};\n" +
- " ^\n" +
- "Type safety: The expression of type List needs unchecked conversion to conform to List>\n"
- ) +
+ "3. WARNING in X.java (at line 8)\n" +
+ " new X(l, iae){};\n" +
+ " ^\n" +
+ "Type safety: The expression of type List needs unchecked conversion to conform to List>\n" +
"----------\n");
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=258798 - variation
@@ -50783,11 +50744,14 @@ public void test1439() {
" ^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Type safety: Unchecked invocation X(List, null) of the generic constructor X(List, T) of type X\n" +
"----------\n" +
+ (this.complianceLevel < ClassFileConstants.JDK1_8 ?
"2. ERROR in X.java (at line 7)\n" +
" this((List) null, null);\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Unhandled exception type Throwable\n" +
- "----------\n" +
+ "----------\n"
+ : "" // no error in 1.8 (bug GH472)
+ ) +
"3. WARNING in X.java (at line 7)\n" +
" this((List) null, null);\n" +
" ^^^^^^^^^^^\n" +
@@ -51071,16 +51035,22 @@ public void test1445() {
" ^^^^^^^^^^^^^^^\n" +
"Type safety: Unchecked invocation foo(List) of the generic method foo(List) of type X\n" +
"----------\n" +
+ (this.complianceLevel < ClassFileConstants.JDK1_8 ?
"4. ERROR in X.java (at line 9)\n" +
" new X(l).foo(l);\n" +
" ^^^^^^^^\n" +
"Unhandled exception type Throwable\n" +
- "----------\n" +
+ "----------\n"
+ : "" // no error in 1.8 (bug GH472)
+ ) +
+ (this.complianceLevel < ClassFileConstants.JDK1_8 ?
"5. ERROR in X.java (at line 9)\n" +
" new X(l).foo(l);\n" +
" ^^^^^^^^^^^^^^^\n" +
"Unhandled exception type Throwable\n" +
- "----------\n" +
+ "----------\n"
+ : "" // no error in 1.8 (bug GH472)
+ ) +
"6. WARNING in X.java (at line 9)\n" +
" new X(l).foo(l);\n" +
" ^\n" +
diff --git a/jdt-patch/e426/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java b/jdt-patch/e426/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java
index 89487cc890..e62b514747 100644
--- a/jdt-patch/e426/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java
+++ b/jdt-patch/e426/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2020 IBM Corporation and others.
+ * Copyright (c) 2000, 2022 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -6681,5 +6681,94 @@ public void testBug576524() {
);
}
}
+
+// https://github.com/eclipse-jdt/eclipse.jdt.core/issues/472
+// If unchecked conversion was necessary for the arguments,
+// substitute and erase the return type.
+public void testBugGH472_a() {
+ if (this.complianceLevel >= ClassFileConstants.JDK1_8) {
+ this.runConformTest(
+ new String[] {
+ "ReturnTypeTest.java",
+ "public class ReturnTypeTest {\n"
+ + " T m(Class arg1, Class arg2) { return null; }\n"
+ + "\n"
+ + " void test(Class c1, Class> c2) throws Exception {\n"
+ + " m(c1, c2).newInstance();\n"
+ + " }\n"
+ + "}"
+ }
+ );
+ }
+}
+
+// A variation for the unchecked conversion test case.
+// the type arguments contain wildcards like extends T>.
+public void testBugGH472_b() {
+ if (this.complianceLevel >= ClassFileConstants.JDK1_8) {
+ this.runConformTest(
+ new String[] {
+ "ReturnTypeTest.java",
+ "public class ReturnTypeTest {\n"
+ + " T m(Class arg1, Class extends T> arg2) { return null; }\n"
+ + "\n"
+ + " void test(Class c1, Class> c2) throws Exception {\n"
+ + " m(c1, c2).newInstance();\n"
+ + " }\n"
+ + "}"
+ }
+ );
+ }
+}
+
+// A variation for the unchecked conversion test case.
+// the type arguments contain wildcards like super T>.
+public void testBugGH472_c() {
+ if (this.complianceLevel >= ClassFileConstants.JDK1_8) {
+ this.runConformTest(
+ new String[] {
+ "ReturnTypeTest.java",
+ "public class ReturnTypeTest {\n"
+ + " T m(Class arg1, Class super T> arg2) { return null; }\n"
+ + "\n"
+ + " void test(Class c1, Class> c2) throws Exception {\n"
+ + " m(c1, c2).newInstance();\n"
+ + " }\n"
+ + "}"
+ }
+ );
+ }
+}
+
+// If unchecked conversion was necessary for the arguments,
+// substitute and erase the thrown type.
+public void testBugGH472_d() {
+ if (this.complianceLevel >= ClassFileConstants.JDK1_8) {
+ this.runConformTest(
+ new String[] {
+ "ThrowTest.java",
+ "public class ThrowTest {\n"
+ + "\n"
+ + " public static void test(MyDerivedException e, MyType t) {\n"
+ + " try {\n"
+ + " new Foo(e, t);\n"
+ + " } catch (MyDerivedException e2) {}\n"
+ + " }\n"
+ + "}\n"
+ + "\n"
+ + "class MyException extends Exception {}\n"
+ + "class MyDerivedException extends MyException {}\n"
+ + "\n"
+ + "class MyType {}\n"
+ + "\n"
+ + "class Foo {\n"
+ + " public Foo(E1 e, MyType a) throws E1 {\n"
+ + " throw e;\n"
+ + " }\n"
+ + "}"
+ }
+ );
+ }
+}
}
diff --git a/jdt-patch/e426/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java b/jdt-patch/e426/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java
index ce64f142a3..ab1a84f1f4 100644
--- a/jdt-patch/e426/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java
+++ b/jdt-patch/e426/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2019 IBM Corporation and others.
+ * Copyright (c) 2000, 2022 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -560,10 +560,10 @@ public ParameterizedGenericMethodBinding(MethodBinding originalMethod, TypeBindi
this.parameters = Scope.substitute(this, originalMethod.parameters);
// error case where exception type variable would have been substituted by a non-reference type (207573)
if (inferredWithUncheckConversion) { // JSL 18.5.2: "If unchecked conversion was necessary..."
- this.returnType = getErasure18_5_2(originalMethod.returnType, environment, hasReturnProblem); // propagate simulation of Bug JDK_8026527
+ this.returnType = getErasure18_5_2(originalMethod.returnType, environment);
this.thrownExceptions = new ReferenceBinding[originalMethod.thrownExceptions.length];
for (int i = 0; i < originalMethod.thrownExceptions.length; i++) {
- this.thrownExceptions[i] = (ReferenceBinding) getErasure18_5_2(originalMethod.thrownExceptions[i], environment, false); // no excuse for exceptions
+ this.thrownExceptions[i] = (ReferenceBinding) getErasure18_5_2(originalMethod.thrownExceptions[i], environment);
}
} else {
this.returnType = Scope.substitute(this, originalMethod.returnType);
@@ -608,13 +608,12 @@ public ParameterizedGenericMethodBinding(MethodBinding originalMethod, TypeBindi
}
}
- TypeBinding getErasure18_5_2(TypeBinding type, LookupEnvironment env, boolean substitute) {
+ TypeBinding getErasure18_5_2(TypeBinding type, LookupEnvironment env) {
// opportunistic interpretation of (JLS 18.5.2):
// "If unchecked conversion was necessary ..., then ...
// the return type and thrown types of the invocation type of m are given by
// the erasure of the return type and thrown types of m's type."
- if (substitute)
- type = Scope.substitute(this, type);
+ type = Scope.substitute(this, type); // compliant with Bug JDK-8135087: Erasure for unchecked invocation happens after inference
return env.convertToRawType(type.erasure(), true);
}
diff --git a/jdt-patch/e426/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IClasspathContainer.java b/jdt-patch/e426/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IClasspathContainer.java
index 6f097c8557..45047197cf 100644
--- a/jdt-patch/e426/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IClasspathContainer.java
+++ b/jdt-patch/e426/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IClasspathContainer.java
@@ -14,6 +14,7 @@
package org.eclipse.jdt.core;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.internal.core.JavaModelManager;
/**
* Interface of a classpath container.
@@ -141,5 +142,16 @@ public interface IClasspathContainer {
* @return IPath - the container path that is associated with this container
*/
IPath getPath();
+
+ /**
+ * Answer the IDs of all registered classpath containers (extensions at extension point
+ * {@link JavaModelManager#CPCONTAINER_INITIALIZER_EXTPOINT_ID}).
+ * @return array of strings as extracted from the "id" attribute from all registered
+ * classpath containers.
+ * @since 3.32
+ */
+ public static String[] getRegisteredContainerIds() {
+ return JavaModelManager.getRegisteredContainerIDs();
+ }
}
diff --git a/jdt-patch/e426/org.eclipse.jdt.core/scripts/binary/META-INF/MANIFEST.MF b/jdt-patch/e426/org.eclipse.jdt.core/scripts/binary/META-INF/MANIFEST.MF
index 9f2ffa1e06..d3570bc6c7 100644
--- a/jdt-patch/e426/org.eclipse.jdt.core/scripts/binary/META-INF/MANIFEST.MF
+++ b/jdt-patch/e426/org.eclipse.jdt.core/scripts/binary/META-INF/MANIFEST.MF
@@ -8,6 +8,7 @@ Bundle-ClassPath: .
Bundle-Vendor: Eclipse.org
Export-Package: org.eclipse.jdt.core,
org.eclipse.jdt.core.compiler,
+ org.eclipse.jdt.core.compiler.batch,
org.eclipse.jdt.internal.antadapter;x-internal:=true,
org.eclipse.jdt.internal.compiler;x-internal:=true,
org.eclipse.jdt.internal.compiler.apt.dispatch;x-internal:=true,
diff --git a/jdt-patch/e426/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexer.java b/jdt-patch/e426/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexer.java
index 82e1f4a2de..8666c61ee4 100644
--- a/jdt-patch/e426/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexer.java
+++ b/jdt-patch/e426/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexer.java
@@ -82,7 +82,7 @@ public class SourceIndexer extends AbstractIndexer implements ITypeRequestor, Su
private CompilationUnit compilationUnit;
private CompilationUnitDeclaration cud;
private static final boolean DEBUG = false;
-
+
public SourceIndexer(SearchDocument document) {
super(document);
this.requestor = new SourceIndexerRequestor(this);
@@ -120,7 +120,7 @@ public void indexDocument() {
}
}
}
-
+
@Override
public void accept(IBinaryType binaryType, PackageBinding packageBinding, AccessRestriction accessRestriction) {
this.lookupEnvironment.createBinaryTypeFrom(binaryType, packageBinding, accessRestriction);
@@ -142,9 +142,9 @@ public void accept(ISourceType[] sourceTypes, PackageBinding packageBinding, Acc
SourceTypeElementInfo elementInfo = (SourceTypeElementInfo) sourceType;
IType type = elementInfo.getHandle();
ICompilationUnit sourceUnit = (ICompilationUnit) type.getCompilationUnit();
- accept(sourceUnit, accessRestriction);
+ accept(sourceUnit, accessRestriction);
}
-
+
public void resolveDocument() {
try {
IPath path = new Path(this.document.getPath());
@@ -196,7 +196,14 @@ private void purgeMethodStatements(TypeDeclaration type) {
AbstractMethodDeclaration[] methods = type.methods;
for (int j = 0, length = methods == null ? 0 : methods.length; j < length; j++) {
AbstractMethodDeclaration method = methods[j];
- if (method != null && (method.bits & ASTNode.HasFunctionalInterfaceTypes) == 0) {
+ /*
+ * In case the method defines a local type, skip purging the method body.
+ * We don't know if the local type defines a method that uses a method reference or a lambda.
+ * See:
+ * https://github.com/eclipse-jdt/eclipse.jdt.core/issues/432
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=566435
+ */
+ if (method != null && (method.bits & (ASTNode.HasFunctionalInterfaceTypes | ASTNode.HasLocalType)) == 0) {
method.statements = null;
method.javadoc = null;
}
@@ -219,11 +226,11 @@ public void indexResolvedDocument() {
if (lambdaExpression.binding != null && lambdaExpression.binding.isValidBinding()) {
final char[] superinterface = lambdaExpression.resolvedType.sourceName();
if (DEBUG) {
- System.out.println('\t' + new String(superinterface) + '.' +
+ System.out.println('\t' + new String(superinterface) + '.' +
new String(lambdaExpression.descriptor.selector) + "-> {}"); //$NON-NLS-1$
}
SourceIndexer.this.addIndexEntry(IIndexConstants.METHOD_DECL, MethodPattern.createIndexKey(lambdaExpression.descriptor.selector, lambdaExpression.descriptor.parameters.length));
-
+
addClassDeclaration(0, // most entries are blank, that is fine, since lambda type/method cannot be searched.
CharOperation.NO_CHAR, // package name
ONE_ZERO,
diff --git a/pom.xml b/pom.xml
index 8e4c0b124d..a11f64365b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -129,7 +129,7 @@
milestone
p2
- https://download.eclipse.org/eclipse/updates/4.26-I-builds/I20221020-1800
+ https://download.eclipse.org/eclipse/updates/4.26-I-builds/I20221109-1850