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


Java TypeDescription.ForLoadedType方法代码示例

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


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

示例1: result

import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
@Override
public final Result<StackManipulation> result() {
    final TypeDescription declaringType = field.getDeclaringType().asErasure();
    final TypeDescription fieldType = field.getType().asErasure();
    if(new NaturalJavaAtom().matches(fieldType)) {
        return new SmtInvokeMethod(
            new TypeDescription.ForLoadedType(Object.class),
            ElementMatchers.named("equals")
        );
    } else {
        return new SmtInvokeMethod(
            declaringType,
            new ConjunctionMatcher<>(
                ElementMatchers.isSynthetic(),
                ElementMatchers.named("atom$equal")
            )
        );
    }
}
 
开发者ID:project-avral,项目名称:oo-atom,代码行数:20,代码来源:SmtCompareAtomFields.java

示例2: check

import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
@Override
public final void check() throws Exception {
    final TypeDescription typeDescription = new TypeDescription.ForLoadedType(clazz);
    final DynamicType.Builder<?> subclass = new ByteBuddy().redefine(clazz);
    final DynamicType.Unloaded<?> make = bt
            .transitionResult(subclass, typeDescription)
            .value()
            .get()
            .make();
    final Class<?> newClazz = make.load(new AnonymousClassLoader()).getLoaded();
    assertThat(
        List.of(newClazz.getDeclaredMethods()).map(Method::getName)
    ).containsOnlyElementsOf(
        methodNames
    );
}
 
开发者ID:project-avral,项目名称:oo-atom,代码行数:17,代码来源:AssertClassToHaveCertainMethodsAfterBuilderTransition.java

示例3: AssertValidatorSuccessTest

import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
public AssertValidatorSuccessTest() {
    super(
        new TestCase(
            "passes when validator under test passes",
            new AssertAssertionPasses(
                new AssertValidatorSuccess(
                    new ValSuccess(),
                    new TypeDescription.ForLoadedType(Object.class)
                )
            )
        ),
        new TestCase(
            "fails when validator under test fails",
            new AssertAssertionFails(
                new AssertValidatorSuccess(
                    new ValFail(
                        "Just as planned"
                    ),
                    new TypeDescription.ForLoadedType(Object.class)
                )
            )
        )
    );
}
 
开发者ID:project-avral,项目名称:oo-atom,代码行数:25,代码来源:AssertValidatorSuccessTest.java

示例4: AssertValidatorFailureTest

import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
public AssertValidatorFailureTest() {
    super(
        new TestCase(
            "passes when validator fails",
            new AssertAssertionPasses(
                new AssertValidatorFailure(
                    new ValFail("Just as planned"),
                    new TypeDescription.ForLoadedType(Object.class),
                    "Just as planned"
                )
            )
        ),
        new TestCase(
            "fails when validator passes",
            new AssertAssertionFails(
                new AssertValidatorFailure(
                    new ValSuccess(),
                    new TypeDescription.ForLoadedType(Object.class),
                    "Expected failure"
                )
            )
        )
    );
}
 
开发者ID:project-avral,项目名称:oo-atom,代码行数:25,代码来源:AssertValidatorFailureTest.java

示例5: SmtBoxTest

import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
public SmtBoxTest() {
    super(
        new TestCase(
            "attempt to box non-primitive must fail",
            new AssertResultIsErroneous(
                new SmtBox(
                    new TypeDescription.ForLoadedType(Object.class)
                ),
                "Attempt to box non-primitive type java.lang.Object"
            )
        ),
        new TestCase(
            "can box integer primitive", 
            new AssertTokenToRepresentExpectedStackManipulation(
                new SmtBox(
                    new TypeDescription.ForLoadedType(int.class)
                ),
                () -> MethodInvocation.invoke(new MethodDescription.ForLoadedMethod(INT_VALUEOF))
            )
        )
    );
}
 
开发者ID:project-avral,项目名称:oo-atom,代码行数:23,代码来源:SmtBoxTest.java

示例6: ExtendingTest

