本文整理汇总了Java中net.bytebuddy.implementation.bytecode.ByteCodeAppender.Size方法的典型用法代码示例。如果您正苦于以下问题:Java ByteCodeAppender.Size方法的具体用法?Java ByteCodeAppender.Size怎么用?Java ByteCodeAppender.Size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.bytebuddy.implementation.bytecode.ByteCodeAppender
的用法示例。
在下文中一共展示了ByteCodeAppender.Size方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import net.bytebuddy.implementation.bytecode.ByteCodeAppender; //导入方法依赖的package包/类
/**
* Applies an implementation that delegates to a invocation handler.
*
* @param methodVisitor The method visitor for writing the byte code to.
* @param implementationContext The implementation context for the current implementation.
* @param instrumentedMethod The method that is instrumented.
* @param preparingManipulation A stack manipulation that applies any preparation to the operand stack.
* @param fieldDescription The field that contains the value for the invocation handler.
* @return The size of the applied assignment.
*/
protected ByteCodeAppender.Size apply(MethodVisitor methodVisitor,
Context implementationContext,
MethodDescription instrumentedMethod,
StackManipulation preparingManipulation,
FieldDescription fieldDescription) {
if (instrumentedMethod.isStatic()) {
throw new IllegalStateException("It is not possible to apply an invocation handler onto the static method " + instrumentedMethod);
}
StackManipulation.Size stackSize = new StackManipulation.Compound(
preparingManipulation,
FieldAccess.forField(fieldDescription).read(),
MethodVariableAccess.loadThis(),
cacheMethods
? MethodConstant.forMethod(instrumentedMethod.asDefined()).cached()
: MethodConstant.forMethod(instrumentedMethod.asDefined()),
ArrayFactory.forType(TypeDescription.Generic.OBJECT).withValues(argumentValuesOf(instrumentedMethod)),
MethodInvocation.invoke(INVOCATION_HANDLER_TYPE.getDeclaredMethods().getOnly()),
assigner.assign(TypeDescription.Generic.OBJECT, instrumentedMethod.getReturnType(), Assigner.Typing.DYNAMIC),
MethodReturn.of(instrumentedMethod.getReturnType())
).apply(methodVisitor, implementationContext);
return new ByteCodeAppender.Size(stackSize.getMaximalSize(), instrumentedMethod.getStackSize());
}
示例2: apply
import net.bytebuddy.implementation.bytecode.ByteCodeAppender; //导入方法依赖的package包/类
/**
* Blueprint method that for applying the actual implementation.
*
* @param methodVisitor The method visitor to which the implementation is applied to.
* @param implementationContext The implementation context for the given implementation.
* @param instrumentedMethod The instrumented method that is target of the implementation.
* @param fixedValueType A description of the type of the fixed value that is loaded by the
* {@code valueLoadingInstruction}.
* @param valueLoadingInstruction A stack manipulation that represents the loading of the fixed value onto the
* operand stack.
* @return A representation of the stack and variable array sized that are required for this implementation.
*/
protected ByteCodeAppender.Size apply(MethodVisitor methodVisitor,
Context implementationContext,
MethodDescription instrumentedMethod,
TypeDescription.Generic fixedValueType,
StackManipulation valueLoadingInstruction) {
StackManipulation assignment = assigner.assign(fixedValueType, instrumentedMethod.getReturnType(), typing);
if (!assignment.isValid()) {
throw new IllegalArgumentException("Cannot return value of type " + fixedValueType + " for " + instrumentedMethod);
}
StackManipulation.Size stackSize = new StackManipulation.Compound(
valueLoadingInstruction,
assignment,
MethodReturn.of(instrumentedMethod.getReturnType())
).apply(methodVisitor, implementationContext);
return new ByteCodeAppender.Size(stackSize.getMaximalSize(), instrumentedMethod.getStackSize());
}
示例3: apply
import net.bytebuddy.implementation.bytecode.ByteCodeAppender; //导入方法依赖的package包/类
@Override
public ByteCodeAppender.Size apply(MethodVisitor mv, Implementation.Context p2, MethodDescription p3) {
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL, "br/com/brjdevs/highhacks/eventbus/ASMEventHandler", "<init>", "()V", false);
if (!isStatic) {
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 1);
mv.visitFieldInsn(PUTFIELD, thisClass, "instance", "Ljava/lang/Object;");
}
mv.visitInsn(RETURN);
mv.visitMaxs(2, 2);
return new ByteCodeAppender.Size(2, 2);
}
示例4: apply
import net.bytebuddy.implementation.bytecode.ByteCodeAppender; //导入方法依赖的package包/类
@Override
public ByteCodeAppender.Size apply(MethodVisitor mv, Implementation.Context implementationContext, MethodDescription instrumentedMethod) {
mv.visitVarInsn(ALOAD, 0);
if (!isStatic) {
mv.visitFieldInsn(GETFIELD, thisClass, "instance", "Ljava/lang/Object;");
mv.visitTypeInsn(CHECKCAST, listenerClass);
}
mv.visitVarInsn(ALOAD, 1);
mv.visitTypeInsn(CHECKCAST, eventClass);
mv.visitMethodInsn(isStatic ? INVOKESTATIC : INVOKEVIRTUAL, listenerClass, callback.getName(), Type.getMethodDescriptor(callback), false);
mv.visitInsn(RETURN);
mv.visitMaxs(2, 2);
return new Size(2, 2);
}
示例5: applyBody
import net.bytebuddy.implementation.bytecode.ByteCodeAppender; //导入方法依赖的package包/类
@Override
public void applyBody(MethodVisitor methodVisitor, Implementation.Context implementationContext, AnnotationValueFilter.Factory annotationValueFilterFactory) {
applyAttributes(methodVisitor, annotationValueFilterFactory);
methodVisitor.visitCode();
ByteCodeAppender.Size size = applyCode(methodVisitor, implementationContext);
methodVisitor.visitMaxs(size.getOperandStackSize(), size.getLocalVariableSize());
}
示例6: apply
import net.bytebuddy.implementation.bytecode.ByteCodeAppender; //导入方法依赖的package包/类
@Override
public void apply(ClassVisitor classVisitor, TypeInitializer typeInitializer, Implementation.Context implementationContext) {
ByteCodeAppender.Size size = typeInitializer.apply(mv, implementationContext, new MethodDescription.Latent.TypeInitializer(instrumentedType));
stackSize = Math.max(stackSize, size.getOperandStackSize());
localVariableLength = Math.max(localVariableLength, size.getLocalVariableSize());
onComplete(implementationContext);
}
示例7: onComplete
import net.bytebuddy.implementation.bytecode.ByteCodeAppender; //导入方法依赖的package包/类
@Override
protected void onComplete(Implementation.Context implementationContext) {
mv.visitLabel(label);
frameWriter.emitFrame(mv);
ByteCodeAppender.Size size = record.applyCode(mv, implementationContext);
stackSize = Math.max(stackSize, size.getOperandStackSize());
localVariableLength = Math.max(localVariableLength, size.getLocalVariableSize());
}
示例8: afterComplete
import net.bytebuddy.implementation.bytecode.ByteCodeAppender; //导入方法依赖的package包/类
@Override
protected void afterComplete(Implementation.Context implementationContext) {
mv.visitLabel(label);
frameWriter.emitFrame(mv);
ByteCodeAppender.Size size = record.applyCode(mv, implementationContext);
stackSize = Math.max(stackSize, size.getOperandStackSize());
localVariableLength = Math.max(localVariableLength, size.getLocalVariableSize());
}
示例9: testNoneThrowsExceptionOnApplication
import net.bytebuddy.implementation.bytecode.ByteCodeAppender; //导入方法依赖的package包/类
@Test
public void testNoneThrowsExceptionOnApplication() throws Exception {
ByteCodeAppender.Size size = TypeInitializer.None.INSTANCE.apply(methodVisitor, implementationContext, methodDescription);
assertThat(size.getOperandStackSize(), is(0));
assertThat(size.getLocalVariableSize(), is(0));
verifyZeroInteractions(methodDescription);
}
示例10: apply
import net.bytebuddy.implementation.bytecode.ByteCodeAppender; //导入方法依赖的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());
}
示例11: applyCode
import net.bytebuddy.implementation.bytecode.ByteCodeAppender; //导入方法依赖的package包/类
@Override
public ByteCodeAppender.Size applyCode(MethodVisitor methodVisitor, Implementation.Context implementationContext) {
throw new IllegalStateException("Cannot apply code for non-implemented method on " + methodDescription);
}