ClassFileAnalyzer (Can)
Home

 

Example: TestCanRuntimeVisibleParameterAnnotations

Test directives .annotation visibleparam and .annotation invisibleparam

 

/* TestCanRuntimeVisibleParameterAnnotations.java */ 

import java.lang.annotation.*;


public class TestCanRuntimeVisibleParameterAnnotations {
  
  
  @Retention(value = RetentionPolicy.CLASS)
  @Target(value = { ElementType.ANNOTATION_TYPE,
                    ElementType.CONSTRUCTOR,
                    ElementType.FIELD,
                    ElementType.LOCAL_VARIABLE,
                    ElementType.METHOD,
                    ElementType.PACKAGE,
                    ElementType.PARAMETER,
                    ElementType.TYPE })
  public @interface Annotation1 {
    byte byteValue() default 1;
    char[] charValue() default { 'a', 'b' };
    double doubleValue();
    float floatValue();
    int[] intValue();
    long longValue();
    short shortValue();
    boolean[] booleanValue();
    String[] stringValue();
  }
  
  
  @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 Annotation2 {
    enum Direction { NORTH, SOUTH, WEST, EAST };
    Direction value1();
    Class value2();
    Class<? extends Number>[] value3() default Integer.class;
  }
  
  
  @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 Annotation3 {
    Annotation1[] value1() default {
            @Annotation1(byteValue = 1, intValue = { 4 }),
            @Annotation1(charValue = { 'a', 'b' }, booleanValue = { true }),
            @Annotation1(floatValue = 1.23f, stringValue = { "Hello", "Can!" })};
    Annotation2[] value2() default {
            @Annotation2(value1 = 
          TestCanRuntimeVisibleParameterAnnotations.Annotation2.Direction.NORTH,
                         value2 = Object.class,
                         value3 = { Byte.class, Integer.class }),
            @Annotation2(value1 =
          TestCanRuntimeVisibleParameterAnnotations.Annotation2.Direction.SOUTH,
                         value2 = StringBuffer.class,
                         value3 = { Float.class, Double.class })};
  }
  
   
  public void method1(
    @Annotation1(doubleValue = 4.56, floatValue = 7.89f, intValue = { 10, 11 },
                 longValue = 12, shortValue = 13, booleanValue = { true, false },
                 stringValue = { "Hello" })
    byte b,
    
    @Annotation1(doubleValue = 0.00, floatValue = 7.89f, intValue = { 10, 11 },
                 longValue = 12, shortValue = 13, booleanValue = { true, false },
                 stringValue = { "Can!" })
    int i,
    
    @Annotation2(value1 =
          TestCanRuntimeVisibleParameterAnnotations.Annotation2.Direction.NORTH,
                 value2 = Object.class,
                 value3 = { Byte.class, Integer.class })
    double d, 
    
    @Annotation3(
    value1 = { @Annotation1(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!" }),
               @Annotation1(byteValue = 2, 
                            charValue = { 'c', 'd' }),
               @Annotation1(byteValue = 3) },
    value2 = { @Annotation2(value1 =
          TestCanRuntimeVisibleParameterAnnotations.Annotation2.Direction.NORTH,
                            value2 = Object.class,
                            value3 = { Byte.class, Integer.class }),
               @Annotation2(value1 =
          TestCanRuntimeVisibleParameterAnnotations.Annotation2.Direction.SOUTH,
                            value2 = StringBuffer.class,
                            value3 = { Float.class, Double.class })})
    String s) {
        
  }
  
  
  public static void main(String[] args) {
    TestCanRuntimeVisibleParameterAnnotations tcrvpa = 
        new TestCanRuntimeVisibleParameterAnnotations(); 
    tcrvpa.method1((byte)1, 2, 3.45, "Hello Can!");
  }
}

 

> javac TestCanRuntimeVisibleParameterAnnotations.java

> java ClassFileAnalyzer TestCanRuntimeVisibleParameterAnnotations.class
> java ClassFileAnalyzer TestCanRuntimeVisibleParameterAnnotations$Annotation1.class
> java ClassFileAnalyzer TestCanRuntimeVisibleParameterAnnotations$Annotation2.class
> java ClassFileAnalyzer TestCanRuntimeVisibleParameterAnnotations$Annotation3.class
> java ClassFileAnalyzer
        TestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction.class

 

; TestCanRuntimeVisibleParameterAnnotations.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 TestCanRuntimeVisibleParameterAnnotations.java
.class public TestCanRuntimeVisibleParameterAnnotations
.super java/lang/Object
; one line
.inner interface public static abstract annotation Annotation3
        inner TestCanRuntimeVisibleParameterAnnotations$Annotation3
        outer TestCanRuntimeVisibleParameterAnnotations
; one line
.inner interface public static abstract annotation Annotation2
        inner TestCanRuntimeVisibleParameterAnnotations$Annotation2
        outer TestCanRuntimeVisibleParameterAnnotations
; one line
.inner interface public static abstract annotation Annotation1
        inner TestCanRuntimeVisibleParameterAnnotations$Annotation1
        outer TestCanRuntimeVisibleParameterAnnotations
; one line
.inner class public static final enum Direction
        inner TestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction
        outer TestCanRuntimeVisibleParameterAnnotations$Annotation2

.method public <init>()V
  .limit stack 1
  .limit locals 1
  .line 6
  0: aload_0
  1: invokespecial java/lang/Object/<init>()V
  .line 48
  4: return
.end method

.method public method1(BIDLjava/lang/String;)V
  .limit stack 0
  .limit locals 6
  .line 114
  0: return
  .annotation visibleparam 3 LTestCanRuntimeVisibleParameterAnnotations$Annotation2;
    value1 e LTestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction; = NORTH
    value2 c = Ljava/lang/Object;
    value3 [c = Ljava/lang/Byte; Ljava/lang/Integer;
    .end annotation
  .annotation visibleparam 4 LTestCanRuntimeVisibleParameterAnnotations$Annotation3;
    value1 [@ LTestCanRuntimeVisibleParameterAnnotations$Annotation1; = .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 [@ LTestCanRuntimeVisibleParameterAnnotations$Annotation2; = .annotation
    value1 e LTestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction; = NORTH
    value2 c = Ljava/lang/Object;
    value3 [c = Ljava/lang/Byte; Ljava/lang/Integer;
    .end annotation
    .annotation
    value1 e LTestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction; = SOUTH
    value2 c = Ljava/lang/StringBuffer;
    value3 [c = Ljava/lang/Float; Ljava/lang/Double;
    .end annotation
    .end annotation
  .annotation invisibleparam 1 LTestCanRuntimeVisibleParameterAnnotations$Annotation1;
    doubleValue D = 4.56
    floatValue F = 7.89
    intValue [I = 10 11
    longValue J = 12
    shortValue S = 13
    booleanValue [Z = 1 0
    stringValue [s = "Hello"
    .end annotation
  .annotation invisibleparam 2 LTestCanRuntimeVisibleParameterAnnotations$Annotation1;
    doubleValue D = 0.0
    floatValue F = 7.89
    intValue [I = 10 11
    longValue J = 12
    shortValue S = 13
    booleanValue [Z = 1 0
    stringValue [s = "Can!"
    .end annotation
.end method

.method public static main([Ljava/lang/String;)V
  .limit stack 6
  .limit locals 2
  .line 118
  0: new TestCanRuntimeVisibleParameterAnnotations
  3: dup
  4: invokespecial TestCanRuntimeVisibleParameterAnnotations/<init>()V
  7: astore_1
  .line 120
  8: aload_1
  9: iconst_1
  10: iconst_2
  11: ldc2_w 3.45
  14: ldc "Hello Can!"
  ; one line
  16: invokevirtual
      TestCanRuntimeVisibleParameterAnnotations/method1(BIDLjava/lang/String;)V
  .line 121
  19: return
.end method

 

; TestCanRuntimeVisibleParameterAnnotations$Annotation1.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 TestCanRuntimeVisibleParameterAnnotations.java
; one line
.interface public abstract annotation
        TestCanRuntimeVisibleParameterAnnotations$Annotation1
; 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; = CLASS
  .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 interface public static abstract annotation Annotation1
        inner TestCanRuntimeVisibleParameterAnnotations$Annotation1
        outer TestCanRuntimeVisibleParameterAnnotations

.method public abstract byteValue()B
  .annotation default
    B = 1
    .end annotation
.end method

.method public abstract charValue()[C
  .annotation default
    [C = 97 98
    .end annotation
.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

 

; TestCanRuntimeVisibleParameterAnnotations$Annotation2.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 TestCanRuntimeVisibleParameterAnnotations.java
; one line
.interface public abstract annotation
        TestCanRuntimeVisibleParameterAnnotations$Annotation2
; 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 interface public static abstract annotation Annotation2
        inner TestCanRuntimeVisibleParameterAnnotations$Annotation2
        outer TestCanRuntimeVisibleParameterAnnotations
; one line
.inner class public static final enum Direction
        inner TestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction
        outer TestCanRuntimeVisibleParameterAnnotations$Annotation2

; one line
.method public abstract
        value1()LTestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction;
.end method

.method public abstract value2()Ljava/lang/Class;
.end method

.method public abstract value3()[Ljava/lang/Class;
  .annotation default
    [c = Ljava/lang/Integer;
    .end annotation
  .signature "()[Ljava/lang/Class<+Ljava/lang/Number;>;"
.end method

 

; TestCanRuntimeVisibleParameterAnnotations$Annotation3.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 TestCanRuntimeVisibleParameterAnnotations.java
; one line
.interface public abstract annotation
        TestCanRuntimeVisibleParameterAnnotations$Annotation3
; 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 interface public static abstract annotation Annotation1
        inner TestCanRuntimeVisibleParameterAnnotations$Annotation1
        outer TestCanRuntimeVisibleParameterAnnotations
; one line
.inner interface public static abstract annotation Annotation2
        inner TestCanRuntimeVisibleParameterAnnotations$Annotation2
        outer TestCanRuntimeVisibleParameterAnnotations
; one line
.inner class public static final enum Direction
        inner TestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction
        outer TestCanRuntimeVisibleParameterAnnotations$Annotation2
; one line
.inner interface public static abstract annotation Annotation3
        inner TestCanRuntimeVisibleParameterAnnotations$Annotation3
        outer TestCanRuntimeVisibleParameterAnnotations

; one line
.method public abstract
        value1()[LTestCanRuntimeVisibleParameterAnnotations$Annotation1;
  .annotation default
    [@ LTestCanRuntimeVisibleParameterAnnotations$Annotation1; = .annotation
    byteValue B = 1
    intValue [I = 4
    .end annotation
    .annotation
    charValue [C = 97 98
    booleanValue [Z = 1
    .end annotation
    .annotation
    floatValue F = 1.23
    stringValue [s = "Hello" "Can!"
    .end annotation
    .end annotation
.end method

; one line
.method public abstract
        value2()[LTestCanRuntimeVisibleParameterAnnotations$Annotation2;
  .annotation default
    [@ LTestCanRuntimeVisibleParameterAnnotations$Annotation2; = .annotation
    value1 e LTestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction; = NORTH
    value2 c = Ljava/lang/Object;
    value3 [c = Ljava/lang/Byte; Ljava/lang/Integer;
    .end annotation
    .annotation
    value1 e LTestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction; = SOUTH
    value2 c = Ljava/lang/StringBuffer;
    value3 [c = Ljava/lang/Float; Ljava/lang/Double;
    .end annotation
    .end annotation
.end method

 

; TestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction.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 TestCanRuntimeVisibleParameterAnnotations.java
; one line
.class public final enum
        TestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction
.super java/lang/Enum
; one line
.signature
"Ljava/lang/Enum<LTestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction;>;"
; one line
.inner interface public static abstract annotation Annotation2
        inner TestCanRuntimeVisibleParameterAnnotations$Annotation2
        outer TestCanRuntimeVisibleParameterAnnotations
; one line
.inner class public static final enum Direction
        inner TestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction
        outer TestCanRuntimeVisibleParameterAnnotations$Annotation2

; one line
.field public static final enum NORTH 
        LTestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction;
; one line
.field public static final enum SOUTH
        LTestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction;
; one line
.field public static final enum WEST
        LTestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction;
; one line
.field public static final enum EAST
        LTestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction;
; one line
.field private static final synthetic $VALUES
        [LTestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction;

; one line
.method public static 
        values()[LTestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction;
  .limit stack 1
  .limit locals 0
  .line 41
  ; one line
  0: getstatic TestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction/
     $VALUES [LTestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction;
  ; one line
  3: invokevirtual [LTestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction;
      /clone()Ljava/lang/Object;
  6: checkcast [LTestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction;
  9: areturn
.end method

; one line
.method public static valueOf(Ljava/lang/String;)
        LTestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction;
  .limit stack 2
  .limit locals 1
  .line 41
  0: ldc_w "TestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction"
  3: aload_0
  ; one line
  4: invokestatic
     java/lang/Enum/valueOf(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;
  7: checkcast TestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction
  10: areturn
.end method

.method private <init>(Ljava/lang/String;I)V
  .limit stack 3
  .limit locals 3
  .line 41
  0: aload_0
  1: aload_1
  2: iload_2
  3: invokespecial java/lang/Enum/<init>(Ljava/lang/String;I)V
  6: return
  .signature "()V"
.end method

.method static <clinit>()V
  .limit stack 4
  .limit locals 0
  .line 41
  0: new TestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction
  3: dup
  4: ldc "NORTH"
  6: iconst_0
  ; one line
  7: invokespecial TestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction/
     <init>(Ljava/lang/String;I)V
  ; one line
  10: putstatic TestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction/
      NORTH LTestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction;
  13: new TestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction
  16: dup
  17: ldc "SOUTH"
  19: iconst_1
  ; one line
  20: invokespecial TestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction/
      <init>(Ljava/lang/String;I)V
  ; one line
  23: putstatic TestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction/
      SOUTH LTestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction;
  26: new TestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction
  29: dup
  30: ldc "WEST"
  32: iconst_2
  ; one line
  33: invokespecial TestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction/
      <init>(Ljava/lang/String;I)V
  ; one line
  36: putstatic TestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction/
      WEST LTestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction;
  39: new TestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction
  42: dup
  43: ldc "EAST"
  45: iconst_3
  ; one line
  46: invokespecial TestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction/
      <init>(Ljava/lang/String;I)V
  ; one line
  49: putstatic TestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction/
      EAST LTestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction;
  52: iconst_4
  53: anewarray TestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction
  56: dup
  57: iconst_0
  ; one line
  58: getstatic TestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction/
      NORTH LTestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction;
  61: aastore
  62: dup
  63: iconst_1
  ; one line
  64: getstatic TestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction/
      SOUTH LTestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction;
  67: aastore
  68: dup
  69: iconst_2
  ; one line
  70: getstatic TestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction/
      WEST LTestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction;
  73: aastore
  74: dup
  75: iconst_3
  ; one line
  76: getstatic TestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction/
      EAST LTestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction;
  79: aastore
  ; one line
  80: putstatic TestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction/
      $VALUES [LTestCanRuntimeVisibleParameterAnnotations$Annotation2$Direction;
  83: return
.end method