Class BytecodeContext.Builder
- java.lang.Object
-
- com.tonic.analysis.execution.core.BytecodeContext.Builder
-
- Enclosing class:
- BytecodeContext
public static class BytecodeContext.Builder extends Object
Builder forBytecodeContext; a heap manager and class resolver are required.
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BytecodeContextbuild()Validates required components and creates the context, defaulting the native registry and propagating the resolver's compact-strings setting to the heap.BytecodeContext.BuilderclassResolver(ClassResolver classResolver)Sets the resolver used to look up classes and methods.BytecodeContext.BuilderheapManager(HeapManager heapManager)Sets the heap manager that owns objects and arrays during execution.BytecodeContext.BuilderinvocationHandler(InvocationHandler invocationHandler)Overrides the default per-mode invocation handler.BytecodeContext.BuildermaxCallDepth(int depth)Sets the maximum call stack depth.BytecodeContext.BuildermaxInstructions(int limit)Sets the instruction budget after which execution aborts.BytecodeContext.Buildermode(ExecutionMode mode)Sets how method invocations are executed.BytecodeContext.BuildernativeRegistry(NativeRegistry nativeRegistry)Sets the registry of native method handlers; a default-populated registry is created if omitted.BytecodeContext.BuildertrackStatistics(boolean track)Controls whether execution statistics are tracked.
-
-
-
Method Detail
-
mode
public BytecodeContext.Builder mode(ExecutionMode mode)
Sets how method invocations are executed.- Parameters:
mode- the execution mode- Returns:
- this builder
- Throws:
IllegalArgumentException- if mode is null
-
heapManager
public BytecodeContext.Builder heapManager(HeapManager heapManager)
Sets the heap manager that owns objects and arrays during execution.- Parameters:
heapManager- the heap manager- Returns:
- this builder
-
classResolver
public BytecodeContext.Builder classResolver(ClassResolver classResolver)
Sets the resolver used to look up classes and methods.- Parameters:
classResolver- the class resolver- Returns:
- this builder
-
nativeRegistry
public BytecodeContext.Builder nativeRegistry(NativeRegistry nativeRegistry)
Sets the registry of native method handlers; a default-populated registry is created if omitted.- Parameters:
nativeRegistry- the native registry- Returns:
- this builder
-
invocationHandler
public BytecodeContext.Builder invocationHandler(InvocationHandler invocationHandler)
Overrides the default per-mode invocation handler.- Parameters:
invocationHandler- the handler to use, or null for the mode default- Returns:
- this builder
-
maxCallDepth
public BytecodeContext.Builder maxCallDepth(int depth)
Sets the maximum call stack depth.- Parameters:
depth- maximum number of nested frames- Returns:
- this builder
- Throws:
IllegalArgumentException- if depth is not positive
-
maxInstructions
public BytecodeContext.Builder maxInstructions(int limit)
Sets the instruction budget after which execution aborts.- Parameters:
limit- maximum number of instructions to execute- Returns:
- this builder
- Throws:
IllegalArgumentException- if limit is not positive
-
trackStatistics
public BytecodeContext.Builder trackStatistics(boolean track)
Controls whether execution statistics are tracked.- Parameters:
track- true to track statistics- Returns:
- this builder
-
build
public BytecodeContext build()
Validates required components and creates the context, defaulting the native registry and propagating the resolver's compact-strings setting to the heap.- Returns:
- the built context
- Throws:
IllegalStateException- if the heap manager or class resolver is missing
-
-