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

Having Autowired annotation in constructor throws Constant pool index out of bounds when Vaadin class is hotswapped #625

Open
abdullahtellioglu opened this issue Jan 13, 2025 · 0 comments

Comments

@abdullahtellioglu
Copy link

In a vaadin project, a view that has another service injected with @Autowired annotation fails after deleting/adding a component due to the following exceptions. Although, it works when Autowired annotation is removed.

Hotswap version is: HOTSWAP AGENT: 14:32:18.991 INFO (org.hotswap.agent.HotswapAgent) - Loading Hotswap agent {2.0.1} - unlimited runtime class redefinition.

Caused by: java.lang.annotation.AnnotationFormatError: java.lang.IllegalArgumentException: Constant pool index out of bounds
	at java.base/sun.reflect.annotation.AnnotationParser.parseParameterAnnotations(AnnotationParser.java:168) ~[na:na]
	at java.base/java.lang.reflect.Executable.parseParameterAnnotations(Executable.java:84) ~[na:na]
	at java.base/java.lang.reflect.Executable.sharedGetParameterAnnotations(Executable.java:576) ~[na:na]
	at java.base/java.lang.reflect.Constructor.getParameterAnnotations(Constructor.java:618) ~[na:na]

Also,

Caused by: java.lang.reflect.GenericSignatureFormatError: Signature Parse error: Expected Field Type Signature
	Remaining input: (Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite;
	at java.base/sun.reflect.generics.parser.SignatureParser.error(SignatureParser.java:124) ~[na:na]
	at java.base/sun.reflect.generics.parser.SignatureParser.parseFieldTypeSignature(SignatureParser.java:291) ~[na:na]
	at java.base/sun.reflect.generics.parser.SignatureParser.parseFieldTypeSignature(SignatureParser.java:277) ~[na:na]
	at java.base/sun.reflect.generics.parser.SignatureParser.parseTypeSignature(SignatureParser.java:469) ~[na:na]
	at java.base/sun.reflect.generics.parser.SignatureParser.parseTypeSig(SignatureParser.java:188) ~[na:na]

An example view that has a parameter injected in the constructor with Autowired annotation.

    public MainView(@Autowired GreetService service) {
        TextField textField = new TextField("Your name");
        textField.addClassName("bordered");

        Button button = new Button("Say hello", e -> {
            add(new Paragraph(service.greet(textField.getValue())));
        });
        button.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
        button.addClickShortcut(Key.ENTER);
        addClassName("centered-content");
        
        add(textField, button);
    }

After some investigation, I found out that parameterAnnotation byte codes inside org.springframework.core.MethodParameter.getParameterAnnotations differs

Broken one:
broken

Working one:
working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants