289 |
289 |
290 vmSymbols::initialize(CHECK); |
290 vmSymbols::initialize(CHECK); |
291 |
291 |
292 SystemDictionary::initialize(CHECK); |
292 SystemDictionary::initialize(CHECK); |
293 |
293 |
294 klassOop ok = SystemDictionary::object_klass(); |
294 klassOop ok = SystemDictionary::Object_klass(); |
295 |
295 |
296 _the_null_string = StringTable::intern("null", CHECK); |
296 _the_null_string = StringTable::intern("null", CHECK); |
297 _the_min_jint_string = StringTable::intern("-2147483648", CHECK); |
297 _the_min_jint_string = StringTable::intern("-2147483648", CHECK); |
298 |
298 |
299 if (UseSharedSpaces) { |
299 if (UseSharedSpaces) { |
300 // Verify shared interfaces array. |
300 // Verify shared interfaces array. |
301 assert(_the_array_interfaces_array->obj_at(0) == |
301 assert(_the_array_interfaces_array->obj_at(0) == |
302 SystemDictionary::cloneable_klass(), "u3"); |
302 SystemDictionary::Cloneable_klass(), "u3"); |
303 assert(_the_array_interfaces_array->obj_at(1) == |
303 assert(_the_array_interfaces_array->obj_at(1) == |
304 SystemDictionary::serializable_klass(), "u3"); |
304 SystemDictionary::Serializable_klass(), "u3"); |
305 |
305 |
306 // Verify element klass for system obj array klass |
306 // Verify element klass for system obj array klass |
307 assert(objArrayKlass::cast(_systemObjArrayKlassObj)->element_klass() == ok, "u1"); |
307 assert(objArrayKlass::cast(_systemObjArrayKlassObj)->element_klass() == ok, "u1"); |
308 assert(objArrayKlass::cast(_systemObjArrayKlassObj)->bottom_klass() == ok, "u2"); |
308 assert(objArrayKlass::cast(_systemObjArrayKlassObj)->bottom_klass() == ok, "u2"); |
309 |
309 |
318 assert(Klass::cast(longArrayKlassObj() )->super() == ok, "u3"); |
318 assert(Klass::cast(longArrayKlassObj() )->super() == ok, "u3"); |
319 assert(Klass::cast(constantPoolKlassObj() )->super() == ok, "u3"); |
319 assert(Klass::cast(constantPoolKlassObj() )->super() == ok, "u3"); |
320 assert(Klass::cast(systemObjArrayKlassObj())->super() == ok, "u3"); |
320 assert(Klass::cast(systemObjArrayKlassObj())->super() == ok, "u3"); |
321 } else { |
321 } else { |
322 // Set up shared interfaces array. (Do this before supers are set up.) |
322 // Set up shared interfaces array. (Do this before supers are set up.) |
323 _the_array_interfaces_array->obj_at_put(0, SystemDictionary::cloneable_klass()); |
323 _the_array_interfaces_array->obj_at_put(0, SystemDictionary::Cloneable_klass()); |
324 _the_array_interfaces_array->obj_at_put(1, SystemDictionary::serializable_klass()); |
324 _the_array_interfaces_array->obj_at_put(1, SystemDictionary::Serializable_klass()); |
325 |
325 |
326 // Set element klass for system obj array klass |
326 // Set element klass for system obj array klass |
327 objArrayKlass::cast(_systemObjArrayKlassObj)->set_element_klass(ok); |
327 objArrayKlass::cast(_systemObjArrayKlassObj)->set_element_klass(ok); |
328 objArrayKlass::cast(_systemObjArrayKlassObj)->set_bottom_klass(ok); |
328 objArrayKlass::cast(_systemObjArrayKlassObj)->set_bottom_klass(ok); |
329 |
329 |
363 } // end of core bootstrapping |
363 } // end of core bootstrapping |
364 |
364 |
365 // Initialize _objectArrayKlass after core bootstraping to make |
365 // Initialize _objectArrayKlass after core bootstraping to make |
366 // sure the super class is set up properly for _objectArrayKlass. |
366 // sure the super class is set up properly for _objectArrayKlass. |
367 _objectArrayKlassObj = instanceKlass:: |
367 _objectArrayKlassObj = instanceKlass:: |
368 cast(SystemDictionary::object_klass())->array_klass(1, CHECK); |
368 cast(SystemDictionary::Object_klass())->array_klass(1, CHECK); |
369 // Add the class to the class hierarchy manually to make sure that |
369 // Add the class to the class hierarchy manually to make sure that |
370 // its vtable is initialized after core bootstrapping is completed. |
370 // its vtable is initialized after core bootstrapping is completed. |
371 Klass::cast(_objectArrayKlassObj)->append_to_sibling_list(); |
371 Klass::cast(_objectArrayKlassObj)->append_to_sibling_list(); |
372 |
372 |
373 // Compute is_jdk version flags. |
373 // Compute is_jdk version flags. |
424 objArrayHandle dummy_array(THREAD, naked_array); |
424 objArrayHandle dummy_array(THREAD, naked_array); |
425 int i = 0; |
425 int i = 0; |
426 while (i < size) { |
426 while (i < size) { |
427 if (!UseConcMarkSweepGC) { |
427 if (!UseConcMarkSweepGC) { |
428 // Allocate dummy in old generation |
428 // Allocate dummy in old generation |
429 oop dummy = instanceKlass::cast(SystemDictionary::object_klass())->allocate_instance(CHECK); |
429 oop dummy = instanceKlass::cast(SystemDictionary::Object_klass())->allocate_instance(CHECK); |
430 dummy_array->obj_at_put(i++, dummy); |
430 dummy_array->obj_at_put(i++, dummy); |
431 } |
431 } |
432 // Allocate dummy in permanent generation |
432 // Allocate dummy in permanent generation |
433 oop dummy = instanceKlass::cast(SystemDictionary::object_klass())->allocate_permanent_instance(CHECK); |
433 oop dummy = instanceKlass::cast(SystemDictionary::Object_klass())->allocate_permanent_instance(CHECK); |
434 dummy_array->obj_at_put(i++, dummy); |
434 dummy_array->obj_at_put(i++, dummy); |
435 } |
435 } |
436 { |
436 { |
437 // Only modify the global variable inside the mutex. |
437 // Only modify the global variable inside the mutex. |
438 // If we had a race to here, the other dummy_array instances |
438 // If we had a race to here, the other dummy_array instances |
538 void Universe::fixup_mirrors(TRAPS) { |
538 void Universe::fixup_mirrors(TRAPS) { |
539 // Bootstrap problem: all classes gets a mirror (java.lang.Class instance) assigned eagerly, |
539 // Bootstrap problem: all classes gets a mirror (java.lang.Class instance) assigned eagerly, |
540 // but we cannot do that for classes created before java.lang.Class is loaded. Here we simply |
540 // but we cannot do that for classes created before java.lang.Class is loaded. Here we simply |
541 // walk over permanent objects created so far (mostly classes) and fixup their mirrors. Note |
541 // walk over permanent objects created so far (mostly classes) and fixup their mirrors. Note |
542 // that the number of objects allocated at this point is very small. |
542 // that the number of objects allocated at this point is very small. |
543 assert(SystemDictionary::class_klass_loaded(), "java.lang.Class should be loaded"); |
543 assert(SystemDictionary::Class_klass_loaded(), "java.lang.Class should be loaded"); |
544 FixupMirrorClosure blk; |
544 FixupMirrorClosure blk; |
545 Universe::heap()->permanent_object_iterate(&blk); |
545 Universe::heap()->permanent_object_iterate(&blk); |
546 } |
546 } |
547 |
547 |
548 |
548 |
554 |
554 |
555 // Called on VM exit. This ought to be run in a separate thread. |
555 // Called on VM exit. This ought to be run in a separate thread. |
556 if (TraceReferenceGC) tty->print_cr("Callback to run finalizers on exit"); |
556 if (TraceReferenceGC) tty->print_cr("Callback to run finalizers on exit"); |
557 { |
557 { |
558 PRESERVE_EXCEPTION_MARK; |
558 PRESERVE_EXCEPTION_MARK; |
559 KlassHandle finalizer_klass(THREAD, SystemDictionary::finalizer_klass()); |
559 KlassHandle finalizer_klass(THREAD, SystemDictionary::Finalizer_klass()); |
560 JavaValue result(T_VOID); |
560 JavaValue result(T_VOID); |
561 JavaCalls::call_static( |
561 JavaCalls::call_static( |
562 &result, |
562 &result, |
563 finalizer_klass, |
563 finalizer_klass, |
564 vmSymbolHandles::run_finalizers_on_exit_name(), |
564 vmSymbolHandles::run_finalizers_on_exit_name(), |
948 Universe::_fully_initialized = true; |
948 Universe::_fully_initialized = true; |
949 EXCEPTION_MARK; |
949 EXCEPTION_MARK; |
950 { ResourceMark rm; |
950 { ResourceMark rm; |
951 Interpreter::initialize(); // needed for interpreter entry points |
951 Interpreter::initialize(); // needed for interpreter entry points |
952 if (!UseSharedSpaces) { |
952 if (!UseSharedSpaces) { |
953 KlassHandle ok_h(THREAD, SystemDictionary::object_klass()); |
953 KlassHandle ok_h(THREAD, SystemDictionary::Object_klass()); |
954 Universe::reinitialize_vtable_of(ok_h, CHECK_false); |
954 Universe::reinitialize_vtable_of(ok_h, CHECK_false); |
955 Universe::reinitialize_itables(CHECK_false); |
955 Universe::reinitialize_itables(CHECK_false); |
956 } |
956 } |
957 } |
957 } |
958 |
958 |
959 klassOop k; |
959 klassOop k; |
960 instanceKlassHandle k_h; |
960 instanceKlassHandle k_h; |
961 if (!UseSharedSpaces) { |
961 if (!UseSharedSpaces) { |
962 // Setup preallocated empty java.lang.Class array |
962 // Setup preallocated empty java.lang.Class array |
963 Universe::_the_empty_class_klass_array = oopFactory::new_objArray(SystemDictionary::class_klass(), 0, CHECK_false); |
963 Universe::_the_empty_class_klass_array = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_false); |
964 // Setup preallocated OutOfMemoryError errors |
964 // Setup preallocated OutOfMemoryError errors |
965 k = SystemDictionary::resolve_or_fail(vmSymbolHandles::java_lang_OutOfMemoryError(), true, CHECK_false); |
965 k = SystemDictionary::resolve_or_fail(vmSymbolHandles::java_lang_OutOfMemoryError(), true, CHECK_false); |
966 k_h = instanceKlassHandle(THREAD, k); |
966 k_h = instanceKlassHandle(THREAD, k); |
967 Universe::_out_of_memory_error_java_heap = k_h->allocate_permanent_instance(CHECK_false); |
967 Universe::_out_of_memory_error_java_heap = k_h->allocate_permanent_instance(CHECK_false); |
968 Universe::_out_of_memory_error_perm_gen = k_h->allocate_permanent_instance(CHECK_false); |
968 Universe::_out_of_memory_error_perm_gen = k_h->allocate_permanent_instance(CHECK_false); |
1025 |
1025 |
1026 |
1026 |
1027 // Setup static method for registering finalizers |
1027 // Setup static method for registering finalizers |
1028 // The finalizer klass must be linked before looking up the method, in |
1028 // The finalizer klass must be linked before looking up the method, in |
1029 // case it needs to get rewritten. |
1029 // case it needs to get rewritten. |
1030 instanceKlass::cast(SystemDictionary::finalizer_klass())->link_class(CHECK_false); |
1030 instanceKlass::cast(SystemDictionary::Finalizer_klass())->link_class(CHECK_false); |
1031 methodOop m = instanceKlass::cast(SystemDictionary::finalizer_klass())->find_method( |
1031 methodOop m = instanceKlass::cast(SystemDictionary::Finalizer_klass())->find_method( |
1032 vmSymbols::register_method_name(), |
1032 vmSymbols::register_method_name(), |
1033 vmSymbols::register_method_signature()); |
1033 vmSymbols::register_method_signature()); |
1034 if (m == NULL || !m->is_static()) { |
1034 if (m == NULL || !m->is_static()) { |
1035 THROW_MSG_(vmSymbols::java_lang_NoSuchMethodException(), |
1035 THROW_MSG_(vmSymbols::java_lang_NoSuchMethodException(), |
1036 "java.lang.ref.Finalizer.register", false); |
1036 "java.lang.ref.Finalizer.register", false); |
1037 } |
1037 } |
1038 Universe::_finalizer_register_cache->init( |
1038 Universe::_finalizer_register_cache->init( |
1039 SystemDictionary::finalizer_klass(), m, CHECK_false); |
1039 SystemDictionary::Finalizer_klass(), m, CHECK_false); |
1040 |
1040 |
1041 // Resolve on first use and initialize class. |
1041 // Resolve on first use and initialize class. |
1042 // Note: No race-condition here, since a resolve will always return the same result |
1042 // Note: No race-condition here, since a resolve will always return the same result |
1043 |
1043 |
1044 // Setup method for security checks |
1044 // Setup method for security checks |
1051 "java.lang.reflect.Method.invoke", false); |
1051 "java.lang.reflect.Method.invoke", false); |
1052 } |
1052 } |
1053 Universe::_reflect_invoke_cache->init(k_h(), m, CHECK_false); |
1053 Universe::_reflect_invoke_cache->init(k_h(), m, CHECK_false); |
1054 |
1054 |
1055 // Setup method for registering loaded classes in class loader vector |
1055 // Setup method for registering loaded classes in class loader vector |
1056 instanceKlass::cast(SystemDictionary::classloader_klass())->link_class(CHECK_false); |
1056 instanceKlass::cast(SystemDictionary::ClassLoader_klass())->link_class(CHECK_false); |
1057 m = instanceKlass::cast(SystemDictionary::classloader_klass())->find_method(vmSymbols::addClass_name(), vmSymbols::class_void_signature()); |
1057 m = instanceKlass::cast(SystemDictionary::ClassLoader_klass())->find_method(vmSymbols::addClass_name(), vmSymbols::class_void_signature()); |
1058 if (m == NULL || m->is_static()) { |
1058 if (m == NULL || m->is_static()) { |
1059 THROW_MSG_(vmSymbols::java_lang_NoSuchMethodException(), |
1059 THROW_MSG_(vmSymbols::java_lang_NoSuchMethodException(), |
1060 "java.lang.ClassLoader.addClass", false); |
1060 "java.lang.ClassLoader.addClass", false); |
1061 } |
1061 } |
1062 Universe::_loader_addClass_cache->init( |
1062 Universe::_loader_addClass_cache->init( |
1063 SystemDictionary::classloader_klass(), m, CHECK_false); |
1063 SystemDictionary::ClassLoader_klass(), m, CHECK_false); |
1064 |
1064 |
1065 // The folowing is initializing converter functions for serialization in |
1065 // The folowing is initializing converter functions for serialization in |
1066 // JVM.cpp. If we clean up the StrictMath code above we may want to find |
1066 // JVM.cpp. If we clean up the StrictMath code above we may want to find |
1067 // a better solution for this as well. |
1067 // a better solution for this as well. |
1068 initialize_converter_functions(); |
1068 initialize_converter_functions(); |