jdk/src/share/classes/sun/tools/attach/HotSpotVirtualMachine.java
/*
* Load JPLIS agent which will load the agent JAR file and invoke
* the agentmain method.
*/
public void loadAgent(String agent, String options)
throws AgentLoadException, AgentInitializationException, IOException
{
{- -------------------------------------------
(1) (変数宣言など)
---------------------------------------- -}
String args = agent;
if (options != null) {
args = args + "=" + options;
}
{- -------------------------------------------
(1) "instrument" (libinstrumentの意) を引数にして
sun.tools.attach.HotSpotVirtualMachine.loadAgentLibrary(String agentLibrary, String options) を呼び出す.
(なお, 失敗した場合は適切な例外をスローする)
---------------------------------------- -}
try {
loadAgentLibrary("instrument", args);
} catch (AgentLoadException x) {
throw new InternalError("instrument library is missing in target VM");
} catch (AgentInitializationException x) {
/*
* Translate interesting errors into the right exception and
* message (FIXME: create a better interface to the instrument
* implementation so this isn't necessary)
*/
int rc = x.returnValue();
switch (rc) {
case JNI_ENOMEM:
throw new AgentLoadException("Insuffient memory");
case ATTACH_ERROR_BADJAR:
throw new AgentLoadException("Agent JAR not found or no Agent-Class attribute");
case ATTACH_ERROR_NOTONCP:
throw new AgentLoadException("Unable to add JAR file to system class path");
case ATTACH_ERROR_STARTFAIL:
throw new AgentInitializationException("Agent JAR loaded but agent failed to initialize");
default :
throw new AgentLoadException("Failed to load agent - unknown reason: " + rc);
}
}
}
This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.