47 // Annotations for this class, or null if none. |
47 // Annotations for this class, or null if none. |
48 AnnotationArray* _class_annotations; |
48 AnnotationArray* _class_annotations; |
49 // Annotation objects (byte arrays) for fields, or null if no annotations. |
49 // Annotation objects (byte arrays) for fields, or null if no annotations. |
50 // Indices correspond to entries (not indices) in fields array. |
50 // Indices correspond to entries (not indices) in fields array. |
51 Array<AnnotationArray*>* _fields_annotations; |
51 Array<AnnotationArray*>* _fields_annotations; |
52 // Annotation objects (byte arrays) for methods, or null if no annotations. |
|
53 // Index is the idnum, which is initially the same as the methods array index. |
|
54 Array<AnnotationArray*>* _methods_annotations; |
|
55 // Annotation objects (byte arrays) for methods' parameters, or null if no |
|
56 // such annotations. |
|
57 // Index is the idnum, which is initially the same as the methods array index. |
|
58 Array<AnnotationArray*>* _methods_parameter_annotations; |
|
59 // Annotation objects (byte arrays) for methods' default values, or null if no |
|
60 // such annotations. |
|
61 // Index is the idnum, which is initially the same as the methods array index. |
|
62 Array<AnnotationArray*>* _methods_default_annotations; |
|
63 // Type annotations for this class, or null if none. |
52 // Type annotations for this class, or null if none. |
64 Annotations* _type_annotations; |
53 AnnotationArray* _class_type_annotations; |
65 |
54 Array<AnnotationArray*>* _fields_type_annotations; |
66 // Constructor where some some values are known to not be null |
|
67 Annotations(Array<AnnotationArray*>* fa, Array<AnnotationArray*>* ma, |
|
68 Array<AnnotationArray*>* mpa, Array<AnnotationArray*>* mda) : |
|
69 _class_annotations(NULL), |
|
70 _fields_annotations(fa), |
|
71 _methods_annotations(ma), |
|
72 _methods_parameter_annotations(mpa), |
|
73 _methods_default_annotations(mda), |
|
74 _type_annotations(NULL) {} |
|
75 |
55 |
76 public: |
56 public: |
77 // Allocate instance of this class |
57 // Allocate instance of this class |
78 static Annotations* allocate(ClassLoaderData* loader_data, TRAPS); |
58 static Annotations* allocate(ClassLoaderData* loader_data, TRAPS); |
79 static Annotations* allocate(ClassLoaderData* loader_data, |
59 |
80 Array<AnnotationArray*>* fa, |
60 static void free_contents(ClassLoaderData* loader_data, Array<AnnotationArray*>* p); |
81 Array<AnnotationArray*>* ma, |
|
82 Array<AnnotationArray*>* mpa, |
|
83 Array<AnnotationArray*>* mda, TRAPS); |
|
84 void deallocate_contents(ClassLoaderData* loader_data); |
61 void deallocate_contents(ClassLoaderData* loader_data); |
85 DEBUG_ONLY(bool on_stack() { return false; }) // for template |
62 DEBUG_ONLY(bool on_stack() { return false; }) // for template |
86 |
63 |
87 // Sizing (in words) |
64 // Sizing (in words) |
88 static int size() { return sizeof(Annotations) / wordSize; } |
65 static int size() { return sizeof(Annotations) / wordSize; } |
91 #endif |
68 #endif |
92 |
69 |
93 // Constructor to initialize to null |
70 // Constructor to initialize to null |
94 Annotations() : _class_annotations(NULL), |
71 Annotations() : _class_annotations(NULL), |
95 _fields_annotations(NULL), |
72 _fields_annotations(NULL), |
96 _methods_annotations(NULL), |
73 _class_type_annotations(NULL), |
97 _methods_parameter_annotations(NULL), |
74 _fields_type_annotations(NULL) {} |
98 _methods_default_annotations(NULL), |
|
99 _type_annotations(NULL) {} |
|
100 |
75 |
101 AnnotationArray* class_annotations() const { return _class_annotations; } |
76 AnnotationArray* class_annotations() const { return _class_annotations; } |
102 Array<AnnotationArray*>* fields_annotations() const { return _fields_annotations; } |
77 Array<AnnotationArray*>* fields_annotations() const { return _fields_annotations; } |
103 Array<AnnotationArray*>* methods_annotations() const { return _methods_annotations; } |
78 AnnotationArray* class_type_annotations() const { return _class_type_annotations; } |
104 Array<AnnotationArray*>* methods_parameter_annotations() const { return _methods_parameter_annotations; } |
79 Array<AnnotationArray*>* fields_type_annotations() const { return _fields_type_annotations; } |
105 Array<AnnotationArray*>* methods_default_annotations() const { return _methods_default_annotations; } |
|
106 Annotations* type_annotations() const { return _type_annotations; } |
|
107 |
80 |
108 void set_class_annotations(AnnotationArray* md) { _class_annotations = md; } |
81 void set_class_annotations(AnnotationArray* md) { _class_annotations = md; } |
109 void set_fields_annotations(Array<AnnotationArray*>* md) { _fields_annotations = md; } |
82 void set_fields_annotations(Array<AnnotationArray*>* md) { _fields_annotations = md; } |
110 void set_methods_annotations(Array<AnnotationArray*>* md) { _methods_annotations = md; } |
83 void set_class_type_annotations(AnnotationArray* cta) { _class_type_annotations = cta; } |
111 void set_methods_parameter_annotations(Array<AnnotationArray*>* md) { _methods_parameter_annotations = md; } |
84 void set_fields_type_annotations(Array<AnnotationArray*>* fta) { _fields_type_annotations = fta; } |
112 void set_methods_default_annotations(Array<AnnotationArray*>* md) { _methods_default_annotations = md; } |
|
113 void set_type_annotations(Annotations* annos) { _type_annotations = annos; } |
|
114 |
|
115 // Redefine classes support |
|
116 AnnotationArray* get_method_annotations_of(int idnum) |
|
117 { return get_method_annotations_from(idnum, _methods_annotations); } |
|
118 |
|
119 AnnotationArray* get_method_parameter_annotations_of(int idnum) |
|
120 { return get_method_annotations_from(idnum, _methods_parameter_annotations); } |
|
121 AnnotationArray* get_method_default_annotations_of(int idnum) |
|
122 { return get_method_annotations_from(idnum, _methods_default_annotations); } |
|
123 |
|
124 |
|
125 void set_method_annotations_of(instanceKlassHandle ik, |
|
126 int idnum, AnnotationArray* anno, TRAPS) { |
|
127 set_methods_annotations_of(ik, idnum, anno, &_methods_annotations, THREAD); |
|
128 } |
|
129 |
|
130 void set_method_parameter_annotations_of(instanceKlassHandle ik, |
|
131 int idnum, AnnotationArray* anno, TRAPS) { |
|
132 set_methods_annotations_of(ik, idnum, anno, &_methods_parameter_annotations, THREAD); |
|
133 } |
|
134 |
|
135 void set_method_default_annotations_of(instanceKlassHandle ik, |
|
136 int idnum, AnnotationArray* anno, TRAPS) { |
|
137 set_methods_annotations_of(ik, idnum, anno, &_methods_default_annotations, THREAD); |
|
138 } |
|
139 |
85 |
140 // Turn metadata annotations into a Java heap object (oop) |
86 // Turn metadata annotations into a Java heap object (oop) |
141 static typeArrayOop make_java_array(AnnotationArray* annotations, TRAPS); |
87 static typeArrayOop make_java_array(AnnotationArray* annotations, TRAPS); |
142 |
88 |
143 inline AnnotationArray* get_method_annotations_from(int idnum, Array<AnnotationArray*>* annos); |
|
144 void set_annotations(Array<AnnotationArray*>* md, Array<AnnotationArray*>** md_p) { *md_p = md; } |
|
145 |
|
146 bool is_klass() const { return false; } |
89 bool is_klass() const { return false; } |
147 private: |
90 private: |
148 void set_methods_annotations_of(instanceKlassHandle ik, |
|
149 int idnum, AnnotationArray* anno, |
|
150 Array<AnnotationArray*>** md_p, TRAPS); |
|
151 static julong count_bytes(Array<AnnotationArray*>* p); |
91 static julong count_bytes(Array<AnnotationArray*>* p); |
152 public: |
92 public: |
153 const char* internal_name() const { return "{constant pool}"; } |
93 const char* internal_name() const { return "{constant pool}"; } |
154 #ifndef PRODUCT |
94 #ifndef PRODUCT |
155 void print_on(outputStream* st) const; |
95 void print_on(outputStream* st) const; |
156 #endif |
96 #endif |
157 void print_value_on(outputStream* st) const; |
97 void print_value_on(outputStream* st) const; |
158 }; |
98 }; |
159 |
|
160 |
|
161 // For method with idnum get the method's Annotations |
|
162 inline AnnotationArray* Annotations::get_method_annotations_from(int idnum, Array<AnnotationArray*>* annos) { |
|
163 if (annos == NULL || annos->length() <= idnum) { |
|
164 return NULL; |
|
165 } |
|
166 return annos->at(idnum); |
|
167 } |
|
168 #endif // SHARE_VM_OOPS_ANNOTATIONS_HPP |
99 #endif // SHARE_VM_OOPS_ANNOTATIONS_HPP |