173 |
173 |
174 Metaspace * _metaspace; // Meta-space where meta-data defined by the |
174 Metaspace * _metaspace; // Meta-space where meta-data defined by the |
175 // classes in the class loader are allocated. |
175 // classes in the class loader are allocated. |
176 Mutex* _metaspace_lock; // Locks the metaspace for allocations and setup. |
176 Mutex* _metaspace_lock; // Locks the metaspace for allocations and setup. |
177 bool _unloading; // true if this class loader goes away |
177 bool _unloading; // true if this class loader goes away |
178 bool _keep_alive; // if this CLD is kept alive without a keep_alive_object(). |
|
179 bool _is_anonymous; // if this CLD is for an anonymous class |
178 bool _is_anonymous; // if this CLD is for an anonymous class |
|
179 int _keep_alive; // if this CLD is kept alive without a keep_alive_object(). |
|
180 // Currently used solely for anonymous classes. |
|
181 // _keep_alive does not need to be volatile or |
|
182 // atomic since there is one unique CLD per anonymous class. |
180 volatile int _claimed; // true if claimed, for example during GC traces. |
183 volatile int _claimed; // true if claimed, for example during GC traces. |
181 // To avoid applying oop closure more than once. |
184 // To avoid applying oop closure more than once. |
182 // Has to be an int because we cas it. |
185 // Has to be an int because we cas it. |
183 JNIHandleBlock* _handles; // Handles to constant pool arrays, Modules, etc, which |
186 JNIHandleBlock* _handles; // Handles to constant pool arrays, Modules, etc, which |
184 // have the same life cycle of the corresponding ClassLoader. |
187 // have the same life cycle of the corresponding ClassLoader. |
222 void clear_claimed() { _claimed = 0; } |
225 void clear_claimed() { _claimed = 0; } |
223 bool claimed() const { return _claimed == 1; } |
226 bool claimed() const { return _claimed == 1; } |
224 bool claim(); |
227 bool claim(); |
225 |
228 |
226 void unload(); |
229 void unload(); |
227 bool keep_alive() const { return _keep_alive; } |
230 bool keep_alive() const { return _keep_alive > 0; } |
228 void classes_do(void f(Klass*)); |
231 void classes_do(void f(Klass*)); |
229 void loaded_classes_do(KlassClosure* klass_closure); |
232 void loaded_classes_do(KlassClosure* klass_closure); |
230 void classes_do(void f(InstanceKlass*)); |
233 void classes_do(void f(InstanceKlass*)); |
231 void methods_do(void f(Method*)); |
234 void methods_do(void f(Method*)); |
232 void modules_do(void f(ModuleEntry*)); |
235 void modules_do(void f(ModuleEntry*)); |
284 bool is_unloading() const { |
287 bool is_unloading() const { |
285 assert(!(is_the_null_class_loader_data() && _unloading), "The null class loader can never be unloaded"); |
288 assert(!(is_the_null_class_loader_data() && _unloading), "The null class loader can never be unloaded"); |
286 return _unloading; |
289 return _unloading; |
287 } |
290 } |
288 |
291 |
289 // Used to make sure that this CLD is not unloaded. |
292 void inc_keep_alive(); |
290 void set_keep_alive(bool value) { _keep_alive = value; } |
293 void dec_keep_alive(); |
291 |
294 |
292 inline unsigned int identity_hash() const; |
295 inline unsigned int identity_hash() const; |
293 |
296 |
294 // Used when tracing from klasses. |
297 // Used when tracing from klasses. |
295 void oops_do(OopClosure* f, KlassClosure* klass_closure, bool must_claim); |
298 void oops_do(OopClosure* f, KlassClosure* klass_closure, bool must_claim); |