为什么我的常规枚举无法工作,甚至无法编译?
我正在运行 Groovy 版本:1.7.0 JVM:1.6.0_17
(更新 - 我刚刚升级到 1.7.1 并得到相同的错误!)
我尝试使用枚举,使用groovy 文档中的确切语法,每次我看到编译错误时:
Groovy:The class java.lang.Enum refers to the class java.lang.Enum and uses 1 parameters, but the referred class takes no parameters
对发生的事情有任何想法吗?
例如:此代码无法编译或运行,并出现上述错误。
enum VehicleStatus { OFF, IDLING, ACCELERATING, DECELARATING }
class Vehicle
{
Long id
Long version
VehicleStatus status
}
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
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这可能是 Netbeans IDE 的错误: http://netbeans.org/bugzilla/show_bug .cgi?id=189275
我发现,运行 Clean 后,错误仍然存在于编辑器中,但实际上并不会在运行时引起问题。
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.
对我有用。
请参阅 http://groovyconsole.appspot.com/script/79003
Works for me.
See http://groovyconsole.appspot.com/script/79003
我刚刚尝试过这个。如果脚本中的唯一代码与您的代码相同,我会收到与您相同的错误。但是,一旦添加
I'm using Groovy 1.7.1 行并从 Netbeans 6.8 中执行脚本,它就会消失。
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
I'm using Groovy 1.7.1 as well and executing the script from within Netbeans 6.8.