src/share/vm/oops/annotations.hpp

Mon, 29 Apr 2013 16:13:57 -0400

author
hseigel
date
Mon, 29 Apr 2013 16:13:57 -0400
changeset 4987
f258c5828eb8
parent 4572
927a311d00f9
child 6876
710a3c8b516e
permissions
-rw-r--r--

8011773: Some tests on Interned String crashed JVM with OOM
Summary: Instead of terminating the VM, throw OutOfMemoryError exceptions.
Reviewed-by: coleenp, dholmes

coleenp@4037 1 /*
acorn@4497 2 * Copyright (c) 2012, 2013, 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;
acorn@4497 37 class KlassSizeStats;
coleenp@4037 38
coleenp@4037 39 typedef Array<u1> AnnotationArray;
coleenp@4037 40
coleenp@4037 41 // Class to hold the various types of annotations. The only metadata that points
stefank@4393 42 // to this is InstanceKlass, or another Annotations instance if this is a
stefank@4393 43 // a type_annotation instance.
coleenp@4037 44
coleenp@4037 45 class Annotations: public MetaspaceObj {
coleenp@4037 46
coleenp@4037 47 // Annotations for this class, or null if none.
coleenp@4037 48 AnnotationArray* _class_annotations;
coleenp@4037 49 // Annotation objects (byte arrays) for fields, or null if no annotations.
coleenp@4037 50 // Indices correspond to entries (not indices) in fields array.
coleenp@4037 51 Array<AnnotationArray*>* _fields_annotations;
stefank@4393 52 // Type annotations for this class, or null if none.
coleenp@4572 53 AnnotationArray* _class_type_annotations;
coleenp@4572 54 Array<AnnotationArray*>* _fields_type_annotations;
coleenp@4037 55
coleenp@4037 56 public:
coleenp@4037 57 // Allocate instance of this class
coleenp@4037 58 static Annotations* allocate(ClassLoaderData* loader_data, TRAPS);
coleenp@4572 59
coleenp@4572 60 static void free_contents(ClassLoaderData* loader_data, Array<AnnotationArray*>* p);
coleenp@4037 61 void deallocate_contents(ClassLoaderData* loader_data);
coleenp@4037 62 DEBUG_ONLY(bool on_stack() { return false; }) // for template
acorn@4497 63
acorn@4497 64 // Sizing (in words)
coleenp@4037 65 static int size() { return sizeof(Annotations) / wordSize; }
acorn@4497 66 #if INCLUDE_SERVICES
acorn@4497 67 void collect_statistics(KlassSizeStats *sz) const;
acorn@4497 68 #endif
coleenp@4037 69
coleenp@4037 70 // Constructor to initialize to null
stefank@4393 71 Annotations() : _class_annotations(NULL),
stefank@4393 72 _fields_annotations(NULL),
coleenp@4572 73 _class_type_annotations(NULL),
coleenp@4572 74 _fields_type_annotations(NULL) {}
coleenp@4037 75
coleenp@4037 76 AnnotationArray* class_annotations() const { return _class_annotations; }
coleenp@4037 77 Array<AnnotationArray*>* fields_annotations() const { return _fields_annotations; }
coleenp@4572 78 AnnotationArray* class_type_annotations() const { return _class_type_annotations; }
coleenp@4572 79 Array<AnnotationArray*>* fields_type_annotations() const { return _fields_type_annotations; }
coleenp@4037 80
coleenp@4037 81 void set_class_annotations(AnnotationArray* md) { _class_annotations = md; }
coleenp@4037 82 void set_fields_annotations(Array<AnnotationArray*>* md) { _fields_annotations = md; }
coleenp@4572 83 void set_class_type_annotations(AnnotationArray* cta) { _class_type_annotations = cta; }
coleenp@4572 84 void set_fields_type_annotations(Array<AnnotationArray*>* fta) { _fields_type_annotations = fta; }
coleenp@4037 85
coleenp@4037 86 // Turn metadata annotations into a Java heap object (oop)
coleenp@4037 87 static typeArrayOop make_java_array(AnnotationArray* annotations, TRAPS);
coleenp@4037 88
stefank@4393 89 bool is_klass() const { return false; }
coleenp@4037 90 private:
acorn@4497 91 static julong count_bytes(Array<AnnotationArray*>* p);
coleenp@4037 92 public:
coleenp@4037 93 const char* internal_name() const { return "{constant pool}"; }
coleenp@4037 94 #ifndef PRODUCT
coleenp@4037 95 void print_on(outputStream* st) const;
coleenp@4037 96 #endif
coleenp@4037 97 void print_value_on(outputStream* st) const;
coleenp@4037 98 };
coleenp@4037 99 #endif // SHARE_VM_OOPS_ANNOTATIONS_HPP

mercurial