< prev index next >

src/share/vm/oops/annotations.hpp

Print this page


  46 
  47   // Annotations for this class, or null if none.
  48   AnnotationArray*             _class_annotations;
  49   // Annotation objects (byte arrays) for fields, or null if no annotations.
  50   // Indices correspond to entries (not indices) in fields array.
  51   Array<AnnotationArray*>*     _fields_annotations;
  52   // Type annotations for this class, or null if none.
  53   AnnotationArray*             _class_type_annotations;
  54   Array<AnnotationArray*>*     _fields_type_annotations;
  55 
  56  public:
  57   // Allocate instance of this class
  58   static Annotations* allocate(ClassLoaderData* loader_data, TRAPS);
  59 
  60   static void free_contents(ClassLoaderData* loader_data, Array<AnnotationArray*>* p);
  61   void deallocate_contents(ClassLoaderData* loader_data);
  62   DEBUG_ONLY(bool on_stack() { return false; })  // for template
  63 
  64   // Sizing (in words)
  65   static int size()    { return sizeof(Annotations) / wordSize; }




  66 #if INCLUDE_SERVICES
  67   void collect_statistics(KlassSizeStats *sz) const;
  68 #endif
  69 
  70   // Constructor to initialize to null
  71   Annotations() : _class_annotations(NULL),
  72                   _fields_annotations(NULL),
  73                   _class_type_annotations(NULL),
  74                   _fields_type_annotations(NULL) {}
  75 
  76   AnnotationArray* class_annotations() const                       { return _class_annotations; }
  77   Array<AnnotationArray*>* fields_annotations() const              { return _fields_annotations; }
  78   AnnotationArray* class_type_annotations() const                  { return _class_type_annotations; }
  79   Array<AnnotationArray*>* fields_type_annotations() const         { return _fields_type_annotations; }
  80 
  81   void set_class_annotations(AnnotationArray* md)                     { _class_annotations = md; }
  82   void set_fields_annotations(Array<AnnotationArray*>* md)            { _fields_annotations = md; }
  83   void set_class_type_annotations(AnnotationArray* cta)               { _class_type_annotations = cta; }
  84   void set_fields_type_annotations(Array<AnnotationArray*>* fta)      { _fields_type_annotations = fta; }
  85 
  86   // Turn metadata annotations into a Java heap object (oop)
  87   static typeArrayOop make_java_array(AnnotationArray* annotations, TRAPS);
  88 
  89   bool is_klass() const { return false; }



  90  private:
  91   static julong count_bytes(Array<AnnotationArray*>* p);
  92  public:
  93   const char* internal_name() const { return "{constant pool}"; }
  94 #ifndef PRODUCT
  95   void print_on(outputStream* st) const;
  96 #endif
  97   void print_value_on(outputStream* st) const;
  98 };
  99 #endif // SHARE_VM_OOPS_ANNOTATIONS_HPP


  46 
  47   // Annotations for this class, or null if none.
  48   AnnotationArray*             _class_annotations;
  49   // Annotation objects (byte arrays) for fields, or null if no annotations.
  50   // Indices correspond to entries (not indices) in fields array.
  51   Array<AnnotationArray*>*     _fields_annotations;
  52   // Type annotations for this class, or null if none.
  53   AnnotationArray*             _class_type_annotations;
  54   Array<AnnotationArray*>*     _fields_type_annotations;
  55 
  56  public:
  57   // Allocate instance of this class
  58   static Annotations* allocate(ClassLoaderData* loader_data, TRAPS);
  59 
  60   static void free_contents(ClassLoaderData* loader_data, Array<AnnotationArray*>* p);
  61   void deallocate_contents(ClassLoaderData* loader_data);
  62   DEBUG_ONLY(bool on_stack() { return false; })  // for template
  63 
  64   // Sizing (in words)
  65   static int size()    { return sizeof(Annotations) / wordSize; }
  66 
  67   // Annotations should be stored in the read-only region of CDS archive.
  68   static bool is_read_only_by_default() { return true; }
  69 
  70 #if INCLUDE_SERVICES
  71   void collect_statistics(KlassSizeStats *sz) const;
  72 #endif
  73 
  74   // Constructor to initialize to null
  75   Annotations() : _class_annotations(NULL),
  76                   _fields_annotations(NULL),
  77                   _class_type_annotations(NULL),
  78                   _fields_type_annotations(NULL) {}
  79 
  80   AnnotationArray* class_annotations() const                       { return _class_annotations; }
  81   Array<AnnotationArray*>* fields_annotations() const              { return _fields_annotations; }
  82   AnnotationArray* class_type_annotations() const                  { return _class_type_annotations; }
  83   Array<AnnotationArray*>* fields_type_annotations() const         { return _fields_type_annotations; }
  84 
  85   void set_class_annotations(AnnotationArray* md)                     { _class_annotations = md; }
  86   void set_fields_annotations(Array<AnnotationArray*>* md)            { _fields_annotations = md; }
  87   void set_class_type_annotations(AnnotationArray* cta)               { _class_type_annotations = cta; }
  88   void set_fields_type_annotations(Array<AnnotationArray*>* fta)      { _fields_type_annotations = fta; }
  89 
  90   // Turn metadata annotations into a Java heap object (oop)
  91   static typeArrayOop make_java_array(AnnotationArray* annotations, TRAPS);
  92 
  93   bool is_klass() const { return false; }
  94   void metaspace_pointers_do(MetaspaceClosure* it);
  95   MetaspaceObj::Type type() const { return AnnotationsType; }
  96 
  97  private:
  98   static julong count_bytes(Array<AnnotationArray*>* p);
  99  public:
 100   const char* internal_name() const { return "{constant pool}"; }
 101 #ifndef PRODUCT
 102   void print_on(outputStream* st) const;
 103 #endif
 104   void print_value_on(outputStream* st) const;
 105 };
 106 #endif // SHARE_VM_OOPS_ANNOTATIONS_HPP
< prev index next >