On Fri, 19 May 2023 17:11:36 GMT, Alan Bateman <[email protected]> wrote:
>> This is the implementation for JEP 451. There are two parts to this:
>>
>> 1. A multi-line warning is printed when a JVM TI or Java agent is loaded
>> into a running VM. For JVM TI, the message is printed to stderr from
>> JvmtiAgent::load. For Java agents, it is printed to System.err (as that may
>> be redirected) in the JPLIS (j.l.instrumentation) implementation. This part
>> includes an update to the JVM TI spec and API docs to require the warning.
>>
>> 2. If running with -Djdk.instrument.traceUsage or
>> -Djdk.instrument.traceUsage=true, the calls to the Instrumentation API print
>> a trace message and stack trace.
>
> Alan Bateman has updated the pull request with a new target base due to a
> merge or a rebase. The incremental webrev excludes the unrelated changes
> brought in by the merge/rebase. The pull request contains 10 additional
> commits since the last revision:
>
> - Merge
> - Refresh package description
> - Merge
> - Tweak docs
> - Merge
> - Draft docs changes
> - Merge
> - Rename/cleanup
> - Merge
> - Initial commit
test/jdk/com/sun/tools/attach/warnings/DynamicLoadWarningTest.java line 90:
> 88: } else {
> 89: libname = "lib" + JVMTI_AGENT_LIB + ".so";
> 90: }
We have some test library support for this with Platform.sharedLibraryExt().
Unfortunately there is no "prefix" API, or better yet, one that builds out the
whole file name, but the following is a bit shorter:
`libname = (Platform.isWindows() ? "" : "lib") + JVMTI_AGENT_LIB + "." +
Platform.sharedLibraryExt();`
Up to you if you want to make this change
test/jdk/com/sun/tools/attach/warnings/DynamicLoadWarningTest.java line 108:
> 106: // no warning should be printed
> 107: test((pid, vm) -> vm.loadAgentLibrary(JVMTI_AGENT_LIB),
> "-XX:+EnableDynamicAgentLoading")
> 108: .shouldNotContain(message);
How about adding a test case for `-XX:-EnableDynamicAgentLoading`. Same thing
in `testJCmdJvmtiAgentLoad()` and `testLoadJavaAgent()` below.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13899#discussion_r1201475362
PR Review Comment: https://git.openjdk.org/jdk/pull/13899#discussion_r1201485800