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


Java TypeDescription.VOID属性代码示例

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

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

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

示例4: getEnterType

@Override
public TypeDefinition getEnterType() {
    return TypeDescription.VOID;
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:4,代码来源:Advice.java


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