Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 200840 Details for
Bug 317719
Method incorrectly flagged as having same erasure output when return type differs
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
proposed fix v2.0 + updated tests
patch317719_6.txt (text/plain), 147.88 KB, created by
Ayushman Jain
on 2011-08-03 13:32:21 EDT
(
hide
)
Description:
proposed fix v2.0 + updated tests
Filename:
MIME Type:
Creator:
Ayushman Jain
Created:
2011-08-03 13:32:21 EDT
Size:
147.88 KB
patch
obsolete
>### 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<T>... 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" + >+ " <S extends A> void foo() { }\n" + >+ " ^^^^^\n" + >+ "Duplicate method foo() in type X\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 3)\n" + >+ " <N extends B> 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" + >+ " <S extends A> void foo() { }\n" + >+ " ^^^^^\n" + >+ "Duplicate method foo() in type X\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 3)\n" + >+ " <N extends B> 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" + >- " <S extends A> void foo() { }\n" + >- " ^^^^^\n" + >- "Duplicate method foo() in type X\n" + >- "----------\n" + >- "2. ERROR in X.java (at line 3)\n" + >- " <N extends B> N foo() { return null; }\n" + >- " ^^^^^\n" + >- "Duplicate method foo() in type X\n" + >- "----------\n" >- ); >+ expectedCompilerLog); > /* javac 7 > X.java:3: name clash: <N>foo() and <S>foo() have the same erasure > <N extends B> 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<T> {\n" + >- " void test() {\n" + >- " new Y<Object>().foo(\"X\");\n" + >- " new Y<Object>().foo2(\"X\");\n" + >- " }\n" + >- " <U1> U1 foo(U1 t) {return null;}\n" + >- " <U2> U2 foo2(U2 t) {return null;}\n" + >- "}\n" + >- "class Y<T2> extends X<T2> {\n" + >- " void foo(T2 t) {}\n" + >- " <U3> 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<Object>().foo(\"X\");\n" + >+ " ^^^\n" + >+ "The method foo(Object) is ambiguous for the type Y<Object>\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 4)\n" + >+ " new Y<Object>().foo2(\"X\");\n" + >+ " ^^^^\n" + >+ "The method foo2(Object) is ambiguous for the type Y<Object>\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<T2> has the same erasure as foo(U1) of type X<T> but does not override it\n" + >+ "----------\n" + >+ "4. WARNING in X.java (at line 11)\n" + >+ " <U3> void foo2(T2 t) {}\n" + >+ " ^^^^^^^^^^\n" + >+ "Name clash: The method foo2(T2) of type Y<T2> has the same erasure as foo2(U2) of type X<T> but does not override it\n" + >+ "----------\n": >+ "----------\n" + > "1. ERROR in X.java (at line 3)\n" + > " new Y<Object>().foo(\"X\");\n" + > " ^^^\n" + >@@ -314,7 +338,24 @@ > " <U3> void foo2(T2 t) {}\n" + > " ^^^^^^^^^^\n" + > "Name clash: The method foo2(T2) of type Y<T2> has the same erasure as foo2(U2) of type X<T> but does not override it\n" + >- "----------\n" >+ "----------\n"; >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X<T> {\n" + >+ " void test() {\n" + >+ " new Y<Object>().foo(\"X\");\n" + >+ " new Y<Object>().foo2(\"X\");\n" + >+ " }\n" + >+ " <U1> U1 foo(U1 t) {return null;}\n" + >+ " <U2> U2 foo2(U2 t) {return null;}\n" + >+ "}\n" + >+ "class Y<T2> extends X<T2> {\n" + >+ " void foo(T2 t) {}\n" + >+ " <U3> void foo2(T2 t) {}\n" + >+ "}\n" >+ }, >+ expectedCompilerLog > ); > /* javac 7 > X.java:3: reference to foo is ambiguous, both method <U1>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" + >+ " <T extends Comparable<T>> void pickOne(T value) throws ExOne {}\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Method pickOne(T) has the same erasure pickOne(Comparable<T>) as another method in type Combined<A,B>\n" + >+ "----------\n" + >+ "2. WARNING in Combined.java (at line 3)\n" + >+ " <T> T pickOne(Comparable<T> value) throws ExTwo { return null;}\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Method pickOne(Comparable<T>) has the same erasure pickOne(Comparable<T>) as another method in type Combined<A,B>\n" + >+ "----------\n": >+ "----------\n" + >+ "1. ERROR in Combined.java (at line 2)\n" + >+ " <T extends Comparable<T>> void pickOne(T value) throws ExOne {}\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Method pickOne(T) has the same erasure pickOne(Comparable<T>) as another method in type Combined<A,B>\n" + >+ "----------\n" + >+ "2. ERROR in Combined.java (at line 3)\n" + >+ " <T> T pickOne(Comparable<T> value) throws ExTwo { return null;}\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Method pickOne(Comparable<T>) has the same erasure pickOne(Comparable<T>) as another method in type Combined<A,B>\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" + >- " <T extends Comparable<T>> void pickOne(T value) throws ExOne {}\n" + >- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >- "Method pickOne(T) has the same erasure pickOne(Comparable<T>) as another method in type Combined<A,B>\n" + >- "----------\n" + >- "2. ERROR in Combined.java (at line 3)\n" + >- " <T> T pickOne(Comparable<T> value) throws ExTwo { return null;}\n" + >- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >- "Method pickOne(Comparable<T>) has the same erasure pickOne(Comparable<T>) as another method in type Combined<A,B>\n" + >- "----------\n" >+ expectedCompilerLog > ); > /* javac 7 > X.java:3: name clash: <T#1>pickOne(Comparable<T#1>) and <T#2>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<AA, BB> {\n" + >- " <T extends Comparable<T>> void pickOne(T value) throws ExOne {}\n" + >- " <T> T pickOne(Comparable<T> value) throws ExTwo { return null;}\n" + >- " void pickOne2(Test1<Integer,Integer> 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" + >+ " <T extends Comparable<T>> void pickOne(T value) throws ExOne {}\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Method pickOne(T) has the same erasure pickOne(Comparable<T>) as another method in type Test1<AA,BB>\n" + >+ "----------\n" + >+ "2. WARNING in Test1.java (at line 3)\n" + >+ " <T> T pickOne(Comparable<T> value) throws ExTwo { return null;}\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Method pickOne(Comparable<T>) has the same erasure pickOne(Comparable<T>) as another method in type Test1<AA,BB>\n" + >+ "----------\n" + >+ "3. WARNING in Test1.java (at line 4)\n" + >+ " void pickOne2(Test1<Integer,Integer> c) throws ExOne { c.pickOne((Comparable) \"test\"); }\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Type safety: Unchecked invocation pickOne(Comparable) of the generic method pickOne(T) of type Test1<Integer,Integer>\n" + >+ "----------\n" + >+ "4. WARNING in Test1.java (at line 4)\n" + >+ " void pickOne2(Test1<Integer,Integer> c) throws ExOne { c.pickOne((Comparable) \"test\"); }\n" + >+ " ^^^^^^^^^^\n" + >+ "Comparable is a raw type. References to generic type Comparable<T> should be parameterized\n" + >+ "----------\n": > "----------\n" + > "1. ERROR in Test1.java (at line 2)\n" + > " <T extends Comparable<T>> void pickOne(T value) throws ExOne {}\n" + >@@ -611,7 +676,19 @@ > " void pickOne2(Test1<Integer,Integer> c) throws ExOne { c.pickOne((Comparable) \"test\"); }\n" + > " ^^^^^^^^^^\n" + > "Comparable is a raw type. References to generic type Comparable<T> should be parameterized\n" + >- "----------\n" >+ "----------\n"; >+ this.runNegativeTest( >+ new String[] { >+ "Test1.java", >+ "public class Test1<AA, BB> {\n" + >+ " <T extends Comparable<T>> void pickOne(T value) throws ExOne {}\n" + >+ " <T> T pickOne(Comparable<T> value) throws ExTwo { return null;}\n" + >+ " void pickOne2(Test1<Integer,Integer> 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: <T#1>pickOne(Comparable<T#1>) and <T#2>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<T extends Object> {\n" + >- "}\n" + >- "public class Y<V extends String> extends X<V> {\n" + >- " public static <W extends String> Y<W> make(Class<W> clazz) {\n" + >- " System.out.print(true);\n" + >- " return new Y<W>();\n" + >- " }\n" + >- " public static <U extends Object> X<U> make(Class<U> clazz) {\n" + >- " System.out.print(false);\n" + >- " return new X<U>();\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<V extends String> extends X<V> {\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 <W extends String> Y<W> make(Class<W> 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 <W extends String> Y<W> make(Class<W> clazz) {\n" + >+ " ^^^^^^^^^^^^^^^^^^^^\n" + >+ "Method make(Class<W>) has the same erasure make(Class<T>) as another method in type Y<V>\n" + >+ "----------\n" + >+ "4. WARNING in Y.java (at line 8)\n" + >+ " public static <U extends Object> X<U> make(Class<U> clazz) {\n" + >+ " ^^^^^^^^^^^^^^^^^^^^\n" + >+ "Method make(Class<U>) has the same erasure make(Class<T>) as another method in type Y<V>\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<W>) 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<String>\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<T> should be parameterized\n" + >+ "----------\n": > "----------\n" + > "1. WARNING in Y.java (at line 3)\n" + > " public class Y<V extends String> extends X<V> {\n" + >@@ -1627,7 +1719,30 @@ > " public static Class getClazz() {\n" + > " ^^^^^\n" + > "Class is a raw type. References to generic type Class<T> should be parameterized\n" + >- "----------\n" >+ "----------\n"; >+ this.runNegativeTest( >+ new String[] { >+ "Y.java", >+ "class X<T extends Object> {\n" + >+ "}\n" + >+ "public class Y<V extends String> extends X<V> {\n" + >+ " public static <W extends String> Y<W> make(Class<W> clazz) {\n" + >+ " System.out.print(true);\n" + >+ " return new Y<W>();\n" + >+ " }\n" + >+ " public static <U extends Object> X<U> make(Class<U> clazz) {\n" + >+ " System.out.print(false);\n" + >+ " return new X<U>();\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: <U>make(Class<U>) and <W>make(Class<W>) 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<T extends Object> {\n" + >- "}\n" + >- "class Y<V extends String> extends X<V> {\n" + >- " public <W extends String> Y<W> make(Class<W> clazz) {\n" + >- " return new Y<W>();\n" + >- " }\n" + >- " public <U extends Object> X<U> make(Class<U> clazz) {\n" + >- " return new X<U>();\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<V extends String> extends X<V> {\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 <W extends String> Y<W> make(Class<W> 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 <W extends String> Y<W> make(Class<W> clazz) {\n" + >+ " ^^^^^^^^^^^^^^^^^^^^\n" + >+ "Method make(Class<W>) has the same erasure make(Class<T>) as another method in type Y<V>\n" + >+ "----------\n" + >+ "4. WARNING in X.java (at line 7)\n" + >+ " public <U extends Object> X<U> make(Class<U> clazz) {\n" + >+ " ^^^^^^^^^^^^^^^^^^^^\n" + >+ "Method make(Class<U>) has the same erasure make(Class<T>) as another method in type Y<V>\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<V> 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<V> 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<T> should be parameterized\n" + >+ "----------\n": > "----------\n" + > "1. WARNING in X.java (at line 3)\n" + > " class Y<V extends String> extends X<V> {\n" + >@@ -1732,7 +1876,31 @@ > " public static Class getClazz() {\n" + > " ^^^^^\n" + > "Class is a raw type. References to generic type Class<T> should be parameterized\n" + >- "----------\n" >+ "----------\n"; >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X<T extends Object> {\n" + >+ "}\n" + >+ "class Y<V extends String> extends X<V> {\n" + >+ " public <W extends String> Y<W> make(Class<W> clazz) {\n" + >+ " return new Y<W>();\n" + >+ " }\n" + >+ " public <U extends Object> X<U> make(Class<U> clazz) {\n" + >+ " return new X<U>();\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: <U>make(Class<U>) and <W>make(Class<W>) 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 extends Number> 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 extends Number> 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 extends Number> 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" + >+ " <U> J<String> b();\n" + >+ " ^^^\n" + >+ "Name clash: The method b() of type J<E> has the same erasure as b() of type I<E> but does not override it\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 15)\n" + >+ " J<Integer> b = ints.a();\n" + >+ " ^^^^^^^^\n" + >+ "Type mismatch: cannot convert from J<String> to J<Integer>\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 16)\n" + >+ " J<Object> c = ints.a();\n" + >+ " ^^^^^^^^\n" + >+ "Type mismatch: cannot convert from J<String> to J<Object>\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<E> should be parameterized\n" + >+ "----------\n" + >+ "5. ERROR in X.java (at line 19)\n" + >+ " I<Integer> f = ints.a();\n" + >+ " ^^^^^^^^\n" + >+ "Type mismatch: cannot convert from J<String> to I<Integer>\n" + >+ "----------\n" + >+ "6. ERROR in X.java (at line 20)\n" + >+ " I<Object> g = ints.a();\n" + >+ " ^^^^^^^^\n" + >+ "Type mismatch: cannot convert from J<String> to I<Object>\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<E> 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<Integer>\n" + >+ "----------\n" + >+ "9. ERROR in X.java (at line 25)\n" + >+ " J<String> a = ints.b();\n" + >+ " ^\n" + >+ "The method b() is ambiguous for the type J<Integer>\n" + >+ "----------\n" + >+ "10. ERROR in X.java (at line 26)\n" + >+ " J<Integer> b = ints.b();\n" + >+ " ^\n" + >+ "The method b() is ambiguous for the type J<Integer>\n" + >+ "----------\n" + >+ "11. ERROR in X.java (at line 27)\n" + >+ " J<Object> c = ints.b();\n" + >+ " ^\n" + >+ "The method b() is ambiguous for the type J<Integer>\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<E> 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<Integer>\n" + >+ "----------\n" + >+ "14. ERROR in X.java (at line 29)\n" + >+ " I<String> e = ints.b();\n" + >+ " ^\n" + >+ "The method b() is ambiguous for the type J<Integer>\n" + >+ "----------\n" + >+ "15. ERROR in X.java (at line 30)\n" + >+ " I<Integer> f = ints.b();\n" + >+ " ^\n" + >+ "The method b() is ambiguous for the type J<Integer>\n" + >+ "----------\n" + >+ "16. ERROR in X.java (at line 31)\n" + >+ " I<Object> g = ints.b();\n" + >+ " ^\n" + >+ "The method b() is ambiguous for the type J<Integer>\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<E> 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<Integer>\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<E> 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<E> should be parameterized\n" + >+ "----------\n": >+ "----------\n" + >+ "1. ERROR in X.java (at line 8)\n" + >+ " <U> J<String> b();\n" + >+ " ^^^\n" + >+ "Name clash: The method b() of type J<E> has the same erasure as b() of type I<E> but does not override it\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 15)\n" + >+ " J<Integer> b = ints.a();\n" + >+ " ^^^^^^^^\n" + >+ "Type mismatch: cannot convert from J<String> to J<Integer>\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 16)\n" + >+ " J<Object> c = ints.a();\n" + >+ " ^^^^^^^^\n" + >+ "Type mismatch: cannot convert from J<String> to J<Object>\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<E> should be parameterized\n" + >+ "----------\n" + >+ "5. ERROR in X.java (at line 19)\n" + >+ " I<Integer> f = ints.a();\n" + >+ " ^^^^^^^^\n" + >+ "Type mismatch: cannot convert from J<String> to I<Integer>\n" + >+ "----------\n" + >+ "6. ERROR in X.java (at line 20)\n" + >+ " I<Object> g = ints.a();\n" + >+ " ^^^^^^^^\n" + >+ "Type mismatch: cannot convert from J<String> to I<Object>\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<E> 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<Integer>\n" + >+ "----------\n" + >+ "9. ERROR in X.java (at line 25)\n" + >+ " J<String> a = ints.b();\n" + >+ " ^\n" + >+ "The method b() is ambiguous for the type J<Integer>\n" + >+ "----------\n" + >+ "10. ERROR in X.java (at line 26)\n" + >+ " J<Integer> b = ints.b();\n" + >+ " ^\n" + >+ "The method b() is ambiguous for the type J<Integer>\n" + >+ "----------\n" + >+ "11. ERROR in X.java (at line 27)\n" + >+ " J<Object> c = ints.b();\n" + >+ " ^\n" + >+ "The method b() is ambiguous for the type J<Integer>\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<E> 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<Integer>\n" + >+ "----------\n" + >+ "14. ERROR in X.java (at line 29)\n" + >+ " I<String> e = ints.b();\n" + >+ " ^\n" + >+ "The method b() is ambiguous for the type J<Integer>\n" + >+ "----------\n" + >+ "15. ERROR in X.java (at line 30)\n" + >+ " I<Integer> f = ints.b();\n" + >+ " ^\n" + >+ "The method b() is ambiguous for the type J<Integer>\n" + >+ "----------\n" + >+ "16. ERROR in X.java (at line 31)\n" + >+ " I<Object> g = ints.b();\n" + >+ " ^\n" + >+ "The method b() is ambiguous for the type J<Integer>\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<E> 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<Integer>\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<E> 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<E> 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" + >- " <U> J<String> b();\n" + >- " ^^^\n" + >- "Name clash: The method b() of type J<E> has the same erasure as b() of type I<E> but does not override it\n" + >- "----------\n" + >- "2. ERROR in X.java (at line 15)\n" + >- " J<Integer> b = ints.a();\n" + >- " ^^^^^^^^\n" + >- "Type mismatch: cannot convert from J<String> to J<Integer>\n" + >- "----------\n" + >- "3. ERROR in X.java (at line 16)\n" + >- " J<Object> c = ints.a();\n" + >- " ^^^^^^^^\n" + >- "Type mismatch: cannot convert from J<String> to J<Object>\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<E> should be parameterized\n" + >- "----------\n" + >- "5. ERROR in X.java (at line 19)\n" + >- " I<Integer> f = ints.a();\n" + >- " ^^^^^^^^\n" + >- "Type mismatch: cannot convert from J<String> to I<Integer>\n" + >- "----------\n" + >- "6. ERROR in X.java (at line 20)\n" + >- " I<Object> g = ints.a();\n" + >- " ^^^^^^^^\n" + >- "Type mismatch: cannot convert from J<String> to I<Object>\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<E> 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<Integer>\n" + >- "----------\n" + >- "9. ERROR in X.java (at line 25)\n" + >- " J<String> a = ints.b();\n" + >- " ^\n" + >- "The method b() is ambiguous for the type J<Integer>\n" + >- "----------\n" + >- "10. ERROR in X.java (at line 26)\n" + >- " J<Integer> b = ints.b();\n" + >- " ^\n" + >- "The method b() is ambiguous for the type J<Integer>\n" + >- "----------\n" + >- "11. ERROR in X.java (at line 27)\n" + >- " J<Object> c = ints.b();\n" + >- " ^\n" + >- "The method b() is ambiguous for the type J<Integer>\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<E> 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<Integer>\n" + >- "----------\n" + >- "14. ERROR in X.java (at line 29)\n" + >- " I<String> e = ints.b();\n" + >- " ^\n" + >- "The method b() is ambiguous for the type J<Integer>\n" + >- "----------\n" + >- "15. ERROR in X.java (at line 30)\n" + >- " I<Integer> f = ints.b();\n" + >- " ^\n" + >- "The method b() is ambiguous for the type J<Integer>\n" + >- "----------\n" + >- "16. ERROR in X.java (at line 31)\n" + >- " I<Object> g = ints.b();\n" + >- " ^\n" + >- "The method b() is ambiguous for the type J<Integer>\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<E> 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<Integer>\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<E> 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<E> 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<String> a) {}\n" + >+ " ^^^^^^^^^^^^^^^^\n" + >+ "Method foo(A<String>) has the same erasure foo(A<T>) as another method in type X\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 3)\n" + >+ " Object foo(A<Integer> a) { return null; }\n" + >+ " ^^^^^^^^^^^^^^^^^\n" + >+ "Method foo(A<Integer>) has the same erasure foo(A<T>) as another method in type X\n" + >+ "----------\n": >+ "----------\n" + >+ "1. ERROR in X.java (at line 2)\n" + >+ " void foo(A<String> a) {}\n" + >+ " ^^^^^^^^^^^^^^^^\n" + >+ "Method foo(A<String>) has the same erasure foo(A<T>) as another method in type X\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 3)\n" + >+ " Object foo(A<Integer> a) { return null; }\n" + >+ " ^^^^^^^^^^^^^^^^^\n" + >+ "Method foo(A<Integer>) has the same erasure foo(A<T>) as another method in type X\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 4)\n" + >+ " void test(A<Integer> a) { foo(a); }\n" + >+ " ^^^\n" + >+ "The method foo(A<String>) in the type X is not applicable for the arguments (A<Integer>)\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "X.java", >@@ -17676,22 +17704,7 @@ > "}\n" + > "class A<T> {}\n", > }, >- "----------\n" + >- "1. ERROR in X.java (at line 2)\n" + >- " void foo(A<String> a) {}\n" + >- " ^^^^^^^^^^^^^^^^\n" + >- "Method foo(A<String>) has the same erasure foo(A<T>) as another method in type X\n" + >- "----------\n" + >- "2. ERROR in X.java (at line 3)\n" + >- " Object foo(A<Integer> a) { return null; }\n" + >- " ^^^^^^^^^^^^^^^^^\n" + >- "Method foo(A<Integer>) has the same erasure foo(A<T>) as another method in type X\n" + >- "----------\n" + >- "3. ERROR in X.java (at line 4)\n" + >- " void test(A<Integer> a) { foo(a); }\n" + >- " ^^^\n" + >- "The method foo(A<String>) in the type X is not applicable for the arguments (A<Integer>)\n" + >- "----------\n" >+ expectedCompilerLog > ); > /* javac 7 > X.java:3: name clash: foo(A<Integer>) and foo(A<String>) have the same erasure >@@ -17704,6 +17717,34 @@ > found: A<Integer> > 2 errors > */ >+ String expectedCompilerLog2 = (this.complianceLevel == ClassFileConstants.JDK1_6)? >+ "----------\n" + >+ "1. WARNING in X.java (at line 2)\n" + >+ " Number foo(A<String> a) { return null; }\n" + >+ " ^^^^^^^^^^^^^^^^\n" + >+ "Method foo(A<String>) has the same erasure foo(A<T>) as another method in type X\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 3)\n" + >+ " Integer foo(A<Integer> a) { return null; }\n" + >+ " ^^^^^^^^^^^^^^^^^\n" + >+ "Method foo(A<Integer>) has the same erasure foo(A<T>) as another method in type X\n" + >+ "----------\n": >+ "----------\n" + >+ "1. ERROR in X.java (at line 2)\n" + >+ " Number foo(A<String> a) { return null; }\n" + >+ " ^^^^^^^^^^^^^^^^\n" + >+ "Method foo(A<String>) has the same erasure foo(A<T>) as another method in type X\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 3)\n" + >+ " Integer foo(A<Integer> a) { return null; }\n" + >+ " ^^^^^^^^^^^^^^^^^\n" + >+ "Method foo(A<Integer>) has the same erasure foo(A<T>) as another method in type X\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 4)\n" + >+ " void test(A<Integer> a) { foo(a); }\n" + >+ " ^^^\n" + >+ "The method foo(A<String>) in the type X is not applicable for the arguments (A<Integer>)\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "X.java", >@@ -17714,22 +17755,7 @@ > "}\n" + > "class A<T> {}\n", > }, >- "----------\n" + >- "1. ERROR in X.java (at line 2)\n" + >- " Number foo(A<String> a) { return null; }\n" + >- " ^^^^^^^^^^^^^^^^\n" + >- "Method foo(A<String>) has the same erasure foo(A<T>) as another method in type X\n" + >- "----------\n" + >- "2. ERROR in X.java (at line 3)\n" + >- " Integer foo(A<Integer> a) { return null; }\n" + >- " ^^^^^^^^^^^^^^^^^\n" + >- "Method foo(A<Integer>) has the same erasure foo(A<T>) as another method in type X\n" + >- "----------\n" + >- "3. ERROR in X.java (at line 4)\n" + >- " void test(A<Integer> a) { foo(a); }\n" + >- " ^^^\n" + >- "The method foo(A<String>) in the type X is not applicable for the arguments (A<Integer>)\n" + >- "----------\n" >+ expectedCompilerLog2 > /* javac 7 > X.java:3: name clash: foo(A<Integer>) and foo(A<String>) have the same erasure > Integer foo(A<Integer> 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 extends Integer> 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 extends Integer> 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 extends String> 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 extends String> 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<String>) 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 extends Integer> 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 extends Integer> 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 extends String> 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 extends String> 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 extends Integer> 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 extends Integer> 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 extends String> 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 extends String> 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: <T#1>foo(Object) and <T#2>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<CC> { <U> BB test() {return null;} }\n" + >+ " ^^^^^^\n" + >+ "Name clash: The method test() of type BB has the same erasure as test() of type AA<T> but does not override it\n" + >+ "----------\n": >+ "----------\n" + >+ "1. ERROR in X.java (at line 9)\n" + >+ " class BB extends AA<CC> { <U> BB test() {return null;} }\n" + >+ " ^^^^^^\n" + >+ "Name clash: The method test() of type BB has the same erasure as test() of type AA<T> 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<CC> { <U> BB test() {return null;} }\n" + >- " ^^^^^^\n" + >- "Name clash: The method test() of type BB has the same erasure as test() of type AA<T> but does not override it\n" + >- "----------\n" >+ ? outputExpectedBelow17 > : "----------\n" + > "1. ERROR in X.java (at line 4)\n" + > " bb.<Object>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<Object> 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<T> 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<CC> { <U> BB test() {return null;} }\n" + >+ " ^^^^^^\n" + >+ "Name clash: The method test() of type BB has the same erasure as test() of type AA<T> but does not override it\n" + >+ "----------\n": >+ "----------\n" + >+ "1. ERROR in X.java (at line 4)\n" + >+ " AA<Object> 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<T> 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<CC> { <U> BB test() {return null;} }\n" + >+ " ^^^^^^\n" + >+ "Name clash: The method test() of type BB has the same erasure as test() of type AA<T> but does not override it\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "X.java", >@@ -22507,27 +22612,7 @@ > "class BB extends AA<CC> { <U> BB test() {return null;} }\n" + > "class CC {}\n", > }, >- "----------\n" + >- "1. ERROR in X.java (at line 4)\n" + >- " AA<Object> 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<T> 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<CC> { <U> BB test() {return null;} }\n" + >- " ^^^^^^\n" + >- "Name clash: The method test() of type BB has the same erasure as test() of type AA<T> but does not override it\n" + >- "----------\n" >+ expectedCompilerLog > ); > /* > X.java:4: reference to test is ambiguous, both method test() in AA and method <U>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<CC> 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<CC> { <U> BB test() {return null;} }\n" + >+ " ^^^^^^\n" + >+ "Name clash: The method test() of type BB has the same erasure as test() of type AA<T> but does not override it\n" + >+ "----------\n": >+ "----------\n" + >+ "1. ERROR in X.java (at line 4)\n" + >+ " AA<CC> 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<CC> { <U> BB test() {return null;} }\n" + >+ " ^^^^^^\n" + >+ "Name clash: The method test() of type BB has the same erasure as test() of type AA<T> but does not override it\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "X.java", >@@ -22565,22 +22683,7 @@ > "class BB extends AA<CC> { <U> BB test() {return null;} }\n" + > "class CC {}\n", > }, >- "----------\n" + >- "1. ERROR in X.java (at line 4)\n" + >- " AA<CC> 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<CC> { <U> BB test() {return null;} }\n" + >- " ^^^^^^\n" + >- "Name clash: The method test() of type BB has the same erasure as test() of type AA<T> but does not override it\n" + >- "----------\n" >+ expectedCompilerLog > ); > /* > X.java:4: reference to test is ambiguous, both method test() in AA and method <U>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<byte[]> cl) { return null; }\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Name clash: The method create(Class<byte[]>) of type X has the same erasure as create(Class<U>) of type Factory<T> but does not override it\n" + >+ "----------\n": >+ "----------\n" + >+ "1. ERROR in X.java (at line 5)\n" + >+ " public byte[] create(Class<byte[]> cl) { return null; }\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Name clash: The method create(Class<byte[]>) of type X has the same erasure as create(Class<U>) of type Factory<T> but does not override it\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "X.java", >@@ -23788,12 +23904,7 @@ > " public byte[] create(Class<byte[]> cl) { return null; }\n" + > "}\n", > }, >- "----------\n" + >- "1. ERROR in X.java (at line 5)\n" + >- " public byte[] create(Class<byte[]> cl) { return null; }\n" + >- " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + >- "Name clash: The method create(Class<byte[]>) of type X has the same erasure as create(Class<U>) of type Factory<T> 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 <S, T extends Comparable<S>, 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 <S, T extends Comparable<S>, R extends S & T> R max(T arg1, S arg2) {\n" + >+ " ^^^^^^^^^^^^^^^^^^^\n" + >+ "Method max(T, S) has the same erasure max(Comparable<T>, 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 <T extends Comparable<S>, S, R extends S & Comparable<S>> R max(T arg1, S arg2) {\n" + >+ " ^^^^^^^^^^\n" + >+ "Cannot specify any additional bound Comparable<S> when first bound is a type parameter\n" + >+ "----------\n" + >+ "5. ERROR in X.java (at line 5)\n" + >+ " public static <T extends Comparable<S>, S, R extends S & Comparable<S>> R max(T arg1, S arg2) {\n" + >+ " ^^^^^^^^^^^^^^^^^^^\n" + >+ "Method max(T, S) has the same erasure max(Comparable<T>, 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 <T extends Comparable<S>, S, R extends Comparable<S>> R max(T arg1, S arg2) {\n" + >+ " ^^^^^^^^^^^^^^^^^^^\n" + >+ "Method max(T, S) has the same erasure max(Comparable<T>, 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 <S, T extends Comparable<S>, 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 <S, T extends Comparable<S>, R extends S & T> R max(T arg1, S arg2) {\n" + >+ " ^^^^^^^^^^^^^^^^^^^\n" + >+ "Method max(T, S) has the same erasure max(Comparable<T>, 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 <T extends Comparable<S>, S, R extends S & Comparable<S>> R max(T arg1, S arg2) {\n" + >+ " ^^^^^^^^^^\n" + >+ "Cannot specify any additional bound Comparable<S> when first bound is a type parameter\n" + >+ "----------\n" + >+ "5. ERROR in X.java (at line 5)\n" + >+ " public static <T extends Comparable<S>, S, R extends S & Comparable<S>> R max(T arg1, S arg2) {\n" + >+ " ^^^^^^^^^^^^^^^^^^^\n" + >+ "Method max(T, S) has the same erasure max(Comparable<T>, 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 <T extends Comparable<S>, S, R extends Comparable<S>> R max(T arg1, S arg2) {\n" + >+ " ^^^^^^^^^^^^^^^^^^^\n" + >+ "Method max(T, S) has the same erasure max(Comparable<T>, 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 <S, T extends Comparable<S>, 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 <S, T extends Comparable<S>, R extends S & T> R max(T arg1, S arg2) {\n" + >- " ^^^^^^^^^^^^^^^^^^^\n" + >- "Method max(T, S) has the same erasure max(Comparable<T>, 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 <T extends Comparable<S>, S, R extends S & Comparable<S>> R max(T arg1, S arg2) {\n" + >- " ^^^^^^^^^^\n" + >- "Cannot specify any additional bound Comparable<S> when first bound is a type parameter\n" + >- "----------\n" + >- "5. ERROR in X.java (at line 5)\n" + >- " public static <T extends Comparable<S>, S, R extends S & Comparable<S>> R max(T arg1, S arg2) {\n" + >- " ^^^^^^^^^^^^^^^^^^^\n" + >- "Method max(T, S) has the same erasure max(Comparable<T>, 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 <T extends Comparable<S>, S, R extends Comparable<S>> R max(T arg1, S arg2) {\n" + >- " ^^^^^^^^^^^^^^^^^^^\n" + >- "Method max(T, S) has the same erasure max(Comparable<T>, 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<String, String> {\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<String,String> a) { return null; }\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Name clash: The method putAll(Map<String,String>) of type X1 has the same erasure as putAll(Map<? extends K,? extends V>) of type HashMap<K,V> but does not override it\n" + >+ "----------\n": >+ "----------\n" + >+ "1. WARNING in X1.java (at line 2)\n" + >+ " public class X1 extends LinkedHashMap<String, String> {\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<String,String> a) { return null; }\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Name clash: The method putAll(Map<String,String>) of type X1 has the same erasure as putAll(Map<? extends K,? extends V>) of type HashMap<K,V> but does not override it\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "X1.java", >@@ -3341,17 +3364,7 @@ > " public Object putAll(Map<String,String> a) { return null; }\n" + > "}\n" > }, >- "----------\n" + >- "1. WARNING in X1.java (at line 2)\n" + >- " public class X1 extends LinkedHashMap<String, String> {\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<String,String> a) { return null; }\n" + >- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >- "Name clash: The method putAll(Map<String,String>) of type X1 has the same erasure as putAll(Map<? extends K,? extends V>) of type HashMap<K,V> but does not override it\n" + >- "----------\n" >+ expectedCompilerLog > ); > /* javac 7 > X.java:4: name clash: putAll(Map<String,String>) in X1 and putAll(Map<? extends K,? extends V>) 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<String> z) { return null; }\n" + >+ " ^^^^^^^^^^^^^^^^\n" + >+ "Name clash: The method foo(I<String>) of type X2 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + >+ "----------\n": >+ "----------\n" + >+ "1. ERROR in X2.java (at line 2)\n" + >+ " public Object foo(I<String> z) { return null; }\n" + >+ " ^^^^^^^^^^^^^^^^\n" + >+ "Name clash: The method foo(I<String>) of type X2 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "X2.java", >@@ -3378,12 +3404,7 @@ > " public void foo(I<? extends T> a);\n" + > "}\n" > }, >- "----------\n" + >- "1. ERROR in X2.java (at line 2)\n" + >- " public Object foo(I<String> z) { return null; }\n" + >- " ^^^^^^^^^^^^^^^^\n" + >- "Name clash: The method foo(I<String>) of type X2 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + >- "----------\n" >+ expectedCompilerLog > ); > /* javac 7 > X.java:2: name clash: foo(I<String>) in X2 and foo(I<? extends T>) 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<String> z) { return null; }\n" + >+ " ^^^^^^^^^^^^^^^^\n" + >+ "Name clash: The method foo(I<String>) of type X4 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + >+ "----------\n": >+ "----------\n" + >+ "1. ERROR in X4.java (at line 2)\n" + >+ " public String foo(I<String> z) { return null; }\n" + >+ " ^^^^^^^^^^^^^^^^\n" + >+ "Name clash: The method foo(I<String>) of type X4 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "X4.java", >@@ -3440,12 +3474,7 @@ > " public Object foo(I<? extends T> a);\n" + > "}\n" > }, >- "----------\n" + >- "1. ERROR in X4.java (at line 2)\n" + >- " public String foo(I<String> z) { return null; }\n" + >- " ^^^^^^^^^^^^^^^^\n" + >- "Name clash: The method foo(I<String>) of type X4 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + >- "----------\n" >+ expectedCompilerLog > ); > /* javac 7 > X.java:2: name clash: foo(I<String>) in X4 and foo(I<? extends T>) 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<String> z) { return null; }\n" + >+ " ^^^^^^^^^^^^^^^^\n" + >+ "Name clash: The method foo(I<String>) of type X5 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + >+ "----------\n": >+ "----------\n" + >+ "1. ERROR in X5.java (at line 2)\n" + >+ " public Object foo(I<String> z) { return null; }\n" + >+ " ^^^^^^^^^^^^^^^^\n" + >+ "Name clash: The method foo(I<String>) of type X5 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "X5.java", >@@ -3471,12 +3513,7 @@ > " public String foo(I<? extends T> a);\n" + > "}\n" > }, >- "----------\n" + >- "1. ERROR in X5.java (at line 2)\n" + >- " public Object foo(I<String> z) { return null; }\n" + >- " ^^^^^^^^^^^^^^^^\n" + >- "Name clash: The method foo(I<String>) of type X5 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + >- "----------\n" >+ expectedCompilerLog > ); > /* javac 7 > X.java:2: name clash: foo(I<String>) in X5 and foo(I<? extends T>) 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<String> z) {}\n" + >+ " ^^^^^^^^^^^^^^^^\n" + >+ "Name clash: The method foo(I<String>) of type X6 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + >+ "----------\n": >+ "----------\n" + >+ "1. ERROR in X6.java (at line 2)\n" + >+ " public void foo(I<String> z) {}\n" + >+ " ^^^^^^^^^^^^^^^^\n" + >+ "Name clash: The method foo(I<String>) of type X6 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "X6.java", >@@ -3503,12 +3553,7 @@ > " public Object foo(I<? extends T> a);\n" + > "}\n" > }, >- "----------\n" + >- "1. ERROR in X6.java (at line 2)\n" + >- " public void foo(I<String> z) {}\n" + >- " ^^^^^^^^^^^^^^^^\n" + >- "Name clash: The method foo(I<String>) of type X6 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + >- "----------\n" >+ expectedCompilerLog > ); > /* javac 7 > X.java:2: name clash: foo(I<String>) in X6 and foo(I<? extends T>) 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<String> z) { return null; }\n" + >+ " ^^^^^^^^^^^^^^^^\n" + >+ "Name clash: The method foo(I<String>) of type X7 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + >+ "----------\n": >+ "----------\n" + >+ "1. ERROR in X7.java (at line 2)\n" + >+ " public String foo(I<String> z) { return null; }\n" + >+ " ^^^^^^^^^^^^^^^^\n" + >+ "Name clash: The method foo(I<String>) of type X7 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "X7.java", >@@ -3534,12 +3592,7 @@ > " public T foo(I<? extends T> a);\n" + > "}\n" > }, >- "----------\n" + >- "1. ERROR in X7.java (at line 2)\n" + >- " public String foo(I<String> z) { return null; }\n" + >- " ^^^^^^^^^^^^^^^^\n" + >- "Name clash: The method foo(I<String>) of type X7 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + >- "----------\n" >+ expectedCompilerLog > ); > /* javac 7 > X.java:2: name clash: foo(I<String>) in X7 and foo(I<? extends T>) 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 extends A> 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 extends B> 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().<B>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 extends A> 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 extends B> 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.<B>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 <S extends A>\n" + >+ "----------\n" + >+ "4. ERROR in X.java (at line 7)\n" + >+ " new X().<B>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 <S extends A>\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 extends A> 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 extends B> 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.<B>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 <S extends A>\n" + >- "----------\n" + >- "4. ERROR in X.java (at line 7)\n" + >- " new X().<B>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 <S extends A>\n" + >- "----------\n" >+ expectedCompilerLog > ); > /* javac 7 > X.java:3: name clash: <N>foo() and <S>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 <S extends A> 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 extends B> 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 <S extends A> 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 extends B> 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 <S extends A> 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 extends B> 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: <N>foo() and <S>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 extends Y> 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 extends Z> 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<Y> 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<Z> 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 extends Z> 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 extends Y> 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 extends Z> 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<Y> 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<Z> 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 extends Z> 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 extends Y> 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 extends Z> 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<Y> 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<Z> 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 extends Z> 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<Y> foo(A<Y> o) { return null; } // duplicate\n" + >+ " ^^^^^^^^^^^\n" + >+ "Method foo(A<Y>) has the same erasure foo(A<T>) as another method in type X.C5\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 4)\n" + >+ " A<Z> foo(A<Z> o) { return null; } // duplicate\n" + >+ " ^^^^^^^^^^^\n" + >+ "Method foo(A<Z>) has the same erasure foo(A<T>) as another method in type X.C5\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 7)\n" + >+ " <T extends Y> T foo(A<Y> o) { return null; } // ok\n" + >+ " ^^^^^^^^^^^\n" + >+ "Method foo(A<Y>) has the same erasure foo(A<T>) as another method in type X.C6\n" + >+ "----------\n" + >+ "4. WARNING in X.java (at line 8)\n" + >+ " <T extends Z> T foo(A<Z> o) { return null; } // ok\n" + >+ " ^^^^^^^^^^^\n" + >+ "Method foo(A<Z>) has the same erasure foo(A<T>) as another method in type X.C6\n" + >+ "----------\n": >+ "----------\n" + >+ "1. ERROR in X.java (at line 3)\n" + >+ " A<Y> foo(A<Y> o) { return null; } // duplicate\n" + >+ " ^^^^^^^^^^^\n" + >+ "Method foo(A<Y>) has the same erasure foo(A<T>) as another method in type X.C5\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 4)\n" + >+ " A<Z> foo(A<Z> o) { return null; } // duplicate\n" + >+ " ^^^^^^^^^^^\n" + >+ "Method foo(A<Z>) has the same erasure foo(A<T>) as another method in type X.C5\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 7)\n" + >+ " <T extends Y> T foo(A<Y> o) { return null; } // ok\n" + >+ " ^^^^^^^^^^^\n" + >+ "Method foo(A<Y>) has the same erasure foo(A<T>) as another method in type X.C6\n" + >+ "----------\n" + >+ "4. ERROR in X.java (at line 8)\n" + >+ " <T extends Z> T foo(A<Z> o) { return null; } // ok\n" + >+ " ^^^^^^^^^^^\n" + >+ "Method foo(A<Z>) has the same erasure foo(A<T>) 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<Y> foo(A<Y> o) { return null; } // duplicate\n" + >- " ^^^^^^^^^^^\n" + >- "Method foo(A<Y>) has the same erasure foo(A<T>) as another method in type X.C5\n" + >- "----------\n" + >- "2. ERROR in X.java (at line 4)\n" + >- " A<Z> foo(A<Z> o) { return null; } // duplicate\n" + >- " ^^^^^^^^^^^\n" + >- "Method foo(A<Z>) has the same erasure foo(A<T>) as another method in type X.C5\n" + >- "----------\n" + >- "3. ERROR in X.java (at line 7)\n" + >- " <T extends Y> T foo(A<Y> o) { return null; } // ok\n" + >- " ^^^^^^^^^^^\n" + >- "Method foo(A<Y>) has the same erasure foo(A<T>) as another method in type X.C6\n" + >- "----------\n" + >- "4. ERROR in X.java (at line 8)\n" + >- " <T extends Z> T foo(A<Z> o) { return null; } // ok\n" + >- " ^^^^^^^^^^^\n" + >- "Method foo(A<Z>) has the same erasure foo(A<T>) as another method in type X.C6\n" + >- "----------\n" >+ expectedCompilerLog > ); > /* javac 7 > X.java:4: name clash: foo(A<Z>) and foo(A<Y>) 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 extends Y, U> 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 extends Z> 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 extends Y, U> 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 extends Z> 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 extends Y, U> 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 extends Z> 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: <T#1>foo(Object) and <T#2,U>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 extends B> N a(A<String> s) { return null; }\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Method a(A<String>) has the same erasure a(A<T>) as another method in type X\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 3)\n" + >+ " <N> Object a(A<Number> n) { return null; }\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Method a(A<Number>) has the same erasure a(A<T>) as another method in type X\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 4)\n" + >+ " <N extends B> void b(A<String> s) {}\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Method b(A<String>) has the same erasure b(A<T>) as another method in type X\n" + >+ "----------\n" + >+ "4. WARNING in X.java (at line 5)\n" + >+ " <N extends B> B b(A<Number> n) { return null; }\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Method b(A<Number>) has the same erasure b(A<T>) as another method in type X\n" + >+ "----------\n" + >+ "5. WARNING in X.java (at line 6)\n" + >+ " void c(A<String> s) {}\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Method c(A<String>) has the same erasure c(A<T>) as another method in type X\n" + >+ "----------\n" + >+ "6. WARNING in X.java (at line 7)\n" + >+ " B c(A<Number> n) { return null; }\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Method c(A<Number>) has the same erasure c(A<T>) as another method in type X\n" + >+ "----------\n": >+ "----------\n" + >+ "1. ERROR in X.java (at line 2)\n" + >+ " <N extends B> N a(A<String> s) { return null; }\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Method a(A<String>) has the same erasure a(A<T>) as another method in type X\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 3)\n" + >+ " <N> Object a(A<Number> n) { return null; }\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Method a(A<Number>) has the same erasure a(A<T>) as another method in type X\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 4)\n" + >+ " <N extends B> void b(A<String> s) {}\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Method b(A<String>) has the same erasure b(A<T>) as another method in type X\n" + >+ "----------\n" + >+ "4. ERROR in X.java (at line 5)\n" + >+ " <N extends B> B b(A<Number> n) { return null; }\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Method b(A<Number>) has the same erasure b(A<T>) as another method in type X\n" + >+ "----------\n" + >+ "5. ERROR in X.java (at line 6)\n" + >+ " void c(A<String> s) {}\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Method c(A<String>) has the same erasure c(A<T>) as another method in type X\n" + >+ "----------\n" + >+ "6. ERROR in X.java (at line 7)\n" + >+ " B c(A<Number> n) { return null; }\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Method c(A<Number>) has the same erasure c(A<T>) as another method in type X\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "X.java", >@@ -3935,37 +4171,7 @@ > "class A<T> {}\n" + > "class B {}\n" > }, >- "----------\n" + >- "1. ERROR in X.java (at line 2)\n" + >- " <N extends B> N a(A<String> s) { return null; }\n" + >- " ^^^^^^^^^^^^^^\n" + >- "Method a(A<String>) has the same erasure a(A<T>) as another method in type X\n" + >- "----------\n" + >- "2. ERROR in X.java (at line 3)\n" + >- " <N> Object a(A<Number> n) { return null; }\n" + >- " ^^^^^^^^^^^^^^\n" + >- "Method a(A<Number>) has the same erasure a(A<T>) as another method in type X\n" + >- "----------\n" + >- "3. ERROR in X.java (at line 4)\n" + >- " <N extends B> void b(A<String> s) {}\n" + >- " ^^^^^^^^^^^^^^\n" + >- "Method b(A<String>) has the same erasure b(A<T>) as another method in type X\n" + >- "----------\n" + >- "4. ERROR in X.java (at line 5)\n" + >- " <N extends B> B b(A<Number> n) { return null; }\n" + >- " ^^^^^^^^^^^^^^\n" + >- "Method b(A<Number>) has the same erasure b(A<T>) as another method in type X\n" + >- "----------\n" + >- "5. ERROR in X.java (at line 6)\n" + >- " void c(A<String> s) {}\n" + >- " ^^^^^^^^^^^^^^\n" + >- "Method c(A<String>) has the same erasure c(A<T>) as another method in type X\n" + >- "----------\n" + >- "6. ERROR in X.java (at line 7)\n" + >- " B c(A<Number> n) { return null; }\n" + >- " ^^^^^^^^^^^^^^\n" + >- "Method c(A<Number>) has the same erasure c(A<T>) as another method in type X\n" + >- "----------\n" >+ expectedCompilerLog > ); > /* javac 7 > X.java:3: name clash: <N#1>a(A<Number>) and <N#2>a(A<String>) 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 extends B> N a(A<Number> s) { return null; }\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Duplicate method a(A<Number>) in type X\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 3)\n" + >+ " <N> Object a(A<Number> n) { return null; }\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Duplicate method a(A<Number>) in type X\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 4)\n" + >+ " <N extends B> N b(A<Number> s) { return null; }\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Method b(A<Number>) has the same erasure b(A<T>) as another method in type X\n" + >+ "----------\n" + >+ "4. WARNING in X.java (at line 5)\n" + >+ " <N> Object b(A<String> n) { return null; }\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Method b(A<String>) has the same erasure b(A<T>) as another method in type X\n" + >+ "----------\n": >+ "----------\n" + >+ "1. ERROR in X.java (at line 2)\n" + >+ " <N extends B> N a(A<Number> s) { return null; }\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Duplicate method a(A<Number>) in type X\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 3)\n" + >+ " <N> Object a(A<Number> n) { return null; }\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Duplicate method a(A<Number>) in type X\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 4)\n" + >+ " <N extends B> N b(A<Number> s) { return null; }\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Method b(A<Number>) has the same erasure b(A<T>) as another method in type X\n" + >+ "----------\n" + >+ "4. ERROR in X.java (at line 5)\n" + >+ " <N> Object b(A<String> n) { return null; }\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Method b(A<String>) has the same erasure b(A<T>) as another method in type X\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "X.java", >@@ -4100,27 +4349,7 @@ > "class A<T> {}\n" + > "class B {}\n" > }, >- "----------\n" + >- "1. ERROR in X.java (at line 2)\n" + >- " <N extends B> N a(A<Number> s) { return null; }\n" + >- " ^^^^^^^^^^^^^^\n" + >- "Duplicate method a(A<Number>) in type X\n" + >- "----------\n" + >- "2. ERROR in X.java (at line 3)\n" + >- " <N> Object a(A<Number> n) { return null; }\n" + >- " ^^^^^^^^^^^^^^\n" + >- "Duplicate method a(A<Number>) in type X\n" + >- "----------\n" + >- "3. ERROR in X.java (at line 4)\n" + >- " <N extends B> N b(A<Number> s) { return null; }\n" + >- " ^^^^^^^^^^^^^^\n" + >- "Method b(A<Number>) has the same erasure b(A<T>) as another method in type X\n" + >- "----------\n" + >- "4. ERROR in X.java (at line 5)\n" + >- " <N> Object b(A<String> n) { return null; }\n" + >- " ^^^^^^^^^^^^^^\n" + >- "Method b(A<String>) has the same erasure b(A<T>) as another method in type X\n" + >- "----------\n" >+ expectedCompilerLog > ); > /* javac 7 > X.java:3: name clash: <N#1>a(A<Number>) and <N#2>a(A<Number>) have the same erasure >@@ -4254,26 +4483,31 @@ > "class A<T> {}\n" + > "class B {}\n" > }, >- "----------\n" + >- "1. ERROR in X.java (at line 2)\n" + >- " void a(A<Number> s) {}\n" + >- " ^^^^^^^^^^^^^^\n" + >- "Duplicate method a(A<Number>) in type X\n" + >- "----------\n" + >- "2. ERROR in X.java (at line 3)\n" + >- " B a(A<Number> n) { return null; }\n" + >- " ^^^^^^^^^^^^^^\n" + >- "Duplicate method a(A<Number>) in type X\n" + >- "----------\n" + >- "3. ERROR in X.java (at line 4)\n" + >- " Object b(A<Number> s) {}\n" + >- " ^^^^^^^^^^^^^^\n" + >- "Duplicate method b(A<Number>) in type X\n" + >- "----------\n" + >- "4. ERROR in X.java (at line 5)\n" + >- " B b(A<Number> n) { return null; }\n" + >- " ^^^^^^^^^^^^^^\n" + >- "Duplicate method b(A<Number>) in type X\n" + >+ "----------\n" + >+ "1. ERROR in X.java (at line 2)\n" + >+ " void a(A<Number> s) {}\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Duplicate method a(A<Number>) in type X\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 3)\n" + >+ " B a(A<Number> n) { return null; }\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Duplicate method a(A<Number>) in type X\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 4)\n" + >+ " Object b(A<Number> s) {}\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Duplicate method b(A<Number>) in type X\n" + >+ "----------\n" + >+ "4. ERROR in X.java (at line 4)\n" + >+ " Object b(A<Number> 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<Number> n) { return null; }\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Duplicate method b(A<Number>) 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<String> a) {}\n" + >+ " ^^^^^^^^^^^^^^^^\n" + >+ "Method foo(A<String>) has the same erasure foo(A<T>) as another method in type X\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 3)\n" + >+ " Object foo(A<Integer> a) { return null; }\n" + >+ " ^^^^^^^^^^^^^^^^^\n" + >+ "Method foo(A<Integer>) has the same erasure foo(A<T>) as another method in type X\n" + >+ "----------\n": >+ "----------\n" + >+ "1. ERROR in X.java (at line 2)\n" + >+ " void foo(A<String> a) {}\n" + >+ " ^^^^^^^^^^^^^^^^\n" + >+ "Method foo(A<String>) has the same erasure foo(A<T>) as another method in type X\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 3)\n" + >+ " Object foo(A<Integer> a) { return null; }\n" + >+ " ^^^^^^^^^^^^^^^^^\n" + >+ "Method foo(A<Integer>) has the same erasure foo(A<T>) as another method in type X\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "X.java", >@@ -4356,17 +4613,7 @@ > "}\n" + > "class A<T> {}\n", > }, >- "----------\n" + >- "1. ERROR in X.java (at line 2)\n" + >- " void foo(A<String> a) {}\n" + >- " ^^^^^^^^^^^^^^^^\n" + >- "Method foo(A<String>) has the same erasure foo(A<T>) as another method in type X\n" + >- "----------\n" + >- "2. ERROR in X.java (at line 3)\n" + >- " Object foo(A<Integer> a) { return null; }\n" + >- " ^^^^^^^^^^^^^^^^^\n" + >- "Method foo(A<Integer>) has the same erasure foo(A<T>) as another method in type X\n" + >- "----------\n" >+ expectedCompilerLog > ); > /* javac 7 > X.java:3: name clash: foo(A<Integer>) and foo(A<String>) 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> 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> 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> 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> 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" + >+ " <T1, T2> 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 extends X> 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" + >+ " <T> 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 extends X> 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 extends X> 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" + >+ " <T> 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" + >+ " <T, S> 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" + >+ " <T1, T2> 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 extends X> 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" + >+ " <T> 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 extends X> 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 extends X> 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" + >+ " <T> 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" + >+ " <T, S> 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 @@ > " <T, S> Object z(X x) { return null; }\n" + > "}\n" > }, >- "----------\n" + >- "1. ERROR in X.java (at line 2)\n" + >- " <T1, T2> 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 extends X> 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" + >- " <T> 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 extends X> 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 extends X> 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" + >- " <T> 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" + >- " <T, S> 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: <T>aaa(T) and <T1,T2>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> t) { return null; }\n" + >+ " ^^^^^^^^^^^\n" + >+ "Duplicate method foo(X<T>) in type X<T>\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 3)\n" + >+ " <S> String foo(X<T> s) { return null; }\n" + >+ " ^^^^^^^^^^^\n" + >+ "Duplicate method foo(X<T>) in type X<T>\n" + >+ "----------\n": >+ "----------\n" + >+ "1. ERROR in X.java (at line 2)\n" + >+ " Object foo(X<T> t) { return null; }\n" + >+ " ^^^^^^^^^^^\n" + >+ "Duplicate method foo(X<T>) in type X<T>\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 3)\n" + >+ " <S> String foo(X<T> s) { return null; }\n" + >+ " ^^^^^^^^^^^\n" + >+ "Duplicate method foo(X<T>) in type X<T>\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "X.java", >@@ -4611,17 +4937,7 @@ > " <S> String foo(X<T> s) { return null; }\n" + > "}\n" > }, >- "----------\n" + >- "1. ERROR in X.java (at line 2)\n" + >- " Object foo(X<T> t) { return null; }\n" + >- " ^^^^^^^^^^^\n" + >- "Duplicate method foo(X<T>) in type X<T>\n" + >- "----------\n" + >- "2. ERROR in X.java (at line 3)\n" + >- " <S> String foo(X<T> s) { return null; }\n" + >- " ^^^^^^^^^^^\n" + >- "Duplicate method foo(X<T>) in type X<T>\n" + >- "----------\n" >+ expectedCompilerLog > ); > /* javac 7 > X.java:3: name clash: <S>foo(X<T>) and foo(X<T>) 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> T a(A<T> t) {return null;}\n" + >+ " ^^^^^^^^^\n" + >+ "Method a(A<T>) has the same erasure a(A<T>) as another method in type X\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 3)\n" + >+ " <T> String a(A<Object> o) {return null;}\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Method a(A<Object>) has the same erasure a(A<T>) as another method in type X\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 4)\n" + >+ " <T> T aa(A<T> t) {return null;}\n" + >+ " ^^^^^^^^^^\n" + >+ "Method aa(A<T>) has the same erasure aa(A<T>) as another method in type X\n" + >+ "----------\n" + >+ "4. WARNING in X.java (at line 5)\n" + >+ " String aa(A<Object> o) {return null;}\n" + >+ " ^^^^^^^^^^^^^^^\n" + >+ "Method aa(A<Object>) has the same erasure aa(A<T>) as another method in type X\n" + >+ "----------\n": >+ "----------\n" + >+ "1. ERROR in X.java (at line 2)\n" + >+ " <T> T a(A<T> t) {return null;}\n" + >+ " ^^^^^^^^^\n" + >+ "Method a(A<T>) has the same erasure a(A<T>) as another method in type X\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 3)\n" + >+ " <T> String a(A<Object> o) {return null;}\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Method a(A<Object>) has the same erasure a(A<T>) as another method in type X\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 4)\n" + >+ " <T> T aa(A<T> t) {return null;}\n" + >+ " ^^^^^^^^^^\n" + >+ "Method aa(A<T>) has the same erasure aa(A<T>) as another method in type X\n" + >+ "----------\n" + >+ "4. ERROR in X.java (at line 5)\n" + >+ " String aa(A<Object> o) {return null;}\n" + >+ " ^^^^^^^^^^^^^^^\n" + >+ "Method aa(A<Object>) has the same erasure aa(A<T>) as another method in type X\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "X.java", >@@ -4677,27 +5036,7 @@ > "}\n" + > "class A<T> {}\n", > }, >- "----------\n" + >- "1. ERROR in X.java (at line 2)\n" + >- " <T> T a(A<T> t) {return null;}\n" + >- " ^^^^^^^^^\n" + >- "Method a(A<T>) has the same erasure a(A<T>) as another method in type X\n" + >- "----------\n" + >- "2. ERROR in X.java (at line 3)\n" + >- " <T> String a(A<Object> o) {return null;}\n" + >- " ^^^^^^^^^^^^^^\n" + >- "Method a(A<Object>) has the same erasure a(A<T>) as another method in type X\n" + >- "----------\n" + >- "3. ERROR in X.java (at line 4)\n" + >- " <T> T aa(A<T> t) {return null;}\n" + >- " ^^^^^^^^^^\n" + >- "Method aa(A<T>) has the same erasure aa(A<T>) as another method in type X\n" + >- "----------\n" + >- "4. ERROR in X.java (at line 5)\n" + >- " String aa(A<Object> o) {return null;}\n" + >- " ^^^^^^^^^^^^^^^\n" + >- "Method aa(A<Object>) has the same erasure aa(A<T>) as another method in type X\n" + >- "----------\n" >+ expectedCompilerLog > ); > /* javac 7 > X.java:3: name clash: <T#1>a(A<Object>) and <T#2>a(A<T#2>) 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<Object>().foo(\"X\");\n" + >+ " ^^^\n" + >+ "The method foo(String) is ambiguous for the type X<Object>\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 4)\n" + >+ " new X<Object>().foo2(\"X\");\n" + >+ " ^^^^\n" + >+ "The method foo2(String) is ambiguous for the type X<Object>\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 6)\n" + >+ " <T> T foo(T t) {return null;}\n" + >+ " ^^^^^^^^\n" + >+ "Method foo(T) has the same erasure foo(Object) as another method in type X<A>\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<A>\n" + >+ "----------\n" + >+ "5. WARNING in X.java (at line 8)\n" + >+ " <T> T foo2(T t) {return null;}\n" + >+ " ^^^^^^^^^\n" + >+ "Method foo2(T) has the same erasure foo2(Object) as another method in type X<A>\n" + >+ "----------\n" + >+ "6. WARNING in X.java (at line 9)\n" + >+ " <T> void foo2(A a) {}\n" + >+ " ^^^^^^^^^\n" + >+ "Method foo2(A) has the same erasure foo2(Object) as another method in type X<A>\n" + >+ "----------\n": >+ "----------\n" + >+ "1. ERROR in X.java (at line 6)\n" + >+ " <T> T foo(T t) {return null;}\n" + >+ " ^^^^^^^^\n" + >+ "Method foo(T) has the same erasure foo(Object) as another method in type X<A>\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<A>\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 8)\n" + >+ " <T> T foo2(T t) {return null;}\n" + >+ " ^^^^^^^^^\n" + >+ "Method foo2(T) has the same erasure foo2(Object) as another method in type X<A>\n" + >+ "----------\n" + >+ "4. ERROR in X.java (at line 9)\n" + >+ " <T> void foo2(A a) {}\n" + >+ " ^^^^^^^^^\n" + >+ "Method foo2(A) has the same erasure foo2(Object) as another method in type X<A>\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "X.java", >@@ -4835,27 +5227,7 @@ > " <T> void foo2(A a) {}\n" + > "}\n" > }, >- "----------\n" + >- "1. ERROR in X.java (at line 6)\n" + >- " <T> T foo(T t) {return null;}\n" + >- " ^^^^^^^^\n" + >- "Method foo(T) has the same erasure foo(Object) as another method in type X<A>\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<A>\n" + >- "----------\n" + >- "3. ERROR in X.java (at line 8)\n" + >- " <T> T foo2(T t) {return null;}\n" + >- " ^^^^^^^^^\n" + >- "Method foo2(T) has the same erasure foo2(Object) as another method in type X<A>\n" + >- "----------\n" + >- "4. ERROR in X.java (at line 9)\n" + >- " <T> void foo2(A a) {}\n" + >- " ^^^^^^^^^\n" + >- "Method foo2(A) has the same erasure foo2(Object) as another method in type X<A>\n" + >- "----------\n" >+ expectedCompilerLog > ); > /* javac 7 > X.java:7: name clash: foo(A) and <T>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<Object>().foo(\"X\");\n" + >+ " ^^^\n" + >+ "The method foo(String) is ambiguous for the type X<Object>\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 4)\n" + >+ " new X<Object>().foo2(\"X\");\n" + >+ " ^^^^\n" + >+ "The method foo2(String) is ambiguous for the type X<Object>\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 6)\n" + >+ " <T> T foo(T t) {return null;}\n" + >+ " ^^^^^^^^\n" + >+ "Name clash: The method foo(T) of type X<A> has the same erasure as foo(A) of type Y<A> but does not override it\n" + >+ "----------\n" + >+ "4. WARNING in X.java (at line 7)\n" + >+ " <T> T foo2(T t) {return null;}\n" + >+ " ^^^^^^^^^\n" + >+ "Name clash: The method foo2(T) of type X<A> has the same erasure as foo2(A) of type Y<A> but does not override it\n" + >+ "----------\n": >+ "----------\n" + >+ "1. ERROR in X.java (at line 3)\n" + >+ " new X<Object>().foo(\"X\");\n" + >+ " ^^^\n" + >+ "The method foo(String) is ambiguous for the type X<Object>\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 4)\n" + >+ " new X<Object>().foo2(\"X\");\n" + >+ " ^^^^\n" + >+ "The method foo2(String) is ambiguous for the type X<Object>\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 6)\n" + >+ " <T> T foo(T t) {return null;}\n" + >+ " ^^^^^^^^\n" + >+ "Name clash: The method foo(T) of type X<A> has the same erasure as foo(A) of type Y<A> but does not override it\n" + >+ "----------\n" + >+ "4. ERROR in X.java (at line 7)\n" + >+ " <T> T foo2(T t) {return null;}\n" + >+ " ^^^^^^^^^\n" + >+ "Name clash: The method foo2(T) of type X<A> has the same erasure as foo2(A) of type Y<A> but does not override it\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "X.java", >@@ -4892,27 +5307,7 @@ > " <T> void foo2(A a) {}\n" + > "}" > }, >- "----------\n" + >- "1. ERROR in X.java (at line 3)\n" + >- " new X<Object>().foo(\"X\");\n" + >- " ^^^\n" + >- "The method foo(String) is ambiguous for the type X<Object>\n" + >- "----------\n" + >- "2. ERROR in X.java (at line 4)\n" + >- " new X<Object>().foo2(\"X\");\n" + >- " ^^^^\n" + >- "The method foo2(String) is ambiguous for the type X<Object>\n" + >- "----------\n" + >- "3. ERROR in X.java (at line 6)\n" + >- " <T> T foo(T t) {return null;}\n" + >- " ^^^^^^^^\n" + >- "Name clash: The method foo(T) of type X<A> has the same erasure as foo(A) of type Y<A> but does not override it\n" + >- "----------\n" + >- "4. ERROR in X.java (at line 7)\n" + >- " <T> T foo2(T t) {return null;}\n" + >- " ^^^^^^^^^\n" + >- "Name clash: The method foo2(T) of type X<A> has the same erasure as foo2(A) of type Y<A> 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 <T>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<V,E>\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<V,E>\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<V,E>\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<V,E>\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "Bar.java", >@@ -7980,17 +8398,7 @@ > "}\n" + > "public class Bar<V,E> extends Foo<V,E> {}" > }, >- "----------\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<V,E>\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<V,E>\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<K,V> 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<E> 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<K,V> 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<E> 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<K,V> 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<E> 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<Integer> l) {return 0;}\n" + >+ " ^^^^^^^^^^^^^^^^^^\n" + >+ "Name clash: The method f(List<Integer>) of type Y has the same erasure as f(List<String>) of type X but does not override it\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 13)\n" + >+ " int f(List<String> l) {return 0;}\n" + >+ " ^^^^^^^^^^^^^^^^^\n" + >+ "Method f(List<String>) has the same erasure f(List<E>) as another method in type XX\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 14)\n" + >+ " double f(List<Integer> l) {return 0;}\n" + >+ " ^^^^^^^^^^^^^^^^^^\n" + >+ "Method f(List<Integer>) has the same erasure f(List<E>) as another method in type XX\n" + >+ "----------\n": >+ "----------\n" + >+ "1. ERROR in X.java (at line 6)\n" + >+ " double f(List<Integer> l) {return 0;}\n" + >+ " ^^^^^^^^^^^^^^^^^^\n" + >+ "Name clash: The method f(List<Integer>) of type Y has the same erasure as f(List<String>) of type X but does not override it\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 13)\n" + >+ " int f(List<String> l) {return 0;}\n" + >+ " ^^^^^^^^^^^^^^^^^\n" + >+ "Method f(List<String>) has the same erasure f(List<E>) as another method in type XX\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 14)\n" + >+ " double f(List<Integer> l) {return 0;}\n" + >+ " ^^^^^^^^^^^^^^^^^^\n" + >+ "Method f(List<Integer>) has the same erasure f(List<E>) as another method in type XX\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "X.java", >@@ -10265,22 +10734,7 @@ > "double f(List<Integer> l) {return 0;}\n" +// name clash in 1.5 & 7 > "}" > }, >- "----------\n" + >- "1. ERROR in X.java (at line 6)\n" + >- " double f(List<Integer> l) {return 0;}\n" + >- " ^^^^^^^^^^^^^^^^^^\n" + >- "Name clash: The method f(List<Integer>) of type Y has the same erasure as f(List<String>) of type X but does not override it\n" + >- "----------\n" + >- "2. ERROR in X.java (at line 13)\n" + >- " int f(List<String> l) {return 0;}\n" + >- " ^^^^^^^^^^^^^^^^^\n" + >- "Method f(List<String>) has the same erasure f(List<E>) as another method in type XX\n" + >- "----------\n" + >- "3. ERROR in X.java (at line 14)\n" + >- " double f(List<Integer> l) {return 0;}\n" + >- " ^^^^^^^^^^^^^^^^^^\n" + >- "Method f(List<Integer>) has the same erasure f(List<E>) 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<E>) 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<E> should be parameterized\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 4)\n" + >+ " double foo(Collection<String> bar) {return 0; }\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Method foo(Collection<String>) has the same erasure foo(Collection<E>) 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<E>) 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<E> should be parameterized\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 4)\n" + >+ " double foo(Collection<String> bar) {return 0; }\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Method foo(Collection<String>) has the same erasure foo(Collection<E>) as another method in type X\n" + >+ "----------\n"; > this.runNegativeTest( > new String[] { > "X.java", >@@ -10711,22 +11200,7 @@ > " double foo(Collection<String> 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<E>) 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<E> should be parameterized\n" + >- "----------\n" + >- "3. ERROR in X.java (at line 4)\n" + >- " double foo(Collection<String> bar) {return 0; }\n" + >- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >- "Method foo(Collection<String>) has the same erasure foo(Collection<E>) as another method in type X\n" + >- "----------\n" >+ errorMessage > ); > /* javac 7 > X.java:4: foo(Collection) is already defined in X
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 317719
:
200641
|
200761
|
200840
|
201125
|
201129