Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why don't my groovy enums work, or even compile?

Tags:

enums

groovy

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 Answers

This may be an error with the Netbeans IDE: http://netbeans.org/bugzilla/show_bug.cgi?id=189275

I've found that, after running Clean, the error persists in the editor, but does not actually cause a problem at runtime.

like image 146
Spike Williams Avatar answered Nov 20 '25 20:11

Spike Williams


Works for me.

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

like image 24
Enrique Medina Avatar answered Nov 20 '25 18:11

Enrique Medina