Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.8-beta-3
-
Fix Version/s: 1.8-rc-1, 1.9-beta-1
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
If I have a class with it and use the 'log' variable in a static method I get a compilation error.
Log4jTest.groovy:
import groovy.util.logging.Log4j
@Log4j
class TestLog4j {
public static void main(String[] args)
{ log.info "Hello World" }}
Error Message:
Apparent variable 'log' was found in a static scope but doesn't refer to a local variable, static field or class. Possible causes:
You attempted to reference a variable in the binding or an instance variable from a static context.
You misspelled a classname or statically imported field. Please check the spelling.
You attempted to use a method 'log' but left out brackets in a place not allowed by the grammar.
I am not sure if this is related but here is a blog that describes the same problem and his attempt to fix. But his fix does not work either (you will get a NPE if you use his).
http://enfranchisedmind.com/blog/posts/with-log-groovy-ast-transform/