src/share/vm/runtime/thread.cpp

Print this page
rev 3087 : 7141252: Diagnostic Framework Default parser fixes


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.
3389   //              Currently even the AWT code has calls to methods in java.lang.Compiler.
3390   //              On the classic VM, java.lang.Compiler is loaded very early to load the JIT.
3391   // Future Fix : the best fix is to grant everyone permissions to read "java.compiler" and
3392   //              read and write"java.vm.info" in the default policy file. See bugid 4211383
3393   //              Once that is done, we should remove this hack.
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);




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       warning("java.lang.IllegalArgumentException has not been initialized");
3373     }
3374   }
3375 
3376   // See        : bugid 4211085.
3377   // Background : the static initializer of java.lang.Compiler tries to read
3378   //              property"java.compiler" and read & write property "java.vm.info".
3379   //              When a security manager is installed through the command line
3380   //              option "-Djava.security.manager", the above properties are not
3381   //              readable and the static initializer for java.lang.Compiler fails
3382   //              resulting in a NoClassDefFoundError.  This can happen in any
3383   //              user code which calls methods in java.lang.Compiler.
3384   // Hack :       the hack is to pre-load and initialize this class, so that only
3385   //              system domains are on the stack when the properties are read.
3386   //              Currently even the AWT code has calls to methods in java.lang.Compiler.
3387   //              On the classic VM, java.lang.Compiler is loaded very early to load the JIT.
3388   // Future Fix : the best fix is to grant everyone permissions to read "java.compiler" and
3389   //              read and write"java.vm.info" in the default policy file. See bugid 4211383
3390   //              Once that is done, we should remove this hack.
3391   initialize_class(vmSymbols::java_lang_Compiler(), CHECK_0);
3392 
3393   // More hackery - the static initializer of java.lang.Compiler adds the string "nojit" to
3394   // the java.vm.info property if no jit gets loaded through java.lang.Compiler (the hotspot
3395   // compiler does not get loaded through java.lang.Compiler).  "java -version" with the
3396   // hotspot vm says "nojit" all the time which is confusing.  So, we reset it here.
3397   // This should also be taken out as soon as 4211383 gets fixed.
3398   reset_vm_info_property(CHECK_0);
3399 
3400   quicken_jni_functions();
3401 
3402   // Must be run after init_ft which initializes ft_enabled
3403   if (TRACE_INITIALIZE() != JNI_OK) {
3404     vm_exit_during_initialization("Failed to initialize tracing backend");
3405   }
3406 
3407   // Set flag that basic initialization has completed. Used by exceptions and various
3408   // debug stuff, that does not work until all basic classes have been initialized.
3409   set_init_completed();
3410 
3411 #ifndef USDT2
3412   HS_DTRACE_PROBE(hotspot, vm__init__end);
3413 #else /* USDT2 */
3414   HOTSPOT_VM_INIT_END();
3415 #endif /* USDT2 */
3416 
3417   // record VM initialization completion time
3418   Management::record_vm_init_completed();
3419 
3420   // Compute system loader. Note that this has to occur after set_init_completed, since
3421   // valid exceptions may be thrown in the process.
3422   // Note that we do not use CHECK_0 here since we are inside an EXCEPTION_MARK and
3423   // set_init_completed has just been called, causing exceptions not to be shortcut
3424   // anymore. We call vm_exit_during_initialization directly instead.
3425   SystemDictionary::compute_java_system_loader(THREAD);