304 } 305 306 // Clear all the JNI handles for methods 307 // These aren't deallocated and are going to look like a leak, but that's 308 // needed because we can't really get rid of jmethodIDs because we don't 309 // know when native code is going to stop using them. The spec says that 310 // they're "invalid" but existing programs likely rely on their being 311 // NULL after class unloading. 312 if (_jmethod_ids != NULL) { 313 Method::clear_jmethod_ids(this); 314 } 315 // Delete lock 316 delete _metaspace_lock; 317 318 // Delete free list 319 if (_deallocate_list != NULL) { 320 delete _deallocate_list; 321 } 322 } 323 324 Metaspace* ClassLoaderData::metaspace_non_null() { 325 assert(!DumpSharedSpaces, "wrong metaspace!"); 326 // If the metaspace has not been allocated, create a new one. Might want 327 // to create smaller arena for Reflection class loaders also. 328 // The reason for the delayed allocation is because some class loaders are 329 // simply for delegating with no metadata of their own. 330 if (_metaspace == NULL) { 331 MutexLockerEx ml(metaspace_lock(), Mutex::_no_safepoint_check_flag); 332 // Check again if metaspace has been allocated while we were getting this lock. 333 if (_metaspace != NULL) { 334 return _metaspace; 335 } 336 if (this == the_null_class_loader_data()) { 337 assert (class_loader() == NULL, "Must be"); 338 set_metaspace(new Metaspace(_metaspace_lock, Metaspace::BootMetaspaceType)); 339 } else if (is_anonymous()) { 340 if (TraceClassLoaderData && Verbose && class_loader() != NULL) { 341 tty->print_cr("is_anonymous: %s", class_loader()->klass()->internal_name()); 342 } 343 set_metaspace(new Metaspace(_metaspace_lock, Metaspace::AnonymousMetaspaceType)); | 304 } 305 306 // Clear all the JNI handles for methods 307 // These aren't deallocated and are going to look like a leak, but that's 308 // needed because we can't really get rid of jmethodIDs because we don't 309 // know when native code is going to stop using them. The spec says that 310 // they're "invalid" but existing programs likely rely on their being 311 // NULL after class unloading. 312 if (_jmethod_ids != NULL) { 313 Method::clear_jmethod_ids(this); 314 } 315 // Delete lock 316 delete _metaspace_lock; 317 318 // Delete free list 319 if (_deallocate_list != NULL) { 320 delete _deallocate_list; 321 } 322 } 323 324 /** 325 * Returns true if this class loader data is for the extension class loader. 326 */ 327 bool ClassLoaderData::is_ext_class_loader_data() const { 328 return SystemDictionary::is_ext_class_loader(class_loader()); 329 } 330 331 Metaspace* ClassLoaderData::metaspace_non_null() { 332 assert(!DumpSharedSpaces, "wrong metaspace!"); 333 // If the metaspace has not been allocated, create a new one. Might want 334 // to create smaller arena for Reflection class loaders also. 335 // The reason for the delayed allocation is because some class loaders are 336 // simply for delegating with no metadata of their own. 337 if (_metaspace == NULL) { 338 MutexLockerEx ml(metaspace_lock(), Mutex::_no_safepoint_check_flag); 339 // Check again if metaspace has been allocated while we were getting this lock. 340 if (_metaspace != NULL) { 341 return _metaspace; 342 } 343 if (this == the_null_class_loader_data()) { 344 assert (class_loader() == NULL, "Must be"); 345 set_metaspace(new Metaspace(_metaspace_lock, Metaspace::BootMetaspaceType)); 346 } else if (is_anonymous()) { 347 if (TraceClassLoaderData && Verbose && class_loader() != NULL) { 348 tty->print_cr("is_anonymous: %s", class_loader()->klass()->internal_name()); 349 } 350 set_metaspace(new Metaspace(_metaspace_lock, Metaspace::AnonymousMetaspaceType)); |