coleenp@4037: /* acorn@4497: * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. coleenp@4037: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. coleenp@4037: * coleenp@4037: * This code is free software; you can redistribute it and/or modify it coleenp@4037: * under the terms of the GNU General Public License version 2 only, as coleenp@4037: * published by the Free Software Foundation. coleenp@4037: * coleenp@4037: * This code is distributed in the hope that it will be useful, but WITHOUT coleenp@4037: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or coleenp@4037: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License coleenp@4037: * version 2 for more details (a copy is included in the LICENSE file that coleenp@4037: * accompanied this code). coleenp@4037: * coleenp@4037: * You should have received a copy of the GNU General Public License version coleenp@4037: * 2 along with this work; if not, write to the Free Software Foundation, coleenp@4037: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. coleenp@4037: * coleenp@4037: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA coleenp@4037: * or visit www.oracle.com if you need additional information or have any coleenp@4037: * questions. coleenp@4037: * coleenp@4037: */ coleenp@4037: coleenp@4037: #ifndef SHARE_VM_OOPS_ANNOTATIONS_HPP coleenp@4037: #define SHARE_VM_OOPS_ANNOTATIONS_HPP coleenp@4037: coleenp@4037: #include "oops/metadata.hpp" coleenp@4037: #include "runtime/handles.hpp" coleenp@4037: #include "utilities/array.hpp" coleenp@4037: #include "utilities/exceptions.hpp" coleenp@4037: #include "utilities/globalDefinitions.hpp" coleenp@4037: coleenp@4037: coleenp@4037: class ClassLoaderData; coleenp@4037: class outputStream; acorn@4497: class KlassSizeStats; coleenp@4037: coleenp@4037: typedef Array AnnotationArray; coleenp@4037: coleenp@4037: // Class to hold the various types of annotations. The only metadata that points stefank@4393: // to this is InstanceKlass, or another Annotations instance if this is a stefank@4393: // a type_annotation instance. coleenp@4037: coleenp@4037: class Annotations: public MetaspaceObj { coleenp@4037: coleenp@4037: // Annotations for this class, or null if none. coleenp@4037: AnnotationArray* _class_annotations; coleenp@4037: // Annotation objects (byte arrays) for fields, or null if no annotations. coleenp@4037: // Indices correspond to entries (not indices) in fields array. coleenp@4037: Array* _fields_annotations; stefank@4393: // Type annotations for this class, or null if none. coleenp@4572: AnnotationArray* _class_type_annotations; coleenp@4572: Array* _fields_type_annotations; coleenp@4037: coleenp@4037: public: coleenp@4037: // Allocate instance of this class coleenp@4037: static Annotations* allocate(ClassLoaderData* loader_data, TRAPS); coleenp@4572: coleenp@4572: static void free_contents(ClassLoaderData* loader_data, Array* p); coleenp@4037: void deallocate_contents(ClassLoaderData* loader_data); coleenp@4037: DEBUG_ONLY(bool on_stack() { return false; }) // for template acorn@4497: acorn@4497: // Sizing (in words) coleenp@4037: static int size() { return sizeof(Annotations) / wordSize; } acorn@4497: #if INCLUDE_SERVICES acorn@4497: void collect_statistics(KlassSizeStats *sz) const; acorn@4497: #endif coleenp@4037: coleenp@4037: // Constructor to initialize to null stefank@4393: Annotations() : _class_annotations(NULL), stefank@4393: _fields_annotations(NULL), coleenp@4572: _class_type_annotations(NULL), coleenp@4572: _fields_type_annotations(NULL) {} coleenp@4037: coleenp@4037: AnnotationArray* class_annotations() const { return _class_annotations; } coleenp@4037: Array* fields_annotations() const { return _fields_annotations; } coleenp@4572: AnnotationArray* class_type_annotations() const { return _class_type_annotations; } coleenp@4572: Array* fields_type_annotations() const { return _fields_type_annotations; } coleenp@4037: coleenp@4037: void set_class_annotations(AnnotationArray* md) { _class_annotations = md; } coleenp@4037: void set_fields_annotations(Array* md) { _fields_annotations = md; } coleenp@4572: void set_class_type_annotations(AnnotationArray* cta) { _class_type_annotations = cta; } coleenp@4572: void set_fields_type_annotations(Array* fta) { _fields_type_annotations = fta; } coleenp@4037: coleenp@4037: // Turn metadata annotations into a Java heap object (oop) coleenp@4037: static typeArrayOop make_java_array(AnnotationArray* annotations, TRAPS); coleenp@4037: stefank@4393: bool is_klass() const { return false; } coleenp@4037: private: acorn@4497: static julong count_bytes(Array* p); coleenp@4037: public: coleenp@4037: const char* internal_name() const { return "{constant pool}"; } coleenp@4037: #ifndef PRODUCT coleenp@4037: void print_on(outputStream* st) const; coleenp@4037: #endif coleenp@4037: void print_value_on(outputStream* st) const; coleenp@4037: }; coleenp@4037: #endif // SHARE_VM_OOPS_ANNOTATIONS_HPP