Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/oops/annotations.hpp
32285 views
/*1* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_OOPS_ANNOTATIONS_HPP25#define SHARE_VM_OOPS_ANNOTATIONS_HPP2627#include "oops/metadata.hpp"28#include "runtime/handles.hpp"29#include "utilities/array.hpp"30#include "utilities/exceptions.hpp"31#include "utilities/globalDefinitions.hpp"323334class ClassLoaderData;35class outputStream;36class KlassSizeStats;3738typedef Array<u1> AnnotationArray;3940// Class to hold the various types of annotations. The only metadata that points41// to this is InstanceKlass, or another Annotations instance if this is a42// a type_annotation instance.4344class Annotations: public MetaspaceObj {4546// Annotations for this class, or null if none.47AnnotationArray* _class_annotations;48// Annotation objects (byte arrays) for fields, or null if no annotations.49// Indices correspond to entries (not indices) in fields array.50Array<AnnotationArray*>* _fields_annotations;51// Type annotations for this class, or null if none.52AnnotationArray* _class_type_annotations;53Array<AnnotationArray*>* _fields_type_annotations;5455public:56// Allocate instance of this class57static Annotations* allocate(ClassLoaderData* loader_data, TRAPS);5859static void free_contents(ClassLoaderData* loader_data, Array<AnnotationArray*>* p);60void deallocate_contents(ClassLoaderData* loader_data);61DEBUG_ONLY(bool on_stack() { return false; }) // for template6263// Sizing (in words)64static int size() { return sizeof(Annotations) / wordSize; }65#if INCLUDE_SERVICES66void collect_statistics(KlassSizeStats *sz) const;67#endif6869// Constructor to initialize to null70Annotations() : _class_annotations(NULL),71_fields_annotations(NULL),72_class_type_annotations(NULL),73_fields_type_annotations(NULL) {}7475AnnotationArray* class_annotations() const { return _class_annotations; }76Array<AnnotationArray*>* fields_annotations() const { return _fields_annotations; }77AnnotationArray* class_type_annotations() const { return _class_type_annotations; }78Array<AnnotationArray*>* fields_type_annotations() const { return _fields_type_annotations; }7980void set_class_annotations(AnnotationArray* md) { _class_annotations = md; }81void set_fields_annotations(Array<AnnotationArray*>* md) { _fields_annotations = md; }82void set_class_type_annotations(AnnotationArray* cta) { _class_type_annotations = cta; }83void set_fields_type_annotations(Array<AnnotationArray*>* fta) { _fields_type_annotations = fta; }8485// Turn metadata annotations into a Java heap object (oop)86static typeArrayOop make_java_array(AnnotationArray* annotations, TRAPS);8788bool is_klass() const { return false; }89private:90static julong count_bytes(Array<AnnotationArray*>* p);91public:92const char* internal_name() const { return "{constant pool}"; }93#ifndef PRODUCT94void print_on(outputStream* st) const;95#endif96void print_value_on(outputStream* st) const;97};98#endif // SHARE_VM_OOPS_ANNOTATIONS_HPP99100101