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 153560 Details for
Bug 296660
[compiler] Incorrect unused method warning from compiler
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
patch.txt (text/plain), 15.40 KB, created by
Srikanth Sankaran
on 2009-12-02 01:48:50 EST
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Srikanth Sankaran
Created:
2009-12-02 01:48:50 EST
Size:
15.40 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java,v >retrieving revision 1.109 >diff -u -r1.109 MethodVerifier.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java 2 Oct 2009 15:09:16 -0000 1.109 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java 2 Dec 2009 06:49:46 -0000 >@@ -423,15 +423,26 @@ > void checkMethods() { > boolean mustImplementAbstractMethods = mustImplementAbstractMethods(); > boolean skipInheritedMethods = mustImplementAbstractMethods && canSkipInheritedMethods(); // have a single concrete superclass so only check overridden methods >+ boolean isOrEnclosedByPrivateType = this.type.isOrEnclosedByPrivateType(); > char[][] methodSelectors = this.inheritedMethods.keyTable; > nextSelector : for (int s = methodSelectors.length; --s >= 0;) { > if (methodSelectors[s] == null) continue nextSelector; > > MethodBinding[] current = (MethodBinding[]) this.currentMethods.get(methodSelectors[s]); >+ MethodBinding[] inherited = (MethodBinding[]) this.inheritedMethods.valueTable[s]; >+ >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=296660, if current type is exposed, >+ // inherited methods of super classes are too. current != null case handled below. >+ if (current == null && !isOrEnclosedByPrivateType) { >+ int length = inherited.length; >+ for (int i = 0; i < length; i++){ >+ inherited[i].original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed; >+ } >+ } >+ > if (current == null && skipInheritedMethods) > continue nextSelector; > >- MethodBinding[] inherited = (MethodBinding[]) this.inheritedMethods.valueTable[s]; > if (inherited.length == 1 && current == null) { // handle the common case > if (mustImplementAbstractMethods && inherited[0].isAbstract()) > checkAbstractMethod(inherited[0]); >@@ -462,7 +473,11 @@ > for (int i = 0, length = inherited.length; i < length; i++) { > MethodBinding inheritedMethod = inherited[i]; > if (inheritedMethod == null) continue; >- >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=296660, if current type is exposed, >+ // inherited methods of super classes are too. current == null case handled already. >+ if (!isOrEnclosedByPrivateType && current != null) { >+ inheritedMethod.original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed; >+ } > matchingInherited[++index] = inheritedMethod; > for (int j = i + 1; j < length; j++) { > MethodBinding otherInheritedMethod = inherited[j]; >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.107 >diff -u -r1.107 MethodVerifier15.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 11 Nov 2009 05:39:17 -0000 1.107 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 2 Dec 2009 06:49:47 -0000 >@@ -366,15 +366,26 @@ > void checkMethods() { > boolean mustImplementAbstractMethods = mustImplementAbstractMethods(); > boolean skipInheritedMethods = mustImplementAbstractMethods && canSkipInheritedMethods(); // have a single concrete superclass so only check overridden methods >+ boolean isOrEnclosedByPrivateType = this.type.isOrEnclosedByPrivateType(); > char[][] methodSelectors = this.inheritedMethods.keyTable; > nextSelector : for (int s = methodSelectors.length; --s >= 0;) { > if (methodSelectors[s] == null) continue nextSelector; > > MethodBinding[] current = (MethodBinding[]) this.currentMethods.get(methodSelectors[s]); >+ MethodBinding[] inherited = (MethodBinding[]) this.inheritedMethods.valueTable[s]; >+ >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=296660, if current type is exposed, >+ // inherited methods of super classes are too. current != null case handled below. >+ if (current == null && !isOrEnclosedByPrivateType) { >+ int length = inherited.length; >+ for (int i = 0; i < length; i++){ >+ inherited[i].original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed; >+ } >+ } >+ > if (current == null && skipInheritedMethods) > continue nextSelector; > >- MethodBinding[] inherited = (MethodBinding[]) this.inheritedMethods.valueTable[s]; > if (inherited.length == 1 && current == null) { // handle the common case > if (mustImplementAbstractMethods && inherited[0].isAbstract()) > checkAbstractMethod(inherited[0]); >@@ -420,9 +431,14 @@ > // either because they match the same currentMethod or match each other > boolean[] skip = new boolean[inheritedLength]; > for (int i = 0; i < inheritedLength; i++) { >+ MethodBinding matchMethod = foundMatch[i]; >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=296660, if current type is exposed, >+ // inherited methods of super classes are too. current == null case handled already. >+ if (!isOrEnclosedByPrivateType && matchMethod == null && current != null) { >+ inherited[i].original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed; >+ } > if (skip[i]) continue; > MethodBinding inheritedMethod = inherited[i]; >- MethodBinding matchMethod = foundMatch[i]; > if (matchMethod == null) > matchingInherited[++index] = inheritedMethod; > for (int j = i + 1; j < inheritedLength; j++) { >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java,v >retrieving revision 1.18 >diff -u -r1.18 ProblemTypeAndMethodTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java 10 Dec 2008 17:42:07 -0000 1.18 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java 2 Dec 2009 06:50:13 -0000 >@@ -4984,4 +4984,268 @@ > "TheFieldDeclaratation cannot be resolved to a type\n" + > "----------\n"); > } >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=296660 >+public void test098() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " private class A {\n" + >+ " public void foo(int a) {\n" + >+ " System.out.println(\"Hello\");\n" + >+ " }\n" + >+ " public void foo(float a) {\n" + >+ " System.out.println(\"Hello\");\n" + >+ " }\n" + >+ " public void foo(boolean a) {\n" + >+ " System.out.println(\"Hello\");\n" + >+ " }\n" + >+ " public void foo(Integer a) {\n" + >+ " System.out.println(\"Hello\");\n" + >+ " }\n" + >+ " }\n" + >+ " private class B extends A {\n" + >+ " public void foo(int a) {\n" + >+ " System.out.println(\"Hello\");\n" + >+ " }\n" + >+ " public void foo(float a) {\n" + >+ " System.out.println(\"Hello\");\n" + >+ " }\n" + >+ " public void foo(double a) {\n" + >+ " System.out.println(\"Hello\");\n" + >+ " }\n" + >+ " public void foo(char a) {\n" + >+ " System.out.println(\"Hello\");\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 3)\n" + >+ " public void foo(int a) {\n" + >+ " ^^^^^^^^^^\n" + >+ "The method foo(int) from the type X.A is never used locally\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 6)\n" + >+ " public void foo(float a) {\n" + >+ " ^^^^^^^^^^^^\n" + >+ "The method foo(float) from the type X.A is never used locally\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 9)\n" + >+ " public void foo(boolean a) {\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "The method foo(boolean) from the type X.A is never used locally\n" + >+ "----------\n" + >+ "4. WARNING in X.java (at line 12)\n" + >+ " public void foo(Integer a) {\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "The method foo(Integer) from the type X.A is never used locally\n" + >+ "----------\n" + >+ "5. WARNING in X.java (at line 16)\n" + >+ " private class B extends A {\n" + >+ " ^\n" + >+ "The type X.B is never used locally\n" + >+ "----------\n" + >+ "6. WARNING in X.java (at line 16)\n" + >+ " private class B extends A {\n" + >+ " ^\n" + >+ "Access to enclosing constructor X.A() is emulated by a synthetic accessor method\n" + >+ "----------\n" + >+ "7. WARNING in X.java (at line 23)\n" + >+ " public void foo(double a) {\n" + >+ " ^^^^^^^^^^^^^\n" + >+ "The method foo(double) from the type X.B is never used locally\n" + >+ "----------\n" + >+ "8. WARNING in X.java (at line 26)\n" + >+ " public void foo(char a) {\n" + >+ " ^^^^^^^^^^^\n" + >+ "The method foo(char) from the type X.B is never used locally\n" + >+ "----------\n"); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=296660 >+public void test098b() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " private class A {\n" + >+ " public void foo(int a) {\n" + >+ " System.out.println(\"Hello\");\n" + >+ " }\n" + >+ " public void foo(float a) {\n" + >+ " System.out.println(\"Hello\");\n" + >+ " }\n" + >+ " public void foo(boolean a) {\n" + >+ " System.out.println(\"Hello\");\n" + >+ " }\n" + >+ " public void foo(Integer a) {\n" + >+ " System.out.println(\"Hello\");\n" + >+ " }\n" + >+ " }\n" + >+ " private class B extends A {\n" + >+ " public void foo(int a) {\n" + >+ " System.out.println(\"Hello\");\n" + >+ " }\n" + >+ " public void foo(float a) {\n" + >+ " System.out.println(\"Hello\");\n" + >+ " }\n" + >+ " public void foo(double a) {\n" + >+ " System.out.println(\"Hello\");\n" + >+ " }\n" + >+ " public void foo(char a) {\n" + >+ " System.out.println(\"Hello\");\n" + >+ " }\n" + >+ " }\n" + >+ " public class C extends B {\n" + >+ " public void foo(int a) {\n" + >+ " System.out.println(\"Hello\");\n" + >+ " }\n" + >+ " public void foo(double a) {\n" + >+ " System.out.println(\"Hello\");\n" + >+ " }\n" + >+ " public void foo(boolean a) {\n" + >+ " System.out.println(\"Hello\");\n" + >+ " }\n" + >+ " public void foo(byte a) {\n" + >+ " System.out.println(\"Hello\");\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 3)\n" + >+ " public void foo(int a) {\n" + >+ " ^^^^^^^^^^\n" + >+ "The method foo(int) from the type X.A is never used locally\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 6)\n" + >+ " public void foo(float a) {\n" + >+ " ^^^^^^^^^^^^\n" + >+ "The method foo(float) from the type X.A is never used locally\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 9)\n" + >+ " public void foo(boolean a) {\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "The method foo(boolean) from the type X.A is never used locally\n" + >+ "----------\n" + >+ "4. WARNING in X.java (at line 16)\n" + >+ " private class B extends A {\n" + >+ " ^\n" + >+ "Access to enclosing constructor X.A() is emulated by a synthetic accessor method\n" + >+ "----------\n" + >+ "5. WARNING in X.java (at line 23)\n" + >+ " public void foo(double a) {\n" + >+ " ^^^^^^^^^^^^^\n" + >+ "The method foo(double) from the type X.B is never used locally\n" + >+ "----------\n" + >+ "6. WARNING in X.java (at line 30)\n" + >+ " public class C extends B {\n" + >+ " ^\n" + >+ "Access to enclosing constructor X.B() is emulated by a synthetic accessor method\n" + >+ "----------\n"); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=296660 >+public void test098c() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " private class A {\n" + >+ " public void foo() {}\n" + >+ " }\n" + >+ " public class B extends A {}\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 5)\n" + >+ " public class B extends A {}\n" + >+ " ^\n" + >+ "Access to enclosing constructor X.A() is emulated by a synthetic accessor method\n" + >+ "----------\n"); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=296660 >+public void test098d() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " private class A {\n" + >+ " public void foo() {}\n" + >+ " public void foo(int a) {}\n" + >+ " }\n" + >+ " public class B extends A {}\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 6)\n" + >+ " public class B extends A {}\n" + >+ " ^\n" + >+ "Access to enclosing constructor X.A() is emulated by a synthetic accessor method\n" + >+ "----------\n"); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=296660 >+public void test098e() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " private class A {\n" + >+ " private void foo() {}\n" + >+ " private void foo(int a) {}\n" + >+ " }\n" + >+ " public class B extends A {}\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 3)\n" + >+ " private void foo() {}\n" + >+ " ^^^^^\n" + >+ "The method foo() from the type X.A is never used locally\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 4)\n" + >+ " private void foo(int a) {}\n" + >+ " ^^^^^^^^^^\n" + >+ "The method foo(int) from the type X.A is never used locally\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 6)\n" + >+ " public class B extends A {}\n" + >+ " ^\n" + >+ "Access to enclosing constructor X.A() is emulated by a synthetic accessor method\n" + >+ "----------\n"); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=296660 >+public void test098f() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " private class A {\n" + >+ " public void foo() {}\n" + >+ " public void foo(int a) {}\n" + >+ " }\n" + >+ " private class B extends A {}\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 3)\n" + >+ " public void foo() {}\n" + >+ " ^^^^^\n" + >+ "The method foo() from the type X.A is never used locally\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 4)\n" + >+ " public void foo(int a) {}\n" + >+ " ^^^^^^^^^^\n" + >+ "The method foo(int) from the type X.A is never used locally\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 6)\n" + >+ " private class B extends A {}\n" + >+ " ^\n" + >+ "The type X.B is never used locally\n" + >+ "----------\n" + >+ "4. WARNING in X.java (at line 6)\n" + >+ " private class B extends A {}\n" + >+ " ^\n" + >+ "Access to enclosing constructor X.A() is emulated by a synthetic accessor method\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 296660
: 153560