3453 } 3454 } 3455 3456 assert(Universe::is_fully_initialized(), "not initialized"); 3457 if (VerifyDuringStartup) { 3458 // Make sure we're starting with a clean slate. 3459 VM_Verify verify_op; 3460 VMThread::execute(&verify_op); 3461 } 3462 3463 Thread* THREAD = Thread::current(); 3464 3465 // At this point, the Universe is initialized, but we have not executed 3466 // any byte code. Now is a good time (the only time) to dump out the 3467 // internal state of the JVM for sharing. 3468 if (DumpSharedSpaces) { 3469 MetaspaceShared::preload_and_dump(CHECK_JNI_ERR); 3470 ShouldNotReachHere(); 3471 } 3472 3473 // Always call even when there are not JVMTI environments yet, since environments 3474 // may be attached late and JVMTI must track phases of VM execution 3475 JvmtiExport::enter_start_phase(); 3476 3477 // Notify JVMTI agents that VM has started (JNI is up) - nop if no agents. 3478 JvmtiExport::post_vm_start(); 3479 3480 initialize_java_lang_classes(main_thread, CHECK_JNI_ERR); 3481 3482 // Create and patch the java.lang.reflect.Module entry for module java.base 3483 // into existing classes. 3484 ModuleEntryTable::patch_javabase_entries(CHECK_JNI_ERR); 3485 3486 // We need this for ClassDataSharing - the initial vm.info property is set 3487 // with the default value of CDS "sharing" which may be reset through 3488 // command line options. 3489 reset_vm_info_property(CHECK_JNI_ERR); 3490 3491 quicken_jni_functions(); 3492 3493 // Must be run after init_ft which initializes ft_enabled 3494 if (TRACE_INITIALIZE() != JNI_OK) { 3495 vm_exit_during_initialization("Failed to initialize tracing backend"); 3496 } 3497 3498 // Set flag that basic initialization has completed. Used by exceptions and various 3499 // debug stuff, that does not work until all basic classes have been initialized. 3574 // Phase 2. Module system initialization 3575 // This will initialize the module system. Only java.base classes 3576 // can be loaded until phase 2 completes. 3577 // 3578 // Call System.initPhase2 after the compiler initialization and jsr292 3579 // classes get initialized because module initialization runs a lot of java 3580 // code, that for performance reasons, should be compiled. Also, this will 3581 // enable the startup code to use lambda and other language features in this 3582 // phase and onward. 3583 // 3584 // After phase 2, The VM will begin search classes from -Xbootclasspath/a. 3585 // 3586 // Phase 3. final setup - set security manager, system class loader and TCCL 3587 // 3588 // This will instantiate and set the security manager, set the system class 3589 // loader as well as the thread context class loader. The security manager 3590 // and system class loader may be a custom class loaded from -Xbootclasspath/a, 3591 // other modules or the application's classpath. 3592 3593 call_initPhase2(CHECK_JNI_ERR); 3594 3595 // Final system initialization including security manager and system class loader. 3596 call_initPhase3(CHECK_JNI_ERR); 3597 3598 // cache the system class loader 3599 SystemDictionary::compute_java_system_loader(CHECK_JNI_ERR); 3600 3601 // Always call even when there are not JVMTI environments yet, since environments 3602 // may be attached late and JVMTI must track phases of VM execution 3603 JvmtiExport::enter_live_phase(); 3604 3605 if (TRACE_START() != JNI_OK) { 3606 vm_exit_during_initialization("Failed to start tracing backend."); 3607 } 3608 3609 // Notify JVMTI agents that VM initialization is complete - nop if no agents. 3610 JvmtiExport::post_vm_initialized(); 3611 3612 #if INCLUDE_MANAGEMENT 3613 Management::initialize(THREAD); | 3453 } 3454 } 3455 3456 assert(Universe::is_fully_initialized(), "not initialized"); 3457 if (VerifyDuringStartup) { 3458 // Make sure we're starting with a clean slate. 3459 VM_Verify verify_op; 3460 VMThread::execute(&verify_op); 3461 } 3462 3463 Thread* THREAD = Thread::current(); 3464 3465 // At this point, the Universe is initialized, but we have not executed 3466 // any byte code. Now is a good time (the only time) to dump out the 3467 // internal state of the JVM for sharing. 3468 if (DumpSharedSpaces) { 3469 MetaspaceShared::preload_and_dump(CHECK_JNI_ERR); 3470 ShouldNotReachHere(); 3471 } 3472 3473 initialize_java_lang_classes(main_thread, CHECK_JNI_ERR); 3474 3475 // Create and patch the java.lang.reflect.Module entry for module java.base 3476 // into existing classes. 3477 ModuleEntryTable::patch_javabase_entries(CHECK_JNI_ERR); 3478 3479 // We need this for ClassDataSharing - the initial vm.info property is set 3480 // with the default value of CDS "sharing" which may be reset through 3481 // command line options. 3482 reset_vm_info_property(CHECK_JNI_ERR); 3483 3484 quicken_jni_functions(); 3485 3486 // Must be run after init_ft which initializes ft_enabled 3487 if (TRACE_INITIALIZE() != JNI_OK) { 3488 vm_exit_during_initialization("Failed to initialize tracing backend"); 3489 } 3490 3491 // Set flag that basic initialization has completed. Used by exceptions and various 3492 // debug stuff, that does not work until all basic classes have been initialized. 3567 // Phase 2. Module system initialization 3568 // This will initialize the module system. Only java.base classes 3569 // can be loaded until phase 2 completes. 3570 // 3571 // Call System.initPhase2 after the compiler initialization and jsr292 3572 // classes get initialized because module initialization runs a lot of java 3573 // code, that for performance reasons, should be compiled. Also, this will 3574 // enable the startup code to use lambda and other language features in this 3575 // phase and onward. 3576 // 3577 // After phase 2, The VM will begin search classes from -Xbootclasspath/a. 3578 // 3579 // Phase 3. final setup - set security manager, system class loader and TCCL 3580 // 3581 // This will instantiate and set the security manager, set the system class 3582 // loader as well as the thread context class loader. The security manager 3583 // and system class loader may be a custom class loaded from -Xbootclasspath/a, 3584 // other modules or the application's classpath. 3585 3586 call_initPhase2(CHECK_JNI_ERR); 3587 3588 // Always call even when there are not JVMTI environments yet, since environments 3589 // may be attached late and JVMTI must track phases of VM execution 3590 JvmtiExport::enter_start_phase(); 3591 3592 // Notify JVMTI agents that VM has started (JNI is up) - nop if no agents. 3593 JvmtiExport::post_vm_start(); 3594 3595 // Final system initialization including security manager and system class loader. 3596 call_initPhase3(CHECK_JNI_ERR); 3597 3598 // cache the system class loader 3599 SystemDictionary::compute_java_system_loader(CHECK_JNI_ERR); 3600 3601 // Always call even when there are not JVMTI environments yet, since environments 3602 // may be attached late and JVMTI must track phases of VM execution 3603 JvmtiExport::enter_live_phase(); 3604 3605 if (TRACE_START() != JNI_OK) { 3606 vm_exit_during_initialization("Failed to start tracing backend."); 3607 } 3608 3609 // Notify JVMTI agents that VM initialization is complete - nop if no agents. 3610 JvmtiExport::post_vm_initialized(); 3611 3612 #if INCLUDE_MANAGEMENT 3613 Management::initialize(THREAD); |