Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Very confusing exception when using storing an int constant to a long field #16

Open
FroMage opened this issue Jul 17, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@FroMage
Copy link
Member

FroMage commented Jul 17, 2019

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant