KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > libraries > asm > attrs > RuntimeInvisibleAnnotations


1 /**
2  * ASM: a very small and fast Java bytecode manipulation framework
3  * Copyright (c) 2000,2002,2003 INRIA, France Telecom
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * 3. Neither the name of the copyright holders nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28  * THE POSSIBILITY OF SUCH DAMAGE.
29  */

30
31 package oracle.toplink.libraries.asm.attrs;
32
33 import java.util.ArrayList JavaDoc;
34 import java.util.List JavaDoc;
35
36 import oracle.toplink.libraries.asm.Attribute;
37 import oracle.toplink.libraries.asm.ByteVector;
38 import oracle.toplink.libraries.asm.ClassReader;
39 import oracle.toplink.libraries.asm.ClassWriter;
40 import oracle.toplink.libraries.asm.Label;
41
42 /**
43  * The RuntimeInvisibleAnnotations attribute is similar to the
44  * RuntimeVisibleAnnotations attribute, except that the annotations represented by
45  * a RuntimeInvisibleAnnotations attribute must not be made available for return
46  * by reflective APIs, unless the JVM has been instructed to retain these
47  * annotations via some implementation-specific mechanism such as a command line
48  * flag. In the absence of such instructions, the JVM ignores this attribute.
49  * <p>
50  * The RuntimeInvisibleAnnotations attribute is a variable length attribute in the
51  * attributes table of the ClassFile, field_info, and method_info structures. The
52  * RuntimeInvisibleAnnotations attribute records runtime-invisible Java
53  * programming language annotations on the corresponding class, method, or field.
54  * Each ClassFile, field_info, and method_info structure may contain at most one
55  * RuntimeInvisibleAnnotations attribute, which records all the runtime-invisible
56  * Java programming language annotations on the corresponding program element.
57  * <p>
58  * The RuntimeInvisibleAnnotations attribute has the following format:
59  * <pre>
60  * RuntimeInvisibleAnnotations_attribute {
61  * u2 attribute_name_index;
62  * u4 attribute_length;
63  * u2 num_annotations;
64  * annotation annotations[num_annotations];
65  * }
66  * </pre>
67  * The items of the RuntimeInvisibleAnnotations structure are as follows:
68  * <dl>
69  * <dt>attribute_name_index</dt>
70  * <dd>The value of the attribute_name_index item must be a valid index into the
71  * constant_pool table. The constant_pool entry at that index must be a
72  * CONSTANT_Utf8_info structure representing the string
73  * "RuntimeInvisibleAnnotations".</dd>
74  * <dt>attribute_length</dt>
75  * <dd>The value of the attribute_length item indicates the length of the
76  * attribute, excluding the initial six bytes. The value of the
77  * attribute_length item is thus dependent on the number of runtime-invisible
78  * annotations represented by the structure, and their values.</dd>
79  * <dt>num_annotations</dt>
80  * <dd>The value of the num_annotations item gives the number of runtime-invisible
81  * annotations represented by the structure. Note that a maximum of 65535
82  * runtime-invisible Java programming language annotations may be directly
83  * attached to a program element.</dd>
84  * <dt>annotations</dt>
85  * <dd>Each value of the annotations table represents a single runtime-invisible
86  * {@link oracle.toplink.libraries.asm.attrs.Annotation annotation} on a program element.</dd>
87  * </dl>
88  *
89  * @see <a HREF="http://www.jcp.org/en/jsr/detail?id=175">JSR 175 : A Metadata
90  * Facility for the Java Programming Language</a>
91  *
92  * @author Eugene Kuleshov
93  */

94
95 public class RuntimeInvisibleAnnotations extends Attribute {
96
97   /**
98    * <code>List</code> of <code>Annotation</code>.
99    *
100    * @associates <{oracle.toplink.libraries.asm.attrs.Annotation}>
101    * @label annotations
102    */

103   public List JavaDoc annotations = new ArrayList JavaDoc();
104
105   public RuntimeInvisibleAnnotations () {
106     super("RuntimeInvisibleAnnotations");
107   }
108
109   protected Attribute read (ClassReader cr, int off,
110                             int len, char[] buf, int codeOff, Label[] labels) {
111     RuntimeInvisibleAnnotations atr = new RuntimeInvisibleAnnotations();
112     Annotation.readAnnotations(atr.annotations, cr, off, buf);
113     return atr;
114   }
115
116   protected ByteVector write (ClassWriter cw, byte[] code,
117                               int len, int maxStack, int maxLocals) {
118     return Annotation.writeAnnotations(new ByteVector(), annotations, cw);
119   }
120
121   /**
122    * Returns value in the format described in JSR-175 for Java source code.
123    *
124    * @return value in the format described in JSR-175 for Java source code.
125    */

126
127   public String JavaDoc toString () {
128     return Annotation.stringAnnotations(annotations);
129   }
130 }
131
Popular Tags