gizmo
gizmo copied to clipboard
Very confusing exception when using storing an `int` constant to a `long` field
This code exhibits the exception:
public class GizmoTest {
public static class MyEntity {
boolean isPersistent;
long version;
}
public static void main(String[] args) {
try(ClassCreator modelClass = ClassCreator.builder().className("test")
.classOutput((foo, bar) -> {
System.err.println("Printing "+foo+": "+bar);
})
.build()){
FieldDescriptor fieldDescriptor = FieldDescriptor.of(MyEntity.class, "version", long.class);
try(MethodCreator creator = modelClass.getMethodCreator("foo", void.class, MyEntity.class)){
ResultHandle entityParam = creator.getMethodParam(0);
creator.writeInstanceField(fieldDescriptor, entityParam, creator.load(0));
creator.returnValue(creator.loadNull());
}
}
}
}
When running it, I get:
Exception in thread "main" java.lang.NegativeArraySizeException
at org.objectweb.asm.Frame.merge(Frame.java:1222)
at org.objectweb.asm.MethodWriter.computeAllFrames(MethodWriter.java:1607)
at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1543)
at org.objectweb.asm.MethodVisitor.visitMaxs(MethodVisitor.java:762)
at io.quarkus.gizmo.MethodCreatorImpl.write(MethodCreatorImpl.java:107)
at io.quarkus.gizmo.ClassCreator.close(ClassCreator.java:173)
at io.quarkus.panache.rx.deployment.GizmoTest.main(GizmoTest.java:36)
Which is very hard to explain the cause is the load(0)
which should be a load(0l)