本文整理汇总了Java中javassist.expr.NewExpr类的典型用法代码示例。如果您正苦于以下问题:Java NewExpr类的具体用法?Java NewExpr怎么用?Java NewExpr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NewExpr类属于javassist.expr包,在下文中一共展示了NewExpr类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: edit
import javassist.expr.NewExpr; //导入依赖的package包/类
/**
* Is called when an instance creation occurs. Replaces references to
* classes to be removed by the value expression in the annotation
* or by <b>null</b>.
*
* @param expression the instance creation expression to be processed
* @throws CannotCompileException in case of errors in the generated
* byte code
*/
@Override
public void edit(NewExpr expression) throws CannotCompileException {
try {
CtConstructor cons = expression.getConstructor();
CtClass declaring = cons.getDeclaringClass();
if (removals.containsKey(cons.getLongName())
|| classesForRemoval.contains(declaring)) {
Variability annotation = Annotations.getAnnotationRec(
declaring, Variability.class,
config.checkRecursively());
String expr;
if (null != annotation && annotation.value().length() > 0) {
expr = "$_ = new " + annotation.value() + "($$);";
} else {
expr = "$_ = null;";
}
expression.replace(expr);
}
} catch (NotFoundException ex) {
throw new CannotCompileException(ex);
}
}
示例2: edit
import javassist.expr.NewExpr; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public void edit(NewExpr ex) throws CannotCompileException {
try {
addTypeIf(innerClassPrefix,
ex.getConstructor().getDeclaringClass(),
targetClassName, inner);
} catch (NotFoundException e) {
throw new CannotCompileException(e);
}
}
示例3: edit
import javassist.expr.NewExpr; //导入依赖的package包/类
/**
* Instruments an object creation.
*
* @param ne the expression to be annotated
* @throws CannotCompileException in case that the new code does not
* compile
*/
public void edit(NewExpr ne) throws CannotCompileException {
try {
expression = ne;
editor.editNewExpression(ne.getClassName());
} catch (InstrumenterException e) {
throw new CannotCompileException(e);
}
}
示例4: edit
import javassist.expr.NewExpr; //导入依赖的package包/类
@Override
public void edit(NewExpr newExpression) throws CannotCompileException {
logger.warn(" >>> NewExpr: {}, line {}, {}", new Object[]{newExpression.getEnclosingClass().getName(),
newExpression.getLineNumber(), newExpression.getSignature()});
try {
CtConstructor constructor = newExpression.getConstructor();
CtClass ctClass = constructor.getDeclaringClass();
MethodDescriptor methodDescriptor = new MethodDescriptor(newExpression);
if (classTransformer.isAlreadyInstrumented(methodDescriptor)) {
return;
}
classTransformer.addInstrumentation(methodDescriptor);
if (ctClass.isFrozen()) {
logger.warn("'{}' is 'frozen'", ctClass.getName());
return;
}
instrument(constructor, ctClass, methodDescriptor);
Transformation transformation = classTransformer.getTransformation(ctClass.getName());
if (transformation != null) {
java.lang.instrument.Instrumentation javainstrumentation = classTransformer.getInstrumentation();
ProfilingClassFileTransformer localTransformer = new ProfilingClassFileTransformer(javainstrumentation);
javainstrumentation.addTransformer(localTransformer, true);
Class<?> cls1 = Class.forName(ctClass.getName());
ClassDefinition classDefinition = new ClassDefinition(cls1, ctClass.toBytecode());
javainstrumentation.redefineClasses(classDefinition);
javainstrumentation.removeTransformer(localTransformer);
}
} catch (Exception e1) {
logger.error(e1.getMessage(), e1);
}
}
示例5: getConstructorEntry
import javassist.expr.NewExpr; //导入依赖的package包/类
public static ConstructorEntry getConstructorEntry(NewExpr call) {
return new ConstructorEntry(
new ClassEntry(Descriptor.toJvmName(call.getClassName())),
new Signature(call.getSignature())
);
}
示例6: getConstructorEntry
import javassist.expr.NewExpr; //导入依赖的package包/类
public static ConstructorEntry getConstructorEntry(NewExpr call) {
return new ConstructorEntry(new ClassEntry(Descriptor.toJvmName(call.getClassName())), new Signature(call.getSignature()));
}
示例7: getConstructorEntry
import javassist.expr.NewExpr; //导入依赖的package包/类
public static ConstructorEntry getConstructorEntry(NewExpr call)
{
return new ConstructorEntry(new ClassEntry(Descriptor.toJvmName(call
.getClassName())), new Signature(call.getSignature()));
}
示例8: MethodDescriptor
import javassist.expr.NewExpr; //导入依赖的package包/类
public MethodDescriptor(NewExpr newExpr) throws NotFoundException {
this(newExpr.getClassName(), newExpr.getConstructor().getName(), newExpr.getLineNumber());
}
示例9: edit
import javassist.expr.NewExpr; //导入依赖的package包/类
public void edit(NewExpr e) throws CannotCompileException { }