Skip to content

Commit

Permalink
Change Attachment.loadAgentLibrary() to a static method
Browse files Browse the repository at this point in the history
Added a dummy arg for the native loadAgentLibraryImpl() to ensure that
the current native method has the ClassLoader instance as its second
argument required by jnimisc.cpp:getCurrentClassLoader().

Signed-off-by: Jason Feng <[email protected]>
  • Loading branch information
JasonFengJ9 committed Aug 8, 2023
1 parent b03193f commit 5efd1ae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,11 @@ private boolean parseLoadAgent(String cmd) {
* add prefixes and suffixes to the library name.
* @return null if successful, diagnostic string if error
*/
String loadAgentLibrary(String agentLibrary, String options,
static String loadAgentLibrary(String agentLibrary, String options,
boolean decorate) {
IPC.logMessage("loadAgentLibrary " + agentLibrary + ':' + options + " decorate=" + decorate); //$NON-NLS-1$ //$NON-NLS-2$
ClassLoader loader = java.lang.ClassLoader.getSystemClassLoader();
int status = loadAgentLibraryImpl(loader ,agentLibrary, options, decorate);
int status = loadAgentLibraryImpl(true, loader, agentLibrary, options, decorate);
if (0 != status) {
if (-1 == status) {
return Response.EXCEPTION_AGENT_LOAD_EXCEPTION + ' '
Expand All @@ -384,16 +384,18 @@ String loadAgentLibrary(String agentLibrary, String options,
}

/**
*
* @param agentLibrary
* a dummy arg to ensure that current native method has the ClassLoader instance
* as it's second argument required by jnimisc.cpp:getCurrentClassLoader()
* @param agentLibrary
* name of the agent library
* @param options
* arguments to the library's Agent_OnAttach function
* @param decorate
* add prefixes and suffixes to the library name.
* add prefixes and suffixes to the library name
* @return 0 if all went well
*/
private native int loadAgentLibraryImpl(ClassLoader loader,String agentLibrary,
private static native int loadAgentLibraryImpl(boolean dummy, ClassLoader loader,String agentLibrary,
String options, boolean decorate);

private int getPortNumber() {
Expand Down
2 changes: 1 addition & 1 deletion runtime/vm/BytecodeInterpreter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4841,7 +4841,7 @@ class INTERPRETER_CLASS
return rc;
}

/* openj9.internal.tools.attach.target.Attachment: private native int loadAgentLibraryImpl(ClassLoader loader, String agentLibrary, String options, boolean decorate); */
/* openj9.internal.tools.attach.target.Attachment: private static native int loadAgentLibraryImpl(boolean dummy, ClassLoader loader, String agentLibrary, String options, boolean decorate); */
VMINLINE VM_BytecodeAction
inlAttachmentLoadAgentLibraryImpl(REGISTER_ARGS_LIST)
{
Expand Down

0 comments on commit 5efd1ae

Please sign in to comment.