8299957: Enhance error logging in instrument coding with additional jplis_assert_msg

Reviewed-by: sspitsyn
This commit is contained in:
Matthias Baesken 2023-01-13 07:57:38 +00:00
parent 640eff64d2
commit be8e6d05db
2 changed files with 8 additions and 4 deletions
src/java.instrument/share/native/libinstrument

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -420,14 +420,14 @@ DEF_Agent_OnAttach(JavaVM* vm, char *args, void * reserved) {
* Create the java.lang.instrument.Instrumentation instance
*/
success = createInstrumentationImpl(jni_env, agent);
jplis_assert(success);
jplis_assert_msg(success, "createInstrumentationImpl failed");
/*
* Setup ClassFileLoadHook handler.
*/
if (success) {
success = setLivePhaseEventHandlers(agent);
jplis_assert(success);
jplis_assert_msg(success, "setLivePhaseEventHandlers failed");
}
/*
@ -439,6 +439,7 @@ DEF_Agent_OnAttach(JavaVM* vm, char *args, void * reserved) {
agentClass,
options,
agent->mAgentmainCaller);
jplis_assert_msg(success, "startJavaAgent failed");
}
if (!success) {

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -448,6 +448,7 @@ startJavaAgent( JPLISAgent * agent,
optionsString,
&classNameObject,
&optionsStringObject);
jplis_assert_msg(success, "commandStringIntoJavaStrings failed");
if (success) {
success = invokeJavaAgentMainMethod( jnienv,
@ -455,6 +456,7 @@ startJavaAgent( JPLISAgent * agent,
agentMainMethod,
classNameObject,
optionsStringObject);
jplis_assert_msg(success, "invokeJavaAgentMainMethod failed");
}
return success;
@ -614,6 +616,7 @@ invokeJavaAgentMainMethod( JNIEnv * jnienv,
errorOutstanding = checkForThrowable(jnienv);
if ( errorOutstanding ) {
logThrowable(jnienv);
jplis_assert_msg(!errorOutstanding, "Outstanding error when calling method in invokeJavaAgentMainMethod");
}
checkForAndClearThrowable(jnienv);
}