@Test public void testConstructorRetentionNoAuxiliaryType() throws Exception { DynamicType.Unloaded<?> dynamicType = new ByteBuddy() .redefine(Bar.class) .make(); assertThat(dynamicType.getAuxiliaryTypes().size(), is(0)); Class<?> type = dynamicType.load(new URLClassLoader(new URL[0], null), ClassLoadingStrategy.Default.WRAPPER).getLoaded(); assertThat(type.getDeclaredConstructors().length, is(1)); assertThat(type.getDeclaredMethods().length, is(0)); Field field = type.getDeclaredField(BAR); assertThat(field.get(type.getDeclaredConstructor(String.class).newInstance(FOO)), is((Object) FOO)); }
public DynamicType.Unloaded<T> make(TypeResolutionStrategy typeResolutionStrategy, TypePool typePool) { MethodRegistry.Prepared methodRegistry = this.methodRegistry.prepare(instrumentedType, methodGraphCompiler, typeValidation, visibilityBridgeStrategy, InliningImplementationMatcher.of(ignoredMethods, originalType)); return TypeWriter.Default.<T>forRedefinition(methodRegistry, auxiliaryTypes, fieldRegistry.compile(methodRegistry.getInstrumentedType()), recordComponentRegistry.compile(methodRegistry.getInstrumentedType()), typeAttributeAppender, asmVisitorWrapper, classFileVersion, annotationValueFilterFactory, annotationRetention, auxiliaryTypeNamingStrategy, implementationContextFactory, typeValidation, classWriterStrategy, typePool, originalType, classFileLocator).make(typeResolutionStrategy.resolve()); }
RedefinitionDynamicTypeBuilder extends AbstractInliningDynamicTypeBuilder<T> { public DynamicType.Unloaded<T> make(TypeResolutionStrategy typeResolutionStrategy, TypePool typePool) { MethodRegistry.Prepared methodRegistry = this.methodRegistry.prepare(instrumentedType, methodGraphCompiler, typeValidation, visibilityBridgeStrategy, InliningImplementationMatcher.of(ignoredMethods, originalType)); return TypeWriter.Default.<T>forRedefinition(methodRegistry, auxiliaryTypes, fieldRegistry.compile(methodRegistry.getInstrumentedType()), recordComponentRegistry.compile(methodRegistry.getInstrumentedType()), typeAttributeAppender, asmVisitorWrapper, classFileVersion, annotationValueFilterFactory, annotationRetention, auxiliaryTypeNamingStrategy, implementationContextFactory, typeValidation, classWriterStrategy, typePool, originalType, classFileLocator).make(typeResolutionStrategy.resolve()); } }
RedefinitionDynamicTypeBuilder extends AbstractInliningDynamicTypeBuilder<T> { public DynamicType.Unloaded<T> make(TypeResolutionStrategy typeResolutionStrategy, TypePool typePool) { MethodRegistry.Prepared methodRegistry = this.methodRegistry.prepare(instrumentedType, methodGraphCompiler, typeValidation, visibilityBridgeStrategy, InliningImplementationMatcher.of(ignoredMethods, originalType)); return TypeWriter.Default.<T>forRedefinition(methodRegistry, auxiliaryTypes, fieldRegistry.compile(methodRegistry.getInstrumentedType()), recordComponentRegistry.compile(methodRegistry.getInstrumentedType()), typeAttributeAppender, asmVisitorWrapper, classFileVersion, annotationValueFilterFactory, annotationRetention, auxiliaryTypeNamingStrategy, implementationContextFactory, typeValidation, classWriterStrategy, typePool, originalType, classFileLocator).make(typeResolutionStrategy.resolve()); } RedefinitionDynamicTypeBuilder(InstrumentedType.WithFlexibleName instrumentedType,
                                          ClassFileVersion classFileVersion,
                                          AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy,
                                          AnnotationValueFilter.Factory annotationValueFilterFactory,
                                          AnnotationRetention annotationRetention,
                                          Implementation.Context.Factory implementationContextFactory,
                                          MethodGraph.Compiler methodGraphCompiler,
                                          TypeValidation typeValidation,
                                          VisibilityBridgeStrategy visibilityBridgeStrategy,
                                          ClassWriterStrategy classWriterStrategy,
                                          LatentMatcher<? super MethodDescription> ignoredMethods,
                                          TypeDescription originalType,
                                          ClassFileLocator classFileLocator); protected  RedefinitionDynamicTypeBuilder(InstrumentedType.WithFlexibleName instrumentedType,
                                             FieldRegistry fieldRegistry,
                                             MethodRegistry methodRegistry,
                                             RecordComponentRegistry recordComponentRegistry,
                                             TypeAttributeAppender typeAttributeAppender,
                                             AsmVisitorWrapper asmVisitorWrapper,
                                             ClassFileVersion classFileVersion,
                                             AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy,
                                             AnnotationValueFilter.Factory annotationValueFilterFactory,
                                             AnnotationRetention annotationRetention,
                                             Implementation.Context.Factory implementationContextFactory,
                                             MethodGraph.Compiler methodGraphCompiler,
                                             TypeValidation typeValidation,
                                             VisibilityBridgeStrategy visibilityBridgeStrategy,
                                             ClassWriterStrategy classWriterStrategy,
                                             LatentMatcher<? super MethodDescription> ignoredMethods,
                                             List<? extends DynamicType> auxiliaryTypes,
                                             TypeDescription originalType,
                                             ClassFileLocator classFileLocator); }
