ClassFileAnalyzer (Can)
Home

 

Example: TestCanAnnotationDefault2

Test directive .annotation default

 

/* TestCanAnnotationDefault2.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 TestCanAnnotationDefault2 {
  
  enum Direction { NORTH, SOUTH, WEST, EAST };
  Direction value1() default Direction.WEST;
  
  Class value2() default Object.class;
  Class<? extends Number>[] value3() default { Byte.class, Integer.class };
}

 

> javac TestCanAnnotationDefault2.java
> java ClassFileAnalyzer TestCanAnnotationDefault2.class

 

; TestCanAnnotationDefault2.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 TestCanAnnotationDefault2.java
.interface public abstract annotation TestCanAnnotationDefault2
; 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
        TestCanAnnotationDefault2$Direction outer TestCanAnnotationDefault2
.method public abstract value1()LTestCanAnnotationDefault2$Direction;
  .annotation default
    e LTestCanAnnotationDefault2$Direction; = WEST
    .end annotation
.end method

.method public abstract value2()Ljava/lang/Class;
  .annotation default
    c = Ljava/lang/Object;
    .end annotation
.end method

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