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 197485 Details for
Bug 345949
[compiler] Inconsistent name clash behavior vis-a-vis javac7
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
patch1.txt (text/plain), 18.93 KB, created by
Satyam Kandula
on 2011-06-07 05:05:46 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Satyam Kandula
Created:
2011-06-07 05:05:46 EDT
Size:
18.93 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/core/compiler/IProblem.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java,v >retrieving revision 1.225.2.18 >diff -u -r1.225.2.18 IProblem.java >--- compiler/org/eclipse/jdt/core/compiler/IProblem.java 18 May 2011 11:14:52 -0000 1.225.2.18 >+++ compiler/org/eclipse/jdt/core/compiler/IProblem.java 7 Jun 2011 09:04:45 -0000 >@@ -1155,6 +1155,8 @@ > > /** @since 3.7 */ > int DuplicateInheritedMethods = MethodRelated + 583; >+ /** @since 3.7 */ >+ int MethodNameClashHidden = MethodRelated + 584; > > /** > * 1.5 Syntax errors (when source level < 1.5) >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.123.2.4 >diff -u -r1.123.2.4 MethodVerifier15.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 23 May 2011 09:17:55 -0000 1.123.2.4 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 7 Jun 2011 09:04:46 -0000 >@@ -235,7 +235,13 @@ > // class A implements I<Integer> { public void test(Integer i) {} } > // class B extends A { public void test(Comparable i) {} } > >- if (inheritedMethod.isStatic()) return; >+ if (inheritedMethod.isStatic() || currentMethod.isStatic()) { >+ MethodBinding original = inheritedMethod.original(); // can be the same as inherited >+ if (this.type.scope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_7 && currentMethod.areParameterErasuresEqual(original)) { >+ problemReporter(currentMethod).methodNameClashHidden(currentMethod, inheritedMethod.declaringClass.isRawType() ? inheritedMethod : original); >+ } >+ return; // no chance of bridge method's clashing >+ } > > if (!detectNameClash(currentMethod, inheritedMethod, false)) { // check up the hierarchy for skipped inherited methods > TypeBinding[] currentParams = currentMethod.parameters; >Index: compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java,v >retrieving revision 1.430.2.25 >diff -u -r1.430.2.25 ProblemReporter.java >--- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 18 May 2011 11:14:51 -0000 1.430.2.25 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 7 Jun 2011 09:04:49 -0000 >@@ -5081,6 +5081,27 @@ > currentMethod.sourceEnd()); > } > >+public void methodNameClashHidden(MethodBinding currentMethod, MethodBinding inheritedMethod) { >+ this.handle( >+ IProblem.MethodNameClashHidden, >+ new String[] { >+ new String(currentMethod.selector), >+ typesAsString(currentMethod.isVarargs(), currentMethod.parameters, false), >+ new String(currentMethod.declaringClass.readableName()), >+ typesAsString(inheritedMethod.isVarargs(), inheritedMethod.parameters, false), >+ new String(inheritedMethod.declaringClass.readableName()), >+ }, >+ new String[] { >+ new String(currentMethod.selector), >+ typesAsString(currentMethod.isVarargs(), currentMethod.parameters, true), >+ new String(currentMethod.declaringClass.shortReadableName()), >+ typesAsString(inheritedMethod.isVarargs(), inheritedMethod.parameters, true), >+ new String(inheritedMethod.declaringClass.shortReadableName()), >+ }, >+ currentMethod.sourceStart(), >+ currentMethod.sourceEnd()); >+} >+ > public void methodNeedBody(AbstractMethodDeclaration methodDecl) { > this.handle( > IProblem.MethodRequiresBody, >Index: compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties,v >retrieving revision 1.262.2.21 >diff -u -r1.262.2.21 messages.properties >--- compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 18 May 2011 11:14:51 -0000 1.262.2.21 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 7 Jun 2011 09:04:49 -0000 >@@ -521,6 +521,7 @@ > 578 = Wildcard is not allowed at this location > 579 = Unused type arguments for the non generic method {0}({1}) of type {2}; it should not be parameterized with arguments <{3}> > 583 = Duplicate methods named {0} with the parameters ({1}) and ({2}) are inherited from the types {3} and {4} >+584 = Name clash: The method {0}({1}) of type {2} has the same erasure as {0}({3}) of type {4} but does not hide it > > ### FOREACH > 580 = Type mismatch: cannot convert from element type {0} to {1} >#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.4.2 >diff -u -r1.75.4.2 AmbiguousMethodTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java 27 May 2011 02:27:37 -0000 1.75.4.2 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java 7 Jun 2011 09:04:52 -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 [] { "test018" }; > } > public AmbiguousMethodTest(String name) { > super(name); >@@ -1491,6 +1492,8 @@ > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=147647 > public void test018() { >+ if (this.complianceLevel >= ClassFileConstants.JDK1_7) >+ return; > this.runConformTest( > new String[] { > "Y.java", >@@ -1516,6 +1519,8 @@ > // in fact, <W extends String> Y<W> make(Class<W> clazz) is the most > // specific method according to JLS 15.12.2.5 > public void test019() { >+ if (this.complianceLevel >= ClassFileConstants.JDK1_7) >+ return; > this.runConformTest( > new String[] { > "Y.java", >@@ -1542,6 +1547,8 @@ > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=147647 > public void test020() { >+ if (this.complianceLevel >= ClassFileConstants.JDK1_7) >+ return; > this.runConformTest( > new String[] { > "Y.java", >@@ -2512,6 +2519,8 @@ > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=184190 > public void test056() { >+ if (this.complianceLevel >= ClassFileConstants.JDK1_7) >+ return; > this.runConformTest( > new String[] { > "X.java", >Index: src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java,v >retrieving revision 1.40.2.14 >diff -u -r1.40.2.14 CompilerInvocationTests.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java 18 May 2011 11:14:34 -0000 1.40.2.14 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java 7 Jun 2011 09:04:53 -0000 >@@ -681,6 +681,7 @@ > expectedProblemAttributes.put("MethodMustOverride", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); > expectedProblemAttributes.put("MethodMustOverrideOrImplement", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); > expectedProblemAttributes.put("MethodNameClash", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); >+ expectedProblemAttributes.put("MethodNameClashHidden", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); > expectedProblemAttributes.put("MethodReducesVisibility", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); > expectedProblemAttributes.put("MethodRequiresBody", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); > expectedProblemAttributes.put("MethodReturnsVoid", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); >@@ -1344,6 +1345,7 @@ > expectedProblemAttributes.put("MethodMustOverride", SKIP); > expectedProblemAttributes.put("MethodMustOverrideOrImplement", SKIP); > expectedProblemAttributes.put("MethodNameClash", SKIP); >+ expectedProblemAttributes.put("MethodNameClashHidden", SKIP); > expectedProblemAttributes.put("MethodReducesVisibility", SKIP); > expectedProblemAttributes.put("MethodRequiresBody", SKIP); > expectedProblemAttributes.put("MethodReturnsVoid", SKIP); >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.222.2.7 >diff -u -r1.222.2.7 MethodVerifyTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 23 May 2011 09:18:18 -0000 1.222.2.7 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 7 Jun 2011 09:04:55 -0000 >@@ -27,7 +27,7 @@ > > public class MethodVerifyTest extends AbstractComparableTest { > static { >-// TESTS_NAMES = new String[] { "test339447" }; >+// TESTS_NAMES = new String[] { "test345949c" }; > // TESTS_NUMBERS = new int[] { 213 }; > // TESTS_RANGE = new int[] { 190, -1}; > } >@@ -6055,6 +6055,33 @@ > " @Override void instanceCase2(Collection c) {}\n" + > "}" > }, >+ this.complianceLevel < ClassFileConstants.JDK1_7 ? >+ "----------\n" + >+ "1. WARNING in Parent.java (at line 3)\n" + >+ " static void staticCase1(Collection c) {}\n" + >+ " ^^^^^^^^^^\n" + >+ "Collection is a raw type. References to generic type Collection<E> should be parameterized\n" + >+ "----------\n" + >+ "2. WARNING in Parent.java (at line 5)\n" + >+ " void instanceCase1(Collection c) {}\n" + >+ " ^^^^^^^^^^\n" + >+ "Collection is a raw type. References to generic type Collection<E> should be parameterized\n" + >+ "----------\n" + >+ "3. WARNING in Parent.java (at line 10)\n" + >+ " static void staticCase2(Collection c) {}\n" + >+ " ^^^^^^^^^^\n" + >+ "Collection is a raw type. References to generic type Collection<E> should be parameterized\n" + >+ "----------\n" + >+ "4. ERROR in Parent.java (at line 11)\n" + >+ " void instanceCase1(Collection<String> c) {}\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Name clash: The method instanceCase1(Collection<String>) of type Child has the same erasure as instanceCase1(Collection) of type Parent but does not override it\n" + >+ "----------\n" + >+ "5. WARNING in Parent.java (at line 12)\n" + >+ " @Override void instanceCase2(Collection c) {}\n" + >+ " ^^^^^^^^^^\n" + >+ "Collection is a raw type. References to generic type Collection<E> should be parameterized\n" + >+ "----------\n": > "----------\n" + > "1. WARNING in Parent.java (at line 3)\n" + > " static void staticCase1(Collection c) {}\n" + >@@ -6066,21 +6093,27 @@ > " ^^^^^^^^^^\n" + > "Collection is a raw type. References to generic type Collection<E> should be parameterized\n" + > "----------\n" + >- "3. WARNING in Parent.java (at line 10)\n" + >+ "3. ERROR in Parent.java (at line 9)\n" + >+ " static void staticCase1(Collection<String> c) {}\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Name clash: The method staticCase1(Collection<String>) of type Child has the same erasure as staticCase1(Collection) of type Parent but does not hide it\n" + >+ "----------\n" + >+ "4. WARNING in Parent.java (at line 10)\n" + > " static void staticCase2(Collection c) {}\n" + > " ^^^^^^^^^^\n" + > "Collection is a raw type. References to generic type Collection<E> should be parameterized\n" + > "----------\n" + >- "4. ERROR in Parent.java (at line 11)\n" + >+ "5. ERROR in Parent.java (at line 11)\n" + > " void instanceCase1(Collection<String> c) {}\n" + > " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + > "Name clash: The method instanceCase1(Collection<String>) of type Child has the same erasure as instanceCase1(Collection) of type Parent but does not override it\n" + > "----------\n" + >- "5. WARNING in Parent.java (at line 12)\n" + >+ "6. WARNING in Parent.java (at line 12)\n" + > " @Override void instanceCase2(Collection c) {}\n" + > " ^^^^^^^^^^\n" + > "Collection is a raw type. References to generic type Collection<E> should be parameterized\n" + > "----------\n" >+ > // @Override is an error for instanceCase1 > // name clash: instanceCase1(Collection<String>) in Child and instanceCase1(Collection) in Parent have the same erasure, yet neither overrides the other > ); >@@ -8828,40 +8861,81 @@ > "class X {}\n" + > "class Y<T> {}" > }, >- "----------\n" + >- "1. ERROR in B.java (at line 2)\n" + >- " static void a(X x) {}\n" + >- " ^^^^^^\n" + >- "This static method cannot hide the instance method from A\n" + >- "----------\n" + >- "2. ERROR in B.java (at line 3)\n" + >- " static void b(Y<String> y) {}\n" + >- " ^^^^^^^^^^^^^^\n" + >- "Name clash: The method b(Y<String>) of type B has the same erasure as b(Y<Integer>) of type A but does not override it\n" + >- "----------\n" + >- "----------\n" + >- "1. ERROR in B2.java (at line 2)\n" + >- " static void b(Y<Integer> y) {}\n" + >- " ^^^^^^^^^^^^^^^\n" + >- "This static method cannot hide the instance method from A\n" + >- "----------\n" + >- "----------\n" + >- "1. ERROR in C.java (at line 3)\n" + >- " void b(Y<String> y) {}\n" + >- " ^^^^^^^^^^^^^^\n" + >- "Name clash: The method b(Y<String>) of type C has the same erasure as b(Y<Integer>) of type A but does not override it\n" + >- "----------\n" + >- "2. ERROR in C.java (at line 4)\n" + >- " void c(X x) {}\n" + >- " ^^^^^^\n" + >- "This instance method cannot override the static method from A\n" + >- "----------\n" + >- "----------\n" + >- "1. ERROR in C2.java (at line 3)\n" + >- " void d(Y<Integer> y) {}\n" + >- " ^^^^^^^^^^^^^^^\n" + >- "This instance method cannot override the static method from A\n" + >+ this.complianceLevel < ClassFileConstants.JDK1_7 ? >+ "----------\n" + >+ "1. ERROR in B.java (at line 2)\n" + >+ " static void a(X x) {}\n" + >+ " ^^^^^^\n" + >+ "This static method cannot hide the instance method from A\n" + >+ "----------\n" + >+ "----------\n" + >+ "1. ERROR in B2.java (at line 2)\n" + >+ " static void b(Y<Integer> y) {}\n" + >+ " ^^^^^^^^^^^^^^^\n" + >+ "This static method cannot hide the instance method from A\n" + >+ "----------\n" + >+ "----------\n" + >+ "1. ERROR in C.java (at line 3)\n" + >+ " void b(Y<String> y) {}\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Name clash: The method b(Y<String>) of type C has the same erasure as b(Y<Integer>) of type A but does not override it\n" + >+ "----------\n" + >+ "2. ERROR in C.java (at line 4)\n" + >+ " void c(X x) {}\n" + >+ " ^^^^^^\n" + >+ "This instance method cannot override the static method from A\n" + >+ "----------\n" + >+ "----------\n" + >+ "1. ERROR in C2.java (at line 3)\n" + >+ " void d(Y<Integer> y) {}\n" + >+ " ^^^^^^^^^^^^^^^\n" + >+ "This instance method cannot override the static method from A\n" + > "----------\n" >+ :"----------\n" + >+ "1. ERROR in B.java (at line 2)\n" + >+ " static void a(X x) {}\n" + >+ " ^^^^^^\n" + >+ "This static method cannot hide the instance method from A\n" + >+ "----------\n" + >+ "2. ERROR in B.java (at line 3)\n" + >+ " static void b(Y<String> y) {}\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Name clash: The method b(Y<String>) of type B has the same erasure as b(Y<Integer>) of type A but does not hide it\n" + >+ "----------\n" + >+ "3. ERROR in B.java (at line 5)\n" + >+ " static void d(Y<String> y) {}\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Name clash: The method d(Y<String>) of type B has the same erasure as d(Y<Integer>) of type A but does not hide it\n" + >+ "----------\n" + >+ "----------\n" + >+ "1. ERROR in B2.java (at line 2)\n" + >+ " static void b(Y<Integer> y) {}\n" + >+ " ^^^^^^^^^^^^^^^\n" + >+ "This static method cannot hide the instance method from A\n" + >+ "----------\n" + >+ "----------\n" + >+ "1. ERROR in C.java (at line 3)\n" + >+ " void b(Y<String> y) {}\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Name clash: The method b(Y<String>) of type C has the same erasure as b(Y<Integer>) of type A but does not override it\n" + >+ "----------\n" + >+ "2. ERROR in C.java (at line 4)\n" + >+ " void c(X x) {}\n" + >+ " ^^^^^^\n" + >+ "This instance method cannot override the static method from A\n" + >+ "----------\n" + >+ "3. ERROR in C.java (at line 5)\n" + >+ " void d(Y<String> y) {}\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "Name clash: The method d(Y<String>) of type C has the same erasure as d(Y<Integer>) of type A but does not hide it\n" + >+ "----------\n" + >+ "----------\n" + >+ "1. ERROR in C2.java (at line 3)\n" + >+ " void d(Y<Integer> y) {}\n" + >+ " ^^^^^^^^^^^^^^^\n" + >+ "This instance method cannot override the static method from A\n" + >+ "----------\n" >+ > ); > } > public void test150() { >@@ -12328,4 +12402,37 @@ > "The method f(String) is ambiguous for the type B<String>\n" + > "----------\n"); > } >+public void test345949a() throws Exception { >+ if (new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_7) return; >+ this.runNegativeTest( >+ new String[] { >+ "Sub.java", >+ "class A<T> {}\n" + >+ "class Super {\n" + >+ " public static void foo(A<Number> p) {}\n" + >+ "}\n" + >+ "public class Sub extends Super {\n" + >+ " public static void foo(A<Integer> p) {}\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in Sub.java (at line 6)\n" + >+ " public static void foo(A<Integer> p) {}\n" + >+ " ^^^^^^^^^^^^^^^^^\n" + >+ "Name clash: The method foo(A<Integer>) of type Sub has the same erasure as foo(A<Number>) of type Super but does not hide it\n" + >+ "----------\n"); >+} >+public void _test345949b() throws Exception { >+ this.runNegativeTest( >+ new String[] { >+ "Sub.java", >+ "class Super {\n" + >+ " public static void foo() {}\n" + >+ "}\n" + >+ "public class Sub extends Super {\n" + >+ " public static <T> void foo() {}\n" + >+ "}\n" >+ }, >+ ""); >+} > }
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 345949
:
197485
|
201890