@Test @JavaVersionRule.Enforce(8) @SuppressWarnings("unchecked") public void testReceiverTypeInterception() throws Exception { Class<? extends Annotation> typeAnnotationType = (Class<? extends Annotation>) Class.forName(TYPE_VARIABLE_NAME); MethodDescription.InDefinedShape value = TypeDescription.ForLoadedType.of(typeAnnotationType).getDeclaredMethods().filter(named(VALUE)).getOnly(); Method method = createPlain() .method(named("toString")) .intercept(StubMethod.INSTANCE) .receiverType(TypeDescription.Generic.Builder.rawType(TargetType.class) .annotate(AnnotationDescription.Builder.ofType(typeAnnotationType).define(VALUE, BAZ).build()) .build()) .make() .load(typeAnnotationType.getClassLoader(), ClassLoadingStrategy.Default.WRAPPER) .getLoaded() .getDeclaredMethod("toString"); assertThat(TypeDescription.Generic.AnnotationReader.DISPATCHER.resolveReceiverType(method).getDeclaredAnnotations().size(), is(1)); assertThat(TypeDescription.Generic.AnnotationReader.DISPATCHER.resolveReceiverType(method).getDeclaredAnnotations() .ofType(typeAnnotationType).getValue(value).resolve(Integer.class), is(BAZ)); }
public DynamicType.Unloaded<T> make(TypeResolutionStrategy typeResolutionStrategy) { return make(typeResolutionStrategy, TypePool.ClassLoading.ofSystemLoader()); }
SubclassDynamicTypeBuilder extends DynamicType.Builder.AbstractBase.Adapter<T> { public DynamicType.Unloaded<T> make(TypeResolutionStrategy typeResolutionStrategy) { return make(typeResolutionStrategy, TypePool.ClassLoading.ofSystemLoader()); } }
SubclassDynamicTypeBuilder extends DynamicType.Builder.AbstractBase.Adapter<T> { public DynamicType.Unloaded<T> make(TypeResolutionStrategy typeResolutionStrategy) { return make(typeResolutionStrategy, TypePool.ClassLoading.ofSystemLoader()); } SubclassDynamicTypeBuilder(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,
                                      ConstructorStrategy constructorStrategy); protected  SubclassDynamicTypeBuilder(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,
                                         ConstructorStrategy constructorStrategy); }
SubclassDynamicTypeBuilder extends DynamicType.Builder.AbstractBase.Adapter<T> { public DynamicType.Unloaded<T> make(TypeResolutionStrategy typeResolutionStrategy) { return make(typeResolutionStrategy, TypePool.ClassLoading.ofSystemLoader()); } SubclassDynamicTypeBuilder(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,
                                      ConstructorStrategy constructorStrategy); protected  SubclassDynamicTypeBuilder(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,
                                         ConstructorStrategy constructorStrategy); DynamicType.Unloaded<T> make(TypeResolutionStrategy typeResolutionStrategy); DynamicType.Unloaded<T> make(TypeResolutionStrategy typeResolutionStrategy, TypePool typePool); }
SubclassDynamicTypeBuilder extends DynamicType.Builder.AbstractBase.Adapter<T> { public DynamicType.Unloaded<T> make(TypeResolutionStrategy typeResolutionStrategy) { return make(typeResolutionStrategy, TypePool.ClassLoading.ofSystemLoader()); } SubclassDynamicTypeBuilder(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,
                                      ConstructorStrategy constructorStrategy); protected  SubclassDynamicTypeBuilder(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,
                                         ConstructorStrategy constructorStrategy); DynamicType.Unloaded<T> make(TypeResolutionStrategy typeResolutionStrategy); DynamicType.Unloaded<T> make(TypeResolutionStrategy typeResolutionStrategy, TypePool typePool);  }