本文整理了Java中javassist.Loader.addTranslator()
方法的一些代码示例,展示了Loader.addTranslator()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Loader.addTranslator()
方法的具体详情如下:
包路径:javassist.Loader
类名称:Loader
方法名:addTranslator
[英]Adds a translator, which is called whenever a class is loaded.
[中]添加一个转换器,在加载类时调用该转换器。
代码示例来源:origin: sc.fiji/fiji-compat
public static void main(String[] args) throws Throwable {
Thread.currentThread().setContextClassLoader(MemoryProfiler.class.getClassLoader());
if (args.length == 0) {
System.err.println("Usage: java " + MemoryProfiler.class + " <main-class> [<argument>...]");
System.exit(1);
}
String mainClass = args[0];
String[] mainArgs = new String[args.length - 1];
System.arraycopy(args, 1, mainArgs, 0, mainArgs.length);
Loader loader = new Loader();
loader.addTranslator(ClassPool.getDefault(), new MemoryProfiler());
gc();
loader.run(mainClass, mainArgs);
}
}
代码示例来源:origin: net.sf.jour/jour-instrument
private void init(String configFileName, String[] path) {
config = new Config(configFileName);
translator = new InstrumentingTranslator(config);
ClassPool pool = ClassPool.getDefault();
try {
for (int i = 0; (path != null) && (i < path.length); i++) {
pool.appendClassPath(path[i]);
}
super.addTranslator(pool, translator);
} catch (NotFoundException e) {
throw new Error(e);
} catch (CannotCompileException e) {
throw new Error(e);
}
}
代码示例来源:origin: org.openimaj/core-aop-support
protected static Loader run(final ClassLoader parent, ClassPool pool, MultiTransformClassFileTransformer tf,
String mainClass, String[] args)
throws Throwable
{
final Loader cl = new Loader(parent, pool);
// Set the correct app name on OSX. Are there similar controls for other
// platforms?
System.setProperty("com.apple.mrj.application.apple.menu.about.name", mainClass);
// skip args4j
cl.delegateLoadingOf("org.apache.log4j.");
cl.addTranslator(pool, tf);
cl.run(mainClass, args);
return cl;
}
代码示例来源:origin: openimaj/openimaj
protected static Loader run(final ClassLoader parent, ClassPool pool, MultiTransformClassFileTransformer tf,
String mainClass, String[] args)
throws Throwable
{
final Loader cl = new Loader(parent, pool);
// Set the correct app name on OSX. Are there similar controls for other
// platforms?
System.setProperty("com.apple.mrj.application.apple.menu.about.name", mainClass);
// skip args4j
cl.delegateLoadingOf("org.apache.log4j.");
cl.addTranslator(pool, tf);
cl.run(mainClass, args);
return cl;
}
代码示例来源:origin: stackoverflow.com
loader.addTranslator(ClassPool.getDefault(), new Profiler());
try {
if (args.length < 1) {
代码示例来源:origin: org.kie/lienzo-tests
public void updateLoaderWithLienzoTranslator(final Loader loader, final Translator translator)
{
try
{
final LienzoMockitoClassTranslator lienzoTranslator = new LienzoMockitoClassTranslator(settings, translator);
loader.addTranslator(ClassPool.getDefault(), lienzoTranslator);
}
catch (final NotFoundException e)
{
e.printStackTrace();
}
catch (final CannotCompileException e)
{
e.printStackTrace();
}
}
}
代码示例来源:origin: com.ahome-it/lienzo-tests
public void updateLoaderWithLienzoTranslator(final Loader loader, final Translator translator)
{
try
{
final LienzoMockitoClassTranslator lienzoTranslator = new LienzoMockitoClassTranslator(settings, translator);
loader.addTranslator(ClassPool.getDefault(), lienzoTranslator);
}
catch (final NotFoundException e)
{
e.printStackTrace();
}
catch (final CannotCompileException e)
{
e.printStackTrace();
}
}
}
代码示例来源:origin: sherif181/java-sequence-diagram-generator
loader.addTranslator(pool, xlat);
代码示例来源:origin: sc.fiji/fiji-compat
loader.addTranslator(pool, new PerformanceProfiler());
} catch (Exception e) {
e.printStackTrace();
代码示例来源:origin: org.openimaj/core-aop-support
/**
* Re-load the given class in a newly created {@link Loader} that is
* configured to apply the given transform(s), and then run the main method.
*
* @param transformer
* the transformer
* @param clz
* the class
* @param args
* the arguments
* @throws Throwable
* if an error occurs
*/
public static void run(MultiTransformClassFileTransformer transformer, Class<?> clz, String[] args) throws Throwable {
final ClassPool pool = new ClassPool();
pool.appendSystemPath();
final Loader loader = new Loader(pool);
// skip args4j
loader.delegateLoadingOf("org.apache.log4j.");
loader.addTranslator(pool, transformer);
loader.run(clz.getName(), args);
}
代码示例来源:origin: openimaj/openimaj
/**
* Re-load the given class in a newly created {@link Loader} that is
* configured to apply the given transform(s), and then run the main method.
*
* @param transformer
* the transformer
* @param clz
* the class
* @param args
* the arguments
* @throws Throwable
* if an error occurs
*/
public static void run(MultiTransformClassFileTransformer transformer, Class<?> clz, String[] args) throws Throwable {
final ClassPool pool = new ClassPool();
pool.appendSystemPath();
final Loader loader = new Loader(pool);
// skip args4j
loader.delegateLoadingOf("org.apache.log4j.");
loader.addTranslator(pool, transformer);
loader.run(clz.getName(), args);
}
内容来源于网络,如有侵权,请联系作者删除!