| ClassFileAnalyzer (Can) |
| Home |
|
Example: TestCanRuntimeVisibleAnnotations4Test directive
/* TestCanAnnotation.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 TestCanAnnotation {
byte byteValue();
char[] charValue();
double doubleValue();
float floatValue();
int[] intValue();
long longValue();
short shortValue();
boolean[] booleanValue();
String[] stringValue();
}
/* 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();
}
/* TestCanAnnotation3.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 TestCanAnnotation3 {
TestCanAnnotation[] value1();
TestCanAnnotation2[] value2();
}
/* TestCanRuntimeVisibleAnnotations4.java */
@TestCanAnnotation3(
value1 = { @TestCanAnnotation(byteValue = 1,
charValue = { 'a', 'b' },
doubleValue = 1.23,
floatValue = 4.56f,
intValue = { 2, 3, 4},
longValue = 5,
shortValue = 6,
booleanValue = { true, false },
stringValue = { "Hello", "Can!" }
),
@TestCanAnnotation(byteValue = 2,
charValue = { 'c', 'd' }
),
@TestCanAnnotation(byteValue = 3)
},
value2 = { @TestCanAnnotation2(value1 = TestCanAnnotation2.Direction.NORTH,
value2 = Object.class,
value3 = { Byte.class, Integer.class }
),
@TestCanAnnotation2(value1 = TestCanAnnotation2.Direction.SOUTH,
value2 = StringBuffer.class,
value3 = { Float.class, Double.class }
)
}
)
public class TestCanRuntimeVisibleAnnotations4 {
@TestCanAnnotation3(
value1 = { @TestCanAnnotation(byteValue = 1,
charValue = { 'a', 'b' },
doubleValue = 1.23,
floatValue = 4.56f,
intValue = { 2, 3, 4},
longValue = 5,
shortValue = 6,
booleanValue = { true, false },
stringValue = { "Hello", "Can!" }
),
@TestCanAnnotation(byteValue = 2,
charValue = { 'c', 'd' }
),
@TestCanAnnotation(byteValue = 3)
},
value2 = { @TestCanAnnotation2(value1 = TestCanAnnotation2.Direction.NORTH,
value2 = Object.class,
value3 = { Byte.class, Integer.class }
),
@TestCanAnnotation2(value1 = TestCanAnnotation2.Direction.SOUTH,
value2 = StringBuffer.class,
value3 = { Float.class, Double.class }
)
}
)
String str = "Hello";
@TestCanAnnotation3(
value1 = { @TestCanAnnotation(byteValue = 1,
charValue = { 'a', 'b' },
doubleValue = 1.23,
floatValue = 4.56f,
intValue = { 2, 3, 4},
longValue = 5,
shortValue = 6,
booleanValue = { true, false },
stringValue = { "Hello", "Can!" }
),
@TestCanAnnotation(byteValue = 2,
charValue = { 'c', 'd' }
),
@TestCanAnnotation(byteValue = 3)
},
value2 = { @TestCanAnnotation2(value1 = TestCanAnnotation2.Direction.NORTH,
value2 = Object.class,
value3 = { Byte.class, Integer.class }
),
@TestCanAnnotation2(value1 = TestCanAnnotation2.Direction.SOUTH,
value2 = StringBuffer.class,
value3 = { Float.class, Double.class }
)
}
)
public void method1(String s) {
System.out.println(str + s);
}
public static void main(String[] args) {
TestCanRuntimeVisibleAnnotations4 tcrva =
new TestCanRuntimeVisibleAnnotations4();
tcrva.method1(" Java!");
}
}
> javac TestCanAnnotation.java > javac TestCanAnnotation2.java > javac TestCanAnnotation3.java > javac TestCanRuntimeVisibleAnnotations4.java > java ClassFileAnalyzer TestCanAnnotation.class > java ClassFileAnalyzer TestCanAnnotation2.class > java ClassFileAnalyzer TestCanAnnotation3.class > java ClassFileAnalyzer TestCanRuntimeVisibleAnnotations4.class
; TestCanAnnotation.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 TestCanAnnotation.java
.interface public abstract annotation TestCanAnnotation
; 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
.method public abstract byteValue()B
.end method
.method public abstract charValue()[C
.end method
.method public abstract doubleValue()D
.end method
.method public abstract floatValue()F
.end method
.method public abstract intValue()[I
.end method
.method public abstract longValue()J
.end method
.method public abstract shortValue()S
.end method
.method public abstract booleanValue()[Z
.end method
.method public abstract stringValue()[Ljava/lang/String;
.end method
; 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
; TestCanAnnotation3.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 TestCanAnnotation3.java
.interface public abstract annotation TestCanAnnotation3
; 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
.method public abstract value1()[LTestCanAnnotation;
.end method
.method public abstract value2()[LTestCanAnnotation2;
.end method
; TestCanRuntimeVisibleAnnotations4.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 TestCanRuntimeVisibleAnnotations4.java
.class public TestCanRuntimeVisibleAnnotations4
.super java/lang/Object
.annotation visible LTestCanAnnotation3;
value1 [@ LTestCanAnnotation; = .annotation
byteValue B = 1
charValue [C = 97 98
doubleValue D = 1.23
floatValue F = 4.56
intValue [I = 2 3 4
longValue J = 5
shortValue S = 6
booleanValue [Z = 1 0
stringValue [s = "Hello" "Can!"
.end annotation
.annotation
byteValue B = 2
charValue [C = 99 100
.end annotation
.annotation
byteValue B = 3
.end annotation
value2 [@ LTestCanAnnotation2; = .annotation
value1 e LTestCanAnnotation2$Direction; = NORTH
value2 c = Ljava/lang/Object;
value3 [c = Ljava/lang/Byte; Ljava/lang/Integer;
.end annotation
.annotation
value1 e LTestCanAnnotation2$Direction; = SOUTH
value2 c = Ljava/lang/StringBuffer;
value3 [c = Ljava/lang/Float; Ljava/lang/Double;
.end annotation
.end annotation
; one line
.inner class public static final enum Direction
inner TestCanAnnotation2$Direction
outer TestCanAnnotation2
.field str Ljava/lang/String;
.annotation visible LTestCanAnnotation3;
value1 [@ LTestCanAnnotation; = .annotation
byteValue B = 1
charValue [C = 97 98
doubleValue D = 1.23
floatValue F = 4.56
intValue [I = 2 3 4
longValue J = 5
shortValue S = 6
booleanValue [Z = 1 0
stringValue [s = "Hello" "Can!"
.end annotation
.annotation
byteValue B = 2
charValue [C = 99 100
.end annotation
.annotation
byteValue B = 3
.end annotation
value2 [@ LTestCanAnnotation2; = .annotation
value1 e LTestCanAnnotation2$Direction; = NORTH
value2 c = Ljava/lang/Object;
value3 [c = Ljava/lang/Byte; Ljava/lang/Integer;
.end annotation
.annotation
value1 e LTestCanAnnotation2$Direction; = SOUTH
value2 c = Ljava/lang/StringBuffer;
value3 [c = Ljava/lang/Float; Ljava/lang/Double;
.end annotation
.end annotation
.end field
.method public <init>()V
.limit stack 2
.limit locals 1
.line 29
0: aload_0
1: invokespecial java/lang/Object/<init>()V
.line 32
4: aload_0
5: ldc "Hello"
7: putfield TestCanRuntimeVisibleAnnotations4/str Ljava/lang/String;
10: return
.end method
.method public method1(Ljava/lang/String;)V
.limit stack 3
.limit locals 2
.line 88
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 TestCanRuntimeVisibleAnnotations4/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 89
27: return
.annotation visible LTestCanAnnotation3;
value1 [@ LTestCanAnnotation; = .annotation
byteValue B = 1
charValue [C = 97 98
doubleValue D = 1.23
floatValue F = 4.56
intValue [I = 2 3 4
longValue J = 5
shortValue S = 6
booleanValue [Z = 1 0
stringValue [s = "Hello" "Can!"
.end annotation
.annotation
byteValue B = 2
charValue [C = 99 100
.end annotation
.annotation
byteValue B = 3
.end annotation
value2 [@ LTestCanAnnotation2; = .annotation
value1 e LTestCanAnnotation2$Direction; = NORTH
value2 c = Ljava/lang/Object;
value3 [c = Ljava/lang/Byte; Ljava/lang/Integer;
.end annotation
.annotation
value1 e LTestCanAnnotation2$Direction; = SOUTH
value2 c = Ljava/lang/StringBuffer;
value3 [c = Ljava/lang/Float; Ljava/lang/Double;
.end annotation
.end annotation
.end method
.method public static main([Ljava/lang/String;)V
.limit stack 2
.limit locals 2
.line 93
0: new TestCanRuntimeVisibleAnnotations4
3: dup
4: invokespecial TestCanRuntimeVisibleAnnotations4/<init>()V
7: astore_1
.line 95
8: aload_1
9: ldc " Java!"
11: invokevirtual TestCanRuntimeVisibleAnnotations4/method1(Ljava/lang/String;)V
.line 96
14: return
.end method
|