Annotations with source retention are generated in bytecode

Issue #281 resolved
Jesper Öqvist created an issue

ExtendJ 8.1.0-27-gcd7effa Java SE 5

The Trait annotation in the following example should not be generated in the bytecode output for the class An6:

import java.lang.annotation.*;

@Trait("magical") public class An6 {
  public static void main(String[] args) {
  }
}

@Retention(RetentionPolicy.SOURCE)
@interface Trait {
  String value() default "";
}

Expected result: no annotations for class An6 in bytecode.

Actual result: the bytecode contains the Trait annotation:

javap -v tmp/An6.class 
Classfile tmp/An6.class
  Last modified Jan 8, 2018; size 405 bytes
  MD5 checksum 9592f4fd0641b17a193026c2b216286c
  Compiled from "An6.java"
public class An6
  SourceFile: "An6.java"
  RuntimeInvisibleAnnotations:
    0: #21(#22=s#23)

Comments (2)

  1. Log in to comment