T
- The interface that the generated class will implement.public class ClassGenerator<T>
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private int |
aloadIndexParameter |
private Bootstrap |
bootstrap |
private java.lang.String |
className |
private java.lang.String |
classSignature |
private boolean |
hasBridge |
private java.lang.String |
interfaceClass |
private java.lang.String |
interfaceMethodName |
private boolean |
interfaceOptimized |
private java.lang.invoke.MethodType |
interfaceSignatureBridge |
private boolean[] |
isArray |
private int |
lengthAloadBridge |
private java.lang.invoke.MethodType |
methodTypeMethod |
private java.lang.invoke.MethodType |
methodTypeSignature |
Constructor and Description |
---|
ClassGenerator(Bootstrap bootstrap,
java.lang.String classSignature,
java.lang.String interfaceClass,
java.lang.String interfaceMethodName,
java.lang.invoke.MethodType methodTypeSignature,
java.lang.invoke.MethodType methodTypeMethod,
boolean interfaceOptimized,
boolean hasBridge,
java.lang.invoke.MethodType interfaceSignatureBridge,
int lengthAloadBridge,
boolean[] isArray,
int aloadIndexParameter)
Constructor of the class that receives all the arguments to dynamically create the class to perform the dynamic invocation.
|
Modifier and Type | Method and Description |
---|---|
private byte[] |
generateClass()
Defines the class that performs the dynamic invocation.
|
T |
getInstance()
Returns an instance of the generated class.
|
private void |
methodInvoke(org.objectweb.asm.ClassWriter cw)
Defines the invoke method, which performs the dynamic invocation.
|
private void |
visitBridgeConstructor(org.objectweb.asm.ClassWriter cw)
Defines the bridge method.
|
private static void |
visitConstructor(org.objectweb.asm.ClassWriter cw)
Defines the class constructor.
|
private final java.lang.String className
private final java.lang.String interfaceClass
private final java.lang.invoke.MethodType methodTypeSignature
private final java.lang.String interfaceMethodName
private final java.lang.invoke.MethodType interfaceSignatureBridge
private final java.lang.invoke.MethodType methodTypeMethod
private final Bootstrap bootstrap
private final java.lang.String classSignature
private final boolean interfaceOptimized
private final boolean hasBridge
private final int lengthAloadBridge
private final boolean[] isArray
private final int aloadIndexParameter
public ClassGenerator(Bootstrap bootstrap, java.lang.String classSignature, java.lang.String interfaceClass, java.lang.String interfaceMethodName, java.lang.invoke.MethodType methodTypeSignature, java.lang.invoke.MethodType methodTypeMethod, boolean interfaceOptimized, boolean hasBridge, java.lang.invoke.MethodType interfaceSignatureBridge, int lengthAloadBridge, boolean[] isArray, int aloadIndexParameter)
bootstrap
- Data that contains the Handle describing the bootstrap.classSignature
- Class signature to be defined. when the class has a generic type must indicate the signature; otherwise, must be null.
Callable
interface with the gereric Long
type.Ljava/lang/Object;Les/uniovi/reflection/invokedynamic/interfaces/Callable<Ljava/lang/Long;>;
interfaceClass
- Interface to be implemented by the generated class.interfaceMethodName
- Name of the method of the interface to be implemented.methodTypeSignature
- Signature of the method in the interface.methodTypeMethod
- Signature of the method, field or constructor to be invoked.interfaceOptimized
- Indicates if the optimization should be performed.hasBridge
- Indicates if generics should be used in the return type.
This will happen when the interface optimization is used and the return type is not Object.interfaceSignatureBridge
- If the bridge is used, the signature of the method should be passed.lengthAloadBridge
- If the bridge is used, the number of parameters to be passed should be passed.isArray
- Indicates when an array of Objects should be unpacked.
Each position in the array represents one parameter.
If the position is true, the parameter should be unpacked as an array;
if it is false, it should be used as Object.
The last value should always be the array.
This last value is used when the interface optimization is not performed.aloadIndexParameter
- Indicates the index from the parameters should be considered.
It is used when the interface optimization is not used.public T getInstance() throws java.lang.InstantiationException
java.lang.InstantiationException
- If there is an error instantiating the class.private byte[] generateClass()
private void methodInvoke(org.objectweb.asm.ClassWriter cw)
cw
- ClassWriter.private void visitBridgeConstructor(org.objectweb.asm.ClassWriter cw)
cw
- ClassWriterprivate static void visitConstructor(org.objectweb.asm.ClassWriter cw)
cw
- ClassWriter