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 203856 Details for
Bug 354502
Incorrect Compiler Warning: "Method can be declared as static"
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch under test
patch354502.txt (text/plain), 3.25 KB, created by
Ayushman Jain
on 2011-09-22 14:41:27 EDT
(
hide
)
Description:
patch under test
Filename:
MIME Type:
Creator:
Ayushman Jain
Created:
2011-09-22 14:41:27 EDT
Size:
3.25 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java,v >retrieving revision 1.103 >diff -u -r1.103 QualifiedAllocationExpression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 28 Jul 2011 17:07:04 -0000 1.103 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 22 Sep 2011 18:38:50 -0000 >@@ -59,6 +59,11 @@ > // analyse the enclosing instance > if (this.enclosingInstance != null) { > flowInfo = this.enclosingInstance.analyseCode(currentScope, flowContext, flowInfo); >+ } else { >+ if (this.binding.declaringClass.superclass().isMemberType() && !this.binding.declaringClass.superclass().isStatic()) { >+ // creating an anonymous type of a non-static member type without an enclosing instance of parent type >+ currentScope.resetEnclosingMethodStaticFlag(); >+ } > } > > // check captured variables are initialized in current context (26134) >#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.44 >diff -u -r1.44 ProblemTypeAndMethodTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java 28 Jul 2011 17:06:26 -0000 1.44 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java 22 Sep 2011 18:38:57 -0000 >@@ -7076,4 +7076,39 @@ > compilerOptions /* custom options */ > ); > } >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=354502 >+// Anonymous class instantiation of a non-static member type, method can't be static >+public void test354502() { >+ if (this.complianceLevel < ClassFileConstants.JDK1_5) >+ return; >+ Map compilerOptions = getCompilerOptions(); >+ compilerOptions.put(CompilerOptions.OPTION_ReportMethodCanBeStatic, CompilerOptions.ERROR); >+ compilerOptions.put(CompilerOptions.OPTION_ReportMethodCanBePotentiallyStatic, CompilerOptions.ERROR); >+ compilerOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.IGNORE); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public abstract class Abstract{}\n" + >+ " public static abstract class Abstract2{}\n" + >+ " private void method1() {\n" + // don't warn >+ " new Abstract() {};\n" + >+ " }\n" + >+ " private void method2() {\n" + // warn >+ " new Abstract2() {};\n" + >+ " }\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 7)\n" + >+ " private void method2() {\n" + >+ " ^^^^^^^^^\n" + >+ "The method method2() from the type X can be declared as static\n" + >+ "----------\n", >+ null /* no extra class libraries */, >+ true /* flush output directory */, >+ compilerOptions /* custom options */ >+ ); >+} > }
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 354502
:
201315
| 203856