当前位置: 首页>>代码示例>>Java>>正文


Java ByteCodeAppender.Size方法代码示例

本文整理汇总了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());
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:33,代码来源:InvocationHandlerAdapter.java

示例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());
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:29,代码来源:FixedValue.java

示例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);
}
 
开发者ID:Mantaro,项目名称:MantaroRPG,代码行数:14,代码来源:ASMEventHandlerConstructor.java

示例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);
}
 
开发者ID:Mantaro,项目名称:MantaroRPG,代码行数:15,代码来源:ASMEventHandlerHandle.java

示例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());
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:8,代码来源:TypeWriter.java

示例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);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:8,代码来源:TypeWriter.java

示例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());
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:9,代码来源:TypeWriter.java

示例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());
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:9,代码来源:TypeWriter.java

示例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);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:8,代码来源:TypeInitializerTest.java

示例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());
}
 
开发者ID:project-avral,项目名称:oo-atom,代码行数:6,代码来源:BtGenerateMethod.java

示例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);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:5,代码来源:TypeWriter.java


注:本文中的net.bytebuddy.implementation.bytecode.ByteCodeAppender.Size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。