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 181611 Details for
Bug 328281
visibility leaks not detected when analyzing unused field in private class
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed alternate patch
patch.txt (text/plain), 10.21 KB, created by
Srikanth Sankaran
on 2010-10-25 02:36:40 EDT
(
hide
)
Description:
Proposed alternate patch
Filename:
MIME Type:
Creator:
Srikanth Sankaran
Created:
2010-10-25 02:36:40 EDT
Size:
10.21 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java,v >retrieving revision 1.181 >diff -u -r1.181 ClassScope.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java 20 Oct 2010 05:46:47 -0000 1.181 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java 25 Oct 2010 06:34:38 -0000 >@@ -148,6 +148,9 @@ > buildMethods(); > > SourceTypeBinding sourceType = this.referenceContext.binding; >+ if (!sourceType.isPrivate() && sourceType.superclass instanceof SourceTypeBinding && sourceType.superclass.isPrivate()) { >+ ((SourceTypeBinding) sourceType.superclass).tagIndirectlyAccessibleFields(); >+ } > if (sourceType.isMemberType() && !sourceType.isLocalType()) > ((MemberTypeBinding) sourceType).checkSyntheticArgsAndFields(); > >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.181 >diff -u -r1.181 SourceTypeBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 15 Sep 2010 15:17:25 -0000 1.181 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 25 Oct 2010 06:34:39 -0000 >@@ -1627,4 +1627,10 @@ > public FieldBinding[] unResolvedFields() { > return this.fields; > } >+public void tagIndirectlyAccessibleFields() { >+ for (int i = 0; i < this.fields.length; i++) { >+ if (!this.fields[i].isPrivate()) >+ this.fields[i].modifiers |= ExtraCompilerModifiers.AccLocallyUsed; >+ } >+} > } >#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.36 >diff -u -r1.36 ProblemTypeAndMethodTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java 20 Oct 2010 05:47:03 -0000 1.36 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java 25 Oct 2010 06:34:44 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 328281 - visibility leaks not detected when analyzing unused field in private class > *******************************************************************************/ > package org.eclipse.jdt.core.tests.compiler.regression; > >@@ -5154,6 +5155,152 @@ > "----------\n"); > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=296660 >+// check independence of textual order >+public void test099a() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\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" + >+ " 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" + >+ " 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" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 2)\n" + >+ " public class C extends B {\n" + >+ " ^\n" + >+ "Access to enclosing constructor X.B() is emulated by a synthetic accessor method\n" + >+ "----------\n" + >+ "2. 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" + >+ "3. 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" + >+ "4. WARNING in X.java (at line 31)\n" + >+ " public void foo(int a) {\n" + >+ " ^^^^^^^^^^\n" + >+ "The method foo(int) from the type X.A is never used locally\n" + >+ "----------\n" + >+ "5. WARNING in X.java (at line 34)\n" + >+ " public void foo(float a) {\n" + >+ " ^^^^^^^^^^^^\n" + >+ "The method foo(float) from the type X.A is never used locally\n" + >+ "----------\n" + >+ "6. WARNING in X.java (at line 37)\n" + >+ " public void foo(boolean a) {\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "The method foo(boolean) from the type X.A is never used locally\n" + >+ "----------\n"); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=296660 >+// check usage via super-call >+public void test099b() { >+ 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" + >+ " super.foo(a);\n" + >+ " }\n" + >+ " public void foo(float a) {\n" + >+ " super.foo(a);\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" + >+ " super.foo(a);\n" + >+ " }\n" + >+ " public void foo(boolean a) {\n" + >+ " super.foo(a);\n" + >+ " }\n" + >+ " public void foo(byte a) {\n" + >+ " System.out.println(\"Hello\");\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. 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" + >+ "2. 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 test100() { > this.runNegativeTest( > new String[] { >Index: src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java,v >retrieving revision 1.26 >diff -u -r1.26 ProgrammingProblemsTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java 22 Oct 2010 22:42:32 -0000 1.26 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java 25 Oct 2010 06:34:45 -0000 >@@ -7,7 +7,9 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >- * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contributions for >+ * bug 185682 - Increment/decrement operators mark local variables as read >+ * bug 328281 - visibility leaks not detected when analyzing unused field in private class > *******************************************************************************/ > package org.eclipse.jdt.core.tests.compiler.regression; > >@@ -2120,5 +2122,30 @@ > true/*shouldFlushOutputDirectory*/, > customOptions); > } >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=328281 >+public void test0052() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR); >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "class X {\n" + >+ " Y y = new Y();\n" + >+ " private class Y {\n" + >+ " int abc;\n" + >+ " Y() {\n" + >+ " abc++;\n" + // not a relevant usage >+ " }\n" + >+ " }\n" + >+ " class Z extends Y {}\n" + // makes 'abc' externally accessible >+ "}" >+ }, >+ "", >+ null/*classLibraries*/, >+ true/*shouldFlushOutputDirectory*/, >+ null/*vmArguments*/, >+ customOptions, >+ null/*requestor*/); >+} > > } >\ No newline at end of file
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 328281
:
181578
|
181581
|
181611
|
193589