Interface DispatchContext
-
public interface DispatchContextRuntime services the opcode dispatcher relies on: constant resolution, heap checks, and pending-operation handoff to the interpreter.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcheckArrayBounds(ArrayInstance array, int index)Validates an array index before an element access.voidcheckCast(ObjectInstance obj, String className)Validates a checkcast against an object.voidcheckNullReference(ObjectInstance ref, String operation)Validates that a reference is non-null before it is dereferenced.ArrayInstancegetArray(ObjectInstance ref)Views a reference as an array.intgetBranchTarget()int[]getPendingArrayDimensions()ConstantDynamicInfogetPendingConstantDynamic()FieldInfogetPendingFieldAccess()MethodInfogetPendingInvoke()InvokeDynamicInfogetPendingInvokeDynamic()MethodHandleInfogetPendingMethodHandle()MethodTypeInfogetPendingMethodType()StringgetPendingNewClass()booleanisInstanceOf(ObjectInstance obj, String className)Tests assignability of an object to a type, treating unloaded types as compatible.ObjectInstanceresolveClassConstant(int index)Resolves a class constant to a heap object representing it.doubleresolveDoubleConstant(int index)Reads a double constant from the constant pool.FieldInforesolveField(int cpIndex)Resolves a field reference from the constant pool.floatresolveFloatConstant(int index)Reads a float constant from the constant pool.intresolveIntConstant(int index)Reads an int constant from the constant pool.longresolveLongConstant(int index)Reads a long constant from the constant pool.MethodInforesolveMethod(int cpIndex)Resolves a method reference from the constant pool.StringresolveStringConstant(int index)Reads a string constant from the constant pool as plain text.ObjectInstanceresolveStringObject(int index)Resolves a string constant to its interned heap object.voidsetBranchTarget(int target)Records the bytecode offset a taken branch should continue at.voidsetPendingArrayDimensions(int[] dimensions)Hands an array allocation to the interpreter.voidsetPendingConstantDynamic(ConstantDynamicInfo info)Hands a dynamic constant to the interpreter.voidsetPendingFieldAccess(FieldInfo fieldInfo)Hands a field access to the interpreter.voidsetPendingInvoke(MethodInfo methodInfo)Hands an invocation to the interpreter.voidsetPendingInvokeDynamic(InvokeDynamicInfo info)Hands an invokedynamic call site to the interpreter.voidsetPendingMethodHandle(MethodHandleInfo info)Hands a method handle constant to the interpreter.voidsetPendingMethodType(MethodTypeInfo info)Hands a method type constant to the interpreter.voidsetPendingNewClass(String className)Hands an allocation to the interpreter.
-
-
-
Method Detail
-
resolveIntConstant
int resolveIntConstant(int index)
Reads an int constant from the constant pool.- Parameters:
index- the constant pool index- Returns:
- the constant value
-
resolveLongConstant
long resolveLongConstant(int index)
Reads a long constant from the constant pool.- Parameters:
index- the constant pool index- Returns:
- the constant value
-
resolveFloatConstant
float resolveFloatConstant(int index)
Reads a float constant from the constant pool.- Parameters:
index- the constant pool index- Returns:
- the constant value
-
resolveDoubleConstant
double resolveDoubleConstant(int index)
Reads a double constant from the constant pool.- Parameters:
index- the constant pool index- Returns:
- the constant value
-
resolveStringConstant
String resolveStringConstant(int index)
Reads a string constant from the constant pool as plain text.- Parameters:
index- the constant pool index- Returns:
- the constant text
-
resolveStringObject
ObjectInstance resolveStringObject(int index)
Resolves a string constant to its interned heap object.- Parameters:
index- the constant pool index- Returns:
- the interned string instance
-
resolveClassConstant
ObjectInstance resolveClassConstant(int index)
Resolves a class constant to a heap object representing it.- Parameters:
index- the constant pool index- Returns:
- the class instance
-
getArray
ArrayInstance getArray(ObjectInstance ref)
Views a reference as an array.- Parameters:
ref- the reference to view- Returns:
- the array behind the reference
- Throws:
IllegalArgumentException- if the reference is not an array
-
checkArrayBounds
void checkArrayBounds(ArrayInstance array, int index)
Validates an array index before an element access.- Parameters:
array- the array being accessedindex- the element index- Throws:
ArrayIndexOutOfBoundsException- if the index is outside the array
-
checkNullReference
void checkNullReference(ObjectInstance ref, String operation)
Validates that a reference is non-null before it is dereferenced.- Parameters:
ref- the reference to checkoperation- description of the access, used in the failure message- Throws:
NullPointerException- if the reference is null
-
resolveField
FieldInfo resolveField(int cpIndex)
Resolves a field reference from the constant pool.- Parameters:
cpIndex- the constant pool index of the field reference- Returns:
- owner, name, descriptor, and staticness of the field
-
resolveMethod
MethodInfo resolveMethod(int cpIndex)
Resolves a method reference from the constant pool.- Parameters:
cpIndex- the constant pool index of the method reference- Returns:
- owner, name, descriptor, and invocation kind of the method
-
isInstanceOf
boolean isInstanceOf(ObjectInstance obj, String className)
Tests assignability of an object to a type, treating unloaded types as compatible.- Parameters:
obj- the object to testclassName- the internal name of the target type- Returns:
- true if the object is, or cannot be disproven to be, an instance of the type
-
checkCast
void checkCast(ObjectInstance obj, String className)
Validates a checkcast against an object.- Parameters:
obj- the object being castclassName- the internal name of the target type- Throws:
ClassCastException- if the object is not an instance of the type
-
getPendingInvoke
MethodInfo getPendingInvoke()
- Returns:
- the invocation the dispatcher handed off, or null if none is pending
-
getPendingFieldAccess
FieldInfo getPendingFieldAccess()
- Returns:
- the field access the dispatcher handed off, or null if none is pending
-
getPendingNewClass
String getPendingNewClass()
- Returns:
- the internal name of the class to instantiate, or null if none is pending
-
getPendingArrayDimensions
int[] getPendingArrayDimensions()
- Returns:
- the requested array dimension lengths, or null if none is pending
-
setPendingInvoke
void setPendingInvoke(MethodInfo methodInfo)
Hands an invocation to the interpreter.- Parameters:
methodInfo- the resolved target method
-
setPendingFieldAccess
void setPendingFieldAccess(FieldInfo fieldInfo)
Hands a field access to the interpreter.- Parameters:
fieldInfo- the resolved target field
-
setPendingNewClass
void setPendingNewClass(String className)
Hands an allocation to the interpreter.- Parameters:
className- the internal name of the class to instantiate
-
setPendingArrayDimensions
void setPendingArrayDimensions(int[] dimensions)
Hands an array allocation to the interpreter.- Parameters:
dimensions- the requested length of each dimension
-
setBranchTarget
void setBranchTarget(int target)
Records the bytecode offset a taken branch should continue at.- Parameters:
target- the destination offset
-
getBranchTarget
int getBranchTarget()
- Returns:
- the destination offset recorded by the last branch
-
setPendingInvokeDynamic
void setPendingInvokeDynamic(InvokeDynamicInfo info)
Hands an invokedynamic call site to the interpreter.- Parameters:
info- the resolved call site
-
getPendingInvokeDynamic
InvokeDynamicInfo getPendingInvokeDynamic()
- Returns:
- the invokedynamic call site the dispatcher handed off, or null if none is pending
-
setPendingMethodHandle
void setPendingMethodHandle(MethodHandleInfo info)
Hands a method handle constant to the interpreter.- Parameters:
info- the resolved handle
-
getPendingMethodHandle
MethodHandleInfo getPendingMethodHandle()
- Returns:
- the method handle the dispatcher handed off, or null if none is pending
-
setPendingMethodType
void setPendingMethodType(MethodTypeInfo info)
Hands a method type constant to the interpreter.- Parameters:
info- the resolved type
-
getPendingMethodType
MethodTypeInfo getPendingMethodType()
- Returns:
- the method type the dispatcher handed off, or null if none is pending
-
setPendingConstantDynamic
void setPendingConstantDynamic(ConstantDynamicInfo info)
Hands a dynamic constant to the interpreter.- Parameters:
info- the resolved constant
-
getPendingConstantDynamic
ConstantDynamicInfo getPendingConstantDynamic()
- Returns:
- the dynamic constant the dispatcher handed off, or null if none is pending
-
-