RedefinitionDynamicTypeBuilder extends AbstractInliningDynamicTypeBuilder<T> { public DynamicType.Unloaded<T> make(TypeResolutionStrategy typeResolutionStrategy, TypePool typePool) { MethodRegistry.Prepared methodRegistry = this.methodRegistry.prepare(instrumentedType, methodGraphCompiler, typeValidation, visibilityBridgeStrategy, InliningImplementationMatcher.of(ignoredMethods, originalType)); return TypeWriter.Default.<T>forRedefinition(methodRegistry, auxiliaryTypes, fieldRegistry.compile(methodRegistry.getInstrumentedType()), recordComponentRegistry.compile(methodRegistry.getInstrumentedType()), typeAttributeAppender, asmVisitorWrapper, classFileVersion, annotationValueFilterFactory, annotationRetention, auxiliaryTypeNamingStrategy, implementationContextFactory, typeValidation, classWriterStrategy, typePool, originalType, classFileLocator).make(typeResolutionStrategy.resolve()); } RedefinitionDynamicTypeBuilder(InstrumentedType.WithFlexibleName instrumentedType,
                                          ClassFileVersion classFileVersion,
                                          AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy,
                                          AnnotationValueFilter.Factory annotationValueFilterFactory,
                                          AnnotationRetention annotationRetention,
                                          Implementation.Context.Factory implementationContextFactory,
                                          MethodGraph.Compiler methodGraphCompiler,
                                          TypeValidation typeValidation,
                                          VisibilityBridgeStrategy visibilityBridgeStrategy,
                                          ClassWriterStrategy classWriterStrategy,
                                          LatentMatcher<? super MethodDescription> ignoredMethods,
                                          TypeDescription originalType,
                                          ClassFileLocator classFileLocator); protected  RedefinitionDynamicTypeBuilder(InstrumentedType.WithFlexibleName instrumentedType,
                                             FieldRegistry fieldRegistry,
                                             MethodRegistry methodRegistry,
                                             RecordComponentRegistry recordComponentRegistry,
                                             TypeAttributeAppender typeAttributeAppender,
                                             AsmVisitorWrapper asmVisitorWrapper,
                                             ClassFileVersion classFileVersion,
                                             AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy,
                                             AnnotationValueFilter.Factory annotationValueFilterFactory,
                                             AnnotationRetention annotationRetention,
                                             Implementation.Context.Factory implementationContextFactory,
                                             MethodGraph.Compiler methodGraphCompiler,
                                             TypeValidation typeValidation,
                                             VisibilityBridgeStrategy visibilityBridgeStrategy,
                                             ClassWriterStrategy classWriterStrategy,
                                             LatentMatcher<? super MethodDescription> ignoredMethods,
                                             List<? extends DynamicType> auxiliaryTypes,
                                             TypeDescription originalType,
                                             ClassFileLocator classFileLocator); DynamicType.Unloaded<T> make(TypeResolutionStrategy typeResolutionStrategy, TypePool typePool); }
RedefinitionDynamicTypeBuilder extends AbstractInliningDynamicTypeBuilder<T> { public DynamicType.Unloaded<T> make(TypeResolutionStrategy typeResolutionStrategy, TypePool typePool) { MethodRegistry.Prepared methodRegistry = this.methodRegistry.prepare(instrumentedType, methodGraphCompiler, typeValidation, visibilityBridgeStrategy, InliningImplementationMatcher.of(ignoredMethods, originalType)); return TypeWriter.Default.<T>forRedefinition(methodRegistry, auxiliaryTypes, fieldRegistry.compile(methodRegistry.getInstrumentedType()), recordComponentRegistry.compile(methodRegistry.getInstrumentedType()), typeAttributeAppender, asmVisitorWrapper, classFileVersion, annotationValueFilterFactory, annotationRetention, auxiliaryTypeNamingStrategy, implementationContextFactory, typeValidation, classWriterStrategy, typePool, originalType, classFileLocator).make(typeResolutionStrategy.resolve()); } RedefinitionDynamicTypeBuilder(InstrumentedType.WithFlexibleName instrumentedType,
                                          ClassFileVersion classFileVersion,
                                          AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy,
                                          AnnotationValueFilter.Factory annotationValueFilterFactory,
                                          AnnotationRetention annotationRetention,
                                          Implementation.Context.Factory implementationContextFactory,
                                          MethodGraph.Compiler methodGraphCompiler,
                                          TypeValidation typeValidation,
                                          VisibilityBridgeStrategy visibilityBridgeStrategy,
                                          ClassWriterStrategy classWriterStrategy,
                                          LatentMatcher<? super MethodDescription> ignoredMethods,
                                          TypeDescription originalType,
                                          ClassFileLocator classFileLocator); protected  RedefinitionDynamicTypeBuilder(InstrumentedType.WithFlexibleName instrumentedType,
                                             FieldRegistry fieldRegistry,
                                             MethodRegistry methodRegistry,
                                             RecordComponentRegistry recordComponentRegistry,
                                             TypeAttributeAppender typeAttributeAppender,
                                             AsmVisitorWrapper asmVisitorWrapper,
                                             ClassFileVersion classFileVersion,
                                             AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy,
                                             AnnotationValueFilter.Factory annotationValueFilterFactory,
                                             AnnotationRetention annotationRetention,
                                             Implementation.Context.Factory implementationContextFactory,
                                             MethodGraph.Compiler methodGraphCompiler,
                                             TypeValidation typeValidation,
                                             VisibilityBridgeStrategy visibilityBridgeStrategy,
                                             ClassWriterStrategy classWriterStrategy,
                                             LatentMatcher<? super MethodDescription> ignoredMethods,
                                             List<? extends DynamicType> auxiliaryTypes,
                                             TypeDescription originalType,
                                             ClassFileLocator classFileLocator); DynamicType.Unloaded<T> make(TypeResolutionStrategy typeResolutionStrategy, TypePool typePool);  }