本文整理汇总了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);
}