### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java,v retrieving revision 1.124.2.1 diff -u -r1.124.2.1 MethodVerifier15.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 28 Jul 2011 17:52:23 -0000 1.124.2.1 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 3 Aug 2011 17:08:54 -0000 @@ -196,7 +196,7 @@ final MethodBinding thisMethod = current[i]; if (thisMethod.areParameterErasuresEqual(bridge) && thisMethod.returnType.erasure() == bridge.returnType.erasure()) { // use inherited method for problem reporting. - problemReporter(thisMethod).methodNameClash(thisMethod, inheritedMethod.declaringClass.isRawType() ? inheritedMethod : inheritedMethod.original()); + problemReporter(thisMethod).methodNameClash(thisMethod, inheritedMethod.declaringClass.isRawType() ? inheritedMethod : inheritedMethod.original(), ProblemSeverities.Error); return; } } @@ -725,6 +725,13 @@ MethodBinding original = methodToCheck.original(); // can be the same as inherited if (!current.areParameterErasuresEqual(original)) return false; + int severity = ProblemSeverities.Error; + if (this.environment.globalOptions.complianceLevel == ClassFileConstants.JDK1_6) { + // for 1.6 return types also need to be checked + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=317719 + if (current.returnType.erasure() != original.returnType.erasure()) + severity = ProblemSeverities.Warning; + } if (!treatAsSynthetic) { // For a user method, see if current class overrides the inherited method. If it does, // then any grievance we may have ought to be against the current class's method and @@ -748,7 +755,8 @@ if (!current.areParameterErasuresEqual(original)) return false; original = inherited.original(); // For error reporting use, inherited.original() - problemReporter(current).methodNameClash(current, inherited.declaringClass.isRawType() ? inherited : original); + problemReporter(current).methodNameClash(current, inherited.declaringClass.isRawType() ? inherited : original, severity); + if (severity == ProblemSeverities.Warning) return false; return true; } public boolean doesMethodOverride(MethodBinding method, MethodBinding inheritedMethod) { Index: compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java,v retrieving revision 1.189.2.1 diff -u -r1.189.2.1 SourceTypeBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 28 Jul 2011 17:52:22 -0000 1.189.2.1 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 3 Aug 2011 17:08:58 -0000 @@ -26,6 +26,7 @@ import org.eclipse.jdt.internal.compiler.ast.TypeReference; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.impl.Constant; +import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities; import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable; import org.eclipse.jdt.internal.compiler.util.Util; @@ -1183,6 +1184,8 @@ // find & report collision cases boolean complyTo15 = this.scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5; + boolean compliance16 = this.scope.compilerOptions().complianceLevel == ClassFileConstants.JDK1_6; + int severity = ProblemSeverities.Error; for (int i = 0, length = this.methods.length; i < length; i++) { MethodBinding method = resolvedMethods[i]; if (method == null) @@ -1195,12 +1198,94 @@ continue nextSibling; if (!CharOperation.equals(selector, method2.selector)) break nextSibling; // methods with same selector are contiguous + if (complyTo15 && method.returnType != null && method2.returnType != null) { + // 8.4.2, for collision to be detected between m1 and m2: + // signature(m1) == signature(m2) i.e. same arity, same type parameter count, can be substituted + // signature(m1) == erasure(signature(m2)) or erasure(signature(m1)) == signature(m2) + TypeBinding[] params1 = method.parameters; + TypeBinding[] params2 = method2.parameters; + int pLength = params1.length; + if (pLength != params2.length) + continue nextSibling; + + TypeVariableBinding[] vars = method.typeVariables; + TypeVariableBinding[] vars2 = method2.typeVariables; + boolean equalTypeVars = vars == vars2; + MethodBinding subMethod = method2; + if (!equalTypeVars) { + MethodBinding temp = method.computeSubstitutedMethod(method2, this.scope.environment()); + if (temp != null) { + equalTypeVars = true; + subMethod = temp; + } + } + boolean equalParams = method.areParametersEqual(subMethod); + if (equalParams && equalTypeVars) { + // duplicates regardless of return types + } else if (equalParams || method.areParameterErasuresEqual(method2)){ + // with fix for http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950 + // we now ignore return types in 1.7 when detecting duplicates, just as we did before 1.5 + // name clash for sure if not duplicates, report as duplicates + // Only in 1.6, we have to make sure even return types are same + if (compliance16) { + if (method.returnType.erasure() != subMethod.returnType.erasure()) { + severity = ProblemSeverities.Warning; + } + // else return types also equal. All conditions satisfied + // to give error in 1.6 compliance as well. + } + } else if (!equalTypeVars && vars != Binding.NO_TYPE_VARIABLES && vars2 != Binding.NO_TYPE_VARIABLES) { + // type variables are different so we can distinguish between methods + continue nextSibling; + } else if (pLength > 0) { + // check to see if the erasure of either method is equal to the other + int index = pLength; + for (; --index >= 0;) { + if (params1[index] != params2[index].erasure()) + break; + if (params1[index] == params2[index]) { + TypeBinding type = params1[index].leafComponentType(); + if (type instanceof SourceTypeBinding && type.typeVariables() != Binding.NO_TYPE_VARIABLES) { + index = pLength; // handle comparing identical source types like X... its erasure is itself BUT we need to answer false + break; + } + } + } + if (index >= 0 && index < pLength) { + for (index = pLength; --index >= 0;) + if (params1[index].erasure() != params2[index]) + break; + } + if (index >= 0) + continue nextSibling; + } + } else if (!method.areParametersEqual(method2)) { // prior to 1.5, parameter identity meant a collision case + continue nextSibling; + } - if (complyTo15 ? !method.areParameterErasuresEqual(method2) : !method.areParametersEqual(method2)) - continue nextSibling; // otherwise duplicates / name clash +// if (complyTo15) { +// if (method.areParameterErasuresEqual(method2)) { +// // we now ignore return types in 1.7 when detecting duplicates, just as we did before 1.5 +// // Only in 1.6, we have to make sure even return types are different +// // https://bugs.eclipse.org/bugs/show_bug.cgi?id=317719 +// if (compliance16 && method.returnType != null && method2.returnType != null) { +// if (method.returnType.erasure() != method2.returnType.erasure()) { +// severity = ProblemSeverities.Warning; +// } +// // else return types also equal. All conditions satisfied +// // to give error in 1.6 compliance as well. +// } +// } else { +// continue nextSibling; +// } +// } else if (!method.areParametersEqual(method2)) { +// // prior to 1.5, parameters identical meant a collision case +// continue nextSibling; +// } + // otherwise duplicates / name clash boolean isEnumSpecialMethod = isEnum() && (CharOperation.equals(selector,TypeConstants.VALUEOF) || CharOperation.equals(selector,TypeConstants.VALUES)); // report duplicate - boolean removeMethod2 = true; + boolean removeMethod2 = (severity == ProblemSeverities.Error) ? true : false; // do not remove if in 1.6 and just a warning given if (methodDecl == null) { methodDecl = method.sourceMethod(); // cannot be retrieved after binding is lost & may still be null if method is special if (methodDecl != null && methodDecl.binding != null) { // ensure its a valid user defined method @@ -1210,7 +1295,7 @@ // remove user defined methods & keep the synthetic removeMethod = true; } else { - this.scope.problemReporter().duplicateMethodInType(this, methodDecl, method.areParametersEqual(method2)); + this.scope.problemReporter().duplicateMethodInType(this, methodDecl, method.areParametersEqual(method2), severity); } if (removeMethod) { removeMethod2 = false; @@ -1229,7 +1314,7 @@ this.scope.problemReporter().duplicateEnumSpecialMethod(this, method2Decl); removeMethod2 = true; } else { - this.scope.problemReporter().duplicateMethodInType(this, method2Decl, method.areParametersEqual(method2)); + this.scope.problemReporter().duplicateMethodInType(this, method2Decl, method.areParametersEqual(method2), severity); } if (removeMethod2) { method2Decl.binding = null; 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.436.2.1 diff -u -r1.436.2.1 ProblemReporter.java --- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 28 Jul 2011 17:52:29 -0000 1.436.2.1 +++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 3 Aug 2011 17:09:11 -0000 @@ -1593,7 +1593,7 @@ nodeSourceStart(local, location), nodeSourceEnd(local, location)); } -public void duplicateMethodInType(SourceTypeBinding type, AbstractMethodDeclaration methodDecl, boolean equalParameters) { +public void duplicateMethodInType(SourceTypeBinding type, AbstractMethodDeclaration methodDecl, boolean equalParameters, int severity) { MethodBinding method = methodDecl.binding; if (equalParameters) { this.handle( @@ -1606,6 +1606,7 @@ new String(methodDecl.selector), new String(method.declaringClass.shortReadableName()), typesAsString(method, true)}, + severity, methodDecl.sourceStart, methodDecl.sourceEnd); } else { @@ -1626,6 +1627,7 @@ new String(method.declaringClass.shortReadableName()), typesAsString(method, true), typesAsString(method, erasures, true) }, + severity, methodDecl.sourceStart, methodDecl.sourceEnd); } @@ -5091,7 +5093,7 @@ method.sourceEnd); } -public void methodNameClash(MethodBinding currentMethod, MethodBinding inheritedMethod) { +public void methodNameClash(MethodBinding currentMethod, MethodBinding inheritedMethod, int severity) { this.handle( IProblem.MethodNameClash, new String[] { @@ -5108,6 +5110,7 @@ typesAsString(inheritedMethod, true), new String(inheritedMethod.declaringClass.shortReadableName()), }, + severity, currentMethod.sourceStart(), currentMethod.sourceEnd()); } #P org.eclipse.jdt.core.tests Index: Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/NegativeTest.java =================================================================== RCS file: /home/cvs/numbat/org.eclipse.jdt.core.tests/Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/NegativeTest.java,v retrieving revision 1.347 diff -u -r1.347 NegativeTest.java --- Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/NegativeTest.java 28 Jul 2011 17:25:17 -0000 1.347 +++ Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/NegativeTest.java 3 Aug 2011 17:10:34 -0000 @@ -22,7 +22,7 @@ public class NegativeTest extends AbstractRegressionTest { static { -// TESTS_NUMBERS = new int[] { 275 }; +// TESTS_NUMBERS = new int[] { 92 }; } public NegativeTest(String name) { super(name); @@ -3697,16 +3697,21 @@ " }\n" + "}", }, - "----------\n" + - "1. ERROR in p\\Toplevel12.java (at line 4)\n" + - " Object local(){\n" + - " ^^^^^^^\n" + - "Duplicate method local() in type Toplevel12\n" + - "----------\n" + - "2. ERROR in p\\Toplevel12.java (at line 17)\n" + - " void local(){\n" + - " ^^^^^^^\n" + - "Duplicate method local() in type Toplevel12\n" + + "----------\n" + + "1. ERROR in p\\Toplevel12.java (at line 4)\n" + + " Object local(){\n" + + " ^^^^^^^\n" + + "Duplicate method local() in type Toplevel12\n" + + "----------\n" + + "2. ERROR in p\\Toplevel12.java (at line 15)\n" + + " return new Package2.Sub();\n" + + " ^^^^^^^^^^^^^^^^^^\n" + + "No enclosing instance of type Package2 is accessible. Must qualify the allocation with an enclosing instance of type Package2 (e.g. x.new A() where x is an instance of Package2).\n" + + "----------\n" + + "3. ERROR in p\\Toplevel12.java (at line 17)\n" + + " void local(){\n" + + " ^^^^^^^\n" + + "Duplicate method local() in type Toplevel12\n" + "----------\n" ); } #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java,v retrieving revision 1.75.6.1 diff -u -r1.75.6.1 AmbiguousMethodTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java 28 Jul 2011 17:52:08 -0000 1.75.6.1 +++ src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java 3 Aug 2011 17:10:41 -0000 @@ -12,6 +12,7 @@ import java.util.Map; +import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import junit.framework.*; @@ -19,7 +20,7 @@ public class AmbiguousMethodTest extends AbstractComparableTest { static { -// TESTS_NAMES = new String [] { "test087" }; +// TESTS_NAMES = new String [] { "test010a" }; } public AmbiguousMethodTest(String name) { super(name); @@ -241,6 +242,34 @@ } public void test005() { // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950 + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in X.java (at line 2)\n" + + " void foo() { }\n" + + " ^^^^^\n" + + "Duplicate method foo() in type X\n" + + "----------\n" + + "2. WARNING in X.java (at line 3)\n" + + " N foo() { return null; }\n" + + " ^^^^^\n" + + "Duplicate method foo() in type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 5)\n" + + " new X().foo();\n" + + " ^^^\n" + + "The method foo() is ambiguous for the type X\n" + + "----------\n": + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " void foo() { }\n" + + " ^^^^^\n" + + "Duplicate method foo() in type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " N foo() { return null; }\n" + + " ^^^^^\n" + + "Duplicate method foo() in type X\n" + + "----------\n"; this.runNegativeTest( new String[] { "X.java", @@ -254,18 +283,7 @@ "class A {}\n" + "class B {}\n" }, - "----------\n" + - "1. ERROR in X.java (at line 2)\n" + - " void foo() { }\n" + - " ^^^^^\n" + - "Duplicate method foo() in type X\n" + - "----------\n" + - "2. ERROR in X.java (at line 3)\n" + - " N foo() { return null; }\n" + - " ^^^^^\n" + - "Duplicate method foo() in type X\n" + - "----------\n" - ); + expectedCompilerLog); /* javac 7 X.java:3: name clash: foo() and foo() have the same erasure N foo() { return null; } @@ -278,23 +296,29 @@ } public void test006() { // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950 - this.runNegativeTest( - new String[] { - "X.java", - "public class X {\n" + - " void test() {\n" + - " new Y().foo(\"X\");\n" + - " new Y().foo2(\"X\");\n" + - " }\n" + - " U1 foo(U1 t) {return null;}\n" + - " U2 foo2(U2 t) {return null;}\n" + - "}\n" + - "class Y extends X {\n" + - " void foo(T2 t) {}\n" + - " void foo2(T2 t) {}\n" + - "}\n" - }, - "----------\n" + + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " new Y().foo(\"X\");\n" + + " ^^^\n" + + "The method foo(Object) is ambiguous for the type Y\n" + + "----------\n" + + "2. ERROR in X.java (at line 4)\n" + + " new Y().foo2(\"X\");\n" + + " ^^^^\n" + + "The method foo2(Object) is ambiguous for the type Y\n" + + "----------\n" + + "3. WARNING in X.java (at line 10)\n" + + " void foo(T2 t) {}\n" + + " ^^^^^^^^^\n" + + "Name clash: The method foo(T2) of type Y has the same erasure as foo(U1) of type X but does not override it\n" + + "----------\n" + + "4. WARNING in X.java (at line 11)\n" + + " void foo2(T2 t) {}\n" + + " ^^^^^^^^^^\n" + + "Name clash: The method foo2(T2) of type Y has the same erasure as foo2(U2) of type X but does not override it\n" + + "----------\n": + "----------\n" + "1. ERROR in X.java (at line 3)\n" + " new Y().foo(\"X\");\n" + " ^^^\n" + @@ -314,7 +338,24 @@ " void foo2(T2 t) {}\n" + " ^^^^^^^^^^\n" + "Name clash: The method foo2(T2) of type Y has the same erasure as foo2(U2) of type X but does not override it\n" + - "----------\n" + "----------\n"; + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " void test() {\n" + + " new Y().foo(\"X\");\n" + + " new Y().foo2(\"X\");\n" + + " }\n" + + " U1 foo(U1 t) {return null;}\n" + + " U2 foo2(U2 t) {return null;}\n" + + "}\n" + + "class Y extends X {\n" + + " void foo(T2 t) {}\n" + + " void foo2(T2 t) {}\n" + + "}\n" + }, + expectedCompilerLog ); /* javac 7 X.java:3: reference to foo is ambiguous, both method foo(U1) in X and method @@ -541,6 +582,29 @@ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=106090 public void test011a() { // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950 + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in Combined.java (at line 2)\n" + + " > void pickOne(T value) throws ExOne {}\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Method pickOne(T) has the same erasure pickOne(Comparable) as another method in type Combined\n" + + "----------\n" + + "2. WARNING in Combined.java (at line 3)\n" + + " T pickOne(Comparable value) throws ExTwo { return null;}\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Method pickOne(Comparable) has the same erasure pickOne(Comparable) as another method in type Combined\n" + + "----------\n": + "----------\n" + + "1. ERROR in Combined.java (at line 2)\n" + + " > void pickOne(T value) throws ExOne {}\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Method pickOne(T) has the same erasure pickOne(Comparable) as another method in type Combined\n" + + "----------\n" + + "2. ERROR in Combined.java (at line 3)\n" + + " T pickOne(Comparable value) throws ExTwo { return null;}\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Method pickOne(Comparable) has the same erasure pickOne(Comparable) as another method in type Combined\n" + + "----------\n"; this.runNegativeTest( new String[] { "Combined.java", @@ -555,17 +619,7 @@ "class ExOne extends Exception {static final long serialVersionUID = 1;}\n" + "class ExTwo extends Exception {static final long serialVersionUID = 2;}" }, - "----------\n" + - "1. ERROR in Combined.java (at line 2)\n" + - " > void pickOne(T value) throws ExOne {}\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Method pickOne(T) has the same erasure pickOne(Comparable) as another method in type Combined\n" + - "----------\n" + - "2. ERROR in Combined.java (at line 3)\n" + - " T pickOne(Comparable value) throws ExTwo { return null;}\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Method pickOne(Comparable) has the same erasure pickOne(Comparable) as another method in type Combined\n" + - "----------\n" + expectedCompilerLog ); /* javac 7 X.java:3: name clash: pickOne(Comparable) and pickOne(T#2) have the same erasure @@ -580,17 +634,28 @@ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=106090 public void test011b() { // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950 - this.runNegativeTest( - new String[] { - "Test1.java", - "public class Test1 {\n" + - " > void pickOne(T value) throws ExOne {}\n" + - " T pickOne(Comparable value) throws ExTwo { return null;}\n" + - " void pickOne2(Test1 c) throws ExOne { c.pickOne((Comparable) \"test\"); }\n" + - "}\n" + - "class ExOne extends Exception {static final long serialVersionUID = 1;}\n" + - "class ExTwo extends Exception {static final long serialVersionUID = 2;}" - }, + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in Test1.java (at line 2)\n" + + " > void pickOne(T value) throws ExOne {}\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Method pickOne(T) has the same erasure pickOne(Comparable) as another method in type Test1\n" + + "----------\n" + + "2. WARNING in Test1.java (at line 3)\n" + + " T pickOne(Comparable value) throws ExTwo { return null;}\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Method pickOne(Comparable) has the same erasure pickOne(Comparable) as another method in type Test1\n" + + "----------\n" + + "3. WARNING in Test1.java (at line 4)\n" + + " void pickOne2(Test1 c) throws ExOne { c.pickOne((Comparable) \"test\"); }\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation pickOne(Comparable) of the generic method pickOne(T) of type Test1\n" + + "----------\n" + + "4. WARNING in Test1.java (at line 4)\n" + + " void pickOne2(Test1 c) throws ExOne { c.pickOne((Comparable) \"test\"); }\n" + + " ^^^^^^^^^^\n" + + "Comparable is a raw type. References to generic type Comparable should be parameterized\n" + + "----------\n": "----------\n" + "1. ERROR in Test1.java (at line 2)\n" + " > void pickOne(T value) throws ExOne {}\n" + @@ -611,7 +676,19 @@ " void pickOne2(Test1 c) throws ExOne { c.pickOne((Comparable) \"test\"); }\n" + " ^^^^^^^^^^\n" + "Comparable is a raw type. References to generic type Comparable should be parameterized\n" + - "----------\n" + "----------\n"; + this.runNegativeTest( + new String[] { + "Test1.java", + "public class Test1 {\n" + + " > void pickOne(T value) throws ExOne {}\n" + + " T pickOne(Comparable value) throws ExTwo { return null;}\n" + + " void pickOne2(Test1 c) throws ExOne { c.pickOne((Comparable) \"test\"); }\n" + + "}\n" + + "class ExOne extends Exception {static final long serialVersionUID = 1;}\n" + + "class ExTwo extends Exception {static final long serialVersionUID = 2;}" + }, + expectedCompilerLog ); /* javac 7 X.java:3: name clash: pickOne(Comparable) and pickOne(T#2) have the same erasure @@ -1570,28 +1647,43 @@ // variant: having both methods in the same class should not change anything public void test021() { // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950 - this.runNegativeTest( - new String[] { - "Y.java", - "class X {\n" + - "}\n" + - "public class Y extends X {\n" + - " public static Y make(Class clazz) {\n" + - " System.out.print(true);\n" + - " return new Y();\n" + - " }\n" + - " public static X make(Class clazz) {\n" + - " System.out.print(false);\n" + - " return new X();\n" + - " }\n" + - " public static void main(String[] args) throws Exception {\n" + - " Y.make(getClazz());\n" + - " }\n" + - " public static Class getClazz() {\n" + - " return String.class;\n" + - " }\n" + - "}" - }, + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in Y.java (at line 3)\n" + + " public class Y extends X {\n" + + " ^^^^^^\n" + + "The type parameter V should not be bounded by the final type String. Final types cannot be further extended\n" + + "----------\n" + + "2. WARNING in Y.java (at line 4)\n" + + " public static Y make(Class clazz) {\n" + + " ^^^^^^\n" + + "The type parameter W should not be bounded by the final type String. Final types cannot be further extended\n" + + "----------\n" + + "3. WARNING in Y.java (at line 4)\n" + + " public static Y make(Class clazz) {\n" + + " ^^^^^^^^^^^^^^^^^^^^\n" + + "Method make(Class) has the same erasure make(Class) as another method in type Y\n" + + "----------\n" + + "4. WARNING in Y.java (at line 8)\n" + + " public static X make(Class clazz) {\n" + + " ^^^^^^^^^^^^^^^^^^^^\n" + + "Method make(Class) has the same erasure make(Class) as another method in type Y\n" + + "----------\n" + + "5. WARNING in Y.java (at line 13)\n" + + " Y.make(getClazz());\n" + + " ^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation make(Class) of the generic method make(Class) of type Y\n" + + "----------\n" + + "6. WARNING in Y.java (at line 13)\n" + + " Y.make(getClazz());\n" + + " ^^^^^^^^^^\n" + + "Type safety: The expression of type Class needs unchecked conversion to conform to Class\n" + + "----------\n" + + "7. WARNING in Y.java (at line 15)\n" + + " public static Class getClazz() {\n" + + " ^^^^^\n" + + "Class is a raw type. References to generic type Class should be parameterized\n" + + "----------\n": "----------\n" + "1. WARNING in Y.java (at line 3)\n" + " public class Y extends X {\n" + @@ -1627,7 +1719,30 @@ " public static Class getClazz() {\n" + " ^^^^^\n" + "Class is a raw type. References to generic type Class should be parameterized\n" + - "----------\n" + "----------\n"; + this.runNegativeTest( + new String[] { + "Y.java", + "class X {\n" + + "}\n" + + "public class Y extends X {\n" + + " public static Y make(Class clazz) {\n" + + " System.out.print(true);\n" + + " return new Y();\n" + + " }\n" + + " public static X make(Class clazz) {\n" + + " System.out.print(false);\n" + + " return new X();\n" + + " }\n" + + " public static void main(String[] args) throws Exception {\n" + + " Y.make(getClazz());\n" + + " }\n" + + " public static Class getClazz() {\n" + + " return String.class;\n" + + " }\n" + + "}" + }, + expectedCompilerLog ); /* javac 7 X.java:8: name clash: make(Class) and make(Class) have the same erasure @@ -1659,29 +1774,58 @@ // variant: using instances triggers raw methods, which are ambiguous public void test022() { // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950 - this.runNegativeTest( - new String[] { - "X.java", - "public class X {\n" + - "}\n" + - "class Y extends X {\n" + - " public Y make(Class clazz) {\n" + - " return new Y();\n" + - " }\n" + - " public X make(Class clazz) {\n" + - " return new X();\n" + - " }\n" + - " public static void main(String[] args) throws Exception {\n" + - " Y y = new Y();\n" + - " y.make(String.class);\n" + - " y.make(getClazz());\n" + - " y.make(getClazz().newInstance().getClass());\n" + - " }\n" + - " public static Class getClazz() {\n" + - " return String.class;\n" + - " }\n" + - "}" - }, + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " class Y extends X {\n" + + " ^^^^^^\n" + + "The type parameter V should not be bounded by the final type String. Final types cannot be further extended\n" + + "----------\n" + + "2. WARNING in X.java (at line 4)\n" + + " public Y make(Class clazz) {\n" + + " ^^^^^^\n" + + "The type parameter W should not be bounded by the final type String. Final types cannot be further extended\n" + + "----------\n" + + "3. WARNING in X.java (at line 4)\n" + + " public Y make(Class clazz) {\n" + + " ^^^^^^^^^^^^^^^^^^^^\n" + + "Method make(Class) has the same erasure make(Class) as another method in type Y\n" + + "----------\n" + + "4. WARNING in X.java (at line 7)\n" + + " public X make(Class clazz) {\n" + + " ^^^^^^^^^^^^^^^^^^^^\n" + + "Method make(Class) has the same erasure make(Class) as another method in type Y\n" + + "----------\n" + + "5. WARNING in X.java (at line 11)\n" + + " Y y = new Y();\n" + + " ^\n" + + "Y is a raw type. References to generic type Y should be parameterized\n" + + "----------\n" + + "6. WARNING in X.java (at line 11)\n" + + " Y y = new Y();\n" + + " ^\n" + + "Y is a raw type. References to generic type Y should be parameterized\n" + + "----------\n" + + "7. ERROR in X.java (at line 12)\n" + + " y.make(String.class);\n" + + " ^^^^\n" + + "The method make(Class) is ambiguous for the type Y\n" + + "----------\n" + + "8. ERROR in X.java (at line 13)\n" + + " y.make(getClazz());\n" + + " ^^^^\n" + + "The method make(Class) is ambiguous for the type Y\n" + + "----------\n" + + "9. ERROR in X.java (at line 14)\n" + + " y.make(getClazz().newInstance().getClass());\n" + + " ^^^^\n" + + "The method make(Class) is ambiguous for the type Y\n" + + "----------\n" + + "10. WARNING in X.java (at line 16)\n" + + " public static Class getClazz() {\n" + + " ^^^^^\n" + + "Class is a raw type. References to generic type Class should be parameterized\n" + + "----------\n": "----------\n" + "1. WARNING in X.java (at line 3)\n" + " class Y extends X {\n" + @@ -1732,7 +1876,31 @@ " public static Class getClazz() {\n" + " ^^^^^\n" + "Class is a raw type. References to generic type Class should be parameterized\n" + - "----------\n" + "----------\n"; + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + "}\n" + + "class Y extends X {\n" + + " public Y make(Class clazz) {\n" + + " return new Y();\n" + + " }\n" + + " public X make(Class clazz) {\n" + + " return new X();\n" + + " }\n" + + " public static void main(String[] args) throws Exception {\n" + + " Y y = new Y();\n" + + " y.make(String.class);\n" + + " y.make(getClazz());\n" + + " y.make(getClazz().newInstance().getClass());\n" + + " }\n" + + " public static Class getClazz() {\n" + + " return String.class;\n" + + " }\n" + + "}" + }, + expectedCompilerLog ); /* javac 7 X.java:7: name clash: make(Class) and make(Class) have the same erasure @@ -1884,6 +2052,29 @@ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=162026 // variant public void test027() { + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in J.java (at line 2)\n" + + " T foo(final Number p);\n" + + " ^^^^^^^^^^^^^^^^^^^\n" + + "Duplicate method foo(Number) in type J\n" + + "----------\n" + + "2. WARNING in J.java (at line 3)\n" + + " Float foo(final Number p);\n" + + " ^^^^^^^^^^^^^^^^^^^\n" + + "Duplicate method foo(Number) in type J\n" + + "----------\n": + "----------\n" + + "1. ERROR in J.java (at line 2)\n" + + " T foo(final Number p);\n" + + " ^^^^^^^^^^^^^^^^^^^\n" + + "Duplicate method foo(Number) in type J\n" + + "----------\n" + + "2. ERROR in J.java (at line 3)\n" + + " Float foo(final Number p);\n" + + " ^^^^^^^^^^^^^^^^^^^\n" + + "Duplicate method foo(Number) in type J\n" + + "----------\n"; this.runNegativeTest( new String[] { "J.java", @@ -1892,17 +2083,7 @@ " Float foo(final Number p);\n" + "}", }, - "----------\n" + - "1. ERROR in J.java (at line 2)\n" + - " T foo(final Number p);\n" + - " ^^^^^^^^^^^^^^^^^^^\n" + - "Duplicate method foo(Number) in type J\n" + - "----------\n" + - "2. ERROR in J.java (at line 3)\n" + - " Float foo(final Number p);\n" + - " ^^^^^^^^^^^^^^^^^^^\n" + - "Duplicate method foo(Number) in type J\n" + - "----------\n"); + expectedCompilerLog); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=162065 public void test028() { @@ -3274,6 +3455,209 @@ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=268837 // See that this test case exhibits the bug 345947 public void test076() { + String output = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in X.java (at line 8)\n" + + " J b();\n" + + " ^^^\n" + + "Name clash: The method b() of type J has the same erasure as b() of type I but does not override it\n" + + "----------\n" + + "2. ERROR in X.java (at line 15)\n" + + " J b = ints.a();\n" + + " ^^^^^^^^\n" + + "Type mismatch: cannot convert from J to J\n" + + "----------\n" + + "3. ERROR in X.java (at line 16)\n" + + " J c = ints.a();\n" + + " ^^^^^^^^\n" + + "Type mismatch: cannot convert from J to J\n" + + "----------\n" + + "4. WARNING in X.java (at line 17)\n" + + " J d = ints.a();\n" + + " ^\n" + + "J is a raw type. References to generic type J should be parameterized\n" + + "----------\n" + + "5. ERROR in X.java (at line 19)\n" + + " I f = ints.a();\n" + + " ^^^^^^^^\n" + + "Type mismatch: cannot convert from J to I\n" + + "----------\n" + + "6. ERROR in X.java (at line 20)\n" + + " I g = ints.a();\n" + + " ^^^^^^^^\n" + + "Type mismatch: cannot convert from J to I\n" + + "----------\n" + + "7. WARNING in X.java (at line 21)\n" + + " I h = ints.a();\n" + + " ^\n" + + "I is a raw type. References to generic type I should be parameterized\n" + + "----------\n" + + "8. ERROR in X.java (at line 24)\n" + + " ints.b();\n" + + " ^\n" + + "The method b() is ambiguous for the type J\n" + + "----------\n" + + "9. ERROR in X.java (at line 25)\n" + + " J a = ints.b();\n" + + " ^\n" + + "The method b() is ambiguous for the type J\n" + + "----------\n" + + "10. ERROR in X.java (at line 26)\n" + + " J b = ints.b();\n" + + " ^\n" + + "The method b() is ambiguous for the type J\n" + + "----------\n" + + "11. ERROR in X.java (at line 27)\n" + + " J c = ints.b();\n" + + " ^\n" + + "The method b() is ambiguous for the type J\n" + + "----------\n" + + "12. WARNING in X.java (at line 28)\n" + + " J d = ints.b();\n" + + " ^\n" + + "J is a raw type. References to generic type J should be parameterized\n" + + "----------\n" + + "13. ERROR in X.java (at line 28)\n" + + " J d = ints.b();\n" + + " ^\n" + + "The method b() is ambiguous for the type J\n" + + "----------\n" + + "14. ERROR in X.java (at line 29)\n" + + " I e = ints.b();\n" + + " ^\n" + + "The method b() is ambiguous for the type J\n" + + "----------\n" + + "15. ERROR in X.java (at line 30)\n" + + " I f = ints.b();\n" + + " ^\n" + + "The method b() is ambiguous for the type J\n" + + "----------\n" + + "16. ERROR in X.java (at line 31)\n" + + " I g = ints.b();\n" + + " ^\n" + + "The method b() is ambiguous for the type J\n" + + "----------\n" + + "17. WARNING in X.java (at line 32)\n" + + " I h = ints.b();\n" + + " ^\n" + + "I is a raw type. References to generic type I should be parameterized\n" + + "----------\n" + + "18. ERROR in X.java (at line 32)\n" + + " I h = ints.b();\n" + + " ^\n" + + "The method b() is ambiguous for the type J\n" + + "----------\n" + + "19. WARNING in X.java (at line 39)\n" + + " J d = ints.c();\n" + + " ^\n" + + "J is a raw type. References to generic type J should be parameterized\n" + + "----------\n" + + "20. WARNING in X.java (at line 43)\n" + + " I h = ints.c();\n" + + " ^\n" + + "I is a raw type. References to generic type I should be parameterized\n" + + "----------\n": + "----------\n" + + "1. ERROR in X.java (at line 8)\n" + + " J b();\n" + + " ^^^\n" + + "Name clash: The method b() of type J has the same erasure as b() of type I but does not override it\n" + + "----------\n" + + "2. ERROR in X.java (at line 15)\n" + + " J b = ints.a();\n" + + " ^^^^^^^^\n" + + "Type mismatch: cannot convert from J to J\n" + + "----------\n" + + "3. ERROR in X.java (at line 16)\n" + + " J c = ints.a();\n" + + " ^^^^^^^^\n" + + "Type mismatch: cannot convert from J to J\n" + + "----------\n" + + "4. WARNING in X.java (at line 17)\n" + + " J d = ints.a();\n" + + " ^\n" + + "J is a raw type. References to generic type J should be parameterized\n" + + "----------\n" + + "5. ERROR in X.java (at line 19)\n" + + " I f = ints.a();\n" + + " ^^^^^^^^\n" + + "Type mismatch: cannot convert from J to I\n" + + "----------\n" + + "6. ERROR in X.java (at line 20)\n" + + " I g = ints.a();\n" + + " ^^^^^^^^\n" + + "Type mismatch: cannot convert from J to I\n" + + "----------\n" + + "7. WARNING in X.java (at line 21)\n" + + " I h = ints.a();\n" + + " ^\n" + + "I is a raw type. References to generic type I should be parameterized\n" + + "----------\n" + + "8. ERROR in X.java (at line 24)\n" + + " ints.b();\n" + + " ^\n" + + "The method b() is ambiguous for the type J\n" + + "----------\n" + + "9. ERROR in X.java (at line 25)\n" + + " J a = ints.b();\n" + + " ^\n" + + "The method b() is ambiguous for the type J\n" + + "----------\n" + + "10. ERROR in X.java (at line 26)\n" + + " J b = ints.b();\n" + + " ^\n" + + "The method b() is ambiguous for the type J\n" + + "----------\n" + + "11. ERROR in X.java (at line 27)\n" + + " J c = ints.b();\n" + + " ^\n" + + "The method b() is ambiguous for the type J\n" + + "----------\n" + + "12. WARNING in X.java (at line 28)\n" + + " J d = ints.b();\n" + + " ^\n" + + "J is a raw type. References to generic type J should be parameterized\n" + + "----------\n" + + "13. ERROR in X.java (at line 28)\n" + + " J d = ints.b();\n" + + " ^\n" + + "The method b() is ambiguous for the type J\n" + + "----------\n" + + "14. ERROR in X.java (at line 29)\n" + + " I e = ints.b();\n" + + " ^\n" + + "The method b() is ambiguous for the type J\n" + + "----------\n" + + "15. ERROR in X.java (at line 30)\n" + + " I f = ints.b();\n" + + " ^\n" + + "The method b() is ambiguous for the type J\n" + + "----------\n" + + "16. ERROR in X.java (at line 31)\n" + + " I g = ints.b();\n" + + " ^\n" + + "The method b() is ambiguous for the type J\n" + + "----------\n" + + "17. WARNING in X.java (at line 32)\n" + + " I h = ints.b();\n" + + " ^\n" + + "I is a raw type. References to generic type I should be parameterized\n" + + "----------\n" + + "18. ERROR in X.java (at line 32)\n" + + " I h = ints.b();\n" + + " ^\n" + + "The method b() is ambiguous for the type J\n" + + "----------\n" + + "19. WARNING in X.java (at line 39)\n" + + " J d = ints.c();\n" + + " ^\n" + + "J is a raw type. References to generic type J should be parameterized\n" + + "----------\n" + + "20. WARNING in X.java (at line 43)\n" + + " I h = ints.c();\n" + + " ^\n" + + "I is a raw type. References to generic type I should be parameterized\n" + + "----------\n"; this.runNegativeTest( new String[] { "X.java", @@ -3323,107 +3707,7 @@ " }\n" + "}" }, - "----------\n" + - "1. ERROR in X.java (at line 8)\n" + - " J b();\n" + - " ^^^\n" + - "Name clash: The method b() of type J has the same erasure as b() of type I but does not override it\n" + - "----------\n" + - "2. ERROR in X.java (at line 15)\n" + - " J b = ints.a();\n" + - " ^^^^^^^^\n" + - "Type mismatch: cannot convert from J to J\n" + - "----------\n" + - "3. ERROR in X.java (at line 16)\n" + - " J c = ints.a();\n" + - " ^^^^^^^^\n" + - "Type mismatch: cannot convert from J to J\n" + - "----------\n" + - "4. WARNING in X.java (at line 17)\n" + - " J d = ints.a();\n" + - " ^\n" + - "J is a raw type. References to generic type J should be parameterized\n" + - "----------\n" + - "5. ERROR in X.java (at line 19)\n" + - " I f = ints.a();\n" + - " ^^^^^^^^\n" + - "Type mismatch: cannot convert from J to I\n" + - "----------\n" + - "6. ERROR in X.java (at line 20)\n" + - " I g = ints.a();\n" + - " ^^^^^^^^\n" + - "Type mismatch: cannot convert from J to I\n" + - "----------\n" + - "7. WARNING in X.java (at line 21)\n" + - " I h = ints.a();\n" + - " ^\n" + - "I is a raw type. References to generic type I should be parameterized\n" + - "----------\n" + - "8. ERROR in X.java (at line 24)\n" + - " ints.b();\n" + - " ^\n" + - "The method b() is ambiguous for the type J\n" + - "----------\n" + - "9. ERROR in X.java (at line 25)\n" + - " J a = ints.b();\n" + - " ^\n" + - "The method b() is ambiguous for the type J\n" + - "----------\n" + - "10. ERROR in X.java (at line 26)\n" + - " J b = ints.b();\n" + - " ^\n" + - "The method b() is ambiguous for the type J\n" + - "----------\n" + - "11. ERROR in X.java (at line 27)\n" + - " J c = ints.b();\n" + - " ^\n" + - "The method b() is ambiguous for the type J\n" + - "----------\n" + - "12. WARNING in X.java (at line 28)\n" + - " J d = ints.b();\n" + - " ^\n" + - "J is a raw type. References to generic type J should be parameterized\n" + - "----------\n" + - "13. ERROR in X.java (at line 28)\n" + - " J d = ints.b();\n" + - " ^\n" + - "The method b() is ambiguous for the type J\n" + - "----------\n" + - "14. ERROR in X.java (at line 29)\n" + - " I e = ints.b();\n" + - " ^\n" + - "The method b() is ambiguous for the type J\n" + - "----------\n" + - "15. ERROR in X.java (at line 30)\n" + - " I f = ints.b();\n" + - " ^\n" + - "The method b() is ambiguous for the type J\n" + - "----------\n" + - "16. ERROR in X.java (at line 31)\n" + - " I g = ints.b();\n" + - " ^\n" + - "The method b() is ambiguous for the type J\n" + - "----------\n" + - "17. WARNING in X.java (at line 32)\n" + - " I h = ints.b();\n" + - " ^\n" + - "I is a raw type. References to generic type I should be parameterized\n" + - "----------\n" + - "18. ERROR in X.java (at line 32)\n" + - " I h = ints.b();\n" + - " ^\n" + - "The method b() is ambiguous for the type J\n" + - "----------\n" + - "19. WARNING in X.java (at line 39)\n" + - " J d = ints.c();\n" + - " ^\n" + - "J is a raw type. References to generic type J should be parameterized\n" + - "----------\n" + - "20. WARNING in X.java (at line 43)\n" + - " I h = ints.c();\n" + - " ^\n" + - "I is a raw type. References to generic type I should be parameterized\n" + - "----------\n" + output ); } Index: src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java,v retrieving revision 1.828.2.1 diff -u -r1.828.2.1 GenericTypeTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 28 Jul 2011 17:52:06 -0000 1.828.2.1 +++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 3 Aug 2011 17:12:03 -0000 @@ -17666,6 +17666,34 @@ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=87956 public void test0561() { // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950 + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in X.java (at line 2)\n" + + " void foo(A a) {}\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X\n" + + "----------\n" + + "2. WARNING in X.java (at line 3)\n" + + " Object foo(A a) { return null; }\n" + + " ^^^^^^^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X\n" + + "----------\n": + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " void foo(A a) {}\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " Object foo(A a) { return null; }\n" + + " ^^^^^^^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 4)\n" + + " void test(A a) { foo(a); }\n" + + " ^^^\n" + + "The method foo(A) in the type X is not applicable for the arguments (A)\n" + + "----------\n"; this.runNegativeTest( new String[] { "X.java", @@ -17676,22 +17704,7 @@ "}\n" + "class A {}\n", }, - "----------\n" + - "1. ERROR in X.java (at line 2)\n" + - " void foo(A a) {}\n" + - " ^^^^^^^^^^^^^^^^\n" + - "Method foo(A) has the same erasure foo(A) as another method in type X\n" + - "----------\n" + - "2. ERROR in X.java (at line 3)\n" + - " Object foo(A a) { return null; }\n" + - " ^^^^^^^^^^^^^^^^^\n" + - "Method foo(A) has the same erasure foo(A) as another method in type X\n" + - "----------\n" + - "3. ERROR in X.java (at line 4)\n" + - " void test(A a) { foo(a); }\n" + - " ^^^\n" + - "The method foo(A) in the type X is not applicable for the arguments (A)\n" + - "----------\n" + expectedCompilerLog ); /* javac 7 X.java:3: name clash: foo(A) and foo(A) have the same erasure @@ -17704,6 +17717,34 @@ found: A 2 errors */ + String expectedCompilerLog2 = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in X.java (at line 2)\n" + + " Number foo(A a) { return null; }\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X\n" + + "----------\n" + + "2. WARNING in X.java (at line 3)\n" + + " Integer foo(A a) { return null; }\n" + + " ^^^^^^^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X\n" + + "----------\n": + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " Number foo(A a) { return null; }\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " Integer foo(A a) { return null; }\n" + + " ^^^^^^^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 4)\n" + + " void test(A a) { foo(a); }\n" + + " ^^^\n" + + "The method foo(A) in the type X is not applicable for the arguments (A)\n" + + "----------\n"; this.runNegativeTest( new String[] { "X.java", @@ -17714,22 +17755,7 @@ "}\n" + "class A {}\n", }, - "----------\n" + - "1. ERROR in X.java (at line 2)\n" + - " Number foo(A a) { return null; }\n" + - " ^^^^^^^^^^^^^^^^\n" + - "Method foo(A) has the same erasure foo(A) as another method in type X\n" + - "----------\n" + - "2. ERROR in X.java (at line 3)\n" + - " Integer foo(A a) { return null; }\n" + - " ^^^^^^^^^^^^^^^^^\n" + - "Method foo(A) has the same erasure foo(A) as another method in type X\n" + - "----------\n" + - "3. ERROR in X.java (at line 4)\n" + - " void test(A a) { foo(a); }\n" + - " ^^^\n" + - "The method foo(A) in the type X is not applicable for the arguments (A)\n" + - "----------\n" + expectedCompilerLog2 /* javac 7 X.java:3: name clash: foo(A) and foo(A) have the same erasure Integer foo(A a) { return null; } @@ -18051,6 +18077,54 @@ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation public void test0574() { // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950 + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in X.java (at line 6)\n" + + " T foo(Object o) { return null; } // ok\n" + + " ^^^^^^^\n" + + "The type parameter T should not be bounded by the final type Integer. Final types cannot be further extended\n" + + "----------\n" + + "2. WARNING in X.java (at line 6)\n" + + " T foo(Object o) { return null; } // ok\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C2\n" + + "----------\n" + + "3. WARNING in X.java (at line 7)\n" + + " T foo(Object o) { return null; } // ok\n" + + " ^^^^^^\n" + + "The type parameter T should not be bounded by the final type String. Final types cannot be further extended\n" + + "----------\n" + + "4. WARNING in X.java (at line 7)\n" + + " T foo(Object o) { return null; } // ok\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C2\n" + + "----------\n" + + "5. ERROR in X.java (at line 10)\n" + + " new X().new C2().foo((List) null);\n" + + " ^^^\n" + + "The method foo(Object) is ambiguous for the type X.C2\n" + + "----------\n": + "----------\n" + + "1. WARNING in X.java (at line 6)\n" + + " T foo(Object o) { return null; } // ok\n" + + " ^^^^^^^\n" + + "The type parameter T should not be bounded by the final type Integer. Final types cannot be further extended\n" + + "----------\n" + + "2. ERROR in X.java (at line 6)\n" + + " T foo(Object o) { return null; } // ok\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C2\n" + + "----------\n" + + "3. WARNING in X.java (at line 7)\n" + + " T foo(Object o) { return null; } // ok\n" + + " ^^^^^^\n" + + "The type parameter T should not be bounded by the final type String. Final types cannot be further extended\n" + + "----------\n" + + "4. ERROR in X.java (at line 7)\n" + + " T foo(Object o) { return null; } // ok\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C2\n" + + "----------\n"; this.runNegativeTest( new String[] { "X.java", @@ -18067,27 +18141,7 @@ " }\n" + "}\n" }, - "----------\n" + - "1. WARNING in X.java (at line 6)\n" + - " T foo(Object o) { return null; } // ok\n" + - " ^^^^^^^\n" + - "The type parameter T should not be bounded by the final type Integer. Final types cannot be further extended\n" + - "----------\n" + - "2. ERROR in X.java (at line 6)\n" + - " T foo(Object o) { return null; } // ok\n" + - " ^^^^^^^^^^^^^\n" + - "Duplicate method foo(Object) in type X.C2\n" + - "----------\n" + - "3. WARNING in X.java (at line 7)\n" + - " T foo(Object o) { return null; } // ok\n" + - " ^^^^^^\n" + - "The type parameter T should not be bounded by the final type String. Final types cannot be further extended\n" + - "----------\n" + - "4. ERROR in X.java (at line 7)\n" + - " T foo(Object o) { return null; } // ok\n" + - " ^^^^^^^^^^^^^\n" + - "Duplicate method foo(Object) in type X.C2\n" + - "----------\n" + expectedCompilerLog ); /* X.java:6: name clash: foo(Object) and foo(Object) have the same erasure @@ -22443,6 +22497,19 @@ } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=97219 public void test0706() { + String outputExpectedBelow17 = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in X.java (at line 9)\n" + + " class BB extends AA { BB test() {return null;} }\n" + + " ^^^^^^\n" + + "Name clash: The method test() of type BB has the same erasure as test() of type AA but does not override it\n" + + "----------\n": + "----------\n" + + "1. ERROR in X.java (at line 9)\n" + + " class BB extends AA { BB test() {return null;} }\n" + + " ^^^^^^\n" + + "Name clash: The method test() of type BB has the same erasure as test() of type AA but does not override it\n" + + "----------\n"; this.runNegativeTest( new String[] { "X.java", @@ -22458,12 +22525,7 @@ "class CC {}\n", }, (this.complianceLevel < ClassFileConstants.JDK1_7) - ? "----------\n" + - "1. ERROR in X.java (at line 9)\n" + - " class BB extends AA { BB test() {return null;} }\n" + - " ^^^^^^\n" + - "Name clash: The method test() of type BB has the same erasure as test() of type AA but does not override it\n" + - "----------\n" + ? outputExpectedBelow17 : "----------\n" + "1. ERROR in X.java (at line 4)\n" + " bb.test();\n" + @@ -22493,6 +22555,49 @@ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=97219 public void test0706a() { // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950 + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. ERROR in X.java (at line 4)\n" + + " AA res1 = bb.test();\n" + + " ^^^^\n" + + "The method test() is ambiguous for the type BB\n" + + "----------\n" + + "2. WARNING in X.java (at line 5)\n" + + " AA res3 = bb.test();\n" + + " ^^\n" + + "AA is a raw type. References to generic type AA should be parameterized\n" + + "----------\n" + + "3. ERROR in X.java (at line 5)\n" + + " AA res3 = bb.test();\n" + + " ^^^^\n" + + "The method test() is ambiguous for the type BB\n" + + "----------\n" + + "4. WARNING in X.java (at line 9)\n" + + " class BB extends AA { BB test() {return null;} }\n" + + " ^^^^^^\n" + + "Name clash: The method test() of type BB has the same erasure as test() of type AA but does not override it\n" + + "----------\n": + "----------\n" + + "1. ERROR in X.java (at line 4)\n" + + " AA res1 = bb.test();\n" + + " ^^^^\n" + + "The method test() is ambiguous for the type BB\n" + + "----------\n" + + "2. WARNING in X.java (at line 5)\n" + + " AA res3 = bb.test();\n" + + " ^^\n" + + "AA is a raw type. References to generic type AA should be parameterized\n" + + "----------\n" + + "3. ERROR in X.java (at line 5)\n" + + " AA res3 = bb.test();\n" + + " ^^^^\n" + + "The method test() is ambiguous for the type BB\n" + + "----------\n" + + "4. ERROR in X.java (at line 9)\n" + + " class BB extends AA { BB test() {return null;} }\n" + + " ^^^^^^\n" + + "Name clash: The method test() of type BB has the same erasure as test() of type AA but does not override it\n" + + "----------\n"; this.runNegativeTest( new String[] { "X.java", @@ -22507,27 +22612,7 @@ "class BB extends AA { BB test() {return null;} }\n" + "class CC {}\n", }, - "----------\n" + - "1. ERROR in X.java (at line 4)\n" + - " AA res1 = bb.test();\n" + - " ^^^^\n" + - "The method test() is ambiguous for the type BB\n" + - "----------\n" + - "2. WARNING in X.java (at line 5)\n" + - " AA res3 = bb.test();\n" + - " ^^\n" + - "AA is a raw type. References to generic type AA should be parameterized\n" + - "----------\n" + - "3. ERROR in X.java (at line 5)\n" + - " AA res3 = bb.test();\n" + - " ^^^^\n" + - "The method test() is ambiguous for the type BB\n" + - "----------\n" + - "4. ERROR in X.java (at line 9)\n" + - " class BB extends AA { BB test() {return null;} }\n" + - " ^^^^^^\n" + - "Name clash: The method test() of type BB has the same erasure as test() of type AA but does not override it\n" + - "----------\n" + expectedCompilerLog ); /* X.java:4: reference to test is ambiguous, both method test() in AA and method test() in BB match @@ -22551,6 +22636,39 @@ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=97219 public void test0706b() { // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950 + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. ERROR in X.java (at line 4)\n" + + " AA res = bb.test();\n" + + " ^^^^\n" + + "The method test() is ambiguous for the type BB\n" + + "----------\n" + + "2. ERROR in X.java (at line 5)\n" + + " BB res2 = bb.test();\n" + + " ^^^^\n" + + "The method test() is ambiguous for the type BB\n" + + "----------\n" + + "3. WARNING in X.java (at line 9)\n" + + " class BB extends AA { BB test() {return null;} }\n" + + " ^^^^^^\n" + + "Name clash: The method test() of type BB has the same erasure as test() of type AA but does not override it\n" + + "----------\n": + "----------\n" + + "1. ERROR in X.java (at line 4)\n" + + " AA res = bb.test();\n" + + " ^^^^\n" + + "The method test() is ambiguous for the type BB\n" + + "----------\n" + + "2. ERROR in X.java (at line 5)\n" + + " BB res2 = bb.test();\n" + + " ^^^^\n" + + "The method test() is ambiguous for the type BB\n" + + "----------\n" + + "3. ERROR in X.java (at line 9)\n" + + " class BB extends AA { BB test() {return null;} }\n" + + " ^^^^^^\n" + + "Name clash: The method test() of type BB has the same erasure as test() of type AA but does not override it\n" + + "----------\n"; this.runNegativeTest( new String[] { "X.java", @@ -22565,22 +22683,7 @@ "class BB extends AA { BB test() {return null;} }\n" + "class CC {}\n", }, - "----------\n" + - "1. ERROR in X.java (at line 4)\n" + - " AA res = bb.test();\n" + - " ^^^^\n" + - "The method test() is ambiguous for the type BB\n" + - "----------\n" + - "2. ERROR in X.java (at line 5)\n" + - " BB res2 = bb.test();\n" + - " ^^^^\n" + - "The method test() is ambiguous for the type BB\n" + - "----------\n" + - "3. ERROR in X.java (at line 9)\n" + - " class BB extends AA { BB test() {return null;} }\n" + - " ^^^^^^\n" + - "Name clash: The method test() of type BB has the same erasure as test() of type AA but does not override it\n" + - "----------\n" + expectedCompilerLog ); /* X.java:4: reference to test is ambiguous, both method test() in AA and method test() in BB match @@ -23778,6 +23881,19 @@ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=100007 public void test0748() { // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950 + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in X.java (at line 5)\n" + + " public byte[] create(Class cl) { return null; }\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Name clash: The method create(Class) of type X has the same erasure as create(Class) of type Factory but does not override it\n" + + "----------\n": + "----------\n" + + "1. ERROR in X.java (at line 5)\n" + + " public byte[] create(Class cl) { return null; }\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Name clash: The method create(Class) of type X has the same erasure as create(Class) of type Factory but does not override it\n" + + "----------\n"; this.runNegativeTest( new String[] { "X.java", @@ -23788,12 +23904,7 @@ " public byte[] create(Class cl) { return null; }\n" + "}\n", }, - "----------\n" + - "1. ERROR in X.java (at line 5)\n" + - " public byte[] create(Class cl) { return null; }\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Name clash: The method create(Class) of type X has the same erasure as create(Class) of type Factory but does not override it\n" + - "----------\n" + expectedCompilerLog ); // javac 7 reports the name clash when X subclasses another class or is a concrete type } @@ -40374,6 +40485,89 @@ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=204534 public void test1181() { // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950 + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " public static , R extends S & T> R max(T arg1, S arg2) {\n" + + " ^\n" + + "Cannot specify any additional bound T when first bound is a type parameter\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " public static , R extends S & T> R max(T arg1, S arg2) {\n" + + " ^^^^^^^^^^^^^^^^^^^\n" + + "Method max(T, S) has the same erasure max(Comparable, Object) as another method in type X\n" + + "----------\n" + + "3. WARNING in X.java (at line 3)\n" + + " return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked cast from Object to R\n" + + "----------\n" + + "4. ERROR in X.java (at line 5)\n" + + " public static , S, R extends S & Comparable> R max(T arg1, S arg2) {\n" + + " ^^^^^^^^^^\n" + + "Cannot specify any additional bound Comparable when first bound is a type parameter\n" + + "----------\n" + + "5. ERROR in X.java (at line 5)\n" + + " public static , S, R extends S & Comparable> R max(T arg1, S arg2) {\n" + + " ^^^^^^^^^^^^^^^^^^^\n" + + "Method max(T, S) has the same erasure max(Comparable, Object) as another method in type X\n" + + "----------\n" + + "6. WARNING in X.java (at line 6)\n" + + " return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked cast from Object to R\n" + + "----------\n" + + "7. WARNING in X.java (at line 8)\n" + + " public static , S, R extends Comparable> R max(T arg1, S arg2) {\n" + + " ^^^^^^^^^^^^^^^^^^^\n" + + "Method max(T, S) has the same erasure max(Comparable, Object) as another method in type X\n" + + "----------\n" + + "8. WARNING in X.java (at line 9)\n" + + " return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked cast from Object to R\n" + + "----------\n": + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " public static , R extends S & T> R max(T arg1, S arg2) {\n" + + " ^\n" + + "Cannot specify any additional bound T when first bound is a type parameter\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " public static , R extends S & T> R max(T arg1, S arg2) {\n" + + " ^^^^^^^^^^^^^^^^^^^\n" + + "Method max(T, S) has the same erasure max(Comparable, Object) as another method in type X\n" + + "----------\n" + + "3. WARNING in X.java (at line 3)\n" + + " return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked cast from Object to R\n" + + "----------\n" + + "4. ERROR in X.java (at line 5)\n" + + " public static , S, R extends S & Comparable> R max(T arg1, S arg2) {\n" + + " ^^^^^^^^^^\n" + + "Cannot specify any additional bound Comparable when first bound is a type parameter\n" + + "----------\n" + + "5. ERROR in X.java (at line 5)\n" + + " public static , S, R extends S & Comparable> R max(T arg1, S arg2) {\n" + + " ^^^^^^^^^^^^^^^^^^^\n" + + "Method max(T, S) has the same erasure max(Comparable, Object) as another method in type X\n" + + "----------\n" + + "6. WARNING in X.java (at line 6)\n" + + " return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked cast from Object to R\n" + + "----------\n" + + "7. ERROR in X.java (at line 8)\n" + + " public static , S, R extends Comparable> R max(T arg1, S arg2) {\n" + + " ^^^^^^^^^^^^^^^^^^^\n" + + "Method max(T, S) has the same erasure max(Comparable, Object) as another method in type X\n" + + "----------\n" + + "8. WARNING in X.java (at line 9)\n" + + " return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked cast from Object to R\n" + + "----------\n"; this.runNegativeTest( new String[] { "X.java", @@ -40390,47 +40584,7 @@ " public static void main(String[] args) {}\n" + "}\n", // ================= }, - "----------\n" + - "1. ERROR in X.java (at line 2)\n" + - " public static , R extends S & T> R max(T arg1, S arg2) {\n" + - " ^\n" + - "Cannot specify any additional bound T when first bound is a type parameter\n" + - "----------\n" + - "2. ERROR in X.java (at line 2)\n" + - " public static , R extends S & T> R max(T arg1, S arg2) {\n" + - " ^^^^^^^^^^^^^^^^^^^\n" + - "Method max(T, S) has the same erasure max(Comparable, Object) as another method in type X\n" + - "----------\n" + - "3. WARNING in X.java (at line 3)\n" + - " return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Type safety: Unchecked cast from Object to R\n" + - "----------\n" + - "4. ERROR in X.java (at line 5)\n" + - " public static , S, R extends S & Comparable> R max(T arg1, S arg2) {\n" + - " ^^^^^^^^^^\n" + - "Cannot specify any additional bound Comparable when first bound is a type parameter\n" + - "----------\n" + - "5. ERROR in X.java (at line 5)\n" + - " public static , S, R extends S & Comparable> R max(T arg1, S arg2) {\n" + - " ^^^^^^^^^^^^^^^^^^^\n" + - "Method max(T, S) has the same erasure max(Comparable, Object) as another method in type X\n" + - "----------\n" + - "6. WARNING in X.java (at line 6)\n" + - " return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Type safety: Unchecked cast from Object to R\n" + - "----------\n" + - "7. ERROR in X.java (at line 8)\n" + - " public static , S, R extends Comparable> R max(T arg1, S arg2) {\n" + - " ^^^^^^^^^^^^^^^^^^^\n" + - "Method max(T, S) has the same erasure max(Comparable, Object) as another method in type X\n" + - "----------\n" + - "8. WARNING in X.java (at line 9)\n" + - " return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Type safety: Unchecked cast from Object to R\n" + - "----------\n" + expectedCompilerLog ); /* X.java:2: a type variable may not be followed by other bounds Index: src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java,v retrieving revision 1.223.2.1 diff -u -r1.223.2.1 MethodVerifyTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 28 Jul 2011 17:52:01 -0000 1.223.2.1 +++ src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 3 Aug 2011 17:12:22 -0000 @@ -27,7 +27,7 @@ public class MethodVerifyTest extends AbstractComparableTest { static { -// TESTS_NAMES = new String[] { "test339447" }; +// TESTS_NAMES = new String[] { "test050l" }; // TESTS_NUMBERS = new int[] { 213 }; // TESTS_RANGE = new int[] { 190, -1}; } @@ -3333,6 +3333,29 @@ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900 public void test048() { + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in X1.java (at line 2)\n" + + " public class X1 extends LinkedHashMap {\n" + + " ^^\n" + + "The serializable class X1 does not declare a static final serialVersionUID field of type long\n" + + "----------\n" + + "2. WARNING in X1.java (at line 3)\n" + + " public Object putAll(Map a) { return null; }\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Name clash: The method putAll(Map) of type X1 has the same erasure as putAll(Map) of type HashMap but does not override it\n" + + "----------\n": + "----------\n" + + "1. WARNING in X1.java (at line 2)\n" + + " public class X1 extends LinkedHashMap {\n" + + " ^^\n" + + "The serializable class X1 does not declare a static final serialVersionUID field of type long\n" + + "----------\n" + + "2. ERROR in X1.java (at line 3)\n" + + " public Object putAll(Map a) { return null; }\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Name clash: The method putAll(Map) of type X1 has the same erasure as putAll(Map) of type HashMap but does not override it\n" + + "----------\n"; this.runNegativeTest( new String[] { "X1.java", @@ -3341,17 +3364,7 @@ " public Object putAll(Map a) { return null; }\n" + "}\n" }, - "----------\n" + - "1. WARNING in X1.java (at line 2)\n" + - " public class X1 extends LinkedHashMap {\n" + - " ^^\n" + - "The serializable class X1 does not declare a static final serialVersionUID field of type long\n" + - "----------\n" + - "2. ERROR in X1.java (at line 3)\n" + - " public Object putAll(Map a) { return null; }\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Name clash: The method putAll(Map) of type X1 has the same erasure as putAll(Map) of type HashMap but does not override it\n" + - "----------\n" + expectedCompilerLog ); /* javac 7 X.java:4: name clash: putAll(Map) in X1 and putAll(Map) in HashMap have the same erasure, yet neither overrides the other @@ -3365,6 +3378,19 @@ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900 public void test048a() { + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in X2.java (at line 2)\n" + + " public Object foo(I z) { return null; }\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Name clash: The method foo(I) of type X2 has the same erasure as foo(I) of type Y but does not override it\n" + + "----------\n": + "----------\n" + + "1. ERROR in X2.java (at line 2)\n" + + " public Object foo(I z) { return null; }\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Name clash: The method foo(I) of type X2 has the same erasure as foo(I) of type Y but does not override it\n" + + "----------\n"; this.runNegativeTest( new String[] { "X2.java", @@ -3378,12 +3404,7 @@ " public void foo(I a);\n" + "}\n" }, - "----------\n" + - "1. ERROR in X2.java (at line 2)\n" + - " public Object foo(I z) { return null; }\n" + - " ^^^^^^^^^^^^^^^^\n" + - "Name clash: The method foo(I) of type X2 has the same erasure as foo(I) of type Y but does not override it\n" + - "----------\n" + expectedCompilerLog ); /* javac 7 X.java:2: name clash: foo(I) in X2 and foo(I) in Y have the same erasure, yet neither overrides the other @@ -3427,6 +3448,19 @@ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900 public void test048c() { + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in X4.java (at line 2)\n" + + " public String foo(I z) { return null; }\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Name clash: The method foo(I) of type X4 has the same erasure as foo(I) of type Y but does not override it\n" + + "----------\n": + "----------\n" + + "1. ERROR in X4.java (at line 2)\n" + + " public String foo(I z) { return null; }\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Name clash: The method foo(I) of type X4 has the same erasure as foo(I) of type Y but does not override it\n" + + "----------\n"; this.runNegativeTest( new String[] { "X4.java", @@ -3440,12 +3474,7 @@ " public Object foo(I a);\n" + "}\n" }, - "----------\n" + - "1. ERROR in X4.java (at line 2)\n" + - " public String foo(I z) { return null; }\n" + - " ^^^^^^^^^^^^^^^^\n" + - "Name clash: The method foo(I) of type X4 has the same erasure as foo(I) of type Y but does not override it\n" + - "----------\n" + expectedCompilerLog ); /* javac 7 X.java:2: name clash: foo(I) in X4 and foo(I) in Y have the same erasure, yet neither overrides the other @@ -3458,6 +3487,19 @@ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900 public void test048d() { + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in X5.java (at line 2)\n" + + " public Object foo(I z) { return null; }\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Name clash: The method foo(I) of type X5 has the same erasure as foo(I) of type Y but does not override it\n" + + "----------\n": + "----------\n" + + "1. ERROR in X5.java (at line 2)\n" + + " public Object foo(I z) { return null; }\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Name clash: The method foo(I) of type X5 has the same erasure as foo(I) of type Y but does not override it\n" + + "----------\n"; this.runNegativeTest( new String[] { "X5.java", @@ -3471,12 +3513,7 @@ " public String foo(I a);\n" + "}\n" }, - "----------\n" + - "1. ERROR in X5.java (at line 2)\n" + - " public Object foo(I z) { return null; }\n" + - " ^^^^^^^^^^^^^^^^\n" + - "Name clash: The method foo(I) of type X5 has the same erasure as foo(I) of type Y but does not override it\n" + - "----------\n" + expectedCompilerLog ); /* javac 7 X.java:2: name clash: foo(I) in X5 and foo(I) in Y have the @@ -3490,6 +3527,19 @@ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900 public void test048e() { + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in X6.java (at line 2)\n" + + " public void foo(I z) {}\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Name clash: The method foo(I) of type X6 has the same erasure as foo(I) of type Y but does not override it\n" + + "----------\n": + "----------\n" + + "1. ERROR in X6.java (at line 2)\n" + + " public void foo(I z) {}\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Name clash: The method foo(I) of type X6 has the same erasure as foo(I) of type Y but does not override it\n" + + "----------\n"; this.runNegativeTest( new String[] { "X6.java", @@ -3503,12 +3553,7 @@ " public Object foo(I a);\n" + "}\n" }, - "----------\n" + - "1. ERROR in X6.java (at line 2)\n" + - " public void foo(I z) {}\n" + - " ^^^^^^^^^^^^^^^^\n" + - "Name clash: The method foo(I) of type X6 has the same erasure as foo(I) of type Y but does not override it\n" + - "----------\n" + expectedCompilerLog ); /* javac 7 X.java:2: name clash: foo(I) in X6 and foo(I) in Y have the same erasure, yet neither overrides the other @@ -3521,6 +3566,19 @@ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900 public void test048f() { + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in X7.java (at line 2)\n" + + " public String foo(I z) { return null; }\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Name clash: The method foo(I) of type X7 has the same erasure as foo(I) of type Y but does not override it\n" + + "----------\n": + "----------\n" + + "1. ERROR in X7.java (at line 2)\n" + + " public String foo(I z) { return null; }\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Name clash: The method foo(I) of type X7 has the same erasure as foo(I) of type Y but does not override it\n" + + "----------\n"; this.runNegativeTest( new String[] { "X7.java", @@ -3534,12 +3592,7 @@ " public T foo(I a);\n" + "}\n" }, - "----------\n" + - "1. ERROR in X7.java (at line 2)\n" + - " public String foo(I z) { return null; }\n" + - " ^^^^^^^^^^^^^^^^\n" + - "Name clash: The method foo(I) of type X7 has the same erasure as foo(I) of type Y but does not override it\n" + - "----------\n" + expectedCompilerLog ); /* javac 7 X.java:2: name clash: foo(I) in X7 and foo(I) in Y have the same erasure, yet neither overrides the other @@ -3642,6 +3695,44 @@ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=94754 public void test050() { + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in X.java (at line 2)\n" + + " public static S foo() { System.out.print(\"A\"); return null; }\n" + + " ^^^^^\n" + + "Duplicate method foo() in type X\n" + + "----------\n" + + "2. WARNING in X.java (at line 3)\n" + + " public static N foo() { System.out.print(\"B\"); return null; }\n" + + " ^^^^^\n" + + "Duplicate method foo() in type X\n" + + "----------\n" + + "3. WARNING in X.java (at line 7)\n" + + " new X().foo();\n" + + " ^^^^^^^^^^^^^^^^\n" + + "The static method foo() from the type X should be accessed in a static way\n" + + "----------\n": + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " public static S foo() { System.out.print(\"A\"); return null; }\n" + + " ^^^^^\n" + + "Duplicate method foo() in type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " public static N foo() { System.out.print(\"B\"); return null; }\n" + + " ^^^^^\n" + + "Duplicate method foo() in type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 6)\n" + + " X.foo();\n" + + " ^^^\n" + + "Bound mismatch: The generic method foo() of type X is not applicable for the arguments (). The inferred type B is not a valid substitute for the bounded parameter \n" + + "----------\n" + + "4. ERROR in X.java (at line 7)\n" + + " new X().foo();\n" + + " ^^^\n" + + "Bound mismatch: The generic method foo() of type X is not applicable for the arguments (). The inferred type B is not a valid substitute for the bounded parameter \n" + + "----------\n"; this.runNegativeTest( new String[] { "X.java", @@ -3657,27 +3748,7 @@ "class A {}\n" + "class B {}" }, - "----------\n" + - "1. ERROR in X.java (at line 2)\n" + - " public static S foo() { System.out.print(\"A\"); return null; }\n" + - " ^^^^^\n" + - "Duplicate method foo() in type X\n" + - "----------\n" + - "2. ERROR in X.java (at line 3)\n" + - " public static N foo() { System.out.print(\"B\"); return null; }\n" + - " ^^^^^\n" + - "Duplicate method foo() in type X\n" + - "----------\n" + - "3. ERROR in X.java (at line 6)\n" + - " X.foo();\n" + - " ^^^\n" + - "Bound mismatch: The generic method foo() of type X is not applicable for the arguments (). The inferred type B is not a valid substitute for the bounded parameter \n" + - "----------\n" + - "4. ERROR in X.java (at line 7)\n" + - " new X().foo();\n" + - " ^^^\n" + - "Bound mismatch: The generic method foo() of type X is not applicable for the arguments (). The inferred type B is not a valid substitute for the bounded parameter \n" + - "----------\n" + expectedCompilerLog ); /* javac 7 X.java:3: name clash: foo() and foo() have the same erasure @@ -3701,6 +3772,39 @@ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=94754 public void test050a() { + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in X.java (at line 2)\n" + + " public static void foo() { System.out.print(\"A\"); }\n" + + " ^^^^^\n" + + "Duplicate method foo() in type X\n" + + "----------\n" + + "2. WARNING in X.java (at line 3)\n" + + " public static N foo() { System.out.print(\"B\"); return null; }\n" + + " ^^^^^\n" + + "Duplicate method foo() in type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 5)\n" + + " X.foo();\n" + + " ^^^\n" + + "The method foo() is ambiguous for the type X\n" + + "----------\n" + + "4. ERROR in X.java (at line 6)\n" + + " foo();\n" + + " ^^^\n" + + "The method foo() is ambiguous for the type X\n" + + "----------\n": + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " public static void foo() { System.out.print(\"A\"); }\n" + + " ^^^^^\n" + + "Duplicate method foo() in type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " public static N foo() { System.out.print(\"B\"); return null; }\n" + + " ^^^^^\n" + + "Duplicate method foo() in type X\n" + + "----------\n"; this.runNegativeTest( new String[] { "X.java", @@ -3715,17 +3819,7 @@ "class A {}\n" + "class B {}" }, - "----------\n" + - "1. ERROR in X.java (at line 2)\n" + - " public static void foo() { System.out.print(\"A\"); }\n" + - " ^^^^^\n" + - "Duplicate method foo() in type X\n" + - "----------\n" + - "2. ERROR in X.java (at line 3)\n" + - " public static N foo() { System.out.print(\"B\"); return null; }\n" + - " ^^^^^\n" + - "Duplicate method foo() in type X\n" + - "----------\n" + expectedCompilerLog ); /* javac 7 X.java:3: name clash: foo() and foo() have the same erasure @@ -3740,6 +3834,89 @@ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation public void test050b() { + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " Y foo(Object o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C1\n" + + "----------\n" + + "2. ERROR in X.java (at line 4)\n" + + " Z foo(Object o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C1\n" + + "----------\n" + + "3. WARNING in X.java (at line 7)\n" + + " T foo(Object o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C2\n" + + "----------\n" + + "4. WARNING in X.java (at line 8)\n" + + " T foo(Object o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C2\n" + + "----------\n" + + "5. ERROR in X.java (at line 11)\n" + + " A foo(Object o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C3\n" + + "----------\n" + + "6. ERROR in X.java (at line 12)\n" + + " A foo(Object o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C3\n" + + "----------\n" + + "7. WARNING in X.java (at line 15)\n" + + " Y foo(Object o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C4\n" + + "----------\n" + + "8. WARNING in X.java (at line 16)\n" + + " T foo(Object o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C4\n" + + "----------\n": + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " Y foo(Object o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C1\n" + + "----------\n" + + "2. ERROR in X.java (at line 4)\n" + + " Z foo(Object o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C1\n" + + "----------\n" + + "3. ERROR in X.java (at line 7)\n" + + " T foo(Object o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C2\n" + + "----------\n" + + "4. ERROR in X.java (at line 8)\n" + + " T foo(Object o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C2\n" + + "----------\n" + + "5. ERROR in X.java (at line 11)\n" + + " A foo(Object o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C3\n" + + "----------\n" + + "6. ERROR in X.java (at line 12)\n" + + " A foo(Object o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C3\n" + + "----------\n" + + "7. ERROR in X.java (at line 15)\n" + + " Y foo(Object o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C4\n" + + "----------\n" + + "8. ERROR in X.java (at line 16)\n" + + " T foo(Object o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C4\n" + + "----------\n"; this.runNegativeTest( new String[] { "X.java", @@ -3765,47 +3942,7 @@ "class Y {}\n" + "class Z {}" }, - "----------\n" + - "1. ERROR in X.java (at line 3)\n" + - " Y foo(Object o) { return null; } // duplicate\n" + - " ^^^^^^^^^^^^^\n" + - "Duplicate method foo(Object) in type X.C1\n" + - "----------\n" + - "2. ERROR in X.java (at line 4)\n" + - " Z foo(Object o) { return null; } // duplicate\n" + - " ^^^^^^^^^^^^^\n" + - "Duplicate method foo(Object) in type X.C1\n" + - "----------\n" + - "3. ERROR in X.java (at line 7)\n" + - " T foo(Object o) { return null; } // duplicate\n" + - " ^^^^^^^^^^^^^\n" + - "Duplicate method foo(Object) in type X.C2\n" + - "----------\n" + - "4. ERROR in X.java (at line 8)\n" + - " T foo(Object o) { return null; } // duplicate\n" + - " ^^^^^^^^^^^^^\n" + - "Duplicate method foo(Object) in type X.C2\n" + - "----------\n" + - "5. ERROR in X.java (at line 11)\n" + - " A foo(Object o) { return null; } // duplicate\n" + - " ^^^^^^^^^^^^^\n" + - "Duplicate method foo(Object) in type X.C3\n" + - "----------\n" + - "6. ERROR in X.java (at line 12)\n" + - " A foo(Object o) { return null; } // duplicate\n" + - " ^^^^^^^^^^^^^\n" + - "Duplicate method foo(Object) in type X.C3\n" + - "----------\n" + - "7. ERROR in X.java (at line 15)\n" + - " Y foo(Object o) { return null; } // duplicate\n" + - " ^^^^^^^^^^^^^\n" + - "Duplicate method foo(Object) in type X.C4\n" + - "----------\n" + - "8. ERROR in X.java (at line 16)\n" + - " T foo(Object o) { return null; } // duplicate\n" + - " ^^^^^^^^^^^^^\n" + - "Duplicate method foo(Object) in type X.C4\n" + - "----------\n" + expectedCompilerLog ); /* javac 7 X.java:4: foo(Object) is already defined in X.C1 @@ -3828,6 +3965,49 @@ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation public void test050c() { + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " A foo(A o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X.C5\n" + + "----------\n" + + "2. ERROR in X.java (at line 4)\n" + + " A foo(A o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X.C5\n" + + "----------\n" + + "3. WARNING in X.java (at line 7)\n" + + " T foo(A o) { return null; } // ok\n" + + " ^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X.C6\n" + + "----------\n" + + "4. WARNING in X.java (at line 8)\n" + + " T foo(A o) { return null; } // ok\n" + + " ^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X.C6\n" + + "----------\n": + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " A foo(A o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X.C5\n" + + "----------\n" + + "2. ERROR in X.java (at line 4)\n" + + " A foo(A o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X.C5\n" + + "----------\n" + + "3. ERROR in X.java (at line 7)\n" + + " T foo(A o) { return null; } // ok\n" + + " ^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X.C6\n" + + "----------\n" + + "4. ERROR in X.java (at line 8)\n" + + " T foo(A o) { return null; } // ok\n" + + " ^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X.C6\n" + + "----------\n"; this.runNegativeTest( new String[] { "X.java", @@ -3845,27 +4025,7 @@ "class Y {}\n" + "class Z {}" }, - "----------\n" + - "1. ERROR in X.java (at line 3)\n" + - " A foo(A o) { return null; } // duplicate\n" + - " ^^^^^^^^^^^\n" + - "Method foo(A) has the same erasure foo(A) as another method in type X.C5\n" + - "----------\n" + - "2. ERROR in X.java (at line 4)\n" + - " A foo(A o) { return null; } // duplicate\n" + - " ^^^^^^^^^^^\n" + - "Method foo(A) has the same erasure foo(A) as another method in type X.C5\n" + - "----------\n" + - "3. ERROR in X.java (at line 7)\n" + - " T foo(A o) { return null; } // ok\n" + - " ^^^^^^^^^^^\n" + - "Method foo(A) has the same erasure foo(A) as another method in type X.C6\n" + - "----------\n" + - "4. ERROR in X.java (at line 8)\n" + - " T foo(A o) { return null; } // ok\n" + - " ^^^^^^^^^^^\n" + - "Method foo(A) has the same erasure foo(A) as another method in type X.C6\n" + - "----------\n" + expectedCompilerLog ); /* javac 7 X.java:4: name clash: foo(A) and foo(A) have the same erasure @@ -3882,6 +4042,29 @@ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation public void test050d() { + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " T foo(Object o) { return null; } // ok\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C7\n" + + "----------\n" + + "2. WARNING in X.java (at line 4)\n" + + " T foo(Object o) { return null; } // ok\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C7\n" + + "----------\n": + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " T foo(Object o) { return null; } // ok\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C7\n" + + "----------\n" + + "2. ERROR in X.java (at line 4)\n" + + " T foo(Object o) { return null; } // ok\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C7\n" + + "----------\n"; this.runNegativeTest( new String[] { "X.java", @@ -3895,17 +4078,7 @@ "class Y {}\n" + "class Z {}" }, - "----------\n" + - "1. ERROR in X.java (at line 3)\n" + - " T foo(Object o) { return null; } // ok\n" + - " ^^^^^^^^^^^^^\n" + - "Duplicate method foo(Object) in type X.C7\n" + - "----------\n" + - "2. ERROR in X.java (at line 4)\n" + - " T foo(Object o) { return null; } // ok\n" + - " ^^^^^^^^^^^^^\n" + - "Duplicate method foo(Object) in type X.C7\n" + - "----------\n" + expectedCompilerLog ); /* javac 7 X.java:4: name clash: foo(Object) and foo(Object) have the same erasure @@ -3921,6 +4094,69 @@ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 public void test050e() { + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in X.java (at line 2)\n" + + " N a(A s) { return null; }\n" + + " ^^^^^^^^^^^^^^\n" + + "Method a(A) has the same erasure a(A) as another method in type X\n" + + "----------\n" + + "2. WARNING in X.java (at line 3)\n" + + " Object a(A n) { return null; }\n" + + " ^^^^^^^^^^^^^^\n" + + "Method a(A) has the same erasure a(A) as another method in type X\n" + + "----------\n" + + "3. WARNING in X.java (at line 4)\n" + + " void b(A s) {}\n" + + " ^^^^^^^^^^^^^^\n" + + "Method b(A) has the same erasure b(A) as another method in type X\n" + + "----------\n" + + "4. WARNING in X.java (at line 5)\n" + + " B b(A n) { return null; }\n" + + " ^^^^^^^^^^^^^^\n" + + "Method b(A) has the same erasure b(A) as another method in type X\n" + + "----------\n" + + "5. WARNING in X.java (at line 6)\n" + + " void c(A s) {}\n" + + " ^^^^^^^^^^^^^^\n" + + "Method c(A) has the same erasure c(A) as another method in type X\n" + + "----------\n" + + "6. WARNING in X.java (at line 7)\n" + + " B c(A n) { return null; }\n" + + " ^^^^^^^^^^^^^^\n" + + "Method c(A) has the same erasure c(A) as another method in type X\n" + + "----------\n": + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " N a(A s) { return null; }\n" + + " ^^^^^^^^^^^^^^\n" + + "Method a(A) has the same erasure a(A) as another method in type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " Object a(A n) { return null; }\n" + + " ^^^^^^^^^^^^^^\n" + + "Method a(A) has the same erasure a(A) as another method in type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 4)\n" + + " void b(A s) {}\n" + + " ^^^^^^^^^^^^^^\n" + + "Method b(A) has the same erasure b(A) as another method in type X\n" + + "----------\n" + + "4. ERROR in X.java (at line 5)\n" + + " B b(A n) { return null; }\n" + + " ^^^^^^^^^^^^^^\n" + + "Method b(A) has the same erasure b(A) as another method in type X\n" + + "----------\n" + + "5. ERROR in X.java (at line 6)\n" + + " void c(A s) {}\n" + + " ^^^^^^^^^^^^^^\n" + + "Method c(A) has the same erasure c(A) as another method in type X\n" + + "----------\n" + + "6. ERROR in X.java (at line 7)\n" + + " B c(A n) { return null; }\n" + + " ^^^^^^^^^^^^^^\n" + + "Method c(A) has the same erasure c(A) as another method in type X\n" + + "----------\n"; this.runNegativeTest( new String[] { "X.java", @@ -3935,37 +4171,7 @@ "class A {}\n" + "class B {}\n" }, - "----------\n" + - "1. ERROR in X.java (at line 2)\n" + - " N a(A s) { return null; }\n" + - " ^^^^^^^^^^^^^^\n" + - "Method a(A) has the same erasure a(A) as another method in type X\n" + - "----------\n" + - "2. ERROR in X.java (at line 3)\n" + - " Object a(A n) { return null; }\n" + - " ^^^^^^^^^^^^^^\n" + - "Method a(A) has the same erasure a(A) as another method in type X\n" + - "----------\n" + - "3. ERROR in X.java (at line 4)\n" + - " void b(A s) {}\n" + - " ^^^^^^^^^^^^^^\n" + - "Method b(A) has the same erasure b(A) as another method in type X\n" + - "----------\n" + - "4. ERROR in X.java (at line 5)\n" + - " B b(A n) { return null; }\n" + - " ^^^^^^^^^^^^^^\n" + - "Method b(A) has the same erasure b(A) as another method in type X\n" + - "----------\n" + - "5. ERROR in X.java (at line 6)\n" + - " void c(A s) {}\n" + - " ^^^^^^^^^^^^^^\n" + - "Method c(A) has the same erasure c(A) as another method in type X\n" + - "----------\n" + - "6. ERROR in X.java (at line 7)\n" + - " B c(A n) { return null; }\n" + - " ^^^^^^^^^^^^^^\n" + - "Method c(A) has the same erasure c(A) as another method in type X\n" + - "----------\n" + expectedCompilerLog ); /* javac 7 X.java:3: name clash: a(A) and a(A) have the same erasure @@ -4088,6 +4294,49 @@ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 public void test050i() { + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in X.java (at line 2)\n" + + " N a(A s) { return null; }\n" + + " ^^^^^^^^^^^^^^\n" + + "Duplicate method a(A) in type X\n" + + "----------\n" + + "2. WARNING in X.java (at line 3)\n" + + " Object a(A n) { return null; }\n" + + " ^^^^^^^^^^^^^^\n" + + "Duplicate method a(A) in type X\n" + + "----------\n" + + "3. WARNING in X.java (at line 4)\n" + + " N b(A s) { return null; }\n" + + " ^^^^^^^^^^^^^^\n" + + "Method b(A) has the same erasure b(A) as another method in type X\n" + + "----------\n" + + "4. WARNING in X.java (at line 5)\n" + + " Object b(A n) { return null; }\n" + + " ^^^^^^^^^^^^^^\n" + + "Method b(A) has the same erasure b(A) as another method in type X\n" + + "----------\n": + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " N a(A s) { return null; }\n" + + " ^^^^^^^^^^^^^^\n" + + "Duplicate method a(A) in type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " Object a(A n) { return null; }\n" + + " ^^^^^^^^^^^^^^\n" + + "Duplicate method a(A) in type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 4)\n" + + " N b(A s) { return null; }\n" + + " ^^^^^^^^^^^^^^\n" + + "Method b(A) has the same erasure b(A) as another method in type X\n" + + "----------\n" + + "4. ERROR in X.java (at line 5)\n" + + " Object b(A n) { return null; }\n" + + " ^^^^^^^^^^^^^^\n" + + "Method b(A) has the same erasure b(A) as another method in type X\n" + + "----------\n"; this.runNegativeTest( new String[] { "X.java", @@ -4100,27 +4349,7 @@ "class A {}\n" + "class B {}\n" }, - "----------\n" + - "1. ERROR in X.java (at line 2)\n" + - " N a(A s) { return null; }\n" + - " ^^^^^^^^^^^^^^\n" + - "Duplicate method a(A) in type X\n" + - "----------\n" + - "2. ERROR in X.java (at line 3)\n" + - " Object a(A n) { return null; }\n" + - " ^^^^^^^^^^^^^^\n" + - "Duplicate method a(A) in type X\n" + - "----------\n" + - "3. ERROR in X.java (at line 4)\n" + - " N b(A s) { return null; }\n" + - " ^^^^^^^^^^^^^^\n" + - "Method b(A) has the same erasure b(A) as another method in type X\n" + - "----------\n" + - "4. ERROR in X.java (at line 5)\n" + - " Object b(A n) { return null; }\n" + - " ^^^^^^^^^^^^^^\n" + - "Method b(A) has the same erasure b(A) as another method in type X\n" + - "----------\n" + expectedCompilerLog ); /* javac 7 X.java:3: name clash: a(A) and a(A) have the same erasure @@ -4254,26 +4483,31 @@ "class A {}\n" + "class B {}\n" }, - "----------\n" + - "1. ERROR in X.java (at line 2)\n" + - " void a(A s) {}\n" + - " ^^^^^^^^^^^^^^\n" + - "Duplicate method a(A) in type X\n" + - "----------\n" + - "2. ERROR in X.java (at line 3)\n" + - " B a(A n) { return null; }\n" + - " ^^^^^^^^^^^^^^\n" + - "Duplicate method a(A) in type X\n" + - "----------\n" + - "3. ERROR in X.java (at line 4)\n" + - " Object b(A s) {}\n" + - " ^^^^^^^^^^^^^^\n" + - "Duplicate method b(A) in type X\n" + - "----------\n" + - "4. ERROR in X.java (at line 5)\n" + - " B b(A n) { return null; }\n" + - " ^^^^^^^^^^^^^^\n" + - "Duplicate method b(A) in type X\n" + + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " void a(A s) {}\n" + + " ^^^^^^^^^^^^^^\n" + + "Duplicate method a(A) in type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " B a(A n) { return null; }\n" + + " ^^^^^^^^^^^^^^\n" + + "Duplicate method a(A) in type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 4)\n" + + " Object b(A s) {}\n" + + " ^^^^^^^^^^^^^^\n" + + "Duplicate method b(A) in type X\n" + + "----------\n" + + "4. ERROR in X.java (at line 4)\n" + + " Object b(A s) {}\n" + + " ^^^^^^^^^^^^^^\n" + + "This method must return a result of type Object\n" + + "----------\n" + + "5. ERROR in X.java (at line 5)\n" + + " B b(A n) { return null; }\n" + + " ^^^^^^^^^^^^^^\n" + + "Duplicate method b(A) in type X\n" + "----------\n" ); /* javac 7 @@ -4347,6 +4581,29 @@ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=89470 public void test051b() { + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in X.java (at line 2)\n" + + " void foo(A a) {}\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X\n" + + "----------\n" + + "2. WARNING in X.java (at line 3)\n" + + " Object foo(A a) { return null; }\n" + + " ^^^^^^^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X\n" + + "----------\n": + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " void foo(A a) {}\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " Object foo(A a) { return null; }\n" + + " ^^^^^^^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X\n" + + "----------\n"; this.runNegativeTest( new String[] { "X.java", @@ -4356,17 +4613,7 @@ "}\n" + "class A {}\n", }, - "----------\n" + - "1. ERROR in X.java (at line 2)\n" + - " void foo(A a) {}\n" + - " ^^^^^^^^^^^^^^^^\n" + - "Method foo(A) has the same erasure foo(A) as another method in type X\n" + - "----------\n" + - "2. ERROR in X.java (at line 3)\n" + - " Object foo(A a) { return null; }\n" + - " ^^^^^^^^^^^^^^^^^\n" + - "Method foo(A) has the same erasure foo(A) as another method in type X\n" + - "----------\n" + expectedCompilerLog ); /* javac 7 X.java:3: name clash: foo(A) and foo(A) have the same erasure @@ -4489,6 +4736,29 @@ // more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897 public void test054() { + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in X.java (at line 2)\n" + + " void a(Object x) {}\n" + + " ^^^^^^^^^^^\n" + + "Method a(Object) has the same erasure a(Object) as another method in type X\n" + + "----------\n" + + "2. WARNING in X.java (at line 3)\n" + + " T a(T x) { return null; }\n" + + " ^^^^^^\n" + + "Method a(T) has the same erasure a(Object) as another method in type X\n" + + "----------\n": + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " void a(Object x) {}\n" + + " ^^^^^^^^^^^\n" + + "Method a(Object) has the same erasure a(Object) as another method in type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " T a(T x) { return null; }\n" + + " ^^^^^^\n" + + "Method a(T) has the same erasure a(Object) as another method in type X\n" + + "----------\n"; this.runNegativeTest( new String[] { "X.java", @@ -4497,17 +4767,7 @@ " T a(T x) { return null; }\n" + "}\n" }, - "----------\n" + - "1. ERROR in X.java (at line 2)\n" + - " void a(Object x) {}\n" + - " ^^^^^^^^^^^\n" + - "Method a(Object) has the same erasure a(Object) as another method in type X\n" + - "----------\n" + - "2. ERROR in X.java (at line 3)\n" + - " T a(T x) { return null; }\n" + - " ^^^^^^\n" + - "Method a(T) has the same erasure a(Object) as another method in type X\n" + - "----------\n" + expectedCompilerLog ); /* javac 7 X.java:3: a(Object) is already defined in X @@ -4518,6 +4778,89 @@ } // more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897 public void test054a() { + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in X.java (at line 2)\n" + + " String aaa(X x) { return null; }\n" + + " ^^^^^^^^\n" + + "Method aaa(X) has the same erasure aaa(X) as another method in type X\n" + + "----------\n" + + "2. WARNING in X.java (at line 3)\n" + + " T aaa(T x) { return null; }\n" + + " ^^^^^^^^\n" + + "Method aaa(T) has the same erasure aaa(X) as another method in type X\n" + + "----------\n" + + "3. WARNING in X.java (at line 4)\n" + + " String aa(X x) { return null; }\n" + + " ^^^^^^^\n" + + "Method aa(X) has the same erasure aa(X) as another method in type X\n" + + "----------\n" + + "4. WARNING in X.java (at line 5)\n" + + " T aa(T x) { return null; }\n" + + " ^^^^^^^\n" + + "Method aa(T) has the same erasure aa(X) as another method in type X\n" + + "----------\n" + + "5. WARNING in X.java (at line 6)\n" + + " String a(X x) { return null; }\n" + + " ^^^^^^\n" + + "Method a(X) has the same erasure a(X) as another method in type X\n" + + "----------\n" + + "6. WARNING in X.java (at line 7)\n" + + " T a(T x) { return null; }\n" + + " ^^^^^^\n" + + "Method a(T) has the same erasure a(X) as another method in type X\n" + + "----------\n" + + "7. WARNING in X.java (at line 8)\n" + + " String z(X x) { return null; }\n" + + " ^^^^^^\n" + + "Duplicate method z(X) in type X\n" + + "----------\n" + + "8. WARNING in X.java (at line 9)\n" + + " Object z(X x) { return null; }\n" + + " ^^^^^^\n" + + "Duplicate method z(X) in type X\n" + + "----------\n": + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " String aaa(X x) { return null; }\n" + + " ^^^^^^^^\n" + + "Method aaa(X) has the same erasure aaa(X) as another method in type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " T aaa(T x) { return null; }\n" + + " ^^^^^^^^\n" + + "Method aaa(T) has the same erasure aaa(X) as another method in type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 4)\n" + + " String aa(X x) { return null; }\n" + + " ^^^^^^^\n" + + "Method aa(X) has the same erasure aa(X) as another method in type X\n" + + "----------\n" + + "4. ERROR in X.java (at line 5)\n" + + " T aa(T x) { return null; }\n" + + " ^^^^^^^\n" + + "Method aa(T) has the same erasure aa(X) as another method in type X\n" + + "----------\n" + + "5. ERROR in X.java (at line 6)\n" + + " String a(X x) { return null; }\n" + + " ^^^^^^\n" + + "Method a(X) has the same erasure a(X) as another method in type X\n" + + "----------\n" + + "6. ERROR in X.java (at line 7)\n" + + " T a(T x) { return null; }\n" + + " ^^^^^^\n" + + "Method a(T) has the same erasure a(X) as another method in type X\n" + + "----------\n" + + "7. ERROR in X.java (at line 8)\n" + + " String z(X x) { return null; }\n" + + " ^^^^^^\n" + + "Duplicate method z(X) in type X\n" + + "----------\n" + + "8. ERROR in X.java (at line 9)\n" + + " Object z(X x) { return null; }\n" + + " ^^^^^^\n" + + "Duplicate method z(X) in type X\n" + + "----------\n"; this.runNegativeTest( new String[] { "X.java", @@ -4532,47 +4875,7 @@ " Object z(X x) { return null; }\n" + "}\n" }, - "----------\n" + - "1. ERROR in X.java (at line 2)\n" + - " String aaa(X x) { return null; }\n" + - " ^^^^^^^^\n" + - "Method aaa(X) has the same erasure aaa(X) as another method in type X\n" + - "----------\n" + - "2. ERROR in X.java (at line 3)\n" + - " T aaa(T x) { return null; }\n" + - " ^^^^^^^^\n" + - "Method aaa(T) has the same erasure aaa(X) as another method in type X\n" + - "----------\n" + - "3. ERROR in X.java (at line 4)\n" + - " String aa(X x) { return null; }\n" + - " ^^^^^^^\n" + - "Method aa(X) has the same erasure aa(X) as another method in type X\n" + - "----------\n" + - "4. ERROR in X.java (at line 5)\n" + - " T aa(T x) { return null; }\n" + - " ^^^^^^^\n" + - "Method aa(T) has the same erasure aa(X) as another method in type X\n" + - "----------\n" + - "5. ERROR in X.java (at line 6)\n" + - " String a(X x) { return null; }\n" + - " ^^^^^^\n" + - "Method a(X) has the same erasure a(X) as another method in type X\n" + - "----------\n" + - "6. ERROR in X.java (at line 7)\n" + - " T a(T x) { return null; }\n" + - " ^^^^^^\n" + - "Method a(T) has the same erasure a(X) as another method in type X\n" + - "----------\n" + - "7. ERROR in X.java (at line 8)\n" + - " String z(X x) { return null; }\n" + - " ^^^^^^\n" + - "Duplicate method z(X) in type X\n" + - "----------\n" + - "8. ERROR in X.java (at line 9)\n" + - " Object z(X x) { return null; }\n" + - " ^^^^^^\n" + - "Duplicate method z(X) in type X\n" + - "----------\n" + expectedCompilerLog ); /* javac 7 X.java:3: name clash: aaa(T) and aaa(X) have the same erasure @@ -4603,6 +4906,29 @@ } // more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897 public void test054b() { + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in X.java (at line 2)\n" + + " Object foo(X t) { return null; }\n" + + " ^^^^^^^^^^^\n" + + "Duplicate method foo(X) in type X\n" + + "----------\n" + + "2. WARNING in X.java (at line 3)\n" + + " String foo(X s) { return null; }\n" + + " ^^^^^^^^^^^\n" + + "Duplicate method foo(X) in type X\n" + + "----------\n": + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " Object foo(X t) { return null; }\n" + + " ^^^^^^^^^^^\n" + + "Duplicate method foo(X) in type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " String foo(X s) { return null; }\n" + + " ^^^^^^^^^^^\n" + + "Duplicate method foo(X) in type X\n" + + "----------\n"; this.runNegativeTest( new String[] { "X.java", @@ -4611,17 +4937,7 @@ " String foo(X s) { return null; }\n" + "}\n" }, - "----------\n" + - "1. ERROR in X.java (at line 2)\n" + - " Object foo(X t) { return null; }\n" + - " ^^^^^^^^^^^\n" + - "Duplicate method foo(X) in type X\n" + - "----------\n" + - "2. ERROR in X.java (at line 3)\n" + - " String foo(X s) { return null; }\n" + - " ^^^^^^^^^^^\n" + - "Duplicate method foo(X) in type X\n" + - "----------\n" + expectedCompilerLog ); /* javac 7 X.java:3: name clash: foo(X) and foo(X) have the same erasure @@ -4666,6 +4982,49 @@ } // more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897 public void test054d() { + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in X.java (at line 2)\n" + + " T a(A t) {return null;}\n" + + " ^^^^^^^^^\n" + + "Method a(A) has the same erasure a(A) as another method in type X\n" + + "----------\n" + + "2. WARNING in X.java (at line 3)\n" + + " String a(A o) {return null;}\n" + + " ^^^^^^^^^^^^^^\n" + + "Method a(A) has the same erasure a(A) as another method in type X\n" + + "----------\n" + + "3. WARNING in X.java (at line 4)\n" + + " T aa(A t) {return null;}\n" + + " ^^^^^^^^^^\n" + + "Method aa(A) has the same erasure aa(A) as another method in type X\n" + + "----------\n" + + "4. WARNING in X.java (at line 5)\n" + + " String aa(A o) {return null;}\n" + + " ^^^^^^^^^^^^^^^\n" + + "Method aa(A) has the same erasure aa(A) as another method in type X\n" + + "----------\n": + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " T a(A t) {return null;}\n" + + " ^^^^^^^^^\n" + + "Method a(A) has the same erasure a(A) as another method in type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " String a(A o) {return null;}\n" + + " ^^^^^^^^^^^^^^\n" + + "Method a(A) has the same erasure a(A) as another method in type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 4)\n" + + " T aa(A t) {return null;}\n" + + " ^^^^^^^^^^\n" + + "Method aa(A) has the same erasure aa(A) as another method in type X\n" + + "----------\n" + + "4. ERROR in X.java (at line 5)\n" + + " String aa(A o) {return null;}\n" + + " ^^^^^^^^^^^^^^^\n" + + "Method aa(A) has the same erasure aa(A) as another method in type X\n" + + "----------\n"; this.runNegativeTest( new String[] { "X.java", @@ -4677,27 +5036,7 @@ "}\n" + "class A {}\n", }, - "----------\n" + - "1. ERROR in X.java (at line 2)\n" + - " T a(A t) {return null;}\n" + - " ^^^^^^^^^\n" + - "Method a(A) has the same erasure a(A) as another method in type X\n" + - "----------\n" + - "2. ERROR in X.java (at line 3)\n" + - " String a(A o) {return null;}\n" + - " ^^^^^^^^^^^^^^\n" + - "Method a(A) has the same erasure a(A) as another method in type X\n" + - "----------\n" + - "3. ERROR in X.java (at line 4)\n" + - " T aa(A t) {return null;}\n" + - " ^^^^^^^^^^\n" + - "Method aa(A) has the same erasure aa(A) as another method in type X\n" + - "----------\n" + - "4. ERROR in X.java (at line 5)\n" + - " String aa(A o) {return null;}\n" + - " ^^^^^^^^^^^^^^^\n" + - "Method aa(A) has the same erasure aa(A) as another method in type X\n" + - "----------\n" + expectedCompilerLog ); /* javac 7 X.java:3: name clash: a(A) and a(A) have the same erasure @@ -4821,6 +5160,59 @@ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=94898 public void test058a() { + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " new X().foo(\"X\");\n" + + " ^^^\n" + + "The method foo(String) is ambiguous for the type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 4)\n" + + " new X().foo2(\"X\");\n" + + " ^^^^\n" + + "The method foo2(String) is ambiguous for the type X\n" + + "----------\n" + + "3. WARNING in X.java (at line 6)\n" + + " T foo(T t) {return null;}\n" + + " ^^^^^^^^\n" + + "Method foo(T) has the same erasure foo(Object) as another method in type X\n" + + "----------\n" + + "4. WARNING in X.java (at line 7)\n" + + " void foo(A a) {}\n" + + " ^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(Object) as another method in type X\n" + + "----------\n" + + "5. WARNING in X.java (at line 8)\n" + + " T foo2(T t) {return null;}\n" + + " ^^^^^^^^^\n" + + "Method foo2(T) has the same erasure foo2(Object) as another method in type X\n" + + "----------\n" + + "6. WARNING in X.java (at line 9)\n" + + " void foo2(A a) {}\n" + + " ^^^^^^^^^\n" + + "Method foo2(A) has the same erasure foo2(Object) as another method in type X\n" + + "----------\n": + "----------\n" + + "1. ERROR in X.java (at line 6)\n" + + " T foo(T t) {return null;}\n" + + " ^^^^^^^^\n" + + "Method foo(T) has the same erasure foo(Object) as another method in type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 7)\n" + + " void foo(A a) {}\n" + + " ^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(Object) as another method in type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 8)\n" + + " T foo2(T t) {return null;}\n" + + " ^^^^^^^^^\n" + + "Method foo2(T) has the same erasure foo2(Object) as another method in type X\n" + + "----------\n" + + "4. ERROR in X.java (at line 9)\n" + + " void foo2(A a) {}\n" + + " ^^^^^^^^^\n" + + "Method foo2(A) has the same erasure foo2(Object) as another method in type X\n" + + "----------\n"; this.runNegativeTest( new String[] { "X.java", @@ -4835,27 +5227,7 @@ " void foo2(A a) {}\n" + "}\n" }, - "----------\n" + - "1. ERROR in X.java (at line 6)\n" + - " T foo(T t) {return null;}\n" + - " ^^^^^^^^\n" + - "Method foo(T) has the same erasure foo(Object) as another method in type X\n" + - "----------\n" + - "2. ERROR in X.java (at line 7)\n" + - " void foo(A a) {}\n" + - " ^^^^^^^^\n" + - "Method foo(A) has the same erasure foo(Object) as another method in type X\n" + - "----------\n" + - "3. ERROR in X.java (at line 8)\n" + - " T foo2(T t) {return null;}\n" + - " ^^^^^^^^^\n" + - "Method foo2(T) has the same erasure foo2(Object) as another method in type X\n" + - "----------\n" + - "4. ERROR in X.java (at line 9)\n" + - " void foo2(A a) {}\n" + - " ^^^^^^^^^\n" + - "Method foo2(A) has the same erasure foo2(Object) as another method in type X\n" + - "----------\n" + expectedCompilerLog ); /* javac 7 X.java:7: name clash: foo(A) and foo(T) have the same erasure @@ -4876,6 +5248,49 @@ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=94898 public void test058b() { + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " new X().foo(\"X\");\n" + + " ^^^\n" + + "The method foo(String) is ambiguous for the type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 4)\n" + + " new X().foo2(\"X\");\n" + + " ^^^^\n" + + "The method foo2(String) is ambiguous for the type X\n" + + "----------\n" + + "3. WARNING in X.java (at line 6)\n" + + " T foo(T t) {return null;}\n" + + " ^^^^^^^^\n" + + "Name clash: The method foo(T) of type X has the same erasure as foo(A) of type Y but does not override it\n" + + "----------\n" + + "4. WARNING in X.java (at line 7)\n" + + " T foo2(T t) {return null;}\n" + + " ^^^^^^^^^\n" + + "Name clash: The method foo2(T) of type X has the same erasure as foo2(A) of type Y but does not override it\n" + + "----------\n": + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " new X().foo(\"X\");\n" + + " ^^^\n" + + "The method foo(String) is ambiguous for the type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 4)\n" + + " new X().foo2(\"X\");\n" + + " ^^^^\n" + + "The method foo2(String) is ambiguous for the type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 6)\n" + + " T foo(T t) {return null;}\n" + + " ^^^^^^^^\n" + + "Name clash: The method foo(T) of type X has the same erasure as foo(A) of type Y but does not override it\n" + + "----------\n" + + "4. ERROR in X.java (at line 7)\n" + + " T foo2(T t) {return null;}\n" + + " ^^^^^^^^^\n" + + "Name clash: The method foo2(T) of type X has the same erasure as foo2(A) of type Y but does not override it\n" + + "----------\n"; this.runNegativeTest( new String[] { "X.java", @@ -4892,27 +5307,7 @@ " void foo2(A a) {}\n" + "}" }, - "----------\n" + - "1. ERROR in X.java (at line 3)\n" + - " new X().foo(\"X\");\n" + - " ^^^\n" + - "The method foo(String) is ambiguous for the type X\n" + - "----------\n" + - "2. ERROR in X.java (at line 4)\n" + - " new X().foo2(\"X\");\n" + - " ^^^^\n" + - "The method foo2(String) is ambiguous for the type X\n" + - "----------\n" + - "3. ERROR in X.java (at line 6)\n" + - " T foo(T t) {return null;}\n" + - " ^^^^^^^^\n" + - "Name clash: The method foo(T) of type X has the same erasure as foo(A) of type Y but does not override it\n" + - "----------\n" + - "4. ERROR in X.java (at line 7)\n" + - " T foo2(T t) {return null;}\n" + - " ^^^^^^^^^\n" + - "Name clash: The method foo2(T) of type X has the same erasure as foo2(A) of type Y but does not override it\n" + - "----------\n" + expectedCompilerLog ); /* javac 7 X.java:3: reference to foo is ambiguous, both method foo(A) in Y and method foo(T) in X match @@ -7971,6 +8366,29 @@ } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=202830 public void test120a() { + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in Bar.java (at line 2)\n" + + " int getThing(V v) { return 1; }\n" + + " ^^^^^^^^^^^^^\n" + + "Method getThing(V) has the same erasure getThing(Object) as another method in type Foo\n" + + "----------\n" + + "2. WARNING in Bar.java (at line 3)\n" + + " boolean getThing(E e) { return true; }\n" + + " ^^^^^^^^^^^^^\n" + + "Method getThing(E) has the same erasure getThing(Object) as another method in type Foo\n" + + "----------\n": + "----------\n" + + "1. ERROR in Bar.java (at line 2)\n" + + " int getThing(V v) { return 1; }\n" + + " ^^^^^^^^^^^^^\n" + + "Method getThing(V) has the same erasure getThing(Object) as another method in type Foo\n" + + "----------\n" + + "2. ERROR in Bar.java (at line 3)\n" + + " boolean getThing(E e) { return true; }\n" + + " ^^^^^^^^^^^^^\n" + + "Method getThing(E) has the same erasure getThing(Object) as another method in type Foo\n" + + "----------\n"; this.runNegativeTest( new String[] { "Bar.java", @@ -7980,17 +8398,7 @@ "}\n" + "public class Bar extends Foo {}" }, - "----------\n" + - "1. ERROR in Bar.java (at line 2)\n" + - " int getThing(V v) { return 1; }\n" + - " ^^^^^^^^^^^^^\n" + - "Method getThing(V) has the same erasure getThing(Object) as another method in type Foo\n" + - "----------\n" + - "2. ERROR in Bar.java (at line 3)\n" + - " boolean getThing(E e) { return true; }\n" + - " ^^^^^^^^^^^^^\n" + - "Method getThing(E) has the same erasure getThing(Object) as another method in type Foo\n" + - "----------\n" + expectedCompilerLog ); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=173477 @@ -9700,6 +10108,59 @@ // JDK7 (7b100) behavior. (earlier we would issue an extra name clash) public void test177() { if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_6) { // see test187() + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)? + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " class A extends LinkedHashMap {\n" + + " ^\n" + + "The serializable class A does not declare a static final serialVersionUID field of type long\n" + + "----------\n" + + "2. WARNING in X.java (at line 3)\n" + + " class A extends LinkedHashMap {\n" + + " ^^^^^^^^^^^^^\n" + + "LinkedHashMap is a raw type. References to generic type LinkedHashMap should be parameterized\n" + + "----------\n" + + "3. WARNING in X.java (at line 4)\n" + + " public A foo(Collection c) { return this; }\n" + + " ^^^^^^^^^^\n" + + "Collection is a raw type. References to generic type Collection should be parameterized\n" + + "----------\n" + + "4. WARNING in X.java (at line 6)\n" + + " class X extends A implements I {\n" + + " ^\n" + + "The serializable class X does not declare a static final serialVersionUID field of type long\n" + + "----------\n" + + "5. WARNING in X.java (at line 7)\n" + + " @Override public X foo(Collection c) { return this; }\n" + + " ^^^^^^^^^^^^^^^^^^^^\n" + + "Name clash: The method foo(Collection) of type X has the same erasure as foo(Collection) of type A but does not override it\n" + + "----------\n": + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " class A extends LinkedHashMap {\n" + + " ^\n" + + "The serializable class A does not declare a static final serialVersionUID field of type long\n" + + "----------\n" + + "2. WARNING in X.java (at line 3)\n" + + " class A extends LinkedHashMap {\n" + + " ^^^^^^^^^^^^^\n" + + "LinkedHashMap is a raw type. References to generic type LinkedHashMap should be parameterized\n" + + "----------\n" + + "3. WARNING in X.java (at line 4)\n" + + " public A foo(Collection c) { return this; }\n" + + " ^^^^^^^^^^\n" + + "Collection is a raw type. References to generic type Collection should be parameterized\n" + + "----------\n" + + "4. WARNING in X.java (at line 6)\n" + + " class X extends A implements I {\n" + + " ^\n" + + "The serializable class X does not declare a static final serialVersionUID field of type long\n" + + "----------\n" + + "5. ERROR in X.java (at line 7)\n" + + " @Override public X foo(Collection c) { return this; }\n" + + " ^^^^^^^^^^^^^^^^^^^^\n" + + "Name clash: The method foo(Collection) of type X has the same erasure as foo(Collection) of type A but does not override it\n" + + "----------\n"; this.runNegativeTest( new String[] { "X.java", @@ -9712,32 +10173,7 @@ " @Override public X foo(Collection c) { return this; }\n" + "}" }, - "----------\n" + - "1. WARNING in X.java (at line 3)\n" + - " class A extends LinkedHashMap {\n" + - " ^\n" + - "The serializable class A does not declare a static final serialVersionUID field of type long\n" + - "----------\n" + - "2. WARNING in X.java (at line 3)\n" + - " class A extends LinkedHashMap {\n" + - " ^^^^^^^^^^^^^\n" + - "LinkedHashMap is a raw type. References to generic type LinkedHashMap should be parameterized\n" + - "----------\n" + - "3. WARNING in X.java (at line 4)\n" + - " public A foo(Collection c) { return this; }\n" + - " ^^^^^^^^^^\n" + - "Collection is a raw type. References to generic type Collection should be parameterized\n" + - "----------\n" + - "4. WARNING in X.java (at line 6)\n" + - " class X extends A implements I {\n" + - " ^\n" + - "The serializable class X does not declare a static final serialVersionUID field of type long\n" + - "----------\n" + - "5. ERROR in X.java (at line 7)\n" + - " @Override public X foo(Collection c) { return this; }\n" + - " ^^^^^^^^^^^^^^^^^^^^\n" + - "Name clash: The method foo(Collection) of type X has the same erasure as foo(Collection) of type A but does not override it\n" + - "----------\n" + expectedCompilerLog ); } else { this.runNegativeTest( @@ -9777,7 +10213,7 @@ " @Override public X foo(Collection c) { return this; }\n" + " ^^^^^^^^^^^^^^^^^^^^\n" + "Name clash: The method foo(Collection) of type X has the same erasure as foo(Collection) of type A but does not override it\n" + - "----------\n" + + "----------\n" + "6. ERROR in X.java (at line 7)\n" + " @Override public X foo(Collection c) { return this; }\n" + " ^^^^^^^^^^^^^^^^^^^^\n" + @@ -10246,6 +10682,39 @@ // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950 //https://bugs.eclipse.org/bugs/show_bug.cgi?id=? public void test187() { + String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6 )? + "----------\n" + + "1. WARNING in X.java (at line 6)\n" + + " double f(List l) {return 0;}\n" + + " ^^^^^^^^^^^^^^^^^^\n" + + "Name clash: The method f(List) of type Y has the same erasure as f(List) of type X but does not override it\n" + + "----------\n" + + "2. WARNING in X.java (at line 13)\n" + + " int f(List l) {return 0;}\n" + + " ^^^^^^^^^^^^^^^^^\n" + + "Method f(List) has the same erasure f(List) as another method in type XX\n" + + "----------\n" + + "3. WARNING in X.java (at line 14)\n" + + " double f(List l) {return 0;}\n" + + " ^^^^^^^^^^^^^^^^^^\n" + + "Method f(List) has the same erasure f(List) as another method in type XX\n" + + "----------\n": + "----------\n" + + "1. ERROR in X.java (at line 6)\n" + + " double f(List l) {return 0;}\n" + + " ^^^^^^^^^^^^^^^^^^\n" + + "Name clash: The method f(List) of type Y has the same erasure as f(List) of type X but does not override it\n" + + "----------\n" + + "2. ERROR in X.java (at line 13)\n" + + " int f(List l) {return 0;}\n" + + " ^^^^^^^^^^^^^^^^^\n" + + "Method f(List) has the same erasure f(List) as another method in type XX\n" + + "----------\n" + + "3. ERROR in X.java (at line 14)\n" + + " double f(List l) {return 0;}\n" + + " ^^^^^^^^^^^^^^^^^^\n" + + "Method f(List) has the same erasure f(List) as another method in type XX\n" + + "----------\n"; this.runNegativeTest( new String[] { "X.java", @@ -10265,22 +10734,7 @@ "double f(List l) {return 0;}\n" +// name clash in 1.5 & 7 "}" }, - "----------\n" + - "1. ERROR in X.java (at line 6)\n" + - " double f(List l) {return 0;}\n" + - " ^^^^^^^^^^^^^^^^^^\n" + - "Name clash: The method f(List) of type Y has the same erasure as f(List) of type X but does not override it\n" + - "----------\n" + - "2. ERROR in X.java (at line 13)\n" + - " int f(List l) {return 0;}\n" + - " ^^^^^^^^^^^^^^^^^\n" + - "Method f(List) has the same erasure f(List) as another method in type XX\n" + - "----------\n" + - "3. ERROR in X.java (at line 14)\n" + - " double f(List l) {return 0;}\n" + - " ^^^^^^^^^^^^^^^^^^\n" + - "Method f(List) has the same erasure f(List) as another method in type XX\n" + - "----------\n" + expectedCompilerLog ); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=279836 @@ -10702,6 +11156,41 @@ } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=285088 public void test200() { + Map options = getCompilerOptions(); + String compliance = (String) options.get(JavaCore.COMPILER_COMPLIANCE); + String errorMessage = compliance == JavaCore.VERSION_1_6 ? + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " int foo(Collection bar) { return 0; }\n" + + " ^^^^^^^^^^^^^^^^^^^\n" + + "Method foo(Collection) has the same erasure foo(Collection) as another method in type X\n" + + "----------\n" + + "2. WARNING in X.java (at line 3)\n" + + " int foo(Collection bar) { return 0; }\n" + + " ^^^^^^^^^^\n" + + "Collection is a raw type. References to generic type Collection should be parameterized\n" + + "----------\n" + + "3. WARNING in X.java (at line 4)\n" + + " double foo(Collection bar) {return 0; }\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Method foo(Collection) has the same erasure foo(Collection) as another method in type X\n" + + "----------\n" : + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " int foo(Collection bar) { return 0; }\n" + + " ^^^^^^^^^^^^^^^^^^^\n" + + "Method foo(Collection) has the same erasure foo(Collection) as another method in type X\n" + + "----------\n" + + "2. WARNING in X.java (at line 3)\n" + + " int foo(Collection bar) { return 0; }\n" + + " ^^^^^^^^^^\n" + + "Collection is a raw type. References to generic type Collection should be parameterized\n" + + "----------\n" + + "3. ERROR in X.java (at line 4)\n" + + " double foo(Collection bar) {return 0; }\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Method foo(Collection) has the same erasure foo(Collection) as another method in type X\n" + + "----------\n"; this.runNegativeTest( new String[] { "X.java", @@ -10711,22 +11200,7 @@ " double foo(Collection bar) {return 0; }\n" + "}" }, - "----------\n" + - "1. ERROR in X.java (at line 3)\n" + - " int foo(Collection bar) { return 0; }\n" + - " ^^^^^^^^^^^^^^^^^^^\n" + - "Method foo(Collection) has the same erasure foo(Collection) as another method in type X\n" + - "----------\n" + - "2. WARNING in X.java (at line 3)\n" + - " int foo(Collection bar) { return 0; }\n" + - " ^^^^^^^^^^\n" + - "Collection is a raw type. References to generic type Collection should be parameterized\n" + - "----------\n" + - "3. ERROR in X.java (at line 4)\n" + - " double foo(Collection bar) {return 0; }\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Method foo(Collection) has the same erasure foo(Collection) as another method in type X\n" + - "----------\n" + errorMessage ); /* javac 7 X.java:4: foo(Collection) is already defined in X