use of java.lang.instrument.ClassFileTransformer in project byte-buddy by raphw.
the class AgentBuilderDefaultTest method testIgnoredTypeMatcherOnlyAppliedOnceWithMultipleTransformations.
@Test
public void testIgnoredTypeMatcherOnlyAppliedOnceWithMultipleTransformations() throws Exception {
AgentBuilder.RawMatcher ignored = mock(AgentBuilder.RawMatcher.class);
ClassFileTransformer classFileTransformer = new AgentBuilder.Default(byteBuddy).with(initializationStrategy).with(poolStrategy).with(typeStrategy).with(installationListener).with(listener).disableNativeMethodPrefix().ignore(ignored).type(typeMatcher).transform(transformer).type(typeMatcher).transform(transformer).installOn(instrumentation);
assertThat(transform(classFileTransformer, JavaModule.ofType(REDEFINED), REDEFINED.getClassLoader(), REDEFINED.getName(), REDEFINED, REDEFINED.getProtectionDomain(), QUX), nullValue(byte[].class));
verify(listener).onIgnored(new TypeDescription.ForLoadedType(REDEFINED), REDEFINED.getClassLoader(), JavaModule.ofType(REDEFINED), true);
verify(listener).onComplete(REDEFINED.getName(), REDEFINED.getClassLoader(), JavaModule.ofType(REDEFINED), true);
verifyNoMoreInteractions(listener);
verify(ignored).matches(new TypeDescription.ForLoadedType(REDEFINED), REDEFINED.getClassLoader(), JavaModule.ofType(REDEFINED), REDEFINED, REDEFINED.getProtectionDomain());
verifyNoMoreInteractions(ignored);
}
use of java.lang.instrument.ClassFileTransformer in project byte-buddy by raphw.
the class AgentBuilderLambdaInstrumentationStrategyTest method testDisabledStrategyIsNoOp.
@Test
public void testDisabledStrategyIsNoOp() throws Exception {
ByteBuddy byteBuddy = mock(ByteBuddy.class);
Instrumentation instrumentation = mock(Instrumentation.class);
ClassFileTransformer classFileTransformer = mock(ClassFileTransformer.class);
AgentBuilder.Default.LambdaInstrumentationStrategy.DISABLED.apply(byteBuddy, instrumentation, classFileTransformer);
verifyZeroInteractions(byteBuddy);
verifyZeroInteractions(instrumentation);
verifyZeroInteractions(classFileTransformer);
}
use of java.lang.instrument.ClassFileTransformer in project pinpoint by naver.
the class MockPluginContextLoadResult method getClassFileTransformer.
@Override
public List<ClassFileTransformer> getClassFileTransformer() {
List<ClassFileTransformer> classFileTransformerList = new ArrayList<ClassFileTransformer>();
for (SetupResult pluginContext : getProfilerPluginContextList()) {
List<ClassFileTransformer> classFileTransformer = pluginContext.getClassTransformerList();
classFileTransformerList.addAll(classFileTransformer);
}
return classFileTransformerList;
}
use of java.lang.instrument.ClassFileTransformer in project pinpoint by naver.
the class DefaultClassFileTransformerDispatcher method createTransformerRegistry.
private TransformerRegistry createTransformerRegistry(PluginContextLoadResult pluginContexts) {
DefaultTransformerRegistry registry = new DefaultTransformerRegistry();
for (ClassFileTransformer transformer : pluginContexts.getClassFileTransformer()) {
if (transformer instanceof MatchableClassFileTransformer) {
MatchableClassFileTransformer t = (MatchableClassFileTransformer) transformer;
logger.info("Registering class file transformer {} for {} ", t, t.getMatcher());
registry.addTransformer(t.getMatcher(), t);
} else {
logger.warn("Ignore class file transformer {}", transformer);
}
}
return registry;
}
use of java.lang.instrument.ClassFileTransformer in project pinpoint by naver.
the class DefaultTransformerRegistry method addModifier0.
private void addModifier0(ClassFileTransformer transformer, String className) {
final String classInternalName = JavaAssistUtils.javaNameToJvmName(className);
ClassFileTransformer old = registry.put(classInternalName, transformer);
if (old != null) {
throw new IllegalStateException("Transformer already exist. className:" + classInternalName + " new:" + transformer.getClass() + " old:" + old.getClass());
}
}
Aggregations