final class EnhancerBuilderImpl extends java.lang.Object implements BytecodeGen.EnhancerBuilder
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.reflect.Method,java.lang.reflect.Method> |
bridgeDelegates |
private java.lang.reflect.Method[] |
enhanceableMethods |
private static java.lang.ClassValue<java.util.Map<java.util.BitSet,java.util.function.Function<java.lang.String,java.util.function.BiFunction<java.lang.Object,java.lang.Object[],java.lang.Object>>>> |
ENHANCERS
Lazy association between classes and their generated enhancers.
|
private java.lang.Class<?> |
hostClass |
Constructor and Description |
---|
EnhancerBuilderImpl(java.lang.Class<?> hostClass,
java.util.Collection<java.lang.reflect.Method> enhanceableMethods,
java.util.Map<java.lang.reflect.Method,java.lang.reflect.Method> bridgeDelegates) |
Modifier and Type | Method and Description |
---|---|
java.util.function.Function<java.lang.String,java.util.function.BiFunction<java.lang.Object,java.lang.Object[],java.lang.Object>> |
buildEnhancer(java.util.BitSet methodIndices)
Generates an enhancer for the selected subset of methods.
|
private java.util.function.Function<java.lang.String,java.util.function.BiFunction<java.lang.Object,java.lang.Object[],java.lang.Object>> |
doBuildEnhancer(java.util.BitSet methodIndices) |
java.lang.reflect.Method[] |
getEnhanceableMethods()
Lists the methods in the host class that can be enhanced.
|
private static final java.lang.ClassValue<java.util.Map<java.util.BitSet,java.util.function.Function<java.lang.String,java.util.function.BiFunction<java.lang.Object,java.lang.Object[],java.lang.Object>>>> ENHANCERS
private final java.lang.Class<?> hostClass
private final java.lang.reflect.Method[] enhanceableMethods
private final java.util.Map<java.lang.reflect.Method,java.lang.reflect.Method> bridgeDelegates
EnhancerBuilderImpl(java.lang.Class<?> hostClass, java.util.Collection<java.lang.reflect.Method> enhanceableMethods, java.util.Map<java.lang.reflect.Method,java.lang.reflect.Method> bridgeDelegates)
public java.lang.reflect.Method[] getEnhanceableMethods()
BytecodeGen.EnhancerBuilder
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.
getEnhanceableMethods
in interface BytecodeGen.EnhancerBuilder
public java.util.function.Function<java.lang.String,java.util.function.BiFunction<java.lang.Object,java.lang.Object[],java.lang.Object>> buildEnhancer(java.util.BitSet methodIndices)
BytecodeGen.EnhancerBuilder
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.
buildEnhancer
in interface BytecodeGen.EnhancerBuilder
private java.util.function.Function<java.lang.String,java.util.function.BiFunction<java.lang.Object,java.lang.Object[],java.lang.Object>> doBuildEnhancer(java.util.BitSet methodIndices)