import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
public ExtendingTest() {
    super(
        new TestCase(
            "matches types inherited from atom", 
            new AssertThatTypeMatches(
                new TypeDescription.ForLoadedType(
                    Bar.class
                ), 
                new Extending(
                    ElementMatchers.anyOf(Foo.class)
                )
            )
        ),
        new TestCase(
            "mismatch atoms",
            new AssertThatTypeDoesNotMatch(
                new TypeDescription.ForLoadedType(
                    Foo.class
                ), 
                new Extending(
                    ElementMatchers.anyOf(Foo.class)
                )
            )
        )
    );
}
 
开发者ID:project-avral,项目名称:oo-atom,代码行数:27,代码来源:ExtendingTest.java

示例7: IsNotAbstractTest

import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
public IsNotAbstractTest() {
    super(
        new TestCase(
            "match non-abstract classes",
            new AssertThatTypeMatches(
                new TypeDescription.ForLoadedType(Foo.class),
                new IsNotAbstract()
            )
        ),
        new TestCase(
            "mismatch abstract classes",
            new AssertThatTypeDoesNotMatch(
                new TypeDescription.ForLoadedType(Bar.class),
                new IsNotAbstract()
            )
        ),
        new TestCase(
            "match enumeration types",
            new AssertThatTypeMatches(
                new TypeDescription.ForLoadedType(Faz.class),
                new IsNotAbstract()
            )
        )
    );
}
 
开发者ID:project-avral,项目名称:oo-atom,代码行数:26,代码来源:IsNotAbstractTest.java

示例8: NoMethodsTest

import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
public NoMethodsTest() {
    super(
        new TestCase(
            "match type with no methods",
            new AssertThatTypeMatches(
                new TypeDescription.ForLoadedType(Foo.class),
                new NoMethods()
            )
        ),
        new TestCase(
            "mismatch type with at least one method",
            new AssertThatTypeDoesNotMatch(
                new TypeDescription.ForLoadedType(Bar.class),
                new NoMethods()
            )
        ),
        new TestCase(
            "match type ignoring methods declared in base class",
            new AssertThatTypeMatches(
                new TypeDescription.ForLoadedType(Barr.class),
                new NoMethods()
            )
        )
    );
}
 
开发者ID:project-avral,项目名称:oo-atom,代码行数:26,代码来源:NoMethodsTest.java

示例9: NoFieldsTest

import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
public NoFieldsTest() {
    super(
        new TestCase(
            "match type with no fields",
            new AssertThatTypeMatches(
                new TypeDescription.ForLoadedType(Foo.class),
                new NoFields()
            )
        ),
        new TestCase(
            "mismatch type with at least one field",
            new AssertThatTypeDoesNotMatch(
                new TypeDescription.ForLoadedType(Bar.class),
                new NoFields()
            )
        ),
        new TestCase(
            "match type ignoring fields from the base class",
            new AssertThatTypeMatches(
                new TypeDescription.ForLoadedType(Barr.class),
                new NoFields()
            )
        )
    );
}
 
开发者ID:project-avral,项目名称:oo-atom,代码行数:26,代码来源:NoFieldsTest.java

示例10: toClass

import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static <T> Class<T> toClass(TypeDescription type)
{
    if ((type instanceof TypeDescription.ForLoadedType) && (typeHandle != null))
    {
        try
        {
            return (Class<T>) typeHandle.invoke(type);
        }
        catch (Throwable throwable)
        {
            throwable.printStackTrace();
        }
    }
    ClassLoader classLoader = StackWalker.getInstance().getCallerClass().getClassLoader();
    try
    {
        return (Class<T>) Class.forName(type.getActualName(), false, classLoader);
    }
    catch (ClassNotFoundException e)
    {
        throw new RuntimeException(e);
    }
}
 
开发者ID:Diorite,项目名称:Diorite,代码行数:25,代码来源:AsmUtils.java

示例11: testGenericClassMultipleEvolution

