本文整理汇总了Java中net.bytebuddy.description.method.MethodDescription.getStackSize方法的典型用法代码示例。如果您正苦于以下问题:Java MethodDescription.getStackSize方法的具体用法?Java MethodDescription.getStackSize怎么用?Java MethodDescription.getStackSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.bytebuddy.description.method.MethodDescription
的用法示例。
在下文中一共展示了MethodDescription.getStackSize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import net.bytebuddy.description.method.MethodDescription; //导入方法依赖的package包/类
public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext,
MethodDescription instrumentedMethod) {
checkMethodSignature(instrumentedMethod);
try {
StackManipulation stack = buildStack();
StackManipulation.Size finalStackSize = stack.apply(methodVisitor, implementationContext);
return new Size(finalStackSize.getMaximalSize(),
instrumentedMethod.getStackSize() + 2); // 2 stack slots for a single local variable
} catch (NoSuchMethodException | NoSuchFieldException e) {
throw new RuntimeException(e);
}
}
示例2: apply
import net.bytebuddy.description.method.MethodDescription; //导入方法依赖的package包/类
@Override
public Size apply(
MethodVisitor methodVisitor,
Context implementationContext,
MethodDescription instrumentedMethod) {
Map<String, FieldDescription> fieldsByName = CodeGenUtil.fieldsByName(implementationContext);
StackManipulation.Size operandStackSize =
new StackManipulation.Compound(
new TextConstant(unserializedFieldValue),
SerializeSupport_serializeString,
FieldAccess.forField(fieldsByName.get(fieldName)).write())
.apply(methodVisitor, implementationContext);
return new Size(operandStackSize.getMaximalSize(), instrumentedMethod.getStackSize());
}
示例3: appender
import net.bytebuddy.description.method.MethodDescription; //导入方法依赖的package包/类
@Override
public ByteCodeAppender appender(final Target implementationTarget) {
return new ByteCodeAppender() {
@Override
public Size apply(
MethodVisitor methodVisitor,
Context implementationContext,
MethodDescription instrumentedMethod) {
StackManipulation.Size size =
new StackManipulation.Compound(
// Load the this reference
MethodVariableAccess.REFERENCE.loadFrom(0),
// Load the delegate argument
MethodVariableAccess.REFERENCE.loadFrom(1),
// Invoke the super constructor (default constructor of Object)
MethodInvocation.invoke(
new TypeDescription.ForLoadedType(DoFnInvokerBase.class)
.getDeclaredMethods()
.filter(
ElementMatchers.isConstructor()
.and(ElementMatchers.takesArguments(DoFn.class)))
.getOnly()),
// Return void.
MethodReturn.VOID)
.apply(methodVisitor, implementationContext);
return new Size(size.getMaximalSize(), instrumentedMethod.getStackSize());
}
};
}
示例4: appender
import net.bytebuddy.description.method.MethodDescription; //导入方法依赖的package包/类
@Override
public ByteCodeAppender appender(final Target implementationTarget) {
return new ByteCodeAppender() {
@Override
public Size apply(
MethodVisitor methodVisitor,
Context implementationContext,
MethodDescription instrumentedMethod) {
StackManipulation.Size size =
new StackManipulation.Compound(
// Load the this reference
MethodVariableAccess.REFERENCE.loadFrom(0),
// Invoke the super constructor (default constructor of Object)
MethodInvocation.invoke(
new TypeDescription.ForLoadedType(Object.class)
.getDeclaredMethods()
.filter(
ElementMatchers.isConstructor()
.and(ElementMatchers.takesArguments(0)))
.getOnly()),
// Load the this reference
MethodVariableAccess.REFERENCE.loadFrom(0),
// Load the delegate argument
MethodVariableAccess.REFERENCE.loadFrom(1),
// Assign the delegate argument to the delegate field
FieldAccess.forField(
implementationTarget
.getInstrumentedType()
.getDeclaredFields()
.filter(ElementMatchers.named(FN_DELEGATE_FIELD_NAME))
.getOnly())
.write(),
// Return void.
MethodReturn.VOID)
.apply(methodVisitor, implementationContext);
return new Size(size.getMaximalSize(), instrumentedMethod.getStackSize());
}
};
}
示例5: apply
import net.bytebuddy.description.method.MethodDescription; //导入方法依赖的package包/类
@Override
public final ByteCodeAppender.Size apply(MethodVisitor mv, Implementation.Context ctx, MethodDescription method) {
StackManipulation.Size size = sm.apply(mv, ctx);
return new ByteCodeAppender.Size(size.getMaximalSize(), method.getStackSize());
}