本文整理匯總了Java中java.lang.instrument.Instrumentation.appendToSystemClassLoaderSearch方法的典型用法代碼示例。如果您正苦於以下問題:Java Instrumentation.appendToSystemClassLoaderSearch方法的具體用法?Java Instrumentation.appendToSystemClassLoaderSearch怎麽用?Java Instrumentation.appendToSystemClassLoaderSearch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.lang.instrument.Instrumentation
的用法示例。
在下文中一共展示了Instrumentation.appendToSystemClassLoaderSearch方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import java.lang.instrument.Instrumentation; //導入方法依賴的package包/類
public static void main(String args[]) throws IOException {
JarFile bootclasses = new JarFile("BootSupport.jar");
JarFile agentclasses = new JarFile("AgentSupport.jar");
Instrumentation ins = Agent.getInstrumentation();
// Test 1: Add BootSupport.jar to boot class path and check that
// BootSupport is loaded by the bootstrap class loader
ins.appendToBootstrapClassLoaderSearch(bootclasses);
checkLoadedByLoader("BootSupport", null);
// Test 2: Add AgentSupport.jar to the system class path and check that
// AgentSupport is loaded by the system class loader.
try {
ins.appendToSystemClassLoaderSearch(agentclasses);
checkLoadedByLoader("AgentSupport", ClassLoader.getSystemClassLoader());
} catch (UnsupportedOperationException x) {
System.out.println("System class loader does not support adding to class path");
}
// throw exception if a test failed
if (failures > 0) {
throw new RuntimeException(failures + " test(s) failed.");
}
}
示例2: loadClassPathJAR
import java.lang.instrument.Instrumentation; //導入方法依賴的package包/類
private static void loadClassPathJAR(final Instrumentation instrumentation, final JarFile jar) {
instrumentation.appendToSystemClassLoaderSearch(jar);
}