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


Java StackManipulation.isValid方法代码示例

本文整理汇总了Java中net.bytebuddy.implementation.bytecode.StackManipulation.isValid方法的典型用法代码示例。如果您正苦于以下问题:Java StackManipulation.isValid方法的具体用法?Java StackManipulation.isValid怎么用?Java StackManipulation.isValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.bytebuddy.implementation.bytecode.StackManipulation的用法示例。


在下文中一共展示了StackManipulation.isValid方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: apply

import net.bytebuddy.implementation.bytecode.StackManipulation; //导入方法依赖的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

示例2: bind

import net.bytebuddy.implementation.bytecode.StackManipulation; //导入方法依赖的package包/类
@Override
public MethodBinding bind(Implementation.Target implementationTarget,
                          MethodDescription source,
                          MethodDelegationBinder.TerminationHandler terminationHandler,
                          MethodInvoker methodInvoker,
                          Assigner assigner) {
    if (!candidate.isAccessibleTo(implementationTarget.getInstrumentedType())) {
        return MethodBinding.Illegal.INSTANCE;
    }
    StackManipulation methodTermination = terminationHandler.resolve(assigner, typing, source, candidate);
    if (!methodTermination.isValid()) {
        return MethodBinding.Illegal.INSTANCE;
    }
    MethodBinding.Builder methodDelegationBindingBuilder = new MethodBinding.Builder(methodInvoker, candidate);
    for (DelegationProcessor.Handler handler : handlers) {
        ParameterBinding<?> parameterBinding = handler.bind(source, implementationTarget, assigner);
        if (!parameterBinding.isValid() || !methodDelegationBindingBuilder.append(parameterBinding)) {
            return MethodBinding.Illegal.INSTANCE;
        }
    }
    return methodDelegationBindingBuilder.build(methodTermination);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:23,代码来源:TargetMethodAnnotationDrivenBinder.java

示例3: apply

import net.bytebuddy.implementation.bytecode.StackManipulation; //导入方法依赖的package包/类
@Override
public Size apply(MethodVisitor methodVisitor, Context implementationContext, MethodDescription instrumentedMethod) {
    StackManipulation defaultMethodInvocation = locateDefault(instrumentedMethod);
    if (!defaultMethodInvocation.isValid()) {
        throw new IllegalStateException("Cannot invoke default method on " + instrumentedMethod);
    }
    StackManipulation.Size stackSize = new StackManipulation.Compound(
            MethodVariableAccess.allArgumentsOf(instrumentedMethod).prependThisReference(),
            defaultMethodInvocation,
            MethodReturn.of(instrumentedMethod.getReturnType())
    ).apply(methodVisitor, implementationContext);
    return new Size(stackSize.getMaximalSize(), instrumentedMethod.getStackSize());
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:14,代码来源:DefaultMethodCall.java

示例4: isValid

import net.bytebuddy.implementation.bytecode.StackManipulation; //导入方法依赖的package包/类
@Override
public boolean isValid() {
    for (StackManipulation stackManipulation : stackManipulations) {
        if (!stackManipulation.isValid()) {
            return false;
        }
    }
    return arrayCreator.isValid();
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:10,代码来源:ArrayFactory.java

示例5: access

import net.bytebuddy.implementation.bytecode.StackManipulation; //导入方法依赖的package包/类
/**
 * Checks a field access and loads the {@code this} instance if necessary.
 *
 * @param fieldDescription   The field to get a value
 * @param instrumentedMethod The instrumented method.
 * @param fieldAccess        A stack manipulation describing the field access.
 * @return An appropriate stack manipulation.
 */
private StackManipulation access(FieldDescription fieldDescription, MethodDescription instrumentedMethod, StackManipulation fieldAccess) {
    if (!fieldAccess.isValid()) {
        throw new IllegalStateException("Incompatible type of " + fieldDescription + " and " + instrumentedMethod);
    } else if (instrumentedMethod.isStatic() && !fieldDescription.isStatic()) {
        throw new IllegalArgumentException("Cannot call instance field " + fieldDescription + " from static method " + instrumentedMethod);
    }
    return new StackManipulation.Compound(fieldDescription.isStatic()
            ? StackManipulation.Trivial.INSTANCE
            : MethodVariableAccess.loadThis(), fieldAccess);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:19,代码来源:FieldAccessor.java

示例6: resolve

import net.bytebuddy.implementation.bytecode.StackManipulation; //导入方法依赖的package包/类
@Override
public Resolved resolve(TypeDescription instrumentedType, MethodDescription instrumentedMethod, Assigner assigner, Assigner.Typing typing) {
    FieldDescription fieldDescription = instrumentedType.getDeclaredFields().filter(named(name)).getOnly();
    StackManipulation stackManipulation = assigner.assign(fieldDescription.getType(), fieldType.asGenericType(), typing);
    if (!stackManipulation.isValid()) {
        throw new IllegalStateException("Cannot assign " + fieldDescription + " to " + fieldType);
    }
    return new Resolved.Simple(new StackManipulation.Compound(FieldAccess.forField(fieldDescription).read(),
            stackManipulation), fieldDescription.getType().asErasure());
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:11,代码来源:InvokeDynamic.java

示例7: doResolve

import net.bytebuddy.implementation.bytecode.StackManipulation; //导入方法依赖的package包/类
@Override
protected Resolved doResolve(StackManipulation access, TypeDescription.Generic typeDescription, Assigner assigner, Assigner.Typing typing) {
    StackManipulation stackManipulation = assigner.assign(typeDescription, this.typeDescription.asGenericType(), typing);
    if (!stackManipulation.isValid()) {
        throw new IllegalStateException("Cannot assign " + typeDescription + " to " + this.typeDescription);
    }
    return new Resolved.Simple(new StackManipulation.Compound(access, stackManipulation), this.typeDescription);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:9,代码来源:InvokeDynamic.java

示例8: apply

import net.bytebuddy.implementation.bytecode.StackManipulation; //导入方法依赖的package包/类
@Override
public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext, MethodDescription instrumentedMethod) {
    StackManipulation superMethodCall = implementationTarget.invokeDominant(instrumentedMethod.asSignatureToken());
    if (!superMethodCall.isValid()) {
        throw new IllegalStateException("Cannot call super (or default) method for " + instrumentedMethod);
    }
    StackManipulation.Size stackSize = new StackManipulation.Compound(
            MethodVariableAccess.allArgumentsOf(instrumentedMethod).prependThisReference(),
            superMethodCall,
            terminationHandler.of(instrumentedMethod)
    ).apply(methodVisitor, implementationContext);
    return new Size(stackSize.getMaximalSize(), instrumentedMethod.getStackSize());
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:14,代码来源:SuperMethodCall.java

示例9: of

import net.bytebuddy.implementation.bytecode.StackManipulation; //导入方法依赖的package包/类
/**
 * Creates a special method invocation for the given method.
 *
 * @param resolvedMethod      The rebased method to be invoked.
 * @param instrumentedType    The instrumented type on which the method is to be invoked if it is non-static.
 * @param additionalArguments Any additional arguments that are to be provided to the rebased method.
 * @return A special method invocation of the rebased method.
 */
protected static Implementation.SpecialMethodInvocation of(MethodDescription resolvedMethod,
                                                           TypeDescription instrumentedType,
                                                           StackManipulation additionalArguments) {
    StackManipulation stackManipulation = resolvedMethod.isStatic()
            ? MethodInvocation.invoke(resolvedMethod)
            : MethodInvocation.invoke(resolvedMethod).special(instrumentedType);
    return stackManipulation.isValid()
            ? new RebasedMethodInvocation(resolvedMethod, instrumentedType, new Compound(additionalArguments, stackManipulation))
            : Illegal.INSTANCE;
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:19,代码来源:RebaseImplementationTarget.java

示例10: of

import net.bytebuddy.implementation.bytecode.StackManipulation; //导入方法依赖的package包/类
/**
 * Creates a special method invocation for a given invocation target.
 *
 * @param methodDescription The method that represents the special method invocation.
 * @param typeDescription   The type on which the method should be invoked on by an {@code INVOKESPECIAL}
 *                          invocation.
 * @return A special method invocation representing a legal invocation if the method can be invoked
 * specially on the target type or an illegal invocation if this is not possible.
 */
public static SpecialMethodInvocation of(MethodDescription methodDescription, TypeDescription typeDescription) {
    StackManipulation stackManipulation = MethodInvocation.invoke(methodDescription).special(typeDescription);
    return stackManipulation.isValid()
            ? new Simple(methodDescription, typeDescription, stackManipulation)
            : SpecialMethodInvocation.Illegal.INSTANCE;
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:16,代码来源:Implementation.java


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