Problem running application with Enums in IDEA X
If I try to run an application that uses an Enum class in IDEA X, a
VerifyError is thrown. The very same application runs fine in IDEA 9.
Seems a pretty fundamental problem... anything I should be checking or
might be doing wrong?
N.
请先登录再写评论。
I was just about to post this issue, too.
My code uses a Java enum in a groovy class.
Is groovy involved in your project, too?
This is my enum:
public enum AccountState {
ACTIVE("active"),
GRACE_PERIOD("in grace period"),
EXPIRED("expired"),
TECHNICAL_ERROR("technical error");
private final String label;
AccountState(@NotNull String label) {
this.label = label;
}
@NotNull
public String getLabel() {
return label;
}
}
And here's part of the groovy class:
class MockUserDto {
@NotNull
@javax.validation.constraints.NotNull
AccountState accountState = AccountState.ACTIVE;
This causes a compile error:
Error:java.lang.VerifyError: (class: com/lufthansatechnik/engineteardown/dtos/AccountState, method: <init> signature: (Ljava/lang/String;ILjava/lang/String;)V) Accessing value from uninitialized register 4
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2259)
at java.lang.Class.getDeclaredFields(Class.java:1715)
at org.codehaus.groovy.vmplugin.v5.Java5.configureClassNode(Java5.java:313)
at org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:263)
at org.codehaus.groovy.ast.ClassNode.getInterfaces(ClassNode.java:346)
at org.codehaus.groovy.ast.ClassNode.declaresInterface(ClassNode.java:934)
at org.codehaus.groovy.ast.ClassNode.implementsInterface(ClassNode.java:914)
at org.codehaus.groovy.ast.ClassNode.isDerivedFromGroovyObject(ClassNode.java:904)
at org.codehaus.groovy.classgen.AsmClassGenerator.isGroovyObject(AsmClassGenerator.java:2705)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitPropertyExpression(AsmClassGenerator.java:2681)
at org.codehaus.groovy.ast.expr.PropertyExpression.visit(PropertyExpression.java:55)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitAndAutoboxBoolean(AsmClassGenerator.java:4072)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitCastExpression(AsmClassGenerator.java:1885)
at org.codehaus.groovy.classgen.AsmClassGenerator.assignmentCastAndVisit(AsmClassGenerator.java:4011)
at org.codehaus.groovy.classgen.AsmClassGenerator.evaluateEqual(AsmClassGenerator.java:3963)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitBinaryExpression(AsmClassGenerator.java:1440)
at org.codehaus.groovy.ast.expr.BinaryExpression.visit(BinaryExpression.java:49)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitAndAutoboxBoolean(AsmClassGenerator.java:4072)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:1421)
at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40)
at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:35)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:161)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:707)
at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:51)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:97)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:108)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:586)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:562)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructor(ClassCodeVisitorSupport.java:115)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructor(AsmClassGenerator.java:656)
at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1040)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:50)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:275)
at org.codehaus.groovy.control.CompilationUnit$11.call(CompilationUnit.java:757)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:971)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:519)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:497)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:474)
at org.jetbrains.groovy.compiler.rt.GroovyCompilerWrapper.compile(GroovyCompilerWrapper.java:43)
at org.jetbrains.groovy.compiler.rt.GroovycRunner.main(GroovycRunner.java:128)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:592)
at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:75)
I think I isolated the problem:
After removing the @NotNull annotation of the enum constructor's argument everything works fine.
So I guess there's a bug in the instrumentation process.
Vote/comment on http://youtrack.jetbrains.net/issue/IDEA-56943
Hello Nathan,
Which target JDK do you use? Do you use the @NotNull instrumentation?
We've upgraded to ASM 3.3 in IDEA 10 - this is what has likely caused this
issue.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
On 29/07/2010 2:49 PM, Dmitry Jemerov wrote:
>
>
Hi Dmitry,
Yes we do use the @NotNull instrumentation and our target JDK is 1.6.0_17.
I'll vote for and add any other comments to the issue that Stephen raised.
Many thanks,
Nathan.
I have had the same problem with cobertura.
Inner Enums with a constructor that is annotated with NotNull or NonNls
triggers this problem.
But upgrading to ASM 3.3 fixed the issue...
Johannes
On 07/29/2010 05:34 PM, Stephen Friedrich wrote: