KickJava   Java API By Example, From Geeks To Geeks.

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


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 RuntimeVisibleParameterAnnotations attribute is a variable length attribute
44  * in the attributes table of the method_info structure. The
45  * RuntimeVisibleParameterAnnotations attribute records runtime-visible Java
46  * programming language annotations on the parameters of the corresponding method.
47  * Each method_info structure may contain at most one
48  * RuntimeVisibleParameterAnnotations attribute, which records all the
49  * runtime-visible Java programming language annotations on the parameters of the
50  * corresponding method. The JVM must make these annotations available so they can
51  * be returned by the appropriate reflective APIs.
52  * <p>
53  * The RuntimeVisibleParameterAnnotations attribute has the following format:
54  * <pre>
55  * RuntimeVisibleParameterAnnotations_attribute {
56  * u2 attribute_name_index;
57  * u4 attribute_length;
58  * u1 num_parameters;
59  * {
60  * u2 num_annotations;
61  * annotation annotations[num_annotations];
62  * } parameter_annotations[num_parameters];
63  * }
64  * <pre>
65  * The items of the RuntimeVisibleParameterAnnotations structure are as follows:
66  * <dl>
67  * <dt>attribute_name_index</dt>
68  * <dd>The value of the attribute_name_index item must be a valid index into the
69  * constant_pool table. The constant_pool entry at that index must be a
70  * CONSTANT_Utf8_info structure representing the string
71  * "RuntimeVisibleParameterAnnotations".</dd>
72  * <dt>attribute_length</dt>
73  * <dd>The value of the attribute_length item indicates the length of the attribute,
74  * excluding the initial six bytes. The value of the attribute_length item is
75  * thus dependent on the number of parameters, the number of runtime-visible
76  * annotations on each parameter, and their values.</dd>
77  * <dt>num_parameters</dt>
78  * <dd>The value of the num_parameters item gives the number of parameters of the
79  * method represented by the method_info structure on which the annotation
80  * occurs. (This duplicates information that could be extracted from the method
81  * descriptor.)</dd>
82  * <dt>parameter_annotations</dt>
83  * <dd>Each value of the parameter_annotations table represents all of the
84  * runtime-visible annotations on a single parameter. The sequence of values in
85  * the table corresponds to the sequence of parameters in the method signature.
86  * Each parameter_annotations entry contains the following two items:</dd>
87  * <dl>
88  * <dt>num_annotations</dt>
89  * <dd>The value of the num_annotations item indicates the number of runtime-visible
90  * annotations on the parameter corresponding to the sequence number of this
91  * parameter_annotations element.</dd>
92  * <dt>annotations</dt>
93  * <dd>Each value of the annotations table represents a single runtime-visible
94  * {@link oracle.toplink.libraries.asm.attrs.Annotation annotation} on the parameter
95  * corresponding to the sequence number of this parameter_annotations element.</dd>
96  * </dl>
97  * </dd>
98  * </dl>
99  *
100  * @see <a HREF="http://www.jcp.org/en/jsr/detail?id=175">JSR 175 : A Metadata
101  * Facility for the Java Programming Language</a>
102  *
103  * @author Eugene Kuleshov
104  */

105
106 public class RuntimeVisibleParameterAnnotations extends Attribute {
107
108   /**
109    * <code>List</code> of <code>List</code>s that
110    * contains <code>Annotation</code> for each method parameter.
111    *
112    * @associates <{oracle.toplink.libraries.asm.attrs.Annotation}>
113    * @label parameters
114    * @associationAsClass List
115    */

116   public List JavaDoc parameters = new ArrayList JavaDoc();
117
118   public RuntimeVisibleParameterAnnotations () {
119     super("RuntimeVisibleParameterAnnotations");
120   }
121
122   protected Attribute read (ClassReader cr, int off,
123                             int len, char[] buf, int codeOff, Label[] labels) {
124     RuntimeVisibleParameterAnnotations atr =
125       new RuntimeVisibleParameterAnnotations();
126     Annotation.readParameterAnnotations(atr.parameters, cr, off, buf);
127     return atr;
128   }
129
130   protected ByteVector write (ClassWriter cw, byte[] code,
131                               int len, int maxStack, int maxLocals) {
132     return Annotation.writeParametersAnnotations(
133       new ByteVector(), parameters, cw);
134   }
135
136   public String JavaDoc toString () {
137     return Annotation.stringParameterAnnotations(parameters);
138   }
139 }
140
Popular Tags