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 188296 Details for
Bug 335780
Compiler says a method can be potentially static but this method contains 'this'
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
updated patch
patch335780.txt (text/plain), 4.25 KB, created by
Ayushman Jain
on 2011-02-04 03:19:35 EST
(
hide
)
Description:
updated patch
Filename:
MIME Type:
Creator:
Ayushman Jain
Created:
2011-02-04 03:19:35 EST
Size:
4.25 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/ThisReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ThisReference.java,v >retrieving revision 1.37 >diff -u -r1.37 ThisReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ThisReference.java 7 Mar 2009 01:08:07 -0000 1.37 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ThisReference.java 4 Feb 2011 08:16:19 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -127,4 +127,13 @@ > visitor.visit(this, blockScope); > visitor.endVisit(this, blockScope); > } >+ >+ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { >+ if (!isImplicitThis()) { >+ // explicit this reference, not allowed in static context >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=335780 >+ currentScope.resetEnclosingMethodStaticFlag(); >+ } >+ return super.analyseCode(currentScope, flowContext, flowInfo); >+ } > } >#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.41 >diff -u -r1.41 ProblemTypeAndMethodTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java 3 Feb 2011 13:29:07 -0000 1.41 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java 4 Feb 2011 08:16:21 -0000 >@@ -6868,4 +6868,65 @@ > compilerOptions /* custom options */ > ); > } >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=335780 >+// For this reference as an argument of a message send, method can't be static >+public void test124a() { >+ 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_ReportNonStaticAccessToStatic, CompilerOptions.IGNORE); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public void method1() {\n" + // don't warn >+ " Foo.m(this);\n" + >+ " }\n" + >+ "static class Foo{\n" + >+ " static void m(X bug) {\n" + >+ " \n" + >+ " }\n" + >+ "}\n" + >+ "}" >+ }, >+ "", >+ null /* no extra class libraries */, >+ true /* flush output directory */, >+ compilerOptions /* custom options */ >+ ); >+} >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=335780 >+// For this reference as an argument of a message send, method can't be static >+public void test124b() { >+ 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_ReportNonStaticAccessToStatic, CompilerOptions.IGNORE); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public static X xField;" + >+ " public void method1() {\n" + // don't warn >+ " Foo.m(this.xField);\n" + >+ " }\n" + >+ "static class Foo{\n" + >+ " static void m(X bug) {\n" + >+ " \n" + >+ " }\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 335780
:
188029
| 188296