< prev index next >

src/hotspot/share/classfile/classLoaderData.hpp

Print this page




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_CLASSFILE_CLASSLOADERDATA_HPP
  26 #define SHARE_VM_CLASSFILE_CLASSLOADERDATA_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "memory/memRegion.hpp"
  30 #include "memory/metaspace.hpp"
  31 #include "memory/metaspaceCounters.hpp"
  32 #include "oops/oopHandle.hpp"
  33 #include "oops/weakHandle.hpp"
  34 #include "runtime/mutex.hpp"
  35 #include "trace/traceMacros.hpp"
  36 #include "utilities/growableArray.hpp"
  37 #include "utilities/macros.hpp"
  38 #if INCLUDE_TRACE
  39 #include "utilities/ticks.hpp"
  40 #endif
  41 
  42 //
  43 // A class loader represents a linkset. Conceptually, a linkset identifies
  44 // the complete transitive closure of resolved links that a dynamic linker can
  45 // produce.
  46 //
  47 // A ClassLoaderData also encapsulates the allocation space, called a metaspace,
  48 // used by the dynamic linker to allocate the runtime representation of all
  49 // the types it defines.
  50 //
  51 // ClassLoaderData are stored in the runtime representation of classes,


  67   friend class ClassLoaderData;
  68   friend class ClassLoaderDataGraphMetaspaceIterator;
  69   friend class ClassLoaderDataGraphKlassIteratorAtomic;
  70   friend class ClassLoaderDataGraphKlassIteratorStatic;
  71   friend class VMStructs;
  72  private:
  73   // All CLDs (except the null CLD) can be reached by walking _head->_next->...
  74   static ClassLoaderData* _head;
  75   static ClassLoaderData* _unloading;
  76   // CMS support.
  77   static ClassLoaderData* _saved_head;
  78   static ClassLoaderData* _saved_unloading;
  79   static bool _should_purge;
  80   // OOM has been seen in metaspace allocation. Used to prevent some
  81   // allocations until class unloading
  82   static bool _metaspace_oom;
  83 
  84   static volatile size_t  _num_instance_classes;
  85   static volatile size_t  _num_array_classes;
  86 

  87   static ClassLoaderData* add(Handle class_loader, bool anonymous);
  88   static void post_class_unload_events();
  89  public:
  90   static ClassLoaderData* find_or_create(Handle class_loader);
  91   static void purge();
  92   static void clear_claimed_marks();
  93   // oops do
  94   static void oops_do(OopClosure* f, bool must_claim);
  95   static void keep_alive_oops_do(OopClosure* blk, bool must_claim);
  96   static void always_strong_oops_do(OopClosure* blk, bool must_claim);
  97   // cld do
  98   static void cld_do(CLDClosure* cl);
  99   static void cld_unloading_do(CLDClosure* cl);
 100   static void roots_cld_do(CLDClosure* strong, CLDClosure* weak);
 101   static void keep_alive_cld_do(CLDClosure* cl);
 102   static void always_strong_cld_do(CLDClosure* cl);
 103   // klass do
 104   // Walking classes through the ClassLoaderDataGraph include array classes.  It also includes
 105   // classes that are allocated but not loaded, classes that have errors, and scratch classes
 106   // for redefinition.  These classes are removed during the next class unloading.


 204     // However, multiple threads can execute oops_do concurrently with add.
 205     oop* add(oop o);
 206     bool contains(oop p);
 207     NOT_PRODUCT(bool owner_of(oop* p);)
 208     void oops_do(OopClosure* f);
 209 
 210     int count() const;
 211   };
 212 
 213   friend class ClassLoaderDataGraph;
 214   friend class ClassLoaderDataGraphKlassIteratorAtomic;
 215   friend class ClassLoaderDataGraphKlassIteratorStatic;
 216   friend class ClassLoaderDataGraphMetaspaceIterator;
 217   friend class InstanceKlass;
 218   friend class MetaDataFactory;
 219   friend class Method;
 220 
 221   static ClassLoaderData * _the_null_class_loader_data;
 222 
 223   WeakHandle<vm_class_loader_data> _holder; // The oop that determines lifetime of this class loader
 224   oop _class_loader;          // The instance of java/lang/ClassLoader associated with
 225                               // this ClassLoaderData
 226 
 227   ClassLoaderMetaspace * volatile _metaspace;  // Meta-space where meta-data defined by the
 228                                     // classes in the class loader are allocated.
 229   Mutex* _metaspace_lock;  // Locks the metaspace for allocations and setup.
 230   bool _unloading;         // true if this class loader goes away
 231   bool _is_anonymous;      // if this CLD is for an anonymous class
 232 
 233   // Remembered sets support for the oops in the class loader data.
 234   bool _modified_oops;             // Card Table Equivalent (YC/CMS support)
 235   bool _accumulated_modified_oops; // Mod Union Equivalent (CMS support)
 236 
 237   s2 _keep_alive;          // if this CLD is kept alive without a keep_alive_object().
 238                            // Used for anonymous classes and the boot class
 239                            // loader. _keep_alive does not need to be volatile or
 240                            // atomic since there is one unique CLD per anonymous class.
 241 
 242   volatile int _claimed;   // true if claimed, for example during GC traces.
 243                            // To avoid applying oop closure more than once.
 244                            // Has to be an int because we cas it.
 245   ChunkedHandleList _handles; // Handles to constant pool arrays, Modules, etc, which
 246                               // have the same life cycle of the corresponding ClassLoader.
 247 
 248   NOT_PRODUCT(volatile int _dependency_count;)  // number of class loader dependencies
 249 
 250   Klass* volatile _klasses;              // The classes defined by the class loader.
 251   PackageEntryTable* volatile _packages; // The packages defined by the class loader.
 252   ModuleEntryTable*  volatile _modules;  // The modules defined by the class loader.
 253   ModuleEntry* _unnamed_module;          // This class loader's unnamed module.
 254   Dictionary*  _dictionary;              // The loaded InstanceKlasses, including initiated by this class loader
 255 
 256   // These method IDs are created for the class loader and set to NULL when the
 257   // class loader is unloaded.  They are rarely freed, only for redefine classes
 258   // and if they lose a data race in InstanceKlass.
 259   JNIMethodBlock*                  _jmethod_ids;
 260 
 261   // Metadata to be deallocated when it's safe at class unloading, when
 262   // this class loader isn't unloaded itself.
 263   GrowableArray<Metadata*>*      _deallocate_list;
 264 
 265   // Support for walking class loader data objects
 266   ClassLoaderData* _next; /// Next loader_datas created
 267 



 268   TRACE_DEFINE_TRACE_ID_FIELD;
 269 
 270   void set_next(ClassLoaderData* next) { _next = next; }
 271   ClassLoaderData* next() const        { return _next; }
 272 
 273   ClassLoaderData(Handle h_class_loader, bool is_anonymous);
 274   ~ClassLoaderData();
 275 
 276   // The CLD are not placed in the Heap, so the Card Table or
 277   // the Mod Union Table can't be used to mark when CLD have modified oops.
 278   // The CT and MUT bits saves this information for the whole class loader data.
 279   void clear_modified_oops()             { _modified_oops = false; }
 280  public:
 281   void record_modified_oops()            { _modified_oops = true; }
 282   bool has_modified_oops()               { return _modified_oops; }
 283 
 284   void accumulate_modified_oops()        { if (has_modified_oops()) _accumulated_modified_oops = true; }
 285   void clear_accumulated_modified_oops() { _accumulated_modified_oops = false; }
 286   bool has_accumulated_modified_oops()   { return _accumulated_modified_oops; }
 287  private:
 288 
 289   void unload();
 290   bool keep_alive() const       { return _keep_alive > 0; }
 291 
 292   oop holder_phantom() const;
 293   void classes_do(void f(Klass*));
 294   void loaded_classes_do(KlassClosure* klass_closure);
 295   void classes_do(void f(InstanceKlass*));
 296   void methods_do(void f(Method*));
 297   void modules_do(void f(ModuleEntry*));
 298   void packages_do(void f(PackageEntry*));
 299 
 300   // Deallocate free list during class unloading.
 301   void free_deallocate_list();      // for the classes that are not unloaded
 302   void unload_deallocate_list();    // for the classes that are unloaded
 303 
 304   // Allocate out of this class loader data
 305   MetaWord* allocate(size_t size);
 306 
 307   Dictionary* create_dictionary();


 308  public:
 309   // GC interface.
 310   void clear_claimed() { _claimed = 0; }
 311   bool claimed() const { return _claimed == 1; }
 312   bool claim();
 313 
 314   bool is_alive() const;
 315 
 316   // Accessors
 317   ClassLoaderMetaspace* metaspace_or_null() const { return _metaspace; }
 318 
 319   static ClassLoaderData* the_null_class_loader_data() {
 320     return _the_null_class_loader_data;
 321   }
 322 
 323   Mutex* metaspace_lock() const { return _metaspace_lock; }
 324 
 325   bool is_anonymous() const { return _is_anonymous; }
 326 
 327   static void init_null_class_loader_data();
 328 
 329   bool is_the_null_class_loader_data() const {
 330     return this == _the_null_class_loader_data;
 331   }
 332 
 333   // Returns true if this class loader data is for the system class loader.
 334   // (Note that the class loader data may be anonymous.)
 335   bool is_system_class_loader_data() const;
 336 
 337   // Returns true if this class loader data is for the platform class loader.
 338   // (Note that the class loader data may be anonymous.)
 339   bool is_platform_class_loader_data() const;
 340 
 341   // Returns true if this class loader data is for the boot class loader.
 342   // (Note that the class loader data may be anonymous.)
 343   bool is_boot_class_loader_data() const {
 344     return class_loader() == NULL;
 345   }
 346 
 347   bool is_builtin_class_loader_data() const;
 348   bool is_permanent_class_loader_data() const;
 349 
 350   // The Metaspace is created lazily so may be NULL.  This
 351   // method will allocate a Metaspace if needed.
 352   ClassLoaderMetaspace* metaspace_non_null();
 353 
 354   oop class_loader() const { return _class_loader; }
 355 
 356   // The object the GC is using to keep this ClassLoaderData alive.
 357   oop keep_alive_object() const;
 358 
 359   // Returns true if this class loader data is for a loader going away.
 360   bool is_unloading() const     {
 361     assert(!(is_the_null_class_loader_data() && _unloading), "The null class loader can never be unloaded");
 362     return _unloading;
 363   }
 364 
 365   // Used to refcount an anonymous class's CLD in order to
 366   // indicate their aliveness without a keep_alive_object().
 367   void inc_keep_alive();
 368   void dec_keep_alive();
 369 
 370   void initialize_holder(Handle holder);
 371 
 372   inline unsigned int identity_hash() const { return (unsigned int)(((intptr_t)this) >> 3); }
 373 
 374   void oops_do(OopClosure* f, bool must_claim, bool clear_modified_oops = false);
 375 
 376   void classes_do(KlassClosure* klass_closure);
 377   Klass* klasses() { return _klasses; }
 378 
 379   JNIMethodBlock* jmethod_ids() const              { return _jmethod_ids; }
 380   void set_jmethod_ids(JNIMethodBlock* new_block)  { _jmethod_ids = new_block; }
 381 
 382   void print()                                     { print_on(tty); }
 383   void print_on(outputStream* out) const PRODUCT_RETURN;
 384   void print_value()                               { print_value_on(tty); }
 385   void print_value_on(outputStream* out) const;
 386   void verify();


 390   void remove_handle(OopHandle h);
 391   void init_handle_locked(OopHandle& pd, Handle h);  // used for concurrent access to ModuleEntry::_pd field
 392   void add_class(Klass* k, bool publicize = true);
 393   void remove_class(Klass* k);
 394   bool contains_klass(Klass* k);
 395   void record_dependency(const Klass* to);
 396   PackageEntryTable* packages() { return _packages; }
 397   ModuleEntry* unnamed_module() { return _unnamed_module; }
 398   ModuleEntryTable* modules();
 399   bool modules_defined() { return (_modules != NULL); }
 400 
 401   // Loaded class dictionary
 402   Dictionary* dictionary() const { return _dictionary; }
 403 
 404   void add_to_deallocate_list(Metadata* m);
 405 
 406   static ClassLoaderData* class_loader_data(oop loader);
 407   static ClassLoaderData* class_loader_data_or_null(oop loader);
 408   static ClassLoaderData* anonymous_class_loader_data(Handle loader);
 409 



 410   TRACE_DEFINE_TRACE_ID_METHODS;
 411 };
 412 
 413 // An iterator that distributes Klasses to parallel worker threads.
 414 class ClassLoaderDataGraphKlassIteratorAtomic : public StackObj {
 415  Klass* volatile _next_klass;
 416  public:
 417   ClassLoaderDataGraphKlassIteratorAtomic();
 418   Klass* next_klass();
 419  private:
 420   static Klass* next_klass_in_cldg(Klass* klass);
 421 };
 422 
 423 class ClassLoaderDataGraphMetaspaceIterator : public StackObj {
 424   ClassLoaderData* _data;
 425  public:
 426   ClassLoaderDataGraphMetaspaceIterator();
 427   ~ClassLoaderDataGraphMetaspaceIterator();
 428   bool repeat() { return _data != NULL; }
 429   ClassLoaderMetaspace* get_next() {


  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_CLASSFILE_CLASSLOADERDATA_HPP
  26 #define SHARE_VM_CLASSFILE_CLASSLOADERDATA_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "memory/memRegion.hpp"
  30 #include "memory/metaspace.hpp"

  31 #include "oops/oopHandle.hpp"
  32 #include "oops/weakHandle.hpp"
  33 #include "runtime/mutex.hpp"
  34 #include "trace/traceMacros.hpp"
  35 #include "utilities/growableArray.hpp"
  36 #include "utilities/macros.hpp"
  37 #if INCLUDE_TRACE
  38 #include "utilities/ticks.hpp"
  39 #endif
  40 
  41 //
  42 // A class loader represents a linkset. Conceptually, a linkset identifies
  43 // the complete transitive closure of resolved links that a dynamic linker can
  44 // produce.
  45 //
  46 // A ClassLoaderData also encapsulates the allocation space, called a metaspace,
  47 // used by the dynamic linker to allocate the runtime representation of all
  48 // the types it defines.
  49 //
  50 // ClassLoaderData are stored in the runtime representation of classes,


  66   friend class ClassLoaderData;
  67   friend class ClassLoaderDataGraphMetaspaceIterator;
  68   friend class ClassLoaderDataGraphKlassIteratorAtomic;
  69   friend class ClassLoaderDataGraphKlassIteratorStatic;
  70   friend class VMStructs;
  71  private:
  72   // All CLDs (except the null CLD) can be reached by walking _head->_next->...
  73   static ClassLoaderData* _head;
  74   static ClassLoaderData* _unloading;
  75   // CMS support.
  76   static ClassLoaderData* _saved_head;
  77   static ClassLoaderData* _saved_unloading;
  78   static bool _should_purge;
  79   // OOM has been seen in metaspace allocation. Used to prevent some
  80   // allocations until class unloading
  81   static bool _metaspace_oom;
  82 
  83   static volatile size_t  _num_instance_classes;
  84   static volatile size_t  _num_array_classes;
  85 
  86   static ClassLoaderData* add_to_graph(Handle class_laoder, bool anonymous);
  87   static ClassLoaderData* add(Handle class_loader, bool anonymous);
  88   static void post_class_unload_events();
  89  public:
  90   static ClassLoaderData* find_or_create(Handle class_loader);
  91   static void purge();
  92   static void clear_claimed_marks();
  93   // oops do
  94   static void oops_do(OopClosure* f, bool must_claim);
  95   static void keep_alive_oops_do(OopClosure* blk, bool must_claim);
  96   static void always_strong_oops_do(OopClosure* blk, bool must_claim);
  97   // cld do
  98   static void cld_do(CLDClosure* cl);
  99   static void cld_unloading_do(CLDClosure* cl);
 100   static void roots_cld_do(CLDClosure* strong, CLDClosure* weak);
 101   static void keep_alive_cld_do(CLDClosure* cl);
 102   static void always_strong_cld_do(CLDClosure* cl);
 103   // klass do
 104   // Walking classes through the ClassLoaderDataGraph include array classes.  It also includes
 105   // classes that are allocated but not loaded, classes that have errors, and scratch classes
 106   // for redefinition.  These classes are removed during the next class unloading.


 204     // However, multiple threads can execute oops_do concurrently with add.
 205     oop* add(oop o);
 206     bool contains(oop p);
 207     NOT_PRODUCT(bool owner_of(oop* p);)
 208     void oops_do(OopClosure* f);
 209 
 210     int count() const;
 211   };
 212 
 213   friend class ClassLoaderDataGraph;
 214   friend class ClassLoaderDataGraphKlassIteratorAtomic;
 215   friend class ClassLoaderDataGraphKlassIteratorStatic;
 216   friend class ClassLoaderDataGraphMetaspaceIterator;
 217   friend class InstanceKlass;
 218   friend class MetaDataFactory;
 219   friend class Method;
 220 
 221   static ClassLoaderData * _the_null_class_loader_data;
 222 
 223   WeakHandle<vm_class_loader_data> _holder; // The oop that determines lifetime of this class loader
 224   OopHandle _class_loader;    // The instance of java/lang/ClassLoader associated with
 225                               // this ClassLoaderData
 226 
 227   ClassLoaderMetaspace * volatile _metaspace;  // Meta-space where meta-data defined by the
 228                                     // classes in the class loader are allocated.
 229   Mutex* _metaspace_lock;  // Locks the metaspace for allocations and setup.
 230   bool _unloading;         // true if this class loader goes away
 231   bool _is_anonymous;      // if this CLD is for an anonymous class
 232 
 233   // Remembered sets support for the oops in the class loader data.
 234   bool _modified_oops;             // Card Table Equivalent (YC/CMS support)
 235   bool _accumulated_modified_oops; // Mod Union Equivalent (CMS support)
 236 
 237   s2 _keep_alive;          // if this CLD is kept alive.
 238                            // Used for anonymous classes and the boot class
 239                            // loader. _keep_alive does not need to be volatile or
 240                            // atomic since there is one unique CLD per anonymous class.
 241 
 242   volatile int _claimed;   // true if claimed, for example during GC traces.
 243                            // To avoid applying oop closure more than once.
 244                            // Has to be an int because we cas it.
 245   ChunkedHandleList _handles; // Handles to constant pool arrays, Modules, etc, which
 246                               // have the same life cycle of the corresponding ClassLoader.
 247 
 248   NOT_PRODUCT(volatile int _dependency_count;)  // number of class loader dependencies
 249 
 250   Klass* volatile _klasses;              // The classes defined by the class loader.
 251   PackageEntryTable* volatile _packages; // The packages defined by the class loader.
 252   ModuleEntryTable*  volatile _modules;  // The modules defined by the class loader.
 253   ModuleEntry* _unnamed_module;          // This class loader's unnamed module.
 254   Dictionary*  _dictionary;              // The loaded InstanceKlasses, including initiated by this class loader
 255 
 256   // These method IDs are created for the class loader and set to NULL when the
 257   // class loader is unloaded.  They are rarely freed, only for redefine classes
 258   // and if they lose a data race in InstanceKlass.
 259   JNIMethodBlock*                  _jmethod_ids;
 260 
 261   // Metadata to be deallocated when it's safe at class unloading, when
 262   // this class loader isn't unloaded itself.
 263   GrowableArray<Metadata*>*      _deallocate_list;
 264 
 265   // Support for walking class loader data objects
 266   ClassLoaderData* _next; /// Next loader_datas created
 267 
 268   // JFR support
 269   Klass*  _class_loader_klass;
 270   Symbol* _class_loader_name;
 271   TRACE_DEFINE_TRACE_ID_FIELD;
 272 
 273   void set_next(ClassLoaderData* next) { _next = next; }
 274   ClassLoaderData* next() const        { return _next; }
 275 
 276   ClassLoaderData(Handle h_class_loader, bool is_anonymous);
 277   ~ClassLoaderData();
 278 
 279   // The CLD are not placed in the Heap, so the Card Table or
 280   // the Mod Union Table can't be used to mark when CLD have modified oops.
 281   // The CT and MUT bits saves this information for the whole class loader data.
 282   void clear_modified_oops()             { _modified_oops = false; }
 283  public:
 284   void record_modified_oops()            { _modified_oops = true; }
 285   bool has_modified_oops()               { return _modified_oops; }
 286 
 287   void accumulate_modified_oops()        { if (has_modified_oops()) _accumulated_modified_oops = true; }
 288   void clear_accumulated_modified_oops() { _accumulated_modified_oops = false; }
 289   bool has_accumulated_modified_oops()   { return _accumulated_modified_oops; }
 290  private:
 291 
 292   void unload();
 293   bool keep_alive() const       { return _keep_alive > 0; }
 294 
 295   oop holder_phantom() const;
 296   void classes_do(void f(Klass*));
 297   void loaded_classes_do(KlassClosure* klass_closure);
 298   void classes_do(void f(InstanceKlass*));
 299   void methods_do(void f(Method*));
 300   void modules_do(void f(ModuleEntry*));
 301   void packages_do(void f(PackageEntry*));
 302 
 303   // Deallocate free list during class unloading.
 304   void free_deallocate_list();      // for the classes that are not unloaded
 305   void unload_deallocate_list();    // for the classes that are unloaded
 306 
 307   // Allocate out of this class loader data
 308   MetaWord* allocate(size_t size);
 309 
 310   Dictionary* create_dictionary();
 311 
 312   void initialize_name_and_klass(Handle class_loader);
 313  public:
 314   // GC interface.
 315   void clear_claimed() { _claimed = 0; }
 316   bool claimed() const { return _claimed == 1; }
 317   bool claim();
 318 
 319   bool is_alive() const;
 320 
 321   // Accessors
 322   ClassLoaderMetaspace* metaspace_or_null() const { return _metaspace; }
 323 
 324   static ClassLoaderData* the_null_class_loader_data() {
 325     return _the_null_class_loader_data;
 326   }
 327 
 328   Mutex* metaspace_lock() const { return _metaspace_lock; }
 329 
 330   bool is_anonymous() const { return _is_anonymous; }
 331 
 332   static void init_null_class_loader_data();
 333 
 334   bool is_the_null_class_loader_data() const {
 335     return this == _the_null_class_loader_data;
 336   }
 337 
 338   // Returns true if this class loader data is for the system class loader.
 339   // (Note that the class loader data may be anonymous.)
 340   bool is_system_class_loader_data() const;
 341 
 342   // Returns true if this class loader data is for the platform class loader.
 343   // (Note that the class loader data may be anonymous.)
 344   bool is_platform_class_loader_data() const;
 345 
 346   // Returns true if this class loader data is for the boot class loader.
 347   // (Note that the class loader data may be anonymous.)
 348   inline bool is_boot_class_loader_data() const;


 349 
 350   bool is_builtin_class_loader_data() const;
 351   bool is_permanent_class_loader_data() const;
 352 
 353   // The Metaspace is created lazily so may be NULL.  This
 354   // method will allocate a Metaspace if needed.
 355   ClassLoaderMetaspace* metaspace_non_null();
 356 
 357   inline oop class_loader() const;



 358 
 359   // Returns true if this class loader data is for a loader going away.
 360   bool is_unloading() const     {
 361     assert(!(is_the_null_class_loader_data() && _unloading), "The null class loader can never be unloaded");
 362     return _unloading;
 363   }
 364 
 365   // Used to refcount an anonymous class's CLD in order to
 366   // indicate their aliveness.
 367   void inc_keep_alive();
 368   void dec_keep_alive();
 369 
 370   void initialize_holder(Handle holder);
 371 
 372   inline unsigned int identity_hash() const { return (unsigned int)(((intptr_t)this) >> 3); }
 373 
 374   void oops_do(OopClosure* f, bool must_claim, bool clear_modified_oops = false);
 375 
 376   void classes_do(KlassClosure* klass_closure);
 377   Klass* klasses() { return _klasses; }
 378 
 379   JNIMethodBlock* jmethod_ids() const              { return _jmethod_ids; }
 380   void set_jmethod_ids(JNIMethodBlock* new_block)  { _jmethod_ids = new_block; }
 381 
 382   void print()                                     { print_on(tty); }
 383   void print_on(outputStream* out) const PRODUCT_RETURN;
 384   void print_value()                               { print_value_on(tty); }
 385   void print_value_on(outputStream* out) const;
 386   void verify();


 390   void remove_handle(OopHandle h);
 391   void init_handle_locked(OopHandle& pd, Handle h);  // used for concurrent access to ModuleEntry::_pd field
 392   void add_class(Klass* k, bool publicize = true);
 393   void remove_class(Klass* k);
 394   bool contains_klass(Klass* k);
 395   void record_dependency(const Klass* to);
 396   PackageEntryTable* packages() { return _packages; }
 397   ModuleEntry* unnamed_module() { return _unnamed_module; }
 398   ModuleEntryTable* modules();
 399   bool modules_defined() { return (_modules != NULL); }
 400 
 401   // Loaded class dictionary
 402   Dictionary* dictionary() const { return _dictionary; }
 403 
 404   void add_to_deallocate_list(Metadata* m);
 405 
 406   static ClassLoaderData* class_loader_data(oop loader);
 407   static ClassLoaderData* class_loader_data_or_null(oop loader);
 408   static ClassLoaderData* anonymous_class_loader_data(Handle loader);
 409 
 410 
 411   Klass* class_loader_klass() const { return _class_loader_klass; }
 412   Symbol* class_loader_name() const { return _class_loader_name; }
 413   TRACE_DEFINE_TRACE_ID_METHODS;
 414 };
 415 
 416 // An iterator that distributes Klasses to parallel worker threads.
 417 class ClassLoaderDataGraphKlassIteratorAtomic : public StackObj {
 418  Klass* volatile _next_klass;
 419  public:
 420   ClassLoaderDataGraphKlassIteratorAtomic();
 421   Klass* next_klass();
 422  private:
 423   static Klass* next_klass_in_cldg(Klass* klass);
 424 };
 425 
 426 class ClassLoaderDataGraphMetaspaceIterator : public StackObj {
 427   ClassLoaderData* _data;
 428  public:
 429   ClassLoaderDataGraphMetaspaceIterator();
 430   ~ClassLoaderDataGraphMetaspaceIterator();
 431   bool repeat() { return _data != NULL; }
 432   ClassLoaderMetaspace* get_next() {
< prev index next >