< prev index next >

src/hotspot/share/oops/instanceKlass.cpp

Print this page




 669 // See "The Virtual Machine Specification" section 2.16.5 for a detailed explanation of the class initialization
 670 // process. The step comments refers to the procedure described in that section.
 671 // Note: implementation moved to static method to expose the this pointer.
 672 void InstanceKlass::initialize(TRAPS) {
 673   if (this->should_be_initialized()) {
 674     initialize_impl(CHECK);
 675     // Note: at this point the class may be initialized
 676     //       OR it may be in the state of being initialized
 677     //       in case of recursive initialization!
 678   } else {
 679     assert(is_initialized(), "sanity check");
 680   }
 681 }
 682 
 683 
 684 bool InstanceKlass::verify_code(TRAPS) {
 685   // 1) Verify the bytecodes
 686   return Verifier::verify(this, should_verify_class(), THREAD);
 687 }
 688 
 689 
 690 // Used exclusively by the shared spaces dump mechanism to prevent
 691 // classes mapped into the shared regions in new VMs from appearing linked.
 692 
 693 void InstanceKlass::unlink_class() {
 694   assert(is_linked(), "must be linked");
 695   _init_state = loaded;
 696 }
 697 
 698 void InstanceKlass::link_class(TRAPS) {
 699   assert(is_loaded(), "must be loaded");
 700   if (!is_linked()) {
 701     link_class_impl(CHECK);
 702   }
 703 }
 704 
 705 // Called to verify that a class can link during initialization, without
 706 // throwing a VerifyError.
 707 bool InstanceKlass::link_class_or_fail(TRAPS) {
 708   assert(is_loaded(), "must be loaded");
 709   if (!is_linked()) {
 710     link_class_impl(CHECK_false);
 711   }
 712   return is_linked();
 713 }
 714 
 715 bool InstanceKlass::link_class_impl(TRAPS) {
 716   if (DumpSharedSpaces && is_in_error_state()) {
 717     // This is for CDS dumping phase only -- we use the in_error_state to indicate that


2283         }
2284       }
2285     }
2286   }
2287 
2288   it->push(&_nest_members);
2289 }
2290 
2291 void InstanceKlass::remove_unshareable_info() {
2292   Klass::remove_unshareable_info();
2293 
2294   if (is_in_error_state()) {
2295     // Classes are attempted to link during dumping and may fail,
2296     // but these classes are still in the dictionary and class list in CLD.
2297     // Check in_error state first because in_error is > linked state, so
2298     // is_linked() is true.
2299     // If there's a linking error, there is nothing else to remove.
2300     return;
2301   }
2302 
2303   // Unlink the class
2304   if (is_linked()) {
2305     unlink_class();
2306   }


2307   {
2308     MutexLocker ml(Compile_lock);
2309     init_implementor();
2310   }
2311 
2312   constants()->remove_unshareable_info();
2313 
2314   for (int i = 0; i < methods()->length(); i++) {
2315     Method* m = methods()->at(i);
2316     m->remove_unshareable_info();
2317   }
2318 
2319   // do array classes also.
2320   if (array_klasses() != NULL) {
2321     array_klasses()->remove_unshareable_info();
2322   }
2323 
2324   // These are not allocated from metaspace, but they should should all be empty
2325   // during dump time, so we don't need to worry about them in InstanceKlass::iterate().
2326   guarantee(_source_debug_extension == NULL, "must be");


2333 #endif
2334 
2335   _init_thread = NULL;
2336   _methods_jmethod_ids = NULL;
2337   _jni_ids = NULL;
2338   _oop_map_cache = NULL;
2339   // clear _nest_host to ensure re-load at runtime
2340   _nest_host = NULL;
2341 }
2342 
2343 void InstanceKlass::remove_java_mirror() {
2344   Klass::remove_java_mirror();
2345 
2346   // do array classes also.
2347   if (array_klasses() != NULL) {
2348     array_klasses()->remove_java_mirror();
2349   }
2350 }
2351 
2352 void InstanceKlass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS) {




2353   set_package(loader_data, CHECK);
2354   Klass::restore_unshareable_info(loader_data, protection_domain, CHECK);
2355 
2356   Array<Method*>* methods = this->methods();
2357   int num_methods = methods->length();
2358   for (int index2 = 0; index2 < num_methods; ++index2) {
2359     methodHandle m(THREAD, methods->at(index2));
2360     m->restore_unshareable_info(CHECK);
2361   }
2362   if (JvmtiExport::has_redefined_a_class()) {
2363     // Reinitialize vtable because RedefineClasses may have changed some
2364     // entries in this vtable for super classes so the CDS vtable might
2365     // point to old or obsolete entries.  RedefineClasses doesn't fix up
2366     // vtables in the shared system dictionary, only the main one.
2367     // It also redefines the itable too so fix that too.
2368     vtable().initialize_vtable(false, CHECK);
2369     itable().initialize_itable(false, CHECK);
2370   }
2371 
2372   // restore constant pool resolved references




 669 // See "The Virtual Machine Specification" section 2.16.5 for a detailed explanation of the class initialization
 670 // process. The step comments refers to the procedure described in that section.
 671 // Note: implementation moved to static method to expose the this pointer.
 672 void InstanceKlass::initialize(TRAPS) {
 673   if (this->should_be_initialized()) {
 674     initialize_impl(CHECK);
 675     // Note: at this point the class may be initialized
 676     //       OR it may be in the state of being initialized
 677     //       in case of recursive initialization!
 678   } else {
 679     assert(is_initialized(), "sanity check");
 680   }
 681 }
 682 
 683 
 684 bool InstanceKlass::verify_code(TRAPS) {
 685   // 1) Verify the bytecodes
 686   return Verifier::verify(this, should_verify_class(), THREAD);
 687 }
 688 









 689 void InstanceKlass::link_class(TRAPS) {
 690   assert(is_loaded(), "must be loaded");
 691   if (!is_linked()) {
 692     link_class_impl(CHECK);
 693   }
 694 }
 695 
 696 // Called to verify that a class can link during initialization, without
 697 // throwing a VerifyError.
 698 bool InstanceKlass::link_class_or_fail(TRAPS) {
 699   assert(is_loaded(), "must be loaded");
 700   if (!is_linked()) {
 701     link_class_impl(CHECK_false);
 702   }
 703   return is_linked();
 704 }
 705 
 706 bool InstanceKlass::link_class_impl(TRAPS) {
 707   if (DumpSharedSpaces && is_in_error_state()) {
 708     // This is for CDS dumping phase only -- we use the in_error_state to indicate that


2274         }
2275       }
2276     }
2277   }
2278 
2279   it->push(&_nest_members);
2280 }
2281 
2282 void InstanceKlass::remove_unshareable_info() {
2283   Klass::remove_unshareable_info();
2284 
2285   if (is_in_error_state()) {
2286     // Classes are attempted to link during dumping and may fail,
2287     // but these classes are still in the dictionary and class list in CLD.
2288     // Check in_error state first because in_error is > linked state, so
2289     // is_linked() is true.
2290     // If there's a linking error, there is nothing else to remove.
2291     return;
2292   }
2293 
2294   // Reset to the 'allocated' state to prevent any premature accessing to
2295   // a shared class at runtime while the class is still being loaded and
2296   // restored. A class' init_state is set to 'loaded' at runtime when it's 
2297   // being added to class hierarchy (see SystemDictionary:::add_to_hierarchy()).
2298   _init_state = allocated;
2299 
2300   {
2301     MutexLocker ml(Compile_lock);
2302     init_implementor();
2303   }
2304 
2305   constants()->remove_unshareable_info();
2306 
2307   for (int i = 0; i < methods()->length(); i++) {
2308     Method* m = methods()->at(i);
2309     m->remove_unshareable_info();
2310   }
2311 
2312   // do array classes also.
2313   if (array_klasses() != NULL) {
2314     array_klasses()->remove_unshareable_info();
2315   }
2316 
2317   // These are not allocated from metaspace, but they should should all be empty
2318   // during dump time, so we don't need to worry about them in InstanceKlass::iterate().
2319   guarantee(_source_debug_extension == NULL, "must be");


2326 #endif
2327 
2328   _init_thread = NULL;
2329   _methods_jmethod_ids = NULL;
2330   _jni_ids = NULL;
2331   _oop_map_cache = NULL;
2332   // clear _nest_host to ensure re-load at runtime
2333   _nest_host = NULL;
2334 }
2335 
2336 void InstanceKlass::remove_java_mirror() {
2337   Klass::remove_java_mirror();
2338 
2339   // do array classes also.
2340   if (array_klasses() != NULL) {
2341     array_klasses()->remove_java_mirror();
2342   }
2343 }
2344 
2345 void InstanceKlass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS) {
2346   // SystemDictionary::add_to_hierarchy() sets the init_state to loaded
2347   // before the InstanceKlass is added to the SystemDictionary. Make
2348   // sure the current state is <loaded.
2349   assert(!is_loaded(), "invalid init state");
2350   set_package(loader_data, CHECK);
2351   Klass::restore_unshareable_info(loader_data, protection_domain, CHECK);
2352 
2353   Array<Method*>* methods = this->methods();
2354   int num_methods = methods->length();
2355   for (int index2 = 0; index2 < num_methods; ++index2) {
2356     methodHandle m(THREAD, methods->at(index2));
2357     m->restore_unshareable_info(CHECK);
2358   }
2359   if (JvmtiExport::has_redefined_a_class()) {
2360     // Reinitialize vtable because RedefineClasses may have changed some
2361     // entries in this vtable for super classes so the CDS vtable might
2362     // point to old or obsolete entries.  RedefineClasses doesn't fix up
2363     // vtables in the shared system dictionary, only the main one.
2364     // It also redefines the itable too so fix that too.
2365     vtable().initialize_vtable(false, CHECK);
2366     itable().initialize_itable(false, CHECK);
2367   }
2368 
2369   // restore constant pool resolved references


< prev index next >