Annotation bytecode error

Issue #60 resolved
Jesper Öqvist created an issue

JastAddJ 7.1.1-150-g198ecc4 Java SE 7 generates incorrect bytecode for the following test case:

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@interface Timeout {
        long timeout() default 0L;
}
public class Test {
        @Timeout(timeout = 100)
        void m() {
        }
}

Accessing the timeout value for m via reflection raises the following exception:

Code execution failed when expected to pass:
Exception in thread "main" java.lang.annotation.AnnotationTypeMismatchException: Incorrectly typed data found for annotation element public abstract long Timeout.timeout() (Found data of type class java.lang.Integer[100])

Comments (2)

  1. Jesper Öqvist reporter

    This error seems to be caused by an integer being placed in the constant pool rather than a long constant value for the annotation element value.

  2. Log in to comment