< prev index next >

src/hotspot/share/runtime/thread.cpp

Print this page




4309     if (on_load_entry != NULL) {
4310       // Invoke the JVM_OnLoad function
4311       JavaThread* thread = JavaThread::current();
4312       ThreadToNativeFromVM ttn(thread);
4313       HandleMark hm(thread);
4314       jint err = (*on_load_entry)(&main_vm, agent->options(), NULL);
4315       if (err != JNI_OK) {
4316         vm_exit_during_initialization("-Xrun library failed to init", agent->name());
4317       }
4318     } else {
4319       vm_exit_during_initialization("Could not find JVM_OnLoad function in -Xrun library", agent->name());
4320     }
4321   }
4322 }
4323 
4324 
4325 // Last thread running calls java.lang.Shutdown.shutdown()
4326 void JavaThread::invoke_shutdown_hooks() {
4327   HandleMark hm(this);
4328 







4329   // We could get here with a pending exception, if so clear it now.
4330   if (this->has_pending_exception()) {
4331     this->clear_pending_exception();
4332   }
4333 
4334   EXCEPTION_MARK;
4335   Klass* shutdown_klass =
4336     SystemDictionary::resolve_or_null(vmSymbols::java_lang_Shutdown(),
4337                                       THREAD);
4338   if (shutdown_klass != NULL) {
4339     // SystemDictionary::resolve_or_null will return null if there was
4340     // an exception.  If we cannot load the Shutdown class, just don't
4341     // call Shutdown.shutdown() at all.  This will mean the shutdown hooks
4342     // won't be run.  Note that if a shutdown hook was registered,
4343     // the Shutdown class would have already been loaded
4344     // (Runtime.addShutdownHook will load it).
4345     JavaValue result(T_VOID);
4346     JavaCalls::call_static(&result,
4347                            shutdown_klass,
4348                            vmSymbols::shutdown_name(),




4309     if (on_load_entry != NULL) {
4310       // Invoke the JVM_OnLoad function
4311       JavaThread* thread = JavaThread::current();
4312       ThreadToNativeFromVM ttn(thread);
4313       HandleMark hm(thread);
4314       jint err = (*on_load_entry)(&main_vm, agent->options(), NULL);
4315       if (err != JNI_OK) {
4316         vm_exit_during_initialization("-Xrun library failed to init", agent->name());
4317       }
4318     } else {
4319       vm_exit_during_initialization("Could not find JVM_OnLoad function in -Xrun library", agent->name());
4320     }
4321   }
4322 }
4323 
4324 
4325 // Last thread running calls java.lang.Shutdown.shutdown()
4326 void JavaThread::invoke_shutdown_hooks() {
4327   HandleMark hm(this);
4328 
4329   // Link all classes for dynamic CDS dumping before vm exit.
4330   // Same operation is being done in JVM_BeforeHalt for handling the
4331   // case where the application calls System.exit().
4332   if (DynamicDumpSharedSpaces) {
4333     MetaspaceShared::link_and_cleanup_shared_classes(false, this);
4334   }
4335 
4336   // We could get here with a pending exception, if so clear it now.
4337   if (this->has_pending_exception()) {
4338     this->clear_pending_exception();
4339   }
4340 
4341   EXCEPTION_MARK;
4342   Klass* shutdown_klass =
4343     SystemDictionary::resolve_or_null(vmSymbols::java_lang_Shutdown(),
4344                                       THREAD);
4345   if (shutdown_klass != NULL) {
4346     // SystemDictionary::resolve_or_null will return null if there was
4347     // an exception.  If we cannot load the Shutdown class, just don't
4348     // call Shutdown.shutdown() at all.  This will mean the shutdown hooks
4349     // won't be run.  Note that if a shutdown hook was registered,
4350     // the Shutdown class would have already been loaded
4351     // (Runtime.addShutdownHook will load it).
4352     JavaValue result(T_VOID);
4353     JavaCalls::call_static(&result,
4354                            shutdown_klass,
4355                            vmSymbols::shutdown_name(),


< prev index next >