Top Description Fields Constructors Methods
com.google.inject.internal.aop

pack-priv final Class EnhancerBuilderImpl

extends Object
implements EnhancerBuilder
Class Inheritance
All Implemented Interfaces
com.google.inject.internal.BytecodeGen.EnhancerBuilder
Static Imports
com.google.inject.internal.aop.ClassBuilding.signature, .ClassBuilding.visitMembers, .ClassDefining.hasPackageAccess, java.lang.reflect.Modifier.FINAL

Builder of enhancers that provide method interception via bytecode generation.
Author
[email protected] (Stuart McCulloch)

Field Summary

Modifier and TypeField and Description
private final Map<Method, Method>
private final Method[]
private static final ClassValue<Map<BitSet, Function<String, BiFunction<Object, Object[], Object>>>>
ENHANCERS

Lazy association between classes and their generated enhancers.

private final Class<?>

Constructor Summary

AccessConstructor and Description
pack-priv
EnhancerBuilderImpl(Class<?> hostClass, Collection<Method> enhanceableMethods, Map<Method, Method> bridgeDelegates)

Method Summary

Modifier and TypeMethod and Description
public Function<String, BiFunction<Object, Object[], Object>>
buildEnhancer(BitSet methodIndices)

Implements com.google.inject.internal.BytecodeGen.EnhancerBuilder.buildEnhancer.

Generates an enhancer for the selected subset of methods.
private Function<String, BiFunction<Object, Object[], Object>>
doBuildEnhancer(BitSet methodIndices)

public Method[]
getEnhanceableMethods()

Implements com.google.inject.internal.BytecodeGen.EnhancerBuilder.getEnhanceableMethods.

Lists the methods in the host class that can be enhanced.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bridgeDelegatesback to summary
private final Map<Method, Method> bridgeDelegates
enhanceableMethodsback to summary
private final Method[] enhanceableMethods
ENHANCERSback to summary
private static final ClassValue<Map<BitSet, Function<String, BiFunction<Object, Object[], Object>>>> ENHANCERS

Lazy association between classes and their generated enhancers.

hostClassback to summary
private final Class<?> hostClass

Constructor Detail

EnhancerBuilderImplback to summary
pack-priv EnhancerBuilderImpl(Class<?> hostClass, Collection<Method> enhanceableMethods, Map<Method, Method> bridgeDelegates)

Method Detail

buildEnhancerback to summary
public Function<String, BiFunction<Object, Object[], Object>> buildEnhancer(BitSet methodIndices)

Implements com.google.inject.internal.BytecodeGen.EnhancerBuilder.buildEnhancer.

Doc from com.google.inject.internal.BytecodeGen.EnhancerBuilder.buildEnhancer.

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 InvocationHandlers 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.

Annotations
@Override
doBuildEnhancerback to summary
private Function<String, BiFunction<Object, Object[], Object>> doBuildEnhancer(BitSet methodIndices)
getEnhanceableMethodsback to summary
public Method[] getEnhanceableMethods()

Implements com.google.inject.internal.BytecodeGen.EnhancerBuilder.getEnhanceableMethods.

Doc from com.google.inject.internal.BytecodeGen.EnhancerBuilder.getEnhanceableMethods.

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 finalize method can never be enhanced.

Annotations
@Override