ClassFileAnalyzer (Can) |
Home |
Example: TestCanRuntimeVisibleAnnotations3Test directive
/* TestCanAnnotation2.java */ import java.lang.annotation.*; @Retention(value = RetentionPolicy.RUNTIME) @Target(value = { ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.LOCAL_VARIABLE, ElementType.METHOD, ElementType.PACKAGE, ElementType.PARAMETER, ElementType.TYPE }) public @interface TestCanAnnotation2 { enum Direction { NORTH, SOUTH, WEST, EAST }; Direction value1(); Class value2(); Class<? extends Number>[] value3(); }
/* TestCanRuntimeVisibleAnnotations3.java */ @TestCanAnnotation2(value1 = TestCanAnnotation2.Direction.NORTH, value2 = Object.class, value3 = { Byte.class, Integer.class } ) public class TestCanRuntimeVisibleAnnotations3 { @TestCanAnnotation2(value1 = TestCanAnnotation2.Direction.SOUTH, value2 = String.class, value3 = { Float.class, Double.class } ) String str = "Hello"; @TestCanAnnotation2(value1 = TestCanAnnotation2.Direction.WEST, value2 = StringBuffer.class, value3 = { java.math.BigInteger.class } ) public void method1(String s) { System.out.println(str + s); } public static void main(String[] args) { TestCanRuntimeVisibleAnnotations3 tcrva = new TestCanRuntimeVisibleAnnotations3(); tcrva.method1(" Java!"); } }
> javac TestCanAnnotation2.java > javac TestCanRuntimeVisibleAnnotations3.java > java ClassFileAnalyzer TestCanAnnotation2.class > java ClassFileAnalyzer TestCanRuntimeVisibleAnnotations3.class
; TestCanAnnotation2.j
; Generated by ClassFileAnalyzer (Can)
; Analyzer and Disassembler for Java class files
; (Jasmin syntax 2, http://jasmin.sourceforge.net)
;
; ClassFileAnalyzer, version 0.7.0
.bytecode 50.0
.source TestCanAnnotation2.java
.interface public abstract annotation TestCanAnnotation2
; Flag ACC_SUPER not set, see JVM spec
.super java/lang/Object
.implements java/lang/annotation/Annotation
.annotation visible Ljava/lang/annotation/Retention;
value e Ljava/lang/annotation/RetentionPolicy; = RUNTIME
.end annotation
.annotation visible Ljava/lang/annotation/Target;
; one line
value [e Ljava/lang/annotation/ElementType; = ANNOTATION_TYPE CONSTRUCTOR
FIELD LOCAL_VARIABLE METHOD PACKAGE PARAMETER TYPE
.end annotation
; one line
.inner class public static final enum Direction
inner TestCanAnnotation2$Direction outer TestCanAnnotation2
.method public abstract value1()LTestCanAnnotation2$Direction;
.end method
.method public abstract value2()Ljava/lang/Class;
.end method
.method public abstract value3()[Ljava/lang/Class;
.signature "()[Ljava/lang/Class<+Ljava/lang/Number;>;"
.end method
; TestCanRuntimeVisibleAnnotations3.j
; Generated by ClassFileAnalyzer (Can)
; Analyzer and Disassembler for Java class files
; (Jasmin syntax 2, http://jasmin.sourceforge.net)
;
; ClassFileAnalyzer, version 0.7.0
.bytecode 50.0
.source TestCanRuntimeVisibleAnnotations3.java
.class public TestCanRuntimeVisibleAnnotations3
.super java/lang/Object
.annotation visible LTestCanAnnotation2;
value1 e LTestCanAnnotation2$Direction; = NORTH
value2 c = Ljava/lang/Object;
value3 [c = Ljava/lang/Byte; Ljava/lang/Integer;
.end annotation
; one line
.inner class public static final enum Direction
inner TestCanAnnotation2$Direction
outer TestCanAnnotation2
.field str Ljava/lang/String;
.annotation visible LTestCanAnnotation2;
value1 e LTestCanAnnotation2$Direction; = SOUTH
value2 c = Ljava/lang/String;
value3 [c = Ljava/lang/Float; Ljava/lang/Double;
.end annotation
.end field
.method public <init>()V
.limit stack 2
.limit locals 1
.line 8
0: aload_0
1: invokespecial java/lang/Object/<init>()V
.line 11
4: aload_0
5: ldc "Hello"
7: putfield TestCanRuntimeVisibleAnnotations3/str Ljava/lang/String;
10: return
.end method
.method public method1(Ljava/lang/String;)V
.limit stack 3
.limit locals 2
.line 23
0: getstatic java/lang/System/out Ljava/io/PrintStream;
3: new java/lang/StringBuilder
6: dup
7: invokespecial java/lang/StringBuilder/<init>()V
10: aload_0
11: getfield TestCanRuntimeVisibleAnnotations3/str Ljava/lang/String;
; one line
14: invokevirtual java/lang/StringBuilder/append(Ljava/lang/String;)
Ljava/lang/StringBuilder;
17: aload_1
; one line
18: invokevirtual java/lang/StringBuilder/append(Ljava/lang/String;)
Ljava/lang/StringBuilder;
21: invokevirtual java/lang/StringBuilder/toString()Ljava/lang/String;
24: invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
.line 24
27: return
.annotation visible LTestCanAnnotation2;
value1 e LTestCanAnnotation2$Direction; = WEST
value2 c = Ljava/lang/StringBuffer;
value3 [c = Ljava/math/BigInteger;
.end annotation
.end method
.method public static main([Ljava/lang/String;)V
.limit stack 2
.limit locals 2
.line 28
0: new TestCanRuntimeVisibleAnnotations3
3: dup
4: invokespecial TestCanRuntimeVisibleAnnotations3/<init>()V
7: astore_1
.line 30
8: aload_1
9: ldc " Java!"
11: invokevirtual TestCanRuntimeVisibleAnnotations3/method1(Ljava/lang/String;)V
.line 31
14: return
.end method
|