Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.5
-
Fix Version/s: 1.6-rc-1, 1.5.8, 1.7-beta-1
-
Component/s: bytecode, class generator
-
Labels:None
-
Environment:Mac OS X Leopard
Java 1.5.0_13
-
Testcase included:yes
-
Number of attachments :
Description
Like Java, Groovy allows for static methods to be called in different ways. Surprisingly, not all of them work for private static methods. Specifically:
class Test {
// all errors go away if method is declared non-private
private static foo() {}
static callFooFromStaticMethod() {
Test.foo() // ok
foo() // ok
this.foo() // ok
new Test().foo() // java.lang.IncompatibleClassChangeError
}
def callFooFromInstanceMethod() {
Test.foo() // ok
foo() // java.lang.IncompatibleClassChangeError
this.foo() // java.lang.IncompatibleClassChangeError
new Test().foo() // java.lang.IncompatibleClassChangeError
}
}
Test.callFooFromStaticMethod()
new Test().callFooFromInstanceMethod()
As indicated, several invocations throw an IncompatibleClassChangeError. I would expect all of them to succeed, just as they do for non-private static methods.
Issue Links
- depends upon
-
GROOVY-3100
allow this in static context again
-