< prev index next >

src/java.base/share/classes/jdk/internal/org/objectweb/asm/AnnotationVisitor.java

Print this page
rev 47452 : imported patch jdk-new-asmv6.patch


  53  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  54  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  55  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  56  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  57  * THE POSSIBILITY OF SUCH DAMAGE.
  58  */
  59 package jdk.internal.org.objectweb.asm;
  60 
  61 /**
  62  * A visitor to visit a Java annotation. The methods of this class must be
  63  * called in the following order: ( <tt>visit</tt> | <tt>visitEnum</tt> |
  64  * <tt>visitAnnotation</tt> | <tt>visitArray</tt> )* <tt>visitEnd</tt>.
  65  *
  66  * @author Eric Bruneton
  67  * @author Eugene Kuleshov
  68  */
  69 public abstract class AnnotationVisitor {
  70 
  71     /**
  72      * The ASM API version implemented by this visitor. The value of this field
  73      * must be one of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
  74      */
  75     protected final int api;
  76 
  77     /**
  78      * The annotation visitor to which this visitor must delegate method calls.
  79      * May be null.
  80      */
  81     protected AnnotationVisitor av;
  82 
  83     /**
  84      * Constructs a new {@link AnnotationVisitor}.
  85      *
  86      * @param api
  87      *            the ASM API version implemented by this visitor. Must be one
  88      *            of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
  89      */
  90     public AnnotationVisitor(final int api) {
  91         this(api, null);
  92     }
  93 
  94     /**
  95      * Constructs a new {@link AnnotationVisitor}.
  96      *
  97      * @param api
  98      *            the ASM API version implemented by this visitor. Must be one
  99      *            of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
 100      * @param av
 101      *            the annotation visitor to which this visitor must delegate
 102      *            method calls. May be null.
 103      */
 104     public AnnotationVisitor(final int api, final AnnotationVisitor av) {
 105         if (api != Opcodes.ASM4 && api != Opcodes.ASM5) {
 106             throw new IllegalArgumentException();
 107         }
 108         this.api = api;
 109         this.av = av;
 110     }
 111 
 112     /**
 113      * Visits a primitive value of the annotation.
 114      *
 115      * @param name
 116      *            the value name.
 117      * @param value
 118      *            the actual value, whose type must be {@link Byte},
 119      *            {@link Boolean}, {@link Character}, {@link Short},
 120      *            {@link Integer} , {@link Long}, {@link Float}, {@link Double},
 121      *            {@link String} or {@link Type} or OBJECT or ARRAY sort. This
 122      *            value can also be an array of byte, boolean, short, char, int,
 123      *            long, float or double values (this is equivalent to using
 124      *            {@link #visitArray visitArray} and visiting each array element
 125      *            in turn, but is more convenient).
 126      */
 127     public void visit(String name, Object value) {
 128         if (av != null) {
 129             av.visit(name, value);
 130         }
 131     }
 132 
 133     /**
 134      * Visits an enumeration value of the annotation.
 135      *
 136      * @param name
 137      *            the value name.
 138      * @param desc
 139      *            the class descriptor of the enumeration class.
 140      * @param value
 141      *            the actual enumeration value.




  53  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  54  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  55  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  56  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  57  * THE POSSIBILITY OF SUCH DAMAGE.
  58  */
  59 package jdk.internal.org.objectweb.asm;
  60 
  61 /**
  62  * A visitor to visit a Java annotation. The methods of this class must be
  63  * called in the following order: ( <tt>visit</tt> | <tt>visitEnum</tt> |
  64  * <tt>visitAnnotation</tt> | <tt>visitArray</tt> )* <tt>visitEnd</tt>.
  65  *
  66  * @author Eric Bruneton
  67  * @author Eugene Kuleshov
  68  */
  69 public abstract class AnnotationVisitor {
  70 
  71     /**
  72      * The ASM API version implemented by this visitor. The value of this field
  73      * must be one of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
  74      */
  75     protected final int api;
  76 
  77     /**
  78      * The annotation visitor to which this visitor must delegate method calls.
  79      * May be null.
  80      */
  81     protected AnnotationVisitor av;
  82 
  83     /**
  84      * Constructs a new {@link AnnotationVisitor}.
  85      *
  86      * @param api
  87      *            the ASM API version implemented by this visitor. Must be one
  88      *            of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
  89      */
  90     public AnnotationVisitor(final int api) {
  91         this(api, null);
  92     }
  93 
  94     /**
  95      * Constructs a new {@link AnnotationVisitor}.
  96      *
  97      * @param api
  98      *            the ASM API version implemented by this visitor. Must be one
  99      *            of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
 100      * @param av
 101      *            the annotation visitor to which this visitor must delegate
 102      *            method calls. May be null.
 103      */
 104     public AnnotationVisitor(final int api, final AnnotationVisitor av) {
 105         if (api < Opcodes.ASM4 || api > Opcodes.ASM6) {
 106             throw new IllegalArgumentException();
 107         }
 108         this.api = api;
 109         this.av = av;
 110     }
 111 
 112     /**
 113      * Visits a primitive value of the annotation.
 114      *
 115      * @param name
 116      *            the value name.
 117      * @param value
 118      *            the actual value, whose type must be {@link Byte},
 119      *            {@link Boolean}, {@link Character}, {@link Short},
 120      *            {@link Integer} , {@link Long}, {@link Float}, {@link Double},
 121      *            {@link String} or {@link Type} of OBJECT or ARRAY sort. This
 122      *            value can also be an array of byte, boolean, short, char, int,
 123      *            long, float or double values (this is equivalent to using
 124      *            {@link #visitArray visitArray} and visiting each array element
 125      *            in turn, but is more convenient).
 126      */
 127     public void visit(String name, Object value) {
 128         if (av != null) {
 129             av.visit(name, value);
 130         }
 131     }
 132 
 133     /**
 134      * Visits an enumeration value of the annotation.
 135      *
 136      * @param name
 137      *            the value name.
 138      * @param desc
 139      *            the class descriptor of the enumeration class.
 140      * @param value
 141      *            the actual enumeration value.


< prev index next >