3203 delete main_thread;
3204 *canTryAgain = false; // don't let caller call JNI_CreateJavaVM again
3205 return JNI_ENOMEM;
3206 }
3207
3208 // Enable guard page *after* os::create_main_thread(), otherwise it would
3209 // crash Linux VM, see notes in os_linux.cpp.
3210 main_thread->create_stack_guard_pages();
3211
3212 // Initialize Java-Level synchronization subsystem
3213 ObjectMonitor::Initialize() ;
3214
3215 // Initialize global modules
3216 jint status = init_globals();
3217 if (status != JNI_OK) {
3218 delete main_thread;
3219 *canTryAgain = false; // don't let caller call JNI_CreateJavaVM again
3220 return status;
3221 }
3222
3223 // Must be run after init_ft which initializes ft_enabled
3224 if (TRACE_INITIALIZE() != JNI_OK) {
3225 vm_exit_during_initialization("Failed to initialize tracing backend");
3226 }
3227
3228 // Should be done after the heap is fully created
3229 main_thread->cache_global_variables();
3230
3231 HandleMark hm;
3232
3233 { MutexLocker mu(Threads_lock);
3234 Threads::add(main_thread);
3235 }
3236
3237 // Any JVMTI raw monitors entered in onload will transition into
3238 // real raw monitor. VM is setup enough here for raw monitor enter.
3239 JvmtiExport::transition_pending_onload_raw_monitors();
3240
3241 if (VerifyBeforeGC &&
3242 Universe::heap()->total_collections() >= VerifyGCStartAt) {
3243 Universe::heap()->prepare_for_verify();
3244 Universe::verify(); // make sure we're starting with a clean slate
3245 }
3246
3247 // Create the VMThread
3349
3350 // The VM preresolve methods to these classes. Make sure that get initialized
3351 initialize_class(vmSymbols::java_lang_reflect_Method(), CHECK_0);
3352 initialize_class(vmSymbols::java_lang_ref_Finalizer(), CHECK_0);
3353 // The VM creates & returns objects of this class. Make sure it's initialized.
3354 initialize_class(vmSymbols::java_lang_Class(), CHECK_0);
3355 call_initializeSystemClass(CHECK_0);
3356 } else {
3357 warning("java.lang.System not initialized");
3358 }
3359
3360 // an instance of OutOfMemory exception has been allocated earlier
3361 if (InitializeJavaLangExceptionsErrors) {
3362 initialize_class(vmSymbols::java_lang_OutOfMemoryError(), CHECK_0);
3363 initialize_class(vmSymbols::java_lang_NullPointerException(), CHECK_0);
3364 initialize_class(vmSymbols::java_lang_ClassCastException(), CHECK_0);
3365 initialize_class(vmSymbols::java_lang_ArrayStoreException(), CHECK_0);
3366 initialize_class(vmSymbols::java_lang_ArithmeticException(), CHECK_0);
3367 initialize_class(vmSymbols::java_lang_StackOverflowError(), CHECK_0);
3368 initialize_class(vmSymbols::java_lang_IllegalMonitorStateException(), CHECK_0);
3369 } else {
3370 warning("java.lang.OutOfMemoryError has not been initialized");
3371 warning("java.lang.NullPointerException has not been initialized");
3372 warning("java.lang.ClassCastException has not been initialized");
3373 warning("java.lang.ArrayStoreException has not been initialized");
3374 warning("java.lang.ArithmeticException has not been initialized");
3375 warning("java.lang.StackOverflowError has not been initialized");
3376 }
3377 }
3378
3379 // See : bugid 4211085.
3380 // Background : the static initializer of java.lang.Compiler tries to read
3381 // property"java.compiler" and read & write property "java.vm.info".
3382 // When a security manager is installed through the command line
3383 // option "-Djava.security.manager", the above properties are not
3384 // readable and the static initializer for java.lang.Compiler fails
3385 // resulting in a NoClassDefFoundError. This can happen in any
3386 // user code which calls methods in java.lang.Compiler.
3387 // Hack : the hack is to pre-load and initialize this class, so that only
3388 // system domains are on the stack when the properties are read.
3394 initialize_class(vmSymbols::java_lang_Compiler(), CHECK_0);
3395
3396 // More hackery - the static initializer of java.lang.Compiler adds the string "nojit" to
3397 // the java.vm.info property if no jit gets loaded through java.lang.Compiler (the hotspot
3398 // compiler does not get loaded through java.lang.Compiler). "java -version" with the
3399 // hotspot vm says "nojit" all the time which is confusing. So, we reset it here.
3400 // This should also be taken out as soon as 4211383 gets fixed.
3401 reset_vm_info_property(CHECK_0);
3402
3403 quicken_jni_functions();
3404
3405 // Set flag that basic initialization has completed. Used by exceptions and various
3406 // debug stuff, that does not work until all basic classes have been initialized.
3407 set_init_completed();
3408
3409 #ifndef USDT2
3410 HS_DTRACE_PROBE(hotspot, vm__init__end);
3411 #else /* USDT2 */
3412 HOTSPOT_VM_INIT_END();
3413 #endif /* USDT2 */
3414
3415 // record VM initialization completion time
3416 Management::record_vm_init_completed();
3417
3418 // Compute system loader. Note that this has to occur after set_init_completed, since
3419 // valid exceptions may be thrown in the process.
3420 // Note that we do not use CHECK_0 here since we are inside an EXCEPTION_MARK and
3421 // set_init_completed has just been called, causing exceptions not to be shortcut
3422 // anymore. We call vm_exit_during_initialization directly instead.
3423 SystemDictionary::compute_java_system_loader(THREAD);
3424 if (HAS_PENDING_EXCEPTION) {
3425 vm_exit_during_initialization(Handle(THREAD, PENDING_EXCEPTION));
3426 }
3427
3428 #ifndef SERIALGC
3429 // Support for ConcurrentMarkSweep. This should be cleaned up
3430 // and better encapsulated. The ugly nested if test would go away
3431 // once things are properly refactored. XXX YSR
3432 if (UseConcMarkSweepGC || UseG1GC) {
3433 if (UseConcMarkSweepGC) {
|
3203 delete main_thread;
3204 *canTryAgain = false; // don't let caller call JNI_CreateJavaVM again
3205 return JNI_ENOMEM;
3206 }
3207
3208 // Enable guard page *after* os::create_main_thread(), otherwise it would
3209 // crash Linux VM, see notes in os_linux.cpp.
3210 main_thread->create_stack_guard_pages();
3211
3212 // Initialize Java-Level synchronization subsystem
3213 ObjectMonitor::Initialize() ;
3214
3215 // Initialize global modules
3216 jint status = init_globals();
3217 if (status != JNI_OK) {
3218 delete main_thread;
3219 *canTryAgain = false; // don't let caller call JNI_CreateJavaVM again
3220 return status;
3221 }
3222
3223 // Should be done after the heap is fully created
3224 main_thread->cache_global_variables();
3225
3226 HandleMark hm;
3227
3228 { MutexLocker mu(Threads_lock);
3229 Threads::add(main_thread);
3230 }
3231
3232 // Any JVMTI raw monitors entered in onload will transition into
3233 // real raw monitor. VM is setup enough here for raw monitor enter.
3234 JvmtiExport::transition_pending_onload_raw_monitors();
3235
3236 if (VerifyBeforeGC &&
3237 Universe::heap()->total_collections() >= VerifyGCStartAt) {
3238 Universe::heap()->prepare_for_verify();
3239 Universe::verify(); // make sure we're starting with a clean slate
3240 }
3241
3242 // Create the VMThread
3344
3345 // The VM preresolve methods to these classes. Make sure that get initialized
3346 initialize_class(vmSymbols::java_lang_reflect_Method(), CHECK_0);
3347 initialize_class(vmSymbols::java_lang_ref_Finalizer(), CHECK_0);
3348 // The VM creates & returns objects of this class. Make sure it's initialized.
3349 initialize_class(vmSymbols::java_lang_Class(), CHECK_0);
3350 call_initializeSystemClass(CHECK_0);
3351 } else {
3352 warning("java.lang.System not initialized");
3353 }
3354
3355 // an instance of OutOfMemory exception has been allocated earlier
3356 if (InitializeJavaLangExceptionsErrors) {
3357 initialize_class(vmSymbols::java_lang_OutOfMemoryError(), CHECK_0);
3358 initialize_class(vmSymbols::java_lang_NullPointerException(), CHECK_0);
3359 initialize_class(vmSymbols::java_lang_ClassCastException(), CHECK_0);
3360 initialize_class(vmSymbols::java_lang_ArrayStoreException(), CHECK_0);
3361 initialize_class(vmSymbols::java_lang_ArithmeticException(), CHECK_0);
3362 initialize_class(vmSymbols::java_lang_StackOverflowError(), CHECK_0);
3363 initialize_class(vmSymbols::java_lang_IllegalMonitorStateException(), CHECK_0);
3364 initialize_class(vmSymbols::java_lang_IllegalArgumentException(), CHECK_0);
3365 } else {
3366 warning("java.lang.OutOfMemoryError has not been initialized");
3367 warning("java.lang.NullPointerException has not been initialized");
3368 warning("java.lang.ClassCastException has not been initialized");
3369 warning("java.lang.ArrayStoreException has not been initialized");
3370 warning("java.lang.ArithmeticException has not been initialized");
3371 warning("java.lang.StackOverflowError has not been initialized");
3372 }
3373 }
3374
3375 // See : bugid 4211085.
3376 // Background : the static initializer of java.lang.Compiler tries to read
3377 // property"java.compiler" and read & write property "java.vm.info".
3378 // When a security manager is installed through the command line
3379 // option "-Djava.security.manager", the above properties are not
3380 // readable and the static initializer for java.lang.Compiler fails
3381 // resulting in a NoClassDefFoundError. This can happen in any
3382 // user code which calls methods in java.lang.Compiler.
3383 // Hack : the hack is to pre-load and initialize this class, so that only
3384 // system domains are on the stack when the properties are read.
3390 initialize_class(vmSymbols::java_lang_Compiler(), CHECK_0);
3391
3392 // More hackery - the static initializer of java.lang.Compiler adds the string "nojit" to
3393 // the java.vm.info property if no jit gets loaded through java.lang.Compiler (the hotspot
3394 // compiler does not get loaded through java.lang.Compiler). "java -version" with the
3395 // hotspot vm says "nojit" all the time which is confusing. So, we reset it here.
3396 // This should also be taken out as soon as 4211383 gets fixed.
3397 reset_vm_info_property(CHECK_0);
3398
3399 quicken_jni_functions();
3400
3401 // Set flag that basic initialization has completed. Used by exceptions and various
3402 // debug stuff, that does not work until all basic classes have been initialized.
3403 set_init_completed();
3404
3405 #ifndef USDT2
3406 HS_DTRACE_PROBE(hotspot, vm__init__end);
3407 #else /* USDT2 */
3408 HOTSPOT_VM_INIT_END();
3409 #endif /* USDT2 */
3410
3411 // Must be run after init_ft which initializes ft_enabled
3412 if (TRACE_INITIALIZE() != JNI_OK) {
3413 vm_exit_during_initialization("Failed to initialize tracing backend");
3414 }
3415
3416 // record VM initialization completion time
3417 Management::record_vm_init_completed();
3418
3419 // Compute system loader. Note that this has to occur after set_init_completed, since
3420 // valid exceptions may be thrown in the process.
3421 // Note that we do not use CHECK_0 here since we are inside an EXCEPTION_MARK and
3422 // set_init_completed has just been called, causing exceptions not to be shortcut
3423 // anymore. We call vm_exit_during_initialization directly instead.
3424 SystemDictionary::compute_java_system_loader(THREAD);
3425 if (HAS_PENDING_EXCEPTION) {
3426 vm_exit_during_initialization(Handle(THREAD, PENDING_EXCEPTION));
3427 }
3428
3429 #ifndef SERIALGC
3430 // Support for ConcurrentMarkSweep. This should be cleaned up
3431 // and better encapsulated. The ugly nested if test would go away
3432 // once things are properly refactored. XXX YSR
3433 if (UseConcMarkSweepGC || UseG1GC) {
3434 if (UseConcMarkSweepGC) {
|