Annotation Type Super
-
@Documented @Retention(RUNTIME) @Target(PARAMETER) public @interface SuperParameters that are annotated with this annotation are assigned an instance of an auxiliary proxy type that allows calling anysupermethods of the instrumented type where the parameter type must be a super type of the instrumented type. The proxy type will be a direct subclass of the parameter's type such as for example a specific interface.
Obviously, the proxy type must be instantiated before it is assigned to the intercepting method's parameter. For this purpose, two strategies are available which can be specified by setting thestrategy()parameter which can be assigned:Super.Instantiation.CONSTRUCTOR: A constructor call is made whereconstructorParameters()determines the constructor's signature. Any constructor parameter is assigned the parameter's default value when the constructor is called. Calling the default constructor is the preconfigured strategy.Super.Instantiation.UNSAFE: The proxy is created by making use of Java'sReflectionFactorywhich is however not a public API which is why it should be used with care. No constructor is called when this strategy is used. If this option is set, theconstructorParameters()parameter is ignored.
Foothat implements some interfaceBar, the proxy type will only implementBarand therefore extendObjectwhat allows for calling the default constructor on the proxy. This implies that an interception by some methodqux(@Super Baz baz, @Super Bar bar)would cause the creation of two super call proxies, one extendingBaz, the other extendingBar, give that both types are super types ofFoo.
As an exception, no method calls toObject.finalize()are delegated by calling this method on thesuper-call proxy by default. If this is absolutely necessary, this can however be enabled by settingignoreFinalizer()tofalse.
If a method parameter is not a super type of the instrumented type, the method with the parameter that is annotated by #Superis not considered a possible delegation target.
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.Class<?>[]constructorParametersDefines the parameter types of the constructor to be called for the createdsuper-call proxy type.java.lang.Class<? extends Super.ConstructorResolver>constructorResolverSpecifies a class to resolve a constructor of the proxied type to use for instantiation ifSuper.Instantiation.CONSTRUCTORis used.booleanignoreFinalizerIftrue, the proxy type will not implementsupercalls toObject.finalize()or any overridden methods.java.lang.Class<?>proxyTypeDetermines the type that is implemented by the proxy.booleanserializableProxyDetermines if the generated proxy should beSerializable.Super.InstantiationstrategyDetermines how thesupercall proxy type is instantiated.
-
-
-
Element Detail
-
strategy
Super.Instantiation strategy
Determines how thesupercall proxy type is instantiated.- Returns:
- The instantiation strategy for this proxy.
- Default:
- net.bytebuddy.implementation.bind.annotation.Super.Instantiation.CONSTRUCTOR
-
-
-
constructorResolver
java.lang.Class<? extends Super.ConstructorResolver> constructorResolver
Specifies a class to resolve a constructor of the proxied type to use for instantiation ifSuper.Instantiation.CONSTRUCTORis used. Note that the specified class will be loaded and instantiated by Byte Buddy in order to resolve the constructor. For this, the specified class requires a public default constructor.- Returns:
- The type of the
Super.ConstructorResolverto use.
- Default:
- net.bytebuddy.implementation.bind.annotation.Super.ConstructorResolver.Default.class
-
-
-
proxyType
java.lang.Class<?> proxyType
Determines the type that is implemented by the proxy. When this value is set to its default valuevoid, the proxy is created as an instance of the parameter's type. When it is set toTargetType, it is created as an instance of the generated class. Otherwise, the proxy type is set to the given value.- Returns:
- The type of the proxy or an indicator type, i.e.
voidorTargetType.
- Default:
- void.class
-
-