use of com.navercorp.pinpoint.bootstrap.instrument.InstrumentContext in project pinpoint by naver.
the class JavassistClassTest method getNestedClasses.
@Test
public void getNestedClasses() throws Exception {
InstrumentEngine engine = newJavassistEngine();
InstrumentContext instrumentContext = mock(InstrumentContext.class);
String testObjectName = "com.navercorp.pinpoint.test.javasssit.mock.TestObjectNestedClass";
byte[] testObjectByteCode = readByteCode(testObjectName);
InstrumentClass testObject = engine.getClass(instrumentContext, null, testObjectName, testObjectByteCode);
Assert.assertEquals(testObject.getName(), testObjectName);
// find class name condition.
final String targetClassName = "com.navercorp.pinpoint.profiler.interceptor.bci.TestObjectNestedClass$InstanceInner";
for (InstrumentClass c : testObject.getNestedClasses(ClassFilters.name(targetClassName))) {
assertEquals(targetClassName, c.getName());
}
// find enclosing method condition.
assertEquals(2, testObject.getNestedClasses(ClassFilters.enclosingMethod("annonymousInnerClass")).size());
// find interface condition.
assertEquals(2, testObject.getNestedClasses(ClassFilters.interfaze("java.util.concurrent.Callable")).size());
// find enclosing method & interface condition.
assertEquals(1, testObject.getNestedClasses(ClassFilters.chain(ClassFilters.enclosingMethod("annonymousInnerClass"), ClassFilters.interfaze("java.util.concurrent.Callable"))).size());
}
use of com.navercorp.pinpoint.bootstrap.instrument.InstrumentContext in project pinpoint by naver.
the class JavassistClassTest method testClassHierarchy.
@Test
public void testClassHierarchy() throws InstrumentException {
InstrumentEngine engine = newJavassistEngine();
InstrumentContext instrumentContext = mock(InstrumentContext.class);
String testObjectName = "com.navercorp.pinpoint.test.javasssit.mock.TestObject";
byte[] testObjectByteCode = readByteCode(testObjectName);
InstrumentClass testObject = engine.getClass(instrumentContext, null, testObjectName, testObjectByteCode);
Assert.assertEquals(testObject.getName(), testObjectName);
String testObjectSuperClass = testObject.getSuperClass();
Assert.assertEquals("java.lang.Object", testObjectSuperClass);
String[] testObjectSuperClassInterfaces = testObject.getInterfaces();
Assert.assertEquals(testObjectSuperClassInterfaces.length, 0);
final String classHierarchyTestMockName = "com.navercorp.pinpoint.test.javasssit.mock.ClassHierarchyTestMock";
byte[] classHierarchyTestMockByteCode = readByteCode(classHierarchyTestMockName);
InstrumentClass classHierarchyObject = engine.getClass(instrumentContext, null, classHierarchyTestMockName, classHierarchyTestMockByteCode);
String hierarchySuperClass = classHierarchyObject.getSuperClass();
Assert.assertEquals("java.util.HashMap", hierarchySuperClass);
String[] hierarchyInterfaces = classHierarchyObject.getInterfaces();
Assert.assertEquals(hierarchyInterfaces.length, 2);
Assert.assertEquals(hierarchyInterfaces[0], "java.lang.Runnable");
Assert.assertEquals(hierarchyInterfaces[1], "java.lang.Comparable");
}
use of com.navercorp.pinpoint.bootstrap.instrument.InstrumentContext in project pinpoint by naver.
the class JavassistClassTest method testDeclaredMethod.
@Test
public void testDeclaredMethod() throws InstrumentException {
InstrumentEngine engine = newJavassistEngine();
InstrumentContext instrumentContext = mock(InstrumentContext.class);
String testObjectName = "com.navercorp.pinpoint.test.javasssit.mock.TestObject";
byte[] testObjectByteCode = readByteCode(testObjectName);
InstrumentClass testObject = engine.getClass(instrumentContext, null, testObjectName, testObjectByteCode);
Assert.assertEquals(testObject.getName(), testObjectName);
InstrumentMethod declaredMethod = testObject.getDeclaredMethod("callA");
Assert.assertNotNull(declaredMethod);
}
use of com.navercorp.pinpoint.bootstrap.instrument.InstrumentContext in project pinpoint by naver.
the class DebugTransformerRegistry method newDebugTransformer.
private DebugTransformer newDebugTransformer(ProfilerConfig profilerConfig, InstrumentEngine instrumentEngine, DynamicTransformTrigger dynamicTransformTrigger) {
ClassInjector classInjector = newClassInjector(profilerConfig);
ClassFileTransformerLoader transformerRegistry = new ClassFileTransformerLoader(profilerConfig, dynamicTransformTrigger);
InstrumentContext debugContext = new PluginInstrumentContext(profilerConfig, instrumentEngine, dynamicTransformTrigger, classInjector, transformerRegistry);
return new DebugTransformer(instrumentEngine, debugContext);
}
use of com.navercorp.pinpoint.bootstrap.instrument.InstrumentContext in project pinpoint by naver.
the class JavassistEngineTest method testGetClass_transform.
@Test
public void testGetClass_transform() throws Exception {
InstrumentEngine instrumentEngine = newJavassistEngine();
InstrumentContext instrumentContext = mock(InstrumentContext.class);
final byte[] transformByteCode = getTransformByteCode();
final InstrumentClass transformClass = instrumentEngine.getClass(instrumentContext, null, mock, transformByteCode);
Assert.assertNotNull(transformClass.getDeclaredMethod("test"));
Assert.assertNotNull("transform method", transformClass.getDeclaredMethod("transformMethod"));
}
Aggregations