use of com.navercorp.pinpoint.profiler.instrument.classpool.NamedClassPool in project pinpoint by naver.
the class JavassistEngine method getContextClassPool.
private ClassPool getContextClassPool(InstrumentContext instrumentContext, NamedClassPool parent, String jvmInternalClassName, byte[] classfileBuffer) throws NotFoundException {
final ClassPool contextCassPool = new ClassPool(parent);
contextCassPool.childFirstLookup = true;
final String javaName = JavaAssistUtils.jvmNameToJavaName(jvmInternalClassName);
if (isDebug) {
logger.debug("getContextClassPool() className={}", javaName);
}
final ClassPath byteArrayClassPath = new ByteArrayClassPath(javaName, classfileBuffer);
contextCassPool.insertClassPath(byteArrayClassPath);
// plugin class not found in jboss classLoader
if (instrumentContext instanceof PluginInstrumentContext) {
final PluginConfig pluginConfig = ((PluginInstrumentContext) instrumentContext).getPluginConfig();
if (pluginConfig != null) {
String jarPath = pluginConfig.getPluginJar().getPath();
contextCassPool.appendClassPath(jarPath);
}
}
return contextCassPool;
}
use of com.navercorp.pinpoint.profiler.instrument.classpool.NamedClassPool in project pinpoint by naver.
the class HierarchyMultipleClassPoolTest method testTestClass.
@Test
public void testTestClass() throws Exception {
NamedClassPool pool = new NamedClassPool("test");
pool.childFirstLookup = true;
HierarchyMultipleClassPool multipleClassPool = new HierarchyMultipleClassPool(pool);
ClassLoader classLoader = new URLClassLoader(new URL[0], ClassLoader.getSystemClassLoader());
multipleClassPool.getClassPool(classLoader);
logger.debug("size {}", multipleClassPool.size());
for (NamedClassPool classPool1 : multipleClassPool.values()) {
logger.debug("classPool:{} name:{}", classPool1, classPool1.getName());
}
Assert.assertEquals(2, multipleClassPool.size());
}
use of com.navercorp.pinpoint.profiler.instrument.classpool.NamedClassPool in project pinpoint by naver.
the class IsolateMultipleClassPoolTest method testPoolSize.
@Test
public void testPoolSize() throws Exception {
IsolateMultipleClassPool pool = new IsolateMultipleClassPool();
NamedClassPool systemPool = pool.getClassPool(systemClassLoader);
Assert.assertEquals(0, pool.size());
pool.getClassPool(null);
Assert.assertEquals(0, pool.size());
Assert.assertSame(systemPool, pool.getClassPool(systemClassLoader));
NamedClassPool child1Pool = pool.getClassPool(child1);
Assert.assertEquals(1, pool.size());
NamedClassPool child1Pool_recheck = pool.getClassPool(child1);
Assert.assertEquals(1, pool.size());
Assert.assertSame(child1Pool, child1Pool_recheck);
Assert.assertNotSame(systemPool, child1Pool);
NamedClassPool classPool2 = pool.getClassPool(child2);
Assert.assertEquals(2, pool.size());
pool.getClassPool(child2);
Assert.assertEquals(2, pool.size());
Assert.assertNotSame(systemPool, classPool2);
}
use of com.navercorp.pinpoint.profiler.instrument.classpool.NamedClassPool in project pinpoint by naver.
the class IsolateMultipleClassPoolTest method testGetClass_childLookupFirst.
@Test
public void testGetClass_childLookupFirst() throws Exception {
IsolateMultipleClassPool pool = new IsolateMultipleClassPool(false, IsolateMultipleClassPool.EMPTY_EVENT_LISTENER, null);
NamedClassPool systemPool = pool.getClassPool(systemClassLoader);
CtClass systemLogger = systemPool.get(TEST_CLASS);
NamedClassPool rootPool = pool.getClassPool(root);
CtClass rootLogger = rootPool.get(TEST_CLASS);
Assert.assertSame(systemLogger, rootLogger);
NamedClassPool childPool = pool.getClassPool(child1);
CtClass childLogger = childPool.get(TEST_CLASS);
Assert.assertSame(systemLogger, childLogger);
NamedClassPool childPool2 = pool.getClassPool(child2);
CtClass child2Logger = childPool2.get(TEST_CLASS);
Assert.assertSame(systemLogger, child2Logger);
}
use of com.navercorp.pinpoint.profiler.instrument.classpool.NamedClassPool in project pinpoint by naver.
the class IsolateMultipleClassPoolTest method testGetClass.
@Test
public void testGetClass() throws Exception {
IsolateMultipleClassPool pool = new IsolateMultipleClassPool();
NamedClassPool systemPool = pool.getClassPool(systemClassLoader);
String classname = "java.lang.String";
CtClass systemString = systemPool.get(classname);
NamedClassPool childPool = pool.getClassPool(child1);
CtClass childPoolString = childPool.get("java.lang.String");
Assert.assertNotSame(systemString, childPoolString);
Assert.assertNotSame(systemString.getClassPool(), childPoolString.getClassPool());
CtClass testClass = childPool.get(this.getClass().getName());
Assert.assertNotSame(systemString.getClassPool(), testClass.getClassPool());
NamedClassPool childPool2 = pool.getClassPool(child2);
CtClass testClass2 = childPool2.get(this.getClass().getName());
Assert.assertNotSame(systemString.getClassPool(), testClass2.getClassPool());
CtClass testCtClass = childPool2.get(TEST_CLASS);
logger.debug("className:{}", Arrays.toString(testCtClass.getConstructors()));
}
Aggregations