Reputation: 49
I am new to groovy and I made a java class that has some constansts.
public class test{
public static final constant1 ="hello"
}
now in my groovy code, I just want to put that constant in a map.
Map<String, String> map1 = new HashMap();
map1.put("hello", test.constant1);
I am getting a groovy.lang.MissingPropertyException error that says no such property: test for class.
What is this error saying?
Upvotes: 1
Views: 1919
Reputation: 8734
So oddly enough, groovy, unlike Java, has difficulty resolving a class name if it is lowercase. Relevant mailing list and this Jira.
Crux of the issue: Compiler related, specifically in producing a grammar that's not ambiguous since variable names, class names, and method names can all share the same context. Groovy seems to rely on the traditional Java convention of a class or type starting with an uppercase letter to reduce the ambiguity.
So capitalize that 't' in 'test' and you should be off to the races! What a silly bug
Upvotes: 1