本文整理了Java中java.lang.instrument.Instrumentation.addTransformer()
方法的一些代码示例,展示了Instrumentation.addTransformer()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instrumentation.addTransformer()
方法的具体详情如下:
包路径:java.lang.instrument.Instrumentation
类名称:Instrumentation
方法名:addTransformer
暂无
代码示例来源:origin: redisson/redisson
/**
* {@inheritDoc}
*/
public void addTransformer(Instrumentation instrumentation, ClassFileTransformer classFileTransformer, boolean canRetransform) {
if (canRetransform) {
throw new UnsupportedOperationException("The current VM does not support retransformation");
}
instrumentation.addTransformer(classFileTransformer);
}
}
代码示例来源:origin: redisson/redisson
/**
* {@inheritDoc}
*/
public void addTransformer(Instrumentation instrumentation, ClassFileTransformer classFileTransformer, boolean canRetransform) {
if (canRetransform) {
throw new UnsupportedOperationException("Cannot apply retransformation on legacy VM");
} else {
instrumentation.addTransformer(classFileTransformer);
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public void addTransformer(ClassFileTransformer transformer) {
Assert.notNull(transformer, "Transformer must not be null");
FilteringClassFileTransformer actualTransformer =
new FilteringClassFileTransformer(transformer, this.classLoader);
synchronized (this.transformers) {
Assert.state(this.instrumentation != null,
"Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation.");
this.instrumentation.addTransformer(actualTransformer);
this.transformers.add(actualTransformer);
}
}
代码示例来源:origin: org.springframework/spring-context
@Override
public void addTransformer(ClassFileTransformer transformer) {
Assert.notNull(transformer, "Transformer must not be null");
FilteringClassFileTransformer actualTransformer =
new FilteringClassFileTransformer(transformer, this.classLoader);
synchronized (this.transformers) {
Assert.state(this.instrumentation != null,
"Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation.");
this.instrumentation.addTransformer(actualTransformer);
this.transformers.add(actualTransformer);
}
}
代码示例来源:origin: linkedin/parseq
public static void agentmain(String agentArgs, Instrumentation instrumentation) {
if (_initialized.compareAndSet(false, true)) {
instrumentation.addTransformer(new Analyzer());
}
}
代码示例来源:origin: kilim/kilim
public static void premain(String agentArgs,Instrumentation inst) {
if (map==null) map = new TreeMap();
inst.addTransformer(new Agent());
}
代码示例来源:origin: oldmanpushcart/greys-anatomy
inst.addTransformer(resetClassFileTransformer, true);
代码示例来源:origin: oldmanpushcart/greys-anatomy
inst.addTransformer(getClassByteArrayFileTransformer, true);
final int size = classes.size();
final Class<?>[] classArray = new Class<?>[size];
代码示例来源:origin: LinShunKang/MyPerf4J
public static void premain(String options, Instrumentation ins) {
if (ASMBootstrap.getInstance().initial()) {
ins.addTransformer(new ProfilingTransformer());
}
}
代码示例来源:origin: oldmanpushcart/greys-anatomy
inst.addTransformer(enhancer, true);
代码示例来源:origin: scouter-project/scouter
public static void premain(String options, Instrumentation instrum) {
if (JavaAgent.instrumentation != null) {
return;
}
intro();
Configure config = Configure.getInstance();
JavaAgent.instrumentation = instrum;
if(config.scouter_enabled){
JavaAgent.instrumentation.addTransformer(new AgentTransformer());
BatchMonitor.getInstance();
}
}
代码示例来源:origin: alibaba/TProfiler
/**
* @param args
* @param inst
*/
public static void premain(String args, Instrumentation inst) {
Manager.instance().initialization();
inst.addTransformer(new ProfTransformer());
Manager.instance().startupThread();
}
}
代码示例来源:origin: uber-common/jvm-profiler
public void run(Arguments arguments, Instrumentation instrumentation, Collection<AutoCloseable> objectsToCloseOnShutdown) {
if (arguments.isNoop()) {
logger.info("Agent noop is true, do not run anything");
return;
}
Reporter reporter = arguments.getReporter();
String processUuid = UUID.randomUUID().toString();
String appId = null;
String appIdVariable = arguments.getAppIdVariable();
if (appIdVariable != null && !appIdVariable.isEmpty()) {
appId = System.getenv(appIdVariable);
}
if (appId == null || appId.isEmpty()) {
appId = SparkUtils.probeAppId(arguments.getAppIdRegex());
}
if (!arguments.getDurationProfiling().isEmpty()
|| !arguments.getArgumentProfiling().isEmpty()) {
instrumentation.addTransformer(new JavaAgentFileTransformer(arguments.getDurationProfiling(), arguments.getArgumentProfiling()));
}
List<Profiler> profilers = createProfilers(reporter, arguments, processUuid, appId);
ProfilerGroup profilerGroup = startProfilers(profilers);
Thread shutdownHook = new Thread(new ShutdownHookRunner(profilerGroup.getPeriodicProfilers(), Arrays.asList(reporter), objectsToCloseOnShutdown));
Runtime.getRuntime().addShutdownHook(shutdownHook);
}
代码示例来源:origin: btraceio/btrace
inst.addTransformer(transformer, true);
Main.debugPrint("Agent init took: " + (System.nanoTime() - ts) + "ns");
代码示例来源:origin: alibaba/jvm-sandbox
inst.addTransformer(sandClassFileTransformer, true);
代码示例来源:origin: org.mockito/mockito-core
this.redefineModule = redefineModule;
MockMethodDispatcher.set(identifier, new MockMethodAdvice(mocks, identifier));
instrumentation.addTransformer(this, true);
代码示例来源:origin: scouter-project/scouter
public static void preStart(String options, Instrumentation instrum, ClassFileTransformer transformer) {
if (JavaAgent.instrumentation != null) {
return;
}
intro();
Configure conf = Configure.getInstance();
if(conf.hook_lambda_instrumentation_strategy_enabled) {
Logger.println("LD001", "hook_lambda_instrumentation_strategy_enabled = true!");
Logger.println("LD001", "This feature is very experimental !!\n test it in your test environment first !!");
try {
new AgentBuilder.Default()
.with(AgentBuilder.LambdaInstrumentationStrategy.ENABLED)
.installOn(instrum);
} catch (Throwable t) {
Logger.println("LD002", "scouter min version doesn't support this feature !!!");
Logger.println("LD002", "Fail to hook_lambda_instrumentation_strategy_enabled !");
Logger.println("LD003", "Fatal on load bytebuddy AgentBuilder", t);
}
}
BackJobs.getInstance().put(Logger.class.getName(), 3000, Logger.initializer);
JavaAgent.instrumentation = instrum;
JavaAgent.instrumentation.addTransformer(transformer);
//TODO suuport 1.5 ?
//JavaAgent.instrumentation.addTransformer(transformer, true);
// RequestAgent.getInstance();
addAsyncRedefineClasses();
TcpRequestMgr.getInstance();
AsyncRunner.getInstance().add(new AgentBoot());
}
代码示例来源:origin: scouter-project/scouter
public static void preStart(String options, Instrumentation instrum, ClassFileTransformer transformer) {
if (JavaAgent.instrumentation != null) {
return;
}
intro();
Configure conf = Configure.getInstance();
if(conf.hook_lambda_instrumentation_strategy_enabled) {
Logger.println("LD001", "hook_lambda_instrumentation_strategy_enabled = true!");
Logger.println("LD001", "This feature is very experimental !!\n test it in your test environment first !!");
try {
new AgentBuilder.Default()
.with(AgentBuilder.LambdaInstrumentationStrategy.ENABLED)
.installOn(instrum);
} catch (Throwable t) {
Logger.println("LD002", "scouter min version doesn't support this feature !!!");
Logger.println("LD002", "Fail to hook_lambda_instrumentation_strategy_enabled !");
Logger.println("LD003", "Fatal on load bytebuddy AgentBuilder", t);
}
}
BackJobs.getInstance().put(Logger.class.getName(), 3000, Logger.initializer);
JavaAgent.instrumentation = instrum;
JavaAgent.instrumentation.addTransformer(transformer);
//TODO suuport 1.5 ?
//JavaAgent.instrumentation.addTransformer(transformer, true);
// RequestAgent.getInstance();
addAsyncRedefineClasses();
TcpRequestMgr.getInstance();
AsyncRunner.getInstance().add(new AgentBoot());
}
代码示例来源:origin: electronicarts/ea-async
public static void premain(String agentArgs, Instrumentation inst)
{
inst.addTransformer(new Transformer(), true);
System.setProperty(Transformer.EA_ASYNC_RUNNING, "true");
}
}
代码示例来源:origin: stackoverflow.com
public class BasicAgent {
public static void premain(String agentArguments, Instrumentation instrumentation){
System.out.println("Simple Agent");
FindUsageTransformer transformer = new FindUsageTransformer ();
instrumentation.addTransformer(transformer,true);
}
}
内容来源于网络,如有侵权,请联系作者删除!