annotate src/share/vm/oops/annotations.hpp @ 5699:9d15b81d5d1b

8016839: JSR292: AME instead of IAE when calling a method Summary: Catch missing-because-illegal case for itable entries and use an exception-throwing method instead of null. Reviewed-by: acorn, jrose, coleenp
author drchase
date Tue, 26 Nov 2013 18:16:04 -0500
parents 16fb9f942703
children
rev   line source
coleenp@3602 1 /*
acorn@4062 2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
coleenp@3602 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
coleenp@3602 4 *
coleenp@3602 5 * This code is free software; you can redistribute it and/or modify it
coleenp@3602 6 * under the terms of the GNU General Public License version 2 only, as
coleenp@3602 7 * published by the Free Software Foundation.
coleenp@3602 8 *
coleenp@3602 9 * This code is distributed in the hope that it will be useful, but WITHOUT
coleenp@3602 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
coleenp@3602 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
coleenp@3602 12 * version 2 for more details (a copy is included in the LICENSE file that
coleenp@3602 13 * accompanied this code).
coleenp@3602 14 *
coleenp@3602 15 * You should have received a copy of the GNU General Public License version
coleenp@3602 16 * 2 along with this work; if not, write to the Free Software Foundation,
coleenp@3602 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
coleenp@3602 18 *
coleenp@3602 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
coleenp@3602 20 * or visit www.oracle.com if you need additional information or have any
coleenp@3602 21 * questions.
coleenp@3602 22 *
coleenp@3602 23 */
coleenp@3602 24
coleenp@3602 25 #ifndef SHARE_VM_OOPS_ANNOTATIONS_HPP
coleenp@3602 26 #define SHARE_VM_OOPS_ANNOTATIONS_HPP
coleenp@3602 27
coleenp@3602 28 #include "oops/metadata.hpp"
coleenp@3602 29 #include "runtime/handles.hpp"
coleenp@3602 30 #include "utilities/array.hpp"
coleenp@3602 31 #include "utilities/exceptions.hpp"
coleenp@3602 32 #include "utilities/globalDefinitions.hpp"
coleenp@3602 33
coleenp@3602 34
coleenp@3602 35 class ClassLoaderData;
coleenp@3602 36 class outputStream;
acorn@4062 37 class KlassSizeStats;
coleenp@3602 38
coleenp@3602 39 typedef Array<u1> AnnotationArray;
coleenp@3602 40
coleenp@3602 41 // Class to hold the various types of annotations. The only metadata that points
stefank@3958 42 // to this is InstanceKlass, or another Annotations instance if this is a
stefank@3958 43 // a type_annotation instance.
coleenp@3602 44
coleenp@3602 45 class Annotations: public MetaspaceObj {
coleenp@3602 46
coleenp@3602 47 // Annotations for this class, or null if none.
coleenp@3602 48 AnnotationArray* _class_annotations;
coleenp@3602 49 // Annotation objects (byte arrays) for fields, or null if no annotations.
coleenp@3602 50 // Indices correspond to entries (not indices) in fields array.
coleenp@3602 51 Array<AnnotationArray*>* _fields_annotations;
stefank@3958 52 // Type annotations for this class, or null if none.
coleenp@4137 53 AnnotationArray* _class_type_annotations;
coleenp@4137 54 Array<AnnotationArray*>* _fields_type_annotations;
coleenp@3602 55
coleenp@3602 56 public:
coleenp@3602 57 // Allocate instance of this class
coleenp@3602 58 static Annotations* allocate(ClassLoaderData* loader_data, TRAPS);
coleenp@4137 59
coleenp@4137 60 static void free_contents(ClassLoaderData* loader_data, Array<AnnotationArray*>* p);
coleenp@3602 61 void deallocate_contents(ClassLoaderData* loader_data);
coleenp@3602 62 DEBUG_ONLY(bool on_stack() { return false; }) // for template
acorn@4062 63
acorn@4062 64 // Sizing (in words)
coleenp@3602 65 static int size() { return sizeof(Annotations) / wordSize; }
acorn@4062 66 #if INCLUDE_SERVICES
acorn@4062 67 void collect_statistics(KlassSizeStats *sz) const;
acorn@4062 68 #endif
coleenp@3602 69
coleenp@3602 70 // Constructor to initialize to null
stefank@3958 71 Annotations() : _class_annotations(NULL),
stefank@3958 72 _fields_annotations(NULL),
coleenp@4137 73 _class_type_annotations(NULL),
coleenp@4137 74 _fields_type_annotations(NULL) {}
coleenp@3602 75
coleenp@3602 76 AnnotationArray* class_annotations() const { return _class_annotations; }
coleenp@3602 77 Array<AnnotationArray*>* fields_annotations() const { return _fields_annotations; }
coleenp@4137 78 AnnotationArray* class_type_annotations() const { return _class_type_annotations; }
coleenp@4137 79 Array<AnnotationArray*>* fields_type_annotations() const { return _fields_type_annotations; }
coleenp@3602 80
coleenp@3602 81 void set_class_annotations(AnnotationArray* md) { _class_annotations = md; }
coleenp@3602 82 void set_fields_annotations(Array<AnnotationArray*>* md) { _fields_annotations = md; }
coleenp@4137 83 void set_class_type_annotations(AnnotationArray* cta) { _class_type_annotations = cta; }
coleenp@4137 84 void set_fields_type_annotations(Array<AnnotationArray*>* fta) { _fields_type_annotations = fta; }
coleenp@3602 85
coleenp@3602 86 // Turn metadata annotations into a Java heap object (oop)
coleenp@3602 87 static typeArrayOop make_java_array(AnnotationArray* annotations, TRAPS);
coleenp@3602 88
stefank@3958 89 bool is_klass() const { return false; }
coleenp@3602 90 private:
acorn@4062 91 static julong count_bytes(Array<AnnotationArray*>* p);
coleenp@3602 92 public:
coleenp@3602 93 const char* internal_name() const { return "{constant pool}"; }
coleenp@3602 94 #ifndef PRODUCT
coleenp@3602 95 void print_on(outputStream* st) const;
coleenp@3602 96 #endif
coleenp@3602 97 void print_value_on(outputStream* st) const;
coleenp@3602 98 };
coleenp@3602 99 #endif // SHARE_VM_OOPS_ANNOTATIONS_HPP