src/hotspot/share/oops/annotations.hpp
author hseigel
Wed, 21 Aug 2019 11:29:40 -0400
changeset 57823 efb2770e8288
parent 53244 9807daeb47c4
permissions -rw-r--r--
8229930: internal_name() in annotations.hpp returns "{constant pool}" Summary: Fix typo and change text to "{annotations}" Reviewed-by: mdoerr, dcubed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52645
diff changeset
     2
 * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     4
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     7
 * published by the Free Software Foundation.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     8
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    13
 * accompanied this code).
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    14
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    18
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    21
 * questions.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    22
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    23
 */
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    24
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52645
diff changeset
    25
#ifndef SHARE_OOPS_ANNOTATIONS_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52645
diff changeset
    26
#define SHARE_OOPS_ANNOTATIONS_HPP
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    27
46448
b5350a83520b 8153646: Move vm/utilities/array.hpp to vm/oops
hseigel
parents: 15601
diff changeset
    28
#include "oops/array.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    29
#include "oops/metadata.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    30
#include "utilities/exceptions.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    31
#include "utilities/globalDefinitions.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    32
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    33
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    34
class ClassLoaderData;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    35
class outputStream;
15437
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 15097
diff changeset
    36
class KlassSizeStats;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    37
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    38
typedef Array<u1> AnnotationArray;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    39
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    40
// Class to hold the various types of annotations. The only metadata that points
15097
9db149412e0e 8004823: Add VM support for type annotation reflection
stefank
parents: 13728
diff changeset
    41
// to this is InstanceKlass, or another Annotations instance if this is a
9db149412e0e 8004823: Add VM support for type annotation reflection
stefank
parents: 13728
diff changeset
    42
// a type_annotation instance.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    43
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    44
class Annotations: public MetaspaceObj {
52645
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 49480
diff changeset
    45
 friend class JVMCIVMStructs;
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 49480
diff changeset
    46
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46448
diff changeset
    47
  // If you add a new field that points to any metaspace object, you
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46448
diff changeset
    48
  // must add this field to Annotations::metaspace_pointers_do().
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    49
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    50
  // Annotations for this class, or null if none.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    51
  AnnotationArray*             _class_annotations;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    52
  // Annotation objects (byte arrays) for fields, or null if no annotations.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    53
  // Indices correspond to entries (not indices) in fields array.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    54
  Array<AnnotationArray*>*     _fields_annotations;
15097
9db149412e0e 8004823: Add VM support for type annotation reflection
stefank
parents: 13728
diff changeset
    55
  // Type annotations for this class, or null if none.
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    56
  AnnotationArray*             _class_type_annotations;
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    57
  Array<AnnotationArray*>*     _fields_type_annotations;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    58
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    59
 public:
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    60
  // Allocate instance of this class
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    61
  static Annotations* allocate(ClassLoaderData* loader_data, TRAPS);
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    62
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    63
  static void free_contents(ClassLoaderData* loader_data, Array<AnnotationArray*>* p);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    64
  void deallocate_contents(ClassLoaderData* loader_data);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    65
  DEBUG_ONLY(bool on_stack() { return false; })  // for template
15437
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 15097
diff changeset
    66
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 15097
diff changeset
    67
  // Sizing (in words)
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    68
  static int size()    { return sizeof(Annotations) / wordSize; }
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46448
diff changeset
    69
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46448
diff changeset
    70
  // Annotations should be stored in the read-only region of CDS archive.
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46448
diff changeset
    71
  static bool is_read_only_by_default() { return true; }
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46448
diff changeset
    72
15437
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 15097
diff changeset
    73
#if INCLUDE_SERVICES
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 15097
diff changeset
    74
  void collect_statistics(KlassSizeStats *sz) const;
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 15097
diff changeset
    75
#endif
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    76
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    77
  // Constructor to initialize to null
15097
9db149412e0e 8004823: Add VM support for type annotation reflection
stefank
parents: 13728
diff changeset
    78
  Annotations() : _class_annotations(NULL),
9db149412e0e 8004823: Add VM support for type annotation reflection
stefank
parents: 13728
diff changeset
    79
                  _fields_annotations(NULL),
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    80
                  _class_type_annotations(NULL),
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    81
                  _fields_type_annotations(NULL) {}
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    82
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    83
  AnnotationArray* class_annotations() const                       { return _class_annotations; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    84
  Array<AnnotationArray*>* fields_annotations() const              { return _fields_annotations; }
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    85
  AnnotationArray* class_type_annotations() const                  { return _class_type_annotations; }
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    86
  Array<AnnotationArray*>* fields_type_annotations() const         { return _fields_type_annotations; }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    87
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    88
  void set_class_annotations(AnnotationArray* md)                     { _class_annotations = md; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    89
  void set_fields_annotations(Array<AnnotationArray*>* md)            { _fields_annotations = md; }
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    90
  void set_class_type_annotations(AnnotationArray* cta)               { _class_type_annotations = cta; }
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    91
  void set_fields_type_annotations(Array<AnnotationArray*>* fta)      { _fields_type_annotations = fta; }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    92
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    93
  // Turn metadata annotations into a Java heap object (oop)
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    94
  static typeArrayOop make_java_array(AnnotationArray* annotations, TRAPS);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    95
15097
9db149412e0e 8004823: Add VM support for type annotation reflection
stefank
parents: 13728
diff changeset
    96
  bool is_klass() const { return false; }
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46448
diff changeset
    97
  void metaspace_pointers_do(MetaspaceClosure* it);
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46448
diff changeset
    98
  MetaspaceObj::Type type() const { return AnnotationsType; }
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46448
diff changeset
    99
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   100
 private:
15437
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 15097
diff changeset
   101
  static julong count_bytes(Array<AnnotationArray*>* p);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   102
 public:
57823
efb2770e8288 8229930: internal_name() in annotations.hpp returns "{constant pool}"
hseigel
parents: 53244
diff changeset
   103
  const char* internal_name() const { return "{annotations}"; }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   104
#ifndef PRODUCT
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   105
  void print_on(outputStream* st) const;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   106
#endif
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   107
  void print_value_on(outputStream* st) const;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   108
};
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52645
diff changeset
   109
#endif // SHARE_OOPS_ANNOTATIONS_HPP