6994753: Implement optional hook to a Java method at VM startup

Reviewed-by: mchung, acorn
This commit is contained in:
Kevin Walls 2011-01-12 15:44:16 +00:00
parent 0b5708a12d
commit b6d2068ee2
7 changed files with 43 additions and 14 deletions

View file

@ -978,6 +978,19 @@ static void set_jkernel_boot_classloader_hook(TRAPS) {
}
#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 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
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