• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java FieldDescription类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中net.bytebuddy.description.field.FieldDescription的典型用法代码示例。如果您正苦于以下问题:Java FieldDescription类的具体用法?Java FieldDescription怎么用?Java FieldDescription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FieldDescription类属于net.bytebuddy.description.field包,在下文中一共展示了FieldDescription类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: SmtBoxFieldTest

import net.bytebuddy.description.field.FieldDescription; //导入依赖的package包/类
public SmtBoxFieldTest() {
    super(
        new TestCase(
            "generates no bytecode for non-primitive fields",
            new AssertTokensToRepresentIdenticalBytecode(
                new SmtBoxField(
                    new FieldDescription.ForLoadedField(
                        NON_PRIMITIVE_FIELD
                    )
                ),
                new SmtDoNothing()
            )
        ),
        new TestCase(
            "boxes primitive fields",
            new AssertTokenToRepresentExpectedStackManipulation(
                new SmtBoxField(
                    new FieldDescription.ForLoadedField(
                        PRIMITIVE_FIELD
                    )
                ),
                () -> MethodInvocation.invoke(new MethodDescription.ForLoadedMethod(INT_VALUEOF))
            )
        )
    );
}
 
开发者ID:project-avral,项目名称:oo-atom,代码行数:27,代码来源:SmtBoxFieldTest.java


示例2: wrap

import net.bytebuddy.description.field.FieldDescription; //导入依赖的package包/类
@Override
        public ClassVisitor wrap(TypeDescription typeDescription, ClassVisitor cv, Context context, TypePool typePool,
                                 FieldList<FieldDescription.InDefinedShape> fieldList, MethodList<?> methodList, int i, int i1)
        {
//            public void visit(int version, int modifiers, String name, String signature, String superName, String[] interfaces) {
            cv.visit(ClassFileVersion.JAVA_V9.getMinorMajorVersion(), typeDescription.getModifiers(), typeDescription.getInternalName(), null,
                     typeDescription.getSuperClass().asErasure().getInternalName(), typeDescription.getInterfaces().asErasures().toInternalNames());
            TypeDescription clazz = this.clazz;
            String internalName = clazz.getInternalName();
            String descriptor = clazz.getDescriptor();
            MethodList<InDefinedShape> declaredMethods = clazz.getDeclaredMethods();
            int methodsSize = declaredMethods.size();
            String implName = GENERATED_PREFIX + "." + clazz.getName();
            String internalImplName = GENERATED_PREFIX.replace('.', '/') + "/" + internalName;
            String descriptorImplName = "L" + GENERATED_PREFIX.replace('.', '/') + "/" + internalName + ";";

            FieldVisitor fv;
            MethodVisitor mv;
            AnnotationVisitor av0;

            cv.visitEnd();
            return cv;
        }
 
开发者ID:Diorite,项目名称:Diorite,代码行数:24,代码来源:TransformerInvokerGenerator.java


示例3: testMatched

