本文整理汇总了Java中net.bytebuddy.description.field.FieldDescription类的典型用法代码示例。如果您正苦于以下问题:Java FieldDescription类的具体用法?Java FieldDescription怎么用?Java FieldDescription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FieldDescription类属于net.bytebuddy.description.field包,在下文中一共展示了FieldDescription类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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))
)
)
);
}
示例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;
}
示例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);
}
示例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);
}
示例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));
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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));
}
示例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);
}