mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
6994753: Implement optional hook to a Java method at VM startup
Reviewed-by: mchung, acorn
This commit is contained in:
parent
0b5708a12d
commit
b6d2068ee2
7 changed files with 43 additions and 14 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue