src/share/vm/oops/annotations.hpp

Wed, 23 Jan 2013 13:02:39 -0500

author
jprovino
date
Wed, 23 Jan 2013 13:02:39 -0500
changeset 4542
db9981fd3124
parent 4393
35431a769282
child 4497
16fb9f942703
permissions
-rw-r--r--

8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
Summary: Rename INCLUDE_ALTERNATE_GCS to INCLUDE_ALL_GCS and replace SERIALGC with INCLUDE_ALL_GCS.
Reviewed-by: coleenp, stefank

coleenp@4037 1 /*
coleenp@4037 2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
coleenp@4037 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
coleenp@4037 4 *
coleenp@4037 5 * This code is free software; you can redistribute it and/or modify it
coleenp@4037 6 * under the terms of the GNU General Public License version 2 only, as
coleenp@4037 7 * published by the Free Software Foundation.
coleenp@4037 8 *
coleenp@4037 9 * This code is distributed in the hope that it will be useful, but WITHOUT
coleenp@4037 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
coleenp@4037 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
coleenp@4037 12 * version 2 for more details (a copy is included in the LICENSE file that
coleenp@4037 13 * accompanied this code).
coleenp@4037 14 *
coleenp@4037 15 * You should have received a copy of the GNU General Public License version
coleenp@4037 16 * 2 along with this work; if not, write to the Free Software Foundation,
coleenp@4037 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
coleenp@4037 18 *
coleenp@4037 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
coleenp@4037 20 * or visit www.oracle.com if you need additional information or have any
coleenp@4037 21 * questions.
coleenp@4037 22 *
coleenp@4037 23 */
coleenp@4037 24
coleenp@4037 25 #ifndef SHARE_VM_OOPS_ANNOTATIONS_HPP
coleenp@4037 26 #define SHARE_VM_OOPS_ANNOTATIONS_HPP
coleenp@4037 27
coleenp@4037 28 #include "oops/metadata.hpp"
coleenp@4037 29 #include "runtime/handles.hpp"
coleenp@4037 30 #include "utilities/array.hpp"
coleenp@4037 31 #include "utilities/exceptions.hpp"
coleenp@4037 32 #include "utilities/globalDefinitions.hpp"
coleenp@4037 33
coleenp@4037 34
coleenp@4037 35 class ClassLoaderData;
coleenp@4037 36 class outputStream;
coleenp@4037 37
coleenp@4037 38 typedef Array<u1> AnnotationArray;
coleenp@4037 39
coleenp@4037 40 // Class to hold the various types of annotations. The only metadata that points
stefank@4393 41 // to this is InstanceKlass, or another Annotations instance if this is a
stefank@4393 42 // a type_annotation instance.
coleenp@4037 43
coleenp@4037 44 class Annotations: public MetaspaceObj {
coleenp@4037 45
coleenp@4037 46 // Annotations for this class, or null if none.
coleenp@4037 47 AnnotationArray* _class_annotations;
coleenp@4037 48 // Annotation objects (byte arrays) for fields, or null if no annotations.
coleenp@4037 49 // Indices correspond to entries (not indices) in fields array.
coleenp@4037 50 Array<AnnotationArray*>* _fields_annotations;
coleenp@4037 51 // Annotation objects (byte arrays) for methods, or null if no annotations.
coleenp@4037 52 // Index is the idnum, which is initially the same as the methods array index.
coleenp@4037 53 Array<AnnotationArray*>* _methods_annotations;
coleenp@4037 54 // Annotation objects (byte arrays) for methods' parameters, or null if no
coleenp@4037 55 // such annotations.
coleenp@4037 56 // Index is the idnum, which is initially the same as the methods array index.
coleenp@4037 57 Array<AnnotationArray*>* _methods_parameter_annotations;
coleenp@4037 58 // Annotation objects (byte arrays) for methods' default values, or null if no
coleenp@4037 59 // such annotations.
coleenp@4037 60 // Index is the idnum, which is initially the same as the methods array index.
coleenp@4037 61 Array<AnnotationArray*>* _methods_default_annotations;
stefank@4393 62 // Type annotations for this class, or null if none.
stefank@4393 63 Annotations* _type_annotations;
coleenp@4037 64
coleenp@4037 65 // Constructor where some some values are known to not be null
coleenp@4037 66 Annotations(Array<AnnotationArray*>* fa, Array<AnnotationArray*>* ma,
coleenp@4037 67 Array<AnnotationArray*>* mpa, Array<AnnotationArray*>* mda) :
coleenp@4037 68 _class_annotations(NULL),
coleenp@4037 69 _fields_annotations(fa),
coleenp@4037 70 _methods_annotations(ma),
coleenp@4037 71 _methods_parameter_annotations(mpa),
stefank@4393 72 _methods_default_annotations(mda),
stefank@4393 73 _type_annotations(NULL) {}
coleenp@4037 74
coleenp@4037 75 public:
coleenp@4037 76 // Allocate instance of this class
coleenp@4037 77 static Annotations* allocate(ClassLoaderData* loader_data, TRAPS);
coleenp@4037 78 static Annotations* allocate(ClassLoaderData* loader_data,
coleenp@4037 79 Array<AnnotationArray*>* fa,
coleenp@4037 80 Array<AnnotationArray*>* ma,
coleenp@4037 81 Array<AnnotationArray*>* mpa,
coleenp@4037 82 Array<AnnotationArray*>* mda, TRAPS);
coleenp@4037 83 void deallocate_contents(ClassLoaderData* loader_data);
coleenp@4037 84 DEBUG_ONLY(bool on_stack() { return false; }) // for template
coleenp@4037 85 static int size() { return sizeof(Annotations) / wordSize; }
coleenp@4037 86
coleenp@4037 87 // Constructor to initialize to null
stefank@4393 88 Annotations() : _class_annotations(NULL),
stefank@4393 89 _fields_annotations(NULL),
coleenp@4037 90 _methods_annotations(NULL),
coleenp@4037 91 _methods_parameter_annotations(NULL),
stefank@4393 92 _methods_default_annotations(NULL),
stefank@4393 93 _type_annotations(NULL) {}
coleenp@4037 94
coleenp@4037 95 AnnotationArray* class_annotations() const { return _class_annotations; }
coleenp@4037 96 Array<AnnotationArray*>* fields_annotations() const { return _fields_annotations; }
coleenp@4037 97 Array<AnnotationArray*>* methods_annotations() const { return _methods_annotations; }
coleenp@4037 98 Array<AnnotationArray*>* methods_parameter_annotations() const { return _methods_parameter_annotations; }
coleenp@4037 99 Array<AnnotationArray*>* methods_default_annotations() const { return _methods_default_annotations; }
stefank@4393 100 Annotations* type_annotations() const { return _type_annotations; }
coleenp@4037 101
coleenp@4037 102 void set_class_annotations(AnnotationArray* md) { _class_annotations = md; }
coleenp@4037 103 void set_fields_annotations(Array<AnnotationArray*>* md) { _fields_annotations = md; }
coleenp@4037 104 void set_methods_annotations(Array<AnnotationArray*>* md) { _methods_annotations = md; }
coleenp@4037 105 void set_methods_parameter_annotations(Array<AnnotationArray*>* md) { _methods_parameter_annotations = md; }
coleenp@4037 106 void set_methods_default_annotations(Array<AnnotationArray*>* md) { _methods_default_annotations = md; }
stefank@4393 107 void set_type_annotations(Annotations* annos) { _type_annotations = annos; }
coleenp@4037 108
coleenp@4037 109 // Redefine classes support
coleenp@4037 110 AnnotationArray* get_method_annotations_of(int idnum)
coleenp@4037 111 { return get_method_annotations_from(idnum, _methods_annotations); }
coleenp@4037 112
coleenp@4037 113 AnnotationArray* get_method_parameter_annotations_of(int idnum)
coleenp@4037 114 { return get_method_annotations_from(idnum, _methods_parameter_annotations); }
coleenp@4037 115 AnnotationArray* get_method_default_annotations_of(int idnum)
coleenp@4037 116 { return get_method_annotations_from(idnum, _methods_default_annotations); }
coleenp@4037 117
coleenp@4037 118
coleenp@4037 119 void set_method_annotations_of(instanceKlassHandle ik,
coleenp@4037 120 int idnum, AnnotationArray* anno, TRAPS) {
coleenp@4037 121 set_methods_annotations_of(ik, idnum, anno, &_methods_annotations, THREAD);
coleenp@4037 122 }
coleenp@4037 123
coleenp@4037 124 void set_method_parameter_annotations_of(instanceKlassHandle ik,
coleenp@4037 125 int idnum, AnnotationArray* anno, TRAPS) {
coleenp@4037 126 set_methods_annotations_of(ik, idnum, anno, &_methods_parameter_annotations, THREAD);
coleenp@4037 127 }
coleenp@4037 128
coleenp@4037 129 void set_method_default_annotations_of(instanceKlassHandle ik,
coleenp@4037 130 int idnum, AnnotationArray* anno, TRAPS) {
coleenp@4037 131 set_methods_annotations_of(ik, idnum, anno, &_methods_default_annotations, THREAD);
coleenp@4037 132 }
coleenp@4037 133
coleenp@4037 134 // Turn metadata annotations into a Java heap object (oop)
coleenp@4037 135 static typeArrayOop make_java_array(AnnotationArray* annotations, TRAPS);
coleenp@4037 136
coleenp@4037 137 inline AnnotationArray* get_method_annotations_from(int idnum, Array<AnnotationArray*>* annos);
coleenp@4037 138 void set_annotations(Array<AnnotationArray*>* md, Array<AnnotationArray*>** md_p) { *md_p = md; }
coleenp@4037 139
stefank@4393 140 bool is_klass() const { return false; }
coleenp@4037 141 private:
coleenp@4037 142 void set_methods_annotations_of(instanceKlassHandle ik,
coleenp@4037 143 int idnum, AnnotationArray* anno,
coleenp@4037 144 Array<AnnotationArray*>** md_p, TRAPS);
coleenp@4037 145
coleenp@4037 146 public:
coleenp@4037 147 const char* internal_name() const { return "{constant pool}"; }
coleenp@4037 148 #ifndef PRODUCT
coleenp@4037 149 void print_on(outputStream* st) const;
coleenp@4037 150 #endif
coleenp@4037 151 void print_value_on(outputStream* st) const;
coleenp@4037 152 };
coleenp@4037 153
coleenp@4037 154
coleenp@4037 155 // For method with idnum get the method's Annotations
coleenp@4037 156 inline AnnotationArray* Annotations::get_method_annotations_from(int idnum, Array<AnnotationArray*>* annos) {
coleenp@4037 157 if (annos == NULL || annos->length() <= idnum) {
coleenp@4037 158 return NULL;
coleenp@4037 159 }
coleenp@4037 160 return annos->at(idnum);
coleenp@4037 161 }
coleenp@4037 162 #endif // SHARE_VM_OOPS_ANNOTATIONS_HPP

mercurial