Skip to content

Commit b2069bc

Browse files
committed
8299957: Enhance error logging in instrument coding with additional jplis_assert_msg
Backport-of: be8e6d05db2f623626506e64a2fb7caf755d5d06
1 parent 8c2df95 commit b2069bc

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/java.instrument/share/native/libinstrument/InvocationAdapter.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* 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) {
420420
* Create the java.lang.instrument.Instrumentation instance
421421
*/
422422
success = createInstrumentationImpl(jni_env, agent);
423-
jplis_assert(success);
423+
jplis_assert_msg(success, "createInstrumentationImpl failed");
424424

425425
/*
426426
* Setup ClassFileLoadHook handler.
427427
*/
428428
if (success) {
429429
success = setLivePhaseEventHandlers(agent);
430-
jplis_assert(success);
430+
jplis_assert_msg(success, "setLivePhaseEventHandlers failed");
431431
}
432432

433433
/*
@@ -439,6 +439,7 @@ DEF_Agent_OnAttach(JavaVM* vm, char *args, void * reserved) {
439439
agentClass,
440440
options,
441441
agent->mAgentmainCaller);
442+
jplis_assert_msg(success, "startJavaAgent failed");
442443
}
443444

444445
if (!success) {

src/java.instrument/share/native/libinstrument/JPLISAgent.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -448,13 +448,15 @@ startJavaAgent( JPLISAgent * agent,
448448
optionsString,
449449
&classNameObject,
450450
&optionsStringObject);
451+
jplis_assert_msg(success, "commandStringIntoJavaStrings failed");
451452

452453
if (success) {
453454
success = invokeJavaAgentMainMethod( jnienv,
454455
agent->mInstrumentationImpl,
455456
agentMainMethod,
456457
classNameObject,
457458
optionsStringObject);
459+
jplis_assert_msg(success, "invokeJavaAgentMainMethod failed");
458460
}
459461

460462
return success;
@@ -614,6 +616,7 @@ invokeJavaAgentMainMethod( JNIEnv * jnienv,
614616
errorOutstanding = checkForThrowable(jnienv);
615617
if ( errorOutstanding ) {
616618
logThrowable(jnienv);
619+
jplis_assert_msg(!errorOutstanding, "Outstanding error when calling method in invokeJavaAgentMainMethod");
617620
}
618621
checkForAndClearThrowable(jnienv);
619622
}

0 commit comments

Comments
 (0)