Java Code Examples for net.bytebuddy.description.method.MethodDescription#UNDEFINED

The following examples show how to use net.bytebuddy.description.method.MethodDescription#UNDEFINED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InstrumentedType.java    From byte-buddy with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
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.<RecordComponentDescription.Token>emptyList(),
            Collections.<AnnotationDescription>emptyList(),
            TypeInitializer.None.INSTANCE,
            LoadedTypeInitializer.NoOp.INSTANCE,
            TypeDescription.UNDEFINED,
            MethodDescription.UNDEFINED,
            TypeDescription.UNDEFINED,
            Collections.<TypeDescription>emptyList(),
            false,
            false,
            false,
            TargetType.DESCRIPTION,
            Collections.<TypeDescription>emptyList());
}
 
Example 2
Source File: InstrumentedType.java    From byte-buddy with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public WithFlexibleName withEnclosingType(TypeDescription enclosingType) {
    return new Default(name,
            modifiers,
            superClass,
            typeVariables,
            interfaceTypes,
            fieldTokens,
            methodTokens,
            recordComponentTokens,
            annotationDescriptions,
            typeInitializer,
            loadedTypeInitializer,
            declaringType,
            MethodDescription.UNDEFINED,
            enclosingType,
            declaredTypes,
            anonymousClass,
            localClass,
            record,
            nestHost,
            nestMembers);
}
 
Example 3
Source File: InstrumentedTypeDefaultTest.java    From byte-buddy with Apache License 2.0 6 votes vote down vote up
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.<RecordComponentDescription.Token>emptyList(),
            Collections.<AnnotationDescription>emptyList(),
            TypeInitializer.None.INSTANCE,
            LoadedTypeInitializer.NoOp.INSTANCE,
            TypeDescription.UNDEFINED,
            MethodDescription.UNDEFINED,
            TypeDescription.UNDEFINED,
            Collections.<TypeDescription>emptyList(),
            false,
            false,
            false,
            TargetType.DESCRIPTION,
            Collections.<TypeDescription>emptyList());
}
 
Example 4
Source File: InstrumentedTypeDefaultTest.java    From byte-buddy with Apache License 2.0 5 votes vote down vote up
@Test
public void testTypeVariableOutOfScopeIsErased() throws Exception {
    TypeDescription typeDescription = new InstrumentedType.Default("foo",
            Opcodes.ACC_PUBLIC,
            TypeDescription.Generic.OfNonGenericType.ForLoadedType.of(AbstractOuter.ExtendedInner.class),
            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.<RecordComponentDescription.Token>emptyList(),
            Collections.<AnnotationDescription>emptyList(),
            TypeInitializer.None.INSTANCE,
            LoadedTypeInitializer.NoOp.INSTANCE,
            TypeDescription.UNDEFINED,
            MethodDescription.UNDEFINED,
            TypeDescription.UNDEFINED,
            Collections.<TypeDescription>emptyList(),
            false,
            false,
            false,
            TargetType.DESCRIPTION,
            Collections.<TypeDescription>emptyList());
    MethodDescription methodDescription = typeDescription.getSuperClass().getSuperClass().getDeclaredMethods().filter(named(FOO)).getOnly();
    assertThat(methodDescription.getReturnType(), is(TypeDescription.Generic.OBJECT));
}
 
Example 5
Source File: MethodGraphCompilerDefaultTest.java    From byte-buddy with Apache License 2.0 5 votes vote down vote up
@Test
public void testVisibilityExtension() throws Exception {
    TypeDescription typeDescription = new InstrumentedType.Default("foo",
            Opcodes.ACC_PUBLIC,
            TypeDescription.Generic.OfNonGenericType.ForLoadedType.of(VisibilityExtension.Base.class),
            Collections.<TypeVariableToken>emptyList(),
            Collections.<TypeDescription.Generic>singletonList(TypeDescription.Generic.OfNonGenericType.ForLoadedType.of(VisibilityExtension.class)),
            Collections.<FieldDescription.Token>emptyList(),
            Collections.<MethodDescription.Token>emptyList(),
            Collections.<RecordComponentDescription.Token>emptyList(),
            Collections.<AnnotationDescription>emptyList(),
            TypeInitializer.None.INSTANCE,
            LoadedTypeInitializer.NoOp.INSTANCE,
            TypeDescription.UNDEFINED,
            MethodDescription.UNDEFINED,
            TypeDescription.UNDEFINED,
            Collections.<TypeDescription>emptyList(),
            false,
            false,
            false,
            TargetType.DESCRIPTION,
            Collections.<TypeDescription>emptyList());
    MethodDescription.SignatureToken signatureToken = new MethodDescription.SignatureToken("foo",
            TypeDescription.ForLoadedType.of(void.class),
            Collections.<TypeDescription>emptyList());
    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(signatureToken);
    assertThat(node.getSort(), is(MethodGraph.Node.Sort.RESOLVED));
    assertThat(node.getRepresentative().asSignatureToken(), is(signatureToken));
    assertThat(node.getMethodTypes().size(), is(1));
    assertThat(node.getMethodTypes(), hasItem(signatureToken.asTypeToken()));
    assertThat(node.getVisibility(), is(Visibility.PUBLIC));
}
 
Example 6
Source File: MethodGraphCompilerDefaultTest.java    From byte-buddy with Apache License 2.0 5 votes vote down vote up
@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.<RecordComponentDescription.Token>emptyList(),
            Collections.<AnnotationDescription>emptyList(),
            TypeInitializer.None.INSTANCE,
            LoadedTypeInitializer.NoOp.INSTANCE,
            TypeDescription.UNDEFINED,
            MethodDescription.UNDEFINED,
            TypeDescription.UNDEFINED,
            Collections.<TypeDescription>emptyList(),
            false,
            false,
            false,
            TargetType.DESCRIPTION,
            Collections.<TypeDescription>emptyList());
    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));
}