tags:

views:

510

answers:

2

I'm running Groovy Version: 1.7.0 JVM: 1.6.0_17

(Update -- I just upgraded to 1.7.1 and get the same errors!)

I've tried to use enums, using the exact syntax from the groovy documentation, and each time I see the compile error:

Groovy:The class java.lang.Enum refers to the class java.lang.Enum and uses 1 parameters, but the referred class takes no parameters

Any ideas on what's going on?

For example: This code won't compile or run, and gets the error above.

enum VehicleStatus { OFF, IDLING, ACCELERATING, DECELARATING }

class Vehicle
{
    Long id
    Long version
    VehicleStatus status
}
+2  A: 

Works for me.

See http://groovyconsole.appspot.com/script/79003

Enrique Medina
+1  A: 

I just tried this. I receive the same error as you if the only code in the script is the same as yours. However, it goes away once you add the line

def a = new Vehicle(id: 1, version: 0, status: VehicleStatus.IDLING) 

I'm using Groovy 1.7.1 as well and executing the script from within Netbeans 6.8.

ssakl
Thanks! It doesn't solve the mystery, but at least I have a workaround. I wonder if it's a netbeans problem, as I'm using netbeans, too.
ראובן
@ ראובן - It doesn't even need to be that particular line. Simply adding an assert() outside of the class has the same result. Unfortunately, I haven't used Groovy enough to know why that is.
ssakl