### Eclipse Workspace Patch 1.0
#P org.eclipse.jdt.core
Index: compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java,v
retrieving revision 1.380
diff -u -r1.380 Scope.java
--- compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 3 Dec 2010 08:44:28 -0000 1.380
+++ compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 14 Feb 2011 10:12:10 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -615,6 +615,24 @@
break firstBound; // do not keep first bound
}
}
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=335751
+ if (compilerOptions().complianceLevel > ClassFileConstants.JDK1_6) {
+ if (typeVariable.rank >= varSuperType.rank && varSuperType.declaringElement == typeVariable.declaringElement) {
+ SimpleSet set = new SimpleSet(typeParameters.length);
+ set.add(typeVariable);
+ ReferenceBinding superBinding = varSuperType;
+ while (superBinding instanceof TypeVariableBinding) {
+ if (set.includes(superBinding)) {
+ problemReporter().hierarchyCircularity(typeVariable, varSuperType, typeRef);
+ typeVariable.tagBits |= TagBits.HierarchyHasProblems;
+ break firstBound; // do not keep first bound
+ } else {
+ set.add(superBinding);
+ superBinding = ((TypeVariableBinding)superBinding).superclass;
+ }
+ }
+ }
+ }
break;
default :
if (((ReferenceBinding) superType).isFinal()) {
Index: compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java,v
retrieving revision 1.430
diff -u -r1.430 ProblemReporter.java
--- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 16 Jan 2011 22:43:21 -0000 1.430
+++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 14 Feb 2011 10:12:24 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -2085,6 +2085,29 @@
end);
}
+public void hierarchyCircularity(TypeVariableBinding type, ReferenceBinding superType, TypeReference reference) {
+ int start = 0;
+ int end = 0;
+
+ start = reference.sourceStart;
+ end = reference.sourceEnd;
+
+ if (type == superType)
+ this.handle(
+ IProblem.HierarchyCircularitySelfReference,
+ new String[] {new String(type.readableName()) },
+ new String[] {new String(type.shortReadableName()) },
+ start,
+ end);
+ else
+ this.handle(
+ IProblem.HierarchyCircularity,
+ new String[] {new String(type.readableName()), new String(superType.readableName())},
+ new String[] {new String(type.shortReadableName()), new String(superType.shortReadableName())},
+ start,
+ end);
+}
+
public void hierarchyHasProblems(SourceTypeBinding type) {
String[] arguments = new String[] {new String(type.sourceName())};
this.handle(
#P org.eclipse.jdt.core.tests.compiler
Index: src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java,v
retrieving revision 1.6
diff -u -r1.6 GenericsRegressionTest.java
--- src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java 14 Feb 2011 05:01:03 -0000 1.6
+++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java 14 Feb 2011 10:12:28 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -27,7 +27,7 @@
// Static initializer to specify tests subset using TESTS_* static variables
// All specified tests which does not belong to the class are skipped...
static {
-// TESTS_NAMES = new String[] { "test322531j" };
+// TESTS_NAMES = new String[] { "test335751" };
// TESTS_NAMES = new String[] { "test1464" };
// TESTS_NUMBERS = new int[] { 1465 };
// TESTS_RANGE = new int[] { 1097, -1 };
@@ -1304,4 +1304,50 @@
"Zork cannot be resolved to a type\n" +
"----------\n");
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=335751 ([1.7][compiler] Cycle inheritance in type arguments is not detected)
+public void test335751() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {}\n"
+ },
+ this.complianceLevel <= ClassFileConstants.JDK1_6 ?
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X {}\n" +
+ " ^\n" +
+ "Illegal forward reference to type parameter B\n" +
+ "----------\n" :
+
+ // 1.7+ output.
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X {}\n" +
+ " ^\n" +
+ "Cycle detected: a cycle exists in the type hierarchy between B and A\n" +
+ "----------\n");
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=334121 ([1.7][compiler] Stackoverflow error if compiled in 1.7 compliance mode)
+public void test334121() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {}\n"
+ },
+ this.complianceLevel <= ClassFileConstants.JDK1_6 ?
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X {}\n" +
+ " ^\n" +
+ "Illegal forward reference to type parameter A\n" +
+ "----------\n" :
+
+ // 1.7+ output.
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X {}\n" +
+ " ^\n" +
+ "Cycle detected: the type A cannot extend/implement itself or one of its own member types\n" +
+ "----------\n");
+}
}
\ No newline at end of file