Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.5
-
None
-
Mac OS X Leopard
Java 1.5.0_13
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.
Attachments
Attachments
Issue Links
- depends upon
-
GROOVY-3100 allow this in static context again
- Closed