Mercurial > hg > truffle
diff src/share/vm/runtime/thread.cpp @ 2129:8f8dfba37802
6994753: Implement optional hook to a Java method at VM startup.
Reviewed-by: mchung, acorn
author | kevinw |
---|---|
date | Wed, 12 Jan 2011 15:44:16 +0000 |
parents | db2b0f8c1cef |
children | ccfcb502af3f |
line wrap: on
line diff
--- a/src/share/vm/runtime/thread.cpp Tue Jan 11 17:50:26 2011 -0500 +++ b/src/share/vm/runtime/thread.cpp Wed Jan 12 15:44:16 2011 +0000 @@ -978,6 +978,19 @@ } #endif // KERNEL +// General purpose hook into Java code, run once when the VM is initialized. +// The Java library method itself may be changed independently from the VM. +static void call_postVMInitHook(TRAPS) { + klassOop k = SystemDictionary::sun_misc_PostVMInitHook_klass(); + instanceKlassHandle klass (THREAD, k); + if (klass.not_null()) { + JavaValue result(T_VOID); + JavaCalls::call_static(&result, klass, vmSymbolHandles::run_method_name(), + vmSymbolHandles::void_method_signature(), + CHECK); + } +} + static void reset_vm_info_property(TRAPS) { // the vm info string ResourceMark rm(THREAD); @@ -3346,6 +3359,14 @@ BiasedLocking::init(); + if (JDK_Version::current().post_vm_init_hook_enabled()) { + call_postVMInitHook(THREAD); + // The Java side of PostVMInitHook.run must deal with all + // exceptions and provide means of diagnosis. + if (HAS_PENDING_EXCEPTION) { + CLEAR_PENDING_EXCEPTION; + } + } // Start up the WatcherThread if there are any periodic tasks // NOTE: All PeriodicTasks should be registered by now. If they