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 124945 Details for
Bug 201912
[compiler] Unused public members of private classes not flagged
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix and tests
external-patch.txt (text/plain), 23.80 KB, created by
Srikanth Sankaran
on 2009-02-06 05:57:55 EST
(
hide
)
Description:
Proposed fix and tests
Filename:
MIME Type:
Creator:
Srikanth Sankaran
Created:
2009-02-06 05:57:55 EST
Size:
23.80 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java,v >retrieving revision 1.49 >diff -u -r1.49 InnerEmulationTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java 4 Dec 2008 17:06:22 -0000 1.49 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java 6 Feb 2009 10:51:24 -0000 >@@ -1468,10 +1468,25 @@ > " ^\n" + > "Access to enclosing constructor A2.B() is emulated by a synthetic accessor method\n" + > "----------\n" + >- "3. ERROR in p1\\A2.java (at line 20)\n" + >+ "3. WARNING in p1\\A2.java (at line 19)\n" + >+ " public void foo() { \n" + >+ " ^^^^^\n" + >+ "The method foo() from the type A2.C is never used locally\n" + >+ "----------\n" + >+ "4. ERROR in p1\\A2.java (at line 20)\n" + > " (new D.E(null, null, null, new F(get()) {}) {}).execute(); \n" + > " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + > "No enclosing instance of type D is accessible. Must qualify the allocation with an enclosing instance of type D (e.g. x.new A() where x is an instance of D).\n" + >+ "----------\n" + >+ "5. WARNING in p1\\A2.java (at line 20)\n" + >+ " (new D.E(null, null, null, new F(get()) {}) {}).execute(); \n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "The type new D.E(){} is never used locally\n" + >+ "----------\n" + >+ "6. WARNING in p1\\A2.java (at line 20)\n" + >+ " (new D.E(null, null, null, new F(get()) {}) {}).execute(); \n" + >+ " ^^^^^^^^\n" + >+ "The type new F(){} is never used locally\n" + > "----------\n"); > } > /** >@@ -1556,10 +1571,20 @@ > " ^\n" + > "Access to enclosing constructor A2.B() is emulated by a synthetic accessor method\n" + > "----------\n" + >- "3. ERROR in p1\\A2.java (at line 20)\n" + >+ "3. WARNING in p1\\A2.java (at line 19)\n" + >+ " public void foo() { \n" + >+ " ^^^^^\n" + >+ "The method foo() from the type A2.C is never used locally\n" + >+ "----------\n" + >+ "4. ERROR in p1\\A2.java (at line 20)\n" + > " (new D.E(null, null, null, new F(get()) {})).execute(); \n" + > " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + > "No enclosing instance of type D is accessible. Must qualify the allocation with an enclosing instance of type D (e.g. x.new A() where x is an instance of D).\n" + >+ "----------\n" + >+ "5. WARNING in p1\\A2.java (at line 20)\n" + >+ " (new D.E(null, null, null, new F(get()) {})).execute(); \n" + >+ " ^^^^^^^^\n" + >+ "The type new F(){} is never used locally\n" + > "----------\n"); > } > /** >@@ -5579,7 +5604,12 @@ > "}", // =================, > }, > "----------\n" + >- "1. ERROR in p\\X.java (at line 11)\n" + >+ "1. WARNING in p\\X.java (at line 5)\n" + >+ " String variable = \"my testing\";\n" + >+ " ^^^^^^^^\n" + >+ "The field X.Outer.Inner.variable is never read locally\n" + >+ "----------\n" + >+ "2. ERROR in p\\X.java (at line 11)\n" + > " Zork z;\n" + > " ^^^^\n" + > "Zork cannot be resolved to a type\n" + >@@ -5633,7 +5663,12 @@ > "}", // =================, > }, > "----------\n" + >- "1. ERROR in p\\X.java (at line 12)\n" + >+ "1. WARNING in p\\X.java (at line 4)\n" + >+ " String variable = \"my testing\";\n" + >+ " ^^^^^^^^\n" + >+ "The field X.Outer.Inner.variable is never read locally\n" + >+ "----------\n" + >+ "2. ERROR in p\\X.java (at line 12)\n" + > " Zork z;\n" + > " ^^^^\n" + > "Zork cannot be resolved to a type\n" + >@@ -6423,22 +6458,32 @@ > " ^^^^^\n" + > "The type X.Test4 is never used locally\n" + > "----------\n" + >- "2. ERROR in X.java (at line 16)\n" + >+ "2. WARNING in X.java (at line 13)\n" + >+ " public Test4() {\n" + >+ " ^^^^^^^\n" + >+ "The constructor X.Test4() is never used locally\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 14)\n" + >+ " super(\"available\", new Test3() {\n" + >+ " ^^^^^^^\n" + >+ "The type new X.Test3(){} is never used locally\n" + >+ "----------\n" + >+ "4. ERROR in X.java (at line 16)\n" + > " System.out.println(X.this.var1.trim());\n" + > " ^^^^^^\n" + > "No enclosing instance of the type X is accessible in scope\n" + > "----------\n" + >- "3. WARNING in X.java (at line 16)\n" + >+ "5. WARNING in X.java (at line 16)\n" + > " System.out.println(X.this.var1.trim());\n" + > " ^^^^\n" + > "Read access to enclosing field X.var1 is emulated by a synthetic accessor method\n" + > "----------\n" + >- "4. WARNING in X.java (at line 17)\n" + >+ "6. WARNING in X.java (at line 17)\n" + > " System.out.println(var1.trim());\n" + > " ^^^^\n" + > "Read access to enclosing field X.var1 is emulated by a synthetic accessor method\n" + > "----------\n" + >- "5. ERROR in X.java (at line 17)\n" + >+ "7. ERROR in X.java (at line 17)\n" + > " System.out.println(var1.trim());\n" + > " ^^^^\n" + > "No enclosing instance of the type X is accessible in scope\n" + >Index: src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest.java,v >retrieving revision 1.47 >diff -u -r1.47 JavadocTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest.java 27 Jun 2008 16:04:44 -0000 1.47 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest.java 6 Feb 2009 10:51:25 -0000 >@@ -271,6 +271,54 @@ > " }\n" + > "}\n" }; > } >+ // The fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=201912 results in these additional >+ // diagnostics to be generated. Just as we arrange for the ``referencedClasses'' to be compiled >+ // automatically, we need to include these diagnostics automatically in the expected messages. >+ static String expectedDiagnosticsFromReferencedClasses = >+ "----------\n" + >+ "1. WARNING in test\\AbstractVisibility.java (at line 5)\n" + >+ " public int avf_public = avf_private;\n" + >+ " ^^^^^^^^^^\n" + >+ "The field AbstractVisibility.AvcPrivate.avf_public is never read locally\n" + >+ "----------\n" + >+ "2. WARNING in test\\AbstractVisibility.java (at line 10)\n" + >+ " public int avm_public() {\n" + >+ " ^^^^^^^^^^^^\n" + >+ "The method avm_public() from the type AbstractVisibility.AvcPrivate is never used locally\n" + >+ "----------\n" + >+ "----------\n" + >+ "1. WARNING in test\\Visibility.java (at line 5)\n" + >+ " public int vf_public = vf_private;\n" + >+ " ^^^^^^^^^\n" + >+ "The field Visibility.VcPrivate.vf_public is never read locally\n" + >+ "----------\n" + >+ "2. WARNING in test\\Visibility.java (at line 11)\n" + >+ " public int vm_public() {\n" + >+ " ^^^^^^^^^^^\n" + >+ "The method vm_public() from the type Visibility.VcPrivate is never used locally\n" + >+ "----------\n" + >+ "----------\n" + >+ "1. WARNING in test\\copy\\VisibilityPackage.java (at line 5)\n" + >+ " public int vf_public = vf_private;\n" + >+ " ^^^^^^^^^\n" + >+ "The field VisibilityPackage.VpPrivate.vf_public is never read locally\n" + >+ "----------\n" + >+ "2. WARNING in test\\copy\\VisibilityPackage.java (at line 10)\n" + >+ " public int vm_public() {\n" + >+ " ^^^^^^^^^^^\n" + >+ "The method vm_public() from the type VisibilityPackage.VpPrivate is never used locally\n" + >+ "----------\n" + >+ "----------\n" + >+ "1. WARNING in test\\copy\\VisibilityPublic.java (at line 5)\n" + >+ " public int vf_public = vf_private;\n" + >+ " ^^^^^^^^^\n" + >+ "The field VisibilityPublic.VpPrivate.vf_public is never read locally\n" + >+ "----------\n" + >+ "2. WARNING in test\\copy\\VisibilityPublic.java (at line 10)\n" + >+ " public int vm_public() {\n" + >+ " ^^^^^^^^^^^\n" + >+ "The method vm_public() from the type VisibilityPublic.VpPrivate is never used locally\n" + >+ "----------\n"; > /* (non-Javadoc) > * @see junit.framework.TestCase#setUp() > */ >@@ -312,6 +360,7 @@ > completedFiles = new String[testFiles.length + referencedClasses.length]; > System.arraycopy(referencedClasses, 0, completedFiles, 0, referencedClasses.length); > System.arraycopy(testFiles, 0, completedFiles, referencedClasses.length, testFiles.length); >+ expected = expectedDiagnosticsFromReferencedClasses + expected; > } > runNegativeTest(completedFiles, expected, javacTestOptions); > } >Index: src/org/eclipse/jdt/core/tests/compiler/regression/ProblemConstructorTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemConstructorTest.java,v >retrieving revision 1.20 >diff -u -r1.20 ProblemConstructorTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/ProblemConstructorTest.java 27 Jun 2008 16:04:44 -0000 1.20 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/ProblemConstructorTest.java 6 Feb 2009 10:51:25 -0000 >@@ -138,4 +138,60 @@ > "Zork cannot be resolved to a type\n" + > "----------\n"); > } >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=201912, test to make sure that unused public members of >+// private class (including constructors, fields, types and methods) get warned about. >+public void test004() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " private class M { \n" + // expect unused field, method, constructor and type warnings >+ " private int state = 0;\n" + >+ " public int unusedMethod() { return this.state; }\n" + >+ " public M (int state) { this.state = state;} \n" + >+ " public int unusedField = 0;\n" + >+ " public class N {}\n" + >+ " }\n" + >+ " private class N { \n" + // No warnings should come from within here >+ " private int state = 0;\n" + >+ " public int usedMethod() { new O(); return new N(this.state + this.usedField).state; }\n" + >+ " public N (int state) { this.state = state;} \n" + >+ " public int usedField = 0;\n" + >+ " public class O {}\n" + >+ " }\n" + >+ " public class P { \n" + // No warnings should come from within here. >+ " private int state = 0;\n" + >+ " public int unusedMethod() { return this.state; }\n" + >+ " public P (int state) { this.state = state;} \n" + >+ " public int unusedField = 0;\n" + >+ " public class N {}\n" + >+ " }\n" + >+ " public M foo(M m, N n) {\n" + >+ " n.usedMethod(); return m;\n" + >+ " }\n" + >+ "} \n" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 4)\n" + >+ " public int unusedMethod() { return this.state; }\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "The method unusedMethod() from the type X.M is never used locally\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 5)\n" + >+ " public M (int state) { this.state = state;} \n" + >+ " ^^^^^^^^^^^^^\n" + >+ "The constructor X.M(int) is never used locally\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 6)\n" + >+ " public int unusedField = 0;\n" + >+ " ^^^^^^^^^^^\n" + >+ "The field X.M.unusedField is never read locally\n" + >+ "----------\n" + >+ "4. WARNING in X.java (at line 7)\n" + >+ " public class N {}\n" + >+ " ^\n" + >+ "The type X.M.N is never used locally\n" + >+ "----------\n" >+ ); >+} > } >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.791 >diff -u -r1.791 GenericTypeTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 5 Feb 2009 09:40:41 -0000 1.791 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 6 Feb 2009 10:51:21 -0000 >@@ -41220,7 +41220,12 @@ > "The type A.P is not visible\n" + > "----------\n" + > "----------\n" + >- "1. WARNING in p\\A.java (at line 18)\n" + >+ "1. WARNING in p\\A.java (at line 9)\n" + >+ " public int pval;\n" + >+ " ^^^^\n" + >+ "The field A.P.pval is never read locally\n" + >+ "----------\n" + >+ "2. WARNING in p\\A.java (at line 18)\n" + > " this.box.set(new P());\n" + > " ^^^^^^^\n" + > "Access to enclosing constructor A.P() is emulated by a synthetic accessor method\n" + >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java,v >retrieving revision 1.69 >diff -u -r1.69 MethodDeclaration.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java 29 Jan 2009 17:00:08 -0000 1.69 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java 6 Feb 2009 10:51:30 -0000 >@@ -49,7 +49,7 @@ > > if (!this.binding.isUsed() && > (this.binding.isPrivate() >- || (((this.binding.modifiers & (ExtraCompilerModifiers.AccOverriding|ExtraCompilerModifiers.AccImplementing)) == 0) && this.binding.declaringClass.isLocalType()))) { >+ || (((this.binding.modifiers & (ClassFileConstants.AccAbstract|ExtraCompilerModifiers.AccOverriding|ExtraCompilerModifiers.AccImplementing)) == 0) && (this.binding.declaringClass.isLocalType() || this.binding.isOrEnclosedByPrivateType())))) { > if (!classScope.referenceCompilationUnit().compilationResult.hasSyntaxError) { > this.scope.problemReporter().unusedPrivateMethod(this); > } >Index: compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java,v >retrieving revision 1.93 >diff -u -r1.93 FieldDeclaration.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java 25 Sep 2008 23:10:29 -0000 1.93 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java 6 Feb 2009 10:51:30 -0000 >@@ -52,7 +52,7 @@ > > public FlowInfo analyseCode(MethodScope initializationScope, FlowContext flowContext, FlowInfo flowInfo) { > if (this.binding != null && !this.binding.isUsed()) { >- if (this.binding.isPrivate() || (this.binding.declaringClass != null && this.binding.declaringClass.isLocalType())) { >+ if (this.binding.isOrEnclosedByPrivateType() || (this.binding.declaringClass != null && this.binding.declaringClass.isLocalType())) { > if (!initializationScope.referenceCompilationUnit().compilationResult.hasSyntaxError) { > initializationScope.problemReporter().unusedPrivateField(this); > } >Index: compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java,v >retrieving revision 1.100 >diff -u -r1.100 ConstructorDeclaration.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java 29 Jan 2009 17:00:08 -0000 1.100 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java 6 Feb 2009 10:51:30 -0000 >@@ -59,6 +59,8 @@ > if (constructorBinding.isPrivate()) { > if ((this.binding.declaringClass.tagBits & TagBits.HasNonPrivateConstructor) == 0) > break checkUnused; // tolerate as known pattern to block instantiation >+ } else if (constructorBinding.isOrEnclosedByPrivateType()) { >+ // fall through and complain unused: https://bugs.eclipse.org/bugs/show_bug.cgi?id=201912 > } else if ((this.binding.declaringClass.tagBits & (TagBits.IsAnonymousType|TagBits.IsLocalType)) != TagBits.IsLocalType) { > break checkUnused; > } >Index: compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java,v >retrieving revision 1.98 >diff -u -r1.98 ASTNode.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 5 Feb 2009 09:38:11 -0000 1.98 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 6 Feb 2009 10:51:29 -0000 >@@ -356,7 +356,7 @@ > // ignore references insing Javadoc comments > if ((this.bits & ASTNode.InsideJavadoc) ==0 && > !isStrictlyAssigned && >- (field.isPrivate() || (field.declaringClass != null && field.declaringClass.isLocalType())) && !scope.isDefinedInField(field)) { >+ (field.isOrEnclosedByPrivateType() || (field.declaringClass != null && field.declaringClass.isLocalType())) && !scope.isDefinedInField(field)) { > // ignore cases where field is used from within inside itself > field.original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed; > } >@@ -393,7 +393,7 @@ > boolean isExplicitUse) { > // ignore references insing Javadoc comments > if ((this.bits & ASTNode.InsideJavadoc) ==0 && >- (method.isPrivate() || method.declaringClass.isLocalType()) && !scope.isDefinedInMethod(method)) { >+ (method.isOrEnclosedByPrivateType() || method.declaringClass.isLocalType()) && !scope.isDefinedInMethod(method)) { > // ignore cases where method is used from within inside itself (e.g. direct recursions) > method.original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed; > } >@@ -452,7 +452,7 @@ > ReferenceBinding refType = (ReferenceBinding) type; > // ignore references insing Javadoc comments > if ((this.bits & ASTNode.InsideJavadoc) == 0 && >- (refType.isPrivate() || refType.isLocalType()) && !scope.isDefinedInType(refType)) { >+ (refType.isOrEnclosedByPrivateType() || refType.isLocalType()) && !scope.isDefinedInType(refType)) { > // ignore cases where type is used from within inside itself > ((ReferenceBinding)refType.erasure()).modifiers |= ExtraCompilerModifiers.AccLocallyUsed; > } >Index: compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java,v >retrieving revision 1.155 >diff -u -r1.155 TypeDeclaration.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java 3 Feb 2009 09:40:45 -0000 1.155 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java 6 Feb 2009 10:51:31 -0000 >@@ -611,7 +611,7 @@ > * Common flow analysis for all types > */ > private void internalAnalyseCode(FlowContext flowContext, FlowInfo flowInfo) { >- if ((this.binding.isPrivate() || (this.binding.tagBits & (TagBits.IsAnonymousType|TagBits.IsLocalType)) == TagBits.IsLocalType) && !this.binding.isUsed()) { >+ if ((this.binding.isOrEnclosedByPrivateType() || (this.binding.tagBits & (TagBits.IsAnonymousType|TagBits.IsLocalType)) == TagBits.IsLocalType) && !this.binding.isUsed()) { > if (!this.scope.referenceCompilationUnit().compilationResult.hasSyntaxError) { > this.scope.problemReporter().unusedPrivateType(this); > } >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java,v >retrieving revision 1.55 >diff -u -r1.55 FieldBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java 5 Dec 2008 12:41:30 -0000 1.55 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java 6 Feb 2009 10:51:31 -0000 >@@ -286,6 +286,14 @@ > public final boolean isPrivate() { > return (this.modifiers & ClassFileConstants.AccPrivate) != 0; > } >+/* Answer true if the receiver has private visibility or is enclosed by a class that does. >+*/ >+ >+public final boolean isOrEnclosedByPrivateType() { >+ if ((this.modifiers & ClassFileConstants.AccPrivate) != 0) >+ return true; >+ return this.declaringClass != null && this.declaringClass.isOrEnclosedByPrivateType(); >+} > /* Answer true if the receiver has private visibility and is used locally > */ > >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.100 >diff -u -r1.100 MethodVerifier.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java 4 Dec 2008 17:06:52 -0000 1.100 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java 6 Feb 2009 10:51:33 -0000 >@@ -205,6 +205,11 @@ > if (concreteMethod.thrownExceptions != Binding.NO_EXCEPTIONS) > for (int i = abstractMethods.length; --i >= 0;) > checkExceptions(concreteMethod, abstractMethods[i]); >+ if (concreteMethod.isOrEnclosedByPrivateType()) { >+ // A subclass inheriting this method and putting it up as the implementation to meet its own >+ // obligations should qualify as a use. >+ concreteMethod.original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed; >+ } > } > > /* >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java,v >retrieving revision 1.113 >diff -u -r1.113 MethodBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java 23 Jan 2009 19:50:22 -0000 1.113 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java 6 Feb 2009 10:51:32 -0000 >@@ -748,6 +748,15 @@ > public final boolean isPrivate() { > return (this.modifiers & ClassFileConstants.AccPrivate) != 0; > } >+ >+/* Answer true if the receiver has private visibility or if any of its enclosing types do. >+*/ >+public final boolean isOrEnclosedByPrivateType() { >+ if ((this.modifiers & ClassFileConstants.AccPrivate) != 0) >+ return true; >+ return this.declaringClass != null && this.declaringClass.isOrEnclosedByPrivateType(); >+} >+ > /* Answer true if the receiver has protected visibility > */ > public final boolean isProtected() { >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java,v >retrieving revision 1.129 >diff -u -r1.129 ReferenceBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java 12 Jan 2009 18:37:16 -0000 1.129 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java 6 Feb 2009 10:51:33 -0000 >@@ -1077,6 +1077,20 @@ > } > > /** >+ * Answer true if the receiver or any of its enclosing types have private visibility >+ */ >+public final boolean isOrEnclosedByPrivateType() { >+ ReferenceBinding type = this; >+ while (type != null) { >+ if ((type.modifiers & ClassFileConstants.AccPrivate) != 0) >+ return true; >+ type = type.enclosingType(); >+ } >+ return false; >+} >+ >+ >+/** > * Answer true if the receiver has protected visibility > */ > public final boolean isProtected() {
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 201912
:
124945
|
125106
|
125569