110 static ClassLoaderData * _the_null_class_loader_data; 111 112 WeakHandle<vm_class_loader_data> _holder; // The oop that determines lifetime of this class loader 113 OopHandle _class_loader; // The instance of java/lang/ClassLoader associated with 114 // this ClassLoaderData 115 116 ClassLoaderMetaspace * volatile _metaspace; // Meta-space where meta-data defined by the 117 // classes in the class loader are allocated. 118 Mutex* _metaspace_lock; // Locks the metaspace for allocations and setup. 119 bool _unloading; // true if this class loader goes away 120 bool _has_class_mirror_holder; // If true, CLD is dedicated to one class and that class determines 121 // the CLDs lifecycle. For example, a non-strong hidden class or an 122 // unsafe anonymous class. Arrays of these classes are also assigned 123 // to these class loader datas. 124 125 // Remembered sets support for the oops in the class loader data. 126 bool _modified_oops; // Card Table Equivalent (YC/CMS support) 127 bool _accumulated_modified_oops; // Mod Union Equivalent (CMS support) 128 129 int _keep_alive; // if this CLD is kept alive. 130 // Used for weak hidden classes, unsafe anonymous classes and the 131 // boot class loader. _keep_alive does not need to be volatile or 132 // atomic since there is one unique CLD per weak hidden or unsafe anonymous class. 133 134 volatile int _claim; // non-zero if claimed, for example during GC traces. 135 // To avoid applying oop closure more than once. 136 ChunkedHandleList _handles; // Handles to constant pool arrays, Modules, etc, which 137 // have the same life cycle of the corresponding ClassLoader. 138 139 NOT_PRODUCT(volatile int _dependency_count;) // number of class loader dependencies 140 141 Klass* volatile _klasses; // The classes defined by the class loader. 142 PackageEntryTable* volatile _packages; // The packages defined by the class loader. 143 ModuleEntryTable* volatile _modules; // The modules defined by the class loader. 144 ModuleEntry* _unnamed_module; // This class loader's unnamed module. 145 Dictionary* _dictionary; // The loaded InstanceKlasses, including initiated by this class loader 146 147 // These method IDs are created for the class loader and set to NULL when the 148 // class loader is unloaded. They are rarely freed, only for redefine classes 149 // and if they lose a data race in InstanceKlass. 150 JNIMethodBlock* _jmethod_ids; 151 152 // Metadata to be deallocated when it's safe at class unloading, when 225 bool is_alive() const; 226 227 // Accessors 228 ClassLoaderMetaspace* metaspace_or_null() const { return _metaspace; } 229 230 static ClassLoaderData* the_null_class_loader_data() { 231 return _the_null_class_loader_data; 232 } 233 234 Mutex* metaspace_lock() const { return _metaspace_lock; } 235 236 bool has_class_mirror_holder() const { return _has_class_mirror_holder; } 237 238 static void init_null_class_loader_data(); 239 240 bool is_the_null_class_loader_data() const { 241 return this == _the_null_class_loader_data; 242 } 243 244 // Returns true if this class loader data is for the system class loader. 245 // (Note that the class loader data may be for an weak hidden or unsafe anonymous class) 246 bool is_system_class_loader_data() const; 247 248 // Returns true if this class loader data is for the platform class loader. 249 // (Note that the class loader data may be for an weak hidden or unsafe anonymous class) 250 bool is_platform_class_loader_data() const; 251 252 // Returns true if this class loader data is for the boot class loader. 253 // (Note that the class loader data may be for an weak hidden unsafe anonymous class) 254 inline bool is_boot_class_loader_data() const; 255 256 bool is_builtin_class_loader_data() const; 257 bool is_permanent_class_loader_data() const; 258 259 // The Metaspace is created lazily so may be NULL. This 260 // method will allocate a Metaspace if needed. 261 ClassLoaderMetaspace* metaspace_non_null(); 262 263 inline oop class_loader() const; 264 265 // Returns true if this class loader data is for a loader going away. 266 // Note that this is only safe after the GC has computed if the CLD is 267 // unloading or not. In concurrent contexts where there are no such 268 // guarantees, is_alive() should be used instead. 269 bool is_unloading() const { 270 assert(!(is_the_null_class_loader_data() && _unloading), "The null class loader can never be unloaded"); 271 return _unloading; 272 } 273 274 // Used to refcount an weak hidden or unsafe anonymous class's CLD in order to 275 // indicate their aliveness. 276 void inc_keep_alive(); 277 void dec_keep_alive(); 278 279 void initialize_holder(Handle holder); 280 281 void oops_do(OopClosure* f, int claim_value, bool clear_modified_oops = false); 282 283 void classes_do(KlassClosure* klass_closure); 284 Klass* klasses() { return _klasses; } 285 286 JNIMethodBlock* jmethod_ids() const { return _jmethod_ids; } 287 void set_jmethod_ids(JNIMethodBlock* new_block) { _jmethod_ids = new_block; } 288 289 void print() const; 290 void print_on(outputStream* out) const PRODUCT_RETURN; 291 void print_value() const; 292 void print_value_on(outputStream* out) const; 293 void verify(); 294 | 110 static ClassLoaderData * _the_null_class_loader_data; 111 112 WeakHandle<vm_class_loader_data> _holder; // The oop that determines lifetime of this class loader 113 OopHandle _class_loader; // The instance of java/lang/ClassLoader associated with 114 // this ClassLoaderData 115 116 ClassLoaderMetaspace * volatile _metaspace; // Meta-space where meta-data defined by the 117 // classes in the class loader are allocated. 118 Mutex* _metaspace_lock; // Locks the metaspace for allocations and setup. 119 bool _unloading; // true if this class loader goes away 120 bool _has_class_mirror_holder; // If true, CLD is dedicated to one class and that class determines 121 // the CLDs lifecycle. For example, a non-strong hidden class or an 122 // unsafe anonymous class. Arrays of these classes are also assigned 123 // to these class loader datas. 124 125 // Remembered sets support for the oops in the class loader data. 126 bool _modified_oops; // Card Table Equivalent (YC/CMS support) 127 bool _accumulated_modified_oops; // Mod Union Equivalent (CMS support) 128 129 int _keep_alive; // if this CLD is kept alive. 130 // Used for non-strong hidden classes, unsafe anonymous classes and the 131 // boot class loader. _keep_alive does not need to be volatile or 132 // atomic since there is one unique CLD per non-strong hidden class 133 // or unsafe anonymous class. 134 135 volatile int _claim; // non-zero if claimed, for example during GC traces. 136 // To avoid applying oop closure more than once. 137 ChunkedHandleList _handles; // Handles to constant pool arrays, Modules, etc, which 138 // have the same life cycle of the corresponding ClassLoader. 139 140 NOT_PRODUCT(volatile int _dependency_count;) // number of class loader dependencies 141 142 Klass* volatile _klasses; // The classes defined by the class loader. 143 PackageEntryTable* volatile _packages; // The packages defined by the class loader. 144 ModuleEntryTable* volatile _modules; // The modules defined by the class loader. 145 ModuleEntry* _unnamed_module; // This class loader's unnamed module. 146 Dictionary* _dictionary; // The loaded InstanceKlasses, including initiated by this class loader 147 148 // These method IDs are created for the class loader and set to NULL when the 149 // class loader is unloaded. They are rarely freed, only for redefine classes 150 // and if they lose a data race in InstanceKlass. 151 JNIMethodBlock* _jmethod_ids; 152 153 // Metadata to be deallocated when it's safe at class unloading, when 226 bool is_alive() const; 227 228 // Accessors 229 ClassLoaderMetaspace* metaspace_or_null() const { return _metaspace; } 230 231 static ClassLoaderData* the_null_class_loader_data() { 232 return _the_null_class_loader_data; 233 } 234 235 Mutex* metaspace_lock() const { return _metaspace_lock; } 236 237 bool has_class_mirror_holder() const { return _has_class_mirror_holder; } 238 239 static void init_null_class_loader_data(); 240 241 bool is_the_null_class_loader_data() const { 242 return this == _the_null_class_loader_data; 243 } 244 245 // Returns true if this class loader data is for the system class loader. 246 // (Note that the class loader data may be for a non-strong hidden class or unsafe anonymous class) 247 bool is_system_class_loader_data() const; 248 249 // Returns true if this class loader data is for the platform class loader. 250 // (Note that the class loader data may be for a non-strong hidden class or unsafe anonymous class) 251 bool is_platform_class_loader_data() const; 252 253 // Returns true if this class loader data is for the boot class loader. 254 // (Note that the class loader data may be for a non-strong hidden class or unsafe anonymous class) 255 inline bool is_boot_class_loader_data() const; 256 257 bool is_builtin_class_loader_data() const; 258 bool is_permanent_class_loader_data() const; 259 260 // The Metaspace is created lazily so may be NULL. This 261 // method will allocate a Metaspace if needed. 262 ClassLoaderMetaspace* metaspace_non_null(); 263 264 inline oop class_loader() const; 265 266 // Returns true if this class loader data is for a loader going away. 267 // Note that this is only safe after the GC has computed if the CLD is 268 // unloading or not. In concurrent contexts where there are no such 269 // guarantees, is_alive() should be used instead. 270 bool is_unloading() const { 271 assert(!(is_the_null_class_loader_data() && _unloading), "The null class loader can never be unloaded"); 272 return _unloading; 273 } 274 275 // Used to refcount a non-strong hidden class's or unsafe anonymous class's CLD in order to 276 // indicate their aliveness. 277 void inc_keep_alive(); 278 void dec_keep_alive(); 279 280 void initialize_holder(Handle holder); 281 282 void oops_do(OopClosure* f, int claim_value, bool clear_modified_oops = false); 283 284 void classes_do(KlassClosure* klass_closure); 285 Klass* klasses() { return _klasses; } 286 287 JNIMethodBlock* jmethod_ids() const { return _jmethod_ids; } 288 void set_jmethod_ids(JNIMethodBlock* new_block) { _jmethod_ids = new_block; } 289 290 void print() const; 291 void print_on(outputStream* out) const PRODUCT_RETURN; 292 void print_value() const; 293 void print_value_on(outputStream* out) const; 294 void verify(); 295 |