Class EnhancerBuilderImpl
- All Implemented Interfaces:
BytecodeGen.EnhancerBuilder
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionEnhancerBuilderImpl
(Class<?> hostClass, Collection<Method> enhanceableMethods, Map<Method, Method> bridgeDelegates) -
Method Summary
Modifier and TypeMethodDescriptionbuildEnhancer
(BitSet methodIndices) Generates an enhancer for the selected subset of methods.doBuildEnhancer
(BitSet methodIndices) Method[]
Lists the methods in the host class that can be enhanced.
-
Field Details
-
ENHANCERS
private static final ClassValue<Map<BitSet,Function<String, ENHANCERSBiFunction<Object, Object[], Object>>>> Lazy association between classes and their generated enhancers. -
hostClass
-
enhanceableMethods
-
bridgeDelegates
-
-
Constructor Details
-
EnhancerBuilderImpl
-
-
Method Details
-
getEnhanceableMethods
Description copied from interface:BytecodeGen.EnhancerBuilder
Lists the methods in the host class that can be enhanced.This always includes public and protected methods that are neither static nor final.
Package-private methods can only be enhanced if they're in the same package as the host and we can define types in the same class loader with Unsafe. The
Object.finalize()
method can never be enhanced.- Specified by:
getEnhanceableMethods
in interfaceBytecodeGen.EnhancerBuilder
-
buildEnhancer
Description copied from interface:BytecodeGen.EnhancerBuilder
Generates an enhancer for the selected subset of methods.The enhancer maps constructor and method signatures to invokers, where each invoker is represented as a
BiFunction
that accepts a context object and an argument array.Constructor invokers take an array of
InvocationHandler
s as their context object. This is stored in the enhanced class before the original host class constructor is called, with arguments unpacked from the argument array. The enhanced instance is then returned.Method invokers take an enhanced instance as their context object and call the original super-method with arguments unpacked from the argument array, ie. provides super-invocation.
- Specified by:
buildEnhancer
in interfaceBytecodeGen.EnhancerBuilder
-
doBuildEnhancer
-