本文整理汇总了Java中net.bytebuddy.description.type.TypeDescription.VOID属性的典型用法代码示例。如果您正苦于以下问题:Java TypeDescription.VOID属性的具体用法?Java TypeDescription.VOID怎么用?Java TypeDescription.VOID使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类net.bytebuddy.description.type.TypeDescription
的用法示例。
在下文中一共展示了TypeDescription.VOID属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTestClassObject
/**
* Creates a test class dynamically for a single test method and returns an instance thereof.
*
* @param baseTest
* @param testMethod
* @return
*/
private static Object createTestClassObject(AbstractDiqlExecutionTest<?> baseTest, Method testMethod) {
// define the method that the returned class should have
MethodDescription.Latent testMethodDescription = new MethodDescription.Latent( //
testMethod.getName() + CACHE_DOUBLE_IDENTIFIER, //
null, // not important, as this is ignored by ByteBuddy (defineMethod(.) call below).
TypeDescription.VOID, //
new ArrayList<>(), //
Modifier.PUBLIC, //
new ArrayList<>());
Test testAnnotation = testMethod.getAnnotation(Test.class);
String newClassName = baseTest.getClass().getName() + CACHE_DOUBLE_IDENTIFIER;
Class<?> testClass = new ByteBuddy() //
.subclass(Object.class) //
.name(newClassName) // class name
.defineMethod(testMethodDescription) // define our method
// intercept calls of our method and call the method in CacheDoubleTestInterceptor instead.
.intercept(MethodDelegation.to(new CacheDoubleTestInterceptor(baseTest, testMethod, newClassName))) //
// let the new method have a Test annotation - use the original annotation to preserve all annotation properties
.annotateMethod(testAnnotation) //
.make() // make class
.load(CacheDoubleTestUtil.class.getClassLoader(), ClassLoadingStrategy.Default.WRAPPER) //
.getLoaded();
try {
return testClass.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException("Cannot instantiate dynamic test class", e);
}
}
示例2: ofSetter
/**
* Returns a method handle for a getter of the given field.
*
* @param fieldDescription The field to represent.
* @return A method handle for a getter of the given field.
*/
public static MethodHandle ofSetter(FieldDescription.InDefinedShape fieldDescription) {
return new MethodHandle(HandleType.ofSetter(fieldDescription),
fieldDescription.getDeclaringType().asErasure(),
fieldDescription.getInternalName(),
TypeDescription.VOID,
Collections.singletonList(fieldDescription.getType().asErasure()));
}
示例3: testOrphanedBridge
@Test
public void testOrphanedBridge() throws Exception {
MethodDescription.SignatureToken bridgeMethod = new MethodDescription.SignatureToken("foo",
TypeDescription.VOID,
Collections.<TypeDescription>emptyList());
TypeDescription typeDescription = new InstrumentedType.Default("foo",
Opcodes.ACC_PUBLIC,
TypeDescription.Generic.OBJECT,
Collections.<TypeVariableToken>emptyList(),
Collections.<TypeDescription.Generic>emptyList(),
Collections.<FieldDescription.Token>emptyList(),
Collections.singletonList(new MethodDescription.Token("foo",
Opcodes.ACC_BRIDGE,
TypeDescription.Generic.VOID,
Collections.<TypeDescription.Generic>emptyList())),
Collections.<AnnotationDescription>emptyList(),
TypeInitializer.None.INSTANCE,
LoadedTypeInitializer.NoOp.INSTANCE,
TypeDescription.UNDEFINED,
MethodDescription.UNDEFINED,
TypeDescription.UNDEFINED,
Collections.<TypeDescription>emptyList(),
false,
false,
false);
MethodGraph.Linked methodGraph = MethodGraph.Compiler.Default.forJavaHierarchy().compile(typeDescription);
assertThat(methodGraph.listNodes().size(), is(1 + TypeDescription.OBJECT.getDeclaredMethods().filter(ElementMatchers.isVirtual()).size()));
MethodGraph.Node node = methodGraph.locate(bridgeMethod);
assertThat(node.getSort(), is(MethodGraph.Node.Sort.RESOLVED));
assertThat(node.getRepresentative().asSignatureToken(), is(bridgeMethod));
assertThat(node.getMethodTypes().size(), is(1));
assertThat(node.getMethodTypes(), hasItem(bridgeMethod.asTypeToken()));
assertThat(node.getVisibility(), is(Visibility.PACKAGE_PRIVATE));
}
示例4: getEnterType
@Override
public TypeDefinition getEnterType() {
return TypeDescription.VOID;
}