You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2019/11/27 18:50:00 UTC

[jira] [Closed] (GROOVY-9185) groovyc doesn't keep RetentionPolicy in generated bytecode

     [ https://issues.apache.org/jira/browse/GROOVY-9185?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eric Milles closed GROOVY-9185.
-------------------------------
    Resolution: Not A Problem

RetentionPolicy.SOURCE is the JVM's default.  RetentionPolicy.CLASS and RetentionPolicy.RUNTIME are written to the annotation class file.

> groovyc doesn't keep RetentionPolicy in generated bytecode
> ----------------------------------------------------------
>
>                 Key: GROOVY-9185
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9185
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 2.5.7
>            Reporter: zhb
>            Priority: Major
>
>  
> {code:java}
> $ groovyc -v
> Groovy compiler version 2.5.7
> Copyright 2003-2019 The Apache Software Foundation. http://groovy-lang.org/
> -------------------------------------------------------------------
> $ cat MyAnnotation.groovy
> import java.lang.annotation.Retention
> import java.lang.annotation.RetentionPolicy
> @Retention(RetentionPolicy.SOURCE)
> @interface MyAnnotation {}
> -------------------------------------------------------------------
> $ groovyc MyAnnotation.groovy && javap -private -v MyAnnotation
> Classfile /Users/zhb/Projects/tmp/groovy-anno/MyAnnotation.class
> Last modified 3 Jul 2019; size 146 bytes
> MD5 checksum 485f011b0c78ff7b08bd0e03b1b429cd
> Compiled from "MyAnnotation.groovy"
> public interface MyAnnotation extends java.lang.annotation.Annotation
> minor version: 0
> major version: 51
> flags: (0x2601) ACC_PUBLIC, ACC_INTERFACE, ACC_ABSTRACT, ACC_ANNOTATION
> this_class: #2 // MyAnnotation
> super_class: #4 // java/lang/Object
> interfaces: 1, fields: 0, methods: 0, attributes: 1
> Constant pool:
> #1 = Utf8 MyAnnotation
> #2 = Class #1 // MyAnnotation
> #3 = Utf8 java/lang/Object
> #4 = Class #3 // java/lang/Object
> #5 = Utf8 java/lang/annotation/Annotation
> #6 = Class #5 // java/lang/annotation/Annotation
> #7 = Utf8 MyAnnotation.groovy
> #8 = Utf8 SourceFile
> {
> }
> SourceFile: "MyAnnotation.groovy"
> -------------------------------------------------------------------
> $ cat MyJavaAnnotation.java
> import java.lang.annotation.Retention;
> import java.lang.annotation.RetentionPolicy;
> @Retention(RetentionPolicy.SOURCE)
> @interface MyJavaAnnotation {}
> -------------------------------------------------------------------
> $ javac MyJavaAnnotation.java && javap -private -v MyJavaAnnotation
> Classfile /Users/zhb/Projects/tmp/groovy-anno/MyJavaAnnotation.class
> Last modified 3 Jul 2019; size 292 bytes
> MD5 checksum c8ea8afe8f9fe148925db48177207f01
> Compiled from "MyJavaAnnotation.java"
> interface MyJavaAnnotation extends java.lang.annotation.Annotation
> minor version: 0
> major version: 55
> flags: (0x2600) ACC_INTERFACE, ACC_ABSTRACT, ACC_ANNOTATION
> this_class: #1 // MyJavaAnnotation
> super_class: #2 // java/lang/Object
> interfaces: 1, fields: 0, methods: 0, attributes: 2
> Constant pool:
> #1 = Class #11 // MyJavaAnnotation
> #2 = Class #12 // java/lang/Object
> #3 = Class #13 // java/lang/annotation/Annotation
> #4 = Utf8 SourceFile
> #5 = Utf8 MyJavaAnnotation.java
> #6 = Utf8 RuntimeVisibleAnnotations
> #7 = Utf8 Ljava/lang/annotation/Retention;
> #8 = Utf8 value
> #9 = Utf8 Ljava/lang/annotation/RetentionPolicy;
> #10 = Utf8 SOURCE
> #11 = Utf8 MyJavaAnnotation
> #12 = Utf8 java/lang/Object
> #13 = Utf8 java/lang/annotation/Annotation
> {
> }
> SourceFile: "MyJavaAnnotation.java"
> RuntimeVisibleAnnotations:
> 0: #7(#8=e#9.#10)
> java.lang.annotation.Retention(
> value=Ljava/lang/annotation/RetentionPolicy;.SOURCE
> )
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)