I just added support for annotation printing to the
gnu.bytecode classfile-printer. Specifically, it now prints
RuntimeVisibleAnnotations and RuntimeInvisibleAnnotations
attributes rather nicely.
This is only in SVN so far - here are instructions for getting it:
http://www.gnu.org/software/kawa/Getting-Kawa.html
Suggestions and bug-reports appreciated!
$ java gnu.bytecode.dump 'jar:file:rt.jar!java.lang.SuppressWarnings'
Reading .class from jar:file:rt.jar!/java/lang/SuppressWarnings.class.
Access flags: public interface abstract annotation
This class: java.lang.SuppressWarnings super: java.lang.Object
Interfaces (count: 1):
- Implements: java.lang.annotation.Annotation
Fields (count: 0):
Methods (count: 1):
Method name:"value" public abstract Signature: ()java.lang.String[]
Attributes (count: 2):
Attribute "SourceFile", length:2, "SuppressWarnings.java"
Attribute "RuntimeVisibleAnnotations", length:52, number of entries: 2
@java.lang.annotation.Target
"value" => array length:6
0: enum[java.lang.annotation.ElementType "TYPE"]
1: enum[java.lang.annotation.ElementType "FIELD"]
2: enum[java.lang.annotation.ElementType "METHOD"]
3: enum[java.lang.annotation.ElementType "PARAMETER"]
4: enum[java.lang.annotation.ElementType "CONSTRUCTOR"]
5: enum[java.lang.annotation.ElementType "LOCAL_VARIABLE"]
@java.lang.annotation.Retention
"value" => enum[java.lang.annotation.RetentionPolicy "SOURCE"]
-verbose also prints the constant pool, and constant pool indexes:
$ cat foo.java
import javax.xml.bind.annotation.*;
public class foo
{
@XmlElement(nillable=true, name="itemprice",
type=java.math.BigDecimal.class)
public java.math.BigDecimal price;
}
$ java gnu.bytecode.dump -verbose foo.class
Reading .class from /tmp/foo.class.
Classfile format major version: 50, minor version: 0.
#1: Method class: #3=java.lang.Object name_and_type: #19=<<init> ()void>
#2: Class name: #20=foo
#3: Class name: #21=java.lang.Object
#4: Utf8: "price"
#5: Utf8: "Ljava/math/BigDecimal;"
#6: Utf8: "RuntimeVisibleAnnotations"
#7: Utf8: "Ljavax/xml/bind/annotation/XmlElement;"
#8: Utf8: "nillable"
#9: Integer 1=0x1
#10: Utf8: "name"
#11: Utf8: "itemprice"
#12: Utf8: "type"
#13: Utf8: "<init>"
#14: Utf8: "()V"
#15: Utf8: "Code"
#16: Utf8: "LineNumberTable"
#17: Utf8: "SourceFile"
#18: Utf8: "foo.java"
#19: NameAndType name: #13=<init>, signature: #14=()void
#20: Utf8: "foo"
#21: Utf8: "java/lang/Object"
Access flags: public super
This class: #2=foo super: #3=java.lang.Object
Interfaces (count: 0):
Fields (count: 1):
Field name: #4=price public Signature: #5=java.math.BigDecimal
Attribute "RuntimeVisibleAnnotations", length:21, number of entries: 1
#[email protected]
#8="nillable" => [kind:Z] #9=true
#10="name" => [kind:s] #11="itemprice"
#12="type" => [kind:c] #5=java.math.BigDecimal
Methods (count: 1):
Method name:#13="<init>" public Signature: #14=()void
Attribute "Code", length:29, max_stack:1, max_locals:1, code_length:5
0: aload_0
1: invokespecial #1=<Method java.lang.Object.<init> ()void>
4: return
Attribute "LineNumberTable", length:6, count: 1
line: 2 at pc: 0
Attributes (count: 1):
Attribute "SourceFile", length:2, #18="foo.java"
--
--Per Bothner
[email protected] http://per.bothner.com/
--
You received this message because you are subscribed to the Google Groups "JVM
Languages" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jvm-languages?hl=en.