import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
@Test
public void testGenericClassMultipleEvolution() throws Exception {
    TypeDescription typeDescription = new TypeDescription.ForLoadedType(GenericClassBase.Intermediate.Inner.class);
    MethodGraph.Linked methodGraph = MethodGraph.Compiler.Default.forJavaHierarchy().compile(typeDescription);
    assertThat(methodGraph.listNodes().size(), is(TypeDescription.OBJECT.getDeclaredMethods().filter(isVirtual()).size() + 1));
    MethodDescription.SignatureToken token = typeDescription.getDeclaredMethods().filter(isMethod().and(ElementMatchers.not(isBridge()))).getOnly().asSignatureToken();
    MethodGraph.Node node = methodGraph.locate(token);
    MethodDescription.SignatureToken firstBridgeToken = typeDescription.getSuperClass().getDeclaredMethods()
            .filter(isMethod().and(ElementMatchers.not(isBridge()))).getOnly().asDefined().asSignatureToken();
    MethodDescription.SignatureToken secondBridgeToken = typeDescription.getSuperClass().getSuperClass().getDeclaredMethods()
            .filter(isMethod()).getOnly().asDefined().asSignatureToken();
    assertThat(node, is(methodGraph.locate(firstBridgeToken)));
    assertThat(node, is(methodGraph.locate(secondBridgeToken)));
    assertThat(node.getSort(), is(MethodGraph.Node.Sort.RESOLVED));
    assertThat(node.getMethodTypes().size(), is(3));
    assertThat(node.getMethodTypes().contains(token.asTypeToken()), is(true));
    assertThat(node.getMethodTypes().contains(firstBridgeToken.asTypeToken()), is(true));
    assertThat(node.getMethodTypes().contains(secondBridgeToken.asTypeToken()), is(true));
    assertThat(node.getVisibility(), is(Visibility.PUBLIC));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:21,代码来源:MethodGraphCompilerDefaultTest.java

示例12: testReturnTypeInterfaceMultipleEvolution

import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
@Test
public void testReturnTypeInterfaceMultipleEvolution() throws Exception {
    TypeDescription typeDescription = new TypeDescription.ForLoadedType(ReturnTypeInterfaceBase.Intermediate.Inner.class);
    MethodGraph.Linked methodGraph = MethodGraph.Compiler.Default.forJavaHierarchy().compile(typeDescription);
    assertThat(methodGraph.listNodes().size(), is(1));
    MethodDescription.SignatureToken token = typeDescription.getDeclaredMethods().filter(ElementMatchers.not(isBridge())).getOnly().asSignatureToken();
    MethodGraph.Node node = methodGraph.locate(token);
    MethodDescription.SignatureToken firstBridgeToken = typeDescription.getInterfaces().getOnly()
            .getDeclaredMethods().filter(ElementMatchers.not(isBridge())).getOnly().asSignatureToken();
    MethodDescription.SignatureToken secondBridgeToken = typeDescription.getInterfaces().getOnly().getInterfaces().getOnly()
            .getDeclaredMethods().getOnly().asSignatureToken();
    assertThat(node, is(methodGraph.locate(firstBridgeToken)));
    assertThat(node.getSort(), is(MethodGraph.Node.Sort.RESOLVED));
    assertThat(node.getMethodTypes().size(), is(3));
    assertThat(node.getMethodTypes().contains(token.asTypeToken()), is(true));
    assertThat(node.getMethodTypes().contains(firstBridgeToken.asTypeToken()), is(true));
    assertThat(node.getMethodTypes().contains(secondBridgeToken.asTypeToken()), is(true));
    assertThat(node.getVisibility(), is(Visibility.PUBLIC));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:20,代码来源:MethodGraphCompilerDefaultTest.java

示例13: testGenericInterfaceMultipleEvolution

import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
@Test
public void testGenericInterfaceMultipleEvolution() throws Exception {
    TypeDescription typeDescription = new TypeDescription.ForLoadedType(GenericInterfaceBase.Intermediate.Inner.class);
    MethodGraph.Linked methodGraph = MethodGraph.Compiler.Default.forJavaHierarchy().compile(typeDescription);
    assertThat(methodGraph.listNodes().size(), is(1));
    MethodDescription.SignatureToken token = typeDescription.getDeclaredMethods().filter(ElementMatchers.not(isBridge())).getOnly().asSignatureToken();
    MethodGraph.Node node = methodGraph.locate(token);
    MethodDescription.SignatureToken firstBridgeToken = typeDescription.getInterfaces().getOnly()
            .getDeclaredMethods().filter(ElementMatchers.not(isBridge())).getOnly().asDefined().asSignatureToken();
    MethodDescription.SignatureToken secondBridgeToken = typeDescription.getInterfaces().getOnly().getInterfaces().getOnly()
            .getDeclaredMethods().getOnly().asDefined().asSignatureToken();
    assertThat(node, is(methodGraph.locate(firstBridgeToken)));
    assertThat(node, is(methodGraph.locate(secondBridgeToken)));
    assertThat(node.getSort(), is(MethodGraph.Node.Sort.RESOLVED));
    assertThat(node.getMethodTypes().size(), is(3));
    assertThat(node.getMethodTypes().contains(token.asTypeToken()), is(true));
    assertThat(node.getMethodTypes().contains(firstBridgeToken.asTypeToken()), is(true));
    assertThat(node.getMethodTypes().contains(secondBridgeToken.asTypeToken()), is(true));
    assertThat(node.getVisibility(), is(Visibility.PUBLIC));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:21,代码来源:MethodGraphCompilerDefaultTest.java

示例14: testBootstrapWithThisValue

import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
@Test
@JavaVersionRule.Enforce(7)
public void testBootstrapWithThisValue() throws Exception {
    TypeDescription typeDescription = new TypeDescription.ForLoadedType(Class.forName(ARGUMENT_BOOTSTRAP));
    DynamicType.Loaded<Simple> dynamicType = new ByteBuddy()
            .subclass(Simple.class)
            .method(isDeclaredBy(Simple.class))
            .intercept(InvokeDynamic.bootstrap(typeDescription.getDeclaredMethods().filter(named(BOOTSTRAP)).getOnly())
                    .invoke(BAZ, String.class)
                    .withThis(Object.class))
            .make()
            .load(getClass().getClassLoader(), ClassLoadingStrategy.Default.WRAPPER);
    assertThat(dynamicType.getLoaded().getDeclaredFields().length, is(0));
    Simple simple = dynamicType.getLoaded().getDeclaredConstructor().newInstance();
    assertThat(simple.foo(), is(simple.toString()));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:17,代码来源:InvokeDynamicTest.java

示例15: testDuplicateNameGenericClass

import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
@Test
public void testDuplicateNameGenericClass() throws Exception {
    TypeDescription typeDescription = new TypeDescription.ForLoadedType(DuplicateNameGenericClass.class);
    MethodGraph.Linked methodGraph = MethodGraph.Compiler.Default.forJavaHierarchy().compile(typeDescription);
    assertThat(methodGraph.listNodes().size(), is(TypeDescription.OBJECT.getDeclaredMethods().filter(isVirtual()).size() + 2));
    MethodDescription objectMethod = typeDescription.getDeclaredMethods().filter(takesArguments(Object.class)).getOnly();
    MethodGraph.Node objectNode = methodGraph.locate(objectMethod.asSignatureToken());
    assertThat(objectNode.getSort(), is(MethodGraph.Node.Sort.RESOLVED));
    assertThat(objectNode.getRepresentative(), is(objectMethod));
    assertThat(objectNode.getMethodTypes().size(), is(1));
    assertThat(objectNode.getMethodTypes().contains(objectMethod.asTypeToken()), is(true));
    assertThat(objectNode.getVisibility(), is(objectMethod.getVisibility()));
    MethodDescription voidMethod = typeDescription.getDeclaredMethods().filter(takesArguments(Integer.class)).getOnly();
    MethodGraph.Node voidNode = methodGraph.locate(voidMethod.asSignatureToken());
    assertThat(voidNode.getSort(), is(MethodGraph.Node.Sort.RESOLVED));
    assertThat(voidNode.getRepresentative(), is(voidMethod));
    assertThat(voidNode.getMethodTypes().size(), is(1));
    assertThat(voidNode.getMethodTypes().contains(voidMethod.asTypeToken()), is(true));
    assertThat(voidNode.getVisibility(), is(voidMethod.getVisibility()));
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:21,代码来源:MethodGraphCompilerDefaultTest.java


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