import net.bytebuddy.description.field.FieldDescription; //导入依赖的package包/类
@Test
public void testMatched() throws Exception {
    assertThat(new AsmVisitorWrapper.ForDeclaredFields()
            .field(matcher, fieldVisitorWrapper)
            .wrap(instrumentedType,
                    classVisitor,
                    implementationContext,
                    typePool,
                    new FieldList.Explicit<FieldDescription.InDefinedShape>(foo, bar),
                    new MethodList.Empty<MethodDescription>(),
                    IRRELEVANT,
                    IRRELEVANT)
            .visitField(MODIFIERS, FOO, QUX, BAZ, QUX + BAZ), is(wrappedVisitor));
    verify(matcher).matches(foo);
    verifyNoMoreInteractions(matcher);
    verify(fieldVisitorWrapper).wrap(instrumentedType, foo, fieldVisitor);
    verifyNoMoreInteractions(fieldVisitorWrapper);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:19,代码来源:AsmVisitorWrapperForDeclaredFieldsTest.java


示例4: subclass

import net.bytebuddy.description.field.FieldDescription; //导入依赖的package包/类
@Override
public InstrumentedType.WithFlexibleName subclass(String name, int modifiers, TypeDescription.Generic superClass) {
    return new InstrumentedType.Default(name,
            modifiers,
            superClass,
            Collections.<TypeVariableToken>emptyList(),
            Collections.<Generic>emptyList(),
            Collections.<FieldDescription.Token>emptyList(),
            Collections.<MethodDescription.Token>emptyList(),
            Collections.<AnnotationDescription>emptyList(),
            TypeInitializer.None.INSTANCE,
            LoadedTypeInitializer.NoOp.INSTANCE,
            TypeDescription.UNDEFINED,
            MethodDescription.UNDEFINED,
            TypeDescription.UNDEFINED,
            Collections.<TypeDescription>emptyList(),
            false,
            false,
            false);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:21,代码来源:InstrumentedType.java


示例5: testLegalAssignment

import net.bytebuddy.description.field.FieldDescription; //导入依赖的package包/类
@Test
public void testLegalAssignment() throws Exception {
    doReturn(void.class).when(annotation).declaringType();
    when(annotation.value()).thenReturn(FOO);
    when(instrumentedType.getDeclaredFields()).thenReturn(new FieldList.Explicit<FieldDescription.InDefinedShape>(fieldDescription));
    when(fieldDescription.getActualName()).thenReturn(FOO);
    when(fieldDescription.isVisibleTo(instrumentedType)).thenReturn(true);
    when(target.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
    when(stackManipulation.isValid()).thenReturn(true);
    MethodDelegationBinder.ParameterBinding<?> binding = FieldValue.Binder.INSTANCE.bind(annotationDescription,
            source,
            target,
            implementationTarget,
            assigner,
            Assigner.Typing.STATIC);
    assertThat(binding.isValid(), is(true));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:18,代码来源:FieldValueBinderTest.java


示例6: Default

import net.bytebuddy.description.field.FieldDescription; //导入依赖的package包/类
/**
 * Creates a new default implementation context.
 *
 * @param instrumentedType            The description of the type that is currently subject of creation.
 * @param classFileVersion            The class file version of the created class.
 * @param auxiliaryTypeNamingStrategy The naming strategy for naming an auxiliary type.
 * @param typeInitializer             The type initializer of the created instrumented type.
 * @param auxiliaryClassFileVersion   The class file version to use for auxiliary classes.
 */
protected Default(TypeDescription instrumentedType,
                  ClassFileVersion classFileVersion,
                  AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy,
                  TypeInitializer typeInitializer,
                  ClassFileVersion auxiliaryClassFileVersion) {
    super(instrumentedType, classFileVersion);
    this.auxiliaryTypeNamingStrategy = auxiliaryTypeNamingStrategy;
    this.typeInitializer = typeInitializer;
    this.auxiliaryClassFileVersion = auxiliaryClassFileVersion;
    registeredAccessorMethods = new HashMap<SpecialMethodInvocation, DelegationRecord>();
    registeredGetters = new HashMap<FieldDescription, DelegationRecord>();
    registeredSetters = new HashMap<FieldDescription, DelegationRecord>();
    auxiliaryTypes = new HashMap<AuxiliaryType, DynamicType>();
    registeredFieldCacheEntries = new HashMap<FieldCacheEntry, FieldDescription.InDefinedShape>();
    suffix = RandomString.make();
    fieldCacheCanAppendEntries = true;
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:27,代码来源:Implementation.java


示例7: testAccessorIsValid

import net.bytebuddy.description.field.FieldDescription; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testAccessorIsValid() throws Exception {
    TypeProxy typeProxy = new TypeProxy(mock(TypeDescription.class),
            mock(Implementation.Target.class),
            mock(TypeProxy.InvocationFactory.class),
            false,
            false);
    TypeProxy.MethodCall methodCall = typeProxy.new MethodCall(mock(MethodAccessorFactory.class));
    TypeDescription instrumentedType = mock(TypeDescription.class);
    FieldList<FieldDescription.InDefinedShape> fieldList = mock(FieldList.class);
    when(fieldList.filter(any(ElementMatcher.class))).thenReturn(fieldList);
    when(fieldList.getOnly()).thenReturn(mock(FieldDescription.InDefinedShape.class));
    when(instrumentedType.getDeclaredFields()).thenReturn(fieldList);
    TypeProxy.MethodCall.Appender appender = methodCall.new Appender(instrumentedType);
    Implementation.SpecialMethodInvocation specialMethodInvocation = mock(Implementation.SpecialMethodInvocation.class);
    when(specialMethodInvocation.isValid()).thenReturn(true);
    StackManipulation stackManipulation = appender.new AccessorMethodInvocation(mock(MethodDescription.class), specialMethodInvocation);
    assertThat(stackManipulation.isValid(), is(true));
    verify(specialMethodInvocation).isValid();
    verifyNoMoreInteractions(specialMethodInvocation);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:23,代码来源:TypeProxyCreationTest.java


示例8: testInstrumentationLegacyClassOtherType

import net.bytebuddy.description.field.FieldDescription; //导入依赖的package包/类
@Test
public void testInstrumentationLegacyClassOtherType() throws Exception {
    ClassVisitor classVisitor = TypeConstantAdjustment.INSTANCE.wrap(mock(TypeDescription.class),
            this.classVisitor,
            mock(Implementation.Context.class),
            mock(TypePool.class),
            new FieldList.Empty<FieldDescription.InDefinedShape>(),
            new MethodList.Empty<MethodDescription>(),
            IGNORED,
            IGNORED);
    classVisitor.visit(ClassFileVersion.JAVA_V4.getMinorMajorVersion(), FOOBAR, FOO, BAR, QUX, new String[]{BAZ});
    MethodVisitor methodVisitor = classVisitor.visitMethod(FOOBAR, FOO, BAR, QUX, new String[]{BAZ});
    assertThat(methodVisitor, not(this.methodVisitor));
    methodVisitor.visitLdcInsn(FOO);
    verify(this.classVisitor).visit(ClassFileVersion.JAVA_V4.getMinorMajorVersion(), FOOBAR, FOO, BAR, QUX, new String[]{BAZ});
    verify(this.classVisitor).visitMethod(FOOBAR, FOO, BAR, QUX, new String[]{BAZ});
    verifyNoMoreInteractions(this.classVisitor);
    verify(this.methodVisitor).visitLdcInsn(FOO);
    verifyNoMoreInteractions(this.methodVisitor);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:21,代码来源:TypeConstantAdjustmentTest.java


示例9: testMatched

import net.bytebuddy.description.field.FieldDescription; //导入依赖的package包/类
@Test
public void testMatched() throws Exception {
    assertThat(new AsmVisitorWrapper.ForDeclaredMethods()
            .method(matcher, methodVisitorWrapper)
            .wrap(instrumentedType,
                    classVisitor,
                    implementationContext,
                    typePool,
                    new FieldList.Empty<FieldDescription.InDefinedShape>(),
                    new MethodList.Explicit<MethodDescription>(foo, bar),
                    FLAGS,
                    FLAGS * 2)
            .visitMethod(MODIFIERS, FOO, QUX, BAZ, new String[]{QUX + BAZ}), is(wrappedVisitor));
    verify(matcher).matches(foo);
    verifyNoMoreInteractions(matcher);
    verify(methodVisitorWrapper).wrap(instrumentedType, foo, methodVisitor, implementationContext, typePool, FLAGS, FLAGS * 2);
    verifyNoMoreInteractions(methodVisitorWrapper);
    verifyZeroInteractions(typePool);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:20,代码来源:AsmVisitorWrapperForDeclaredMethodsTest.java


示例10: testNotMatched

import net.bytebuddy.description.field.FieldDescription; //导入依赖的package包/类
@Test
public void testNotMatched() throws Exception {
    assertThat(new AsmVisitorWrapper.ForDeclaredMethods()
            .method(matcher, methodVisitorWrapper)
            .wrap(instrumentedType,
                    classVisitor,
                    implementationContext,
                    typePool,
                    new FieldList.Empty<FieldDescription.InDefinedShape>(),
                    new MethodList.Explicit<MethodDescription>(foo, bar),
                    FLAGS,
                    FLAGS * 2)
            .visitMethod(MODIFIERS, BAR, BAZ, BAZ, new String[]{QUX + BAZ}), is(methodVisitor));
    verify(matcher).matches(bar);
    verifyNoMoreInteractions(matcher);
    verifyZeroInteractions(methodVisitorWrapper);
    verifyZeroInteractions(typePool);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:19,代码来源:AsmVisitorWrapperForDeclaredMethodsTest.java


示例11: makePlainInstrumentedType

import net.bytebuddy.description.field.FieldDescription; //导入依赖的package包/类
protected static InstrumentedType.WithFlexibleName makePlainInstrumentedType() {
    return new InstrumentedType.Default(FOO + "." + BAZ,
            ModifierReviewable.EMPTY_MASK,
            TypeDescription.Generic.OBJECT,
            Collections.<TypeVariableToken>emptyList(),
            Collections.<TypeDescription.Generic>emptyList(),
            Collections.<FieldDescription.Token>emptyList(),
            Collections.<MethodDescription.Token>emptyList(),
            Collections.<AnnotationDescription>emptyList(),
            TypeInitializer.None.INSTANCE,
            LoadedTypeInitializer.NoOp.INSTANCE,
            TypeDescription.UNDEFINED,
            MethodDescription.UNDEFINED,
            TypeDescription.UNDEFINED,
            Collections.<TypeDescription>emptyList(),
            false,
            false,
            false);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:20,代码来源:InstrumentedTypeDefaultTest.java


示例12: testInstrumentationModernClassFile

import net.bytebuddy.description.field.FieldDescription; //导入依赖的package包/类
@Test
public void testInstrumentationModernClassFile() throws Exception {
    ClassVisitor classVisitor = TypeConstantAdjustment.INSTANCE.wrap(mock(TypeDescription.class),
            this.classVisitor,
            mock(Implementation.Context.class),
            mock(TypePool.class),
            new FieldList.Empty<FieldDescription.InDefinedShape>(),
            new MethodList.Empty<MethodDescription>(),
            IGNORED,
            IGNORED);
    classVisitor.visit(ClassFileVersion.JAVA_V5.getMinorMajorVersion(), FOOBAR, FOO, BAR, QUX, new String[]{BAZ});
    assertThat(classVisitor.visitMethod(FOOBAR, FOO, BAR, QUX, new String[]{BAZ}), is(methodVisitor));
    verify(this.classVisitor).visit(ClassFileVersion.JAVA_V5.getMinorMajorVersion(), FOOBAR, FOO, BAR, QUX, new String[]{BAZ});
    verify(this.classVisitor).visitMethod(FOOBAR, FOO, BAR, QUX, new String[]{BAZ});
    verifyNoMoreInteractions(this.classVisitor);
    verifyZeroInteractions(methodVisitor);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:18,代码来源:TypeConstantAdjustmentTest.java


示例13: testSetterNameDiscovery

import net.bytebuddy.description.field.FieldDescription; //导入依赖的package包/类
@Test
public void testSetterNameDiscovery() throws Exception {
    doReturn(void.class).when(annotation).declaringType();
    when(annotation.value()).thenReturn(FieldValue.Binder.Delegate.BEAN_PROPERTY);
    when(instrumentedType.getDeclaredFields()).thenReturn(new FieldList.Explicit<FieldDescription.InDefinedShape>(fieldDescription));
    when(fieldDescription.getActualName()).thenReturn(FOO);
    when(fieldDescription.isVisibleTo(instrumentedType)).thenReturn(true);
    when(target.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
    when(stackManipulation.isValid()).thenReturn(true);
    when(source.getInternalName()).thenReturn("setFoo");
    when(source.getActualName()).thenReturn("setFoo");
    when(source.getReturnType()).thenReturn(TypeDescription.Generic.VOID);
    when(source.getParameters()).thenReturn(new ParameterList.Explicit.ForTypes(source, TypeDescription.Generic.OBJECT));
    MethodDelegationBinder.ParameterBinding<?> binding = FieldValue.Binder.INSTANCE.bind(annotationDescription,
            source,
            target,
            implementationTarget,
            assigner,
            Assigner.Typing.STATIC);
    assertThat(binding.isValid(), is(true));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:22,代码来源:FieldValueBinderTest.java


示例14: testIllegalAssignmentStaticMethod

import net.bytebuddy.description.field.FieldDescription; //导入依赖的package包/类
@Test
public void testIllegalAssignmentStaticMethod() throws Exception {
    doReturn(void.class).when(annotation).declaringType();
    when(annotation.value()).thenReturn(FOO);
    when(instrumentedType.getDeclaredFields()).thenReturn(new FieldList.Explicit<FieldDescription.InDefinedShape>(fieldDescription));
    when(fieldDescription.getActualName()).thenReturn(FOO);
    when(fieldDescription.isVisibleTo(instrumentedType)).thenReturn(true);
    when(target.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
    when(stackManipulation.isValid()).thenReturn(true);
    when(source.isStatic()).thenReturn(true);
    MethodDelegationBinder.ParameterBinding<?> binding = FieldValue.Binder.INSTANCE.bind(annotationDescription,
            source,
            target,
            implementationTarget,
            assigner,
            Assigner.Typing.STATIC);
    assertThat(binding.isValid(), is(false));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:19,代码来源:FieldValueBinderTest.java


示例15: wrap

import net.bytebuddy.description.field.FieldDescription; //导入依赖的package包/类
@Override
public ClassVisitor wrap(TypeDescription instrumentedType,
                         ClassVisitor classVisitor,
                         Implementation.Context implementationContext,
                         TypePool typePool,
                         FieldList<FieldDescription.InDefinedShape> fields,
                         MethodList<?> methods,
                         int writerFlags,
                         int readerFlags) {
    Map<String, MethodDescription> mapped = new HashMap<String, MethodDescription>();
    for (MethodDescription methodDescription : CompoundList.<MethodDescription>of(methods, new MethodDescription.Latent.TypeInitializer(instrumentedType))) {
        mapped.put(methodDescription.getInternalName() + methodDescription.getDescriptor(), methodDescription);
    }
    return new DispatchingVisitor(classVisitor,
            instrumentedType,
            implementationContext,
            typePool,
            mapped,
            writerFlags,
            readerFlags);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:22,代码来源:AsmVisitorWrapper.java


示例16: setUp

import net.bytebuddy.description.field.FieldDescription; //导入依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    when(getterMethod.getDeclaringType()).thenReturn(getterType);
    when(setterMethod.getDeclaringType()).thenReturn(setterType);
    when(instrumentedType.getDeclaredFields()).thenReturn(new FieldList.Explicit<FieldDescription.InDefinedShape>(fieldDescription));
    when(fieldDescription.getType()).thenReturn(genericFieldType);
    when(genericFieldType.getSort()).thenReturn(TypeDefinition.Sort.NON_GENERIC);
    when(genericFieldType.getStackSize()).thenReturn(StackSize.ZERO);
    when(genericFieldType.asErasure()).thenReturn(fieldType);
    when(fieldType.getSort()).thenReturn(TypeDefinition.Sort.NON_GENERIC);
    when(fieldType.asErasure()).thenReturn(fieldType);
    when(fieldType.getInternalName()).thenReturn(FOO);
    when(genericSetterType.asErasure()).thenReturn(setterType);
    when(genericGetterType.asErasure()).thenReturn(getterType);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:18,代码来源:FieldProxyBinderTest.java


示例17: ForElementMatchers

import net.bytebuddy.description.field.FieldDescription; //导入依赖的package包/类
/**
 * Creates a new substitution that applies element matchers to determine what byte code elements to substitute.
 *
 * @param fieldMatcher        The field matcher to determine fields to substitute.
 * @param methodMatcher       The method matcher to determine methods to substitute.
 * @param matchFieldRead      {@code true} if field read access should be substituted.
 * @param matchFieldWrite     {@code true} if field write access should be substituted.
 * @param includeVirtualCalls {@code true} if virtual method calls should be substituted.
 * @param includeSuperCalls   {@code true} if super method calls should be substituted.
 * @param resolver            The resolver to apply on elements to substitute.
 */
protected ForElementMatchers(ElementMatcher<? super FieldDescription.InDefinedShape> fieldMatcher,
                             ElementMatcher<? super MethodDescription> methodMatcher,
                             boolean matchFieldRead,
                             boolean matchFieldWrite,
                             boolean includeVirtualCalls,
                             boolean includeSuperCalls,
                             Resolver resolver) {
    this.fieldMatcher = fieldMatcher;
    this.methodMatcher = methodMatcher;
    this.matchFieldRead = matchFieldRead;
    this.matchFieldWrite = matchFieldWrite;
    this.includeVirtualCalls = includeVirtualCalls;
    this.includeSuperCalls = includeSuperCalls;
    this.resolver = resolver;
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:27,代码来源:MemberSubstitution.java


示例18: testGetterNameDiscovery

import net.bytebuddy.description.field.FieldDescription; //导入依赖的package包/类
@Test
public void testGetterNameDiscovery() throws Exception {
    doReturn(void.class).when(annotation).declaringType();
    when(annotation.value()).thenReturn(FieldValue.Binder.Delegate.BEAN_PROPERTY);
    when(instrumentedType.getDeclaredFields()).thenReturn(new FieldList.Explicit<FieldDescription.InDefinedShape>(fieldDescription));
    when(fieldDescription.getActualName()).thenReturn(FOO);
    when(fieldDescription.isVisibleTo(instrumentedType)).thenReturn(true);
    when(target.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
    when(stackManipulation.isValid()).thenReturn(true);
    when(source.getInternalName()).thenReturn("getFoo");
    when(source.getActualName()).thenReturn("getFoo");
    when(source.getReturnType()).thenReturn(TypeDescription.Generic.OBJECT);
    when(source.getParameters()).thenReturn(new ParameterList.Empty<ParameterDescription.InDefinedShape>());
    MethodDelegationBinder.ParameterBinding<?> binding = FieldValue.Binder.INSTANCE.bind(annotationDescription,
            source,
            target,
            implementationTarget,
            assigner,
            Assigner.Typing.STATIC);
    assertThat(binding.isValid(), is(true));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:22,代码来源:FieldValueBinderTest.java


示例19: testNotMatched

import net.bytebuddy.description.field.FieldDescription; //导入依赖的package包/类
@Test
public void testNotMatched() throws Exception {
    assertThat(new AsmVisitorWrapper.ForDeclaredFields()
            .field(matcher, fieldVisitorWrapper)
            .wrap(instrumentedType,
                    classVisitor,
                    implementationContext,
                    typePool,
                    new FieldList.Explicit<FieldDescription.InDefinedShape>(foo, bar),
                    new MethodList.Empty<MethodDescription>(),
                    IRRELEVANT,
                    IRRELEVANT)
            .visitField(MODIFIERS, BAR, QUX, BAZ, QUX + BAZ), is(fieldVisitor));
    verify(matcher).matches(bar);
    verifyNoMoreInteractions(matcher);
    verifyZeroInteractions(fieldVisitorWrapper);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:18,代码来源:AsmVisitorWrapperForDeclaredFieldsTest.java


示例20: apply

import net.bytebuddy.description.field.FieldDescription; //导入依赖的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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ShapeRenderer类代码示例发布时间:2022-05-22
下一篇:
Java LinkLogic类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap