@Test public void testClassWithManyMethods() throws Exception { DynamicType.Builder<?> builder = new ByteBuddy().subclass(Object.class); for (int index = 0; index < 1000; index++) { builder = builder.defineMethod("method" + index, void.class, Visibility.PUBLIC).intercept(StubMethod.INSTANCE); } Class<?> type = builder.make().load(ClassLoadingStrategy.BOOTSTRAP_LOADER, ClassLoadingStrategy.Default.WRAPPER).getLoaded(); assertThat(type.getDeclaredMethods().length, is(1000)); DynamicType.Builder<?> subclassBuilder = new ByteBuddy().subclass(type); for (Method method : type.getDeclaredMethods()) { subclassBuilder = subclassBuilder.method(ElementMatchers.is(method)).intercept(StubMethod.INSTANCE); } Class<?> subclass = subclassBuilder.make().load(type.getClassLoader(), ClassLoadingStrategy.Default.WRAPPER).getLoaded(); assertThat(subclass.getDeclaredMethods().length, is(1000)); }
@SuppressWarnings("unchecked") public <T> DynamicType.Builder<T> subclass(Class<T> superType) { return (DynamicType.Builder<T>) subclass(TypeDescription.ForLoadedType.of(superType)); }
ByteBuddy { @SuppressWarnings("unchecked") public <T> DynamicType.Builder<T> subclass(Class<T> superType) { return (DynamicType.Builder<T>) subclass(TypeDescription.ForLoadedType.of(superType)); } }
ByteBuddy { @SuppressWarnings("unchecked") public <T> DynamicType.Builder<T> subclass(Class<T> superType) { return (DynamicType.Builder<T>) subclass(TypeDescription.ForLoadedType.of(superType)); } ByteBuddy();  ByteBuddy(ClassFileVersion classFileVersion); protected  ByteBuddy(ClassFileVersion classFileVersion,
                        NamingStrategy namingStrategy,
                        AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy,
                        AnnotationValueFilter.Factory annotationValueFilterFactory,
                        AnnotationRetention annotationRetention,
                        Implementation.Context.Factory implementationContextFactory,
                        MethodGraph.Compiler methodGraphCompiler,
                        InstrumentedType.Factory instrumentedTypeFactory,
                        TypeValidation typeValidation,
                        VisibilityBridgeStrategy visibilityBridgeStrategy,
                        ClassWriterStrategy classWriterStrategy,
                        LatentMatcher<? super MethodDescription> ignoredMethods); }
ByteBuddy { @SuppressWarnings("unchecked") public <T> DynamicType.Builder<T> subclass(Class<T> superType) { return (DynamicType.Builder<T>) subclass(TypeDescription.ForLoadedType.of(superType)); } ByteBuddy();  ByteBuddy(ClassFileVersion classFileVersion); protected  ByteBuddy(ClassFileVersion classFileVersion,
                        NamingStrategy namingStrategy,
                        AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy,
                        AnnotationValueFilter.Factory annotationValueFilterFactory,
                        AnnotationRetention annotationRetention,
                        Implementation.Context.Factory implementationContextFactory,
                        MethodGraph.Compiler methodGraphCompiler,
                        InstrumentedType.Factory instrumentedTypeFactory,
                        TypeValidation typeValidation,
                        VisibilityBridgeStrategy visibilityBridgeStrategy,
                        ClassWriterStrategy classWriterStrategy,
                        LatentMatcher<? super MethodDescription> ignoredMethods); @SuppressWarnings("unchecked") DynamicType.Builder<T> subclass(Class<T> superType); @SuppressWarnings("unchecked") DynamicType.Builder<T> subclass(Class<T> superType, ConstructorStrategy constructorStrategy); DynamicType.Builder<?> subclass(Type superType); DynamicType.Builder<?> subclass(Type superType, ConstructorStrategy constructorStrategy); DynamicType.Builder<?> subclass(TypeDefinition superType); DynamicType.Builder<?> subclass(TypeDefinition superType, ConstructorStrategy constructorStrategy); DynamicType.Builder<?> makeInterface(); @SuppressWarnings("unchecked") DynamicType.Builder<T> makeInterface(Class<T> interfaceType); DynamicType.Builder<?> makeInterface(Type... interfaceType); DynamicType.Builder<?> makeInterface(List<? extends Type> interfaceTypes); DynamicType.Builder<?> makeInterface(TypeDefinition... interfaceType); DynamicType.Builder<?> makeInterface(Collection<? extends TypeDefinition> interfaceTypes); DynamicType.Builder<?> makePackage(String name); DynamicType.Builder<?> makeRecord(); DynamicType.Builder<? extends Annotation> makeAnnotation(); DynamicType.Builder<? extends Enum<?>> makeEnumeration(String... value); DynamicType.Builder<? extends Enum<?>> makeEnumeration(Collection<? extends String> values); DynamicType.Builder<T> redefine(Class<T> type); DynamicType.Builder<T> redefine(Class<T> type, ClassFileLocator classFileLocator); DynamicType.Builder<T> redefine(TypeDescription type, ClassFileLocator classFileLocator); DynamicType.Builder<T> rebase(Class<T> type); DynamicType.Builder<T> rebase(Class<T> type, ClassFileLocator classFileLocator); DynamicType.Builder<T> rebase(Class<T> type, ClassFileLocator classFileLocator, MethodNameTransformer methodNameTransformer); DynamicType.Builder<T> rebase(TypeDescription type, ClassFileLocator classFileLocator); DynamicType.Builder<T> rebase(TypeDescription type, ClassFileLocator classFileLocator, MethodNameTransformer methodNameTransformer); DynamicType.Builder<?> rebase(Package aPackage, ClassFileLocator classFileLocator); DynamicType.Builder<?> rebase(PackageDescription aPackage, ClassFileLocator classFileLocator); DynamicType.Builder<T> decorate(Class<T> type); DynamicType.Builder<T> decorate(Class<T> type, ClassFileLocator classFileLocator); DynamicType.Builder<T> decorate(TypeDescription type, ClassFileLocator classFileLocator); ByteBuddy with(ClassFileVersion classFileVersion); ByteBuddy with(NamingStrategy namingStrategy); ByteBuddy with(AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy); ByteBuddy with(AnnotationValueFilter.Factory annotationValueFilterFactory); ByteBuddy with(AnnotationRetention annotationRetention); ByteBuddy with(Implementation.Context.Factory implementationContextFactory); ByteBuddy with(MethodGraph.Compiler methodGraphCompiler); ByteBuddy with(InstrumentedType.Factory instrumentedTypeFactory); ByteBuddy with(TypeValidation typeValidation); ByteBuddy with(VisibilityBridgeStrategy visibilityBridgeStrategy); ByteBuddy with(ClassWriterStrategy classWriterStrategy); ByteBuddy ignore(ElementMatcher<? super MethodDescription> ignoredMethods); ByteBuddy ignore(LatentMatcher<? super MethodDescription> ignoredMethods); }
ByteBuddy { @SuppressWarnings("unchecked") public <T> DynamicType.Builder<T> subclass(Class<T> superType) { return (DynamicType.Builder<T>) subclass(TypeDescription.ForLoadedType.of(superType)); } ByteBuddy();  ByteBuddy(ClassFileVersion classFileVersion); protected  ByteBuddy(ClassFileVersion classFileVersion,
                        NamingStrategy namingStrategy,
                        AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy,
                        AnnotationValueFilter.Factory annotationValueFilterFactory,
                        AnnotationRetention annotationRetention,
                        Implementation.Context.Factory implementationContextFactory,
                        MethodGraph.Compiler methodGraphCompiler,
                        InstrumentedType.Factory instrumentedTypeFactory,
                        TypeValidation typeValidation,
                        VisibilityBridgeStrategy visibilityBridgeStrategy,
                        ClassWriterStrategy classWriterStrategy,
                        LatentMatcher<? super MethodDescription> ignoredMethods); @SuppressWarnings("unchecked") DynamicType.Builder<T> subclass(Class<T> superType); @SuppressWarnings("unchecked") DynamicType.Builder<T> subclass(Class<T> superType, ConstructorStrategy constructorStrategy); DynamicType.Builder<?> subclass(Type superType); DynamicType.Builder<?> subclass(Type superType, ConstructorStrategy constructorStrategy); DynamicType.Builder<?> subclass(TypeDefinition superType); DynamicType.Builder<?> subclass(TypeDefinition superType, ConstructorStrategy constructorStrategy); DynamicType.Builder<?> makeInterface(); @SuppressWarnings("unchecked") DynamicType.Builder<T> makeInterface(Class<T> interfaceType); DynamicType.Builder<?> makeInterface(Type... interfaceType); DynamicType.Builder<?> makeInterface(List<? extends Type> interfaceTypes); DynamicType.Builder<?> makeInterface(TypeDefinition... interfaceType); DynamicType.Builder<?> makeInterface(Collection<? extends TypeDefinition> interfaceTypes); DynamicType.Builder<?> makePackage(String name); DynamicType.Builder<?> makeRecord(); DynamicType.Builder<? extends Annotation> makeAnnotation(); DynamicType.Builder<? extends Enum<?>> makeEnumeration(String... value); DynamicType.Builder<? extends Enum<?>> makeEnumeration(Collection<? extends String> values); DynamicType.Builder<T> redefine(Class<T> type); DynamicType.Builder<T> redefine(Class<T> type, ClassFileLocator classFileLocator); DynamicType.Builder<T> redefine(TypeDescription type, ClassFileLocator classFileLocator); DynamicType.Builder<T> rebase(Class<T> type); DynamicType.Builder<T> rebase(Class<T> type, ClassFileLocator classFileLocator); DynamicType.Builder<T> rebase(Class<T> type, ClassFileLocator classFileLocator, MethodNameTransformer methodNameTransformer); DynamicType.Builder<T> rebase(TypeDescription type, ClassFileLocator classFileLocator); DynamicType.Builder<T> rebase(TypeDescription type, ClassFileLocator classFileLocator, MethodNameTransformer methodNameTransformer); DynamicType.Builder<?> rebase(Package aPackage, ClassFileLocator classFileLocator); DynamicType.Builder<?> rebase(PackageDescription aPackage, ClassFileLocator classFileLocator); DynamicType.Builder<T> decorate(Class<T> type); DynamicType.Builder<T> decorate(Class<T> type, ClassFileLocator classFileLocator); DynamicType.Builder<T> decorate(TypeDescription type, ClassFileLocator classFileLocator); ByteBuddy with(ClassFileVersion classFileVersion); ByteBuddy with(NamingStrategy namingStrategy); ByteBuddy with(AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy); ByteBuddy with(AnnotationValueFilter.Factory annotationValueFilterFactory); ByteBuddy with(AnnotationRetention annotationRetention); ByteBuddy with(Implementation.Context.Factory implementationContextFactory); ByteBuddy with(MethodGraph.Compiler methodGraphCompiler); ByteBuddy with(InstrumentedType.Factory instrumentedTypeFactory); ByteBuddy with(TypeValidation typeValidation); ByteBuddy with(VisibilityBridgeStrategy visibilityBridgeStrategy); ByteBuddy with(ClassWriterStrategy classWriterStrategy); ByteBuddy ignore(ElementMatcher<? super MethodDescription> ignoredMethods); ByteBuddy ignore(LatentMatcher<? super MethodDescription> ignoredMethods);  }