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 201890 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]
Synchronized patch
patch.txt (text/plain), 17.11 KB, created by
Srikanth Sankaran
on 2011-08-22 03:12:55 EDT
(
hide
)
Description:
Synchronized patch
Filename:
MIME Type:
Creator:
Srikanth Sankaran
Created:
2011-08-22 03:12:55 EDT
Size:
17.11 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.228 >diff -u -r1.228 IProblem.java >--- compiler/org/eclipse/jdt/core/compiler/IProblem.java 28 Jul 2011 17:07:43 -0000 1.228 >+++ compiler/org/eclipse/jdt/core/compiler/IProblem.java 22 Aug 2011 07:11:50 -0000 >@@ -1151,6 +1151,8 @@ > > /** @since 3.7.1 */ > int DuplicateInheritedMethods = MethodRelated + 583; >+ /** @since 3.8 */ >+ 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.127 >diff -u -r1.127 MethodVerifier15.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 9 Aug 2011 13:06:23 -0000 1.127 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 22 Aug 2011 07:11:50 -0000 >@@ -230,7 +230,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.438 >diff -u -r1.438 ProblemReporter.java >--- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 9 Aug 2011 13:06:23 -0000 1.438 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 22 Aug 2011 07:11:52 -0000 >@@ -5115,6 +5115,27 @@ > currentMethod.sourceEnd()); > } > >+public void methodNameClashHidden(MethodBinding currentMethod, MethodBinding inheritedMethod) { >+ this.handle( >+ IProblem.MethodNameClashHidden, >+ new String[] { >+ new String(currentMethod.selector), >+ typesAsString(currentMethod, currentMethod.parameters, false), >+ new String(currentMethod.declaringClass.readableName()), >+ typesAsString(inheritedMethod, inheritedMethod.parameters, false), >+ new String(inheritedMethod.declaringClass.readableName()), >+ }, >+ new String[] { >+ new String(currentMethod.selector), >+ typesAsString(currentMethod, currentMethod.parameters, true), >+ new String(currentMethod.declaringClass.shortReadableName()), >+ typesAsString(inheritedMethod, 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.268 >diff -u -r1.268 messages.properties >--- compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 9 Aug 2011 14:32:41 -0000 1.268 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 22 Aug 2011 07:11:52 -0000 >@@ -517,6 +517,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.78 >diff -u -r1.78 AmbiguousMethodTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java 18 Aug 2011 10:02:39 -0000 1.78 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java 22 Aug 2011 07:11:54 -0000 >@@ -1568,6 +1568,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", >@@ -1593,6 +1595,9 @@ > // 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", >@@ -1619,6 +1624,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", >@@ -2680,6 +2687,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.42 >diff -u -r1.42 CompilerInvocationTests.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java 28 Jul 2011 17:06:24 -0000 1.42 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java 22 Aug 2011 07:11:54 -0000 >@@ -677,6 +677,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.227 >diff -u -r1.227 MethodVerifyTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 18 Aug 2011 10:02:39 -0000 1.227 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 22 Aug 2011 07:11:56 -0000 >@@ -6437,6 +6437,7 @@ > " @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" + >@@ -6462,7 +6463,38 @@ > " @Override void instanceCase2(Collection c) {}\n" + > " ^^^^^^^^^^\n" + > "Collection is a raw type. References to generic type Collection<E> should be parameterized\n" + >- "----------\n" >+ "----------\n": >+ "----------\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. 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" + >+ "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" + >+ "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 > ); >@@ -9246,40 +9278,80 @@ > "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" + >- "----------\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() { >@@ -13420,4 +13492,38 @@ > }, > output); > } >+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