Details
Description
When I try to create an enum in Groovysh an exception occurs. Apparently, the enum type is being properly created, but groovysh uselessly tries to instantiate it.
Session transcript:
Groovy Shell (1.1-rc-1, JVM: 1.6.0-b105)
Type 'help' or '\h' for help.
------------------------------------------------------
groovy:000> enum E {A,B,C}
ERROR java.lang.InstantiationException: E
groovy:000> println E.A
A
===> null
BTW you get a similar problem when defining a class with a private default constructor that also cannot be instantiated:
groovy:000> class K { private K(){} }
ERROR java.lang.IllegalAccessException: Class org.codehaus.groovy.runtime.InvokerHelper can not access a member of class K with modifiers "private"
I'm not really sure what the proper fix for this puppy is.... but I have found that if we insert an expression into the bufferer when evaluating (after imports, before user code) that things seem to be much happier.