# ⬢ truffle-api 25.6.0-elide.4 Every page: [llms.txt](llms.txt), or all in one file: [llms-full.txt](llms-full.txt) API reference for truffle-api. ## Packages - [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md): Do you want to implement your own Truffle based language? In such case start here. - [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md): The Bytecode DSL is a DSL and runtime support component of Truffle that makes it easier to implement bytecode interpreters. - [`com.oracle.truffle.api.bytecode.debug`](com/oracle/truffle/api/bytecode/debug/index.md): Debug utilities for the Bytecode DSL. - [`com.oracle.truffle.api.bytecode.serialization`](com/oracle/truffle/api/bytecode/serialization/index.md): Serialization-specific classes for the Bytecode DSL. - [`com.oracle.truffle.api.debug`](com/oracle/truffle/api/debug/index.md): The debug package contains a debugger API that can be used to install breakpoints, step through and control the execution of Truffle guest language applications. - [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md): Domain specific language that allows to specify specializing AST nodes in a declarative way. - [`com.oracle.truffle.api.exception`](com/oracle/truffle/api/exception/index.md): This package contains a Truffle exception base class. - [`com.oracle.truffle.api.frame`](com/oracle/truffle/api/frame/index.md): Package containing stack frame representation classes. - [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md): The instrumentation API provides a way to introspect and inject behavior into interpreters written using the Truffle framework. - [`com.oracle.truffle.api.instrumentation.provider`](com/oracle/truffle/api/instrumentation/provider/index.md): This package contains a provider to instantiate a Truffle instrument. - [`com.oracle.truffle.api.interop`](com/oracle/truffle/api/interop/index.md): This package contains classes that specify the contract for inter-operability between Truffle guest languages and tools. - [`com.oracle.truffle.api.io`](com/oracle/truffle/api/io/index.md): This package contains I/O related classes used by com.oracle.truffle.api.TruffleLanguage implementations. - [`com.oracle.truffle.api.library`](com/oracle/truffle/api/library/index.md): Truffle Libraries allow language implementations to use polymorphic dispatch for receiver types with support for implementation specific caching/profiling and customization of the dispatch. - [`com.oracle.truffle.api.library.provider`](com/oracle/truffle/api/library/provider/index.md): This package contains service provider interfaces used by Truffle libraries. - [`com.oracle.truffle.api.memory`](com/oracle/truffle/api/memory/index.md): This package contains memory related classes used by com.oracle.truffle.api.TruffleLanguage implementations. - [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md): Abstract syntax tree nodes are the basic building block for your com.oracle.truffle.api.TruffleLanguage. - [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md): Dynamic object storage model. - [`com.oracle.truffle.api.profiles`](com/oracle/truffle/api/profiles/index.md): A profile is a Truffle utility class that uses the Truffle compiler directives to guard for and/or forward runtime information to the compiler. - [`com.oracle.truffle.api.provider`](com/oracle/truffle/api/provider/index.md): This package contains a provider to instantiate a Truffle language. - [`com.oracle.truffle.api.source`](com/oracle/truffle/api/source/index.md): Represents a source file. - [`com.oracle.truffle.api.staticobject`](com/oracle/truffle/api/staticobject/index.md): Static Object Model APIs to represent the layout of objects that, once defined, do not change the number and the type of their properties. - [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md): Truffle String related APIs. - [`com.oracle.truffle.api.utilities`](com/oracle/truffle/api/utilities/index.md): Various utility classes that aim to make the development of TruffleLanguage guest languages easier. ## Types in `com.oracle.truffle.api` `ArrayUtils`, `Assumption`, `CallTarget`, `CompilerAsserts`, `CompilerDirectives`, `CompilerDirectives.CompilationFinal`, `CompilerDirectives.EarlyEscapeAnalysis`, `CompilerDirectives.EarlyInline`, `CompilerDirectives.TruffleBoundary`, `CompilerDirectives.ValueType`, `ContextLocal`, `ContextThreadLocal`, `ExactMath`, `HostCompilerDirectives`, `HostCompilerDirectives.BytecodeInterpreterFetchOpcode`, `HostCompilerDirectives.BytecodeInterpreterHandler`, `HostCompilerDirectives.BytecodeInterpreterHandlerConfig`, `HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument`, `HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.ExpansionKind`, `HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.Field`, `HostCompilerDirectives.BytecodeInterpreterSwitch`, `HostCompilerDirectives.InliningCutoff`, `HostCompilerDirectives.InliningRoot`, `InstrumentInfo`, `InternalResource`, `InternalResource.CPUArchitecture`, `InternalResource.Env`, `InternalResource.Id`, `InternalResource.OS`, `OptimizationFailedException`, `Option`, `Option.Group`, `ReplaceObserver`, `RootCallTarget`, `ThreadLocalAction`, `ThreadLocalAction.Access`, `Truffle`, `TruffleContext`, `TruffleContext.Builder`, `TruffleFile`, `TruffleFile.AttributeDescriptor`, `TruffleFile.Attributes`, `TruffleFile.FileStoreInfo`, `TruffleFile.FileTypeDetector`, `TruffleLanguage`, `TruffleLanguage.ContextLocalFactory`, `TruffleLanguage.ContextLocalProvider`, `TruffleLanguage.ContextPolicy`, `TruffleLanguage.ContextReference`, `TruffleLanguage.ContextThreadLocalFactory`, `TruffleLanguage.Env`, `TruffleLanguage.ExitMode`, `TruffleLanguage.InlineParsingRequest`, `TruffleLanguage.LanguageReference`, `TruffleLanguage.ParsingRequest`, `TruffleLanguage.Registration`, `TruffleLogger`, `TruffleOptionDescriptors`, `TruffleOptions`, `TruffleRuntime`, `TruffleRuntimeAccess`, `TruffleSafepoint`, `TruffleSafepoint.CompiledInterruptible`, `TruffleSafepoint.CompiledInterruptibleFunction`, `TruffleSafepoint.Interrupter`, `TruffleSafepoint.Interruptible`, `TruffleSafepoint.InterruptibleFunction`, `TruffleStackTrace`, `TruffleStackTraceElement`, `TruffleThreadBuilder` ## Types in `com.oracle.truffle.api.bytecode` `BytecodeBuilder`, `BytecodeConfig`, `BytecodeConfig.Builder`, `BytecodeConfigEncoder`, `BytecodeDSLAccess`, `BytecodeDescriptor`, `BytecodeEncodingException`, `BytecodeFrame`, `BytecodeIndexMode`, `BytecodeLabel`, `BytecodeLocal`, `BytecodeLocation`, `BytecodeNode`, `BytecodeParser`, `BytecodeRootNode`, `BytecodeRootNodes`, `BytecodeSupport`, `BytecodeSupport.CloneReferenceList`, `BytecodeSupport.ConstantsBuffer`, `BytecodeTier`, `BytecodeTransition`, `BytecodeVersion`, `ConstantOperand`, `ConstantOperand.Repeat`, `ContinuationResult`, `ContinuationRootNode`, `EpilogExceptional`, `EpilogReturn`, `ExceptionHandler`, `ExceptionHandler.HandlerKind`, `ForceQuickening`, `ForceQuickening.Repeat`, `GenerateBytecode`, `GenerateBytecodeTestVariants`, `GenerateBytecodeTestVariants.Variant`, `Instruction`, `Instruction.Argument`, `Instruction.Argument.BranchProfile`, `Instruction.Argument.Kind`, `InstructionDescriptor`, `InstructionDescriptor.ArgumentDescriptor`, `InstructionTracer`, `InstructionTracer.InstructionAccess`, `Instrumentation`, `LocalAccessor`, `LocalRangeAccessor`, `LocalVariable`, `MaterializedLocalAccessor`, `Operation`, `OperationProxy`, `OperationProxy.Proxyable`, `OperationProxy.Repeat`, `Prolog`, `Return`, `ShortCircuitOperation`, `ShortCircuitOperation.Operator`, `ShortCircuitOperation.Repeat`, `SourceInformation`, `SourceInformationTree`, `StackValue`, `StoreBytecodeIndex`, `TagTree`, `TagTreeNode`, `TagTreeNodeGen`, `TagTreeNodeGen.DynamicDispatchLibraryExports`, `TagTreeNodeGen.DynamicDispatchLibraryExports.Cached`, `TagTreeNodeGen.DynamicDispatchLibraryExports.Uncached`, `Variadic`, `Yield` ## Types in `com.oracle.truffle.api.bytecode.debug` `BytecodeDebugListener`, `BytecodeDebugTraceListener`, `HistogramInstructionTracer`, `HistogramInstructionTracer.Builder`, `HistogramInstructionTracer.GroupClause`, `HistogramInstructionTracer.Histogram`, `PrintInstructionTracer`, `PrintInstructionTracer.Builder` ## Types in `com.oracle.truffle.api.bytecode.serialization` `ByteBufferDataInput`, `BytecodeDeserializer`, `BytecodeDeserializer.DeserializerContext`, `BytecodeSerializer`, `BytecodeSerializer.SerializerContext`, `SerializationUtils` ## Types in `com.oracle.truffle.api.debug` `Breakpoint`, `Breakpoint.Builder`, `Breakpoint.ExceptionBuilder`, `Breakpoint.Kind`, `Breakpoint.ResolveListener`, `DebugContext`, `DebugContextsListener`, `DebugException`, `DebugException.CatchLocation`, `DebugScope`, `DebugStackFrame`, `DebugStackTraceElement`, `DebugThreadsListener`, `DebugValue`, `Debugger`, `DebuggerSession`, `DebuggerTags`, `DebuggerTags.AlwaysHalt`, `SourceElement`, `StepConfig`, `StepConfig.Builder`, `SuspendAnchor`, `SuspendedCallback`, `SuspendedEvent`, `SuspensionFilter`, `SuspensionFilter.Builder` ## Types in `com.oracle.truffle.api.dsl` `AOTSupport`, `Bind`, `Bind.DefaultExpression`, `Cached`, `Cached.Exclusive`, `Cached.Shared`, `CreateCast`, `DSLSupport`, `DSLSupport.SpecializationDataNode`, `ExecuteTracingSupport`, `Executed`, `Fallback`, `GenerateAOT`, `GenerateAOT.Exclude`, `GenerateAOT.Provider`, `GenerateCached`, `GenerateInline`, `GenerateNodeFactory`, `GeneratePackagePrivate`, `GenerateUncached`, `GeneratedBy`, `Idempotent`, `ImplicitCast`, `ImportStatic`, `InlineSupport`, `InlineSupport.BooleanField`, `InlineSupport.ByteField`, `InlineSupport.CharField`, `InlineSupport.DoubleField`, `InlineSupport.FloatField`, `InlineSupport.InlinableField`, `InlineSupport.InlineTarget`, `InlineSupport.IntField`, `InlineSupport.LongField`, `InlineSupport.ReferenceField`, `InlineSupport.RequiredField`, `InlineSupport.RequiredFields`, `InlineSupport.ShortField`, `InlineSupport.StateField`, `InlineSupport.UnsafeAccessedField`, `Introspectable`, `Introspection`, `Introspection.Provider`, `Introspection.SpecializationInfo`, `NeverDefault`, `NodeChild`, `NodeChildren`, `NodeFactory`, `NodeField`, `NodeFields`, `NonIdempotent`, `ReportPolymorphism`, `ReportPolymorphism.Exclude`, `ReportPolymorphism.Megamorphic`, `Specialization`, `SpecializationStatistics`, `SpecializationStatistics.AlwaysEnabled`, `SpecializationStatistics.NodeStatistics`, `SuppressPackageWarnings`, `TypeCast`, `TypeCheck`, `TypeSystem`, `TypeSystemReference`, `UnsupportedSpecializationException` ## Types in `com.oracle.truffle.api.exception` `AbstractTruffleException` ## Types in `com.oracle.truffle.api.frame` `Frame`, `FrameDescriptor`, `FrameDescriptor.Builder`, `FrameExtensions`, `FrameInstance`, `FrameInstance.FrameAccess`, `FrameInstanceVisitor`, `FrameSlotKind`, `FrameSlotTypeException`, `MaterializedFrame`, `VirtualFrame` ## Types in `com.oracle.truffle.api.instrumentation` `AllocationEvent`, `AllocationEventFilter`, `AllocationEventFilter.Builder`, `AllocationListener`, `AllocationReporter`, `ContextsListener`, `EventBinding`, `EventContext`, `ExecuteSourceEvent`, `ExecuteSourceListener`, `ExecutionEventListener`, `ExecutionEventNode`, `ExecutionEventNodeFactory`, `GenerateWrapper`, `GenerateWrapper.Ignore`, `GenerateWrapper.IncomingConverter`, `GenerateWrapper.OutgoingConverter`, `GenerateWrapper.YieldException`, `InstrumentableNode`, `InstrumentableNode.WrapperNode`, `Instrumenter`, `LoadSourceEvent`, `LoadSourceListener`, `LoadSourceSectionEvent`, `LoadSourceSectionListener`, `NearestSectionFilter`, `NearestSectionFilter.Builder`, `ProbeNode`, `ProvidedTags`, `SourceFilter`, `SourceFilter.Builder`, `SourceSectionFilter`, `SourceSectionFilter.Builder`, `SourceSectionFilter.IndexRange`, `SourceSectionFilter.SourcePredicate`, `StandardTags`, `StandardTags.CallTag`, `StandardTags.ExpressionTag`, `StandardTags.ReadVariableTag`, `StandardTags.RootBodyTag`, `StandardTags.RootTag`, `StandardTags.StatementTag`, `StandardTags.TryBlockTag`, `StandardTags.WriteVariableTag`, `Tag`, `Tag.Identifier`, `ThreadsActivationListener`, `ThreadsListener`, `TruffleInstrument`, `TruffleInstrument.ContextLocalFactory`, `TruffleInstrument.ContextLocalProvider`, `TruffleInstrument.ContextThreadLocalFactory`, `TruffleInstrument.Env`, `TruffleInstrument.Registration` ## Types in `com.oracle.truffle.api.instrumentation.provider` `TruffleInstrumentProvider` ## Types in `com.oracle.truffle.api.interop` `ArityException`, `ExceptionType`, `HeapIsolationException`, `InteropException`, `InteropLibrary`, `InvalidArrayIndexException`, `InvalidBufferOffsetException`, `NodeLibrary`, `StopIterationException`, `TruffleObject`, `UnknownIdentifierException`, `UnknownKeyException`, `UnsupportedMessageException`, `UnsupportedTypeException` ## Types in `com.oracle.truffle.api.io` `TruffleProcessBuilder` ## Types in `com.oracle.truffle.api.library` `CachedLibrary`, `DynamicDispatchLibrary`, `ExportLibrary`, `ExportLibrary.Repeat`, `ExportMessage`, `ExportMessage.Ignore`, `ExportMessage.Repeat`, `GenerateLibrary`, `GenerateLibrary.Abstract`, `GenerateLibrary.DefaultExport`, `GenerateLibrary.DefaultExport.Repeat`, `Library`, `LibraryExport`, `LibraryExport.DelegateExport`, `LibraryFactory`, `Message`, `ReflectionLibrary` ## Types in `com.oracle.truffle.api.library.provider` `DefaultExportProvider`, `EagerExportProvider` ## Types in `com.oracle.truffle.api.memory` `ByteArraySupport` ## Types in `com.oracle.truffle.api.nodes` `BlockNode`, `BlockNode.ElementExecutor`, `BytecodeOSRNode`, `ControlFlowException`, `DenyReplace`, `DirectCallNode`, `EncapsulatingNodeReference`, `ExecutableNode`, `ExecutionSignature`, `ExplodeLoop`, `ExplodeLoop.LoopExplosionKind`, `IndirectCallNode`, `InvalidAssumptionException`, `LanguageInfo`, `LoopNode`, `Node`, `Node.Child`, `Node.Children`, `NodeClass`, `NodeCloneable`, `NodeCost`, `NodeInfo`, `NodeInterface`, `NodeUtil`, `NodeUtil.NodeCountFilter`, `NodeVisitor`, `RepeatingNode`, `RootNode`, `SlowPathException`, `UnadoptableNode`, `UnexpectedResultException` ## Types in `com.oracle.truffle.api.object` `DoubleLocation`, `DynamicObject`, `DynamicObject.ContainsKeyNode`, `DynamicObject.CopyPropertiesNode`, `DynamicObject.DynamicField`, `DynamicObject.GetDynamicTypeNode`, `DynamicObject.GetKeyArrayNode`, `DynamicObject.GetNode`, `DynamicObject.GetPropertyArrayNode`, `DynamicObject.GetPropertyFlagsNode`, `DynamicObject.GetPropertyNode`, `DynamicObject.GetShapeFlagsNode`, `DynamicObject.IsSharedNode`, `DynamicObject.MarkSharedNode`, `DynamicObject.PutAllNode`, `DynamicObject.PutConstantNode`, `DynamicObject.PutNode`, `DynamicObject.RemoveKeyNode`, `DynamicObject.ResetShapeNode`, `DynamicObject.SetAllPropertyFlagsNode`, `DynamicObject.SetDynamicTypeNode`, `DynamicObject.SetPropertyFlagsNode`, `DynamicObject.SetShapeFlagsNode`, `DynamicObject.UpdateShapeNode`, `DynamicObjectFactory`, `DynamicObjectLibrary`, `FinalLocationException`, `HiddenKey`, `IncompatibleLocationException`, `IntLocation`, `Location`, `Property`, `PropertyGetter`, `Shape`, `Shape.Builder`, `Shape.DerivedBuilder` ## Types in `com.oracle.truffle.api.profiles` `BranchProfile`, `ByteValueProfile`, `ConditionProfile`, `CountingConditionProfile`, `DoubleValueProfile`, `FloatValueProfile`, `InlinedBranchProfile`, `InlinedByteValueProfile`, `InlinedConditionProfile`, `InlinedCountingConditionProfile`, `InlinedDoubleValueProfile`, `InlinedExactClassProfile`, `InlinedFloatValueProfile`, `InlinedIntValueProfile`, `InlinedLongValueProfile`, `InlinedLoopConditionProfile`, `InlinedProfile`, `IntValueProfile`, `LongValueProfile`, `LoopConditionProfile`, `PrimitiveValueProfile`, `Profile`, `ValueProfile` ## Types in `com.oracle.truffle.api.provider` `InternalResourceProvider`, `TruffleLanguageProvider` ## Types in `com.oracle.truffle.api.source` `Source`, `Source.LiteralBuilder`, `Source.SourceBuilder`, `SourceSection` ## Types in `com.oracle.truffle.api.staticobject` `DefaultStaticObjectFactory`, `DefaultStaticProperty`, `StaticProperty`, `StaticShape`, `StaticShape.Builder` ## Types in `com.oracle.truffle.api.strings` `AbstractTruffleString`, `InternalByteArray`, `MutableTruffleString`, `MutableTruffleString.AsManagedNode`, `MutableTruffleString.AsMutableTruffleStringNode`, `MutableTruffleString.ConcatNode`, `MutableTruffleString.ForceEncodingNode`, `MutableTruffleString.FromByteArrayNode`, `MutableTruffleString.FromNativePointerNode`, `MutableTruffleString.SubstringByteIndexNode`, `MutableTruffleString.SubstringNode`, `MutableTruffleString.SwitchEncodingNode`, `MutableTruffleString.WriteByteNode`, `MutableTruffleStringFactory`, `NativeAllocator`, `TranscodingErrorHandler`, `TranscodingErrorHandler.ReplacementString`, `TruffleString`, `TruffleString.AsManagedNode`, `TruffleString.AsNativeNode`, `TruffleString.AsTruffleStringNode`, `TruffleString.ByteIndexOfAnyByteNode`, `TruffleString.ByteIndexOfCodePointNode`, `TruffleString.ByteIndexOfCodePointSetNode`, `TruffleString.ByteIndexOfStringNode`, `TruffleString.ByteIndexOfStringSetNode`, `TruffleString.ByteIndexToCodePointIndexNode`, `TruffleString.ByteLengthOfCodePointNode`, `TruffleString.CharIndexOfAnyCharUTF16Node`, `TruffleString.CodePointAtByteIndexNode`, `TruffleString.CodePointAtIndexNode`, `TruffleString.CodePointAtIndexUTF32Node`, `TruffleString.CodePointIndexToByteIndexNode`, `TruffleString.CodePointLengthNode`, `TruffleString.CodePointSet`, `TruffleString.CodeRange`, `TruffleString.CodeRangeEqualsNode`, `TruffleString.CompactionLevel`, `TruffleString.CompareBytesNode`, `TruffleString.CompareCharsUTF16Node`, `TruffleString.CompareIntsUTF32Node`, `TruffleString.ConcatNode`, `TruffleString.CopyToByteArrayNode`, `TruffleString.CopyToNativeMemoryNode`, `TruffleString.CreateBackwardCodePointIteratorNode`, `TruffleString.CreateCodePointIteratorNode`, `TruffleString.Encoding`, `TruffleString.EqualNode`, `TruffleString.ErrorHandling`, `TruffleString.ForceEncodingNode`, `TruffleString.FromByteArrayNode`, `TruffleString.FromByteArrayWithCompactionUTF32Node`, `TruffleString.FromCharArrayUTF16Node`, `TruffleString.FromCodePointNode`, `TruffleString.FromIntArrayUTF32Node`, `TruffleString.FromJavaStringNode`, `TruffleString.FromLongNode`, `TruffleString.FromNativePointerNode`, `TruffleString.FromNativePointerWithCompactionUTF32Node`, `TruffleString.FromZeroTerminatedNativePointerNode`, `TruffleString.GetByteCodeRangeNode`, `TruffleString.GetCodeRangeImpreciseNode`, `TruffleString.GetCodeRangeNode`, `TruffleString.GetInternalByteArrayNode`, `TruffleString.GetInternalNativePointerNode`, `TruffleString.GetStringCompactionLevelNode`, `TruffleString.HashCodeNode`, `TruffleString.IllegalByteArrayLengthException`, `TruffleString.IndexOfCodePointNode`, `TruffleString.IndexOfStringNode`, `TruffleString.IntIndexOfAnyIntUTF32Node`, `TruffleString.IsValidNode`, `TruffleString.LastByteIndexOfCodePointNode`, `TruffleString.LastByteIndexOfStringNode`, `TruffleString.LastIndexOfCodePointNode`, `TruffleString.LastIndexOfStringNode`, `TruffleString.MaterializeNode`, `TruffleString.MaterializeSubstringNode`, `TruffleString.NumberFormatException`, `TruffleString.ParseDoubleNode`, `TruffleString.ParseIntNode`, `TruffleString.ParseLongNode`, `TruffleString.ReadByteNode`, `TruffleString.ReadCharUTF16Node`, `TruffleString.RegionEqualByteIndexNode`, `TruffleString.RegionEqualNode`, `TruffleString.RepeatNode`, `TruffleString.StringSet`, `TruffleString.SubstringByteIndexNode`, `TruffleString.SubstringNode`, `TruffleString.SwitchEncodingNode`, `TruffleString.ToJavaStringNode`, `TruffleString.ToValidStringNode`, `TruffleString.WithMask`, `TruffleString.WithMask.CreateNode`, `TruffleString.WithMask.CreateUTF16Node`, `TruffleString.WithMask.CreateUTF32Node`, `TruffleStringBuilder`, `TruffleStringBuilder.AppendByteNode`, `TruffleStringBuilder.AppendCharUTF16Node`, `TruffleStringBuilder.AppendCodePointNode`, `TruffleStringBuilder.AppendIntNumberNode`, `TruffleStringBuilder.AppendJavaStringUTF16Node`, `TruffleStringBuilder.AppendLongNumberNode`, `TruffleStringBuilder.AppendStringNode`, `TruffleStringBuilder.AppendSubstringByteIndexNode`, `TruffleStringBuilder.ToStringNode`, `TruffleStringBuilderFactory`, `TruffleStringBuilderUTF16`, `TruffleStringBuilderUTF32`, `TruffleStringBuilderUTF8`, `TruffleStringFactory`, `TruffleStringFactory.WithMaskFactory`, `TruffleStringIterator`, `TruffleStringIterator.NextNode`, `TruffleStringIterator.PreviousNode`, `TruffleStringIteratorFactory` ## Types in `com.oracle.truffle.api.utilities` `AssumedValue`, `CyclicAssumption`, `FinalBitSet`, `JSONHelper`, `JSONHelper.JSONArrayBuilder`, `JSONHelper.JSONObjectBuilder`, `JSONHelper.JSONStringBuilder`, `MathUtils`, `TriState`, `TruffleWeakReference` # ▣ com.oracle.truffle.api [truffle-api](index.md) · Every page: [llms.txt](llms.txt) Package in truffle-api. Since 0.8 or older. Do you want to implement your own [`Truffle based language`](com/oracle/truffle/api/TruffleLanguage.md)? In such case start [`here`](com/oracle/truffle/api/TruffleLanguage.md). ## Interfaces - [`Assumption`](com/oracle/truffle/api/Assumption.md): An assumption is a global boolean flag that starts with the value true (i.e., the assumption is valid) and can subsequently be invalidated (using Assumption.invalidate()). - [`CallTarget`](com/oracle/truffle/api/CallTarget.md): Represents the target of a call. - [`InternalResource`](com/oracle/truffle/api/InternalResource.md): Represents an internal resource of a language that can be lazily unpacked to a cache user directory. - [`ReplaceObserver`](com/oracle/truffle/api/ReplaceObserver.md): An observer that is notified whenever a child node is replaced. - [`RootCallTarget`](com/oracle/truffle/api/RootCallTarget.md): Represents the target of a call to a RootNode, i.e., to another tree of nodes. - [`TruffleOptionDescriptors`](com/oracle/truffle/api/TruffleOptionDescriptors.md): An OptionDescriptors enhanced to provide a sandbox policy for options. - [`TruffleRuntime`](com/oracle/truffle/api/TruffleRuntime.md): Interface representing a Truffle runtime object. - [`TruffleRuntimeAccess`](com/oracle/truffle/api/TruffleRuntimeAccess.md): A service that provides access to a TruffleRuntime implementation. ## Classes - [`ArrayUtils`](com/oracle/truffle/api/ArrayUtils.md): This class provides additional operations for String as well as character and byte arrays, which may be intrinsified by a compiler. - [`CompilerAsserts`](com/oracle/truffle/api/CompilerAsserts.md): Assertions about the code produced by the Truffle compiler. - [`CompilerDirectives`](com/oracle/truffle/api/CompilerDirectives.md): Directives that influence the optimizations of the Truffle compiler. - [`ContextLocal`](com/oracle/truffle/api/ContextLocal.md): A context local reference that refers to a value that is created for each polyglot context. - [`ContextThreadLocal`](com/oracle/truffle/api/ContextThreadLocal.md): A context thread local reference that refers to a value that is created for each polyglot context and thread. - [`ExactMath`](com/oracle/truffle/api/ExactMath.md): This class contains exact math related methods that are generally useful for dynamic language implementations. - [`HostCompilerDirectives`](com/oracle/truffle/api/HostCompilerDirectives.md): Directives that influence the optimizations of the host compiler. - [`InstrumentInfo`](com/oracle/truffle/api/InstrumentInfo.md): Represents public information about an instrument. - [`ThreadLocalAction`](com/oracle/truffle/api/ThreadLocalAction.md): Represents an action that is executed at a safepoint location of the guest language execution. - [`Truffle`](com/oracle/truffle/api/Truffle.md): Class for obtaining the Truffle runtime singleton object of this virtual machine. - [`TruffleContext`](com/oracle/truffle/api/TruffleContext.md): A handle on a context of a set of Truffle languages. - [`TruffleFile`](com/oracle/truffle/api/TruffleFile.md): An abstract representation of a file used by Truffle languages. - [`TruffleLanguage`](com/oracle/truffle/api/TruffleLanguage.md): A Truffle language implementation contains all the services a language should provide to make it composable with other languages. - [`TruffleLogger`](com/oracle/truffle/api/TruffleLogger.md): Support for logging in Truffle languages and instruments. - [`TruffleOptions`](com/oracle/truffle/api/TruffleOptions.md): Class containing general Truffle options. - [`TruffleSafepoint`](com/oracle/truffle/api/TruffleSafepoint.md): Truffle safepoints allow interrupting the guest language execution to execute thread-local actions submitted by a language or tool. - [`TruffleStackTraceElement`](com/oracle/truffle/api/TruffleStackTraceElement.md): Represents a guest stack trace element. - [`TruffleThreadBuilder`](com/oracle/truffle/api/TruffleThreadBuilder.md): A builder for threads that have access to the appropriate TruffleContext. ## Exceptions - [`OptimizationFailedException`](com/oracle/truffle/api/OptimizationFailedException.md): No description. - [`TruffleStackTrace`](com/oracle/truffle/api/TruffleStackTrace.md): Represents a guest language stack trace. ## Annotations - [`Option`](com/oracle/truffle/api/Option.md): Describes the attributes of an option whose value is in a static field annotated by this annotation. # ◆ ArrayUtils [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 19.0. ```java public final class ArrayUtils ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `ArrayUtils` This class provides additional operations for [`String`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html) as well as character and byte arrays, which may be intrinsified by a compiler. ## Methods ### indexOf(String, int, …) `public static int indexOf(String string, int fromIndex, int maxIndex, char... values)`. Since 19.0. Returns the index of the first occurrence of any character contained in `values` in `string`, bounded by `fromIndex` (inclusive) and `maxIndex` (exclusive). Returns `int`: the index of the first occurrence of any character contained in `values` in `string` that is greater than or equal to `fromIndex` and less than `maxIndex`, or `-1` if none of the characters occur. Cite: `com/oracle/truffle/api/ArrayUtils.html#indexOf(java.lang.String,int,int,char...)` ### indexOf(char[], int, …) `public static int indexOf(char[] array, int fromIndex, int maxIndex, char... values)`. Since 19.0. Returns the index of the first occurrence of any character contained in `values` in `array`, bounded by `fromIndex` (inclusive) and `maxIndex` (exclusive). Returns `int`: the index of the first occurrence of any character contained in `values` in `array` that is greater than or equal to `fromIndex` and less than `maxIndex`, or `-1` if none of the characters occur. Cite: `com/oracle/truffle/api/ArrayUtils.html#indexOf(char[],int,int,char...)` ### indexOf(byte[], int, …) `public static int indexOf(byte[] array, int fromIndex, int maxIndex, byte... values)`. Since 19.0. Returns the index of the first occurrence of any byte contained in `values` in `array`, bounded by `fromIndex` (inclusive) and `maxIndex` (exclusive). Returns `int`: the index of the first occurrence of any byte contained in `values` in `array` that is greater than or equal to `fromIndex` and less than `maxIndex`, or `-1` if none of the values occur. Cite: `com/oracle/truffle/api/ArrayUtils.html#indexOf(byte[],int,int,byte...)` ### indexOfWithOrMask(byte[], int, …) `public static int indexOfWithOrMask(byte[] haystack, int fromIndex, int length, byte[] needle, byte[] mask)`. Since 19.3. Returns the index of the first region of `haystack` that equals `needle` after being OR'ed with `mask`, bounded by `fromIndex` (inclusive) and `length`. Performs best if `needle` and `mask` are `CompilationFinal` with `dimensions = 1`. Returns `int`: the index of the first region of `haystack` where for all indices `i` of `needle` `(haystack[index + i] | mask[i]) == needle[i]` holds, and `fromIndex <= index && index + needle.length <= fromIndex + length` holds, or `-1` if no such region is found. Cite: `com/oracle/truffle/api/ArrayUtils.html#indexOfWithOrMask(byte[],int,int,byte[],byte[])` ### indexOfWithOrMask(char[], int, …) `public static int indexOfWithOrMask(char[] haystack, int fromIndex, int length, char[] needle, char[] mask)`. Since 19.3. Returns the index of the first region of `haystack` that equals `needle` after being OR'ed with `mask`, bounded by `fromIndex` (inclusive) and `length`. Performs best if `needle` and `mask` are `CompilationFinal` with `dimensions = 1`. Returns `int`: the index of the first region of `haystack` where for all indices `i` of `needle` `(haystack[index + i] | mask[i]) == needle[i]` holds, and `fromIndex <= index && index + needle.length <= fromIndex + length` holds, or `-1` if no such region is found. Cite: `com/oracle/truffle/api/ArrayUtils.html#indexOfWithOrMask(char[],int,int,char[],char[])` ### indexOfWithOrMask(String, int, …) `public static int indexOfWithOrMask(String haystack, int fromIndex, int length, String needle, String mask)`. Since 19.3. Returns the index of the first region of `haystack` that equals `needle` after being OR'ed with `mask`, bounded by `fromIndex` (inclusive) and `length`. Performs best if `needle` and `mask` are `CompilationFinal`. Returns `int`: the index of the first region of `haystack` where for all indices `i` of `needle` `(haystack.charAt(index + i) | mask.charAt(i)) == needle.charAt(i)` holds, and `fromIndex <= index && index + needle.length() <= fromIndex + length` holds, or `-1` if no such region is found. Cite: `com/oracle/truffle/api/ArrayUtils.html#indexOfWithOrMask(java.lang.String,int,int,java.lang.String,java.lang.String)` ### regionEqualsWithOrMask(byte[], int, …) `public static boolean regionEqualsWithOrMask(byte[] a, int offsetA, byte[] b, int offsetB, int length, byte[] mask)`. Since 19.3. Returns `true` iff for all indices `i` from `0` (inclusive) to `length` (exclusive), `(a[offsetA + i] | mask[i]) == b[offsetB + i]` holds. Performs best if `length` and `mask` are `CompilationFinal` with `dimensions = 1`. If `mask` is `null`, it is treated as if it was filled with zeroes. Cite: `com/oracle/truffle/api/ArrayUtils.html#regionEqualsWithOrMask(byte[],int,byte[],int,int,byte[])` ### regionEqualsWithOrMask(char[], int, …) `public static boolean regionEqualsWithOrMask(char[] a, int offsetA, char[] b, int offsetB, int length, char[] mask)`. Since 19.3. Returns `true` iff for all indices `i` from `0` (inclusive) to `length` (exclusive), `(a[offsetA + i] | mask[i]) == b[offsetB + i]` holds. Performs best if `length` and `mask` are `CompilationFinal` with `dimensions = 1`. If `mask` is `null`, it is treated as if it was filled with zeroes. Cite: `com/oracle/truffle/api/ArrayUtils.html#regionEqualsWithOrMask(char[],int,char[],int,int,char[])` ### regionEqualsWithOrMask(String, int, …) `public static boolean regionEqualsWithOrMask(String a, int offsetA, String b, int offsetB, int length, String mask)`. Since 19.3. Returns `true` iff for all indices `i` from `0` (inclusive) to `length` (exclusive), `(a.charAt(offsetA + i) | mask.charAt(i)) == b.charAt(offsetB + i)` holds. Performs best if `length` and `mask` are `CompilationFinal` with `dimensions = 1`. If `mask` is `null`, it is treated as if it was filled with zeroes. Cite: `com/oracle/truffle/api/ArrayUtils.html#regionEqualsWithOrMask(java.lang.String,int,java.lang.String,int,int,java.lang.String)` ### arraycopy(int[], int, …) `public static void arraycopy(int[] source, int sourceIndex, int[] destination, int destinationIndex, int length)`. Since 25.1. Copies `length` elements from `source`, starting at `sourceIndex`, to `destination`, starting at `destinationIndex`. This method is intended for performance-sensitive Truffle code that copies non-overlapping `int[]` regions and can benefit from compiler intrinsification, in particular for small constant-length copies. It is not a general replacement for [`System.arraycopy`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/System.html#arraycopy%28java.lang.Object,int,java.lang.Object,int,int%29): use [`System.arraycopy`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/System.html#arraycopy%28java.lang.Object,int,java.lang.Object,int,int%29) unless the stricter contract below is acceptable. Unlike [`System.arraycopy`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/System.html#arraycopy%28java.lang.Object,int,java.lang.Object,int,int%29), this method is intrinsified in a manner that doesn't behave exactly as the scalar loop would: overlapping source and destination regions are not supported, and individual elements may be copied twice, which may be observable in multi-threading contexts. Cite: `com/oracle/truffle/api/ArrayUtils.html#arraycopy(int[],int,int[],int,int)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ Assumption [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 0.8 or earlier. ```java public interface Assumption ``` An assumption is a global boolean flag that starts with the value true (i.e., the assumption is valid) and can subsequently be invalidated (using [`Assumption.invalidate()`](com/oracle/truffle/api/Assumption.md#invalidate%28%29)). Once invalidated, an assumption can never get valid again. Assumptions can be created using the [`TruffleRuntime.createAssumption()`](com/oracle/truffle/api/TruffleRuntime.md#createAssumption%28%29) or the [`TruffleRuntime.createAssumption(String)`](com/oracle/truffle/api/TruffleRuntime.md#createAssumption%28java.lang.String%29) method. The Truffle compiler has special knowledge of this class in order to produce efficient machine code for checking an assumption in case the assumption object is a compile time constant. Therefore, assumptions should be stored in final fields in Truffle nodes. All instances of classes implementing `Assumption` must be held in `final` fields for compiler optimizations to take effect. Do not manually subclass the [`Assumption`](com/oracle/truffle/api/Assumption.md) interface. This class is only intended to be subclassed by Truffle runtime implementations to avoid polymorphism in performance sensitive methods. ## Fields ### ALWAYS_VALID `Assumption ALWAYS_VALID`. Since 22.1. An assumption that is always valid and fails with an [`UnsupportedOperationException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/UnsupportedOperationException.html) if invalidated. Cite: `com/oracle/truffle/api/Assumption.html#ALWAYS_VALID` ### NEVER_VALID `Assumption NEVER_VALID`. Since 22.1. An assumption that is never valid. Cite: `com/oracle/truffle/api/Assumption.html#NEVER_VALID` ## Methods ### check() `void check() throws InvalidAssumptionException`. Since 0.8 or earlier. Checks that this assumption is still valid. The method throws an exception, if this is no longer the case. This method is preferred over the `isValid()` method when writing guest language interpreter code. The catch block should perform a node rewrite (see `Node.replace(Node)`) with a node that no longer relies on the assumption. Throws: `InvalidAssumptionException`: If the assumption is no longer valid. Cite: `com/oracle/truffle/api/Assumption.html#check()` ### isValid() `boolean isValid()`. Since 0.8 or earlier. Checks whether the assumption is still valid. Returns `boolean`: a boolean value indicating the validity of the assumption. Cite: `com/oracle/truffle/api/Assumption.html#isValid()` ### invalidate() `void invalidate()`. Since 0.8 or earlier. Invalidates this assumption. Performs no operation, if the assumption is already invalid. Cite: `com/oracle/truffle/api/Assumption.html#invalidate()` ### invalidate(String) `default void invalidate(String message)`. Since 0.33. Invalidates this assumption. Performs no operation, if the assumption is already invalid. Parameters: `message` `String`: a message stating the reason of the invalidation. Cite: `com/oracle/truffle/api/Assumption.html#invalidate(java.lang.String)` ### getName() `String getName()`. Since 0.8 or earlier. A name for the assumption that is used for debug output. Returns `String`: the name of the assumption. Cite: `com/oracle/truffle/api/Assumption.html#getName()` ### isValidAssumption(Assumption) `static boolean isValidAssumption(Assumption assumption)`. Since 19.0. Checks whether an assumption is not `null` and valid. Cite: `com/oracle/truffle/api/Assumption.html#isValidAssumption(com.oracle.truffle.api.Assumption)` ### isValidAssumption(Assumption[]) `static boolean isValidAssumption(Assumption[] assumptions)`. Since 19.0. Checks whether all assumptions in an array are not `null` and valid. Returns `false` if the assumptions array itself is `null`. This method is designed for compilation. Note that the provided assumptions array must be a compilation final array with `dimensions` set to one. Cite: `com/oracle/truffle/api/Assumption.html#isValidAssumption(com.oracle.truffle.api.Assumption[])` ### create() `static Assumption create()`. Since 22.1. Creates a new assumption with a name. Shortcut for `TruffleRuntime.createAssumption()`. Cite: `com/oracle/truffle/api/Assumption.html#create()` ### create(String) `static Assumption create(String name)`. Since 22.1. Creates a new assumption with a name. Shortcut for `TruffleRuntime.createAssumption(String)`. Cite: `com/oracle/truffle/api/Assumption.html#create(java.lang.String)` # ◇ CallTarget [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 0.8 or earlier. ```java public interface CallTarget ``` Represents the target of a call. Call targets are created automatically from a [`RootNode`](com/oracle/truffle/api/nodes/RootNode.md) by calling [`RootNode.getCallTarget()`](com/oracle/truffle/api/nodes/RootNode.md#getCallTarget%28%29). A call target allows the runtime to employ a compilation heuristic to trigger partial evaluation of the underlying [`RootNode`](com/oracle/truffle/api/nodes/RootNode.md), typically in the background. Additionally, calling a call target builds a guest language level [`stack trace`](com/oracle/truffle/api/TruffleStackTrace.md) which can be inspected using [`TruffleRuntime.iterateFrames(com.oracle.truffle.api.frame.FrameInstanceVisitor)`](com/oracle/truffle/api/TruffleRuntime.md#iterateFrames%28com.oracle.truffle.api.frame.FrameInstanceVisitor%29) or [`TruffleStackTrace.getStackTrace(Throwable)`](com/oracle/truffle/api/TruffleStackTrace.md#getStackTrace%28java.lang.Throwable%29). Do not subclass [`CallTarget`](com/oracle/truffle/api/CallTarget.md) directly, as this interface is likely to become sealed in the future. **See also** - [`RootNode`](com/oracle/truffle/api/nodes/RootNode.md) - [`DirectCallNode`](com/oracle/truffle/api/nodes/DirectCallNode.md) - [`IndirectCallNode`](com/oracle/truffle/api/nodes/IndirectCallNode.md) ## Methods ### call(Object...) `Object call(Object... arguments)`. Since 0.8 or earlier. Calls the encapsulated root node with the given arguments and returns the result. By calling this method, the call location is looked up using `EncapsulatingNodeReference`. Use `call(Node, Object...)` if the call location is already known. Calling this method in partially evaluated code will allow it to get inlined if the receiver (this) is a `pe-constant`. Call site `cloning` is only supported if a `DirectCallNode` is used instead. Parameters: `arguments` `Object...`: The arguments passed to the call, as an object array. Returns `Object`: The result of the call. See also: `call(Node, Object...)`. Cite: `com/oracle/truffle/api/CallTarget.html#call(java.lang.Object...)` ### call(Node, Object...) `default Object call(Node location, Object... arguments)`. Since 24.1. Calls the encapsulated root node with an explicit call location and arguments, and returns the result. This method should be preferred over `call(Object...)` if the current location is known, as it avoids looking up the current location from a thread-local. Parameters: `location` `Node`: A `Node` that identifies the location of this call. The location may be `null` if no location is available. `arguments` `Object...`: The arguments passed to the call, as an object array. Returns `Object`: The result of the call. See also: `call(Object...)`. Cite: `com/oracle/truffle/api/CallTarget.html#call(com.oracle.truffle.api.nodes.Node,java.lang.Object...)` ### call(Node, int, Object[]) `default Object call(Node location, int bytecodeIndex, Object[] arguments)`. Since 25.6. Calls the root node, preserving the explicit location and BCI for stack walking. Callers that do not have an explicit bytecode index should pass `-1`. Parameters: `location` `Node`: a `Node` that identifies the location of this call. The location may be `null` if no location is available. `bytecodeIndex` `int`: the bytecode index associated with this call, or `-1` if no explicit bytecode index is available. `arguments` `Object[]`: the arguments passed to the call, as an object array. Returns `Object`: the result of the call. See also: `call(Node, Object...)`. Cite: `com/oracle/truffle/api/CallTarget.html#call(com.oracle.truffle.api.nodes.Node,int,java.lang.Object[])` # ◆ CompilerAsserts [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 0.8 or earlier. ```java public final class CompilerAsserts ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `CompilerAsserts` Assertions about the code produced by the Truffle compiler. All operations have no effect when either executed in the interpreter or in the compiled code. The assertions are checked during code generation and the Truffle compiler produces for failing assertions a stack trace that identifies the code position of the assertion in the context of the current compilation. ## Methods ### neverPartOfCompilation() `public static void neverPartOfCompilation()`. Since 0.8 or earlier. Assertion that this code position should never be reached during compilation. It can be used for exceptional code paths or rare code paths that should never be included in a compilation unit. See `CompilerDirectives.transferToInterpreter()` for the corresponding compiler directive. `CompilerDirectives.bailout(String)` should be used if failing compilation is desired, e.g., for testing. `neverPartOfCompilation()` must not be reachable for runtime compilation, see the TruffleCheckNeverPartOfCompilation option. Cite: `com/oracle/truffle/api/CompilerAsserts.html#neverPartOfCompilation()` ### neverPartOfCompilation(String) `public static void neverPartOfCompilation(String message)`. Since 0.8 or earlier. Assertion that this code position should never be reached during compilation. It can be used for exceptional code paths or rare code paths that should never be included in a compilation unit. See `CompilerDirectives.transferToInterpreter()` for the corresponding compiler directive. `CompilerDirectives.bailout(String)` should be used if failing compilation is desired, e.g., for testing. `neverPartOfCompilation()` must not be reachable for runtime compilation, see the TruffleCheckNeverPartOfCompilation option. Parameters: `message` `String`: text associated with the bailout exception. Cite: `com/oracle/truffle/api/CompilerAsserts.html#neverPartOfCompilation(java.lang.String)` ### compilationConstant(Object) `public static void compilationConstant(Object value)`. Since 0.8 or earlier. Assertion that the corresponding value is reduced to a constant during compilation. This is, for example, useful to assert that an array has always the same size, although the actual value is only known at run-time. In most cases, it is preferred to use `CompilerAsserts.partialEvaluationConstant(Object)` and its specialized variants. Parameters: `value` `Object`: the value that must be constant during compilation. See also: `CompilerAsserts.partialEvaluationConstant(Object)`. Cite: `com/oracle/truffle/api/CompilerAsserts.html#compilationConstant(java.lang.Object)` ### partialEvaluationConstant(Object) `public static void partialEvaluationConstant(Object value)`. Since 0.8 or earlier. Assertion that the corresponding value is reduced to a constant during the initial partial evaluation phase. Compared with `CompilerAsserts.compilationConstant(Object)`, the constantness of the value is checked much earlier in the compilation pipeline. It should therefore be preferred, also because its specialized variants avoid boxing. Parameters: `value` `Object`: the value that must be constant during compilation. See also: `CompilerAsserts.compilationConstant(Object)`. Cite: `com/oracle/truffle/api/CompilerAsserts.html#partialEvaluationConstant(java.lang.Object)` ### partialEvaluationConstant(boolean) `public static void partialEvaluationConstant(boolean value)`. Since 19.3. Specialized version of `CompilerAsserts.compilationConstant(Object)` for `boolean` values. Parameters: `value` `boolean`: the value that must be constant during partial evaluation. See also: `CompilerAsserts.partialEvaluationConstant(Object)`. Cite: `com/oracle/truffle/api/CompilerAsserts.html#partialEvaluationConstant(boolean)` ### partialEvaluationConstant(int) `public static void partialEvaluationConstant(int value)`. Since 19.3. Specialized version of `CompilerAsserts.compilationConstant(Object)` for `int` values. Parameters: `value` `int`: the value that must be constant during partial evaluation. See also: `CompilerAsserts.partialEvaluationConstant(Object)`. Cite: `com/oracle/truffle/api/CompilerAsserts.html#partialEvaluationConstant(int)` ### partialEvaluationConstant(float) `public static void partialEvaluationConstant(float value)`. Since 19.3. Specialized version of `CompilerAsserts.compilationConstant(Object)` for `float` values. Parameters: `value` `float`: the value that must be constant during partial evaluation. See also: `CompilerAsserts.partialEvaluationConstant(Object)`. Cite: `com/oracle/truffle/api/CompilerAsserts.html#partialEvaluationConstant(float)` ### partialEvaluationConstant(long) `public static void partialEvaluationConstant(long value)`. Since 19.3. Specialized version of `CompilerAsserts.compilationConstant(Object)` for `long` values. Parameters: `value` `long`: the value that must be constant during partial evaluation. See also: `CompilerAsserts.partialEvaluationConstant(Object)`. Cite: `com/oracle/truffle/api/CompilerAsserts.html#partialEvaluationConstant(long)` ### partialEvaluationConstant(double) `public static void partialEvaluationConstant(double value)`. Since 19.3. Specialized version of `CompilerAsserts.compilationConstant(Object)` for `double` values. Parameters: `value` `double`: the value that must be constant during partial evaluation. See also: `CompilerAsserts.partialEvaluationConstant(Object)`. Cite: `com/oracle/truffle/api/CompilerAsserts.html#partialEvaluationConstant(double)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ CompilerDirectives [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 0.8 or earlier. ```java public final class CompilerDirectives ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `CompilerDirectives` Directives that influence the optimizations of the Truffle compiler. All of the operations have no effect when executed in the Truffle interpreter. ## Nested types - [`CompilerDirectives.CompilationFinal`](com/oracle/truffle/api/CompilerDirectives.CompilationFinal.md) (annotation interface): Marks fields that should be considered final for a Truffle compilation although they are not final while executing in the interpreter. - [`CompilerDirectives.EarlyEscapeAnalysis`](com/oracle/truffle/api/CompilerDirectives.EarlyEscapeAnalysis.md) (annotation interface): Requests the Truffle compiler to run escape analysis on this method before partial evaluation. - [`CompilerDirectives.EarlyInline`](com/oracle/truffle/api/CompilerDirectives.EarlyInline.md) (annotation interface): Marks a method or constructor as a candidate for early inlining during Truffle compilation. - [`CompilerDirectives.TruffleBoundary`](com/oracle/truffle/api/CompilerDirectives.TruffleBoundary.md) (annotation interface): Marks a method that it is considered as a boundary for Truffle partial evaluation. - [`CompilerDirectives.ValueType`](com/oracle/truffle/api/CompilerDirectives.ValueType.md) (annotation interface): Marks classes as value types. ## Fields ### LIKELY_PROBABILITY `public static final double LIKELY_PROBABILITY`. Since 0.8 or earlier. Constant value: `0.75`. Cite: `com/oracle/truffle/api/CompilerDirectives.html#LIKELY_PROBABILITY` ### UNLIKELY_PROBABILITY `public static final double UNLIKELY_PROBABILITY`. Since 0.8 or earlier. Constant value: `0.25`. Cite: `com/oracle/truffle/api/CompilerDirectives.html#UNLIKELY_PROBABILITY` ### SLOWPATH_PROBABILITY `public static final double SLOWPATH_PROBABILITY`. Since 0.8 or earlier. Constant value: `1.0E-4`. Cite: `com/oracle/truffle/api/CompilerDirectives.html#SLOWPATH_PROBABILITY` ### FASTPATH_PROBABILITY `public static final double FASTPATH_PROBABILITY`. Since 0.8 or earlier. Constant value: `0.9999`. Cite: `com/oracle/truffle/api/CompilerDirectives.html#FASTPATH_PROBABILITY` ## Methods ### transferToInterpreter() `public static void transferToInterpreter()`. Since 0.8 or earlier. Directive for the compiler to discontinue compilation at this code position and instead insert a transfer to the interpreter. Cite: `com/oracle/truffle/api/CompilerDirectives.html#transferToInterpreter()` ### transferToInterpreterAndInvalidate() `public static void transferToInterpreterAndInvalidate()`. Since 0.8 or earlier. Directive for the compiler to discontinue compilation at this code position and instead insert a transfer to the interpreter, invalidating the currently executing machine code. Cite: `com/oracle/truffle/api/CompilerDirectives.html#transferToInterpreterAndInvalidate()` ### inInterpreter() `public static boolean inInterpreter()`. Since 0.8 or earlier. Returns a boolean value indicating whether the method is executed in the interpreter. Returns `boolean`: `true` when executed in the interpreter, `false` in compiled code. Cite: `com/oracle/truffle/api/CompilerDirectives.html#inInterpreter()` ### hasNextTier() `public static boolean hasNextTier()`. Since 22.0.0. Returns a boolean value indicating whether the method is executed in a compilation tier which can be replaced with a higher tier (e.g. interpretation tier can be replaced by a first tier, a first tier by a second tier compilation). Returns `boolean`: `true` when executed in the first tier Truffle compilation, `false` otherwise. Cite: `com/oracle/truffle/api/CompilerDirectives.html#hasNextTier()` ### inCompiledCode() `public static boolean inCompiledCode()`. Since 0.8 or earlier. Returns a boolean value indicating whether the method is executed in the compiled code. Returns `boolean`: `false` when executed in the interpreter, `true` in compiled code. Cite: `com/oracle/truffle/api/CompilerDirectives.html#inCompiledCode()` ### preserveFrameStateHere() `public static void preserveFrameStateHere()`. Since 25.1. Inserts a state-split marker at this program point so deoptimization restores frame state for the current bytecode location. This is intended for bytecode interpreters that need reliable transfer-to-interpreter transition reporting at specific program points. Cite: `com/oracle/truffle/api/CompilerDirectives.html#preserveFrameStateHere()` ### inCompilationRoot() `public static boolean inCompilationRoot()`. Since 0.28 or earlier. Returns a boolean value indicating whether the method is executed in the root of a Truffle compilation. Returns `boolean`: `false` when executed in the interpreter or in an inlined `CallTarget`, `true` when in non-inlined compiled code. Cite: `com/oracle/truffle/api/CompilerDirectives.html#inCompilationRoot()` ### isCompilationConstant(Object) `public static boolean isCompilationConstant(Object value)`. Since 0.8 or earlier. Returns a boolean indicating whether or not a given value is seen as constant in optimized code. If this method is called in the interpreter this method will always return `true`. Note that optimizations that a compiler will apply to code that is conditional on `isCompilationConstant` may be limited. For this reason `isCompilationConstant` is not recommended for use to select between alternate implementations of functionality depending on whether a value is constant. Instead, it is intended for use as a diagnostic mechanism. Returns `boolean`: `true` when given value is seen as compilation constant, `false` if not compilation constant. Cite: `com/oracle/truffle/api/CompilerDirectives.html#isCompilationConstant(java.lang.Object)` ### isPartialEvaluationConstant(Object) `public static boolean isPartialEvaluationConstant(Object value)`. Since 0.8 or earlier. Returns a boolean indicating whether a given value is seen as constant during the initial partial evaluation phase. If this method is called in the interpreter this method will always return `true`. Because of that one should consider if the code guarded by this check should be run in interpreter or not. If it's faster to not run the guarded code in interpreter one can use: but beware that code is never run in interpreter and so might lead to subtle bugs and is harder to debug. If it does not matter much whether the code runs in interpreter it's best to just: Returns `boolean`: `true` when given value is seen as compilation constant or in interpreter, `false` otherwise. Cite: `com/oracle/truffle/api/CompilerDirectives.html#isPartialEvaluationConstant(java.lang.Object)` ```java if (CompilerDirectives.inCompiledCode() && CompilerDirectives.isPartialEvaluationConstant(value)) { // logic only run in compiled code if value is a PE constant } ``` ```java if (CompilerDirectives.isPartialEvaluationConstant(value)) { // logic run in interpreter and in compiled code if value is a PE constant } ``` ### interpreterOnly(Runnable) `public static void interpreterOnly(Runnable runnable)`. Since 0.8 or earlier. Directive for the compiler that the given runnable should only be executed in the interpreter and ignored in the compiled code. Parameters: `runnable` `Runnable`: the closure that should only be executed in the interpreter. Cite: `com/oracle/truffle/api/CompilerDirectives.html#interpreterOnly(java.lang.Runnable)` ### interpreterOnly(Callable) `public static T interpreterOnly(Callable callable) throws Exception`. Since 0.8 or earlier. Directive for the compiler that the given callable should only be executed in the interpreter. Parameters: `callable` `Callable`: the closure that should only be executed in the interpreter. Returns `T`: the result of executing the closure in the interpreter and null in the compiled code. Throws: `Exception`: If the closure throws an exception when executed in the interpreter. Cite: `com/oracle/truffle/api/CompilerDirectives.html#interpreterOnly(java.util.concurrent.Callable)` ### injectBranchProbability(double, boolean) `public static boolean injectBranchProbability(double probability, boolean condition)`. Since 0.8 or earlier. Injects a probability for the given condition into the probability information of the immediately succeeding branch instruction for the condition. The probability must be a value between 0.0 and 1.0 (inclusive). The condition should not be a combined condition. Example usage immediately before an if statement (it specifies that the likelihood for a to be greater than b is 90%): ` if (injectBranchProbability(0.9, a > b)) { // ... } ` Example usage for a combined condition (it specifies that the likelihood for a to be greater than b is 90% and under the assumption that this is true, the likelihood for a being 0 is 10%): ` if (injectBranchProbability(0.9, a > b) && injectBranchProbability(0.1, a == 0)) { // ... } ` There are predefined constants for commonly used probabilities (see `LIKELY_PROBABILITY` , `UNLIKELY_PROBABILITY`, `SLOWPATH_PROBABILITY`, `FASTPATH_PROBABILITY` ). Parameters: `probability` `double`: the probability value between 0.0 and 1.0 that should be injected. Cite: `com/oracle/truffle/api/CompilerDirectives.html#injectBranchProbability(double,boolean)` ### bailout(String) `public static void bailout(String reason)`. Since 0.8 or earlier. Bails out of a compilation (e.g., for guest language features that should never be compiled). Parameters: `reason` `String`: the reason for the bailout. Cite: `com/oracle/truffle/api/CompilerDirectives.html#bailout(java.lang.String)` ### materialize(Object) `public static void materialize(Object obj)`. Since 0.8 or earlier. Ensures that the given object is not virtual, i.e., not removed by Escape Analysis at the point of this call. Parameters: `obj` `Object`: the object to exclude from Escape Analysis. Cite: `com/oracle/truffle/api/CompilerDirectives.html#materialize(java.lang.Object)` ### ensureAllocatedHere(T) `public static T ensureAllocatedHere(T object)`. Since 24.1.0. Prevents the compiler from moving an allocation, enabling precise [`OutOfMemoryError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/OutOfMemoryError.html) exception locations. This intrinsic ensures the allocation's immobility and guarantees that the compiler's optimizations do not eliminate the allocation. Imposing such a restriction can hinder certain compiler optimizations, potentially degrading performance. If the intrinsic does not find an allocation as its argument, it causes a runtime compilation failure, invoking `CompilerDirectives.bailout(String)`. **Example usage:**. Cite: `com/oracle/truffle/api/CompilerDirectives.html#ensureAllocatedHere(T)` ```java int[] tryAllocateArray() { int[] array; try { array = CompilerDirectives.ensureAllocatedHere(new int[42]); } catch (OutOfMemoryError e) { // handle out of memory errors to maintain consistency array = null; } return array; } ``` ### ensureVirtualized(Object) `public static void ensureVirtualized(Object object)`. Since 0.8 or earlier. Ensures that the given object will be virtual (escape analyzed) at all points that are dominated by the current position. Cite: `com/oracle/truffle/api/CompilerDirectives.html#ensureVirtualized(java.lang.Object)` ### ensureVirtualizedHere(Object) `public static void ensureVirtualizedHere(Object object)`. Since 0.8 or earlier. Ensures that the given object will be virtual at the current position. Cite: `com/oracle/truffle/api/CompilerDirectives.html#ensureVirtualizedHere(java.lang.Object)` ### blackhole(boolean) `public static void blackhole(boolean value)`. Since 21.2. Consume a value, making sure the compiler doesn't optimize away the computation of this value, even if it is otherwise unused. This should only be used for benchmarking purposes. Cite: `com/oracle/truffle/api/CompilerDirectives.html#blackhole(boolean)` ### blackhole(byte) `public static void blackhole(byte value)`. Since 21.2. Consume a value, making sure the compiler doesn't optimize away the computation of this value, even if it is otherwise unused. This should only be used for benchmarking purposes. Cite: `com/oracle/truffle/api/CompilerDirectives.html#blackhole(byte)` ### blackhole(short) `public static void blackhole(short value)`. Since 21.2. Consume a value, making sure the compiler doesn't optimize away the computation of this value, even if it is otherwise unused. This should only be used for benchmarking purposes. Cite: `com/oracle/truffle/api/CompilerDirectives.html#blackhole(short)` ### blackhole(char) `public static void blackhole(char value)`. Since 21.2. Consume a value, making sure the compiler doesn't optimize away the computation of this value, even if it is otherwise unused. This should only be used for benchmarking purposes. Cite: `com/oracle/truffle/api/CompilerDirectives.html#blackhole(char)` ### blackhole(int) `public static void blackhole(int value)`. Since 21.2. Consume a value, making sure the compiler doesn't optimize away the computation of this value, even if it is otherwise unused. This should only be used for benchmarking purposes. Cite: `com/oracle/truffle/api/CompilerDirectives.html#blackhole(int)` ### blackhole(long) `public static void blackhole(long value)`. Since 21.2. Consume a value, making sure the compiler doesn't optimize away the computation of this value, even if it is otherwise unused. This should only be used for benchmarking purposes. Cite: `com/oracle/truffle/api/CompilerDirectives.html#blackhole(long)` ### blackhole(float) `public static void blackhole(float value)`. Since 21.2. Consume a value, making sure the compiler doesn't optimize away the computation of this value, even if it is otherwise unused. This should only be used for benchmarking purposes. Cite: `com/oracle/truffle/api/CompilerDirectives.html#blackhole(float)` ### blackhole(double) `public static void blackhole(double value)`. Since 21.2. Consume a value, making sure the compiler doesn't optimize away the computation of this value, even if it is otherwise unused. This should only be used for benchmarking purposes. Cite: `com/oracle/truffle/api/CompilerDirectives.html#blackhole(double)` ### blackhole(Object) `public static void blackhole(Object value)`. Since 21.2. Consume a value, making sure the compiler doesn't optimize away the computation of this value, even if it is otherwise unused. This should only be used for benchmarking purposes. Cite: `com/oracle/truffle/api/CompilerDirectives.html#blackhole(java.lang.Object)` ### castExact(Object, Class) `public static T castExact(Object object, Class clazz)`. Since 0.33. Casts the given object to the exact class represented by `clazz`. The cast succeeds only if `object == null || object.getClass() == clazz` and thus fails for any subclass. Parameters: `object` `Object`: the object to be cast. `clazz` `Class`: the class to check against, must not be null. Returns `T`: the object after casting. Throws: `ClassCastException` (unchecked): if the object is non-null and not exactly of the given class. `NullPointerException` (unchecked): if the class argument is null. See also: [`Class.cast(Object)`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Class.html#cast%28java.lang.Object%29). Cite: `com/oracle/truffle/api/CompilerDirectives.html#castExact(java.lang.Object,java.lang.Class)` ### isExact(Object, Class) `public static boolean isExact(Object object, Class clazz)`. Since 21.1. Checks the given object to the exact class represented by `clazz`. The method returns `true` only if `object != null && object.getClass() == clazz` and thus fails for any subclass. Parameters: `object` `Object`: the object to be cast. `clazz` `Class`: the class to check against, must not be null. Throws: `NullPointerException` (unchecked): if the class argument is null. Cite: `com/oracle/truffle/api/CompilerDirectives.html#isExact(java.lang.Object,java.lang.Class)` ### shouldNotReachHere() `public static RuntimeException shouldNotReachHere()`. Since 20.2. Indicates a code path that is not supposed to be reached during compilation or interpretation. Reaching this method is considered a fatal internal error and execution should not continue. Transfers to interpreter and `invalidates` the compiled code and always throws an [`AssertionError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AssertionError.html) when invoked. This method returns a runtime exception to be conveniently used in combination with Java throw statements, for example: Cite: `com/oracle/truffle/api/CompilerDirectives.html#shouldNotReachHere()` ```java if (expectedCondition) { return 42; } else { throw shouldNotReachHere(); } ``` ### shouldNotReachHere(String) `public static RuntimeException shouldNotReachHere(String message)`. Since 20.2. Indicates a code path that is not supposed to be reached during compilation or interpretation. Reaching this method is considered a fatal internal error and execution should not continue. Transfers to interpreter and `invalidates` the compiled code and always throws an [`AssertionError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AssertionError.html) when invoked. This method returns a runtime exception to be conveniently used in combination with Java throw statements, for example: Parameters: `message` `String`: an additional message for the exception thrown. Cite: `com/oracle/truffle/api/CompilerDirectives.html#shouldNotReachHere(java.lang.String)` ```java if (expectedCondition) { return 42; } else { throw shouldNotReachHere("Additional message"); } ``` ### shouldNotReachHere(Throwable) `public static RuntimeException shouldNotReachHere(Throwable cause)`. Since 20.2. Indicates a code path that is not supposed to be reached during compilation or interpretation. Reaching this method is considered a fatal internal error and execution should not continue. Transfers to interpreter and `invalidates` the compiled code and always throws an [`AssertionError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AssertionError.html) when invoked. This method returns a runtime exception to be conveniently used in combination with Java throw statements, for example: Parameters: `cause` `Throwable`: the cause if an exception was responsible for the unexpected case. Cite: `com/oracle/truffle/api/CompilerDirectives.html#shouldNotReachHere(java.lang.Throwable)` ```java if (expectedCondition) { return 42; } else { throw shouldNotReachHere("Additional message"); } ``` ### shouldNotReachHere(String, Throwable) `public static RuntimeException shouldNotReachHere(String message, Throwable cause)`. Since 20.2. Indicates a code path that is not supposed to be reached during compilation or interpretation. Reaching this method is considered a fatal internal error and execution should not continue. Transfers to interpreter and `invalidates` the compiled code and always throws an [`AssertionError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AssertionError.html) when invoked. This method returns a runtime exception to be conveniently used in combination with Java throw statements, for example: Parameters: `message` `String`: an additional message for the exception thrown. `cause` `Throwable`: the cause if an exception was responsible for the unexpected case. Cite: `com/oracle/truffle/api/CompilerDirectives.html#shouldNotReachHere(java.lang.String,java.lang.Throwable)` ```java if (expectedCondition) { return 42; } else { throw shouldNotReachHere("Additional message"); } ``` ### mergeExplodeKey(int) `public static int mergeExplodeKey(int i)`. Since 25.5. Marks a local variable as the key used for merging loop iterations in methods annotated with `LoopExplosionKind.MERGE_EXPLODE`. Using this outside of merge exploded methods will lead to a compilation failure. Call this method once before the loop, preferably immediately before it, and assign the return value back to the variable: Direct adjacency is not required, but the marked value must reach the first loop header unchanged and must not be consumed by an intervening merge-exploded loop. Key discovery happens only at initial entry; calling this method inside the loop is too late. Later iterations track the current value at the discovered location. A nested `int` or `long` value stored in objects virtualized by `EarlyEscapeAnalysis` can also be marked, for example `state.inner.key = CompilerDirectives.mergeExplodeKey(state.inner.key);`. This is only supported while every object on that access path remains virtual and never escapes. Only a single variable can currently be marked with this method; marking multiple variables causes a compilation failure. This restriction will be lifted in a future release. At every iteration, the key value must be a compile-time constant `int` or `long` so the compiler can create a distinct merge point for each key value and correctly handle irreducibly exploded structures. If this is not upheld, a compilation failure occurs. Other variables must have the same value at every iteration where the key matches (e.g., partial evaluate to the same constant or remain unchanged). If a non-key variable changes while the key stays the same, a compilation failure occurs because the states cannot be merged. A way to explicitly mark a variable as exempt from the same-value requirement is planned. Parameters: `i` `int`: the variable that should be used as the merge key. Returns `int`: the unchanged value. See also: `mergeExplodeKey(long)`. Cite: `com/oracle/truffle/api/CompilerDirectives.html#mergeExplodeKey(int)` ```java int bci = 0; // ... bci = CompilerDirectives.mergeExplodeKey(bci); while (bci != END_BCI) { // ... } ``` ### mergeExplodeKey(long) `public static long mergeExplodeKey(long i)`. Since 25.5. Marks a `long` variable as the key used for merging loop iterations in methods annotated with `LoopExplosionKind.MERGE_EXPLODE`. Using this outside of merge exploded methods will lead to a compilation failure. The usage and restrictions are the same as for `mergeExplodeKey(int)`, including the requirement that the key be a compile-time constant at every loop header. For irreducible loops, `long` key values must also fit in the signed 32-bit `int` range. Values outside of this range will cause a compilation failure. Parameters: `i` `long`: the variable that should be used as the merge key. Returns `long`: the unchanged value. See also: `mergeExplodeKey(int)`. Cite: `com/oracle/truffle/api/CompilerDirectives.html#mergeExplodeKey(long)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # @ CompilerDirectives.CompilationFinal [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 0.8 or earlier. Nested in [`CompilerDirectives`](com/oracle/truffle/api/CompilerDirectives.md). ```java @Retention(RUNTIME) @Target({FIELD}) public @interface CompilerDirectives.CompilationFinal ``` Marks fields that should be considered final for a Truffle compilation although they are not final while executing in the interpreter. If the field type is an array type, the compiler considers reads with a constant index as constants. ## Elements ### dimensions() `int dimensions() default -1`. Since 0.14. Specifies the number of array dimensions to be marked as compilation final. This value should be specified for all array-typed compilation-final fields and should be left unspecified for other field types for which it has no meaning. The allowed range is from 0 to the number of declared array dimensions (inclusive). Specifically, a `dimensions` value of 0 marks only the reference to the (outermost) array as final but not its elements, a value of 1 marks the outermost array and all its elements as final but not the elements of any nested arrays. For compatibility reasons, array-typed fields without an explicit `dimensions` parameter default to the number of array dimensions declared in the field type. Default: `-1`. Cite: `com/oracle/truffle/api/CompilerDirectives.CompilationFinal.html#dimensions()` # @ CompilerDirectives.EarlyEscapeAnalysis [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 25.1. Nested in [`CompilerDirectives`](com/oracle/truffle/api/CompilerDirectives.md). ```java @Retention(RUNTIME) @Target({METHOD, CONSTRUCTOR}) public @interface CompilerDirectives.EarlyEscapeAnalysis ``` Requests the Truffle compiler to run escape analysis on this method before partial evaluation. When a method or constructor is annotated with `@EarlyEscapeAnalysis`, a dedicated partial escape analysis phase is executed for that method before partial evaluation. This allows allocations that do not escape the method to be virtualized or eliminated, and their fields to be treated as partial-evaluation-time constants where possible. ### Typical use cases - Methods that allocate temporary objects whose fields are used only locally and are expected to become constants after partial evaluation. - Interpreters that keep loop state in a small object (for example a bytecode index), in combination with [`ExplodeLoop`](com/oracle/truffle/api/nodes/ExplodeLoop.md) and [`EarlyInline`](com/oracle/truffle/api/CompilerDirectives.EarlyInline.md), so that the state object can be fully scalar replaced. ### Example: non-escaping temporary object ```java @EarlyEscapeAnalysis private static int computeConstant() { TestEscape v = new TestEscape(42); CompilerAsserts.partialEvaluationConstant(v.value); // After early escape analysis and partial evaluation this method reduces to "return 42". return v.value; } static final class TestEscape { int value; TestEscape(int value) { this.value = value; } } ``` ### Example: loop state object in a merge-exploded interpreter ```java static final class BytecodeIndex { int bci; } @CompilationFinal(dimensions = 1) private final byte[] bytecodes = new byte[]{0, 1, 4, 2, 3}; @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) @EarlyEscapeAnalysis int execute(Boolean v) { byte[] bc = this.bytecodes; BytecodeIndex index = new BytecodeIndex(); while (true) { CompilerAsserts.partialEvaluationConstant(index.bci); switch (bc[index.bci]) { case 0: index.bci++; break; case 1: // {@code branchTrue} is early inlined and sees the virtual {@code index} // object. branchTrue(bc, index, v); break; case 2: return 41; case 3: return 42; case 4: throw CompilerDirectives.shouldNotReachHere(); } } } @EarlyInline private static void branchTrue(byte[] bc, BytecodeIndex index, Boolean v) { if (v) { index.bci = bc[index.bci + 1]; } else { index.bci = index.bci + 2; } } ``` # @ CompilerDirectives.EarlyInline [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 25.1. Nested in [`CompilerDirectives`](com/oracle/truffle/api/CompilerDirectives.md). ```java @Retention(RUNTIME) @Target({METHOD, CONSTRUCTOR}) public @interface CompilerDirectives.EarlyInline ``` Marks a method or constructor as a candidate for early inlining during Truffle compilation. Methods annotated with `@EarlyInline` are considered by a dedicated early inlining phase before partial evaluation. This exposes the helper's control flow and state updates directly in the caller so that other Truffle directives such as [`ExplodeLoop`](com/oracle/truffle/api/nodes/ExplodeLoop.md) and [`EarlyEscapeAnalysis`](com/oracle/truffle/api/CompilerDirectives.EarlyEscapeAnalysis.md) can see and optimize them. Only direct calls whose target method is annotated are considered, and normal inlining preconditions still apply. Indirect calls, native methods, and methods that cannot be inlined are ignored. ### Typical use cases - Inlining small branch or bytecode handlers into a [`merge-exploded`](com/oracle/truffle/api/nodes/ExplodeLoop.LoopExplosionKind.md#MERGE_EXPLODE) interpreter loop so that loop explosion can merge state across the helper call. - Inlining helpers that update non-escaping state objects in methods annotated with [`EarlyEscapeAnalysis`](com/oracle/truffle/api/CompilerDirectives.EarlyEscapeAnalysis.md), improving escape analysis and scalar replacement. ### Example: early inlining of a branch handler ```java @CompilationFinal(dimensions = 1) private final byte[] bytecodes = new byte[]{0, 1, 4, 2, 3}; @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) int execute(Boolean v) { byte[] bc = this.bytecodes; int bci = 0; while (true) { CompilerAsserts.partialEvaluationConstant(bci); switch (bc[bci]) { case 0: bci++; break; case 1: // {@code branchTrue} is inlined before partial evaluation. bci = branchTrue(bc, bci, v); break; case 2: return 41; case 3: return 42; default: throw CompilerDirectives.shouldNotReachHere(); } } } @EarlyInline private static int branchTrue(byte[] bc, int bci, Boolean v) { if (v) { return bc[bci + 1]; } else { return bci + 2; } } ``` # @ CompilerDirectives.TruffleBoundary [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 0.8 or earlier. Nested in [`CompilerDirectives`](com/oracle/truffle/api/CompilerDirectives.md). ```java @Retention(RUNTIME) @Target({METHOD, CONSTRUCTOR}) public @interface CompilerDirectives.TruffleBoundary ``` Marks a method that it is considered as a boundary for Truffle partial evaluation. ## Elements ### transferToInterpreterOnException() `boolean transferToInterpreterOnException() default true`. Since 0.28. Determines whether execution should be transferred to the interpreter if an exception is thrown across this boundary, in which case the caller's compiled code is invalidated and will not transfer to the interpreter on exceptions for this method again. Default: `true`. Cite: `com/oracle/truffle/api/CompilerDirectives.TruffleBoundary.html#transferToInterpreterOnException()` ### allowInlining() `boolean allowInlining() default false`. Since 0.27. Considers this Truffle boundary invoke as an inlining candidate. Partial evaluation cannot inline a boundary, but a later inlining pass can. Default: `false`. Cite: `com/oracle/truffle/api/CompilerDirectives.TruffleBoundary.html#allowInlining()` # @ CompilerDirectives.ValueType [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 0.8 or earlier. Nested in [`CompilerDirectives`](com/oracle/truffle/api/CompilerDirectives.md). ```java @Retention(RUNTIME) @Target({TYPE}) public @interface CompilerDirectives.ValueType ``` Marks classes as value types. Reference comparisons (==) between instances of those classes have undefined semantics and can either return true or false. # ◆ ContextLocal [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 20.3. ```java public abstract class ContextLocal ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `ContextLocal` A context local reference that refers to a value that is created for each polyglot context. Context references can be used to attach data to a polyglot context. That data can be retrieved efficiently for the current context using [`get()`](com/oracle/truffle/api/ContextLocal.md#get%28%29) or for other contexts using [`get(TruffleContext)`](com/oracle/truffle/api/ContextLocal.md#get%28com.oracle.truffle.api.TruffleContext%29). Context locals can be created for languages and instruments. See links below for usage examples. **See also** - [`Usage with languages.`](com/oracle/truffle/api/TruffleLanguage.ContextLocalProvider.md#createContextLocal%28com.oracle.truffle.api.TruffleLanguage.ContextLocalFactory%29) - [`Usage with instruments.`](com/oracle/truffle/api/instrumentation/TruffleInstrument.ContextLocalProvider.md#createContextLocal%28com.oracle.truffle.api.instrumentation.TruffleInstrument.ContextLocalFactory%29) ## Constructors ### ContextLocal(Object) `protected ContextLocal(Object polyglotObject)`. Since 20.3. Custom subclasses of context local are not allowed. Cite: `com/oracle/truffle/api/ContextLocal.html#(java.lang.Object)` ## Methods ### get() `public abstract T get()`. Since 20.3. Returns the context local value for the currently entered context. This method is intended to be used on compiled code paths. The return value is never `null`. Throws: `IllegalStateException` (unchecked): if assertions (-ea) are enabled and no current context is entered on the current thread, context locals have already been cleared for the current context, the corresponding instrument is not initialized, or the corresponding language is not created. Cite: `com/oracle/truffle/api/ContextLocal.html#get()` ### get(TruffleContext) `public abstract T get(TruffleContext context)`. Since 20.3. Returns the context local value for an explicit `context`. This method is intended to be used on compiled code paths. The return value is never `null`. Throws: `IllegalStateException` (unchecked): if assertions (-ea) are enabled and context locals have already been cleared for the specified context, the corresponding instrument is not initialized, or the corresponding language is not created. Cite: `com/oracle/truffle/api/ContextLocal.html#get(com.oracle.truffle.api.TruffleContext)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ ContextThreadLocal [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 20.3. ```java public abstract class ContextThreadLocal ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `ContextThreadLocal` A context thread local reference that refers to a value that is created for each polyglot context and thread. Context thread references can be used to attach data to a polyglot context for a thread. That data can be retrieved efficiently for the current context and thread using [`get()`](com/oracle/truffle/api/ContextThreadLocal.md#get%28%29) or less efficiently for other contexts and other threads using [`get(TruffleContext, Thread)`](com/oracle/truffle/api/ContextThreadLocal.md#get%28com.oracle.truffle.api.TruffleContext,java.lang.Thread%29). Context thread locals can be created for languages and instruments. See links below for usage examples. **See also** - [`Usage with languages.`](com/oracle/truffle/api/TruffleLanguage.ContextLocalProvider.md#createContextThreadLocal%28com.oracle.truffle.api.TruffleLanguage.ContextThreadLocalFactory%29) - [`Usage with instruments.`](com/oracle/truffle/api/instrumentation/TruffleInstrument.ContextLocalProvider.md#createContextThreadLocal%28com.oracle.truffle.api.instrumentation.TruffleInstrument.ContextThreadLocalFactory%29) ## Constructors ### ContextThreadLocal(Object) `protected ContextThreadLocal(Object polyglotObject)`. Since 20.3. Custom subclasses of context local are not allowed. Cite: `com/oracle/truffle/api/ContextThreadLocal.html#(java.lang.Object)` ## Methods ### get() `public abstract T get()`. Since 20.3. Returns the context thread local value for the currently entered context and thread. This method is intended to be used on compiled code paths. The return value is never `null`. Throws [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) if no current context is entered on the current thread. Cite: `com/oracle/truffle/api/ContextThreadLocal.html#get()` ### get(Thread) `public abstract T get(Thread t)`. Since 20.3. Returns the context thread local value for the currently entered context and the given thread. This method is less efficient than `get()` or `get(TruffleContext)` as it requires synchronization between the threads. The return value is never `null`. Throws [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) if no current context is entered on the current thread. Cite: `com/oracle/truffle/api/ContextThreadLocal.html#get(java.lang.Thread)` ### get(TruffleContext) `public abstract T get(TruffleContext t)`. Since 20.3. Returns the context thread local value for the given context and the current thread.his method is intended to be used on compiled code paths. The return value is never `null`. Throws [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) if no current context is entered on the current thread. Cite: `com/oracle/truffle/api/ContextThreadLocal.html#get(com.oracle.truffle.api.TruffleContext)` ### get(TruffleContext, Thread) `public abstract T get(TruffleContext context, Thread t)`. Since 20.3. Returns the context thread local value for the given context and the given thread. The context does not need to, but may be entered when retrieving the current context local. This method is less efficient than `get()` or `get(TruffleContext)` as it requires synchronization between the threads. The return value is never `null`. Throws [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) if no current context is entered on the current thread. Cite: `com/oracle/truffle/api/ContextThreadLocal.html#get(com.oracle.truffle.api.TruffleContext,java.lang.Thread)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ ExactMath [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 0.8 or earlier. ```java public final class ExactMath ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `ExactMath` This class contains exact math related methods that are generally useful for dynamic language implementations. ## Methods ### multiplyHigh(int, int) `public static int multiplyHigh(int x, int y)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/ExactMath.html#multiplyHigh(int,int)` ### multiplyHigh(long, long) `public static long multiplyHigh(long x, long y)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/ExactMath.html#multiplyHigh(long,long)` ### multiplyHighUnsigned(int, int) `public static int multiplyHighUnsigned(int x, int y)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/ExactMath.html#multiplyHighUnsigned(int,int)` ### multiplyHighUnsigned(long, long) `public static long multiplyHighUnsigned(long x, long y)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/ExactMath.html#multiplyHighUnsigned(long,long)` ### truncate(float) `public static float truncate(float x)`. Since 21.1. Removes the decimal part (aka truncation or rounds towards zero) of the given float. This corresponds to the IEEE 754 `roundToIntegralTowardZero` operation (IEEE Std 754-2008, section 5.9, page 41). Cite: `com/oracle/truffle/api/ExactMath.html#truncate(float)` ### truncate(double) `public static double truncate(double x)`. Since 21.1. Removes the decimal part (aka truncation or rounds towards zero) of the given double. This corresponds to the IEEE 754 `roundToIntegralTowardZero` operation (IEEE Std 754-2008, section 5.9, page 41). Cite: `com/oracle/truffle/api/ExactMath.html#truncate(double)` ### truncateToUnsignedLong(double) `public static long truncateToUnsignedLong(double x)`. Since 25.0. Converts the double value to unsigned long with truncation (i.e. rounding towards zero) and saturation of `NaN` and `x <= -1` to `0`, and `x >= 2`64 to `2`63`-1` (`-1`). Non-saturating (e.g. trapping) behavior can be implemented by checking the input for NaN, underflow (`x <= -1`) and overflow (`x >= 0x1p64`) first. Parameters: `x` `double`: input value. Returns `long`: the unsigned integer result, wrapped in a signed integer. Cite: `com/oracle/truffle/api/ExactMath.html#truncateToUnsignedLong(double)` ### truncateToUnsignedLong(float) `public static long truncateToUnsignedLong(float x)`. Since 25.0. Converts the float value to unsigned long with truncation (i.e. rounding towards zero) and saturation of `NaN` and `x <= -1` to `0`, and `x >= 2`64 to `2`63`-1` (`-1`). Non-saturating (e.g. trapping) behavior can be implemented by checking the input for NaN, underflow (`x <= -1f`) and overflow (`x >= 0x1p64f`) first. Parameters: `x` `float`: input value. Returns `long`: the unsigned integer result, wrapped in a signed integer. Cite: `com/oracle/truffle/api/ExactMath.html#truncateToUnsignedLong(float)` ### truncateToUnsignedInt(double) `public static int truncateToUnsignedInt(double x)`. Since 25.0. Converts the double value to unsigned long with truncation (i.e. rounding towards zero) and saturation of `NaN` and `x <= -1` to `0`, and `x >= 2`32 to `2`31`-1` (`-1`). Non-saturating (e.g. trapping) behavior can be implemented by checking the input for NaN, underflow (`x <= -1`) and overflow (`x >= 0x1p32`) first. Parameters: `x` `double`: input value. Returns `int`: the unsigned integer result, wrapped in a signed integer. Cite: `com/oracle/truffle/api/ExactMath.html#truncateToUnsignedInt(double)` ### truncateToUnsignedInt(float) `public static int truncateToUnsignedInt(float x)`. Since 25.0. Converts the float value to unsigned int with truncation (i.e. rounding towards zero) and saturation of `NaN` and `x <= -1` to `0`, and `x >= 2`32 to `2`31`-1` (`-1`). Non-saturating (e.g. trapping) behavior can be implemented by checking the input for NaN, underflow (`x <= -1`) and overflow (`x >= 0x1p64`) first. Parameters: `x` `float`: input value. Returns `int`: the unsigned integer result, wrapped in a signed integer. Cite: `com/oracle/truffle/api/ExactMath.html#truncateToUnsignedInt(float)` ### unsignedToDouble(long) `public static double unsignedToDouble(long x)`. Since 25.0. Converts the given unsigned `long` to the closest `double` value. Parameters: `x` `long`: unsigned integer input, wrapped in a signed integer. Returns `double`: the `double` result. Cite: `com/oracle/truffle/api/ExactMath.html#unsignedToDouble(long)` ### unsignedToFloat(long) `public static float unsignedToFloat(long x)`. Since 25.0. Converts the given unsigned `long` to the closest `float` value. Parameters: `x` `long`: unsigned integer input, wrapped in a signed integer. Returns `float`: the `float` result. Cite: `com/oracle/truffle/api/ExactMath.html#unsignedToFloat(long)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ HostCompilerDirectives [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 21.0. ```java public final class HostCompilerDirectives ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `HostCompilerDirectives` Directives that influence the optimizations of the host compiler. These operations affect how the Truffle interpreter is itself compiled. ## Nested types - [`HostCompilerDirectives.BytecodeInterpreterFetchOpcode`](com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterFetchOpcode.md) (annotation interface): Annotates a method that fetches the next opcode. - [`HostCompilerDirectives.BytecodeInterpreterHandler`](com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandler.md) (annotation interface): Annotates a method that serves as a Truffle interpreter bytecode handler, that is, a method implements the complete semantics of a single bytecode instruction. - [`HostCompilerDirectives.BytecodeInterpreterHandlerConfig`](com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandlerConfig.md) (annotation interface): Configuration for all bytecode interpreter handler arguments, including the receiver. - [`HostCompilerDirectives.BytecodeInterpreterSwitch`](com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterSwitch.md) (annotation interface): Marks a method that is an implementation of a Truffle interpreter, and which should receive additional optimization budget. - [`HostCompilerDirectives.InliningCutoff`](com/oracle/truffle/api/HostCompilerDirectives.InliningCutoff.md) (annotation interface): Hints to Truffle host inlining that a particular method is partial evaluatable, but it would be a good place for a cutoff when performing host inlining. - [`HostCompilerDirectives.InliningRoot`](com/oracle/truffle/api/HostCompilerDirectives.InliningRoot.md) (annotation interface): Marks a method as a candidate for Truffle host inlining. ## Methods ### inInterpreterFastPath() `public static boolean inInterpreterFastPath()`. Since 23.0. Indicates whether a branch is executed only in the interpreter. In addition to `CompilerDirectives.inInterpreter()`, this method instructs the host compiler to treat the positive branch as frequently executed code of high importance. Branches protected by this method should be treated as if they were runtime compiled code paths, even if they may never actually be compiled. This means that slow-paths must be protected using either `CompilerDirectives.transferToInterpreterAndInvalidate()` or `TruffleBoundary`. A common use case for this directive is in counting condition profiles, where counters must be protected by `CompilerDirectives.inInterpreter()` but also need to be optimized as fast-path by the host compiler. Without this directive, the host compiler may treat the branch as a slow-path branch. Returns `boolean`: `true` if executed in the interpreter, `false` in compiled code. Cite: `com/oracle/truffle/api/HostCompilerDirectives.html#inInterpreterFastPath()` ### markThreadedSwitch(int) `public static int markThreadedSwitch(int input)`. Since 25.1. Marks a switch statement within a loop as a candidate for threaded switch optimization. Threaded switch replicates the switch statement at the end of each case, improving branch prediction at the processor level. Usage example: The compiler recognizes the code blocks from the loop header up to the switch and duplicates them into each case that continues the while loop. This effectively transforms the structure as follows: When additional statements follow the switch block within a loop, the compiler may trigger an optimization to duplicate these statements into each case block. If this duplication does not occur, the compiler can still identify the loop as a candidate for threaded switch optimization and apply relevant optimizations to minimize overhead in the loop header, such as postponing register spilling from the loop header to cases with actual register pressure, even at the cost of code bloat. However, due to the presence of these tail statements, the loop has only one back edge, which effectively disables threading. The compiler may also reject candidates for threaded switch optimization if the identified code blocks, after inlining, contain complex control flow or operations beyond memory reads. To log decisions related to threaded switch optimization, use the Graal option `TraceThreadedSwitchOptimization`. Cite: `com/oracle/truffle/api/HostCompilerDirectives.html#markThreadedSwitch(int)` ```java while (cond) { input = inlinedNextOpcode(); switch (markThreadedSwitch(input)) { case op1: { body1; } case op2: { body2; } } } ``` ```java if (cond) { input = inlinedNextOpcode(); switch (markThreadedSwitch(input)) { case op1: { body1; if (cond) { input = inlinedNextOpcode(); switch (markThreadedSwitch(input)) // go to matching case of outer switch } } case op2: { body2; if (cond) { input = inlinedNextOpcode(); switch (markThreadedSwitch(input)) // go to matching case of outer switch } } } } ``` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # @ HostCompilerDirectives.BytecodeInterpreterFetchOpcode [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 25.1. Nested in [`HostCompilerDirectives`](com/oracle/truffle/api/HostCompilerDirectives.md). ```java @Retention(RUNTIME) @Target({METHOD}) public @interface HostCompilerDirectives.BytecodeInterpreterFetchOpcode ``` Annotates a method that fetches the next opcode. The annotated method must be side-effect free, must not throw for valid interpreter state, and share the same signature with [`BytecodeInterpreterHandler`](com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandler.md)-annotated methods in the same enclosing class. It will be inlined into Truffle interpreter bytecode handler stubs to enable tail call threading. # @ HostCompilerDirectives.BytecodeInterpreterHandler [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 25.1. Nested in [`HostCompilerDirectives`](com/oracle/truffle/api/HostCompilerDirectives.md). ```java @Retention(RUNTIME) @Target({METHOD}) public @interface HostCompilerDirectives.BytecodeInterpreterHandler ``` Annotates a method that serves as a Truffle interpreter bytecode handler, that is, a method implements the complete semantics of a single bytecode instruction. For more details, see the [ One Compilation per Bytecode Handler documentation](https://github.com/oracle/graal/blob/master/truffle/docs/OneCompilationPerBytecodeHandler.md). ## Elements ### value() `int[] value()`. The handled bytecode's opcodes. Cite: `com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandler.html#value()` ### threading() `boolean threading() default true`. Indicates whether to enable tail call threading at the end of this handler. If `false`, the threading will terminate, and control will return to the switch-loop after this handler is executed. Alternatively, omitting the `BytecodeInterpreterHandler` annotation will cause control to return to the switch-loop before this handler is executed. Default: `true`. Cite: `com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandler.html#threading()` ### safepoint() `boolean safepoint() default true`. Indicates whether host safepoint should be inserted in the stub correspond to this handler. Default: `true`. Cite: `com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandler.html#safepoint()` # @ HostCompilerDirectives.BytecodeInterpreterHandlerConfig [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 25.1. Nested in [`HostCompilerDirectives`](com/oracle/truffle/api/HostCompilerDirectives.md). ```java @Retention(RUNTIME) @Target({METHOD}) public @interface HostCompilerDirectives.BytecodeInterpreterHandlerConfig ``` Configuration for all bytecode interpreter handler arguments, including the receiver. Must be used in conjunction with [`BytecodeInterpreterSwitch`](com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterSwitch.md). **See also** - [`BytecodeInterpreterHandler`](com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandler.md) ## Nested types - [`HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument`](com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.md) (annotation interface): Configuration for a bytecode interpreter handler argument. ## Elements ### maximumOperationCode() `int maximumOperationCode()`. The maximum unsigned value of the opcode. This is relevant for `BytecodeInterpreterHandler` when tail call threading is enabled, and is used to construct a handler table. Cite: `com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandlerConfig.html#maximumOperationCode()` ### arguments() `HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument[] arguments()`. Configuration for each method argument. For non-static methods, the first element corresponds to the receiver. Cite: `com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandlerConfig.html#arguments()` ### secondarySwitch() `boolean secondarySwitch() default false`. Indicates that the annotated method implements a secondary partition of a bytecode interpreter switch. A secondary switch is expected to be inlined into a primary `BytecodeInterpreterSwitch` method during host compilation. Its handler configuration is retained so that handler calls originating from the inlined secondary switch can be mapped to the primary switch's handler stubs. When compiled as a separate method, however, handler calls in a secondary switch are not outlined. In particular, a deoptimization target may invoke the separately compiled secondary switch without first passing through host inlining. Keeping its handler calls ordinary prevents such execution from entering threaded handler stubs without the primary switch's exception and state-management paths. Returns `boolean`: `true` if the annotated method is a secondary switch partition whose handler calls must not be outlined when the method is compiled separately. Default: `false`. Cite: `com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandlerConfig.html#secondarySwitch()` ### enableTailDuplication() `boolean enableTailDuplication() default false`. Since 25.5. Enables tail duplication for this interpreter's threaded bytecode handler stubs. When enabled, the compiler removes the control-flow anchor at the handler return and encourages duplication of the dispatch tail, allowing different handler paths to have separate indirect tail-call sites. Duplication remains subject to compiler safety checks and code size budgets; enabling this option does not guarantee that a tail will be duplicated. Separate dispatch sites can improve branch prediction, but the additional code can also reduce performance. This option is disabled by default and should only be enabled after measuring the effect on the interpreter's workloads. When disabled, the return anchor is retained and no tail-duplication hint is emitted. This option has no effect on non-threaded stubs, which always retain their return anchor. Default: `false`. Cite: `com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandlerConfig.html#enableTailDuplication()` # @ HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 25.1. Nested in [`HostCompilerDirectives.BytecodeInterpreterHandlerConfig`](com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandlerConfig.md). ```java @Retention(RUNTIME) @Target({METHOD}) public @interface HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument ``` Configuration for a bytecode interpreter handler argument. **See also** - [`BytecodeInterpreterHandler`](com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandler.md) ## Nested types - [`HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.ExpansionKind`](com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.ExpansionKind.md) (enum class): No description. - [`HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.Field`](com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.Field.md) (annotation interface): Configuration for an expanded field. ## Elements ### returnValue() `boolean returnValue() default false`. Indicates that this argument will be updated with the return value of the handler. The interpreter must store the handler result directly back to the logical local represented by this argument. Threaded handler stubs rely on that direct store shape to keep the local consistent when an exception unwinds before the normal return-value update path runs. Default: `false`. Cite: `com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.html#returnValue()` ### expand() `HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.ExpansionKind expand() default NONE`. Indicates that this argument will be expanded in a Truffle interpreter bytecode handler stub if its expansion kind is not `ExpansionKind.NONE`. Default: `NONE`. Cite: `com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.html#expand()` ### expandedType() `Class expandedType() default void.class`. Since 25.5. Exact concrete type reconstructed for a `ExpansionKind.VIRTUAL` argument. `void.class` uses the declared parameter type. An explicit type must be a concrete instance class assignable to the parameter type. It may be defined by a different class loader from the handler's declaring class. At each outlined call, the compiler must prove that the argument is non-null and has this exact type. All instance fields, including inherited fields, are expanded. The expansion type must have at least one instance field. This property is ignored on HotSpot, which uses the declared parameter type. Default: `void.class`. Cite: `com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.html#expandedType()` ### fields() `HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.Field[] fields() default {}`. Indicates the fields to be expanded of this argument if its expansion kind is `ExpansionKind.MATERIALIZED`. Default: `{}`. Cite: `com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.html#fields()` ### nonNull() `boolean nonNull() default true`. Indicates that this argument is always non-null. A null check will be placed before the call site and before threading dispatch. This property is irrelevant for primitive arguments. Default: `true`. Cite: `com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.html#nonNull()` # ≡ HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.ExpansionKind [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Enum class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Nested in [`HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument`](com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.md). ```java public enum HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.ExpansionKind ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html) > `ExpansionKind` ## Enum constants ### NONE `NONE`. No expansion. Cite: `com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.ExpansionKind.html#NONE` ### MATERIALIZED `MATERIALIZED`. The argument is expanded into its subfields in addition to the original argument. Cite: `com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.ExpansionKind.html#MATERIALIZED` ### VIRTUAL `VIRTUAL`. The argument is expanded into its subfields without the original argument. Cite: `com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.ExpansionKind.html#VIRTUAL` ## Methods ### values() `public static HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.ExpansionKind[] values()`. Returns the enum constants in declaration order. Returns `HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.ExpansionKind[]`: Returns the enum constants in declaration order. Cite: `com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.ExpansionKind.html#values()` ### valueOf(String) `public static HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.ExpansionKind valueOf(String name)`. Returns the enum constant with the given name. Parameters: `name` `String`: The exact name of the enum constant. Returns `HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.ExpansionKind`: Returns the enum constant with the given name. Cite: `com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.ExpansionKind.html#valueOf(java.lang.String)` ## Inherited members - From class [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#clone%28%29), [`compareTo`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#compareTo%28E%29), [`describeConstable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#describeConstable%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#finalize%28%29), [`getDeclaringClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#getDeclaringClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#hashCode%28%29), [`name`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#name%28%29), [`ordinal`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#ordinal%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#toString%28%29), [`valueOf`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#valueOf%28java.lang.Class,java.lang.String%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # @ HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.Field [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 25.1. Nested in [`HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument`](com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.md). ```java @Retention(RUNTIME) @Target({METHOD}) public @interface HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.Field ``` Configuration for an expanded field. ## Elements ### name() `String name()`. Name of the field. Cite: `com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.Field.html#name()` ### nonNull() `boolean nonNull() default true`. Indicates that this field is always non-null. A null check will be placed before the call site and before threading dispatch. This property is irrelevant for primitive fields. Default: `true`. Cite: `com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.Field.html#nonNull()` ### templateVariable() `int templateVariable() default 0`. Since 25.5. Marks this field as template state for threaded bytecode handlers. A value of `N >= 2` creates one handler variant for each field value in the range `[0, N)`. A value of `0` disables template specialization for this field, and `1` is invalid. Each variant starts with the corresponding field value. Before control transfers to the next threaded handler, every control-flow path must assign a known valid value or retain the current value. If multiple template fields are updated, their values must be resolved through the same control-flow merge. When threading ends, the current field value is written back to the original argument. When template mode is disabled, the field behaves like an ordinary expanded field. The field must be an `int` field of a `ExpansionKind.VIRTUAL` argument. See the [ template handler documentation](https://github.com/oracle/graal/blob/master/truffle/docs/OneCompilationPerBytecodeHandler.md#template) for examples and additional restrictions. Default: `0`. Cite: `com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.Field.html#templateVariable()` ### validWhen() `String validWhen() default ""`. Since 25.5. Names the template-variable field on the same virtual-expanded argument that controls whether this field's incoming value is valid. An empty name disables conditional validity and requires `valid()` to be empty. Only non-final, non-template `long` or `double` fields of `ExpansionKind.VIRTUAL` arguments support conditional validity. This metadata is ignored on HotSpot and whenever template mode is disabled. Default: `""`. Cite: `com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.Field.html#validWhen()` ### valid() `int[] valid() default {}`. Since 25.5. Values of `validWhen()` for which the incoming field value is valid. Otherwise, the generated handler starts with an arbitrary field value that must not be observed, including through exception-state materialization. The handler may overwrite the field before reading it. This contract applies at handler entry, not to subsequent changes of the template-variable field. This metadata is ignored on HotSpot and whenever template mode is disabled. Default: `{}`. Cite: `com/oracle/truffle/api/HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.Field.html#valid()` # @ HostCompilerDirectives.BytecodeInterpreterSwitch [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 21.0. Nested in [`HostCompilerDirectives`](com/oracle/truffle/api/HostCompilerDirectives.md). ```java @Retention(RUNTIME) @Target({METHOD, CONSTRUCTOR}) public @interface HostCompilerDirectives.BytecodeInterpreterSwitch ``` Marks a method that is an implementation of a Truffle interpreter, and which should receive additional optimization budget. This annotation is used to annotate the root method of a bytecode interpreter, and it hints the compiler to invest extra effort into optimizing such methods. Language implementers are advised to inspect the IR of the interpreter when using this. # @ HostCompilerDirectives.InliningCutoff [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 22.3. Nested in [`HostCompilerDirectives`](com/oracle/truffle/api/HostCompilerDirectives.md). ```java @Retention(RUNTIME) @Target({METHOD, CONSTRUCTOR}) public @interface HostCompilerDirectives.InliningCutoff ``` Hints to Truffle host inlining that a particular method is partial evaluatable, but it would be a good place for a cutoff when performing host inlining. A host compiler may use this information as a hint to take trade-offs optimizing the code. Good examples of cutoffs are: - Methods related to instrumentation or tracing. Instrumentation and tracing are typically not critical for interpreter performance. - Methods raising guest language exceptions. Such paths must often partially evaluate for good peak performance, but are not a priority to optimize during interpreter execution. - Methods related to Truffle interoperability behavior. Such paths are typically only used exceptionally, as the vast majority of code is likely non-interop code. - Methods that are very complex and would only deny other more important methods to be inlined. If a method is already annotated with [`TruffleBoundary`](com/oracle/truffle/api/CompilerDirectives.TruffleBoundary.md) or is dominated by a call to [`transferToInterpreter()`](com/oracle/truffle/api/CompilerDirectives.md#transferToInterpreterAndInvalidate%28%29) then this method has no effect, as any path that is not designed for partial evaluation is already considered a slow-path in hosted inlining. This annotation may be used to tune Truffle hosted inlining decisions. It is useful in cases where the host inliner did not have enough budget to exhaustively inline the entire partial evaluatable fast-path. In such a case it might be worthwhile to annotate rarely executed methods with [`InliningCutoff`](com/oracle/truffle/api/HostCompilerDirectives.InliningCutoff.md) to reduce their priority to make room for more important methods. For more details on host inlining see the [documentation](https://github.com/oracle/graal/blob/master/truffle/docs/HostCompilation.md) # @ HostCompilerDirectives.InliningRoot [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 25.1. Nested in [`HostCompilerDirectives`](com/oracle/truffle/api/HostCompilerDirectives.md). ```java @Retention(RUNTIME) @Target({METHOD, CONSTRUCTOR}) public @interface HostCompilerDirectives.InliningRoot ``` Marks a method as a candidate for Truffle host inlining. The host compiler may use this information to guide inlining and optimization decisions. Annotated methods must be designed for partial evaluation. This annotation should not be applied to arbitrary Java code or third-party libraries, as doing so may cause severe performance degradation. Typical examples include `execute` methods of cached nodes. The Truffle DSL automatically applies this annotation to every generated execute method. It is recommended to be used for manually written `execute` methods as well. For more details, see the [ Truffle host compilation documentation](https://github.com/oracle/graal/blob/master/truffle/docs/HostCompilation.md). # ◆ InstrumentInfo [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 0.26. ```java public final class InstrumentInfo ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `InstrumentInfo` Represents public information about an instrument. ## Methods ### getId() `public String getId()`. Since 0.26. Gets the id clients can use to acquire this instrument. Returns `String`: this instrument's unique id. Cite: `com/oracle/truffle/api/InstrumentInfo.html#getId()` ### getName() `public String getName()`. Since 0.26. Gets a human readable name of this instrument. Returns `String`: this instrument's user-friendly name. Cite: `com/oracle/truffle/api/InstrumentInfo.html#getName()` ### getVersion() `public String getVersion()`. Since 0.26. Gets the version of this instrument. Returns `String`: this instrument's version. Cite: `com/oracle/truffle/api/InstrumentInfo.html#getVersion()` ### toString() `public String toString()`. Since 0.26. Overrides `toString()`. Cite: `com/oracle/truffle/api/InstrumentInfo.html#toString()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ InternalResource [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 23.1. ```java public interface InternalResource ``` Represents an internal resource of a language that can be lazily unpacked to a cache user directory. A typical implementation of an `InternalResource` for a platform-specific library stored in the `META-INF/resources////` looks like this: ```java @InternalResource.Id("resource-id") final class NativeLibResource implements InternalResource { @Override public void unpackFiles(Env env, Path targetDirectory) throws IOException { Path base = Path.of("META-INF", "resources", "mylanguage", "resource-id", env.getOS().toString(), env.getCPUArchitecture().toString()); env.unpackResourceFiles(base.resolve("file-list"), targetDirectory, base); } @Override public String versionHash(Env env) { try { Path hashResource = Path.of("META-INF", "resources", "mylanguage", "resource-id", env.getOS().toString(), env.getCPUArchitecture().toString(), "sha256"); return env.readResourceLines(hashResource).get(0); } catch (IOException ioe) { throw CompilerDirectives.shouldNotReachHere(ioe); } } } ``` The resource files are listed in the `META-INF/resources/////file-list` file. For the file list format, refer to [`InternalResource.unpackFiles(Env, Path)`](com/oracle/truffle/api/InternalResource.md#unpackFiles%28com.oracle.truffle.api.InternalResource.Env,java.nio.file.Path%29). Additionally, the `META-INF/resources/////sha256` file contains an SHA-256 hash of the resource files. It is recommended to use non-encapsulated resource paths that include the component ID and resource ID, as this helps prevent ambiguity when the language or instrument is used in an unnamed module. ## Nested types - [`InternalResource.CPUArchitecture`](com/oracle/truffle/api/InternalResource.CPUArchitecture.md) (enum class): Represents a supported CPU architecture. - [`InternalResource.Env`](com/oracle/truffle/api/InternalResource.Env.md) (class): Access to common utilities for unpacking resource files. - [`InternalResource.Id`](com/oracle/truffle/api/InternalResource.Id.md) (annotation interface): The annotation used to lookup InternalResource by an id. - [`InternalResource.OS`](com/oracle/truffle/api/InternalResource.OS.md) (enum class): Represents a supported operating system. ## Methods ### unpackFiles(InternalResource.Env, Path) `void unpackFiles(InternalResource.Env env, Path targetDirectory) throws IOException`. Since 23.1. Unpacks all resources to a given target directory. The target directory is guaranteed to be writable and the unpacking is synchronized by a file system lock. If a resource was previously cached then `versionHash(Env)` is invoked and the version string is compared. If it matches then `unpackFiles(Env, Path)` will not be invoked and the directory will be used as previously unpacked. The target directory is guaranteed to exist and guaranteed to be empty. Ideally the result of this method should be idempotent in order to be safely cacheable. Care should be taken, if system properties are used that change the result of this method. It is safe to use `OS` and `CPUArchitecture` enums as internal resources are never cached or moved across operating system architectures. No guest language code must run as part of this method. Parameters: `targetDirectory` `Path`: the target directory to extract files to. Cite: `com/oracle/truffle/api/InternalResource.html#unpackFiles(com.oracle.truffle.api.InternalResource.Env,java.nio.file.Path)` ### versionHash(InternalResource.Env) `String versionHash(InternalResource.Env env) throws IOException`. Since 23.1. Returns the version hash to be used for this resource. It is the responsibility of the implementer to ensure that this version hash is unique. For example, an SHA-256 could be a good version identifier for file based resources. Since the version hash serves as a path component on the host filesystem, its length is restricted to a maximum of 128 bytes. If the version hash length exceeds this limit, an `IOException` will be thrown during unpacking. Cite: `com/oracle/truffle/api/InternalResource.html#versionHash(com.oracle.truffle.api.InternalResource.Env)` # ≡ InternalResource.CPUArchitecture [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Enum class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 23.1. Nested in [`InternalResource`](com/oracle/truffle/api/InternalResource.md). ```java public enum InternalResource.CPUArchitecture ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html) > `CPUArchitecture` Represents a supported CPU architecture. ## Enum constants ### AARCH64 `AARCH64`. Since 23.1. The ARMv8 64-bit architecture. Cite: `com/oracle/truffle/api/InternalResource.CPUArchitecture.html#AARCH64` ### AMD64 `AMD64`. Since 23.1. The x86 64-bit architecture. Cite: `com/oracle/truffle/api/InternalResource.CPUArchitecture.html#AMD64` ### UNSUPPORTED `UNSUPPORTED`. Since 25.1. Represents an unsupported architecture. To enable execution on unsupported platforms, the system property `-Dpolyglot.engine.allowUnsupportedPlatform=true` must be explicitly set. If this property is not set and the platform is unsupported, the `getCurrent()` method will throw an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html). Cite: `com/oracle/truffle/api/InternalResource.CPUArchitecture.html#UNSUPPORTED` ## Methods ### values() `public static InternalResource.CPUArchitecture[] values()`. Returns the enum constants in declaration order. Returns `InternalResource.CPUArchitecture[]`: Returns the enum constants in declaration order. Cite: `com/oracle/truffle/api/InternalResource.CPUArchitecture.html#values()` ### valueOf(String) `public static InternalResource.CPUArchitecture valueOf(String name)`. Returns the enum constant with the given name. Parameters: `name` `String`: The exact name of the enum constant. Returns `InternalResource.CPUArchitecture`: Returns the enum constant with the given name. Cite: `com/oracle/truffle/api/InternalResource.CPUArchitecture.html#valueOf(java.lang.String)` ### toString() `public String toString()`. Since 23.1. Returns the string representing CPU architecture name. Overrides `toString()`. Cite: `com/oracle/truffle/api/InternalResource.CPUArchitecture.html#toString()` ### getCurrent() `public static InternalResource.CPUArchitecture getCurrent()`. Since 23.1. Returns the current CPU architecture. Cite: `com/oracle/truffle/api/InternalResource.CPUArchitecture.html#getCurrent()` ## Inherited members - From class [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#clone%28%29), [`compareTo`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#compareTo%28E%29), [`describeConstable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#describeConstable%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#finalize%28%29), [`getDeclaringClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#getDeclaringClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#hashCode%28%29), [`name`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#name%28%29), [`ordinal`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#ordinal%28%29), [`valueOf`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#valueOf%28java.lang.Class,java.lang.String%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ InternalResource.Env [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 23.1. Nested in [`InternalResource`](com/oracle/truffle/api/InternalResource.md). ```java public final class InternalResource.Env ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Env` Access to common utilities for unpacking resource files. ## Methods ### inContextPreinitialization() `public boolean inContextPreinitialization()`. Since 23.1. Returns `true` if the engine causing the resource unpacking is being pre-initialized. Cite: `com/oracle/truffle/api/InternalResource.Env.html#inContextPreinitialization()` ### inNativeImageBuild() `public boolean inNativeImageBuild()`. Since 23.1. Returns `true` if resource unpacking happens during the native image build. Cite: `com/oracle/truffle/api/InternalResource.Env.html#inNativeImageBuild()` ### getCPUArchitecture() `public InternalResource.CPUArchitecture getCPUArchitecture()`. Since 23.1. Returns the current processor architecture. The value can be used to resolve an architecture specific files during resource unpacking. Cite: `com/oracle/truffle/api/InternalResource.Env.html#getCPUArchitecture()` ### getOS() `public InternalResource.OS getOS()`. Since 23.1. Returns the current operating system. The value can be used to resolve an OS specific files during resource unpacking. Cite: `com/oracle/truffle/api/InternalResource.Env.html#getOS()` ### readResourceLines(Path) `public List readResourceLines(Path location) throws IOException`. Since 23.1. Reads a resource from the module, which owns the `InternalResource` implementation class. If the resource is encapsulated in the module, see [`Module.getResourceAsStream(String)`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Module.html#getResourceAsStream%28java.lang.String%29), the module needs to open the `location` enclosing package to the `org.graalvm.truffle` module. It is recommended to use non-encapsulated resource paths. Parameters: `location` `Path`: relative path that identifies the resource in the module. The relative path gets resolved into an absolute path using the archive root. Returns `List`: the lines from the resource as a [`List`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/List.html). Throws: `IOException`: in case of IO error. Cite: `com/oracle/truffle/api/InternalResource.Env.html#readResourceLines(java.nio.file.Path)` ### unpackResourceFiles(Path, Path, …) `public void unpackResourceFiles(Path source, Path target, Path relativizeTo, Predicate filter) throws IOException`. Since 24.2. Extracts files from the module, which owns the `InternalResource` implementation class, listed in the `source` file list and places them into the `target` folder. If resources are encapsulated within the module, see [`Module.getResourceAsStream(String)`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Module.html#getResourceAsStream%28java.lang.String%29), the module needs to open the enclosing package of the resources to the `org.graalvm.truffle` module. It is recommended to use non-encapsulated resource paths. The file list is a [`Java properties`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/Properties.html) file where resource files serve as keys, and the corresponding values consist of serialized attributes separated by `','`. Currently, only the POSIX file permissions attribute is supported. The format of this attribute follows the same convention used by the [`PosixFilePermissions.fromString(String)`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/attribute/PosixFilePermissions.html#fromString%28java.lang.String%29). Example of a file list content: Parameters: `source` `Path`: the relative path that identifies the file list resource in the module. The relative path gets resolved into an absolute path using the archive root. `target` `Path`: the folder to extract resources to. `relativizeTo` `Path`: the path used to relativize the file list entries in the `target` folder. In other words, the file list entries are resolved using the `target` directory after removing the `relativizeTo` path. `filter` `Predicate`: resource path filter. Only resources at resource paths for which the filter predicate returns `true` are unpacked. Throws: `IllegalArgumentException` (unchecked): if `relativizeTo` is an absolute path or file list contains an absolute path. `IOException`: in case of IO error. Cite: `com/oracle/truffle/api/InternalResource.Env.html#unpackResourceFiles(java.nio.file.Path,java.nio.file.Path,java.nio.file.Path,java.util.function.Predicate)` ```java META-INF/resources/darwin/amd64/bin/libtrufflenfi.dylib = rwxr-xr-x META-INF/resources/common/include/trufflenfi.h = rw-r--r-- ``` ### unpackResourceFiles(Path, Path, Path) `public void unpackResourceFiles(Path source, Path target, Path relativizeTo) throws IOException`. Since 23.1. Extracts files from the module, which owns the `InternalResource` implementation class, listed in the `source` file list and places them into the `target` folder. Same as `unpackResourceFiles(Path, Path, Path, Predicate)` with `filter = p -> true`. See also: `unpackResourceFiles(Path, Path, Path, Predicate)`. Cite: `com/oracle/truffle/api/InternalResource.Env.html#unpackResourceFiles(java.nio.file.Path,java.nio.file.Path,java.nio.file.Path)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # @ InternalResource.Id [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 23.1. Nested in [`InternalResource`](com/oracle/truffle/api/InternalResource.md). ```java @Retention(RUNTIME) @Target({TYPE}) public @interface InternalResource.Id ``` The annotation used to lookup [`InternalResource`](com/oracle/truffle/api/InternalResource.md) by an id. The internal resource can be designated as either required or optional. For required internal resources, their availability is imperative. In addition to being annotated with this annotation, they also need to be registered using the [`TruffleLanguage.Registration.internalResources()`](com/oracle/truffle/api/TruffleLanguage.Registration.md#internalResources%28%29) method to be associated with a specific language or instrument. On the other hand, optional internal resources are not mandatory in the runtime. Instead of being registered using the [`TruffleLanguage.Registration.internalResources()`](com/oracle/truffle/api/TruffleLanguage.Registration.md#internalResources%28%29) annotation, they should supply the relevant language or instrument id through [`Id.componentId()`](com/oracle/truffle/api/InternalResource.Id.md#componentId%28%29). ## Elements ### value() `String value()`. Since 23.1. An internal resource identifier that is a valid path component and unique per language. Cite: `com/oracle/truffle/api/InternalResource.Id.html#value()` ### componentId() `String componentId() default ""`. Since 23.1. A Truffle language or instrument identifier for which the resource is registered. The `componentId` is necessary only for optional internal resources to associate them with the appropriate language or instrument. For required internal resources, the `componentId` can be left unset. Default: `""`. Cite: `com/oracle/truffle/api/InternalResource.Id.html#componentId()` ### optional() `boolean optional() default false`. Since 23.1. Marks the annotated resource as optional. By default, internal resources are considered required and must be registered using `TruffleLanguage.Registration` or `TruffleInstrument.Registration`. Optional internal resources are retrieved using the [`java.util.ServiceLoader`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/ServiceLoader.html) mechanism. The service implementation is generated by an annotation processor. Therefore, for proper functionality, the Truffle DSL processor must be included in the processor path. Default: `false`. Cite: `com/oracle/truffle/api/InternalResource.Id.html#optional()` # ≡ InternalResource.OS [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Enum class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 23.1. Nested in [`InternalResource`](com/oracle/truffle/api/InternalResource.md). ```java public enum InternalResource.OS ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html) > `OS` Represents a supported operating system. ## Enum constants ### DARWIN `DARWIN`. Since 23.1. The macOS operating system. Cite: `com/oracle/truffle/api/InternalResource.OS.html#DARWIN` ### LINUX `LINUX`. Since 23.1. The Linux operating system. Cite: `com/oracle/truffle/api/InternalResource.OS.html#LINUX` ### WINDOWS `WINDOWS`. Since 23.1. The Windows operating system. Cite: `com/oracle/truffle/api/InternalResource.OS.html#WINDOWS` ### UNSUPPORTED `UNSUPPORTED`. Since 25.1. Represents an unsupported operating system. To enable execution on unsupported platforms, the system property `-Dpolyglot.engine.allowUnsupportedPlatform=true` must be explicitly set. If this property is not set and the platform is unsupported, the `getCurrent()` method will throw an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html). Cite: `com/oracle/truffle/api/InternalResource.OS.html#UNSUPPORTED` ## Methods ### values() `public static InternalResource.OS[] values()`. Returns the enum constants in declaration order. Returns `InternalResource.OS[]`: Returns the enum constants in declaration order. Cite: `com/oracle/truffle/api/InternalResource.OS.html#values()` ### valueOf(String) `public static InternalResource.OS valueOf(String name)`. Returns the enum constant with the given name. Parameters: `name` `String`: The exact name of the enum constant. Returns `InternalResource.OS`: Returns the enum constant with the given name. Cite: `com/oracle/truffle/api/InternalResource.OS.html#valueOf(java.lang.String)` ### toString() `public String toString()`. Since 23.1. Returns the string representing operating system name. Overrides `toString()`. Cite: `com/oracle/truffle/api/InternalResource.OS.html#toString()` ### getCurrent() `public static InternalResource.OS getCurrent()`. Since 23.1. Returns the current operating system. Cite: `com/oracle/truffle/api/InternalResource.OS.html#getCurrent()` ## Inherited members - From class [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#clone%28%29), [`compareTo`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#compareTo%28E%29), [`describeConstable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#describeConstable%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#finalize%28%29), [`getDeclaringClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#getDeclaringClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#hashCode%28%29), [`name`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#name%28%29), [`ordinal`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#ordinal%28%29), [`valueOf`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#valueOf%28java.lang.Class,java.lang.String%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ⚡︎ OptimizationFailedException [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Exception in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 0.8 or earlier. ```java public class OptimizationFailedException extends RuntimeException ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) > [`Exception`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Exception.html) > [`RuntimeException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/RuntimeException.html) > `OptimizationFailedException` ## Constructors ### OptimizationFailedException(Throwable, RootCallTarget) `public OptimizationFailedException(Throwable cause, RootCallTarget callTarget)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/OptimizationFailedException.html#(java.lang.Throwable,com.oracle.truffle.api.RootCallTarget)` ## Methods ### getCallTarget() `public RootCallTarget getCallTarget()`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/OptimizationFailedException.html#getCallTarget()` ## Inherited members - From class [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html): [`addSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#addSuppressed%28java.lang.Throwable%29), [`fillInStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#fillInStackTrace%28%29), [`getCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getCause%28%29), [`getLocalizedMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getLocalizedMessage%28%29), [`getMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getMessage%28%29), [`getStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getStackTrace%28%29), [`getSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getSuppressed%28%29), [`initCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#initCause%28java.lang.Throwable%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintStream%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintWriter%29), [`setStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#setStackTrace%28java.lang.StackTraceElement[]%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # @ Option [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 0.27. ```java @Retention(CLASS) @Target({FIELD}) public @interface Option ``` Describes the attributes of an option whose [`value`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/options/OptionKey.html) is in a static field annotated by this annotation. If used in a class then a package-protected class following the name pattern `$classNameOptionDescriptors` is generated. The generated class implements [`OptionDescriptors`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/options/OptionDescriptors.html) and contains all options specified by the declaring class. If the [`Option`](com/oracle/truffle/api/Option.md) annotation is used in a subclass of [`TruffleLanguage`](com/oracle/truffle/api/TruffleLanguage.md) or [`com.oracle.truffle.api.instrumentation.TruffleInstrument`](com/oracle/truffle/api/instrumentation/TruffleInstrument.md) then the option descriptor prefix is automatically inherited from the [`language id`](com/oracle/truffle/api/TruffleLanguage.Registration.md#id%28%29) or the [`instrument id`](com/oracle/truffle/api/instrumentation/TruffleInstrument.Registration.md#id%28%29). If the class is not a language or an instrument then the [`Option.Group`](com/oracle/truffle/api/Option.Group.md) annotation can be used on the class to specify a option group name prefix. The [`option descriptor name`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/options/OptionDescriptor.html#getName%28%29) is generated from the [`group name`](com/oracle/truffle/api/Option.Group.md#value%28%29) and the [`option name`](com/oracle/truffle/api/Option.md#name%28%29) separated by `'.'`. If the option name is an empty [`String`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html) then the trailing `'.'` will be removed from the descriptor name such that it exactly matches the group name. If, for example, the option group is `'js'` and the option name is inherited from the field name `'ECMACompatibility'` then the full descriptor name is `'js.ECMACompatibility'`. **Example usage:** ```java @TruffleLanguage.Registration(id = "mylang", name = "My Language", version = "1.0") abstract static class MyLanguage extends TruffleLanguage { // the descriptor name for MyOption1 is 'mylang.MyOption1' @Option(help = "Help Text.", category = OptionCategory.USER, stability = OptionStability.STABLE) static final OptionKey MyOption1 = new OptionKey<>(""); // the descriptor name for SecondOption is 'mylang.secondOption' @Option(help = "Help Text.", name = "secondOption", category = OptionCategory.EXPERT, stability = OptionStability.EXPERIMENTAL) static final OptionKey SecondOption = new OptionKey<>(false); @Override protected Context createContext(TruffleLanguage.Env env) { if (env.getOptions().get(SecondOption)) { // options are available via environment } return null; } @Override protected OptionDescriptors getOptionDescriptors() { // this class is generated by the annotation processor return new MyLanguageOptionDescriptors(); } } ``` . **See also** - [`OptionDescriptor`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/options/OptionDescriptor.html) - [`Option.Group`](com/oracle/truffle/api/Option.Group.md) ## Nested types - [`Option.Group`](com/oracle/truffle/api/Option.Group.md) (annotation interface): Must be applied on classes containing option fields to specify a name prefix if the prefix cannot be inferred by language or instrument. ## Elements ### name() `String name() default ""`. Since 0.27. Returns a custom name for the option. If not specified then the name of the annotated field is used. The [`option descriptor name`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/options/OptionDescriptor.html#getName%28%29) is generated from the `group name` and the `option name` separated by `'.'`. If the option name is an empty [`String`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html) then the trailing `'.'` will be removed from the descriptor name such that it exactly matches the group name. If, for example, the option group is `'js'` and the option name is inherited from the field name `'ECMACompatibility'` then the full descriptor name is `'js.ECMACompatibility'`. Default: `""`. Cite: `com/oracle/truffle/api/Option.html#name()` ### help() `String help()`. Since 0.27. Returns a help message for the option. New lines can be embedded in the message with `"%n"`. The generated an option descriptor returns this value as result of [`OptionDescriptor.getHelp()`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/options/OptionDescriptor.html#getHelp%28%29). Recommendation: Include the default value for the option and the end of the text, e.g. `"Enable or disable the option (default: true)."`. Cite: `com/oracle/truffle/api/Option.html#help()` ### deprecated() `boolean deprecated() default false`. Since 0.27. Returns `true` if this option is deprecated. The generated option descriptor returns this value as result of [`OptionDescriptor.isDeprecated()`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/options/OptionDescriptor.html#isDeprecated%28%29). Default: `false`. Cite: `com/oracle/truffle/api/Option.html#deprecated()` ### deprecationMessage() `String deprecationMessage() default ""`. Since 20.1.0. Returns the deprecation reason and the recommended fix. The generated option descriptor returns this value as result of [`OptionDescriptor.getDeprecationMessage()`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/options/OptionDescriptor.html#getDeprecationMessage%28%29). Default: `""`. Cite: `com/oracle/truffle/api/Option.html#deprecationMessage()` ### category() `OptionCategory category()`. Since 0.27. Specifies the category of the option. The generated option descriptor returns this value as result of [`OptionDescriptor.getCategory()`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/options/OptionDescriptor.html#getCategory%28%29). Cite: `com/oracle/truffle/api/Option.html#category()` ### stability() `OptionStability stability() default EXPERIMENTAL`. Since 19.0. Defines the stability of this option. The default value is [`OptionStability.EXPERIMENTAL`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/options/OptionStability.html#EXPERIMENTAL). Default: `EXPERIMENTAL`. Cite: `com/oracle/truffle/api/Option.html#stability()` ### usageSyntax() `String usageSyntax() default ""`. Since 22.1. Describes in short the syntax of accepted values for this option. This value is used when generating help messages to better explain how to use the option. Combine with the help message to illustrate to users how to correctly use the option. For example: Recommendations: if the option accepts a discrete number of values (e.g. boolean, enum) list the values separated by a '\|' character. The default value for enums should be placed as the first in the list. e.g. `"true|false"`, `"none|red|green|blue|white"`; if the options accepts a value representing a well-known concept or a number representing particular units, place that concept/unit between \< and \> e.g. `""`, `""`, `""`, `"<>"`; if the options accepts a range of numbers use the range syntax: \[a,b\] for inclusive range from a to b, (a, b) for exclusive range from a to b, \[a, b) for range from a to b including a and (a, b\] for range from a to b including b. If the range is infinite use inf and -inf. For example: `"[0, 100]"`, `"(0.0, 1.0)"`, `"[0, inf)`.; if the options accepts a comma-separated list, use two comma-separated values and a `...`. Apply these same recommendations to individual values, e.g. `",,..."`.; if the options accepts a custom format, describe the format in a generic manner e.g. ip address - `"*.*.*.*"`, CSV Person - `",,"`. Default: `""`. Cite: `com/oracle/truffle/api/Option.html#usageSyntax()` ```java @Option(name = "Enabled", help = "Enable/Disable the option.", usageSyntax = "true|false") ``` ### sandbox() `SandboxPolicy sandbox() default TRUSTED`. Since 23.0. Specifies the most strict sandbox policy in which the option can be used. The option can be used for an engine/context with the specified sandbox policy or a weaker one. For example, if an option specifies `ISOLATED` policy, it can be used for an engine/context configured with sandbox policy `TRUSTED`, `CONSTRAINED` or `ISOLATED`. But it cannot be used for an engine/context configured with the `UNTRUSTED` sandbox policy. Default: `TRUSTED`. See also: [`SandboxPolicy`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/SandboxPolicy.html). Cite: `com/oracle/truffle/api/Option.html#sandbox()` ### constant() `boolean constant() default false`. Since 25.1. Declares this option as immutable after polyglot runtime initialization, enabling constant propagation and dead-code elimination when read through [`org.graalvm.options.ConstantOptionKey.getConstantValue()`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/options/ConstantOptionKey.html#getConstantValue%28%29). Constant options must use [`org.graalvm.options.ConstantOptionKey`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/options/ConstantOptionKey.html) as their field type. Their value is fixed before the polyglot runtime is initialized and cannot be changed at runtime. The value is read from the system property `-Dpolyglot.=` during class initialization; if absent, the [`default value`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/options/OptionKey.html#getDefaultValue%28%29) is used. Once set, calls to [`org.graalvm.options.ConstantOptionKey.getConstantValue()`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/options/ConstantOptionKey.html#getConstantValue%28%29) on a `static final` field are eligible for constant folding by the GraalVM compiler, allowing dead branches to be eliminated. The default value is `false`. Default: `false`. See also: [`org.graalvm.options.ConstantOptionKey`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/options/ConstantOptionKey.html). Cite: `com/oracle/truffle/api/Option.html#constant()` # @ Option.Group [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 0.27. Nested in [`Option`](com/oracle/truffle/api/Option.md). ```java @Retention(CLASS) @Target({TYPE}) public @interface Option.Group ``` Must be applied on classes containing [`option`](com/oracle/truffle/api/Option.md) fields to specify a name prefix if the prefix cannot be inferred by language or instrument. The [`option descriptor name`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/options/OptionDescriptor.html#getName%28%29) is generated from the [`option name prefix`](com/oracle/truffle/api/Option.Group.md#value%28%29) and the [`option name`](com/oracle/truffle/api/Option.md#name%28%29) separated by `'.'`. If the option name is an empty [`String`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html) then the trailing `'.'` will be removed from the descriptor name. ## Elements ### value() `String[] value()`. Since 0.27. A set of group names that are used as prefix for all options of the annotated class. If multiple group names are specified then descriptors for each combination of group and option name is generated. The [`option descriptor name`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/options/OptionDescriptor.html#getName%28%29) is generated from the `group name` and the `option name` separated by `'.'`. If the option name is an empty [`String`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html) then the trailing `'.'` will be removed from the descriptor name such that it exactly matches the group name. If, for example, the option group is `'js'` and the option name is inherited from the field name `'ECMACompatibility'` then the full descriptor name is `'js.ECMACompatibility'`. Cite: `com/oracle/truffle/api/Option.Group.html#value()` # ◇ ReplaceObserver [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 0.8 or earlier. ```java public interface ReplaceObserver ``` An observer that is notified whenever a child node is replaced. Note this is **not** called if the RootNode does not have a CallTarget yet. ## Methods ### nodeReplaced(Node, Node, CharSequence) `boolean nodeReplaced(Node oldNode, Node newNode, CharSequence reason)`. Since 0.8 or earlier. Returns `true` if the event is consumed and no parent nodes should be notified by for replaces. Returns `false` if the parent `Node` or `CallTarget` should get notified. Cite: `com/oracle/truffle/api/ReplaceObserver.html#nodeReplaced(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence)` # ◇ RootCallTarget [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 0.8 or earlier. ```java public interface RootCallTarget extends CallTarget ``` Extends: [`CallTarget`](com/oracle/truffle/api/CallTarget.md) Represents the target of a call to a [`RootNode`](com/oracle/truffle/api/nodes/RootNode.md), i.e., to another tree of nodes. Instances of this class are created lazily and can be accessed via [`RootNode.getCallTarget()`](com/oracle/truffle/api/nodes/RootNode.md#getCallTarget%28%29). ## Methods ### getRootNode() `RootNode getRootNode()`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/RootCallTarget.html#getRootNode()` ## Inherited members - From interface [`CallTarget`](com/oracle/truffle/api/CallTarget.md): [`call`](com/oracle/truffle/api/CallTarget.md#call%28com.oracle.truffle.api.nodes.Node,int,java.lang.Object[]%29), [`call`](com/oracle/truffle/api/CallTarget.md#call%28com.oracle.truffle.api.nodes.Node,java.lang.Object...%29), [`call`](com/oracle/truffle/api/CallTarget.md#call%28java.lang.Object...%29) # ◆ ThreadLocalAction [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 21.1. ```java public abstract class ThreadLocalAction ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `ThreadLocalAction` Represents an action that is executed at a [`safepoint`](com/oracle/truffle/api/TruffleSafepoint.md) location of the guest language execution. Thread local actions can be submitted by [`languages`](com/oracle/truffle/api/TruffleLanguage.Env.md#submitThreadLocal%28java.lang.Thread[],com.oracle.truffle.api.ThreadLocalAction%29) or [`instruments`](com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.md#submitThreadLocal%28com.oracle.truffle.api.TruffleContext,java.lang.Thread[],com.oracle.truffle.api.ThreadLocalAction%29). When an action is submitted it will be [`performed`](com/oracle/truffle/api/ThreadLocalAction.md#perform%28com.oracle.truffle.api.ThreadLocalAction.Access%29) locally on the threads they are submitted to. After submitting a thread local action a [`Future`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/Future.html) is returned that allows to wait for and cancel the submitted action. Thread local actions can be configured to allow side-effects using the constructor of the action. If side-effects are allowed (`true`), then the thread-local action is allowed to throw non-internal guest language exceptions from the action and modify the observable guest application state. Otherwise, the action is not allowed to modify the observable state, and any non-internal guest language exception will be transformed to an internal error of type [`AssertionError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AssertionError.html). Side-effects may be temporarily [`disabled`](com/oracle/truffle/api/TruffleSafepoint.md#setAllowSideEffects%28boolean%29) by the guest language. Thread local actions can also be set to be executed in a synchronous or asynchronous way. A submitted synchronous thread-local action waits until it is started on all threads that it was submitted on. Then the action is [`performed`](com/oracle/truffle/api/ThreadLocalAction.md#perform%28com.oracle.truffle.api.ThreadLocalAction.Access%29) on all threads. After they were performed on a thread, the action waits for all threads to complete. No synchronous thread-local actions can be submitted while performing synchronous actions, as this may lead to deadlocks. If a synchronous event is submitted during a synchronous event, then a [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) is thrown when the action is submitted. Asynchronous thread-local actions might start and complete to perform independently of each other. There is no restriction on how they may be submitted. Thread local actions are guaranteed to be executed in the same order as they were submitted for a context. If a context has pending thread-local actions, the actions may be canceled when the context is canceled or closed invalid. Exceptions thrown by the action will be forwarded handled by the guest language implementation. The only exception is for truffle exceptions that are thrown for non-side-effecting events. Notifications of blocking: [`notifyBlocked(Access)`](com/oracle/truffle/api/ThreadLocalAction.md#notifyBlocked%28com.oracle.truffle.api.ThreadLocalAction.Access%29) and [`notifyUnblocked(Access)`](com/oracle/truffle/api/ThreadLocalAction.md#notifyUnblocked%28com.oracle.truffle.api.ThreadLocalAction.Access%29) notify thread local actions that their processing has been blocked/unblocked due to [`a blocked call`](com/oracle/truffle/api/TruffleSafepoint.md#setBlockedFunction%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.TruffleSafepoint.Interrupter,com.oracle.truffle.api.TruffleSafepoint.InterruptibleFunction,T,java.lang.Runnable,java.util.function.Consumer%29). [`notifyBlocked(Access)`](com/oracle/truffle/api/ThreadLocalAction.md#notifyBlocked%28com.oracle.truffle.api.ThreadLocalAction.Access%29) is called for each pending action at the beginning of a blocked call and for each of the continuations of the blocked call after it is interrupted and thread local actions are processed. [`ThreadLocalAction.notifyUnblocked(Access)`](com/oracle/truffle/api/ThreadLocalAction.md#notifyUnblocked%28com.oracle.truffle.api.ThreadLocalAction.Access%29) is called for each pending action at the end of a blocked call and also right after each of its interruptions, before thread local actions are processed and the blocked call continues. In case a thread local action is submitted during a blocked call, the call is interrupted and [`notifyUnblocked(Access)`](com/oracle/truffle/api/ThreadLocalAction.md#notifyUnblocked%28com.oracle.truffle.api.ThreadLocalAction.Access%29) is called without a previous call to [`notifyBlocked(Access)`](com/oracle/truffle/api/ThreadLocalAction.md#notifyBlocked%28com.oracle.truffle.api.ThreadLocalAction.Access%29). Recurring thread local actions do not repeatedly interrupt a blocked call - a blocked call is not interrupted if all pending actions are recurring actions submitted before the blocked call. New submissions of thread local actions still interrupt blocked calls, no matter if the new thread local actions are recurring or not. When a blocked call is interrupted, all pending actions are processed no matter if they are recurring or not. The notifications of blocking are especially useful for recurring thread local actions as those actions don't interrupt blocked calls and the notifications inform them about the potentially long time intervals when those actions are not executed due to the blocked calls. Non-recurring thread local actions mainly benefit from the [`ThreadLocalAction.notifyUnblocked(Access)`](com/oracle/truffle/api/ThreadLocalAction.md#notifyUnblocked%28com.oracle.truffle.api.ThreadLocalAction.Access%29) notification telling them that they interrupted a blocked call. For example, a safepoint sampler might want to exclude the samples from blocked calls. Example Usage: ```java Env env; // language or instrument environment env.submitThreadLocal(null, new ThreadLocalAction(true, true) { @Override protected void perform(Access access) { assert access.getThread() == Thread.currentThread(); } @Override protected void notifyBlocked(Access access) { assert access.getThread() == Thread.currentThread(); } @Override protected void notifyUnblocked(Access access) { assert access.getThread() == Thread.currentThread(); } @Override protected String name() { return "MyAction" } }); ``` Further information can be found in the [safepoint tutorial](http://github.com/oracle/graal/blob/master/truffle/docs/Safepoints.md). **See also** - [`TruffleSafepoint`](com/oracle/truffle/api/TruffleSafepoint.md) - [`TruffleLanguage.Env.submitThreadLocal`](com/oracle/truffle/api/TruffleLanguage.Env.md#submitThreadLocal%28java.lang.Thread[],com.oracle.truffle.api.ThreadLocalAction%29) - [`com.oracle.truffle.api.instrumentation.TruffleInstrument.Env.submitThreadLocal`](com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.md#submitThreadLocal%28com.oracle.truffle.api.TruffleContext,java.lang.Thread[],com.oracle.truffle.api.ThreadLocalAction%29) ## Nested types - [`ThreadLocalAction.Access`](com/oracle/truffle/api/ThreadLocalAction.Access.md) (abstract class): Argument class for ThreadLocalAction.perform(Access). ## Constructors ### ThreadLocalAction(boolean, boolean) `protected ThreadLocalAction(boolean hasSideEffects, boolean synchronous)`. Since 21.1. Creates a new thread local action. Parameters: `hasSideEffects` `boolean`: true if the event may have side-effects else false. `synchronous` `boolean`: true if the event should run synchronous else the event will run asynchronous. See also: `ThreadLocalAction`. Cite: `com/oracle/truffle/api/ThreadLocalAction.html#(boolean,boolean)` ### ThreadLocalAction(boolean, boolean, boolean) `protected ThreadLocalAction(boolean hasSideEffects, boolean synchronous, boolean recurring)`. Since 21.1. Creates a new thread local action. Parameters: `hasSideEffects` `boolean`: true if the event may have side-effects else false. `synchronous` `boolean`: true if the event should run synchronous else the event will run asynchronous. `recurring` `boolean`: true if the event should be rescheduled until cancelled, else false. See also: `ThreadLocalAction`. Cite: `com/oracle/truffle/api/ThreadLocalAction.html#(boolean,boolean,boolean)` ## Methods ### perform(ThreadLocalAction.Access) `protected abstract void perform(ThreadLocalAction.Access access)`. Since 21.1. Performs the thread local action on a given thread. Parameters: `access` `ThreadLocalAction.Access`: allows access to the current thread and the current code location. See also: `ThreadLocalAction`. Cite: `com/oracle/truffle/api/ThreadLocalAction.html#perform(com.oracle.truffle.api.ThreadLocalAction.Access)` ### notifyBlocked(ThreadLocalAction.Access) `protected void notifyBlocked(ThreadLocalAction.Access access)`. Since 24.2. Callback for notifying the thread local action that its processing has been blocked due to `a blocked call`. Parameters: `access` `ThreadLocalAction.Access`: allows access to the current thread and the current code location. See also: `ThreadLocalAction`. Cite: `com/oracle/truffle/api/ThreadLocalAction.html#notifyBlocked(com.oracle.truffle.api.ThreadLocalAction.Access)` ### notifyUnblocked(ThreadLocalAction.Access) `protected void notifyUnblocked(ThreadLocalAction.Access access)`. Since 24.2. Callback for notifying the thread local action that its processing has been unblocked during or while leaving `a blocked call`. Parameters: `access` `ThreadLocalAction.Access`: allows access to the current thread and the current code location. See also: `ThreadLocalAction`. Cite: `com/oracle/truffle/api/ThreadLocalAction.html#notifyUnblocked(com.oracle.truffle.api.ThreadLocalAction.Access)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ ThreadLocalAction.Access [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 21.1. Nested in [`ThreadLocalAction`](com/oracle/truffle/api/ThreadLocalAction.md). ```java public abstract static class ThreadLocalAction.Access ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Access` Argument class for [`ThreadLocalAction.perform(Access)`](com/oracle/truffle/api/ThreadLocalAction.md#perform%28com.oracle.truffle.api.ThreadLocalAction.Access%29). ## Constructors ### Access(Object) `protected Access(Object secret)`. Since 23.1. Constructor for framework use only. Cite: `com/oracle/truffle/api/ThreadLocalAction.Access.html#(java.lang.Object)` ### Access(AbstractPolyglotImpl) `protected Access(AbstractPolyglotImpl secret)`. Since 21.1. Constructor for framework use only. Cite: `com/oracle/truffle/api/ThreadLocalAction.Access.html#(org.graalvm.polyglot.impl.AbstractPolyglotImpl)` ## Methods ### getLocation() `public abstract Node getLocation()`. Since 21.1. Returns the current node location executing on this thread. The return value is guaranteed to be non-null. Cite: `com/oracle/truffle/api/ThreadLocalAction.Access.html#getLocation()` ### getThread() `public abstract Thread getThread()`. Since 21.1. Returns the thread where this thread local action is running on. Currently this always returns [`Thread.currentThread()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Thread.html#currentThread%28%29). See the [safepoint tutorial](http://github.com/oracle/graal/blob/master/truffle/docs/Safepoints.md) for further details on our plans. Cite: `com/oracle/truffle/api/ThreadLocalAction.Access.html#getThread()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ Truffle [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 0.8 or earlier. ```java public final class Truffle ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Truffle` Class for obtaining the Truffle runtime singleton object of this virtual machine. ## Methods ### getRuntime() `public static TruffleRuntime getRuntime()`. Since 0.8 or earlier. Gets the singleton `TruffleRuntime` object. Cite: `com/oracle/truffle/api/Truffle.html#getRuntime()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleContext [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 0.27. ```java public final class TruffleContext implements AutoCloseable ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `TruffleContext` Implements: [`AutoCloseable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AutoCloseable.html) A handle on a context of a set of Truffle languages. This context handle is designed to be used by Truffle guest language implementations. The Truffle context can be used to create inner contexts for isolated execution of guest language code. A [`context`](com/oracle/truffle/api/TruffleContext.md) consists of a [`language context`](com/oracle/truffle/api/TruffleLanguage.md#createContext%28com.oracle.truffle.api.TruffleLanguage.Env%29) instance for each [`installed language`](com/oracle/truffle/api/TruffleLanguage.Env.md#getInternalLanguages%28%29). The current language context is [`created`](com/oracle/truffle/api/TruffleLanguage.md#createContext%28com.oracle.truffle.api.TruffleLanguage.Env%29) eagerly and can be accessed using a [`context reference`](com/oracle/truffle/api/TruffleLanguage.ContextReference.md) after the context was [`entered`](com/oracle/truffle/api/TruffleContext.md#enter%28com.oracle.truffle.api.nodes.Node%29). The configuration for each language context is inherited from its parent/creator context. In addition to that [`config`](com/oracle/truffle/api/TruffleContext.Builder.md#config%28java.lang.String,java.lang.Object%29) parameters can be passed to new language context instance of the current language. The configuration of other installed languages cannot be modified. To run guest language code in a context, the context needs to be first [`entered`](com/oracle/truffle/api/TruffleContext.md#enter%28com.oracle.truffle.api.nodes.Node%29) and then [`left`](com/oracle/truffle/api/TruffleContext.md#leave%28com.oracle.truffle.api.nodes.Node,java.lang.Object%29). The context should be [`closed`](com/oracle/truffle/api/TruffleContext.md#close%28%29) when it is no longer needed. If the context is not closed explicitly, then it is automatically closed together with the parent context. Example usage: ```java final class MyNode extends Node { void executeInContext(Env env) { MyContext outerLangContext = getContext(this); TruffleContext innerContext = env.newInnerContextBuilder(). initializeCreatorContext(true).build(); Object p = innerContext.enter(this); try { /* * Here the this node cannot be passed otherwise an * invalid sharing error would occur. */ MyContext innerLangContext = getContext(null); assert outerLangContext != innerLangContext; } finally { innerContext.leave(this, p); } assert outerLangContext == getContext(this); innerContext.close(); } } private static ContextReference REFERENCE = ContextReference.create(MyLanguage.class); private static MyContext getContext(Node node) { return REFERENCE.get(node); } ``` ## Nested types - [`TruffleContext.Builder`](com/oracle/truffle/api/TruffleContext.Builder.md) (class): Builder class to create new TruffleContext instances. ## Methods ### equals(Object) `public boolean equals(Object obj)`. Since 20.3. Overrides `equals(java.lang.Object)`. Cite: `com/oracle/truffle/api/TruffleContext.html#equals(java.lang.Object)` ### hashCode() `public int hashCode()`. Since 20.3. Overrides `hashCode()`. Cite: `com/oracle/truffle/api/TruffleContext.html#hashCode()` ### getParent() `public TruffleContext getParent()`. Since 0.30. Get a parent context of this context, if any. This provides the hierarchy of inner contexts. Returns `TruffleContext`: a parent context, or `null` if there is no parent. Cite: `com/oracle/truffle/api/TruffleContext.html#getParent()` ### enter(Node) `public Object enter(Node node)`. Since 20.3. Enters this context and returns an object representing the previous context. Calls to enter must be followed by a call to `leave(Node, Object)` in a finally block and the previous context must be passed as an argument. It is allowed to enter a context multiple times from the same thread. If the context is currently not entered by any thread then it is allowed be entered by an arbitrary thread. Entering the context from two or more different threads at the same time is possible, unless one of the loaded languages denies access to the thread, in which case an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) is thrown. If the current thread was not previously entered in any context, the enter function returns `null`. If the return value is not `null`, the result of the enter function is unspecified and must only be passed to `leave(Node, Object)`. The result value must not be stored permanently. An adopted node may be passed to allow perform optimizations on the fast-path. If a `null` node is passed then entering a context will result in a `boundary` call in compiled code. If the provided node is not adopted an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. Entering a language context is designed for compilation and is most efficient if the `context` instance is compilation final. Example usage: `TruffleContextSnippets.MyNode.executeInContext`. See also: `leave(Node, Object)`. Cite: `com/oracle/truffle/api/TruffleContext.html#enter(com.oracle.truffle.api.nodes.Node)` ### initializeInternal(Node, String) `public boolean initializeInternal(Node node, String languageId)`. Since 22.3. Forces initialization of an internal or public language. If the context is not an inner context and e.g. accessed using `Env.getContext()` an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) is thrown. In such a case `Env.initializeLanguage(LanguageInfo)` should be used instead to initialize contexts. No context or the parent creator context must be entered to initialize languages in a `TruffleContext` otherwise an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) will be thrown. Parameters: `node` `Node`: a partial evaluation constant node context used to optimize this operation. Can be `null` if not available. `languageId` `String`: the id of the language to initialize. Returns `boolean`: `true` if the language was initialized, else `false`, e.g. if the language as already initialized. Throws: `IllegalStateException` (unchecked): if an invalid context is entered or the context is already closed. `IllegalArgumentException` (unchecked): if the given language of the source cannot be accessed. Cite: `com/oracle/truffle/api/TruffleContext.html#initializeInternal(com.oracle.truffle.api.nodes.Node,java.lang.String)` ### initializePublic(Node, String) `public boolean initializePublic(Node node, String languageId)`. Since 22.3. The same as `initializeInternal(Node, String)`, but only public languages are accessible. Parameters: `node` `Node`: a partial evaluation constant node context used to optimize this operation. Can be `null` if not available. `languageId` `String`: the id of the language to initialize. Returns `boolean`: `true` if the language was initialized, else `false`, e.g. if the language as already initialized. Throws: `IllegalStateException` (unchecked): if an invalid context is entered or the context is already closed. `IllegalArgumentException` (unchecked): if the given language of the source cannot be accessed. Cite: `com/oracle/truffle/api/TruffleContext.html#initializePublic(com.oracle.truffle.api.nodes.Node,java.lang.String)` ### evalInternal(Node, Source) `public Object evalInternal(Node node, Source source)`. Since 21.3. Evaluates a source in an inner context and returns the result. If the context is not an inner context and e.g. accessed using `Env.getContext()` an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) is thrown. In such a case `Env.parseInternal(Source, String...)` should be used instead to evaluate sources. No context or the parent creator context must be entered to evaluate sources in a `TruffleContext` otherwise an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) will be thrown. In order to ensure that all values are accessed from their respective contexts only, any non-primitive value returned by the evaluation will be wrapped and enter this context for each interop message sent. Parameters to interop messages will enter and leave the parent context when they are accessed. If the result is a primitive value, then the value is directly returned. This method has access to all public and internal languages the creator context has access to. This corresponds to the set of languages returned by `Env.getInternalLanguages()`. If a language cannot be accessed then an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. If a language is not yet initialized in the inner context, it will get automatically initialized. This method is designed to be used in compiled code paths. This method may be used from multiple threads at the same time. The result of this method must not be cached, instead the `Source` object should be cached. Parameters: `node` `Node`: a partial evaluation constant node context used to optimize this operation. Can be `null` if not available. `source` `Source`: the source to evaluate. Throws: `IllegalArgumentException` (unchecked): if the given language of the source cannot be accessed. `IllegalStateException` (unchecked): if an invalid context is entered or the context is already closed. Cite: `com/oracle/truffle/api/TruffleContext.html#evalInternal(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.source.Source)` ### evalPublic(Node, Source) `public Object evalPublic(Node node, Source source)`. Since 21.3. The same as `evalInternal(Node, Source)`, but only public languages are accessible. Parameters: `node` `Node`: a partial evaluation constant node context used to optimize this operation. Can be `null` if not available. `source` `Source`: the source to evaluate. Throws: `IllegalArgumentException` (unchecked): if the given language of the source cannot be accessed. `IllegalStateException` (unchecked): if an invalid context is entered or the context is already closed. Cite: `com/oracle/truffle/api/TruffleContext.html#evalPublic(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.source.Source)` ### isEntered() `public boolean isEntered()`. Since 20.0. Checks whether the context is entered on the current thread and the context is the currently active context on this thread. There can be multiple contexts `active` on a single thread, but this method only returns `true` if it is the top-most context. This method is thread-safe and may be used from multiple threads. Returns `boolean`: `true` if the context is active, `false` otherwise. Cite: `com/oracle/truffle/api/TruffleContext.html#isEntered()` ### isActive() `public boolean isActive()`. Since 20.3. Returns `true` if the context is currently active on the current thread, else `false`. Checks whether the context has been previously entered by this thread with `enter(Node)` and hasn't been left yet with `leave(Node, java.lang.Object)` methods. Multiple contexts can be active on a single thread. See `isEntered()` for checking whether it is the top-most entered context. This method is thread-safe and may be used from multiple threads. Cite: `com/oracle/truffle/api/TruffleContext.html#isActive()` ### isClosed() `public boolean isClosed()`. Since 20.3. Returns `true` if the context was closed else `false`. A context may be closed if `close()`, `closeCancelled(Node, String)`, or `closeExited(Node, int)` was called previously. Cite: `com/oracle/truffle/api/TruffleContext.html#isClosed()` ### isCancelling() `public boolean isCancelling()`. Since 21.1. Returns `true` if the context is being cancelled else `false`. A context may be in the process of cancelling if `closeCancelled(Node, String)` was called previously. Cite: `com/oracle/truffle/api/TruffleContext.html#isCancelling()` ### isExiting() `public boolean isExiting()`. Since 22.0. Returns `true` if the context is being hard-exited else `false`. A context may be in the process of exit if `closeExited(Node, int)` was called previously. Cite: `com/oracle/truffle/api/TruffleContext.html#isExiting()` ### pause() `public Future pause()`. Since 21.2. Pause execution on all threads for this context. This call does not wait for the threads to be actually paused. Instead, a future is returned that can be used to wait for the execution to be paused. The future is completed when all active threads are paused. New threads entered after this point are paused immediately after entering until `TruffleContext.resume(Future)` is called. Returns `Future`: a future that can be used to wait for the execution to be paused. Also, the future is used to resume execution by passing it to the `TruffleContext.resume(Future)` method. Cite: `com/oracle/truffle/api/TruffleContext.html#pause()` ### resume(Future) `public void resume(Future pauseFuture)`. Since 21.2. Resume previously paused execution on all threads for this context. The execution will not resume if `TruffleContext.pause()` was called multiple times and for some of the other calls resume was not called yet. Parameters: `pauseFuture` `Future`: pause future returned by a previous call to `TruffleContext.pause()`. Throws: `IllegalArgumentException` (unchecked): in case the passed pause future was not obtained by a previous call to `TruffleContext.pause()` on this context. Cite: `com/oracle/truffle/api/TruffleContext.html#resume(java.util.concurrent.Future)` ### leave(Node, Object) `public void leave(Node node, Object prev)`. Since 20.3. Leaves this context and sets the previous context as the new current context. An adopted node may be passed to allow perform optimizations on the fast-path. If a `null` node is passed then entering a context will result in a `boundary` call in compiled code. If the node is not adopted an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. Leaving a language context is designed for compilation and is most efficient if the `context` instance is compilation final. Parameters: `prev` `Object`: the previous context returned by `enter(Node)`. See also: `enter(Node)`. Cite: `com/oracle/truffle/api/TruffleContext.html#leave(com.oracle.truffle.api.nodes.Node,java.lang.Object)` ### leaveAndEnter(Node, Supplier) `@Deprecated public T leaveAndEnter(Node node, Supplier runWhileOutsideContext)`. Since 21.1. Deprecated. Use `leaveAndEnter(Node, Interrupter, InterruptibleFunction, Object)` instead. Leaves this context, runs the passed supplier and reenters the context. This is useful when the current thread must wait for another thread (and does not need to access the context to do so) and triggering multithreading is not desired, for instance when implementing coroutines with threads. The supplier cannot access the context and must not run any guest language code or invoke interoperability messages. The supplier will typically notify another thread that it can now enter the context without triggering multithreading and then wait for some thread to leave the context before exiting the supplier and reentering the context (again to avoid triggering multithreading). An adopted node may be passed to allow perform optimizations on the fast-path. If a `null` node is passed then entering a context will result in a `boundary` call in compiled code. If the provided node is not adopted an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. Entering a language context is designed for compilation and is most efficient if the `context` instance is compilation final. Parameters: `node` `Node`: an adopted node or `null`. `runWhileOutsideContext` `Supplier`: the supplier to run while having left this context. Cite: `com/oracle/truffle/api/TruffleContext.html#leaveAndEnter(com.oracle.truffle.api.nodes.Node,java.util.function.Supplier)` ### leaveAndEnter(Node, TruffleSafepoint.Interrupter, …) `public R leaveAndEnter(Node node, TruffleSafepoint.Interrupter interrupter, TruffleSafepoint.InterruptibleFunction interruptible, T object)`. Since 23.1. Leaves this context, runs the passed interruptible function and reenters the context. This is useful when the current thread must wait for another thread (and does not need to access the context to do so) and triggering multithreading is not desired, for instance when implementing coroutines with threads. The function cannot access the context and must not run any guest language code or invoke interoperability messages. The function will typically notify another thread that it can now enter the context without triggering multithreading and then wait for some thread to leave the context before exiting the function and reentering the context (again to avoid triggering multithreading). An adopted node may be passed to allow performing optimizations on the fast-path. Parameters: `node` `Node`: an adopted node or `null`. `interrupter` `TruffleSafepoint.Interrupter`: an interrupter used to interrupt the interruptible function when, e.g., the context is cancelled. The interrupter is also used to `reset` the interrupted state when the context is reentered. `interruptible` `TruffleSafepoint.InterruptibleFunction`: the interruptible function to run while having left this context. This function is run at most once. Returns `R`: return value of the interruptible, or `null` if the interruptibe throws an [`InterruptedException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/InterruptedException.html) without the context being cancelled or exited. Cite: `com/oracle/truffle/api/TruffleContext.html#leaveAndEnter(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.TruffleSafepoint.Interrupter,com.oracle.truffle.api.TruffleSafepoint.InterruptibleFunction,T)` ### close() `public void close()`. Since 0.27. Closes this context and disposes its resources. Closes this context and disposes its resources. A context cannot be closed if it is currently `entered` or active by any thread. If a closed context is attempted to be accessed or entered, then an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) is thrown. If the context is not closed explicitly, then it is automatically closed together with the parent context. If an attempt to close a context was successful then consecutive calls to close have no effect. Throws: `UnsupportedOperationException` (unchecked): if the close operation is not supported on this context. `IllegalStateException` (unchecked): if the context is `active`. Overrides `close()`. See also: `closeCancelled(Node, String)`, `closeResourceExhausted(Node, String)`. Cite: `com/oracle/truffle/api/TruffleContext.html#close()` ### closeCancelled(Node, String) `public void closeCancelled(Node closeLocation, String message)`. Since 20.3. Force closes the context as cancelled and stops all the execution on all active threads using a special [`ThreadDeath`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ThreadDeath.html) cancel exception. If this context is not currently `entered` on the current thread then this method waits until the close operation is complete and `isClosed()` returns `true`, else it throws the cancelled exception upon its completion of this method. If an attempt to close a context was successful then consecutive calls to close have no effect. The throwing of the special [`ThreadDeath`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ThreadDeath.html) cancel exception also applies to any guest code run during `TruffleLanguage.finalizeContext(Object)` which means that `TruffleLanguage.finalizeContext(Object)` cannot run guest code during the cancel operation. If forced and this context currently `entered` on the current thread and no other context is entered on the current thread then this method directly throws a [`ThreadDeath`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ThreadDeath.html) error instead of completing to indicate that the current thread should be stopped. The thrown [`ThreadDeath`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ThreadDeath.html) must not be caught by the guest language and freely propagated to the guest application to cancel the execution on the current thread. Please note that this means that the guest language's finally blocks must not be executed. If a context is `active` on the current thread, but not `entered`, then an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) is thrown, as parent contexts that are active on the current thread cannot be cancelled. Parameters: `closeLocation` `Node`: the node where the close occurred. If the context is currently entered on the thread, then this node will be used as location, for the exception thrown. If the context is not entered, then the closeLocation parameter will be ignored. `message` `String`: exception text for humans provided to the embedder and tools that observe the cancellation. Throws: `UnsupportedOperationException` (unchecked): if the close operation is not supported on this context. `IllegalStateException` (unchecked): if the context is `active` but not `entered` on the current thread. See also: `close()`, `closeResourceExhausted(Node, String)`. Cite: `com/oracle/truffle/api/TruffleContext.html#closeCancelled(com.oracle.truffle.api.nodes.Node,java.lang.String)` ### closeExited(Node, int) `public void closeExited(Node exitLocation, int exitCode)`. Since 22.0. Initiates force close of the context as exited - `hard exit`. Requires the context to be entered on the current thread. Languages are first notified by calling `TruffleLanguage.exitContext(Object, TruffleLanguage.ExitMode, int)` and then the closing of the context is initiated. Execution on all active threads including the current thread is stopped by throwing a special [`ThreadDeath`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ThreadDeath.html) exit exception. This method does not wait for the execution on other threads to be stopped, it throws the [`ThreadDeath`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ThreadDeath.html) exception as soon as possible. To exit threads reliably, guest languages need to ensure that the [`ThreadDeath`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ThreadDeath.html) is always immediately rethrown and guest language exception handlers and finally blocks are not run. The throwing of the special [`ThreadDeath`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ThreadDeath.html) exit exception also applies to any guest code run during `TruffleLanguage.finalizeContext(Object)` which means that `TruffleLanguage.finalizeContext(Object)` cannot run guest code during hard exit. The exit code can be specified only once and the first call to this method also executes the `exit notifications` on the same thread. Further calls to this method will ensure that the following guest code on the calling thread is not executed by throwing the [`ThreadDeath`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ThreadDeath.html) exit exception, and the exit location is used as the stopping point of the thread, but the passed exit code is ignored and exit notifications are not run. In case the context is in one of the following states the context is being closed and the finalization stage has already begun (`TruffleLanguage.finalizeContext(Object)` is being executed for all language contexts).; the context is already closed; the context threads are being unwound as a part of the cancelling process; the context threads are being unwound as a part of the hard exit process that comes after exit notifications then calling this method has no effect. Parameters: `exitLocation` `Node`: the node where the exit occurred. `exitCode` `int`: exitCode provided to the embedder and tools that observe the exit. Throws: `IllegalStateException` (unchecked): if the context is not `entered` on the current thread. See also: [Context Exit](https://github.com/oracle/graal/blob/master/truffle/docs/Exit.md). Cite: `com/oracle/truffle/api/TruffleContext.html#closeExited(com.oracle.truffle.api.nodes.Node,int)` ### closeResourceExhausted(Node, String) `public void closeResourceExhausted(Node location, String message)`. Since 20.3. Force closes the context due to resource exhaustion. This method is equivalent to calling `closeCancelled(location, message)` except in addition the thrown [`PolyglotException`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/PolyglotException.html) returns `true` for [`PolyglotException.isResourceExhausted()`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/PolyglotException.html#isResourceExhausted%28%29). See also: [`PolyglotException.isResourceExhausted()`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/PolyglotException.html#isResourceExhausted%28%29), `close()`, `closeCancelled(Node, String)`. Cite: `com/oracle/truffle/api/TruffleContext.html#closeResourceExhausted(com.oracle.truffle.api.nodes.Node,java.lang.String)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleContext.Builder [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 0.27. Nested in [`TruffleContext`](com/oracle/truffle/api/TruffleContext.md). ```java public final class TruffleContext.Builder ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Builder` Builder class to create new [`TruffleContext`](com/oracle/truffle/api/TruffleContext.md) instances. ## Methods ### config(String, Object) `public TruffleContext.Builder config(String key, Object value)`. Since 0.27. Sets a config parameter that the child context of this language can access using `Env.getConfig()`. Cite: `com/oracle/truffle/api/TruffleContext.Builder.html#config(java.lang.String,java.lang.Object)` ### initializeCreatorContext(boolean) `public TruffleContext.Builder initializeCreatorContext(boolean enabled)`. Since 21.3. Specifies whether the creating language context should be initialized in the new context. By default the creating language won't get initialized. Cite: `com/oracle/truffle/api/TruffleContext.Builder.html#initializeCreatorContext(boolean)` ### out(OutputStream) `public TruffleContext.Builder out(OutputStream out)`. Since 22.3. Sets the standard output stream to be used for the context. If not set or set to `null`, then the standard output stream is inherited from the outer context. Cite: `com/oracle/truffle/api/TruffleContext.Builder.html#out(java.io.OutputStream)` ### err(OutputStream) `public TruffleContext.Builder err(OutputStream err)`. Since 22.3. Sets the error output stream to be used for the context. If not set or set to `null`, then the standard error stream is inherited from the outer context. is used. Cite: `com/oracle/truffle/api/TruffleContext.Builder.html#err(java.io.OutputStream)` ### in(InputStream) `public TruffleContext.Builder in(InputStream in)`. Since 22.3. Sets the input stream to be used for the context. If not set or set to `null`, then the standard input stream is inherited from the outer context. Cite: `com/oracle/truffle/api/TruffleContext.Builder.html#in(java.io.InputStream)` ### forceSharing(Boolean) `public TruffleContext.Builder forceSharing(Boolean enabled)`. Since 22.3. Force enables or disables code sharing for this inner context. By default this option is set to `null` which instructs this context to inherit sharing configuration from the outer context. If sharing is explicitly set to `true` then code may be shared with all contexts compatible with the configuration of this inner context. Code may also be shared with the outer context if the outer context supports code sharing and its sharing layer is compatible. This may be useful to force sharing for multiple created inner contexts if the outer context configuration disabled sharing. If sharing is explicitly set to `false` then no code will be shared even if the outer context has code sharing enabled and supported by the language. This may be useful to avoid runtime profile pollution through code run in an inner context. If multiple languages are potentially used it is recommended but not required to use `permitted languages` to specify all used languages ahead of time. This allows to validate sharing layer compatibility eagerly and avoids late failures when a language is initialized lazily and is not compatible with the sharing layer. Use `--engine.TraceSharing` for details on whether the sharing configuration is compatible. Cite: `com/oracle/truffle/api/TruffleContext.Builder.html#forceSharing(java.lang.Boolean)` ### option(String, String) `public TruffleContext.Builder option(String key, String value)`. Since 22.3. Overrides an option of the inner context. Only language options may be changed. Engine or instrument options cannot be modified after their initial configuration in the outer context. All options for inner contexts are inherited from the outer context, but options set for the inner context have precedence over options set in the outer context. This method is currently only supported if the outer context is configured with [`org.graalvm.polyglot.Context.Builder.allowInnerContextOptions(boolean)`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.Builder.html#allowInnerContextOptions%28boolean%29). If all privileges are denied then an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) will be thrown when building the inner context. To find out whether the inner context option privilege has been granted languages may use `TruffleLanguage.Env.isInnerContextOptionsAllowed()`. Cite: `com/oracle/truffle/api/TruffleContext.Builder.html#option(java.lang.String,java.lang.String)` ### inheritAllAccess(boolean) `public TruffleContext.Builder inheritAllAccess(boolean b)`. Since 22.3. If set to `true` allows all access privileges that were also granted to the outer context. If set to `false` then all privileges are denied in the created context independent of the outer context. By default all privileges are denied and not inherited. This privilege enables inheritance for the following privileges: `allowCreateThread(boolean)`; `allowNativeAccess(boolean)`; `allowIO(boolean)`; `allowHostClassLookup(boolean)`; `allowHostClassLoading(boolean)`; `allowCreateProcess(boolean)`; `allowPolyglotAccess(boolean)`; `allowInheritEnvironmentAccess(boolean)`; `allowInnerContextOptions(boolean)` If an individual privilege was set explicitly then the value of `inheritAllAccess(boolean)` is ignored for that privilege. For example it is possible to set `inheritAllAccess(boolean)` to `true` but set `allowNativeAccess(boolean)` to `false` to allow inheritance of all but native access rights from the outer to the inner context. In case new privileges are added in the future, then this method will allow or disallow inheritance for the new privileges as well. For security sensitive use-cases it is recommended to keep the default value of `inheritAllAccess(boolean)` and individually specify allowed privileges for this context. For non security sensitive use-cases it is recommended to set this flag to `true`. Following this recommendation is important in case new privileges are added to the platform. Cite: `com/oracle/truffle/api/TruffleContext.Builder.html#inheritAllAccess(boolean)` ### allowCreateThread(boolean) `public TruffleContext.Builder allowCreateThread(boolean b)`. Since 22.3. Allows or denies creating threads for this context. Set to `true` to inherit access privilege from the outer context or `false` to deny access for this context. See also: `inheritAllAccess(boolean)`, [`org.graalvm.polyglot.Context.Builder.allowCreateThread(boolean)`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.Builder.html#allowCreateThread%28boolean%29). Cite: `com/oracle/truffle/api/TruffleContext.Builder.html#allowCreateThread(boolean)` ### allowNativeAccess(boolean) `public TruffleContext.Builder allowNativeAccess(boolean b)`. Since 22.3. Allows or denies using native access in this context. Set to `true` to inherit access privilege from the outer context or `false` to deny access for this context. See also: `inheritAllAccess(boolean)`, [`org.graalvm.polyglot.Context.Builder.allowNativeAccess(boolean)`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.Builder.html#allowNativeAccess%28boolean%29). Cite: `com/oracle/truffle/api/TruffleContext.Builder.html#allowNativeAccess(boolean)` ### allowIO(boolean) `public TruffleContext.Builder allowIO(boolean b)`. Since 22.3. Allows or denies using IO in this context. Set to `true` to inherit access privilege from the outer context or `false` to deny access for this context. See also: `inheritAllAccess(boolean)`, [`org.graalvm.polyglot.Context.Builder.allowIO(org.graalvm.polyglot.io.IOAccess)`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.Builder.html#allowIO%28org.graalvm.polyglot.io.IOAccess%29). Cite: `com/oracle/truffle/api/TruffleContext.Builder.html#allowIO(boolean)` ### allowHostClassLoading(boolean) `public TruffleContext.Builder allowHostClassLoading(boolean b)`. Since 22.3. Allows or denies loading new host classes in this context. Set to `true` to inherit access privilege from the outer context or `false` to deny access for this context. See also: `inheritAllAccess(boolean)`, [`org.graalvm.polyglot.Context.Builder.allowHostAccess(org.graalvm.polyglot.HostAccess)`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.Builder.html#allowHostAccess%28org.graalvm.polyglot.HostAccess%29). Cite: `com/oracle/truffle/api/TruffleContext.Builder.html#allowHostClassLoading(boolean)` ### allowHostClassLookup(boolean) `public TruffleContext.Builder allowHostClassLookup(boolean b)`. Since 22.3. Allows or denies loading new host classes in this context. Set to `true` to inherit access privilege from the outer context or `false` to deny access for this context. See also: `inheritAllAccess(boolean)`, [`org.graalvm.polyglot.Context.Builder.allowHostAccess(org.graalvm.polyglot.HostAccess)`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.Builder.html#allowHostAccess%28org.graalvm.polyglot.HostAccess%29). Cite: `com/oracle/truffle/api/TruffleContext.Builder.html#allowHostClassLookup(boolean)` ### allowCreateProcess(boolean) `public TruffleContext.Builder allowCreateProcess(boolean b)`. Since 22.3. Allows or denies creating processes in this context. Set to `true` to inherit access privilege from the outer context or `false` to deny access for this context. See also: `inheritAllAccess(boolean)`, [`org.graalvm.polyglot.Context.Builder.allowCreateProcess(boolean)`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.Builder.html#allowCreateProcess%28boolean%29). Cite: `com/oracle/truffle/api/TruffleContext.Builder.html#allowCreateProcess(boolean)` ### allowInnerContextOptions(boolean) `public TruffleContext.Builder allowInnerContextOptions(boolean b)`. Since 22.3. Allows or denies options for inner contexts created by this context. Set to `true` to inherit access privilege from the outer context or `false` to deny access for this context. See also: `inheritAllAccess(boolean)`, [`org.graalvm.polyglot.Context.Builder.allowCreateProcess(boolean)`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.Builder.html#allowCreateProcess%28boolean%29). Cite: `com/oracle/truffle/api/TruffleContext.Builder.html#allowInnerContextOptions(boolean)` ### allowPolyglotAccess(boolean) `public TruffleContext.Builder allowPolyglotAccess(boolean b)`. Since 22.3. Allows or denies access to polyglot languages in this context. Set to `true` to inherit access privilege from the outer context or `false` to deny access for this context. See also: `inheritAllAccess(boolean)`, [`org.graalvm.polyglot.Context.Builder.allowPolyglotAccess(org.graalvm.polyglot.PolyglotAccess)`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.Builder.html#allowPolyglotAccess%28org.graalvm.polyglot.PolyglotAccess%29). Cite: `com/oracle/truffle/api/TruffleContext.Builder.html#allowPolyglotAccess(boolean)` ### threadAccessDeniedHandler(Consumer) `public TruffleContext.Builder threadAccessDeniedHandler(Consumer handler)`. Since 24.2. Installs handler to control what happens on multiple thread access. When multiple threads are accessing a context which isn't ready for multithreaded access an exception is yielded by default. By installing this `handler` one can control what shall happen. Either to throw exception (with the provided reason) or to resolve the multithreaded situation somehow and return to retry the thread access again. Parameters: `handler` `Consumer`: callback (that gets a reason as an input) that either throws an exception or returns to signal a **request for retry**. Returns `TruffleContext.Builder`: this builder. Cite: `com/oracle/truffle/api/TruffleContext.Builder.html#threadAccessDeniedHandler(java.util.function.Consumer)` ### allowInheritEnvironmentAccess(boolean) `public TruffleContext.Builder allowInheritEnvironmentAccess(boolean b)`. Since 22.3. Allows or denies access to the parent context's environment in this context. Set to `true` to inherit variables from the outer context or `false` to deny inheritance for this context. Environment variables can be set for the inner context with `environment(String, String)` even if inheritance is disabled. If inheritance is enabled, environment variables specified for the inner context override environment variables of the outer context. See also: `inheritAllAccess(boolean)`, [`org.graalvm.polyglot.Context.Builder.allowEnvironmentAccess(org.graalvm.polyglot.EnvironmentAccess)`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.Builder.html#allowEnvironmentAccess%28org.graalvm.polyglot.EnvironmentAccess%29). Cite: `com/oracle/truffle/api/TruffleContext.Builder.html#allowInheritEnvironmentAccess(boolean)` ### environment(String, String) `public TruffleContext.Builder environment(String name, String value)`. Since 22.3. Sets an environment variable. Parameters: `name` `String`: the environment variable name. `value` `String`: the environment variable value. Cite: `com/oracle/truffle/api/TruffleContext.Builder.html#environment(java.lang.String,java.lang.String)` ### environment(Map) `public TruffleContext.Builder environment(Map env)`. Since 22.3. Shortcut for setting multiple `environment variables` using a map. All values of the provided map must be non-null. Parameters: `env` `Map`: environment variables. See also: `To set a single environment variable.`. Cite: `com/oracle/truffle/api/TruffleContext.Builder.html#environment(java.util.Map)` ### timeZone(ZoneId) `public TruffleContext.Builder timeZone(ZoneId zone)`. Since 22.3. Sets the default time zone to be used for this context. If not set, or explicitly set to `null` then the time zone of the outer context will be used. Cite: `com/oracle/truffle/api/TruffleContext.Builder.html#timeZone(java.time.ZoneId)` ### arguments(String, String[]) `public TruffleContext.Builder arguments(String language, String[] args)`. Since 22.3. Sets the guest language application arguments for a language context. Application arguments are typically made available to guest language implementations. Passing no arguments to a language is equivalent to providing an empty arguments array. Parameters: `language` `String`: the language id of the primary language. `args` `String[]`: an array of arguments passed to the guest language program. Throws: `IllegalArgumentException` (unchecked): if an invalid language id was specified. Cite: `com/oracle/truffle/api/TruffleContext.Builder.html#arguments(java.lang.String,java.lang.String[])` ### options(Map) `public TruffleContext.Builder options(Map options)`. Since 22.3. Sets multiple options using a map. See `option(String, String)` for details. Cite: `com/oracle/truffle/api/TruffleContext.Builder.html#options(java.util.Map)` ### onCancelled(Runnable) `public TruffleContext.Builder onCancelled(Runnable r)`. Since 22.1. Specifies a [`Runnable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Runnable.html) that will be executed when the new context is `cancelled` and the cancel exception is about to reach the outer context, or when some operation on the new context is attempted while the context is already cancelled. However, the runnable will only be executed if the outer context is not cancelled. The purpose of the runnable is to allow throwing a custom guest exception before the cancel exception reaches the outer context, so that the outer context can properly handle the exception. In case the runnable does not throw any exception, an internal error is thrown (should not be caught). Cite: `com/oracle/truffle/api/TruffleContext.Builder.html#onCancelled(java.lang.Runnable)` ### onExited(Consumer) `public TruffleContext.Builder onExited(Consumer r)`. Since 22.1. Specifies a [`Consumer`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/Consumer.html) that will be executed when the new context is `hard-exited` and the exit exception is about to reach the outer context, or when some operation on the new context is attempted while the context is already hard-exited. However, the consumer will only be executed if the outer context is not hard-exited. The purpose of the consumer is to allow throwing a custom guest exception before the exit exception reaches the outer context, so that the outer context can properly handle the exception. In case the consumer does not throw any exception, an internal error is thrown (should not be caught). The single input argument to the [`Consumer`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/Consumer.html) is the exit code. See also: [Context Exit](https://github.com/oracle/graal/blob/master/truffle/docs/Exit.md). Cite: `com/oracle/truffle/api/TruffleContext.Builder.html#onExited(java.util.function.Consumer)` ### onClosed(Runnable) `public TruffleContext.Builder onClosed(Runnable r)`. Since 22.1. Specifies a [`Runnable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Runnable.html) that will be executed when some operation on the new context attempted while the context is already `closed`. However, the runnable will only be executed if the outer context is not closed. The purpose of the runnable is to allow throwing a custom guest exception before the close exception reaches the outer context, so that the outer context can properly handle the exception. In case the runnable does not throw any exception, an internal error is thrown (should not be caught). Cite: `com/oracle/truffle/api/TruffleContext.Builder.html#onClosed(java.lang.Runnable)` ### build() `public TruffleContext build()`. Since 0.27. Builds the new context instance. Cite: `com/oracle/truffle/api/TruffleContext.Builder.html#build()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleFile [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 19.0. ```java public final class TruffleFile extends TruffleFileLegacy ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `TruffleFileLegacy` > `TruffleFile` An abstract representation of a file used by Truffle languages. ## Nested types - [`TruffleFile.AttributeDescriptor`](com/oracle/truffle/api/TruffleFile.AttributeDescriptor.md) (class): Represents a file's attribute. - [`TruffleFile.Attributes`](com/oracle/truffle/api/TruffleFile.Attributes.md) (class): A view over file's attributes values obtained by getAttributes. - [`TruffleFile.FileStoreInfo`](com/oracle/truffle/api/TruffleFile.FileStoreInfo.md) (class): Provides information about the file store. - [`TruffleFile.FileTypeDetector`](com/oracle/truffle/api/TruffleFile.FileTypeDetector.md) (interface): A detector for finding file's MIME type and encoding. ## Fields ### LAST_MODIFIED_TIME `public static final TruffleFile.AttributeDescriptor LAST_MODIFIED_TIME`. Since 19.0. The file's last modified time. Supported by all filesystems. Cite: `com/oracle/truffle/api/TruffleFile.html#LAST_MODIFIED_TIME` ### LAST_ACCESS_TIME `public static final TruffleFile.AttributeDescriptor LAST_ACCESS_TIME`. Since 19.0. The file's last access time. Supported by all filesystems. Cite: `com/oracle/truffle/api/TruffleFile.html#LAST_ACCESS_TIME` ### CREATION_TIME `public static final TruffleFile.AttributeDescriptor CREATION_TIME`. Since 19.0. The file's creation time. Supported by all filesystems. Cite: `com/oracle/truffle/api/TruffleFile.html#CREATION_TIME` ### IS_REGULAR_FILE `public static final TruffleFile.AttributeDescriptor IS_REGULAR_FILE`. Since 19.0. Represents the file a regular file. Supported by all filesystems. Cite: `com/oracle/truffle/api/TruffleFile.html#IS_REGULAR_FILE` ### IS_DIRECTORY `public static final TruffleFile.AttributeDescriptor IS_DIRECTORY`. Since 19.0. Represents the file a directory. Supported by all filesystems. Cite: `com/oracle/truffle/api/TruffleFile.html#IS_DIRECTORY` ### IS_SYMBOLIC_LINK `public static final TruffleFile.AttributeDescriptor IS_SYMBOLIC_LINK`. Since 19.0. Represents the file a symbolic link. Supported by all filesystems. Cite: `com/oracle/truffle/api/TruffleFile.html#IS_SYMBOLIC_LINK` ### IS_OTHER `public static final TruffleFile.AttributeDescriptor IS_OTHER`. Since 19.0. Represents the file a special file (device, named pipe). Supported by all filesystems. Cite: `com/oracle/truffle/api/TruffleFile.html#IS_OTHER` ### SIZE `public static final TruffleFile.AttributeDescriptor SIZE`. Since 19.0. The file's size in bytes. Supported by all filesystems. Cite: `com/oracle/truffle/api/TruffleFile.html#SIZE` ### UNIX_OWNER `public static final TruffleFile.AttributeDescriptor UNIX_OWNER`. Since 19.0. The owner of the file. Supported only by UNIX native filesystem. Cite: `com/oracle/truffle/api/TruffleFile.html#UNIX_OWNER` ### UNIX_GROUP `public static final TruffleFile.AttributeDescriptor UNIX_GROUP`. Since 19.0. The group owner of the file. Supported only by UNIX native filesystem. Cite: `com/oracle/truffle/api/TruffleFile.html#UNIX_GROUP` ### UNIX_PERMISSIONS `public static final TruffleFile.AttributeDescriptor> UNIX_PERMISSIONS`. Since 19.0. The file's Posix permissions. Supported only by UNIX native filesystem. Cite: `com/oracle/truffle/api/TruffleFile.html#UNIX_PERMISSIONS` ### UNIX_MODE `public static final TruffleFile.AttributeDescriptor UNIX_MODE`. Since 19.0. The file's mode containing the protection and file type bits. Supported only by UNIX native filesystem. Cite: `com/oracle/truffle/api/TruffleFile.html#UNIX_MODE` ### UNIX_INODE `public static final TruffleFile.AttributeDescriptor UNIX_INODE`. Since 19.0. The file's inode number. Supported only by UNIX native filesystem. Cite: `com/oracle/truffle/api/TruffleFile.html#UNIX_INODE` ### UNIX_DEV `public static final TruffleFile.AttributeDescriptor UNIX_DEV`. Since 19.0. The id of a device containing the file. Supported only by UNIX native filesystem. Cite: `com/oracle/truffle/api/TruffleFile.html#UNIX_DEV` ### UNIX_RDEV `public static final TruffleFile.AttributeDescriptor UNIX_RDEV`. Since 19.0. The id of a device represented by the file. Supported only by UNIX native filesystem. Cite: `com/oracle/truffle/api/TruffleFile.html#UNIX_RDEV` ### UNIX_NLINK `public static final TruffleFile.AttributeDescriptor UNIX_NLINK`. Since 19.0. The number of hard links. Supported only by UNIX native filesystem. Cite: `com/oracle/truffle/api/TruffleFile.html#UNIX_NLINK` ### UNIX_UID `public static final TruffleFile.AttributeDescriptor UNIX_UID`. Since 19.0. The user id of file owner. Supported only by UNIX native filesystem. Cite: `com/oracle/truffle/api/TruffleFile.html#UNIX_UID` ### UNIX_GID `public static final TruffleFile.AttributeDescriptor UNIX_GID`. Since 19.0. The group id of file owner. Supported only by UNIX native filesystem. Cite: `com/oracle/truffle/api/TruffleFile.html#UNIX_GID` ### UNIX_CTIME `public static final TruffleFile.AttributeDescriptor UNIX_CTIME`. Since 19.0. The file's last status change time. Supported only by UNIX native filesystem. Cite: `com/oracle/truffle/api/TruffleFile.html#UNIX_CTIME` ## Methods ### exists(LinkOption...) `public boolean exists(LinkOption... options)`. Since 19.0. Tests existence of a file. Parameters: `options` `LinkOption...`: the options determining how the symbolic links should be handled. Returns `boolean`: `true` if the file exists. Throws: `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#exists(java.nio.file.LinkOption...)` ### isReadable() `public boolean isReadable()`. Since 19.0. Tests if a file is readable. Checks if the file exists and this Java virtual machine has enough privileges to read the file. Returns `boolean`: `true` if the file exists and is readable. Throws: `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#isReadable()` ### isWritable() `public boolean isWritable()`. Since 19.0. Tests if a file is writable. Checks if the file exists and this Java virtual machine has enough privileges to write to the file. Returns `boolean`: `true` if the file exists and is writable. Throws: `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#isWritable()` ### isExecutable() `public boolean isExecutable()`. Since 19.0. Tests if a file is executable. Checks if the file exists and this Java virtual machine has enough privileges to execute the file. Returns `boolean`: `true` if the file exists and is executable. Throws: `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#isExecutable()` ### isDirectory(LinkOption...) `public boolean isDirectory(LinkOption... options)`. Since 19.0. Tests if a file is a directory. Checks if the file exists and is a directory. Parameters: `options` `LinkOption...`: the options determining how the symbolic links should be handled, by default the symbolic links are followed. Returns `boolean`: `true` if the file exists and is a directory. Throws: `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#isDirectory(java.nio.file.LinkOption...)` ### isRegularFile(LinkOption...) `public boolean isRegularFile(LinkOption... options)`. Since 19.0. Tests if a file is a regular file. Checks if the file exists and is a regular file. Parameters: `options` `LinkOption...`: the options determining how the symbolic links should be handled, by default the symbolic links are followed. Returns `boolean`: `true` if the file exists and is a regular file. Throws: `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#isRegularFile(java.nio.file.LinkOption...)` ### isSymbolicLink() `public boolean isSymbolicLink()`. Since 19.0. Tests if a file is a symbolic link. Checks if the file exists and is a symbolic link. Returns `boolean`: `true` if the file exists and is a symbolic link. Throws: `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#isSymbolicLink()` ### isAbsolute() `public boolean isAbsolute()`. Since 19.0. Tests if this `TruffleFile`'s path is absolute. Returns `boolean`: `true` if the file path is absolute. Cite: `com/oracle/truffle/api/TruffleFile.html#isAbsolute()` ### getName() `public String getName()`. Since 19.0. Returns the name of this `TruffleFile`. Returns `String`: the name of file or directory denoted by this `TruffleFile`, or `null` if the file is a root directory. Cite: `com/oracle/truffle/api/TruffleFile.html#getName()` ### getPath() `public String getPath()`. Since 19.0. Returns the string representation of this `TruffleFile`. Returns `String`: the path of this `TruffleFile`. Cite: `com/oracle/truffle/api/TruffleFile.html#getPath()` ### toUri() `public URI toUri()`. Since 19.0. Returns the absolute [`URI`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/URI.html) representation of this `TruffleFile`. Returns `URI`: the absolute [`URI`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/URI.html) representing the `TruffleFile`. Throws: `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied a resolution of an absolute path. Cite: `com/oracle/truffle/api/TruffleFile.html#toUri()` ### toRelativeUri() `public URI toRelativeUri()`. Since 19.0. Returns a relative [`URI`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/URI.html) representation of non absolute `TruffleFile`. If this `TruffleFile` is relative it returns a relative [`URI`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/URI.html). For an `absolute` `TruffleFile` it returns an absolute [`URI`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/URI.html). Returns `URI`: the [`URI`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/URI.html) representing the `TruffleFile`. Cite: `com/oracle/truffle/api/TruffleFile.html#toRelativeUri()` ### getAbsoluteFile() `public TruffleFile getAbsoluteFile()`. Since 19.0. Resolves this `TruffleFile` to absolute `TruffleFile`. If this `TruffleFile` is already absolute this method returns this `TruffleFile` without any resolution. Returns `TruffleFile`: the absolute `TruffleFile`. Throws: `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied a resolution of an absolute path. Cite: `com/oracle/truffle/api/TruffleFile.html#getAbsoluteFile()` ### getCanonicalFile(LinkOption...) `public TruffleFile getCanonicalFile(LinkOption... options) throws IOException`. Since 19.0. Returns a `TruffleFile` representing the real (canonical) path of an existing file. Parameters: `options` `LinkOption...`: the options determining how the symbolic links should be handled. Returns `TruffleFile`: a `TruffleFile` representing the absolute canonical path. Throws: `IOException`: in case of IO error. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#getCanonicalFile(java.nio.file.LinkOption...)` ### getParent() `public TruffleFile getParent()`. Since 19.0. Returns a parent `TruffleFile` or null when the file does not have a parent. Returns `TruffleFile`: the parent `TruffleFile`. Cite: `com/oracle/truffle/api/TruffleFile.html#getParent()` ### resolve(String) `public TruffleFile resolve(String name)`. Since 19.0. Resolves given string path representation against this `TruffleFile`. Parameters: `name` `String`: the path to resolve. Returns `TruffleFile`: the resolved `TruffleFile`. Throws: `InvalidPathException` (unchecked): if the path string contains non valid characters. Cite: `com/oracle/truffle/api/TruffleFile.html#resolve(java.lang.String)` ### resolveSibling(String) `public TruffleFile resolveSibling(String name)`. Since 19.0. Resolves given string path representation against the parent of this `TruffleFile`. Parameters: `name` `String`: the path to resolve. Returns `TruffleFile`: the resolved `TruffleFile`. Throws: `InvalidPathException` (unchecked): if the path string contains non valid characters. Cite: `com/oracle/truffle/api/TruffleFile.html#resolveSibling(java.lang.String)` ### size(LinkOption...) `public long size(LinkOption... options) throws IOException`. Since 19.0. Returns the size of a file. Parameters: `options` `LinkOption...`: the options determining how the symbolic links should be handled. Returns `long`: the file size in bytes. Throws: `IOException`: in case of IO error. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#size(java.nio.file.LinkOption...)` ### getLastModifiedTime(LinkOption...) `public FileTime getLastModifiedTime(LinkOption... options) throws IOException`. Since 19.0. Returns the last modified time. Parameters: `options` `LinkOption...`: the options determining how the symbolic links should be handled. Returns `FileTime`: the [`FileTime`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/attribute/FileTime.html) representing the time this `TruffleFile` was last modified. Throws: `IOException`: in case of IO error. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#getLastModifiedTime(java.nio.file.LinkOption...)` ### setLastModifiedTime(FileTime, LinkOption...) `public void setLastModifiedTime(FileTime time, LinkOption... options) throws IOException`. Since 19.0. Sets the file's last modified time. Parameters: `time` `FileTime`: the new value of the last modified time. `options` `LinkOption...`: the options determining how the symbolic links should be handled. Throws: `IOException`: in case of IO error. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#setLastModifiedTime(java.nio.file.attribute.FileTime,java.nio.file.LinkOption...)` ### getLastAccessTime(LinkOption...) `public FileTime getLastAccessTime(LinkOption... options) throws IOException`. Since 19.0. Returns the last access time. Parameters: `options` `LinkOption...`: the options determining how the symbolic links should be handled. Returns `FileTime`: the [`FileTime`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/attribute/FileTime.html) representing the time this `TruffleFile` was last accessed. Throws: `IOException`: in case of IO error. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#getLastAccessTime(java.nio.file.LinkOption...)` ### setLastAccessTime(FileTime, LinkOption...) `public void setLastAccessTime(FileTime time, LinkOption... options) throws IOException`. Since 19.0. Sets the file's last access time. Parameters: `time` `FileTime`: the new value of the last access time. `options` `LinkOption...`: the options determining how the symbolic links should be handled. Throws: `IOException`: in case of IO error. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#setLastAccessTime(java.nio.file.attribute.FileTime,java.nio.file.LinkOption...)` ### getCreationTime(LinkOption...) `public FileTime getCreationTime(LinkOption... options) throws IOException`. Since 19.0. Returns the creation time. Parameters: `options` `LinkOption...`: the options determining how the symbolic links should be handled. Returns `FileTime`: the [`FileTime`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/attribute/FileTime.html) representing the time this `TruffleFile` was created. Throws: `IOException`: in case of IO error. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#getCreationTime(java.nio.file.LinkOption...)` ### setCreationTime(FileTime, LinkOption...) `public void setCreationTime(FileTime time, LinkOption... options) throws IOException`. Since 19.0. Sets the file's creation time. Parameters: `time` `FileTime`: the new value of the creation time. `options` `LinkOption...`: the options determining how the symbolic links should be handled. Throws: `IOException`: in case of IO error. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#setCreationTime(java.nio.file.attribute.FileTime,java.nio.file.LinkOption...)` ### list() `public Collection list() throws IOException`. Since 19.0. Returns a collection of `TruffleFile`s in the directory denoted by this `TruffleFile`. Returns `Collection`: a collection of `TruffleFile`s located in the directory denoted by this `TruffleFile`. Throws: `IOException`: in case of IO error. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#list()` ### newByteChannel(Set, FileAttribute...) `public FileChannel newByteChannel(Set options, FileAttribute... attributes) throws IOException`. Since 19.0. Opens or creates a file returning a [`FileChannel`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileChannel.html) to access the file content. In most cases, the returned channel should be closed using a try-with-resources construct. When the channel must remain open for the lifetime of a context, it should be `registered` for automatic close on context disposal. The returned channel supports file locking when locking is supported by the underlying file system. On JDK 22 and later, it also supports mapping file regions when memory mapping is supported by the underlying file system. Parameters: `options` `Set`: the options specifying how the file should be opened. `attributes` `FileAttribute...`: the optional attributes to set atomically when creating the new file. Returns `FileChannel`: the created [`FileChannel`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileChannel.html). Throws: `FileAlreadyExistsException` (unchecked): if [`StandardOpenOption.CREATE_NEW`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/StandardOpenOption.html#CREATE_NEW) option is set and a file already exists on given path. `IOException`: in case of IO error. `UnsupportedOperationException` (unchecked): if the attributes contain an attribute which cannot be set atomically. `IllegalArgumentException` (unchecked): in case of invalid options combination. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Overrides `newByteChannel(java.util.Set,java.nio.file.attribute.FileAttribute...)`. Cite: `com/oracle/truffle/api/TruffleFile.html#newByteChannel(java.util.Set,java.nio.file.attribute.FileAttribute...)` ### newInputStream(OpenOption...) `public InputStream newInputStream(OpenOption... options) throws IOException`. Since 19.0. Opens a file for reading returning an [`InputStream`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/InputStream.html) to access the file content. In most cases, the returned [`InputStream`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/InputStream.html) should be closed using try-with-resources construct. When the stream must keep being opened for the lifetime of a context it should be `registered` for automatic close on context dispose. Parameters: `options` `OpenOption...`: the options specifying how the file should be opened. Returns `InputStream`: the created [`InputStream`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/InputStream.html). Throws: `IOException`: in case of IO error. `IllegalArgumentException` (unchecked): in case of invalid options combination. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#newInputStream(java.nio.file.OpenOption...)` ### newBufferedReader(Charset) `public BufferedReader newBufferedReader(Charset charset) throws IOException`. Since 19.0. Opens a file for reading returning a [`BufferedReader`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/BufferedReader.html) to access the file content. In most cases, the returned [`BufferedReader`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/BufferedReader.html) should be closed using try-with-resources construct. When the reader must keep being opened for the lifetime of a context it should be `registered` for automatic close on context dispose. Parameters: `charset` `Charset`: the file encoding. Returns `BufferedReader`: the created [`BufferedReader`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/BufferedReader.html). Throws: `IOException`: in case of IO error. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#newBufferedReader(java.nio.charset.Charset)` ### newBufferedReader() `public BufferedReader newBufferedReader() throws IOException`. Since 19.0. Opens a file for reading returning a [`BufferedReader`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/BufferedReader.html) to access the file content. See `newBufferedReader(Charset)`. Returns `BufferedReader`: the created [`BufferedReader`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/BufferedReader.html). Throws: `IOException`: in case of IO error. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#newBufferedReader()` ### readAllBytes() `public byte[] readAllBytes() throws IOException`. Since 19.0. Reads a file content as bytes. Returns `byte[]`: the created `byte[]`. Throws: `IOException`: in case of IO error. `OutOfMemoryError` (unchecked): if an array of a file size cannot be allocated. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#readAllBytes()` ### newOutputStream(OpenOption...) `public OutputStream newOutputStream(OpenOption... options) throws IOException`. Since 19.0. Opens a file for writing returning an [`OutputStream`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/OutputStream.html). In most cases, the returned [`OutputStream`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/OutputStream.html) should be closed using try-with-resources construct. When the stream must keep being opened for the lifetime of a context it should be `registered` for automatic close on context dispose. Parameters: `options` `OpenOption...`: the options specifying how the file should be opened. Returns `OutputStream`: the created [`OutputStream`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/OutputStream.html). Throws: `IOException`: in case of IO error. `IllegalArgumentException` (unchecked): in case of invalid options combination. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#newOutputStream(java.nio.file.OpenOption...)` ### newBufferedWriter(Charset, OpenOption...) `public BufferedWriter newBufferedWriter(Charset charset, OpenOption... options) throws IOException`. Since 19.0. Opens a file for writing returning an [`BufferedWriter`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/BufferedWriter.html). In most cases, the returned [`BufferedWriter`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/BufferedWriter.html) should be closed using try-with-resources construct. When the writer must keep being opened for the lifetime of a context it should be `registered` for automatic close on context dispose. Parameters: `charset` `Charset`: the file encoding. `options` `OpenOption...`: the options specifying how the file should be opened. Returns `BufferedWriter`: the created [`BufferedWriter`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/BufferedWriter.html). Throws: `IOException`: in case of IO error. `IllegalArgumentException` (unchecked): in case of invalid options combination. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#newBufferedWriter(java.nio.charset.Charset,java.nio.file.OpenOption...)` ### newBufferedWriter(OpenOption...) `public BufferedWriter newBufferedWriter(OpenOption... options) throws IOException`. Since 19.0. Opens a file for writing returning an [`BufferedWriter`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/BufferedWriter.html). See `newBufferedWriter(Charset, OpenOption...)`. Parameters: `options` `OpenOption...`: the options specifying how the file should be opened. Returns `BufferedWriter`: the created [`BufferedWriter`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/BufferedWriter.html). Throws: `IOException`: in case of IO error. `IllegalArgumentException` (unchecked): in case of invalid options combination. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#newBufferedWriter(java.nio.file.OpenOption...)` ### createFile(FileAttribute...) `public void createFile(FileAttribute... attributes) throws IOException`. Since 19.0. Creates a new empty file. Parameters: `attributes` `FileAttribute...`: the optional attributes to set atomically when creating the new file. Throws: `FileAlreadyExistsException` (unchecked): if the file already exists on given path. `IOException`: in case of IO error. `UnsupportedOperationException` (unchecked): if the attributes contain an attribute which cannot be set atomically. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#createFile(java.nio.file.attribute.FileAttribute...)` ### createDirectory(FileAttribute...) `public void createDirectory(FileAttribute... attributes) throws IOException`. Since 19.0. Creates a new directory. Parameters: `attributes` `FileAttribute...`: the optional attributes to set atomically when creating the new file. Throws: `FileAlreadyExistsException` (unchecked): if the file or directory already exists on given path. `IOException`: in case of IO error. `UnsupportedOperationException` (unchecked): if the attributes contain an attribute which cannot be set atomically. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#createDirectory(java.nio.file.attribute.FileAttribute...)` ### createDirectories(FileAttribute...) `public void createDirectories(FileAttribute... attributes) throws IOException`. Since 19.0. Creates a directory and all nonexistent parent directories. Unlike the `createDirectory` the [`FileAlreadyExistsException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/FileAlreadyExistsException.html) is not thrown if the directory already exists. Parameters: `attributes` `FileAttribute...`: the optional attributes to set atomically when creating the new file. Throws: `FileAlreadyExistsException` (unchecked): if a file (not a directory) already exists on given path. `IOException`: in case of IO error. `UnsupportedOperationException` (unchecked): if the attributes contain an attribute which cannot be set atomically. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#createDirectories(java.nio.file.attribute.FileAttribute...)` ### delete() `public void delete() throws IOException`. Since 19.0. Deletes the file. If the `TruffleFile` denotes a directory, the directory must be empty before deleting. If the `TruffleFile` denotes a symbolic link the symbolic link itself is deleted not its target. Throws: `NoSuchFileException` (unchecked): if the file does not exist. `DirectoryNotEmptyException` (unchecked): if the `TruffleFile` denotes a non empty directory. `IOException`: in case of IO error. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#delete()` ### move(TruffleFile, CopyOption...) `public void move(TruffleFile target, CopyOption... options) throws IOException`. Since 19.0. Moves or renames the file. Parameters: `target` `TruffleFile`: the path of a target file. `options` `CopyOption...`: the options specifying how the move should be performed, see [`StandardCopyOption`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/StandardCopyOption.html). Throws: `UnsupportedOperationException` (unchecked): if `options` contains unsupported option. `FileAlreadyExistsException` (unchecked): if the target path already exists and the `options` don't contain [`StandardCopyOption.REPLACE_EXISTING`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/StandardCopyOption.html#REPLACE_EXISTING) option. `DirectoryNotEmptyException` (unchecked): if the `options` contain [`StandardCopyOption.REPLACE_EXISTING`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/StandardCopyOption.html#REPLACE_EXISTING) but the `target` is a non empty directory. `AtomicMoveNotSupportedException` (unchecked): if the `options` contain [`StandardCopyOption.ATOMIC_MOVE`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/StandardCopyOption.html#ATOMIC_MOVE) but file cannot be moved atomically. `IOException`: in case of IO error. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#move(com.oracle.truffle.api.TruffleFile,java.nio.file.CopyOption...)` ### getPosixPermissions(LinkOption...) `public Set getPosixPermissions(LinkOption... linkOptions) throws IOException`. Since 19.0. Returns the file's Posix permissions. Parameters: `linkOptions` `LinkOption...`: the options determining how the symbolic links should be handled. Returns `Set`: the file's Posix permissions. Throws: `IOException`: in case of IO error. `UnsupportedOperationException` (unchecked): when the Posix permissions are not supported by filesystem. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#getPosixPermissions(java.nio.file.LinkOption...)` ### setPosixPermissions(Set, LinkOption...) `public void setPosixPermissions(Set permissions, LinkOption... linkOptions) throws IOException`. Since 19.0. Sets the file's Posix permissions. Parameters: `permissions` `Set`: the Posix permissions to set. `linkOptions` `LinkOption...`: the options determining how the symbolic links should be handled. Throws: `IOException`: in case of IO error. `UnsupportedOperationException` (unchecked): when the Posix permissions are not supported by filesystem. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#setPosixPermissions(java.util.Set,java.nio.file.LinkOption...)` ### toString() `public String toString()`. Since 19.0. Overrides `toString()`. Cite: `com/oracle/truffle/api/TruffleFile.html#toString()` ### hashCode() `public int hashCode()`. Since 19.0. Overrides `hashCode()`. Cite: `com/oracle/truffle/api/TruffleFile.html#hashCode()` ### equals(Object) `public boolean equals(Object other)`. Since 19.0. Overrides `equals(java.lang.Object)`. Cite: `com/oracle/truffle/api/TruffleFile.html#equals(java.lang.Object)` ### normalize() `public TruffleFile normalize()`. Since 19.0. Returns a `TruffleFile` with removed redundant name elements in it's path. Returns `TruffleFile`: the normalized `TruffleFile`. Cite: `com/oracle/truffle/api/TruffleFile.html#normalize()` ### relativize(TruffleFile) `public TruffleFile relativize(TruffleFile other)`. Since 19.0. Creates a `TruffleFile` with a relative path between this `TruffleFile` and a given `TruffleFile`. Relativization is the inverse of `resolution`. Relativization constructs a `TruffleFile` with relative path that when `resolved` against this `TruffleFile` yields a `TruffleFile` locating the same file as given `TruffleFile`. A relative path cannot be constructed if only one of the `TruffleFile`s is `absolute`. Parameters: `other` `TruffleFile`: the `TruffleFile` to relativize against this `TruffleFile`. Returns `TruffleFile`: the `TruffleFile` with relative path between this and `other` `TruffleFile`s. Throws: `IllegalArgumentException` (unchecked): when `other` cannot be relativized against this `TruffleFile`. Cite: `com/oracle/truffle/api/TruffleFile.html#relativize(com.oracle.truffle.api.TruffleFile)` ### startsWith(String) `public boolean startsWith(String other)`. Since 19.0. Tests if this `TruffleFile` path starts with the given path. The path `foo/bar` starts with `foo` and `foo/bar` but does not start with `f`. Parameters: `other` `String`: the path. Returns `boolean`: `true` if this `TruffleFile` path starts with given path. Throws: `IllegalArgumentException` (unchecked): if the path cannot be parsed. Cite: `com/oracle/truffle/api/TruffleFile.html#startsWith(java.lang.String)` ### startsWith(TruffleFile) `public boolean startsWith(TruffleFile other)`. Since 19.0. Tests if this `TruffleFile` path starts with the given `TruffleFile` path. The path `foo/bar` starts with `foo` and `foo/bar` but does not start with `f`. Parameters: `other` `TruffleFile`: the `TruffleFile`. Returns `boolean`: `true` if this `TruffleFile` path starts with given `TruffleFile` path. Cite: `com/oracle/truffle/api/TruffleFile.html#startsWith(com.oracle.truffle.api.TruffleFile)` ### endsWith(String) `public boolean endsWith(String other)`. Since 19.0. Tests if this `TruffleFile` path ends with the given path. The path `foo/bar` ends with `bar` and `foo/bar` but does not end with `r`. Parameters: `other` `String`: the path. Returns `boolean`: `true` if this `TruffleFile` path ends with given path. Throws: `IllegalArgumentException` (unchecked): if the path cannot be parsed. Cite: `com/oracle/truffle/api/TruffleFile.html#endsWith(java.lang.String)` ### endsWith(TruffleFile) `public boolean endsWith(TruffleFile other)`. Since 19.0. Tests if this `TruffleFile` path ends with the given `TruffleFile` path. The path `foo/bar` ends with `bar` and `foo/bar` but does not end with `r`. Parameters: `other` `TruffleFile`: the `TruffleFile`. Returns `boolean`: `true` if this `TruffleFile` path ends with given `TruffleFile` path. Cite: `com/oracle/truffle/api/TruffleFile.html#endsWith(com.oracle.truffle.api.TruffleFile)` ### createLink(TruffleFile) `public void createLink(TruffleFile target) throws IOException`. Since 19.0. Creates a new link to an existing target *(optional operation)*. Parameters: `target` `TruffleFile`: the existing file to link. Throws: `FileAlreadyExistsException` (unchecked): if the file or directory already exists on given path. `IOException`: in case of IO error. `UnsupportedOperationException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) implementation does not support links. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#createLink(com.oracle.truffle.api.TruffleFile)` ### createSymbolicLink(TruffleFile, FileAttribute...) `public void createSymbolicLink(TruffleFile target, FileAttribute... attrs) throws IOException`. Since 19.0. Creates a symbolic link to a target *(optional operation)*. Parameters: `target` `TruffleFile`: the target of the symbolic link. `attrs` `FileAttribute...`: the optional attributes to set atomically when creating the symbolic link. Throws: `FileAlreadyExistsException` (unchecked): if the file or directory already exists on given path. `IOException`: in case of IO error. `UnsupportedOperationException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) implementation does not support symbolic links or the attributes contain an attribute which cannot be set atomically. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#createSymbolicLink(com.oracle.truffle.api.TruffleFile,java.nio.file.attribute.FileAttribute...)` ### readSymbolicLink() `public TruffleFile readSymbolicLink() throws IOException`. Since 20.3. Reads the target of a symbolic link. Returns `TruffleFile`: the `TruffleFile` representing the target of the symbolic link. Throws: `NotLinkException` (unchecked): if the `TruffleFile` is not a symbolic link. `IOException`: in case of IO error. `UnsupportedOperationException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) implementation does not support symbolic links. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#readSymbolicLink()` ### getOwner(LinkOption...) `public UserPrincipal getOwner(LinkOption... options) throws IOException`. Since 19.0. Returns the owner of the file. Parameters: `options` `LinkOption...`: the options determining how the symbolic links should be handled. Returns `UserPrincipal`: the file owner. Throws: `IOException`: in case of IO error. `UnsupportedOperationException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) implementation does not support owner attribute. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#getOwner(java.nio.file.LinkOption...)` ### getGroup(LinkOption...) `public GroupPrincipal getGroup(LinkOption... options) throws IOException`. Since 19.0. Returns the group owner of the file. Parameters: `options` `LinkOption...`: the options determining how the symbolic links should be handled. Returns `GroupPrincipal`: the file owner. Throws: `IOException`: in case of IO error. `UnsupportedOperationException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) implementation does not support group owner attribute. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#getGroup(java.nio.file.LinkOption...)` ### newDirectoryStream() `public DirectoryStream newDirectoryStream() throws IOException`. Since 19.0. Opens a directory, returning a [`DirectoryStream`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/DirectoryStream.html) to iterate over all entries in the directory. The `TruffleFile`s returned by the directory stream's [`iterator`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/DirectoryStream.html#iterator%28%29) are created as if by `resolving` the name of the directory entry against this `TruffleFile`. In most cases, the returned [`DirectoryStream`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/DirectoryStream.html) should be closed using try-with-resources construct. When the stream must keep being opened for the lifetime of a context it should be `registered` for automatic close on context dispose. When not using the try-with-resources construct, then the directory stream's [`close`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/Closeable.html#close%28%29) method should be called after iteration is completed. The code which iterates over all files can use simpler `list()` method. Returns `DirectoryStream`: a new opened [`DirectoryStream`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/DirectoryStream.html) object. Throws: `IOException`: in case of IO error. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#newDirectoryStream()` ### visit(FileVisitor, int, FileVisitOption...) `public void visit(FileVisitor visitor, int maxDepth, FileVisitOption... options) throws IOException`. Since 19.0. Visits this `TruffleFile` file tree. This method walks a file tree rooted at this `TruffleFile`. The file tree traversal is *depth-first*. The appropriate method on give [`FileVisitor`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/FileVisitor.html) is invoked for each met file. File tree traversal completes when all accessible files in the tree have been visited, a [`FileVisitor`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/FileVisitor.html) visit method returns a [`FileVisitResult.TERMINATE`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/FileVisitResult.html#TERMINATE) or a [`FileVisitor`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/FileVisitor.html) method terminates due to an uncaught exception. For each file encountered this method attempts to read its [`java.nio.file.attribute.BasicFileAttributes`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/attribute/BasicFileAttributes.html). If the file is not a directory then the [`visitFile`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/FileVisitor.html#visitFile%28T,java.nio.file.attribute.BasicFileAttributes%29) method is invoked with the file attributes. If the file attributes cannot be read, due to an I/O exception, then the [`visitFileFailed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/FileVisitor.html#visitFileFailed%28T,java.io.IOException%29) method is invoked with the I/O exception. Where the file is a directory, and the directory could not be opened, then the `visitFileFailed` method is invoked with the I/O exception, after which, the file tree walk continues, by default, at the next *sibling* of the directory. Where the directory is opened successfully, then the entries in the directory, and their *descendants* are visited. When all entries have been visited, or an I/O error occurs during iteration of the directory, then the directory is closed and the visitor's [`postVisitDirectory`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/FileVisitor.html#postVisitDirectory%28T,java.io.IOException%29) method is invoked. The file tree walk then continues, by default, at the next *sibling* of the directory. By default, symbolic links are not automatically followed by this method. If the `options` parameter contains the [`FOLLOW_LINKS`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/FileVisitOption.html#FOLLOW_LINKS) option then symbolic links are followed. The `maxDepth` parameter is the maximum number of levels of directories to visit. A value of `0` means that only the starting file is visited. The `visitFile` method is invoked for all files, including directories, encountered at `maxDepth`, unless the basic file attributes cannot be read, in which case the ` visitFileFailed` method is invoked. Parameters: `visitor` `FileVisitor`: the [`FileVisitor`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/FileVisitor.html) to invoke for each file. `maxDepth` `int`: the maximum number of directory levels to visit, [`MAX_VALUE`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Integer.html#MAX_VALUE) may be used to indicate that all levels should be visited. `options` `FileVisitOption...`: the options configuring the file tree traversal. Throws: `IllegalArgumentException` (unchecked): if the `maxDepth` parameter is negative. `IOException`: in case of IO error. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#visit(java.nio.file.FileVisitor,int,java.nio.file.FileVisitOption...)` ### copy(TruffleFile, CopyOption...) `public void copy(TruffleFile target, CopyOption... options) throws IOException`. Since 19.0. Copies the file. When the file is a directory the copy creates an empty directory in the target location, the directory entries are not copied. This method can be used with the `visit` method to copy the whole sub-tree. Parameters: `target` `TruffleFile`: the path of a target file. `options` `CopyOption...`: the options specifying how the copy should be performed, see [`StandardCopyOption`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/StandardCopyOption.html). Throws: `UnsupportedOperationException` (unchecked): if `options` contains unsupported option. `FileAlreadyExistsException` (unchecked): if the target path already exists and the `options` don't contain [`StandardCopyOption.REPLACE_EXISTING`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/StandardCopyOption.html#REPLACE_EXISTING) option. `DirectoryNotEmptyException` (unchecked): if the `options` contain [`StandardCopyOption.REPLACE_EXISTING`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/StandardCopyOption.html#REPLACE_EXISTING) but the `target` is a non empty directory. `IOException`: in case of IO error. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#copy(com.oracle.truffle.api.TruffleFile,java.nio.file.CopyOption...)` ### detectMimeType() `public String detectMimeType()`. Since 22.2. Detects the `file` MIME type. Returns `String`: the MIME type or `null` if the MIME type is not recognized. Throws: `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#detectMimeType()` ### isSameFile(TruffleFile, LinkOption...) `public boolean isSameFile(TruffleFile other, LinkOption... options) throws IOException`. Since 20.2.0. Tests if this and the given `TruffleFile` refer to the same physical file. If both `TruffleFile` objects are `equal` then this method returns `true` without any checks. If the `TruffleFile`s have different filesystems then this method returns `false`. Otherwise, this method checks if both `TruffleFile`s refer to the same physical file. Depending on the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) implementation it may require to read the files attributes. This implies: Public and Internal files with disabled IO are never the same.; Public and Internal files with allowed IO are potentially the same.; Files created by different languages are potentially the same.; Files created during the Context pre-initialization and files created during Context execution are potentially the same. Parameters: `other` `TruffleFile`: the other `TruffleFile`. Returns `boolean`: `true` if this and the given `TruffleFile` refer to the same physical file. Throws: `IOException`: in case of IO error. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#isSameFile(com.oracle.truffle.api.TruffleFile,java.nio.file.LinkOption...)` ### getAttribute(TruffleFile.AttributeDescriptor, LinkOption...) `public T getAttribute(TruffleFile.AttributeDescriptor attribute, LinkOption... linkOptions) throws IOException`. Since 19.0. Reads a single file's attribute. Parameters: `attribute` `TruffleFile.AttributeDescriptor`: the attribute to read. `linkOptions` `LinkOption...`: the options determining how the symbolic links should be handled. Returns `T`: the attribute value. Throws: `IOException`: in case of IO error. `UnsupportedOperationException` (unchecked): when the filesystem does not support required attribute. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#getAttribute(com.oracle.truffle.api.TruffleFile.AttributeDescriptor,java.nio.file.LinkOption...)` ### setAttribute(TruffleFile.AttributeDescriptor, T, LinkOption...) `public void setAttribute(TruffleFile.AttributeDescriptor attribute, T value, LinkOption... linkOptions) throws IOException`. Since 19.1.0. Sets a single file's attribute. Parameters: `attribute` `TruffleFile.AttributeDescriptor`: the attribute to set. `value` `T`: the attribute value. `linkOptions` `LinkOption...`: the options determining how the symbolic links should be handled. Throws: `IOException`: in case of IO error. `UnsupportedOperationException` (unchecked): when the filesystem does not support given attribute. `IllegalArgumentException` (unchecked): when the attribute value has an inappropriate value. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#setAttribute(com.oracle.truffle.api.TruffleFile.AttributeDescriptor,T,java.nio.file.LinkOption...)` ### getAttributes(Collection, LinkOption...) `public TruffleFile.Attributes getAttributes(Collection> attributes, LinkOption... linkOptions) throws IOException`. Since 19.0. Reads file's attributes as a bulk operation. Parameters: `attributes` `Collection>`: the attributes to read. `linkOptions` `LinkOption...`: the options determining how the symbolic links should be handled. Returns `TruffleFile.Attributes`: the `attributes view`. Throws: `IllegalArgumentException` (unchecked): when no attributes are given. `IOException`: in case of IO error. `UnsupportedOperationException` (unchecked): when the filesystem does not support some of the required attributes. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.html#getAttributes(java.util.Collection,java.nio.file.LinkOption...)` ### getFileStoreInfo() `public TruffleFile.FileStoreInfo getFileStoreInfo()`. Since 25.0.0. Returns information about the file store that contains this file. The returned `FileStoreInfo` object provides access to disk-related metadata such as total size, usable space, and unallocated space. See also: `FileStoreInfo`. Cite: `com/oracle/truffle/api/TruffleFile.html#getFileStoreInfo()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleFile.AttributeDescriptor [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 19.0. Nested in [`TruffleFile`](com/oracle/truffle/api/TruffleFile.md). ```java public static final class TruffleFile.AttributeDescriptor ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `AttributeDescriptor` Represents a file's attribute. Not all attributes are supported by all filesystems. When the filesystem does not support the attribute the attribute read fails with [`UnsupportedOperationException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/UnsupportedOperationException.html). Attributes can be read one by one by the [`getAttribute`](com/oracle/truffle/api/TruffleFile.md#getAttribute%28com.oracle.truffle.api.TruffleFile.AttributeDescriptor,java.nio.file.LinkOption...%29) method or as a bulk read operation by [`getAttributes`](com/oracle/truffle/api/TruffleFile.md#getAttributes%28java.util.Collection,java.nio.file.LinkOption...%29) method. When more attributes are needed the bulk read provides better performance. ## Methods ### toString() `public String toString()`. Since 19.0. Overrides `toString()`. Cite: `com/oracle/truffle/api/TruffleFile.AttributeDescriptor.html#toString()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleFile.Attributes [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 19.0. Nested in [`TruffleFile`](com/oracle/truffle/api/TruffleFile.md). ```java public static final class TruffleFile.Attributes ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Attributes` A view over file's attributes values obtained by [`getAttributes`](com/oracle/truffle/api/TruffleFile.md#getAttributes%28java.util.Collection,java.nio.file.LinkOption...%29). ## Methods ### get(TruffleFile.AttributeDescriptor) `public T get(TruffleFile.AttributeDescriptor descriptor)`. Since 19.0. Returns the attribute value. Parameters: `descriptor` `TruffleFile.AttributeDescriptor`: the attribute to obtain value for. Returns `T`: the attribute value, may return `null` if the filesystem doesn't support the attribute. Throws: `IllegalArgumentException` (unchecked): if the view was not created for the given attribute. Cite: `com/oracle/truffle/api/TruffleFile.Attributes.html#get(com.oracle.truffle.api.TruffleFile.AttributeDescriptor)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleFile.FileStoreInfo [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 25.0.0. Nested in [`TruffleFile`](com/oracle/truffle/api/TruffleFile.md). ```java public final class TruffleFile.FileStoreInfo ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `FileStoreInfo` Provides information about the file store. This class offers access to storage-related metrics, such as the total size of the file store, unallocated space, and the usable space available to the current Java virtual machine. **See also** - [`TruffleFile.getFileStoreInfo()`](com/oracle/truffle/api/TruffleFile.md#getFileStoreInfo%28%29) ## Methods ### getTotalSpace() `public long getTotalSpace() throws IOException`. Since 25.0.0. Returns the size, in bytes, of the file store. If the file store's size exceeds [`Long.MAX_VALUE`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Long.html#MAX_VALUE), `Long.MAX_VALUE` is returned. Returns `long`: the size of the file store in bytes. Throws: `UnsupportedOperationException` (unchecked): if the file system does not support retrieving file store information. `IOException`: if an I/O error occurs while accessing the file store. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) implementation denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.FileStoreInfo.html#getTotalSpace()` ### getUnallocatedSpace() `public long getUnallocatedSpace() throws IOException`. Since 25.0.0. Returns the number of unallocated bytes in the file store. The returned value represents the raw free space on the storage device, regardless of access permissions or user quotas. If the number of unallocated bytes exceeds [`Long.MAX_VALUE`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Long.html#MAX_VALUE), `Long.MAX_VALUE` is returned. Note that the value may be imprecise, as it can change at any time due to external I/O operations, including those performed outside this virtual machine. Returns `long`: the number of unallocated bytes. Throws: `UnsupportedOperationException` (unchecked): if the file system does not support retrieving file store information. `IOException`: if an I/O error occurs while accessing the file store. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) implementation denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.FileStoreInfo.html#getUnallocatedSpace()` ### getUsableSpace() `public long getUsableSpace() throws IOException`. Since 25.0.0. Returns the number of bytes available to this Java virtual machine on the file store. Unlike `getUnallocatedSpace()`, this method accounts for operating system-level restrictions, user quotas, and file system permissions, and therefore may return a smaller value. If the available space exceeds [`Long.MAX_VALUE`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Long.html#MAX_VALUE), `Long.MAX_VALUE` is returned. Note that the returned value may be imprecise, as it can change at any time due to external I/O activity, including operations performed outside this virtual machine. Returns `long`: the number of usable bytes available to this Java virtual machine. Throws: `UnsupportedOperationException` (unchecked): if the file system does not support retrieving file store information. `IOException`: if an I/O error occurs while accessing the file store. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) implementation denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.FileStoreInfo.html#getUsableSpace()` ### getBlockSize() `public long getBlockSize() throws IOException`. Since 25.0.0. Returns the number of bytes per block in the file store. Returns `long`: the block size. Throws: `UnsupportedOperationException` (unchecked): if the file system does not support retrieving file store information. `IOException`: if an I/O error occurs while accessing the file store. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) implementation denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.FileStoreInfo.html#getBlockSize()` ### isReadOnly() `public boolean isReadOnly() throws IOException`. Since 25.0.0. Determines whether the file store is read-only. Note that even if the file store is not read-only, individual write operations may still be denied due to restrictions imposed by the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) implementation, operating system level policies, user quotas, or file system permissions. Throws: `UnsupportedOperationException` (unchecked): if the file system does not support retrieving file store information. `IOException`: if an I/O error occurs while accessing the file store. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) implementation denied the operation. Cite: `com/oracle/truffle/api/TruffleFile.FileStoreInfo.html#isReadOnly()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ TruffleFile.FileTypeDetector [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 19.0. Nested in [`TruffleFile`](com/oracle/truffle/api/TruffleFile.md). ```java public interface TruffleFile.FileTypeDetector ``` A detector for finding [`file`](com/oracle/truffle/api/TruffleFile.md)'s MIME type and encoding. The means by which the detector determines the MIME is highly implementation specific. A simple implementation might detect the MIME type using [`file`](com/oracle/truffle/api/TruffleFile.md) extension. In other cases, the content of [`file`](com/oracle/truffle/api/TruffleFile.md) needs to be examined to guess its file type. The implementations are registered using [`TruffleLanguage registration`](com/oracle/truffle/api/TruffleLanguage.Registration.md#fileTypeDetectors%28%29). **See also** - [`TruffleFile.detectMimeType()`](com/oracle/truffle/api/TruffleFile.md#detectMimeType%28%29) - [`TruffleLanguage.Registration.fileTypeDetectors()`](com/oracle/truffle/api/TruffleLanguage.Registration.md#fileTypeDetectors%28%29) ## Methods ### findMimeType(TruffleFile) `String findMimeType(TruffleFile file) throws IOException`. Since 19.0. Finds a MIME type for given `TruffleFile`. Parameters: `file` `TruffleFile`: the `file` to find a MIME type for. Returns `String`: the MIME type or `null` if the MIME type is not recognized. Throws: `IOException`: of an I/O error occurs. `SecurityException` (unchecked): if the implementation requires an access the file and the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denies the operation. Cite: `com/oracle/truffle/api/TruffleFile.FileTypeDetector.html#findMimeType(com.oracle.truffle.api.TruffleFile)` ### findEncoding(TruffleFile) `Charset findEncoding(TruffleFile file) throws IOException`. Since 19.0. For a file containing an encoding information returns the encoding. Parameters: `file` `TruffleFile`: the `file` to find an encoding for. It's guaranteed that the `file` has a MIME type supported by the language registering this `FileTypeDetector`. Returns `Charset`: the file encoding or `null` if the file does not provide encoding. Throws: `IOException`: of an I/O error occurs. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denies the file access. Cite: `com/oracle/truffle/api/TruffleFile.FileTypeDetector.html#findEncoding(com.oracle.truffle.api.TruffleFile)` # ◆ TruffleLanguage [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 0.8 or earlier. ```java public abstract class TruffleLanguage ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `TruffleLanguage` A Truffle language implementation contains all the services a language should provide to make it composable with other languages. Implementation classes must be annotated with [`Registration`](com/oracle/truffle/api/TruffleLanguage.Registration.md) in order to be discoverable by the [Polyglot API](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/package-summary.html). [`TruffleLanguage`](com/oracle/truffle/api/TruffleLanguage.md) subclasses must provide a public default constructor. #### Lifecycle A language implementation becomes available for use by an engine when metadata is added using the [`Registration`](com/oracle/truffle/api/TruffleLanguage.Registration.md) annotation and the implementation's JAR file placed on the host Java Virtual Machine's class path. A newly created engine locates all available language implementations and creates a [descriptor](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Language.html) for each. The descriptor holds the language's registered metadata, but its execution environment is not initialized until the language is needed for code execution. That execution environment remains initialized for the lifetime of the engine and is isolated from the environment in any other engine instance. Language global state can be shared between multiple context instances by saving them in a custom field of the [`TruffleLanguage`](com/oracle/truffle/api/TruffleLanguage.md) subclass. Languages may control sharing between multiple contexts using its [`context policy`](com/oracle/truffle/api/TruffleLanguage.Registration.md#contextPolicy%28%29). By default the context policy is [`exclusive`](com/oracle/truffle/api/TruffleLanguage.ContextPolicy.md#EXCLUSIVE): each context has its own separate TruffleLanguage instance. If the context policy is more permissive then the implementation needs to manually ensure data isolation between the contexts. This means that state associated with a context must not be stored in a TruffleLanguage subclass. ASTs and assumptions can be shared across multiple contexts if modifying them does not affect language semantics. Languages are strongly discouraged from using static mutable state in their languages. Instead [`TruffleLanguage`](com/oracle/truffle/api/TruffleLanguage.md) instances should be used instead to store global state and their sharing should be configured using [`context policy`](com/oracle/truffle/api/TruffleLanguage.Registration.md#contextPolicy%28%29). Whenever an engine is disposed then each initialized language context will be [`disposed`](com/oracle/truffle/api/TruffleLanguage.md#disposeContext%28C%29). #### Context Policy and Sharing The number of [`TruffleLanguage`](com/oracle/truffle/api/TruffleLanguage.md) instances per polyglot [`context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html) is configured by the [`context policy`](com/oracle/truffle/api/TruffleLanguage.Registration.md#contextPolicy%28%29). By default an [`exclusive`](com/oracle/truffle/api/TruffleLanguage.ContextPolicy.md#EXCLUSIVE) [`language`](com/oracle/truffle/api/TruffleLanguage.md) instance is created for every [`polyglot context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html) or [`inner context`](com/oracle/truffle/api/TruffleLanguage.Env.md#newInnerContextBuilder%28java.lang.String...%29). With policy [`reuse`](com/oracle/truffle/api/TruffleLanguage.ContextPolicy.md#REUSE), language instances will be reused after a language context was [`disposed`](com/oracle/truffle/api/TruffleLanguage.md#disposeContext%28C%29). With policy [`shared`](com/oracle/truffle/api/TruffleLanguage.ContextPolicy.md#SHARED), a language will also be reused if active contexts are not yet disposed. Language instances will only be shared or reused if they are [`compatible`](com/oracle/truffle/api/TruffleLanguage.md#areOptionsCompatible%28org.graalvm.options.OptionValues,org.graalvm.options.OptionValues%29). Language implementations are encouraged to support the most permissive context policy possible. Please see the individual [`policies`](com/oracle/truffle/api/TruffleLanguage.ContextPolicy.md) for details on the implications on the language implementation. The following illustration shows the cardinalities of the individual components: ```java N: unbounded P: N for exclusive, 1 for shared context policy L: number of installed languages I: number of installed instruments - 1 : Host VM Processs - N : Engine - N : Context - L : Language Context - P * L : TruffleLanguage - I : Instrument - 1 : TruffleInstrument ``` For more information on sharing between multiple contexts please see [`ContextPolicy`](com/oracle/truffle/api/TruffleLanguage.ContextPolicy.md). #### Parse Caching The result of the [`parsing request`](com/oracle/truffle/api/TruffleLanguage.md#parse%28com.oracle.truffle.api.TruffleLanguage.ParsingRequest%29) is cached per language instance, [`source`](com/oracle/truffle/api/TruffleLanguage.ParsingRequest.md#getSource%28%29), [`argument names`](com/oracle/truffle/api/TruffleLanguage.ParsingRequest.md#getArgumentNames%28%29) and environment [`options`](com/oracle/truffle/api/TruffleLanguage.Env.md#getOptions%28%29). The scope of the caching is influenced by the [`context policy`](com/oracle/truffle/api/TruffleLanguage.Registration.md#contextPolicy%28%29). Caching may be [`disabled`](com/oracle/truffle/api/source/Source.md#isCached%28%29) for certain sources. It is enabled for new sources by default. #### Language Configuration On [`context creation`](com/oracle/truffle/api/TruffleLanguage.md#createContext%28com.oracle.truffle.api.TruffleLanguage.Env%29) each language context is provided with information about the environment [`environment`](com/oracle/truffle/api/TruffleLanguage.Env.md). Language can optionally declare [`configurable`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.Builder.html#option%28java.lang.String,java.lang.String%29) options in [`getOptionDescriptors()`](com/oracle/truffle/api/TruffleLanguage.md#getOptionDescriptors%28%29). #### Polyglot Bindings Language implementations communicate with one another (and with instrumentation-based tools such as debuggers) by reading/writing named values into the [`polyglot bindings`](com/oracle/truffle/api/TruffleLanguage.Env.md#getPolyglotBindings%28%29). This bindings object is used to implement guest language export/import statements used for *language interoperation*. A language implementation can also [import](com/oracle/truffle/api/TruffleLanguage.Env.md#importSymbol%28java.lang.String%29) or [export](com/oracle/truffle/api/TruffleLanguage.Env.md#exportSymbol%28java.lang.String,java.lang.Object%29) a global symbol by name. The scope may be accessed from multiple threads at the same time. Existing keys are overwritten. #### Configuration vs. Initialization To ensure that a Truffle language can be used in a language-agnostic way, the implementation should be designed to decouple its configuration and initialization from language specifics as much as possible. One aspect of this is the initialization and start of execution via the [`org.graalvm.polyglot.Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html), which should be designed in a generic way. Language-specific entry points, for instance to emulate the command-line interface of an existing implementation, should be handled externally. #### Multi-threading There are two kinds of threads that access contexts of Truffle guest languages: - Internal threads are [`created`](com/oracle/truffle/api/TruffleLanguage.Env.md#newTruffleThreadBuilder%28java.lang.Runnable%29) and managed by a language for a context. All internally created threads need to be stopped when the context is [`disposed`](com/oracle/truffle/api/TruffleLanguage.md#disposeContext%28C%29). - External threads are created and managed by the host application / language launcher. The host application is allowed to use language contexts from changing threads, sequentially or at the same time if the language [`allows`](com/oracle/truffle/api/TruffleLanguage.md#isThreadAccessAllowed%28java.lang.Thread,boolean%29) it. By default every [`context`](com/oracle/truffle/api/TruffleLanguage.md#createContext%28com.oracle.truffle.api.TruffleLanguage.Env%29) only allows access from one thread at the same time. Therefore if the context is tried to be accessed from multiple threads at the same time the access will fail. Languages that want to allow multi-threaded access to a context may override [`isThreadAccessAllowed(Thread, boolean)`](com/oracle/truffle/api/TruffleLanguage.md#isThreadAccessAllowed%28java.lang.Thread,boolean%29) and return `true` also for multi-threaded accesses. Initialization actions for multi-threaded access can be performed by overriding [`initializeMultiThreading(Object)`](com/oracle/truffle/api/TruffleLanguage.md#initializeMultiThreading%28C%29). Threads are [`initialized`](com/oracle/truffle/api/TruffleLanguage.md#initializeThread%28C,java.lang.Thread%29) and [`disposed`](com/oracle/truffle/api/TruffleLanguage.md#disposeContext%28C%29) before and after use with a context. Languages may [`create`](com/oracle/truffle/api/TruffleLanguage.Env.md#newTruffleThreadBuilder%28java.lang.Runnable%29) new threads if the environment [`allows`](com/oracle/truffle/api/TruffleLanguage.Env.md#isCreateThreadAllowed%28%29) it. In addition to the two kinds of threads described above, there are [`system threads`](com/oracle/truffle/api/TruffleLanguage.Env.md#createSystemThread%28java.lang.Runnable,java.lang.ThreadGroup%29) designed to process language internal tasks in the background. They do not require the [`creation permit`](com/oracle/truffle/api/TruffleLanguage.Env.md#isCreateThreadAllowed%28%29), but they must not enter any language context. **Type parameters** - ``: internal state of the language associated with every thread that is executing program [`parsed`](com/oracle/truffle/api/TruffleLanguage.md#parse%28com.oracle.truffle.api.TruffleLanguage.ParsingRequest%29) by the language **See also** - [`for embedding of Truffle languages in Java host applications.`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html) ## Nested types - [`TruffleLanguage.ContextLocalFactory`](com/oracle/truffle/api/TruffleLanguage.ContextLocalFactory.md) (interface): Context local factory for Truffle languages. - [`TruffleLanguage.ContextLocalProvider`](com/oracle/truffle/api/TruffleLanguage.ContextLocalProvider.md) (class): Provider for creating context local and context thread local references. - [`TruffleLanguage.ContextPolicy`](com/oracle/truffle/api/TruffleLanguage.ContextPolicy.md) (enum class): Defines the supported policy for reusing languages per context. - [`TruffleLanguage.ContextReference`](com/oracle/truffle/api/TruffleLanguage.ContextReference.md) (abstract class): Represents a reference to the current context. - [`TruffleLanguage.ContextThreadLocalFactory`](com/oracle/truffle/api/TruffleLanguage.ContextThreadLocalFactory.md) (interface): Context thread local factory for Truffle languages. - [`TruffleLanguage.Env`](com/oracle/truffle/api/TruffleLanguage.Env.md) (class): Represents execution environment of the TruffleLanguage. - [`TruffleLanguage.ExitMode`](com/oracle/truffle/api/TruffleLanguage.ExitMode.md) (enum class): Mode of exit operation. - [`TruffleLanguage.InlineParsingRequest`](com/oracle/truffle/api/TruffleLanguage.InlineParsingRequest.md) (class): Request for inline parsing. - [`TruffleLanguage.LanguageReference`](com/oracle/truffle/api/TruffleLanguage.LanguageReference.md) (abstract class): Represents a reference to the current language instance. - [`TruffleLanguage.ParsingRequest`](com/oracle/truffle/api/TruffleLanguage.ParsingRequest.md) (class): Request for parsing. - [`TruffleLanguage.Registration`](com/oracle/truffle/api/TruffleLanguage.Registration.md) (annotation interface): The annotation to use to register your language to the Polyglot API. ## Fields ### locals `protected final TruffleLanguage.ContextLocalProvider locals`. Since 23.1. Provider for creating context local and context thread local references. See also: `TruffleLanguage.ContextLocalProvider.createContextLocal(TruffleLanguage.ContextLocalFactory)`, `TruffleLanguage.ContextLocalProvider.createContextThreadLocal(TruffleLanguage.ContextThreadLocalFactory)`. Cite: `com/oracle/truffle/api/TruffleLanguage.html#locals` ## Constructors ### TruffleLanguage() `protected TruffleLanguage()`. Since 0.8 or earlier. Constructor to be called by subclasses. Language should not create any `RootNode`s in its constructor. The RootNodes created in the language constructor are not associated with a Context and they don't respect Context's engine options. The needed RootNodes can be created in the `createContext(Env)`. Cite: `com/oracle/truffle/api/TruffleLanguage.html#()` ## Methods ### areOptionsCompatible(OptionValues, OptionValues) `protected boolean areOptionsCompatible(OptionValues firstOptions, OptionValues newOptions)`. Since 19.0. Returns `true` if the combination of two sets of options allow to `share` or `reuse` the same language instance, else `false`. If options are incompatible then a new language instance will be created for a new context. The default implementation returns `true`. If the context policy of a language is set to `exclusive` (default behavior) then `areOptionsCompatible(OptionValues, OptionValues)` will never be invoked as `TruffleLanguage` instances will not be shared for multiple contexts. For the other context policies `reuse` and `shared` this method can be used to further restrict the reuse of language instances. Compatibility influences `parse caching` because it uses the `language` instance as a key. Example usage of areOptionsCompatible if sharing of the language instances and parse caching should be restricted by the script version option: Parameters: `firstOptions` `OptionValues`: the options used to create the first context, never `null`. `newOptions` `OptionValues`: the options that will be used for the new context, never `null`. See also: `ContextPolicy`, `parse(ParsingRequest)`. Cite: `com/oracle/truffle/api/TruffleLanguage.html#areOptionsCompatible(org.graalvm.options.OptionValues,org.graalvm.options.OptionValues)` ```java class CompatibleLanguage extends TruffleLanguage { @Option(help = "", category = OptionCategory.USER) static final OptionKey ScriptVersion = new OptionKey<>("ECMA2017"); @Override protected boolean areOptionsCompatible(OptionValues firstOptions, OptionValues newOptions) { return firstOptions.get(ScriptVersion). equals(newOptions.get(ScriptVersion)); } @Override protected OptionDescriptors getOptionDescriptors() { return new CompatibleLanguageOptionDescriptors(); } } ``` ### createContext(TruffleLanguage.Env) `protected abstract C createContext(TruffleLanguage.Env env)`. Since 0.8 or earlier. Creates internal representation of the executing context suitable for given environment. Each time the `language` is used by a new [`org.graalvm.polyglot.Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html), the system calls this method to let the `language` prepare for *execution*. The returned execution context is completely language specific; it is however expected it will contain reference to here-in provided `env` and adjust itself according to parameters provided by the `env` object. The context created by this method is accessible using `context references`. An [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) is thrown if the context is tried to be accessed while the createContext method is executed. This method shouldn't perform any complex operations. The runtime system is just being initialized and for example making `calls into other languages` and assuming your language is already initialized and others can see it would be wrong - until you return from this method, the initialization isn't over. The same is true for instrumentation, the instruments cannot receive any meta data about code executed during context creation. Should there be a need to perform complex initialization, do it by overriding the `initializeContext(java.lang.Object)` method. Additional services provided by the language must be `registered` by this method otherwise [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) is thrown. May return `null` if the language does not need any per-[context](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html) state. Otherwise it should return a new object instance every time it is called. Parameters: `env` `TruffleLanguage.Env`: the environment the language is supposed to operate in. Returns `C`: internal data of the language in given environment or `null`. Cite: `com/oracle/truffle/api/TruffleLanguage.html#createContext(com.oracle.truffle.api.TruffleLanguage.Env)` ### initializeContext(C) `protected void initializeContext(C context) throws Exception`. Since 0.17. Perform any complex initialization. The `createContext(com.oracle.truffle.api.TruffleLanguage.Env)` factory method shouldn't do any complex operations. Just create the instance of the context, let the runtime system register it properly. Should there be a need to perform complex initialization, override this method and let the runtime call it *later* to finish any *post initialization* actions. Example: Parameters: `context` `C`: the context created by `createContext(com.oracle.truffle.api.TruffleLanguage.Env)`. Throws: `Exception`: if something goes wrong. Cite: `com/oracle/truffle/api/TruffleLanguage.html#initializeContext(C)` ```java class PostInitLanguage extends TruffleLanguage { @Override protected Context createContext(Env env) { // "quickly" create the context return new Context(env); } @Override protected void initializeContext(Context context) throws IOException { // called "later" to finish the initialization // for example call into another language Source source = Source.newBuilder("js", "function(x, y) x * y", "mul.js").build(); context.mul = context.env.parsePublic(source); } } ``` ### finalizeContext(C) `protected void finalizeContext(C context)`. Since 0.30. Performs language context finalization actions that are necessary before language contexts are `disposed`. However, in case the underlying polyglot context is being cancelled or hard-exited, `disposeContext(Object)` is called even if `finalizeContext(Object)` throws an `com.oracle.truffle.api.exception.AbstractTruffleException` or a [`ThreadDeath`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ThreadDeath.html) cancel or exit exception. For the hard exit a language is supposed to run its finalization actions that require running guest code in `exitContext(Object, ExitMode, int)`, but please note that after `exitContext(Object, ExitMode, int)` runs for a language, the language can still be invoked from `exitContext(Object, ExitMode, int)` for a different language. Therefore, for instance, finalization for standard streams should both flush and set them to unbuffered mode at the end of exitContext, so that running guest code is not required to dispose the streams after that point. Context finalization is invoked even if a context was cancelled. In such a case, if guest code would run as part of the finalization, it would be cancelled at the next polled `safepoint`. If there is guest code that always needs to run even if cancelled, e.g. to prevent resource leakage, use `TruffleSafepoint.setAllowActions(boolean)` to temporarily disable safepoints while executing that code. All installed languages must remain usable after finalization. The finalization order can be influenced by specifying `language dependencies`. By default internal languages are finalized last, otherwise, the default order is unspecified but deterministic. While the finalization code is run, other language contexts may become initialized. In such a case, the finalization order may be non-deterministic and/or not respect the order specified by language dependencies. All threads `created` by the language must be stopped and joined during finalizeContext. The languages are responsible for fulfilling that contract, otherwise, an [`AssertionError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AssertionError.html) is thrown. It's not safe to use the [`ExecutorService.awaitTermination(long, java.util.concurrent.TimeUnit)`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/ExecutorService.html#awaitTermination%28long,java.util.concurrent.TimeUnit%29) to detect Thread termination as the polyglot thread may be cancelled before executing the executor worker. During finalizeContext, all unclosed inner contexts `created` by the language must be left on all threads where the contexts are still active. No active inner context is allowed after `finalizeContext(Object)` returns, otherwise it is an internal error. Non-active inner contexts `created` by the language that are still unclosed after `finalizeContext(Object)` returns are automatically closed by Truffle. Typical implementation looks like: Parameters: `context` `C`: the context created by `createContext(com.oracle.truffle.api.TruffleLanguage.Env)`. See also: `for specifying language dependencies.`. Cite: `com/oracle/truffle/api/TruffleLanguage.html#finalizeContext(C)` ```java class AsyncThreadLanguage extends TruffleLanguage { @Override protected Context createContext(Env env) { return new Context(env); } @Override protected boolean isThreadAccessAllowed(Thread thread, boolean singleThreaded) { // allow access from any thread instead of just one return true; } @Override protected void initializeContext(Context context) throws Exception { // create and start a Thread for the asynchronous task // remeber the Thread reference to stop and join it in // the finalizeContext Thread t = context.env.newTruffleThreadBuilder(new Runnable() { @Override public void run() { // asynchronous task } }).build(); context.startedThreads.add(t); t.start(); } @Override protected void finalizeContext(Context context) { // stop and join all the created Threads boolean interrupted = false; for (int i = 0; i < context.startedThreads.size();) { Thread threadToJoin = context.startedThreads.get(i); try { if (threadToJoin != Thread.currentThread()) { threadToJoin.interrupt(); threadToJoin.join(); } i++; } catch (InterruptedException ie) { interrupted = true; } } if (interrupted) { Thread.currentThread().interrupt(); } } } ``` ### exitContext(C, TruffleLanguage.ExitMode, int) `protected void exitContext(C context, TruffleLanguage.ExitMode exitMode, int exitCode)`. Since 22.0. Performs language exit event actions that are necessary before language contexts are `finalized`. However, in case the underlying polyglot context is being cancelled, `exit notifications` are not executed. Also, for `hard exit`, `finalizeContext(Object)` is called even if `exitContext(Object, ExitMode, int)` throws an `com.oracle.truffle.api.exception.AbstractTruffleException` or a [`ThreadDeath`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ThreadDeath.html) cancel or exit exception. All initialized language contexts must remain usable after exit notifications. In case a `com.oracle.truffle.api.exception.AbstractTruffleException` or the [`ThreadDeath`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ThreadDeath.html) exit exception is thrown during an `hard exit notification`, it is just logged and otherwise ignored and the notification process continues with the next language in order. In case the [`ThreadDeath`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ThreadDeath.html) cancel exception is thrown, it means the context is being cancelled in which case the exit notification process immediately stops. The exit notification order can be influenced by specifying `language dependencies` - The exit notification for language A that depends on language B is executed before the exit notification for language B. By default, notifications for internal languages are executed last, otherwise, the default order is unspecified but deterministic. During `hard exit` notification, a language is supposed to run its finalization actions that require running guest code instead of running them in `finalizeContext(Object)`. While the exit notification code is run, all languages remain fully functional. Also, other language contexts may become initialized. In such a case, the notification order may be non-deterministic and/or not respect the order specified by language dependencies. In case `TruffleContext.closeExited(Node, int)` is called during a `natural exit` notification, natural exit notifications for remaining language contexts are not executed and the `hard exit` process starts by executing `hard exit` notifications. In case `TruffleContext.closeExited(Node, int)` is called during a `hard exit` notification, it just throws the special [`ThreadDeath`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ThreadDeath.html) exit exception, which is then just logged as described above. In case the underlying polyglot context is cancelled by e.g. `TruffleContext.closeCancelled(Node, String)` during exit notifications, guest code executed during exit notification is regularly cancelled, i.e., throws the [`ThreadDeath`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ThreadDeath.html) cancel exception, and the notification process does not continue as described above. In the case of `hard exit`, if the current context has inner contexts that are still active, the execution for them will be stopped as well after all language exit notifications are executed for the outer context, but the exit notifications for the inner contexts are not automatically executed. The language needs to take appropriate action to make sure inner contexts are exited properly. Parameters: `context` `C`: language context. `exitMode` `TruffleLanguage.ExitMode`: mode of exit. `exitCode` `int`: exit code that was specified for exit. See also: [Context Exit](https://github.com/oracle/graal/blob/master/truffle/docs/Exit.md). Cite: `com/oracle/truffle/api/TruffleLanguage.html#exitContext(C,com.oracle.truffle.api.TruffleLanguage.ExitMode,int)` ### initializeMultipleContexts() `protected void initializeMultipleContexts()`. Since 19.0. Initializes this language instance for use with multiple contexts. Whether a language instance supports being used for multiple contexts depends on its `context policy`. For any sharing of a language instance for multiple language contexts to take place a context must be created with sharing enabled. By default sharing is disabled for polyglot contexts. Sharing can be enabled by specifying an [`explicit engine`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.Builder.html#engine%28org.graalvm.polyglot.Engine%29) or using an option. Before any language is used for sharing `initializeMultipleContexts()` is invoked. It is guaranteed that sharing between multiple contexts is `initialized` before any language context is `created`. A language may use this method to configure itself to use context independent speculations only. Since Truffle nodes are never shared between multiple language instances it is sufficient to keep track of whether sharing is enabled using a non-volatile boolean field instead of an assumption. They field may also be annotated with `CompilationFinal` as it is guaranteed that this method is called prior to any compilation. The following criteria should be satisfied when supporting context independent code: All speculation on runtime value identity must be disabled with multiple contexts initialized, as they will lead to a guaranteed deoptimization when used with a second context.; Function inline caches should be modified and implemented as a two-level inline cache. The first level speculates on the function instance's identity and the second level on the underlying CallTarget instance. The first level cache must be disabled if multiple contexts are initialized, as this would unnecessarily cause deoptimization.; The DynamicObject root Shape instance should be stored in the language instance instead of the language context. Otherwise, any inline cache on shapes will not stabilize and ultimately end up in the generic state.; All Node implementations must not store context-dependent data structures or context-dependent runtime values.; All assumption instances should be stored in the language instance instead of the context. With multiple contexts initialized, the context instance read using context references may no longer be a constant. In this case any assumption read from the context would not be folded and they would cause significant runtime performance overhead. Assumptions from the language can always be folded by the compiler in both single and multiple context mode. See also: `More information on sharing language instances for multiple contexts.`, `Specify option configurations that make sharing incompatible.`, `ContextPolicy`. Cite: `com/oracle/truffle/api/TruffleLanguage.html#initializeMultipleContexts()` ### disposeContext(C) `protected void disposeContext(C context)`. Since 0.8 or earlier. Disposes the context created by `createContext(com.oracle.truffle.api.TruffleLanguage.Env)`. A dispose cleans up all resources associated with a context. The context may become unusable after it was disposed. It is not allowed to run guest language code while disposing a context. Finalization code should be run in `finalizeContext(Object)` instead. Finalization will be performed prior to context `disposal`. However, in case the underlying polyglot context is being cancelled, `disposeContext(Object)` is called even if `finalizeContext(Object)` throws `com.oracle.truffle.api.exception.AbstractTruffleException` or [`ThreadDeath`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ThreadDeath.html) exception.. The disposal order can be influenced by specifying `language dependencies`. By default internal languages are disposed last, otherwise the default order is unspecified but deterministic. During disposal no other language must be accessed using the `language environment`. Parameters: `context` `C`: the context created by `createContext(com.oracle.truffle.api.TruffleLanguage.Env)`. See also: `to run finalization code for a context.`, `to perform disposal actions when a thread is no longer used.`. Cite: `com/oracle/truffle/api/TruffleLanguage.html#disposeContext(C)` ### parse(TruffleLanguage.ParsingRequest) `protected CallTarget parse(TruffleLanguage.ParsingRequest request) throws Exception`. Since 0.22. Parses the `provided source` and generates its appropriate AST representation. The parsing should execute no user code, it should only create the `Node` tree to represent the source. If the `provided source` does not correspond naturally to a `call target`, the returned call target should create and if necessary initialize the corresponding language entity and return it. The result of the parsing request is cached per language instance, `source` and `argument names`. It is safe to assume that current `language` instance and `argument names` will remain unchanged for a parsed `CallTarget`. The scope of the caching is influenced by the `context policy` and option `compatibility`. Caching may be `disabled` for sources. It is enabled for new sources by default. The `argumentNames` may contain symbolic names for actual parameters of the call to the returned value. The result should be a call target with method `CallTarget.call(java.lang.Object...)` that accepts as many arguments as were provided via the `ParsingRequest.getArgumentNames()` method. Implement `parse(com.oracle.truffle.api.TruffleLanguage.InlineParsingRequest)` to parse source in a specific context location. Parameters: `request` `TruffleLanguage.ParsingRequest`: request for parsing. Returns `CallTarget`: a call target to invoke which also keeps in memory the `Node` tree representing just parsed `code`. Throws: `Exception`: exception can be thrown when parsing goes wrong. Here-in thrown exception is propagated to the user who called one of `eval` methods of [`org.graalvm.polyglot.Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html). See also: `TruffleLanguage.Registration.contextPolicy()`. Cite: `com/oracle/truffle/api/TruffleLanguage.html#parse(com.oracle.truffle.api.TruffleLanguage.ParsingRequest)` ### parse(TruffleLanguage.InlineParsingRequest) `protected ExecutableNode parse(TruffleLanguage.InlineParsingRequest request) throws Exception`. Since 0.31. Parses the `provided source snippet` at the `provided location` and generates its appropriate AST representation. The parsing should execute no user code, it should only create the `Node` tree to represent the source. The parsing should be performed in a context (specified by `InlineParsingRequest.getLocation()`). The result should be an AST fragment with method `ExecutableNode.execute(com.oracle.truffle.api.frame.VirtualFrame)` that accepts frames valid at the `provided location`. When not implemented, `null` is returned by default. Parameters: `request` `TruffleLanguage.InlineParsingRequest`: request for parsing. Returns `ExecutableNode`: a fragment to invoke which also keeps in memory the `Node` tree representing just parsed `code`, or `null` when inline parsing of code snippets is not implemented. Throws: `Exception`: exception can be thrown when parsing goes wrong. Cite: `com/oracle/truffle/api/TruffleLanguage.html#parse(com.oracle.truffle.api.TruffleLanguage.InlineParsingRequest)` ### getOptionDescriptors() `protected OptionDescriptors getOptionDescriptors()`. Since 0.27. Returns a set of option descriptors that are supported by this language. Option values are accessible using the `environment` when the context is `created`. To construct option descriptors from a list then [`OptionDescriptors.create(List)`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/options/OptionDescriptors.html#create%28java.util.List%29) can be used. Languages must always return the same option descriptors independent of the language instance or side-effects. See also: `For an example of declaring the option descriptor using an annotation.`. Cite: `com/oracle/truffle/api/TruffleLanguage.html#getOptionDescriptors()` ### getSourceOptionDescriptors() `protected OptionDescriptors getSourceOptionDescriptors()`. Since 25.0. Returns a set of source option descriptors that are supported by this language. Option values are accessible using the `environment` or using a `parsing request` when the source is parsed. Languages must always return the same option descriptors independent of the language instance or side-effects. See also: `For an example of declaring the option descriptor using an annotation.`. Cite: `com/oracle/truffle/api/TruffleLanguage.html#getSourceOptionDescriptors()` ### patchContext(C, TruffleLanguage.Env) `protected boolean patchContext(C context, TruffleLanguage.Env newEnv)`. Since 0.31. Notifies the language with pre-initialized context about `Env` change. See [`org.graalvm.polyglot.Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html) for information how to enable the Context pre-initialization. During the pre-initialization (in the native compilation time) the `createContext(com.oracle.truffle.api.TruffleLanguage.Env)` and `initializeContext(java.lang.Object)` methods are called. In the image execution time, the `patchContext(java.lang.Object, com.oracle.truffle.api.TruffleLanguage.Env)` is called on all languages whose contexts were created during the pre-initialization a consequence of [`org.graalvm.polyglot.Context.create(java.lang.String...)`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html#create%28java.lang.String...%29) invocation. The contexts are patched in a topological order starting from dependent languages. If the `patchContext(java.lang.Object, com.oracle.truffle.api.TruffleLanguage.Env)` is successful for all pre-initialized languages the pre-initialized context is used, otherwise a new context is created. Typical implementation looks like: Parameters: `context` `C`: the context created by `createContext(com.oracle.truffle.api.TruffleLanguage.Env)` during pre-initialization. `newEnv` `TruffleLanguage.Env`: the new environment replacing the environment used in pre-initialization phase. Returns `boolean`: true in case of successful environment update. When the context cannot be updated to a new environment return false to create a new context. By default it returns `false` to prevent an usage of pre-initialized context by a language which is not aware of context pre-initialization. Cite: `com/oracle/truffle/api/TruffleLanguage.html#patchContext(C,com.oracle.truffle.api.TruffleLanguage.Env)` ```java @Override protected boolean patchContext(Context context, Env newEnv) { if (!optionsAllowPreInitializedContext(context, newEnv)) { // Incompatible options - cannot use pre-initialized context return false; } context.env = newEnv; context.args = newEnv.getApplicationArguments(); context.in = newEnv.in(); context.out = newEnv.out(); context.err = newEnv.err(); return true; } private boolean optionsAllowPreInitializedContext(Context context, Env newEnv) { // Verify that values of important options in the new Env do not differ // from values in the pre-initialized context final String newVersionValue = newEnv.getOptions().get(version); return Objects.equals(context.languageVersion, newVersionValue); } ``` ### isThreadAccessAllowed(Thread, boolean) `protected boolean isThreadAccessAllowed(Thread thread, boolean singleThreaded)`. Since 0.28. Returns `true` if code of this language is allowed to be executed on this thread. The method returns `false` to deny execution on this thread. The default implementation denies access to more than one thread at the same time. The [`current thread`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Thread.html#currentThread%28%29) may differ from the passed thread. If this method throws an `com.oracle.truffle.api.exception.AbstractTruffleException` the exception interop messages may be executed without a context being entered. **Example multi-threaded language implementation:**. Parameters: `thread` `Thread`: the thread that accesses the context for the first time. `singleThreaded` `boolean`: `true` if the access is considered single-threaded, `false` if more than one thread is active at the same time. Cite: `com/oracle/truffle/api/TruffleLanguage.html#isThreadAccessAllowed(java.lang.Thread,boolean)` ```java class MultiThreadedLanguage extends TruffleLanguage { @Override protected Context createContext(Env env) { return new Context(env); } @Override protected boolean isThreadAccessAllowed(Thread thread, boolean singleThreaded) { // allow access from any thread instead of just one return true; } @Override protected void initializeMultiThreading(Context context) { // perform actions when the context is switched to multi-threading context.singleThreaded.invalidate(); } @Override protected void initializeThread(Context context, Thread thread) { // perform initialization actions for threads } @Override protected void disposeThread(Context context, Thread thread) { // perform disposal actions for threads } } ``` ### initializeMultiThreading(C) `protected void initializeMultiThreading(C context)`. Since 0.28. Invoked before the context is accessed from multiple threads at the same time. This allows languages to perform actions that are required to support multi-threading. It will never be invoked if `isThreadAccessAllowed(Thread, boolean)` is implemented to deny access from multiple threads at the same time. All initialized languages must allow multi-threading for this method to be invoked. If this method throws an `com.oracle.truffle.api.exception.AbstractTruffleException` the exception interop messages may be executed without a context being entered. **Example multi-threaded language implementation:**. Parameters: `context` `C`: the context that should be prepared for multi-threading. Cite: `com/oracle/truffle/api/TruffleLanguage.html#initializeMultiThreading(C)` ```java class MultiThreadedLanguage extends TruffleLanguage { @Override protected Context createContext(Env env) { return new Context(env); } @Override protected boolean isThreadAccessAllowed(Thread thread, boolean singleThreaded) { // allow access from any thread instead of just one return true; } @Override protected void initializeMultiThreading(Context context) { // perform actions when the context is switched to multi-threading context.singleThreaded.invalidate(); } @Override protected void initializeThread(Context context, Thread thread) { // perform initialization actions for threads } @Override protected void disposeThread(Context context, Thread thread) { // perform disposal actions for threads } } ``` ### initializeThread(C, Thread) `protected void initializeThread(C context, Thread thread)`. Since 0.28. Invoked before a context is accessed from a new thread. This allows the language to perform initialization actions for each thread before guest language code is executed. Also for languages that deny access from multiple threads at the same time, multiple threads may be initialized if they are used sequentially. This method will be invoked before the context is `initialized` for the thread the context will be initialized with. If the thread is stored in the context it must be referenced using [`WeakReference`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ref/WeakReference.html) to avoid leaking thread objects. The [`current thread`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Thread.html#currentThread%28%29) is equal to the initialized thread. If this method throws an `com.oracle.truffle.api.exception.AbstractTruffleException` the exception interop messages may be executed without a context being entered. **Example multi-threaded language implementation:**. Parameters: `context` `C`: the context that is entered. `thread` `Thread`: the thread that accesses the context for the first time. Cite: `com/oracle/truffle/api/TruffleLanguage.html#initializeThread(C,java.lang.Thread)` ```java class MultiThreadedLanguage extends TruffleLanguage { @Override protected Context createContext(Env env) { return new Context(env); } @Override protected boolean isThreadAccessAllowed(Thread thread, boolean singleThreaded) { // allow access from any thread instead of just one return true; } @Override protected void initializeMultiThreading(Context context) { // perform actions when the context is switched to multi-threading context.singleThreaded.invalidate(); } @Override protected void initializeThread(Context context, Thread thread) { // perform initialization actions for threads } @Override protected void disposeThread(Context context, Thread thread) { // perform disposal actions for threads } } ``` ### finalizeThread(C, Thread) `protected void finalizeThread(C context, Thread thread)`. Since 23.1. The behavior of this notification is different for `polyglot threads` and embedder threads. For `polyglot threads` the `finalizeThread` notification is invoked just before the context is left for the last time in the thread, and it is still safe to run guest code unless the context is cancelled or hard-exited. This allows the language to perform finalization actions for each thread and context. Polyglot threads are finalized before or while the context is finalized and it always holds that `thread == Thread.currentThread()`. Embedder threads are finalized after the context is finalized, but before it is disposed. `thread == Thread.currentThread()` holds only for the embedder thread that performed the context finalization. Finalization of other embedder threads is invoked in the context finalization thread as well, and so `thread != Thread.currentThread()`. It is still safe to run guest code in `finalizeThread` for an embedder thread unless the context is cancelled or hard-exited, but it is not allowed to initialize new language contexts or create polyglot threads. A language context initialization or creation of a polyglot thread in `finalizeThread` for an embedder thread results in [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html). Please note that embedder threads may be collected by the garbage collector before they can be finalized and may therefore not be finalized. Thread finalization is invoked before `thread disposal`. See also: `For usage details.`. Cite: `com/oracle/truffle/api/TruffleLanguage.html#finalizeThread(C,java.lang.Thread)` ### disposeThread(C, Thread) `protected void disposeThread(C context, Thread thread)`. Since 0.28. Invoked the last time code will be executed for this thread and context. This allows the language to perform cleanup actions for each thread and context. Threads might be disposed before after or while a context is disposed. The [`current thread`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Thread.html#currentThread%28%29) may differ from the disposed thread. Disposal of threads is only guaranteed for threads that were created by guest languages, so called `polyglot threads`. Other threads, created by the embedder, may be collected by the garbage collector before they can be disposed and may therefore not be disposed. See also: `For usage details.`. Cite: `com/oracle/truffle/api/TruffleLanguage.html#disposeThread(C,java.lang.Thread)` ### getScope(C) `protected Object getScope(C context)`. Since 20.3. Get a top scope of the language, if any. The returned object must be an `interop scope object` and may have `parent scopes`. The scope object exposes all top scopes variables as flattened `members`. Top scopes are independent of a `Frame`. See `com.oracle.truffle.api.interop.InteropLibrary.isScope(Object)` for details. The returned scope objects may be cached by the caller per language context. Therefore the method should always return equivalent top-scopes and variables objects for a given language context. Changes to the top scope by executing guest language code should be reflected by cached scope instances. It is recommended to store the top-scope directly in the language context for efficient access. Interpretation In most languages, just evaluating an expression like `Math` is equivalent of a lookup with the identifier 'Math' in the top-most scopes of the language. Looking up the identifier 'Math' should have equivalent semantics as reading with the key 'Math' from the variables object of one of the top-most scopes of the language. In addition languages may optionally allow modification and insertion with the variables object of the returned top-scopes. Languages may want to specify multiple parent top-scopes. It is recommended to stay as close as possible to the set of top-scopes that as is described in the guest language specification, if available. For example, in JavaScript, there is a 'global environment' and a 'global object' scope. While the global environment scope contains class declarations and is not insertable, the global object scope is used to insert new global variable values and is therefore insertable. Use Cases Top scopes are accessible to instruments with `com.oracle.truffle.api.instrumentation.TruffleInstrument.Env.getScope(LanguageInfo)`. They are used by debuggers to access the top-most scopes of the language.; Top scopes available in the [`polyglot API`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/package-summary.html) as context [`bindings`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html#getBindings%28java.lang.String%29) object. Access to members of the bindings object is applied to the returned scope object via interop.; Languages may expose other language scopes using a polyglot bindings builtin. E.g with `com.oracle.truffle.api.TruffleLanguage.Env.getScopePublic(LanguageInfo)`. Parameters: `context` `C`: the context to find the language top scope in. Returns `Object`: the scope object or `null` if the language does not support such concept. Cite: `com/oracle/truffle/api/TruffleLanguage.html#getScope(C)` ### isVisible(C, Object) `protected boolean isVisible(C context, Object value)`. Since 0.22. Decides whether the result of evaluating an interactive source should be printed to stdout. By default this methods returns `true` claiming all values are visible. This method affects behavior of [`org.graalvm.polyglot.Context.eval(org.graalvm.polyglot.Source)`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html#eval%28org.graalvm.polyglot.Source%29) - when evaluating an `interactive source` the result of the evaluation is tested for `visibility` and if the value is found visible, it gets converted to string and printed to [`standard output`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.Builder.html#out%28java.io.OutputStream%29). A language can control whether a value is or isn't printed by overriding this method and returning `false` for some or all values. In such case it is up to the language itself to use the `Env.out()`, `Env.err()` and `Env.in()` streams of the environment. When evaluation is called with an `interactive source` of a language that controls its interactive behavior, it is the responsibility of the language itself to print the result to use the `Env.out()`, `Env.err()` and `Env.in()` streams of the environment. Parameters: `context` `C`: the execution context for doing the conversion. `value` `Object`: the value to check. Either primitive type or `com.oracle.truffle.api.interop.TruffleObject`. Returns `boolean`: `true` if the language implements an interactive response to evaluation of interactive sources. Cite: `com/oracle/truffle/api/TruffleLanguage.html#isVisible(C,java.lang.Object)` ### getLanguageView(C, Object) `protected Object getLanguageView(C context, Object value)`. Since 20.1. Wraps the value to provide language-specific information for primitive and foreign values. Foreign values should be enhanced to look like the most generic object type of the language. The wrapper needs to introduce any "virtual" methods and properties that are commonly used in language constructs and in algorithms that are written to work on this generic object type. The wrapper may add or remove existing interop traits, but it is not allowed to change the `interop type`. For example, it is not allowed to change the type from number to string. If the behavior of an existing trait is modified then all writes on the mapper need to be forwarded to the underlying object, apart from the virtual members. Writes to the virtual members should be persisted in the wrapper if this is the behavior of the object type that is being mapped to. Every language view wrapper must return the current language as their associated `language`. An [`AssertionError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AssertionError.html) is thrown when a language view is requested if this contract is violated. Example modifications language view wrappers may perform: Provide a language specific `display string` for primitive and foreign values.; Return a language specific `metaobject` for primitive or foreign values.; Add virtual members to the object for the view. For example, any JavaScript object is expected to have an implicit \_\_proto\_\_ member. Foreign objects, even if they do not have such a member, are interpreted as if they have.; There are languages where all scalar values are also vectors. In such a case the array element trait may be added using the language wrapper to such values. The default implementation returns `null`. If `null` is returned then the default language view will be used. The default language view wraps the value and returns the current language as their associated language. With the default view wrapper all interop library messages will be forwarded to the delegate value. This following example shows a simplified language view. For a full implementation including an example of metaobjects can be found in the Truffle examples language "SimpleLanguage". Parameters: `context` `C`: the current context. `value` `Object`: the value. Cite: `com/oracle/truffle/api/TruffleLanguage.html#getLanguageView(C,java.lang.Object)` ```java @ExportLibrary(value = InteropLibrary.class, delegateTo = "delegate") final class ExampleLanguageView implements TruffleObject { protected final Object delegate; ExampleLanguageView(Object delegate) { this.delegate = delegate; } @ExportMessage boolean hasLanguageId() { return true; } @ExportMessage String getLanguageId() { return MyLanguage.ID; } @ExportMessage Object toDisplayString(boolean allowSideEffects, @CachedLibrary("this.delegate") InteropLibrary dLib) { try { if (dLib.isString(this.delegate)) { return dLib.asString(this.delegate); } else if (dLib.isBoolean(this.delegate)) { return dLib.asBoolean(this.delegate) ? "TRUE" : "FALSE"; } else if (dLib.fitsInLong(this.delegate)) { return longToString(dLib.asLong(this.delegate)); } else { // full list truncated for this language return "Unsupported value"; } } catch (UnsupportedMessageException e) { CompilerDirectives.transferToInterpreter(); throw new AssertionError(e); } } @TruffleBoundary private static String longToString(long value) { return String.valueOf(value); } @ExportMessage boolean hasMetaObject(@CachedLibrary("this.delegate") InteropLibrary dLib) { return dLib.isString(this.delegate)// || dLib.fitsInLong(this.delegate)// || dLib.isBoolean(this.delegate); } @ExportMessage Object getMetaObject(@CachedLibrary("this.delegate") InteropLibrary dLib) throws UnsupportedMessageException { if (dLib.isString(this.delegate)) { return MyMetaObject.PRIMITIVE_STRING; } else if (dLib.isBoolean(this.delegate)) { return MyMetaObject.PRIMITIVE_LONG; } else if (dLib.fitsInLong(this.delegate)) { return MyMetaObject.PRIMITIVE_BOOLEAN; } else { // no associable metaobject throw UnsupportedMessageException.create(); } } } ``` ### createContextLocal(TruffleLanguage.ContextLocalFactory) `@Deprecated protected final ContextLocal createContextLocal(TruffleLanguage.ContextLocalFactory factory)`. Since 20.3. Deprecated. in 23.1, use `TruffleLanguage.ContextLocalProvider.createContextLocal(TruffleLanguage.ContextLocalFactory)` instead. Creates a new context local reference for this Truffle language. Starting with JDK 21, using this method leads to a this-escape warning. Use `TruffleLanguage.ContextLocalProvider.createContextLocal(TruffleLanguage.ContextLocalFactory)` instead. Cite: `com/oracle/truffle/api/TruffleLanguage.html#createContextLocal(com.oracle.truffle.api.TruffleLanguage.ContextLocalFactory)` ### createContextThreadLocal(TruffleLanguage.ContextThreadLocalFactory) `@Deprecated protected final ContextThreadLocal createContextThreadLocal(TruffleLanguage.ContextThreadLocalFactory factory)`. Since 20.3. Deprecated. in 23.1, use `TruffleLanguage.ContextLocalProvider.createContextThreadLocal(TruffleLanguage.ContextThreadLocalFactory)` instead. Creates a new context thread local reference for this Truffle language. Starting with JDK 21, using this method leads to a this-escape warning. Use `TruffleLanguage.ContextLocalProvider.createContextThreadLocal(TruffleLanguage.ContextThreadLocalFactory)` instead. Cite: `com/oracle/truffle/api/TruffleLanguage.html#createContextThreadLocal(com.oracle.truffle.api.TruffleLanguage.ContextThreadLocalFactory)` ### getLanguageHome() `protected final String getLanguageHome()`. Since 19.0. Returns the home location for this language or `null` if the language home is not set. Languages consumed from the Maven repository typically don't have a language home. For legacy graalvm or standalone builds the language home corresponds to the directory in which the Jar file is located, if run from a Jar file. For an AOT compiled binary, this corresponds to the location of the language files in the default GraalVM distribution layout. Cite: `com/oracle/truffle/api/TruffleLanguage.html#getLanguageHome()` ### getAsynchronousStackDepth() `protected final int getAsynchronousStackDepth()`. Since 20.1.0. Get the depth of asynchronous stack. When zero, the language should not sacrifice performance to be able to provide asynchronous stack. When the depth is non-zero, the language should provide asynchronous stack up to that depth. The language may provide more asynchronous frames than this depth if it's of no performance penalty, or if requested by other (e.g. language-specific) options. The returned depth may change at any time. Override `RootNode.findAsynchronousFrames(Frame)` to provide the asynchronous stack frames. See also: `RootNode.findAsynchronousFrames(Frame)`. Cite: `com/oracle/truffle/api/TruffleLanguage.html#getAsynchronousStackDepth()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ TruffleLanguage.ContextLocalFactory [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 20.3. Nested in [`TruffleLanguage`](com/oracle/truffle/api/TruffleLanguage.md). ```java @FunctionalInterface protected interface TruffleLanguage.ContextLocalFactory ``` Context local factory for Truffle languages. Creates a new value per context. ## Methods ### create(C) `T create(C context)`. Since 20.3. Returns a new value for a context local of a language. The returned value must not be `null` and must return a stable and exact type per registered language. A thread local must always return the same [`class`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), even for multiple instances of the same `TruffleLanguage`. If this method throws an `com.oracle.truffle.api.exception.AbstractTruffleException` the exception interop messages may be executed without a context being entered. See also: `TruffleLanguage.ContextLocalProvider.createContextLocal(TruffleLanguage.ContextLocalFactory)`. Cite: `com/oracle/truffle/api/TruffleLanguage.ContextLocalFactory.html#create(C)` # ◆ TruffleLanguage.ContextLocalProvider [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 23.1. Nested in [`TruffleLanguage`](com/oracle/truffle/api/TruffleLanguage.md). ```java protected static final class TruffleLanguage.ContextLocalProvider ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `ContextLocalProvider` Provider for creating context local and context thread local references. **See also** - [`TruffleLanguage.locals`](com/oracle/truffle/api/TruffleLanguage.md#locals) - [`TruffleLanguage.ContextLocalProvider.createContextLocal(TruffleLanguage.ContextLocalFactory)`](com/oracle/truffle/api/TruffleLanguage.ContextLocalProvider.md#createContextLocal%28com.oracle.truffle.api.TruffleLanguage.ContextLocalFactory%29) - [`TruffleLanguage.ContextLocalProvider.createContextThreadLocal(TruffleLanguage.ContextThreadLocalFactory)`](com/oracle/truffle/api/TruffleLanguage.ContextLocalProvider.md#createContextThreadLocal%28com.oracle.truffle.api.TruffleLanguage.ContextThreadLocalFactory%29) ## Methods ### createContextLocal(TruffleLanguage.ContextLocalFactory) `public ContextLocal createContextLocal(TruffleLanguage.ContextLocalFactory factory)`. Since 23.1. Creates a new context local reference for this Truffle language. Context locals for languages allow to store additional top-level values for each context besides the language context. The advantage of context locals compared to storing the value in a field of the language context is that reading a context local requires one indirection less. It is recommended to use context locals for languages only if the read is critical for performance. Context local references must be created during the invocation in the `TruffleLanguage` constructor. Calling this method at a later point in time will throw an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html). For each registered `TruffleLanguage` subclass it is required to always produce the same number of context local references. The values produced by the factory must not be `null` and use a stable exact value type for each instance of a registered language class. If the return value of the factory is not stable or `null` then an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) is thrown. These restrictions allow the Truffle runtime to read the value more efficiently. Usage example: Cite: `com/oracle/truffle/api/TruffleLanguage.ContextLocalProvider.html#createContextLocal(com.oracle.truffle.api.TruffleLanguage.ContextLocalFactory)` ```java @TruffleLanguage.Registration(id = "example", name = "ExampleLanguage") public final class ExampleLanguage extends TruffleLanguage { final ContextLocal contextLocal = locals.createContextLocal(ExampleLocal::new); @Override protected Env createContext(Env env) { return env; } @Override protected CallTarget parse(ParsingRequest request) throws Exception { return new RootNode(this) { @Override public Object execute(VirtualFrame frame) { // fast read ExampleLocal local = contextLocal.get(); // access local return ""; } }.getCallTarget(); } static final class ExampleLocal { final Env env; ExampleLocal(Env env) { this.env = env; } } } ``` ### createContextThreadLocal(TruffleLanguage.ContextThreadLocalFactory) `public ContextThreadLocal createContextThreadLocal(TruffleLanguage.ContextThreadLocalFactory factory)`. Since 23.1. Creates a new context thread local reference for this Truffle language. Context threadlocals for languages allow storing additional top-level values for each context and thread. The factory may be invoked on any thread other than the thread of the context thread local value. Context thread local references must be created during the invocation in the `TruffleLanguage` constructor. Calling this method at a later point in time will throw an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html). For each registered `TruffleLanguage` subclass it is required to always produce the same number of context thread local references. The values produced by the factory must not be `null` and use a stable exact value type for each instance of a registered language class. If the return value of the factory is not stable or `null` then an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) is thrown. These restrictions allow the Truffle runtime to read the value more efficiently. Context thread locals should not contain a strong reference to the provided thread. Use a weak reference instance for that purpose. Usage example: Cite: `com/oracle/truffle/api/TruffleLanguage.ContextLocalProvider.html#createContextThreadLocal(com.oracle.truffle.api.TruffleLanguage.ContextThreadLocalFactory)` ```java @TruffleLanguage.Registration(id = "example", name = "ExampleLanguage") public static class ExampleLanguage extends TruffleLanguage { final ContextThreadLocal threadLocal = locals.createContextThreadLocal(ExampleLocal::new); @Override protected Env createContext(Env env) { return env; } @Override protected CallTarget parse(ParsingRequest request) throws Exception { return new RootNode(this) { @Override public Object execute(VirtualFrame frame) { // fast read ExampleLocal local = threadLocal.get(); // access local return ""; } }.getCallTarget(); } static final class ExampleLocal { final Env env; final WeakReference thread; ExampleLocal(Env env, Thread thread) { this.env = env; this.thread = new WeakReference<>(thread); } } } ``` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ≡ TruffleLanguage.ContextPolicy [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Enum class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 19.0. Nested in [`TruffleLanguage`](com/oracle/truffle/api/TruffleLanguage.md). ```java public enum TruffleLanguage.ContextPolicy ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html) > `ContextPolicy` Defines the supported policy for reusing [`languages`](com/oracle/truffle/api/TruffleLanguage.md) per context. I.e. the policy specifies the degree of sharing that is allowed between multiple language contexts. The default policy is [`exclusive`](com/oracle/truffle/api/TruffleLanguage.ContextPolicy.md#EXCLUSIVE). Every language is encouraged to try to support a context policy that is as permissive as possible, where [`exclusive`](com/oracle/truffle/api/TruffleLanguage.ContextPolicy.md#EXCLUSIVE) is the least and [`shared`](com/oracle/truffle/api/TruffleLanguage.ContextPolicy.md#SHARED) is the most permissive policy. [`Parse caching`](com/oracle/truffle/api/TruffleLanguage.md#parse%28com.oracle.truffle.api.TruffleLanguage.ParsingRequest%29) is scoped per [`language`](com/oracle/truffle/api/TruffleLanguage.md) instance, therefore the context policy influences its behavior. If multiple sharable languages are used at the same time, nodes of sharable languages may adopt nodes of a non-sharable languages indirectly, e.g. through Truffle interoperability. This would complicate language implementations as they would always need to support sharing for their nodes. To avoid this problem, Truffle uses sharing layers. Sharing layers ensure that every node created by a language instance can only be observed by a single language instance at a time. Sharing layers operate on the principle that all languages share the code with the same language instance or no language shares. As a convenient consequence any call to [`LanguageReference.get(Node)`](com/oracle/truffle/api/TruffleLanguage.LanguageReference.md#get%28com.oracle.truffle.api.nodes.Node%29) with an adopted [`Node`](com/oracle/truffle/api/nodes/Node.md) can fold to a constant during partial evaluation. For any sharing to take place a context must be created with sharing enabled. By default sharing is disabled for polyglot contexts. Sharing can be enabled by specifying an [`explicit engine`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.Builder.html#engine%28org.graalvm.polyglot.Engine%29) or using an option. Before any language is used for sharing [`TruffleLanguage.initializeMultipleContexts()`](com/oracle/truffle/api/TruffleLanguage.md#initializeMultipleContexts%28%29) is invoked. It is guaranteed that sharing between multiple contexts is [`initialized`](com/oracle/truffle/api/TruffleLanguage.md#initializeMultipleContexts%28%29) before any language context is [`created`](com/oracle/truffle/api/TruffleLanguage.md#createContext%28com.oracle.truffle.api.TruffleLanguage.Env%29). **See also** - [`To configure context policy for a language.`](com/oracle/truffle/api/TruffleLanguage.Registration.md#contextPolicy%28%29) - [`TruffleLanguage.parse(ParsingRequest)`](com/oracle/truffle/api/TruffleLanguage.md#parse%28com.oracle.truffle.api.TruffleLanguage.ParsingRequest%29) - [`TruffleLanguage.initializeMultipleContexts()`](com/oracle/truffle/api/TruffleLanguage.md#initializeMultipleContexts%28%29) ## Enum constants ### EXCLUSIVE `EXCLUSIVE`. Since 19.0. Use one exclusive `TruffleLanguage` instance per language context instance. Using this policy has the following implications: `Parse caching` is scoped per `language` instance. This means the language context instance may be directly stored in instance fields of AST nodes without the use of `ContextReference`. The use of `ContextReference` is still recommended to simplify migration to more permissive policies.; If the language does not allow `multi-threading` (default behavior) then the language instance is guaranteed to be used from one thread at a time only. Cached ASTs will not be used from multiple threads at the same time.; `TruffleLanguage.initializeMultipleContexts()` is guaranteed to never be invoked. Cite: `com/oracle/truffle/api/TruffleLanguage.ContextPolicy.html#EXCLUSIVE` ### REUSE `REUSE`. Since 19.0. Use a single `TruffleLanguage` instance per context instance, but allow the reuse of a language instance when a context was `disposed`. This policy is useful when parsed ASTs should be shared, but multiple thread execution of the AST is not yet supported by the language. Using this policy has the following implications: `Parse caching` is scoped per `language` instance. This means language context instances must NOT be directly stored in instance fields of AST nodes and the `ContextReference` must be used instead.; If the language does not `allow` access from multiple threads (default behavior) then the language instance is guaranteed to be used from one thread at a time only. In this case also cached ASTs will not be used from multiple threads at the same time. If the language allows access from multiple threads then also ASTs may be used from multiple threads at the same time.; `TruffleLanguage.initializeMultipleContexts()` will be invoked to notify the language that multiple contexts will be used with one language instance.; `Language` instance fields must only be used for data that can be shared across multiple contexts. Cite: `com/oracle/truffle/api/TruffleLanguage.ContextPolicy.html#REUSE` ### SHARED `SHARED`. Since 19.0. Use one `TruffleLanguage` instance for many language context instances. Using this policy has the following implications: `Parse caching` is scoped per `language` instance. With multiple language instances per context, context instances must *not* be directly stored in instance fields of AST nodes and the `ContextReference` must be used instead.; All methods of the `language` instance and parsed ASTs may be called from multiple threads at the same time independent of whether multiple thread access is `allowed` for the language.; `TruffleLanguage.initializeMultipleContexts()` will be invoked to notify the language that multiple contexts will be used with one language instance.; `Language` instance fields must only be used for data that can be shared across multiple contexts and mutable data held by the language instance must be synchronized to support concurrent access. Cite: `com/oracle/truffle/api/TruffleLanguage.ContextPolicy.html#SHARED` ## Methods ### values() `public static TruffleLanguage.ContextPolicy[] values()`. Returns the enum constants in declaration order. Returns `TruffleLanguage.ContextPolicy[]`: Returns the enum constants in declaration order. Cite: `com/oracle/truffle/api/TruffleLanguage.ContextPolicy.html#values()` ### valueOf(String) `public static TruffleLanguage.ContextPolicy valueOf(String name)`. Returns the enum constant with the given name. Parameters: `name` `String`: The exact name of the enum constant. Returns `TruffleLanguage.ContextPolicy`: Returns the enum constant with the given name. Cite: `com/oracle/truffle/api/TruffleLanguage.ContextPolicy.html#valueOf(java.lang.String)` ## Inherited members - From class [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#clone%28%29), [`compareTo`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#compareTo%28E%29), [`describeConstable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#describeConstable%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#finalize%28%29), [`getDeclaringClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#getDeclaringClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#hashCode%28%29), [`name`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#name%28%29), [`ordinal`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#ordinal%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#toString%28%29), [`valueOf`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#valueOf%28java.lang.Class,java.lang.String%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleLanguage.ContextReference [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 0.25 revised in 21.3. Nested in [`TruffleLanguage`](com/oracle/truffle/api/TruffleLanguage.md). ```java public abstract static class TruffleLanguage.ContextReference ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `ContextReference` Represents a reference to the current context. The current context is a thread local value that changes when polyglot context is entered or left. Context references are created using [`create(Class)`](com/oracle/truffle/api/TruffleLanguage.ContextReference.md#create%28java.lang.Class%29) and are intended to be stored in static final fields and accessed at runtime using [`ContextReference.get(Node)`](com/oracle/truffle/api/TruffleLanguage.ContextReference.md#get%28com.oracle.truffle.api.nodes.Node%29) with the current [`Node`](com/oracle/truffle/api/nodes/Node.md), if available, as parameter. Example intended usage: ```java public final class MyContext { private static final ContextReference REFERENCE = ContextReference.create(MyLanguage.class); public static MyContext get(Node node) { return REFERENCE.get(node); } } @Registration(...) public final class MyLanguage extends TruffleLanguage { // ... private static final LanguageReference REFERENCE = LanguageReference.create(MyLanguage.class); public static MyLanguage get(Node node) { return REFERENCE.get(node); } } public final class MyLanguageNode extends Node { // ... public Object execute(VirtualFrame frame) { MyContext currentContext = getContext(); MyLanguage currentLanguage = getLanguage(); // use context or language on the fast-path // references can also be used behind the boundary exampleBoundary(); } @TruffleBoundary public void exampleBoundary() { MyLanguage currentLanguage = MyLanguage.get(null); MyContext currentContext = MyContext.get(null); // use context or language on the slow-path } public final MyLanguage getLanguage() { return MyLanguage.get(this); } public final MyContext getContext() { return MyContext.get(this); } } ``` ## Constructors ### ContextReference() `protected ContextReference()`. Since 19.0. Constructors for subclasses. Cite: `com/oracle/truffle/api/TruffleLanguage.ContextReference.html#()` ## Methods ### get(Node) `public abstract C get(Node node)`. Since 21.3. Returns the current language context associated with the current thread. An enclosing node should be provided as parameter if available, otherwise `null` may be provided. This method is designed to be called safely from compiled code paths. In order to maximize efficiency in compiled code paths, a partial evaluation constant and adopted node should be passed as parameter. If this is the case then the return context will get constant folded in compiled code paths if there is only a single context instance for the enclosing engine or lookup location/node. The current context might vary between `executions` if resources or code is `shared` between multiple contexts or when used as part of an InteropLibrary export. It is recommended to \*not\* cache values of the context in the AST to reduce footprint. Getting it through a context reference will either constant fold or be very efficient in compiled code paths. If a context is accessed during `context creation`, on an unknown Thread, or in the language class constructor an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) is thrown. See also: `for a full usage example`. Cite: `com/oracle/truffle/api/TruffleLanguage.ContextReference.html#get(com.oracle.truffle.api.nodes.Node)` ### create(Class) `public static , C> TruffleLanguage.ContextReference create(Class languageClass)`. Since 21.3. Creates a new instance of a context reference for an registered language. Throws [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) if the provided language class is not `registered`. Guaranteed to always return the same context reference for a given language class. See `ContextReference` for a usage example. Cite: `com/oracle/truffle/api/TruffleLanguage.ContextReference.html#create(java.lang.Class)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ TruffleLanguage.ContextThreadLocalFactory [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 20.3. Nested in [`TruffleLanguage`](com/oracle/truffle/api/TruffleLanguage.md). ```java @FunctionalInterface protected interface TruffleLanguage.ContextThreadLocalFactory ``` Context thread local factory for Truffle languages. Creates a new value per context and thread. ## Methods ### create(C, Thread) `T create(C context, Thread thread)`. Since 20.3. Returns a new value for a context thread local for a language context and thread. The returned value must not be `null` and must return a stable and exact type per TruffleLanguage subclass. A thread local must always return the same [`class`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), even for multiple instances of the same `TruffleLanguage`. If this method throws an `com.oracle.truffle.api.exception.AbstractTruffleException` the exception interop messages may be executed without a context being entered. See also: `TruffleLanguage.ContextLocalProvider.createContextThreadLocal(TruffleLanguage.ContextThreadLocalFactory)`. Cite: `com/oracle/truffle/api/TruffleLanguage.ContextThreadLocalFactory.html#create(C,java.lang.Thread)` # ◆ TruffleLanguage.Env [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 0.8 or earlier. Nested in [`TruffleLanguage`](com/oracle/truffle/api/TruffleLanguage.md). ```java public static final class TruffleLanguage.Env ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Env` Represents execution environment of the [`TruffleLanguage`](com/oracle/truffle/api/TruffleLanguage.md). Each active [`TruffleLanguage`](com/oracle/truffle/api/TruffleLanguage.md) receives instance of the environment before any code is executed upon it. The environment has knowledge of all active languages and can exchange symbols between them. ## Methods ### getOptions() `public OptionValues getOptions()`. Since 0.27. Returns option values for the options described in `TruffleLanguage.getOptionDescriptors()`. The returned options are never `null`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#getOptions()` ### getApplicationArguments() `public String[] getApplicationArguments()`. Since 0.27. Returns the application arguments that were provided for this context. The arguments array and its elements are never `null`. It is up to the language implementation whether and how they are accessible within the guest language scripts. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#getApplicationArguments()` ### isCreateThreadAllowed() `public boolean isCreateThreadAllowed()`. Since 0.28. Returns `true` if the creation of new threads is allowed in the current environment. See also: `newTruffleThreadBuilder(Runnable)`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#isCreateThreadAllowed()` ### createThread(Runnable) `@Deprecated public Thread createThread(Runnable runnable)`. Since 0.28. Deprecated. Use `newTruffleThreadBuilder(Runnable)` instead. Creates a new thread that has access to the current language context. See `createThread(Runnable, TruffleContext, ThreadGroup, long)` for a detailed description of the parameters. The `group` is null and `stackSize` set to 0. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#createThread(java.lang.Runnable)` ### createThread(Runnable, TruffleContext) `@Deprecated public Thread createThread(Runnable runnable, TruffleContext context)`. Since 0.28. Deprecated. Use `newTruffleThreadBuilder(Runnable)` instead. Creates a new thread that has access to the given context. See `createThread(Runnable, TruffleContext, ThreadGroup, long)` for a detailed description of the parameters. The `group` is null and `stackSize` set to 0. See also: `getContext()`, `newInnerContextBuilder(String...)`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#createThread(java.lang.Runnable,com.oracle.truffle.api.TruffleContext)` ### createThread(Runnable, TruffleContext, ThreadGroup) `@Deprecated public Thread createThread(Runnable runnable, TruffleContext context, ThreadGroup group)`. Since 0.28. Deprecated. Use `newTruffleThreadBuilder(Runnable)` instead. Creates a new thread that has access to the given context. See `createThread(Runnable, TruffleContext, ThreadGroup, long)` for a detailed description of the parameters. The `stackSize` set to 0. See also: `getContext()`, `newInnerContextBuilder(String...)`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#createThread(java.lang.Runnable,com.oracle.truffle.api.TruffleContext,java.lang.ThreadGroup)` ### createThread(Runnable, TruffleContext, …) `@Deprecated public Thread createThread(Runnable runnable, TruffleContext context, ThreadGroup group, long stackSize)`. Since 0.28. Deprecated. Use `newTruffleThreadBuilder(Runnable)` instead. Creates a new thread that has access to the given context. A thread is `initialized` when it is [`started`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Thread.html#start%28%29) and `disposed` as soon as the thread finished the execution. It is recommended to set an [`uncaught exception handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Thread.html#setUncaughtExceptionHandler%28java.lang.Thread.UncaughtExceptionHandler%29) for the created thread. For example the thread can throw an uncaught exception if one of the initialized language contexts don't support execution on this thread. The language that created and started the thread is responsible to stop and join it during the `finalizeContext`, otherwise an [`AssertionError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AssertionError.html) is thrown. It's not safe to use the [`ExecutorService.awaitTermination(long, java.util.concurrent.TimeUnit)`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/ExecutorService.html#awaitTermination%28long,java.util.concurrent.TimeUnit%29) to detect Thread termination as the polyglot thread may be cancelled before executing the executor worker. A typical implementation looks like: The `TruffleContext` can be either an inner context created by `newInnerContextBuilder(String...)`.`build()`, or the context associated with this environment obtained from `getContext()`. Parameters: `runnable` `Runnable`: the runnable to run on this thread. `context` `TruffleContext`: the context to enter and leave when the thread is started. `group` `ThreadGroup`: the thread group, passed on to the underlying [`Thread`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Thread.html). `stackSize` `long`: the desired stack size for the new thread, or zero if this parameter is to be ignored. Throws: `IllegalStateException` (unchecked): if thread creation is not `allowed`. See also: `getContext()`, `newInnerContextBuilder(String...)`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#createThread(java.lang.Runnable,com.oracle.truffle.api.TruffleContext,java.lang.ThreadGroup,long)` ```java class AsyncThreadLanguage extends TruffleLanguage { @Override protected Context createContext(Env env) { return new Context(env); } @Override protected boolean isThreadAccessAllowed(Thread thread, boolean singleThreaded) { // allow access from any thread instead of just one return true; } @Override protected void initializeContext(Context context) throws Exception { // create and start a Thread for the asynchronous task // remeber the Thread reference to stop and join it in // the finalizeContext Thread t = context.env.newTruffleThreadBuilder(new Runnable() { @Override public void run() { // asynchronous task } }).build(); context.startedThreads.add(t); t.start(); } @Override protected void finalizeContext(Context context) { // stop and join all the created Threads boolean interrupted = false; for (int i = 0; i < context.startedThreads.size();) { Thread threadToJoin = context.startedThreads.get(i); try { if (threadToJoin != Thread.currentThread()) { threadToJoin.interrupt(); threadToJoin.join(); } i++; } catch (InterruptedException ie) { interrupted = true; } } if (interrupted) { Thread.currentThread().interrupt(); } } } ``` ### newTruffleThreadBuilder(Runnable) `public TruffleThreadBuilder newTruffleThreadBuilder(Runnable runnable)`. Since 23.0. Creates a builder for threads that have access to the given context. Parameters: `runnable` `Runnable`: the runnable to run on the threads created by the builder. Returns `TruffleThreadBuilder`: the builder for threads that have access to the given context. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#newTruffleThreadBuilder(java.lang.Runnable)` ### createSystemThread(Runnable) `public Thread createSystemThread(Runnable runnable)`. Since 22.3. Creates a new thread designed to process language internal tasks in the background. See `createSystemThread(Runnable, ThreadGroup)` for a detailed description of the parameters. See also: `createSystemThread(Runnable, ThreadGroup)`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#createSystemThread(java.lang.Runnable)` ### createSystemThread(Runnable, ThreadGroup) `public Thread createSystemThread(Runnable runnable, ThreadGroup threadGroup)`. Since 22.3. Creates a new thread designed to process language internal tasks in the background. The created thread cannot enter the context, if it tries an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) is thrown. Creating or terminating a system thread does not notify `languages` or instruments' thread-listeners. Creating a system thread does not cause a transition to multi-threaded access. The `creation permit` is not required to create a system thread. The caller must be either entered in a context, or in another system thread to create a new system thread. If not an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) is thrown. It is recommended to set an [`uncaught exception handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Thread.html#setUncaughtExceptionHandler%28java.lang.Thread.UncaughtExceptionHandler%29) for the created thread. For example the thread can throw an uncaught exception if the context is closed before the thread is started. The language that created and started the thread is responsible to stop and join it during the `TruffleLanguage.disposeContext(Object)` disposeContext}, otherwise an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) is thrown. It's not safe to use the [`ExecutorService.awaitTermination(long, java.util.concurrent.TimeUnit)`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/ExecutorService.html#awaitTermination%28long,java.util.concurrent.TimeUnit%29) to detect Thread termination as the system thread may be cancelled before executing the executor worker. A typical implementation looks like: Parameters: `runnable` `Runnable`: the runnable to run on this thread. `threadGroup` `ThreadGroup`: the thread group, passed on to the underlying [`Thread`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Thread.html). Throws: `IllegalStateException` (unchecked): if the context is already closed. See also: `createSystemThread(Runnable)`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#createSystemThread(java.lang.Runnable,java.lang.ThreadGroup)` ```java class SystemThreadLanguage extends TruffleLanguage { static class Context { private final BlockingQueue tasks; private final Env env; private volatile Thread systemThread; private volatile boolean cancelled; Context(Env env) { this.tasks = new LinkedBlockingQueue<>(); this.env = env; } } @Override protected Context createContext(Env env) { return new Context(env); } @Override protected void initializeContext(Context context) { // Create and start a Thread for the asynchronous internal task. // Remember the Thread to stop and join it in the disposeContext. context.systemThread = context.env.createSystemThread(() -> { while (!context.cancelled) { try { Runnable task = context.tasks. poll(Integer.MAX_VALUE, SECONDS); if (task != null) { task.run(); } } catch (InterruptedException ie) { // pass to cancelled check } } }); context.systemThread.start(); } @Override protected void disposeContext(Context context) { // Stop and join system thread. context.cancelled = true; Thread threadToJoin = context.systemThread; if (threadToJoin != null) { threadToJoin.interrupt(); boolean interrupted = false; boolean terminated = false; while (!terminated) { try { threadToJoin.join(); terminated = true; } catch (InterruptedException ie) { interrupted = true; } } if (interrupted) { Thread.currentThread().interrupt(); } } } } ``` ### newInnerContextBuilder(String...) `public TruffleContext.Builder newInnerContextBuilder(String... permittedLanguages)`. Since 22.3. Returns a new context builder useful to create inner context instances. By default the inner context inherits none of the access privileges. To inherit access set `TruffleContext.Builder.inheritAllAccess(boolean)` to `true`. No language context will be initialized by default in the inner context. In order to initialize the creator context use `TruffleContext.Builder.initializeCreatorContext(boolean)`, initialize the language after context creation using `TruffleContext.initializePublic(Node, String)` or evaluate a source using `TruffleContext.evalPublic(Node, Source)`. Parameters: `permittedLanguages` `String...`: ids of languages permitted in the context. If no languages are provided, then all languages permitted to the outer context will be permitted. Languages are validated when the context is [`built`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.Builder.html#build%28%29). An [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) will be thrown if an unknown or a language denied by the engine was used. See also: `for details on language inner contexts.`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#newInnerContextBuilder(java.lang.String...)` ### getPolyglotBindings() `public Object getPolyglotBindings()`. Since 0.32. Returns a TruffleObject that represents the polyglot bindings. The polyglot bindings consists of a set of symbols that have been exported explicitly by the languages or the embedder. This set of symbols allows for data exchange between polyglot languages. The polyglot bindings is separate from language bindings. The symbols can by read using string identifiers, a list of symbols may be requested with the keys message. Existing identifiers are removable, modifiable, readable and any new identifiers are insertable. Throws: `SecurityException` (unchecked): if polyglot access is not enabled. See also: `isPolyglotBindingsAccessAllowed()`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#getPolyglotBindings()` ### importSymbol(String) `public Object importSymbol(String symbolName)`. Since 0.8 or earlier. Explicitly imports a symbol from the polyglot bindings. The behavior of this method is equivalent to sending a READ message to the `polyglot bindings` object. Reading a symbol that does not exist will return `null`. The returned symbol value can either be a `TruffleObject` (e.g. a native object from the other language) to support interoperability between languages, [`String`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html) or one of the Java primitive wrappers ( [`Integer`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Integer.html), [`Double`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Double.html), [`Byte`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Byte.html), [`Boolean`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Boolean.html), etc.). Polyglot symbols can only be imported if the `polyglot bindings access` is allowed. Parameters: `symbolName` `String`: the name of the symbol to search for. Returns `Object`: object representing the symbol or `null` if it does not exist. Throws: `SecurityException` (unchecked): if importing polyglot symbols is not allowed. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#importSymbol(java.lang.String)` ### exportSymbol(String, Object) `public void exportSymbol(String symbolName, Object value)`. Since 0.27. Explicitly exports a symbol to the polyglot bindings object. The behavior of this method is equivalent to sending a WRITE message to the `polyglot bindings` object. Exporting a symbol with a `null` value will remove the symbol from the polyglot object. The exported symbol value can either be a `TruffleObject` (e.g. a native object from the other language) to support interoperability between languages, [`String`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html) or one of the Java primitive wrappers ( [`Integer`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Integer.html), [`Double`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Double.html), [`Byte`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Byte.html), [`Boolean`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Boolean.html), etc.). Polyglot symbols can only be export if the `polyglot bindings access` is allowed. Parameters: `symbolName` `String`: the name with which the symbol should be exported into the polyglot scope. `value` `Object`: the value to export for. Throws: `SecurityException` (unchecked): if exporting polyglot symbols is not allowed. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#exportSymbol(java.lang.String,java.lang.Object)` ### isHostLookupAllowed() `public boolean isHostLookupAllowed()`. Since 0.27. Returns `true` if host access is generally allowed. If this method returns `false` then `lookupHostSymbol(String)` will always fail. Host lookup is generally disallowed if the embedder provided a null [`host class filter`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.Builder.html#allowHostClassLookup%28java.util.function.Predicate%29). Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#isHostLookupAllowed()` ### addToHostClassPath(TruffleFile) `public void addToHostClassPath(TruffleFile entry)`. Since 19.0. Adds an entry to the Java host class loader. All classes looked up with `lookupHostSymbol(String)` will lookup classes with this new entry. If the entry was already added then calling this method again for the same entry has no effect. Given entry must not be `null`. Note that classes added by this method are in the unnamed module. Throws: `SecurityException` (unchecked): if the file is not `readable`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#addToHostClassPath(com.oracle.truffle.api.TruffleFile)` ### lookupHostSymbol(String) `public Object lookupHostSymbol(String symbolName)`. Since 0.27. Looks up a Java class in the top-most scope the host environment. Throws an error if no symbol was found or the symbol was not accessible. Symbols might not be accessible if a [`host class filter`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.Builder.html#allowHostClassLookup%28java.util.function.Predicate%29) prevents access. The returned object is always a `TruffleObject` that represents the class symbol. Parameters: `symbolName` `String`: the qualified class name in the host language. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#lookupHostSymbol(java.lang.String)` ### isHostObject(Object) `@Deprecated(since = "25.1") public boolean isHostObject(Object value)`. Since 19.0. Deprecated since 25.1. Use isHostObject. Returns `true` if the argument is Java host language object wrapped using Truffle interop. See also: `asHostObject(Object)`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#isHostObject(java.lang.Object)` ### asHostObject(Object) `@Deprecated(since = "25.1") public Object asHostObject(Object value)`. Since 19.0. Deprecated since 25.1. Use asHostObject. Returns the java host representation of a Truffle guest object if it represents a Java host language object. Throws [`ClassCastException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ClassCastException.html) if the provided argument is not a `host object`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#asHostObject(java.lang.Object)` ### asGuestValue(Object) `public Object asGuestValue(Object hostObject)`. Since 19.0. Converts an existing Java host object to a guest language value. If the value is already an interop value, then no conversion will be performed. Otherwise, the returned wraps the host object and provides support for the interop contract to access the java members. The interpretation of converted objects is described in [`Context.asValue(Object)`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html#asValue%28java.lang.Object%29). This method should be used exclusively to convert already allocated Java objects to a guest language representation. To allocate new host objects users should use `lookupHostSymbol(String)` to lookup the class and then send a NEW interop message to that object to instantiate it. This method does not respect configured [`class filters`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.Builder.html#allowHostClassLookup%28java.util.function.Predicate%29). Parameters: `hostObject` `Object`: the host object to convert. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#asGuestValue(java.lang.Object)` ### asBoxedGuestValue(Object) `public Object asBoxedGuestValue(Object guestObject)`. Since 19.0. Wraps primitive interop values in a TruffleObject exposing their methods as members. By default, primitive host values are not wrapped in TruffleObjects to expose their members. This method is intended for compatibility with existing Java interop APIs that expect such behavior. This method boxes the following primitive interop values: [`Boolean`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Boolean.html), [`Byte`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Byte.html), [`Short`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Short.html), [`Integer`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Integer.html), [`Long`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Long.html), [`Float`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Float.html), [`Double`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Double.html) , [`Character`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Character.html), [`String`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html). If the provided value is already boxed then the current value will be returned. If the provided value is not an interop value then an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) will be thrown. Parameters: `guestObject` `Object`: the primitive guest value to box. Throws: `IllegalArgumentException` (unchecked): if value is an invalid interop value. See also: `asGuestValue(Object)`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#asBoxedGuestValue(java.lang.Object)` ### isHostFunction(Object) `@Deprecated(since = "25.1") public boolean isHostFunction(Object value)`. Since 19.0. Deprecated since 25.1. Use `interopLibrary.isHostObject(obj) && interopLibrary.isExecutable(obj) && !interopLibrary.hasMembers(obj)`. Returns `true` if the argument is a Java host language function wrapped using Truffle interop. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#isHostFunction(java.lang.Object)` ### findMetaObject(Object) `public Object findMetaObject(Object value)`. Since 19.0. Find a metaobject of a value, if any. The metaobject represents a description of the object, reveals it's kind and it's features. Some information that a metaobject might define includes the base object's type, interface, class, methods, attributes, etc. When no metaobject is known, returns `null`. The metaobject is an interop value. An interop value can be either a `TruffleObject` (e.g. a native object from the other language) to support interoperability between languages or a [`String`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html). Parameters: `value` `Object`: the value to find the meta object for. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#findMetaObject(java.lang.Object)` ### isHostException(Throwable) `@Deprecated(since = "25.1") public boolean isHostException(Throwable exception)`. Since 19.0. Deprecated since 25.1. Use `interopLibrary.isHostObject(obj) && interopLibrary.isException(obj)`. Tests whether an exception is a host exception thrown by a Java Interop method invocation. Host exceptions may be thrown by interoperability messages. The host exception may be unwrapped using `asHostException(Throwable)`. Parameters: `exception` `Throwable`: the [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) to test. Returns `boolean`: `true` if the `exception` is a host exception, `false` otherwise. See also: `asHostException(Throwable)`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#isHostException(java.lang.Throwable)` ### asHostException(Throwable) `@Deprecated(since = "25.1") public Throwable asHostException(Throwable exception)`. Since 19.0. Deprecated since 25.1. Use asHostObject. Unwraps a host exception thrown by a Java method invocation. Host exceptions may be thrown by interoperability messages. The host exception may be unwrapped using `asHostException(Throwable)`. Parameters: `exception` `Throwable`: the host exception to unwrap. Returns `Throwable`: the original Java exception. Throws: `IllegalArgumentException` (unchecked): if the `exception` is not a host exception. See also: `isHostException(Throwable)`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#asHostException(java.lang.Throwable)` ### isHostSymbol(Object) `@Deprecated(since = "25.1") public boolean isHostSymbol(Object guestObject)`. Since 19.0. Deprecated since 25.1. Use `interopLibrary.isHostObject(obj) && interopLibrary.isScope(obj)`. Returns `true` if the argument is a host symbol, representing the constructor and static members of a Java class, as obtained by e.g. `lookupHostSymbol`. See also: `lookupHostSymbol(String)`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#isHostSymbol(java.lang.Object)` ### asHostSymbol(Class) `public Object asHostSymbol(Class symbolClass)`. Since 19.0. Converts a Java class to a host symbol as if by `lookupHostSymbol(symbolClass.getName())` but without an actual lookup. Must not be used with Truffle or guest language classes. See also: `lookupHostSymbol(String)`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#asHostSymbol(java.lang.Class)` ### isInnerContextOptionsAllowed() `public boolean isInnerContextOptionsAllowed()`. Since 22.3. Returns `true` if context options are allowed to be modified for inner contexts, or `false` if not. This method only indicates whether the embedder granted wildcard all access for new privileges using [`org.graalvm.polyglot.Context.Builder.allowInnerContextOptions(boolean)`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.Builder.html#allowInnerContextOptions%28boolean%29). This method is useful to find out whether it is possible to specify options for inner contexts using `TruffleContext.Builder.option(String, String)`, as options can only be specified with all access enabled. See also: `TruffleContext.Builder.option(String, String)`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#isInnerContextOptionsAllowed()` ### isFileIOAllowed() `public boolean isFileIOAllowed()`. Since 23.0. Returns `true` if access to files is allowed, else `false`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#isFileIOAllowed()` ### isSocketIOAllowed() `public boolean isSocketIOAllowed()`. Since 23.0. Returns `true` if access to network sockets is allowed, else `false`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#isSocketIOAllowed()` ### isNativeAccessAllowed() `public boolean isNativeAccessAllowed()`. Since 19.0. Returns `true` if access to native code is generally allowed. If this method returns `false` then loading native libraries with the Truffle NFI will fail. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#isNativeAccessAllowed()` ### isPolyglotEvalAllowed() `@Deprecated public boolean isPolyglotEvalAllowed()`. Since 19.2. Deprecated. in 24.1 use `isPolyglotEvalAllowed(null) instead`. Note that language implementations should now check whether polyglot eval is allowed also for individual languages, as access could be denied only for an individual language. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#isPolyglotEvalAllowed()` ### isPolyglotEvalAllowed(LanguageInfo) `public boolean isPolyglotEvalAllowed(LanguageInfo targetLanguage)`. Since 24.1. Returns `true` if the current language is allowed to evaluate guest application provided code of the given language, else `false`. If this method returns `true` then the current language has permission to use `parsePublic(Source, String...)` and `getScopePublic(LanguageInfo)` for the given language. If the given language is `null` then this method will return `true` if polyglot access is allowed in principle, else `false`. Languages may want to call this method twice. Once with `null` to determine whether polyglot eval and scope based builtins should be available to the application at all and once with the concrete language just before the access. The result of this method is safe to be cached per language context, it is guaranteed to not change for a context and target language combination. See also: [`Embedders can restrict polyglot eval access between certain languages.`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/PolyglotAccess.Builder.html#allowEval%28java.lang.String,java.lang.String%29), `parsePublic(Source, String...)`, `getScopePublic(LanguageInfo)`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#isPolyglotEvalAllowed(com.oracle.truffle.api.nodes.LanguageInfo)` ### isPolyglotBindingsAccessAllowed() `public boolean isPolyglotBindingsAccessAllowed()`. Since 19.2. Returns `true` if polyglot bindings access is allowed, else `false` . Guest languages should hide or disable all polyglot bindings builtins if this flag is set to `false`. If polyglot bindings access is disabled then `getPolyglotBindings()`, `importSymbol(String)` or `exportSymbol(String, Object)` fails with a SecurityException. See also: [`org.graalvm.polyglot.Context.Builder.allowPolyglotAccess(org.graalvm.polyglot.PolyglotAccess)`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.Builder.html#allowPolyglotAccess%28org.graalvm.polyglot.PolyglotAccess%29). Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#isPolyglotBindingsAccessAllowed()` ### isMimeTypeSupported(String) `public boolean isMimeTypeSupported(String mimeType)`. Since 0.11. Allows it to be determined if this [`org.graalvm.polyglot.Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html) can execute code written in a language with a given MIME type. Returns `boolean`: a boolean that indicates if the MIME type is supported. See also: `Source.getMimeType()`, `parsePublic(Source, String...)`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#isMimeTypeSupported(java.lang.String)` ### parseInternal(Source, String...) `public CallTarget parseInternal(Source source, String... argumentNames)`. Since 19.2. Parses the source of a public or internal language and returns the parse result as `CallTarget`. The `language id` is used to identify the `TruffleLanguage` to use to perform the `parse(com.oracle.truffle.api.TruffleLanguage.ParsingRequest)`. The names of arguments are parameters for the resulting {#link CallTarget} that allow the `source` to reference the actual parameters passed to `CallTarget.call(java.lang.Object...)`. The suffix `internal` in the method name indicates that the result of this method is **not** safe to exposed to arbitrary guest code, by default. Use `parsePublic(Source, String...)` for that purpose instead. Compared to `parsePublic(Source, String...)` this method provides also access to `internal` and dependent languages in addition to public languages. For example, in JavaScript, a call to the eval builtin should forward to `parsePublic(Source, String...)` as it contains code provided by the guest language user. Parsing regular expressions with the internal regular expression engine should call `parseInternal(Source, String...)` instead, as this is considered an implementation detail of the language. It is recommended that the language uses `Env.parsePublic(Source, String...)` or `Env.parseInternal(Source, String...)` instead of directly passing the Source to the parser, in order to support code caching with `ContextPolicy.SHARED` and `ContextPolicy.REUSE`. Parameters: `source` `Source`: the source to evaluate. `argumentNames` `String...`: the names of `CallTarget.call(java.lang.Object...)` arguments that can be referenced from the source. Returns `CallTarget`: the call target representing the parsed result. Throws: `IllegalStateException` (unchecked): if polyglot context associated with this environment is not entered, or if the language is neither a `public language` nor an `internal language`. `IllegalArgumentException` (unchecked): if the language is not allowed to evaluate code by the current language. See also: `parsePublic(Source, String...)`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#parseInternal(com.oracle.truffle.api.source.Source,java.lang.String...)` ### parsePublic(Source, String...) `public CallTarget parsePublic(Source source, String... argumentNames)`. Since 19.2. Parses the source of a public language and returns the parse result as `CallTarget` . The `language id` is used to identify the `TruffleLanguage` to use to perform the `parse(com.oracle.truffle.api.TruffleLanguage.ParsingRequest)`. The names of arguments are parameters for the resulting {#link CallTarget} that allow the `source` to reference the actual parameters passed to `CallTarget.call(java.lang.Object...)`. The suffix `public` in the method name indicates that the result of this method is safe to be exposed by default to guest applications. Public languages are configured by the embedder to be accessible to the guest language program. For example, in JavaScript, a call to the eval builtin should forward to `parsePublic(Source, String...)` as it contains code provided by the guest language user. Parsing regular expressions with the internal regular expression engine should call `parseInternal(Source, String...)` instead, as this is considered an implementation detail of the language. It is recommended that the language uses `Env.parsePublic(Source, String...)` or `Env.parseInternal(Source, String...)` instead of directly passing the Source to the parser, in order to support code caching with `ContextPolicy.SHARED` and `ContextPolicy.REUSE`. Languages should check for `eval permissions` for each `public language` prior to calling this method, otherwise [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown if not sufficient privileges are available. Parameters: `source` `Source`: the source to evaluate. `argumentNames` `String...`: the names of `CallTarget.call(java.lang.Object...)` arguments that can be referenced from the source. Returns `CallTarget`: the call target representing the parsed result. Throws: `IllegalStateException` (unchecked): if polyglot context associated with this environment is not entered, or if the language is not a `public language`. `IllegalArgumentException` (unchecked): if the language is not allowed to evaluate code by the current language. See also: `parseInternal(Source, String...)`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#parsePublic(com.oracle.truffle.api.source.Source,java.lang.String...)` ### in() `public InputStream in()`. Since 0.8 or earlier. Input stream provided by [`org.graalvm.polyglot.Context.Builder.in(InputStream)`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.Builder.html#in%28java.io.InputStream%29) this language is being executed in. Returns `InputStream`: reader, never `null`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#in()` ### out() `public OutputStream out()`. Since 0.8 or earlier. Standard output writer provided by [`org.graalvm.polyglot.Context.Builder.out(OutputStream)`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.Builder.html#out%28java.io.OutputStream%29) this language is being executed in. Returns `OutputStream`: writer, never `null`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#out()` ### err() `public OutputStream err()`. Since 0.8 or earlier. Standard error writer provided by [`org.graalvm.polyglot.Context.Builder.err(OutputStream)`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.Builder.html#err%28java.io.OutputStream%29) this language is being executed in. Returns `OutputStream`: writer, never `null`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#err()` ### lookup(Class) `public T lookup(Class type)`. Since 0.12. Looks additional service up. An environment for a particular `language` may also be associated with additional services. One can request implementations of such services by calling this method with the type identifying the requested service and its API. Services that can be obtained via this method include `com.oracle.truffle.api.instrumentation.Instrumenter` and others. Type parameters: ``: type of requested service. Parameters: `type` `Class`: class of requested service. Returns `T`: instance of T or `null` if there is no such service available. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#lookup(java.lang.Class)` ### lookup(InstrumentInfo, Class) `public S lookup(InstrumentInfo instrument, Class type)`. Since 0.26. Returns an additional service provided by this instrument, specified by type. If an instrument is not enabled, it will be enabled automatically by requesting a supported service. If the instrument does not provide a service for a given type it will not be enabled automatically. Type parameters: ``: the requested type. Parameters: `instrument` `InstrumentInfo`: identification of the instrument to query. `type` `Class`: the class of the requested type. Returns `S`: the registered service or `null` if none is found. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#lookup(com.oracle.truffle.api.InstrumentInfo,java.lang.Class)` ### lookup(LanguageInfo, Class) `public S lookup(LanguageInfo language, Class type)`. Since 19.0 supports services registered by registerService. Returns an additional service provided by the given language, specified by type. For services registered by `Registration.services()` the service lookup will ensure that the language is loaded and services are registered. The provided langauge and type must not be `null`. Type parameters: ``: the requested type. Parameters: `language` `LanguageInfo`: the language to query. `type` `Class`: the class of the requested type. Returns `S`: the registered service or `null` if none is found. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#lookup(com.oracle.truffle.api.nodes.LanguageInfo,java.lang.Class)` ### initializeLanguage(LanguageInfo) `public boolean initializeLanguage(LanguageInfo targetLanguage)`. Since 20.1.0. Ensures that the target language is initialized. This method firstly verifies that the target language is accessible from this language. If not the [`SecurityException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/SecurityException.html) is thrown. Then the target language initialization is performed if not already done. Parameters: `targetLanguage` `LanguageInfo`: the language to initialize. Throws: `SecurityException` (unchecked): if an access to `targetLanguage` is not permitted. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#initializeLanguage(com.oracle.truffle.api.nodes.LanguageInfo)` ### getInternalLanguages() `public Map getInternalLanguages()`. Since 19.2. Returns all languages that are installed and internally accessible in the environment. Using the language instance additional services can be `looked up`. `parseInternal(Source, String...)` is allowed for all languages returned by this method. This list of languages should not be exposed to guest language programs, as it lists internal languages. See also: `lookup(LanguageInfo, Class)`, `parseInternal(Source, String...)`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#getInternalLanguages()` ### getHostLanguage() `public LanguageInfo getHostLanguage()`. Since 24.2. Retrieves the host language used in this environment. The returned language can be used to obtain the host language top scope object using `getScopeInternal(LanguageInfo)` method. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#getHostLanguage()` ### getPublicLanguages() `public Map getPublicLanguages()`. Since 19.2. Returns all languages that are installed and publicly accessible in the environment. Using the language instance additional services can be `looked up`. `parsePublic(Source, String...)` is allowed for all languages returned by this method. This list of languages may be exposed ot the guest language program. See also: `parsePublic(Source, String...)`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#getPublicLanguages()` ### getLanguageInfo(Class) `public LanguageInfo getLanguageInfo(Class> languageClass)`. Since 24.2. Returns the `language info` for a given language class if available. The class may be obtained with `InteropLibrary.getLanguage(Object)`. Throws an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) if the provided language is not registered. Parameters: `languageClass` `Class>`: the language class to convert. Returns `LanguageInfo`: the associated language info. Throws: `IllegalArgumentException` (unchecked): if the language class is not valid. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#getLanguageInfo(java.lang.Class)` ### getInstruments() `public Map getInstruments()`. Since 0.26. Returns a map instrument-id to instrument instance of all instruments that are installed in the environment. Using the instrument instance additional services can be `looked up` . Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#getInstruments()` ### getTimeZone() `public ZoneId getTimeZone()`. Since 19.2. Returns the default time zone of this environment. If the time-zone was not explicitly set by the embedder, UTC is returned with [`SandboxPolicy.CONSTRAINED`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/SandboxPolicy.html#CONSTRAINED) or stricter sandbox policies, and the [`system default`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/time/ZoneId.html#systemDefault%28%29) time-zone is returned otherwise. See also: [`ZoneId.systemDefault()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/time/ZoneId.html#systemDefault%28%29). Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#getTimeZone()` ### getConfig() `public Map getConfig()`. Since 0.11. Configuration arguments passed from an outer language context to an inner language context. Inner language contexts can be created using `newInnerContextBuilder(String...)`. See also: `to create inner contexts.`, `to pass configuration objects to the inner context.`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#getConfig()` ### getContext() `public TruffleContext getContext()`. Since 0.30. Returns the polyglot context associated with this environment. Returns `TruffleContext`: the polyglot context. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#getContext()` ### isPreInitialization() `public boolean isPreInitialization()`. Since 19.0. Returns `true` if this [`org.graalvm.polyglot.Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html) is being pre-initialized. For a given `environment`, the return value of this method never changes. See also: `initializeContext(Object)`, `patchContext(Object, Env)`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#isPreInitialization()` ### getPublicTruffleFile(String) `public TruffleFile getPublicTruffleFile(String path)`. Since 19.3.0. Returns a `TruffleFile` for given path. The returned `TruffleFile` access depends on the file system used by the context and can vary from all access in case of [`allowed IO`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/IOAccess.html#ALL) to no access in case of [`denied IO`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/IOAccess.html#NONE). When IO is not enabled by the `Context` the `TruffleFile` operations throw [`SecurityException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/SecurityException.html). The `getPublicTruffleFile` method should be used to access user files or to implement language IO builtins. Parameters: `path` `String`: the absolute or relative path to create `TruffleFile` for. Returns `TruffleFile`: `TruffleFile`. Throws: `UnsupportedOperationException` (unchecked): when the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) supports only [`URI`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/URI.html). `IllegalArgumentException` (unchecked): if the `path` string cannot be converted to a [`Path`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/Path.html). See also: [`IOAccess`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/IOAccess.html), [`Builder.allowIO(IOAccess)`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.Builder.html#allowIO%28org.graalvm.polyglot.io.IOAccess%29). Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#getPublicTruffleFile(java.lang.String)` ### getPublicTruffleFile(URI) `public TruffleFile getPublicTruffleFile(URI uri)`. Since 19.3.0. Returns a `TruffleFile` for given path. See `getPublicTruffleFile(String)` for detailed information. Parameters: `uri` `URI`: the [`URI`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/URI.html) to create `TruffleFile` for. Returns `TruffleFile`: `TruffleFile`. Throws: `UnsupportedOperationException` (unchecked): when [`URI`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/URI.html) scheme is not supported. `IllegalArgumentException` (unchecked): if preconditions on the `uri` do not hold. `FileSystemNotFoundException` (unchecked): is the file system, identified by the `uri`, does not exist and cannot be created automatically. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#getPublicTruffleFile(java.net.URI)` ### getInternalTruffleFile(String) `public TruffleFile getInternalTruffleFile(String path)`. Since 19.3.0. Returns a `TruffleFile` for the given path. This method allows access to a language's internal resources even if file system privileges might be limited or denied. If the path locates a file under an internal resource root or under a guest language home, it is guaranteed that the returned `TruffleFile` has at least read access. Otherwise, the returned `TruffleFile` access depends on the file system used by the context and can vary from all access in case of allowed IO to no access in case of denied IO. This method should be used to read language-provided files, such as language standard libraries. This method is equivalent to `getTruffleFileInternal(path, p -> true)`. If a language should only use a subset of the language's internal resources, consider using `getTruffleFileInternal(String, Predicate)` and perform that language-specific restriction using a predicate. Parameters: `path` `String`: the absolute or relative path to create `TruffleFile` for. Returns `TruffleFile`: `TruffleFile`. Throws: `UnsupportedOperationException` (unchecked): when the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) supports only [`URI`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/URI.html). `IllegalArgumentException` (unchecked): if the `path` string cannot be converted to a [`Path`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/Path.html). See also: `getTruffleFileInternal(String, Predicate)`, `getPublicTruffleFile(java.lang.String)`, `getInternalResource(String)`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#getInternalTruffleFile(java.lang.String)` ### getInternalTruffleFile(URI) `public TruffleFile getInternalTruffleFile(URI uri)`. Since 19.3.0. Returns `TruffleFile` for given [`URI`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/URI.html). See `getInternalTruffleFile(String)` for detailed information. Parameters: `uri` `URI`: the [`URI`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/URI.html) to create `TruffleFile` for. Returns `TruffleFile`: `TruffleFile`. Throws: `UnsupportedOperationException` (unchecked): when [`URI`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/URI.html) scheme is not supported. `IllegalArgumentException` (unchecked): if preconditions on the `uri` do not hold. `FileSystemNotFoundException` (unchecked): is the file system, identified by the `uri`, does not exist and cannot be created automatically. See also: `getTruffleFileInternal(URI, Predicate)`, `getPublicTruffleFile(java.net.URI)`, `getInternalResource(String)`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#getInternalTruffleFile(java.net.URI)` ### getTruffleFileInternal(String, Predicate) `public TruffleFile getTruffleFileInternal(String path, Predicate filter)`. Since 21.1.0. Returns a `TruffleFile` for the given path. This method allows access to a language's internal resources even if file system privileges might be limited or denied. If the path locates a file under an internal resource root or under a guest language home, and the file satisfies the given `filter`, it is guaranteed that the returned `TruffleFile` has at least read access. Otherwise, the returned `TruffleFile` access depends on the file system used by the context and can vary from all access in case of allowed IO to no access in case of denied IO. A common use case for this method is a filter granting read access to the language standard libraries. The method performs the following checks: If the IO is enabled by the [`Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html) an accessible `TruffleFile` is returned without any other checks.; If the given path does not locate a file in an internal resource root or a guest language home, a `TruffleFile` with no access is returned.; If the given filter accepts the file a readable `TruffleFile` is returned. Otherwise, a `TruffleFile` with no access is returned. The relation to `getPublicTruffleFile(String)` and `getInternalTruffleFile(String)` is: The `getPublicTruffleFile(String)` is equivalent to `getTruffleFileInternal(path, p -> false)`.; The `getInternalTruffleFile(String)` is equivalent to `getTruffleFileInternal(path, p -> true)`. Parameters: `path` `String`: the absolute or relative path to create `TruffleFile` for. `filter` `Predicate`: to enable read access to `TruffleFile`. Multiple invocations of `filter.test(file)` must consistently return `true` or consistently return `false` for a given path. Returns `TruffleFile`: `TruffleFile`. Throws: `UnsupportedOperationException` (unchecked): when the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) supports only [`URI`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/URI.html). `IllegalArgumentException` (unchecked): if the `path` string cannot be converted to a [`Path`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/Path.html). See also: `getTruffleFileInternal(URI, Predicate)`, `getPublicTruffleFile(String)`, `getInternalTruffleFile(String)`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#getTruffleFileInternal(java.lang.String,java.util.function.Predicate)` ### getTruffleFileInternal(URI, Predicate) `public TruffleFile getTruffleFileInternal(URI uri, Predicate filter)`. Since 21.1.0. Returns a `TruffleFile` for given URI. See `getTruffleFileInternal(String, Predicate)` for detailed information. Parameters: `uri` `URI`: the [`URI`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/URI.html) to create `TruffleFile` for. `filter` `Predicate`: to enable read access to `TruffleFile`. Multiple invocations of `filter.test(file)` must consistently return `true` or consistently return `false` for a given path. Returns `TruffleFile`: `TruffleFile`. Throws: `UnsupportedOperationException` (unchecked): when the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) supports only [`URI`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/URI.html). `IllegalArgumentException` (unchecked): if preconditions on the `uri` do not hold. `FileSystemNotFoundException` (unchecked): is the file system, identified by the `uri`, does not exist and cannot be created automatically. See also: `getTruffleFileInternal(String, Predicate)`, `getPublicTruffleFile(URI)`, `getInternalTruffleFile(URI)`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#getTruffleFileInternal(java.net.URI,java.util.function.Predicate)` ### getCurrentWorkingDirectory() `public TruffleFile getCurrentWorkingDirectory()`. Since 19.0. Gets the current working directory. The current working directory is used to resolve non absolute paths in `TruffleFile` methods. Returns `TruffleFile`: the current working directory. Throws: `SecurityException` (unchecked): if the [`filesystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denies reading of the current working directory. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#getCurrentWorkingDirectory()` ### setCurrentWorkingDirectory(TruffleFile) `public void setCurrentWorkingDirectory(TruffleFile currentWorkingDirectory)`. Since 19.0. Sets the current working directory. The current working directory is used to resolve non absolute paths in `TruffleFile` methods. Parameters: `currentWorkingDirectory` `TruffleFile`: the new current working directory. Throws: `UnsupportedOperationException` (unchecked): if setting of the current working directory is not supported. `IllegalArgumentException` (unchecked): if the `currentWorkingDirectory` is not a valid current working directory. `SecurityException` (unchecked): if `currentWorkingDirectory` is not readable. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#setCurrentWorkingDirectory(com.oracle.truffle.api.TruffleFile)` ### getFileNameSeparator() `public String getFileNameSeparator()`. Since 19.0. Returns the name separator used to separate names in `TruffleFile`'s path string. Returns `String`: the name separator. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#getFileNameSeparator()` ### getPathSeparator() `public String getPathSeparator()`. Since 19.1.0. Returns the path separator used to separate filenames in a path list. On UNIX the path separator is `':'`. On Windows it's `';'`. Returns `String`: the path separator. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#getPathSeparator()` ### registerService(Object) `public void registerService(Object service)`. Since 19.0. Registers additional services provided by the language. The registered services are made available to users via `lookup(com.oracle.truffle.api.nodes.LanguageInfo, java.lang.Class)` query method. For each service interface enumerated in `language registration` the language has to register a single service implementation. This method can be called only during the execution of the `createContext method`, then the services are collected and cannot be changed anymore. Parameters: `service` `Object`: a service to be returned from associated `lookup method`. Throws: `IllegalStateException` (unchecked): if the method is called outside of `createContext(com.oracle.truffle.api.TruffleLanguage.Env)` method. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#registerService(java.lang.Object)` ### isCreateProcessAllowed() `public boolean isCreateProcessAllowed()`. Since 19.1.0. Returns `true` if the creation of a sub-process is allowed in the current environment. See also: `newProcessBuilder(java.lang.String...)`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#isCreateProcessAllowed()` ### newProcessBuilder(String...) `public TruffleProcessBuilder newProcessBuilder(String... command)`. Since 19.1.0. Creates a new process builder with the specified operating program and arguments. Parameters: `command` `String...`: the executable and its arguments. Throws: `SecurityException` (unchecked): when process creation is not allowed. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#newProcessBuilder(java.lang.String...)` ### getEnvironment() `public Map getEnvironment()`. Since 19.1.0. Returns an unmodifiable map of the process environment. When the `Context` is configured with [`EnvironmentAccess.INHERIT`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/EnvironmentAccess.html#INHERIT) it returns the [`System.getenv()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/System.html#getenv%28%29) and the environment variables configured on the `Context`. For the [`EnvironmentAccess.NONE`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/EnvironmentAccess.html#NONE) only the environment variables configured on the `Context` are returned. Returns `Map`: the process environment as a map of variable names to values. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#getEnvironment()` ### createTempFile(TruffleFile, String, …) `public TruffleFile createTempFile(TruffleFile dir, String prefix, String suffix, FileAttribute... attrs) throws IOException`. Since 19.3.0. Creates a new empty file in the specified or default temporary directory, using the given prefix and suffix to generate its name. This method provides only part of a temporary file facility. To arrange for a file created by this method to be deleted automatically the resulting file must be opened using the [`DELETE_ON_CLOSE`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/StandardOpenOption.html#DELETE_ON_CLOSE) option. In this case the file is deleted when the appropriate `close` method is invoked. Alternatively, a [`shutdown hook`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Runtime.html#addShutdownHook%28java.lang.Thread%29) may be used to delete the file automatically. Parameters: `dir` `TruffleFile`: the directory in which the file should be created or `null` for a default temporary directory. `prefix` `String`: the prefix to generate the file's name or `null`. `suffix` `String`: the suffix to generate the file's name or `null` in which case "`.tmp`" is used. `attrs` `FileAttribute...`: the optional attributes to set atomically when creating the file. Returns `TruffleFile`: the `TruffleFile` representing the newly created file that did not exist before this method was invoked. Throws: `IOException`: in case of IO error. `IllegalArgumentException` (unchecked): if the prefix or suffix cannot be used to generate a valid file name. `UnsupportedOperationException` (unchecked): if the attributes contain an attribute which cannot be set atomically or [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) does not support default temporary directory. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#createTempFile(com.oracle.truffle.api.TruffleFile,java.lang.String,java.lang.String,java.nio.file.attribute.FileAttribute...)` ### createTempDirectory(TruffleFile, String, FileAttribute...) `public TruffleFile createTempDirectory(TruffleFile dir, String prefix, FileAttribute... attrs) throws IOException`. Since 19.3.0. Creates a new directory in the specified or default temporary directory, using the given prefix to generate its name. This method provides only part of a temporary file facility. A [`shutdown hook`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Runtime.html#addShutdownHook%28java.lang.Thread%29) may be used to delete the directory automatically. Parameters: `dir` `TruffleFile`: the directory in which the directory should be created or `null` for a default temporary directory. `prefix` `String`: the prefix to generate the directory's name or `null`. `attrs` `FileAttribute...`: the optional attributes to set atomically when creating the directory. Returns `TruffleFile`: the `TruffleFile` representing the newly created directory that did not exist before this method was invoked. Throws: `IOException`: in case of IO error. `IllegalArgumentException` (unchecked): if the prefix cannot be used to generate a valid file name. `UnsupportedOperationException` (unchecked): if the attributes contain an attribute which cannot be set atomically or [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) does not support default temporary directory. `SecurityException` (unchecked): if the [`FileSystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied the operation. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#createTempDirectory(com.oracle.truffle.api.TruffleFile,java.lang.String,java.nio.file.attribute.FileAttribute...)` ### createHostAdapter(Object[]) `public Object createHostAdapter(Object[] types)`. Since 22.1. Creates a Java host adapter class that can be instantiated with a guest object (as the last argument) in order to create adapter instances of the provided host types, (non-final) methods of which delegate to the guest object's invocable members. Implementations must be [allowed](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/HostAccess.Builder.html#allowImplementations%28java.lang.Class%29) for these types. The returned host adapter class is an instantiable host object that is also a meta object, so `isMetaInstance` can be used to check if an object is an instance of this adapter class. See usage example below. Please note that only classes from the unnamed module or classes exported to the unnamed module can be used in `types`. The generated host adapter class is also in the unnamed module. A host class is generated as follows: For every protected or public constructor in the extended class, the adapter class will have one public constructor (visibility of protected constructors in the extended class is promoted to public). For every super constructor, a constructor taking a trailing [`Value`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Value.html) argument preceded by original constructor's arguments is generated. When such a constructor is invoked, the passed [`Value`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Value.html)'s member functions are used to implement and/or override methods on the original class, dispatched by name. A single invocable member will act as the implementation for all overloaded methods of the same name. When methods on an adapter instance are invoked, the functions are invoked having the [`Value`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Value.html) passed in the instance constructor as their receiver. Subsequent changes to the members of that [`Value`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Value.html) (reassignment or removal of its functions) are reflected in the adapter instance; the method implementations are not bound to functions at constructor invocation time. The generated host class extends all non-final public or protected methods, and forwards their invocations to the guest object provided to the constructor. If the guest object does not contain an invocable member with that name, the super/default method is invoked instead. If the super method is abstract, an [`AbstractMethodError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AbstractMethodError.html) is thrown. If the original types collectively have only one abstract method, or have several of them, but all share the same name, the constructor(s) will check if the [`Value`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Value.html) is executable, and if so, will use the passed function as the implementation for all abstract methods. For consistency, any concrete methods sharing the single abstract method name will also be overridden by the function. For non-void methods, all the conversions supported by [`Value.as`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Value.html#as%28java.lang.Class%29) will be in effect to coerce the guest methods' return value to the expected Java return type. Instances of the host class have the following additional special members: `super`: provides access to the super methods of the host class via a wrapper object. Can be used to call super methods from guest method overrides.; `this`: returns the original guest object. Direct member operations on an adapter instance for members not provided by the generated host class are delegated to the original guest object. Java host fields and methods, and the special `super` and `this` members, take precedence over same-named guest object members. Example: Parameters: `types` `Object[]`: the types to extend. Must be non-null and contain at least one extensible superclass or interface, and at most one superclass. All types must be public, accessible, and allow implementation. Returns `Object`: a host class that can be instantiated to create instances of a host class that extends all the provided host types. The host class may be cached. Throws: `IllegalArgumentException` (unchecked): if the types are not extensible or more than one superclass is given. `SecurityException` (unchecked): if host access does not allow creating adapter classes for these types. `UnsupportedOperationException` (unchecked): if creating adapter classes is not supported on this runtime at all, which is currently the case for native images. `NullPointerException` (unchecked): if `types` is null. See also: `createHostAdapterWithClassOverrides(Object[], Object)`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#createHostAdapter(java.lang.Object[])` ```java Object hostClass = env.createHostAdapter(new Object[]{ env.asHostSymbol(Superclass.class), env.asHostSymbol(Interface.class)}); // generates a class along the lines of: public class Adapter extends Superclass implements Interface { private Value delegate; public Adapter(Value delegate) { this.delegate = delegate; } public method(Object... args) { if (delegate.canInvokeMember("method") { return delegate.invokeMember("method", args); } else { return super.method(args); } } } // and can be instantiated as follows: Object instance = InteropLibrary.getUncached().instantiate(hostClass, guestObject); assert InteropLibrary.getUncached().isMetaInstance(hostClass, instance); ``` ### createHostAdapterWithClassOverrides(Object[], Object) `public Object createHostAdapterWithClassOverrides(Object[] types, Object classOverrides)`. Since 22.1. Like `createHostAdapter(Object[])` but creates a Java host adapter class with class-level overrides, i.e., the guest object provided as `classOverrides` is statically bound to the class rather than instances of the class. Returns a host class that can be instantiated to create instances of the provided host `types`, (non-final) methods of which delegate to the guest object provided as `classOverrides`. Allows creating host adapter class hierarchies, i.e., the returned class can be used as a superclass of other host adapter classes. Note that classes created with method cannot be cached. Therefore, this feature should be used sparingly. See `createHostAdapter(Object[])` for more details. Parameters: `types` `Object[]`: the types to extend. Must be non-null and contain at least one extensible superclass or interface, and at most one superclass. All types must be public, accessible, and allow implementation. `classOverrides` `Object`: a guest object with class-level overrides. If not null, the object is bound to the class, not to any instance. Consequently, the generated constructors are changed to not take an object; all instances will share the same overrides object. Note that since a new class has to be generated for every overrides object instance and cannot be shared, use of this feature is discouraged; it is provided only for compatibility reasons. Returns `Object`: a host class symbol that can be instantiated to create instances of a host class that extends all the provided host types. Throws: `IllegalArgumentException` (unchecked): if the types are not extensible or more than one superclass is given. `SecurityException` (unchecked): if host access does not allow creating adapter classes for these types. `UnsupportedOperationException` (unchecked): if creating adapter classes is not supported on this runtime at all, which is currently the case for native images. `NullPointerException` (unchecked): if either `types` or `classOverrides` is null. See also: `createHostAdapter(Object[])`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#createHostAdapterWithClassOverrides(java.lang.Object[],java.lang.Object)` ### getInternalResource(Class) `public TruffleFile getInternalResource(Class resource) throws IOException`. Since 23.1. Returns the `TruffleFile` representing the target directory of an internal resource. The internal resource is guaranteed to be fully `InternalResource.unpackFiles(InternalResource.Env, Path)` s unpacked} before this method returns. When this method is called for the first time and the resource is not cached than the resource will be unpacked. Unpacking an internal resource can be an expensive operation, but the implementation makes sure that unpacked internal resources are cached. The returned `TruffleFile` will only grant read-only access to the target directory, but access is provided even if IO access is disabled. On a HotSpot VM the internal resource is typically cached in the user directory, so unpacking would be repeated once per operating system user. When the language was compiled using native-image internal resources are unpacked at native-image compile time and stored relative to the native-image. Parameters: `resource` `Class`: the resource class to load. Throws: `IllegalArgumentException` (unchecked): if `resource` is not associated with this language. `IOException`: in case of IO error. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#getInternalResource(java.lang.Class)` ### getInternalResource(String) `public TruffleFile getInternalResource(String resourceId) throws IOException`. Since 23.1. Returns the `TruffleFile` representing the target directory of an internal resource. Unlike the `getInternalResource(Class)`, this method can be used for optional resources whose classes may not exist at runtime. In this case the optional resource must be unpacked at build time, see [`Engine.copyResources(Path, String...)`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Engine.html#copyResources%28java.nio.file.Path,java.lang.String...%29). If the resource with the specified `resourceId` is not associated to this language, the function returns `null`. Parameters: `resourceId` `String`: unique id of the resource to be loaded. Returns `TruffleFile`: internal resource directory or `null` if resource with the `resourceId` is not associated with this language. Throws: `IOException`: in case of IO error. See also: `getInternalResource(Class)`, [`Engine.copyResources(Path, String...)`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Engine.html#copyResources%28java.nio.file.Path,java.lang.String...%29). Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#getInternalResource(java.lang.String)` ### getLogger(String) `public TruffleLogger getLogger(String loggerName)`. Since 21.1. Find or create a context-bound logger. The returned `TruffleLogger` always uses a logging handler and options from this execution environment context and does not depend on being entered on any thread. If a logger with a given name already exists it's returned. Otherwise, a new logger is created. Unlike loggers created by `TruffleLogger.getLogger` loggers created by this method are bound to a single context. There may be more logger instances having the same name but each bound to a different context. Languages should never store the returned logger into a static field. If the context policy is more permissive than `ContextPolicy.EXCLUSIVE` the returned logger must not be stored in a TruffleLanguage subclass. It is recommended to create all language loggers in `TruffleLanguage.createContext(Env)`. Parameters: `loggerName` `String`: the name of a `TruffleLogger`, if a `loggerName` is null or empty a root logger for language or instrument is returned. Returns `TruffleLogger`: a `TruffleLogger`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#getLogger(java.lang.String)` ### getLogger(Class) `public TruffleLogger getLogger(Class forClass)`. Since 21.1. Find or create a context-bound logger. The returned `TruffleLogger` always uses a logging handler and options from this execution environment context and does not depend on being entered on any thread. If a logger with a given name already exists it's returned. Otherwise, a new logger is created. Unlike loggers created by `TruffleLogger.getLogger` loggers created by this method are bound to a single context. There may be more logger instances having the same name but each bound to a different context. Languages should never store the returned logger into a static field. If the context policy is more permissive than `ContextPolicy.EXCLUSIVE` the returned logger must not be stored in a TruffleLanguage subclass. It is recommended to create all language loggers in `TruffleLanguage.createContext(Env)`. Parameters: `forClass` `Class`: the [`Class`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Class.html) to create a logger for. Returns `TruffleLogger`: a `TruffleLogger`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#getLogger(java.lang.Class)` ### submitThreadLocal(Thread[], ThreadLocalAction) `public Future submitThreadLocal(Thread[] threads, ThreadLocalAction action)`. Since 21.1. Submits a thread local action to be performed at the next guest language safepoint on a provided set of threads, once for each thread. If the threads array is `null` then the thread local action will be performed on all alive threads. The submitted actions are processed in the same order as they are submitted in. The action can be synchronous or asynchronous, side-effecting or non-side-effecting. Please see `ThreadLocalAction` for details. It is ensured that a thread local action will get processed as long as the thread stays active for this context. If a thread becomes inactive before the action can get processed then the action will not be performed for this thread. If a thread becomes active while the action is being processed then the action will be performed for that thread as long as the thread filter includes the thread or `null` was passed. Already started synchronous actions will block on activation of a new thread. If the synchronous action was not yet started on any thread, then the synchronous action will also be performed for the newly activated thread. The method returns a [`Future`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/Future.html) instance that allows to wait for the thread local action to complete or to cancel a currently performed event. Example Usage: By default thread-local actions are executed once per configured thread and do not repeat themselves. If a ThreadLocalAction is configured to be `recurring` then the action will automatically be rescheduled in the same configuration until it is [`cancelled`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/Future.html#cancel%28boolean%29). For recurring actions, an invocation of [`Future.get()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/Future.html#get%28%29) will only wait for the first action to be performed. [`Future.isDone()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/Future.html#isDone%28%29) will return `true` only if the action was canceled. Canceling a recurring action will result in the current event being canceled and no further events being submitted. Using recurring events should be preferred over submitting the event again for the current thread while performing the thread-local action as recurring events are also resubmitted in case all threads leave and later reenter. If the thread local action future needs to be waited on and this might be prone to deadlocks the `blocking API` can be used to allow other thread local actions to be processed while the current thread is waiting. The returned [`Future.get()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/Future.html#get%28%29) method can be used as `Interruptible`. If the underlying polyglot context is already closed, the method returns a completed [`Future`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/Future.html). Parameters: `threads` `Thread[]`: the threads to execute the action on. `null` for all threads. `action` `ThreadLocalAction`: the action to perform on that thread. See also: `ThreadLocalAction`, `TruffleSafepoint`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#submitThreadLocal(java.lang.Thread[],com.oracle.truffle.api.ThreadLocalAction)` ```java Env env; // supplied env.submitThreadLocal(null, new ThreadLocalAction(true, true) { @Override protected void perform(Access access) { // perform action } }); ``` ### registerOnDispose(Closeable) `public void registerOnDispose(Closeable closeable)`. Since 21.2. Registers [`Closeable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/Closeable.html) for automatic close on context dispose. In most cases, closeable should be closed using try-with-resources construct. When a closeable must keep being opened for the lifetime of a context it should be registered using this method for automatic close on context dispose. The registered [`Closeable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/Closeable.html) is weakly referenced. The guest language must strongly reference it otherwise, it may be garbage collected before it's closed. If the registered closeable throws an [`IOException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/IOException.html) during close, the thrown exception does not prevent successful context dispose. The IOException is logged to the engine logger with a [`Level.WARNING`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#WARNING) level. Other exceptions are rethrown as internal [`PolyglotException`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/PolyglotException.html). Parameters: `closeable` `Closeable`: to be closed on context dispose. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#registerOnDispose(java.io.Closeable)` ### getSandboxPolicy() `public SandboxPolicy getSandboxPolicy()`. Since 23.0. Returns the context's [`SandboxPolicy`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/SandboxPolicy.html). A language can use the returned sandbox policy to make language-specific verifications that the sandbox requirements are met. These verifications should be made as early as possible in the `TruffleLanguage.createContext(Env)` method. See also: [`SandboxPolicy`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/SandboxPolicy.html), `TruffleLanguage.createContext(Env)`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#getSandboxPolicy()` ### getScopePublic(LanguageInfo) `public Object getScopePublic(LanguageInfo language) throws IllegalArgumentException`. Since 24.1. Returns the scope object of a non-null `public language`. The returned value follows the contract of `TruffleLanguage.getScope(Object)` of the other language, therefore it must be an `interop scope object` and may have `parent scopes`. The bindings object exposes all top scopes variables as flattened `members`. In addition to being a scope the returned object may implement any number of the `interop traits`. The interop members of the returned object are typically writable, but that is not guaranteed. The suffix `public` in the method name indicates that the result of this method is safe to be exposed by default to guest applications. For example, languages should use this method to implement the semantics of their polyglot bindings builtin, but is not limited to that. All `public` languages with `eval permissions` are accessible. If a language is not accessible then an [`SecurityException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/SecurityException.html) is thrown. The scope of the current language is always accessible, but it is recommended to use a language specific way to access symbols of the current language. Languages should check for `eval permissions` for each `public language` prior to calling this method, otherwise it might cause [`SecurityException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/SecurityException.html) if not sufficient privileges are available. Returns `Object`: the scope, or `null` if the requested language does not support such a concept. Throws: `IllegalStateException` (unchecked): if polyglot context associated with this environment is not entered. `SecurityException` (unchecked): if polyglot scope access is not enabled for this language. See also: `getScopeInternal(LanguageInfo)`, `isPolyglotEvalAllowed(LanguageInfo)`, `getPolyglotBindings()`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#getScopePublic(com.oracle.truffle.api.nodes.LanguageInfo)` ### getScopeInternal(LanguageInfo) `public Object getScopeInternal(LanguageInfo language)`. Since 24.1. Returns the scope object of a non-null `internal language`. Works the same as `getScopePublic(LanguageInfo)` but it also returns scopes of internal and dependent languages. The suffix `internal` in the method name indicates that the result of this method is **not** safe to be exposed to arbitrary guest code, by default. Use `getScopePublic(LanguageInfo)` for that purpose instead. For example, this method could be used to access a fixed set of symbols from the Truffle Native Interface, e.g. to load native language extensions. Languages may decide to expose scopes of internal languages to arbitrary guest code for testing purposes. Make sure this option is disabled by default and enabled using an [`internal`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/options/OptionCategory.html#INTERNAL) option only. The scope of the current language is always accessible, but it is recommended to use a language specific way to access symbols of the current language. It is recommended to only use this method for `internal` or `dependent languages`. For convenience, this method will also succeed for all accessible `public languages` with `eval permissions`. Returns `Object`: the scope, or `null` if the requested language does not support such a concept. Throws: `IllegalStateException` (unchecked): if polyglot context associated with this environment is not entered. `SecurityException` (unchecked): if polyglot scope access is not enabled for this language. See also: `getScopePublic(LanguageInfo)`. Cite: `com/oracle/truffle/api/TruffleLanguage.Env.html#getScopeInternal(com.oracle.truffle.api.nodes.LanguageInfo)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ≡ TruffleLanguage.ExitMode [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Enum class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 22.0. Nested in [`TruffleLanguage`](com/oracle/truffle/api/TruffleLanguage.md). ```java public enum TruffleLanguage.ExitMode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html) > `ExitMode` Mode of exit operation. **See also** - [`exitContext(Object, ExitMode, int)`](com/oracle/truffle/api/TruffleLanguage.md#exitContext%28C,com.oracle.truffle.api.TruffleLanguage.ExitMode,int%29) ## Enum constants ### NATURAL `NATURAL`. Since 22.0. Natural exit that occurs during normal context close. Cite: `com/oracle/truffle/api/TruffleLanguage.ExitMode.html#NATURAL` ### HARD `HARD`. Since 22.0. Hard exit triggered by `TruffleContext.closeExited(Node, int)`. Cite: `com/oracle/truffle/api/TruffleLanguage.ExitMode.html#HARD` ## Methods ### values() `public static TruffleLanguage.ExitMode[] values()`. Returns the enum constants in declaration order. Returns `TruffleLanguage.ExitMode[]`: Returns the enum constants in declaration order. Cite: `com/oracle/truffle/api/TruffleLanguage.ExitMode.html#values()` ### valueOf(String) `public static TruffleLanguage.ExitMode valueOf(String name)`. Returns the enum constant with the given name. Parameters: `name` `String`: The exact name of the enum constant. Returns `TruffleLanguage.ExitMode`: Returns the enum constant with the given name. Cite: `com/oracle/truffle/api/TruffleLanguage.ExitMode.html#valueOf(java.lang.String)` ## Inherited members - From class [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#clone%28%29), [`compareTo`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#compareTo%28E%29), [`describeConstable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#describeConstable%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#finalize%28%29), [`getDeclaringClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#getDeclaringClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#hashCode%28%29), [`name`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#name%28%29), [`ordinal`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#ordinal%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#toString%28%29), [`valueOf`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#valueOf%28java.lang.Class,java.lang.String%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleLanguage.InlineParsingRequest [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 0.31. Nested in [`TruffleLanguage`](com/oracle/truffle/api/TruffleLanguage.md). ```java public static final class TruffleLanguage.InlineParsingRequest ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `InlineParsingRequest` Request for inline parsing. Contains information of what to parse and in which context. ## Methods ### getSource() `public Source getSource()`. Since 0.31. The source code to parse. Returns `Source`: the source code, never `null`. Cite: `com/oracle/truffle/api/TruffleLanguage.InlineParsingRequest.html#getSource()` ### getOptionValues() `public OptionValues getOptionValues()`. Since 25.0. Returns the source option values associated with the parsing request's source and language. This method should be preferred over `Source.getOptions(TruffleLanguage)` when accessing the source options of a source when possible, to avoid parsing the options twice. In order to allow users of the language to specify source options they must be declared by implementing `TruffleLanguage.getSourceOptionDescriptors()`. Cite: `com/oracle/truffle/api/TruffleLanguage.InlineParsingRequest.html#getOptionValues()` ### getLocation() `public Node getLocation()`. Since 0.31. Specifies the code location for parsing. The location is specified as an instance of a `Node` in the AST. The node can be `com.oracle.truffle.api.instrumentation.EventContext.getInstrumentedNode()`, for example. Returns `Node`: a `Node` defining AST context for the parsing, it's never `null`. Cite: `com/oracle/truffle/api/TruffleLanguage.InlineParsingRequest.html#getLocation()` ### getFrame() `public MaterializedFrame getFrame()`. Since 0.31. Specifies the execution context for parsing. If the parsing request is used for evaluation during halted execution, for example as in `com.oracle.truffle.api.debug.DebugStackFrame.eval(String)` method, this method provides access to current `frame` with local variables, etc. Returns `MaterializedFrame`: a `MaterializedFrame` exposing the current execution state or `null` if there is none. Cite: `com/oracle/truffle/api/TruffleLanguage.InlineParsingRequest.html#getFrame()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleLanguage.LanguageReference [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 0.25 revised in 21.3. Nested in [`TruffleLanguage`](com/oracle/truffle/api/TruffleLanguage.md). ```java public abstract static class TruffleLanguage.LanguageReference ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `LanguageReference` Represents a reference to the current language instance. The current language is a thread local value that potentially changes when polyglot context is entered or left. Language references are created using [`create(Class)`](com/oracle/truffle/api/TruffleLanguage.LanguageReference.md#create%28java.lang.Class%29) and are intended to be stored in static final fields and accessed at runtime using [`LanguageReference.get(Node)`](com/oracle/truffle/api/TruffleLanguage.LanguageReference.md#get%28com.oracle.truffle.api.nodes.Node%29) with the current [`Node`](com/oracle/truffle/api/nodes/Node.md), if available, as parameter. Example intended usage: See [`ContextReference`](com/oracle/truffle/api/TruffleLanguage.ContextReference.md) for a full usage example. ## Constructors ### LanguageReference() `protected LanguageReference()`. Since 19.0. Constructors for subclasses. Cite: `com/oracle/truffle/api/TruffleLanguage.LanguageReference.html#()` ## Methods ### get(Node) `public abstract L get(Node node)`. Since 21.3. Returns the current language instance associated with the current thread. An enclosing node should be provided as parameter if available, otherwise `null` may be provided. This method is designed to be called safely from compiled code paths. In order to maximize efficiency in compiled code paths, a partial evaluation constant and adopted node should be passed as parameter. If this is the case then the return language will get constant folded in compiled code paths. The current language is fixed per `RootNode`. It is recommended to \*not\* cache values of the language in the AST to reduce footprint. Getting it through a language reference will either constant fold or be very efficient in compiled code paths. If a language is accessed on an unknown Thread, or in the language class constructor an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) is thrown. See also: `for a full usage example`. Cite: `com/oracle/truffle/api/TruffleLanguage.LanguageReference.html#get(com.oracle.truffle.api.nodes.Node)` ### create(Class) `public static > TruffleLanguage.LanguageReference create(Class languageClass)`. Since 21.3. Creates a new instance of a langauge reference for an registered language. Throws [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) if the provided language class is not `registered`. Guaranteed to always return the same context reference for a given language class. See `LanguageReference` for a usage example. Cite: `com/oracle/truffle/api/TruffleLanguage.LanguageReference.html#create(java.lang.Class)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleLanguage.ParsingRequest [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 0.22. Nested in [`TruffleLanguage`](com/oracle/truffle/api/TruffleLanguage.md). ```java public static final class TruffleLanguage.ParsingRequest ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `ParsingRequest` Request for parsing. Contains information of what to parse and in which context. ## Methods ### getSource() `public Source getSource()`. Since 0.22. The source code to parse. Returns `Source`: the source code, never `null`. Cite: `com/oracle/truffle/api/TruffleLanguage.ParsingRequest.html#getSource()` ### getOptionValues() `public OptionValues getOptionValues()`. Since 25.0. Returns the source option values associated with the parsing request's source and language. This method should be preferred over `Source.getOptions(TruffleLanguage)` when accessing the source options of a source when possible, to avoid parsing the options twice. In order to allow users of the language to specify source options they must be declared by implementing `TruffleLanguage.getSourceOptionDescriptors()`. Cite: `com/oracle/truffle/api/TruffleLanguage.ParsingRequest.html#getOptionValues()` ### getArgumentNames() `public List getArgumentNames()`. Since 0.22. Argument names. The result of `parsing` is an instance of `CallTarget` that `can be invoked` without or with some parameters. If the invocation requires some arguments, and the `getSource()` references them, it is essential to name them. Example that uses the argument names: Returns `List`: symbolic names for parameters of `CallTarget.call(java.lang.Object...)`. Cite: `com/oracle/truffle/api/TruffleLanguage.ParsingRequest.html#getArgumentNames()` ```java public void parseWithParams(Env env) { Source multiply = Source.newBuilder("js", "a * b", "mul.js").build(); CallTarget method = env.parsePublic(multiply, "a", "b"); Number fortyTwo = (Number) method.call(6, 7); assert 42 == fortyTwo.intValue(); Number ten = (Number) method.call(2, 5); assert 10 == ten.intValue(); } ``` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # @ TruffleLanguage.Registration [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 0.8 or earlier. Nested in [`TruffleLanguage`](com/oracle/truffle/api/TruffleLanguage.md). ```java @Retention(RUNTIME) @Target({TYPE}) public @interface TruffleLanguage.Registration ``` The annotation to use to register your language to the [`Polyglot API`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/package-summary.html). By annotating your implementation of [`TruffleLanguage`](com/oracle/truffle/api/TruffleLanguage.md) by this annotation the language can be discovered on the class path. ## Elements ### id() `String id() default ""`. Since 0.8 or earlier. Unique id of your language. This id will be exposed to users via the getter. It is used as group identifier for options of the language. Returns `String`: identifier of your language. Default: `""`. Cite: `com/oracle/truffle/api/TruffleLanguage.Registration.html#id()` ### name() `String name() default ""`. Since 0.8 or earlier. Unique name of your language. This name will be exposed to users via the [`org.graalvm.polyglot.Language.getName()`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Language.html#getName%28%29) getter. Returns `String`: identifier of your language. Default: `""`. Cite: `com/oracle/truffle/api/TruffleLanguage.Registration.html#name()` ### implementationName() `String implementationName() default ""`. Since 0.8 or earlier. Unique name of your language implementation. Returns `String`: the implementation name of your language. Default: `""`. Cite: `com/oracle/truffle/api/TruffleLanguage.Registration.html#implementationName()` ### version() `String version() default "inherit"`. Since 0.8 or earlier. Unique string identifying the language version. This name will be exposed to users via the [`org.graalvm.polyglot.Language.getVersion()`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Language.html#getVersion%28%29) getter. It inherits from [`org.graalvm.polyglot.Engine.getVersion()`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Engine.html#getVersion%28%29) by default. Returns `String`: version of your language. Default: `"inherit"`. Cite: `com/oracle/truffle/api/TruffleLanguage.Registration.html#version()` ### defaultMimeType() `String defaultMimeType() default ""`. Since 19.0. Returns the default MIME type of this language. The default MIME type allows embedders and other language or instruments to find out how content is interpreted if no MIME type was specified. The default MIME type must be specified in the list of supported `character` or `byte` based MIME types. The default MIME type is mandatory if more than one supported MIME type was specified. If no default MIME type and no supported MIME types were specified then all sources for this language will be interpreted as `character` based sources. Default: `""`. See also: `LanguageInfo.getDefaultMimeType()`, [`Language.getDefaultMimeType()`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Language.html#getDefaultMimeType%28%29), `characterMimeTypes()`, `byteMimeTypes()`. Cite: `com/oracle/truffle/api/TruffleLanguage.Registration.html#defaultMimeType()` ### characterMimeTypes() `String[] characterMimeTypes() default {}`. Since 19.0. List of MIME types supported by this language which sources should be interpreted as `character` based sources. Languages may use MIME types to differentiate supported source kinds. If a MIME type is declared as supported then the language needs to be able to `parse` sources of this kind. If only one supported MIME type was specified by a language then it will be used as `default` MIME type. If no supported character and byte based MIME types are specified then all sources will be interpreted as `character` based. Returns `String[]`: array of MIME types assigned to your language files. Default: `{}`. See also: `defaultMimeType()`, `byteMimeTypes()`. Cite: `com/oracle/truffle/api/TruffleLanguage.Registration.html#characterMimeTypes()` ### byteMimeTypes() `String[] byteMimeTypes() default {}`. Since 19.0. List of MIME types supported by this language which sources should be interpreted as `byte` based sources. Languages may use MIME types to differentiate supported source kinds. If a MIME type is declared as supported, then the language needs to be able to `parse` sources of this kind. If only one supported MIME type was specified by a language then it will be used as `default` MIME type. If no supported character and byte based MIME types are specified then all sources will be interpreted as `character` based. Returns `String[]`: array of MIME types assigned to your language files. Default: `{}`. See also: `defaultMimeType()`, `characterMimeTypes()`. Cite: `com/oracle/truffle/api/TruffleLanguage.Registration.html#byteMimeTypes()` ### interactive() `boolean interactive() default true`. Since 0.22. Specifies if the language is suitable for interactive evaluation of `sources`. `Interactive` languages should be displayed in interactive environments and presented to the user. The default value of this attribute is `true` assuming majority of the languages is interactive. Change the value to `false` to opt-out and turn your language into non-interactive one. Returns `boolean`: `true` if the language should be presented to end-user in an interactive environment. Default: `true`. Cite: `com/oracle/truffle/api/TruffleLanguage.Registration.html#interactive()` ### internal() `boolean internal() default false`. Since 0.27. Returns `true` if this language is intended for internal use only. Internal languages cannot be used in the host environment directly, they can only be used from other languages or from instruments. Default: `false`. Cite: `com/oracle/truffle/api/TruffleLanguage.Registration.html#internal()` ### dependentLanguages() `String[] dependentLanguages() default {}`. Since 0.30. Specifies a list of languages that this language depends on. Languages are referenced using their `id()`. This has the following effects: This language always has access to dependent languages if this language is accessible. Languages may not be accessible if language access is [`restricted`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html#create%28java.lang.String...%29).; This language is finalized before dependent language contexts are `finalized`.; This language is disposed before dependent language contexts are `disposed`. `Non-internal` languages implicitly depend on all internal languages. Therefore by default non-internal languages are disposed and finalized before internal languages. Dependent languages should be parsed with `Env.parseInternal(Source, String...)` as the embedder might choose to disable access to it for `Env.parsePublic(Source, String...)`. Dependent languages references are optional. If a dependent language is not installed and the language needs to fail in such a case then the language should fail on `context initialization`. Cycles in dependencies will cause an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) when one of the cyclic languages is [`initialized`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html#initialize%28java.lang.String%29). Default: `{}`. Cite: `com/oracle/truffle/api/TruffleLanguage.Registration.html#dependentLanguages()` ### contextPolicy() `TruffleLanguage.ContextPolicy contextPolicy() default EXCLUSIVE`. Since 19.0. Defines the supported policy for reusing `languages` per context. I.e. the policy specifies the degree of sharing that is allowed between multiple language contexts. The default policy is `exclusive`. Every language is encouraged to try to support a context policy that is as permissive as possible, where `exclusive` is the least and `shared` is the most permissive policy. `Parse caching` is scoped per `language` instance, therefore the context policy influences its behavior. The context policy applies to contexts that were created using the [`polyglot API`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html) as well as for `inner contexts`. The context policy does not apply to nodes that were created using the Truffle interop protocol. Therefore, interop message nodes always need to be prepared to be used with policy `ContextPolicy.SHARED`. Default: `EXCLUSIVE`. See also: `TruffleLanguage.parse(ParsingRequest)`. Cite: `com/oracle/truffle/api/TruffleLanguage.Registration.html#contextPolicy()` ### services() `Class[] services() default {}`. Since 19.0. Declarative list of classes this language is known to provide. The language is supposed to override its `createContext` method and instantiate and `register` all here in defined services. Languages automatically get created but not yet initialized when their registered `service is requested`. Returns `Class[]`: list of service types that this language can provide. Default: `{}`. Cite: `com/oracle/truffle/api/TruffleLanguage.Registration.html#services()` ### fileTypeDetectors() `Class[] fileTypeDetectors() default {}`. Since 19.0. Declarative list of `TruffleFile.FileTypeDetector` classes provided by this language. The language has to support all MIME types recognized by the registered `file type detectors`. Returns `Class[]`: list of file type detectors. Default: `{}`. Cite: `com/oracle/truffle/api/TruffleLanguage.Registration.html#fileTypeDetectors()` ### needsAllEncodings() `@Deprecated(since = "24.1") boolean needsAllEncodings() default false`. Since 22.1. Deprecated since 24.1. To enable all `TruffleString` encodings, it is sufficient to add the `org.graalvm.shadowed.jcodings` module to the language's module-info `requires` and ensure it is on the module path when languages are loaded. If the module can be found, and at least one languages requires it, all encodings are automatically enabled. When languages are loaded from the class path (i.e. as an unnamed module), having jcodings on the class path is enough to enable it. Returns `true` if the language uses `TruffleString`s with encodings not present in the following list. `UTF-8`; `UTF-16`; `UTF-32`; `ISO-8859-1`; `US-ASCII`; `BYTES`. Default: `false`. Cite: `com/oracle/truffle/api/TruffleLanguage.Registration.html#needsAllEncodings()` ### website() `String website() default ""`. Since 22.1.0. A link to a website with more information about the language. Will be shown in the help text of GraalVM launchers. The link can contain the following substitutions: **`${graalvm-version}`** the current GraalVM version. Optionally, a format string can be provided for the version using `${graalvm-version:format}`. See [`Version.format`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/home/Version.html#format%28java.lang.String%29).; **`${graalvm-website-version}`** the current GraalVM version in a format suitable for links to the GraalVM reference manual. The exact format may change without notice. Returns `String`: URL for language website. Default: `""`. Cite: `com/oracle/truffle/api/TruffleLanguage.Registration.html#website()` ### sandbox() `SandboxPolicy sandbox() default TRUSTED`. Since 23.0. Specifies the most strict sandbox policy in which the language can be used. The language can be used in a context with the specified sandbox policy or a weaker one. For example, if a language specifies `ISOLATED` policy, it can be used in a context configured with sandbox policy `TRUSTED`, `CONSTRAINED` or `ISOLATED`. But it cannot be used in a context configured with the `UNTRUSTED` sandbox policy. Default: `TRUSTED`. See also: [`SandboxPolicy`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/SandboxPolicy.html). Cite: `com/oracle/truffle/api/TruffleLanguage.Registration.html#sandbox()` ### internalResources() `Class[] internalResources() default {}`. Since 23.1. Declarative list of `InternalResource` classes that is associated with this language. Use the `internalResources` attribute solely for registering required internal resources. Optional internal resources should provide the associated language identifier using the `Id.componentId()` method. To unpack all resources of a language embedders may use [`Engine.copyResources(Path, String...)`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Engine.html#copyResources%28java.nio.file.Path,java.lang.String...%29). Default: `{}`. See also: `InternalResource`, `Id`. Cite: `com/oracle/truffle/api/TruffleLanguage.Registration.html#internalResources()` ### optionalResources() `String[] optionalResources() default {}`. Since 25.0. A declarative list of optional `InternalResource` identifiers associated with this language. It is recommended to register all optional resource identifiers here. Specifying the resource identifier allows the language use the resource even if its implementation was omitted at runtime. To use the resource when its implementation was omitted the `polyglot.engine.resourcePath.languageId` system property must be specified and point to a path with the resources. This allows to omit the resource implementation class in standalone distributions. Default: `{}`. See also: `InternalResource`, `Id`. Cite: `com/oracle/truffle/api/TruffleLanguage.Registration.html#optionalResources()` # ◆ TruffleLogger [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 19.0. ```java public final class TruffleLogger ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `TruffleLogger` Support for logging in Truffle languages and instruments. The logger's [`Level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html) configuration is done using the [`Context's options`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.Builder.html#options%28java.util.Map%29). The level option key has the following format: `log.languageId.className.level` or `log.instrumentId.className.level`. The value is either the name of pre-defined [`Level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html) constant or a numeric [`Level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html) value. If not explicitly set in [`Context's options`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.Builder.html#options%28java.util.Map%29) the level is inherited from the parent logger. The [`TruffleLogger`](com/oracle/truffle/api/TruffleLogger.md) supports [`message parameters`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/LogRecord.html#getParameters%28%29) of primitive types and strings. The object parameters are converted into string value before they are passed to the [`Handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Handler.html). The [`TruffleLogger`](com/oracle/truffle/api/TruffleLogger.md) instances are safe to be used on compiled code paths as well as from multiple-threads. ## Methods ### getLogger(String) `public static TruffleLogger getLogger(String id)`. Since 19.0. Find or create a root logger for a given language or instrument. If the root logger for given language or instrument already exists it's returned, otherwise a new root logger is created. Parameters: `id` `String`: the unique id of language or instrument. Returns `TruffleLogger`: a `TruffleLogger`. Throws: `NullPointerException` (unchecked): if `id` is null. `IllegalArgumentException` (unchecked): if `id` is not a valid language or instrument id. Cite: `com/oracle/truffle/api/TruffleLogger.html#getLogger(java.lang.String)` ### getLogger(String, Class) `public static TruffleLogger getLogger(String id, Class forClass)`. Since 19.0. Find or create a logger for a given language or instrument class. If a logger for the class already exists it's returned, otherwise a new logger is created. Parameters: `id` `String`: the unique id of language or instrument. `forClass` `Class`: the [`Class`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Class.html) to create a logger for. Returns `TruffleLogger`: a `TruffleLogger`. Throws: `NullPointerException` (unchecked): if `id` or `forClass` is null. `IllegalArgumentException` (unchecked): if `id` is not a valid language or instrument id. Cite: `com/oracle/truffle/api/TruffleLogger.html#getLogger(java.lang.String,java.lang.Class)` ### getLogger(String, String) `public static TruffleLogger getLogger(String id, String loggerName)`. Since 19.0. Find or create a logger for a given language or instrument. If a logger with given name already exists it's returned, otherwise a new logger is created. Parameters: `id` `String`: the unique id of language or instrument. `loggerName` `String`: the name of a `TruffleLogger`, if a `loggerName` is null or empty a root logger for language or instrument is returned. Returns `TruffleLogger`: a `TruffleLogger`. Throws: `NullPointerException` (unchecked): if `id` is null. `IllegalArgumentException` (unchecked): if `id` is not a valid language or instrument id. Cite: `com/oracle/truffle/api/TruffleLogger.html#getLogger(java.lang.String,java.lang.String)` ### config(String) `public void config(String message)`. Since 19.0. Logs a message with [`config level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#CONFIG). If the logger is enabled for the [`config level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#CONFIG) the message is sent to the [`Handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Handler.html) registered in the current [`Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html). Parameters: `message` `String`: the message to log. Cite: `com/oracle/truffle/api/TruffleLogger.html#config(java.lang.String)` ### config(Supplier) `public void config(Supplier messageSupplier)`. Since 19.0. Logs a message with [`config level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#CONFIG). The message is constructed only when the logger is enabled for the [`config level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#CONFIG). If the logger is enabled for the [`config level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#CONFIG) the message is sent to the [`Handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Handler.html) registered in the current [`Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html). Parameters: `messageSupplier` `Supplier`: the [`Supplier`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/Supplier.html) called to produce the message to log. Cite: `com/oracle/truffle/api/TruffleLogger.html#config(java.util.function.Supplier)` ### entering(String, String) `public void entering(String sourceClass, String sourceMethod)`. Since 19.0. Logs entry into method. This method can be used to log entry into a method. A [`LogRecord`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/LogRecord.html) with message "ENTRY" and the given `sourceMethod` and `sourceClass` is logged with [`finer level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#FINER). Parameters: `sourceClass` `String`: the entered class. `sourceMethod` `String`: the entered method. Cite: `com/oracle/truffle/api/TruffleLogger.html#entering(java.lang.String,java.lang.String)` ### entering(String, String, Object) `public void entering(String sourceClass, String sourceMethod, Object parameter)`. Since 19.0. Logs entry into method with single parameter. This method can be used to log entry into a method. A [`LogRecord`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/LogRecord.html) with message "ENTRY", the given `sourceMethod` and `sourceClass` and given parameter is logged with [`finer level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#FINER). Parameters: `sourceClass` `String`: the entered class. `sourceMethod` `String`: the entered method. `parameter` `Object`: the method parameter. Cite: `com/oracle/truffle/api/TruffleLogger.html#entering(java.lang.String,java.lang.String,java.lang.Object)` ### entering(String, String, Object[]) `public void entering(String sourceClass, String sourceMethod, Object[] parameters)`. Since 19.0. Logs entry into method with multiple parameters. This method can be used to log entry into a method. A [`LogRecord`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/LogRecord.html) with message "ENTRY", the given `sourceMethod` and `sourceClass` and given parameters is logged with [`finer level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#FINER). Parameters: `sourceClass` `String`: the entered class. `sourceMethod` `String`: the entered method. `parameters` `Object[]`: the method parameters. Cite: `com/oracle/truffle/api/TruffleLogger.html#entering(java.lang.String,java.lang.String,java.lang.Object[])` ### exiting(String, String) `public void exiting(String sourceClass, String sourceMethod)`. Since 19.0. Logs a return from method. This method can be used to log return from a method. A [`LogRecord`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/LogRecord.html) with message "RETURN" and the given `sourceMethod` and `sourceClass` is logged with [`finer level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#FINER). Parameters: `sourceClass` `String`: the exiting class. `sourceMethod` `String`: the exiting method. Cite: `com/oracle/truffle/api/TruffleLogger.html#exiting(java.lang.String,java.lang.String)` ### exiting(String, String, Object) `public void exiting(String sourceClass, String sourceMethod, Object result)`. Since 19.0. Logs a return from method with result. This method can be used to log return from a method. A [`LogRecord`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/LogRecord.html) with message "RETURN", the given `sourceMethod` and `sourceClass` and method result is logged with [`finer level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#FINER). Parameters: `sourceClass` `String`: the exiting class. `sourceMethod` `String`: the exiting method. `result` `Object`: the return value. Cite: `com/oracle/truffle/api/TruffleLogger.html#exiting(java.lang.String,java.lang.String,java.lang.Object)` ### fine(String) `public void fine(String message)`. Since 19.0. Logs a message with [`fine level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#FINE). If the logger is enabled for the [`fine level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#FINE) the message is sent to the [`Handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Handler.html) registered in the current [`Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html). Parameters: `message` `String`: the message to log. Cite: `com/oracle/truffle/api/TruffleLogger.html#fine(java.lang.String)` ### fine(Supplier) `public void fine(Supplier messageSupplier)`. Since 19.0. Logs a message with [`fine level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#FINE). The message is constructed only when the logger is enabled for the [`fine level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#FINE). If the logger is enabled for the [`fine level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#FINE) the message is sent to the [`Handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Handler.html) registered in the current [`Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html). Parameters: `messageSupplier` `Supplier`: the [`Supplier`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/Supplier.html) called to produce the message to log. Cite: `com/oracle/truffle/api/TruffleLogger.html#fine(java.util.function.Supplier)` ### finer(String) `public void finer(String message)`. Since 19.0. Logs a message with [`finer level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#FINER). If the logger is enabled for the [`finer level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#FINER) the message is sent to the [`Handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Handler.html) registered in the current [`Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html). Parameters: `message` `String`: the message to log. Cite: `com/oracle/truffle/api/TruffleLogger.html#finer(java.lang.String)` ### finer(Supplier) `public void finer(Supplier messageSupplier)`. Since 19.0. Logs a message with [`finer level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#FINER). The message is constructed only when the logger is enabled for the [`finer level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#FINER). If the logger is enabled for the [`finer level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#FINER) the message is sent to the [`Handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Handler.html) registered in the current [`Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html). Parameters: `messageSupplier` `Supplier`: the [`Supplier`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/Supplier.html) called to produce the message to log. Cite: `com/oracle/truffle/api/TruffleLogger.html#finer(java.util.function.Supplier)` ### finest(String) `public void finest(String message)`. Since 19.0. Logs a message with [`finest level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#FINEST). If the logger is enabled for the [`finest level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#FINEST) the message is sent to the [`Handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Handler.html) registered in the current [`Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html). Parameters: `message` `String`: the message to log. Cite: `com/oracle/truffle/api/TruffleLogger.html#finest(java.lang.String)` ### finest(Supplier) `public void finest(Supplier messageSupplier)`. Since 19.0. Logs a message with [`finest level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#FINEST). The message is constructed only when the logger is enabled for the [`finest level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#FINEST). If the logger is enabled for the [`finest level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#FINEST) the message is sent to the [`Handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Handler.html) registered in the current [`Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html). Parameters: `messageSupplier` `Supplier`: the [`Supplier`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/Supplier.html) called to produce the message to log. Cite: `com/oracle/truffle/api/TruffleLogger.html#finest(java.util.function.Supplier)` ### info(String) `public void info(String message)`. Since 19.0. Logs a message with [`info level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#INFO). If the logger is enabled for the [`info level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#INFO) the message is sent to the [`Handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Handler.html) registered in the current [`Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html). Parameters: `message` `String`: the message to log. Cite: `com/oracle/truffle/api/TruffleLogger.html#info(java.lang.String)` ### info(Supplier) `public void info(Supplier messageSupplier)`. Since 19.0. Logs a message with [`info level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#INFO). The message is constructed only when the logger is enabled for the [`info level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#INFO). If the logger is enabled for the [`info level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#INFO) the message is sent to the [`Handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Handler.html) registered in the current [`Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html). Parameters: `messageSupplier` `Supplier`: the [`Supplier`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/Supplier.html) called to produce the message to log. Cite: `com/oracle/truffle/api/TruffleLogger.html#info(java.util.function.Supplier)` ### severe(String) `public void severe(String message)`. Since 19.0. Logs a message with [`severe level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#SEVERE). If the logger is enabled for the [`severe level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#SEVERE) the message is sent to the [`Handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Handler.html) registered in the current [`Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html). Parameters: `message` `String`: the message to log. Cite: `com/oracle/truffle/api/TruffleLogger.html#severe(java.lang.String)` ### severe(Supplier) `public void severe(Supplier messageSupplier)`. Since 19.0. Logs a message with [`severe level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#SEVERE). The message is constructed only when the logger is enabled for the [`severe level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#SEVERE). If the logger is enabled for the [`severe level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#SEVERE) the message is sent to the [`Handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Handler.html) registered in the current [`Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html). Parameters: `messageSupplier` `Supplier`: the [`Supplier`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/Supplier.html) called to produce the message to log. Cite: `com/oracle/truffle/api/TruffleLogger.html#severe(java.util.function.Supplier)` ### throwing(String, String, T) `public T throwing(String sourceClass, String sourceMethod, T thrown)`. Since 19.0. Logs throwing an exception. This method can be used to log exception thrown from a method. A [`LogRecord`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/LogRecord.html) with message "THROW",the given `sourceMethod` and `sourceClass` and `thrown` is logged with [`finer level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#FINER). Parameters: `sourceClass` `String`: the class throwing an exception. `sourceMethod` `String`: the method throwing an exception. `thrown` `T`: the thrown exception. Cite: `com/oracle/truffle/api/TruffleLogger.html#throwing(java.lang.String,java.lang.String,T)` ### warning(String) `public void warning(String message)`. Since 19.0. Logs a message with [`warning level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#WARNING). If the logger is enabled for the [`warning level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#WARNING) the message is sent to the [`Handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Handler.html) registered in the current [`Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html). Parameters: `message` `String`: the message to log. Cite: `com/oracle/truffle/api/TruffleLogger.html#warning(java.lang.String)` ### warning(Supplier) `public void warning(Supplier messageSupplier)`. Since 19.0. Logs a message with [`warning level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#WARNING). The message is constructed only when the logger is enabled for the [`warning level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#WARNING). If the logger is enabled for the [`warning level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html#WARNING) the message is sent to the [`Handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Handler.html) registered in the current [`Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html). Parameters: `messageSupplier` `Supplier`: the [`Supplier`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/Supplier.html) called to produce the message to log. Cite: `com/oracle/truffle/api/TruffleLogger.html#warning(java.util.function.Supplier)` ### log(Level, String) `public void log(Level level, String message)`. Since 19.0. Logs a message. If the logger is enabled for the given `level` the message is sent to the [`Handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Handler.html) registered in the current [`Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html). Parameters: `level` `Level`: the required [`Level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html). `message` `String`: the message to log. Cite: `com/oracle/truffle/api/TruffleLogger.html#log(java.util.logging.Level,java.lang.String)` ### log(Level, Supplier) `public void log(Level level, Supplier messageSupplier)`. Since 19.0. Logs a message. The message is constructed only when the logger is enabled for the given `level`. If the logger is enabled for the given `level` the message is sent to the [`Handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Handler.html) registered in the current [`Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html). Parameters: `level` `Level`: the required [`Level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html). `messageSupplier` `Supplier`: the [`Supplier`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/Supplier.html) called to produce the message to log. Cite: `com/oracle/truffle/api/TruffleLogger.html#log(java.util.logging.Level,java.util.function.Supplier)` ### log(Level, String, Object) `public void log(Level level, String message, Object parameter)`. Since 19.0. Logs a message with single parameter. If the logger is enabled for the given `level` the message is sent to the [`Handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Handler.html) registered in the current [`Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html). Parameters: `level` `Level`: the required [`Level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html). `message` `String`: the message to log. `parameter` `Object`: the log message parameter. Cite: `com/oracle/truffle/api/TruffleLogger.html#log(java.util.logging.Level,java.lang.String,java.lang.Object)` ### log(Level, String, Object[]) `public void log(Level level, String message, Object[] parameters)`. Since 19.0. Logs a message with multiple parameters. If the logger is enabled for the given `level` the message is sent to the [`Handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Handler.html) registered in the current [`Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html). Parameters: `level` `Level`: the required [`Level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html). `message` `String`: the message to log. `parameters` `Object[]`: the log message parameters. Cite: `com/oracle/truffle/api/TruffleLogger.html#log(java.util.logging.Level,java.lang.String,java.lang.Object[])` ### log(Level, String, Throwable) `public void log(Level level, String message, Throwable thrown)`. Since 19.0. Logs a message with an exception. If the logger is enabled for the given `level` the message is sent to the [`Handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Handler.html) registered in the current [`Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html). Parameters: `level` `Level`: the required [`Level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html). `message` `String`: the message to log. `thrown` `Throwable`: the exception to log. Cite: `com/oracle/truffle/api/TruffleLogger.html#log(java.util.logging.Level,java.lang.String,java.lang.Throwable)` ### log(Level, Throwable, Supplier) `public void log(Level level, Throwable thrown, Supplier messageSupplier)`. Since 19.0. Logs a message with an exception. The message is constructed only when the logger is enabled for the given `level`. If the logger is enabled for the given `level` the message is sent to the [`Handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Handler.html) registered in the current [`Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html). Parameters: `level` `Level`: the required [`Level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html). `thrown` `Throwable`: the exception to log. `messageSupplier` `Supplier`: the [`Supplier`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/Supplier.html) called to produce the message to log. Cite: `com/oracle/truffle/api/TruffleLogger.html#log(java.util.logging.Level,java.lang.Throwable,java.util.function.Supplier)` ### logp(Level, String, …) `public void logp(Level level, String sourceClass, String sourceMethod, String message)`. Since 19.0. Logs a message, specifying source class and source method. If the logger is enabled for the given `level` the message is sent to the [`Handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Handler.html) registered in the current [`Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html). Parameters: `level` `Level`: the required [`Level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html). `sourceClass` `String`: the class issued the logging request. `sourceMethod` `String`: the method issued the logging request. `message` `String`: the message to log. Cite: `com/oracle/truffle/api/TruffleLogger.html#logp(java.util.logging.Level,java.lang.String,java.lang.String,java.lang.String)` ### logp(Level, String, …) `public void logp(Level level, String sourceClass, String sourceMethod, Supplier messageSupplier)`. Since 19.0. Logs a message, specifying source class and source method. The message is constructed only when the logger is enabled for the given `level`. If the logger is enabled for the given `level` the message is sent to the [`Handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Handler.html) registered in the current [`Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html). Parameters: `level` `Level`: the required [`Level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html). `sourceClass` `String`: the class issued the logging request. `sourceMethod` `String`: the method issued the logging request. `messageSupplier` `Supplier`: the [`Supplier`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/Supplier.html) called to produce the message to log. Cite: `com/oracle/truffle/api/TruffleLogger.html#logp(java.util.logging.Level,java.lang.String,java.lang.String,java.util.function.Supplier)` ### logp(Level, String, …) `public void logp(Level level, String sourceClass, String sourceMethod, String message, Object parameter)`. Since 19.0. Logs a message with single parameter, specifying source class and source method. If the logger is enabled for the given `level` the message is sent to the [`Handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Handler.html) registered in the current [`Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html). Parameters: `level` `Level`: the required [`Level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html). `sourceClass` `String`: the class issued the logging request. `sourceMethod` `String`: the method issued the logging request. `message` `String`: the message to log. `parameter` `Object`: the log message parameter. Cite: `com/oracle/truffle/api/TruffleLogger.html#logp(java.util.logging.Level,java.lang.String,java.lang.String,java.lang.String,java.lang.Object)` ### logp(Level, String, …) `public void logp(Level level, String sourceClass, String sourceMethod, String message, Object[] parameters)`. Since 19.0. Log a message with multiple parameters, specifying source class and source method. If the logger is enabled for the given `level` the message is sent to the [`Handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Handler.html) registered in the current [`Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html). Parameters: `level` `Level`: the required [`Level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html). `sourceClass` `String`: the class issued the logging request. `sourceMethod` `String`: the method issued the logging request. `message` `String`: the message to log. `parameters` `Object[]`: the log message parameters. Cite: `com/oracle/truffle/api/TruffleLogger.html#logp(java.util.logging.Level,java.lang.String,java.lang.String,java.lang.String,java.lang.Object[])` ### logp(Level, String, …) `public void logp(Level level, String sourceClass, String sourceMethod, String message, Throwable thrown)`. Since 19.0. Logs a message with an exception, specifying source class and source method. If the logger is enabled for the given `level` the message is sent to the [`Handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Handler.html) registered in the current [`Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html). Parameters: `level` `Level`: the required [`Level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html). `sourceClass` `String`: the class issued the logging request. `sourceMethod` `String`: the method issued the logging request. `message` `String`: the message to log. `thrown` `Throwable`: the exception to log. Cite: `com/oracle/truffle/api/TruffleLogger.html#logp(java.util.logging.Level,java.lang.String,java.lang.String,java.lang.String,java.lang.Throwable)` ### logp(Level, String, …) `public void logp(Level level, String sourceClass, String sourceMethod, Throwable thrown, Supplier messageSupplier)`. Since 19.0. Logs a message with an exception, specifying source class and source method. The message is constructed only when the logger is enabled for the given `level`. If the logger is enabled for the given `level` the message is sent to the [`Handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Handler.html) registered in the current [`Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html). Parameters: `level` `Level`: the required [`Level`](https://docs.oracle.com/en/java/javase/25/docs/api/java.logging/java/util/logging/Level.html). `sourceClass` `String`: the class issued the logging request. `sourceMethod` `String`: the method issued the logging request. `thrown` `Throwable`: the exception to log. `messageSupplier` `Supplier`: the [`Supplier`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/Supplier.html) called to produce the message to log. Cite: `com/oracle/truffle/api/TruffleLogger.html#logp(java.util.logging.Level,java.lang.String,java.lang.String,java.lang.Throwable,java.util.function.Supplier)` ### getName() `public String getName()`. Since 19.0. Returns the name of the logger. Returns `String`: the logger name. Cite: `com/oracle/truffle/api/TruffleLogger.html#getName()` ### getParent() `public TruffleLogger getParent()`. Since 19.0. Returns the parent `TruffleLogger`. Returns `TruffleLogger`: the parent `TruffleLogger` or null when the `TruffleLogger` has no parent. Cite: `com/oracle/truffle/api/TruffleLogger.html#getParent()` ### isLoggable(Level) `public boolean isLoggable(Level level)`. Since 19.0. Checks if a message of the given level would be logged by this logger. Parameters: `level` `Level`: the required logging level. Returns `boolean`: true if message is loggable by this logger. Cite: `com/oracle/truffle/api/TruffleLogger.html#isLoggable(java.util.logging.Level)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ TruffleOptionDescriptors [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 23.0. ```java public interface TruffleOptionDescriptors extends OptionDescriptors ``` Extends: [`OptionDescriptors`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/options/OptionDescriptors.html) An [`OptionDescriptors`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/options/OptionDescriptors.html) enhanced to provide a sandbox policy for options. ## Methods ### getSandboxPolicy(String) `SandboxPolicy getSandboxPolicy(String key)`. Since 23.0. Returns a [`SandboxPolicy`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/SandboxPolicy.html) for an option `key`. Cite: `com/oracle/truffle/api/TruffleOptionDescriptors.html#getSandboxPolicy(java.lang.String)` ## Inherited members - From interface [`OptionDescriptors`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/options/OptionDescriptors.html): [`EMPTY`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/options/OptionDescriptors.html#EMPTY), [`get`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/options/OptionDescriptors.html#get%28java.lang.String%29), [`iterator`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/options/OptionDescriptors.html#iterator%28%29) - From interface [`Iterable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Iterable.html): [`forEach`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Iterable.html#forEach%28java.util.function.Consumer%29), [`spliterator`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Iterable.html#spliterator%28%29) # ◆ TruffleOptions [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 0.8 or earlier. ```java public final class TruffleOptions ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `TruffleOptions` Class containing general Truffle options. ## Fields ### TraceRewrites `public static final boolean TraceRewrites`. Since 0.8 or earlier. Enables/disables the rewriting of traces in the Truffle runtime to stdout. Can be set with `-Dtruffle.TraceRewrites=true`. Cite: `com/oracle/truffle/api/TruffleOptions.html#TraceRewrites` ### DetailedRewriteReasons `public static final boolean DetailedRewriteReasons`. Since 0.8 or earlier. Enables the generation of detailed rewrite reasons. Enabling this may introduce some overhead for rewriting nodes. Can be set with `-Dtruffle.DetailedRewriteReasons=true`. Cite: `com/oracle/truffle/api/TruffleOptions.html#DetailedRewriteReasons` ### DetailedAssertions `public static final boolean DetailedAssertions`. Since 25.6. Enables expensive assertions in Truffle and guest language implementations. An assertion is expensive if its cost is significant compared to the operation it checks, for example when it recomputes a cached result. Disabled by default. Can be set with `-Dtruffle.DetailedAssertions=true` before this class is initialized. Java assertions must also be enabled for the classes containing the checks. For native images, set the property when building the image. This is not a polyglot option and is not forwarded to polyglot isolates. Use this option to guard expensive checks while keeping inexpensive assertions enabled: Cite: `com/oracle/truffle/api/TruffleOptions.html#DetailedAssertions` ```java assert !TruffleOptions.DetailedAssertions || expensiveCheck(); ``` ### TraceRewritesFilterClass `public static final String TraceRewritesFilterClass`. Since 0.8 or earlier. Filters rewrites that do not contain the given string in the qualified name of the source or target class hierarchy. Can be set with `-Dtruffle.TraceRewritesFilterClass=name`. Cite: `com/oracle/truffle/api/TruffleOptions.html#TraceRewritesFilterClass` ### TraceRewritesFilterFromCost `@Deprecated public static final NodeCost TraceRewritesFilterFromCost`. Since 0.8 or earlier. Deprecated. in 24.1 without replacement. Cite: `com/oracle/truffle/api/TruffleOptions.html#TraceRewritesFilterFromCost` ### TraceRewritesFilterToCost `@Deprecated public static final NodeCost TraceRewritesFilterToCost`. Since 0.8 or earlier. Deprecated. in 24.1 without replacement. Cite: `com/oracle/truffle/api/TruffleOptions.html#TraceRewritesFilterToCost` ### AOT `public static final boolean AOT`. Since 0.8 or earlier. Forces ahead-of-time initialization. Cite: `com/oracle/truffle/api/TruffleOptions.html#AOT` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ TruffleRuntime [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 0.8 or earlier. ```java public interface TruffleRuntime ``` Interface representing a Truffle runtime object. The runtime is responsible for creating call targets and performing optimizations for them. ## Methods ### getName() `String getName()`. Since 0.8 or earlier. Name describing this runtime implementation for debugging purposes. Returns `String`: the name as a String. Cite: `com/oracle/truffle/api/TruffleRuntime.html#getName()` ### createDirectCallNode(CallTarget) `default DirectCallNode createDirectCallNode(CallTarget target)`. Since 0.8 or earlier. Creates a new runtime specific version of `DirectCallNode`. Parameters: `target` `CallTarget`: the direct `CallTarget` to call. Returns `DirectCallNode`: the new call node. Cite: `com/oracle/truffle/api/TruffleRuntime.html#createDirectCallNode(com.oracle.truffle.api.CallTarget)` ### createLoopNode(RepeatingNode) `LoopNode createLoopNode(RepeatingNode body)`. Since 0.8 or earlier. Creates a new loop node with an implementation provided by a Truffle runtime implementation. Using Truffle loop nodes allows the runtime to do additional optimizations such as on stack replacement for loops. See also: `usage example`. Cite: `com/oracle/truffle/api/TruffleRuntime.html#createLoopNode(com.oracle.truffle.api.nodes.RepeatingNode)` ### createIndirectCallNode() `default IndirectCallNode createIndirectCallNode()`. Since 0.8 or earlier. Creates a new runtime specific version of `IndirectCallNode`. Returns `IndirectCallNode`: the new call node. Cite: `com/oracle/truffle/api/TruffleRuntime.html#createIndirectCallNode()` ### createAssumption() `Assumption createAssumption()`. Since 0.8 or earlier. Creates a new assumption object that can be checked and invalidated. Returns `Assumption`: the newly created assumption object. Cite: `com/oracle/truffle/api/TruffleRuntime.html#createAssumption()` ### createAssumption(String) `Assumption createAssumption(String name)`. Since 0.8 or earlier. Creates a new assumption object with a given name that can be checked and invalidated. Parameters: `name` `String`: the name for the new assumption. Returns `Assumption`: the newly created assumption object. Cite: `com/oracle/truffle/api/TruffleRuntime.html#createAssumption(java.lang.String)` ### createVirtualFrame(Object[], FrameDescriptor) `VirtualFrame createVirtualFrame(Object[] arguments, FrameDescriptor frameDescriptor)`. Since 0.8 or earlier. Creates a new virtual frame object that can be used to store values and is potentially optimizable by the runtime. Returns `VirtualFrame`: the newly created virtual frame object. Cite: `com/oracle/truffle/api/TruffleRuntime.html#createVirtualFrame(java.lang.Object[],com.oracle.truffle.api.frame.FrameDescriptor)` ### createMaterializedFrame(Object[]) `MaterializedFrame createMaterializedFrame(Object[] arguments)`. Since 0.8 or earlier. Creates a new materialized frame object that can be used to store values. Returns `MaterializedFrame`: the newly created materialized frame object. Cite: `com/oracle/truffle/api/TruffleRuntime.html#createMaterializedFrame(java.lang.Object[])` ### createMaterializedFrame(Object[], FrameDescriptor) `MaterializedFrame createMaterializedFrame(Object[] arguments, FrameDescriptor frameDescriptor)`. Since 0.8 or earlier. Creates a new materialized frame object with the given frame descriptor that can be used to store values. Parameters: `frameDescriptor` `FrameDescriptor`: the frame descriptor describing this frame's values. Returns `MaterializedFrame`: the newly created materialized frame object. Cite: `com/oracle/truffle/api/TruffleRuntime.html#createMaterializedFrame(java.lang.Object[],com.oracle.truffle.api.frame.FrameDescriptor)` ### iterateFrames(FrameInstanceVisitor) `default T iterateFrames(FrameInstanceVisitor visitor)`. Since 0.8 or earlier. Accesses the current stack, i.e., the contents of the `Frame`s and the associated `CallTarget`s. Iteration starts at the current frame. Iteration continues as long as `FrameInstanceVisitor.visitFrame`, which is invoked for every `FrameInstance`, returns null. Any non-null result of the visitor indicates that frame iteration should stop. Instances of `FrameInstance` must not escape the invocation of `FrameInstanceVisitor.visitFrame(FrameInstance)`. This rule is currently not enforced, but will be in future versions of Truffle. Note that this method can cause deoptimization if `FrameInstance.getFrame(FrameInstance.FrameAccess)` is called with `FrameAccess.READ_WRITE` or `FrameAccess.MATERIALIZE` on the fast path. Instructions and flags for debugging such deoptimizations can be found in [/truffle/docs/Optimizing.md#debugging-deoptimizations](https://github.com/oracle/graal/blob/master/truffle/docs/Optimizing.md#debugging-deoptimizations) To get possible asynchronous stack frames, use `TruffleStackTrace.getAsynchronousStackTrace(CallTarget, Frame)` and provide call target and frame from the last `FrameInstance`. Parameters: `visitor` `FrameInstanceVisitor`: the visitor that is called for every matching frame. Returns `T`: the last result returned by the visitor (which is non-null to indicate that iteration should stop), or null if the whole stack was iterated. Cite: `com/oracle/truffle/api/TruffleRuntime.html#iterateFrames(com.oracle.truffle.api.frame.FrameInstanceVisitor)` ### iterateFrames(FrameInstanceVisitor, int) `default T iterateFrames(FrameInstanceVisitor visitor, int skipFrames)`. Since 21.1. Accesses the current stack, i.e., the contents of the `Frame`s and the associated `CallTarget`s. Iteration starts at the current frame and skips a number of frames provided as argument. Iteration continues as long as `FrameInstanceVisitor.visitFrame`, which is invoked for every `FrameInstance`, returns null. Any non-null result of the visitor indicates that frame iteration should stop. Instances of `FrameInstance` must not escape the invocation of `FrameInstanceVisitor.visitFrame(FrameInstance)`. This rule is currently not enforced, but will be in future versions of Truffle. Note that this method can cause deoptimization if `FrameInstance.getFrame(FrameInstance.FrameAccess)` is called with `FrameAccess.READ_WRITE` or `FrameAccess.MATERIALIZE` on the fast path. Instructions and flags for debugging such deoptimizations can be found in [/truffle/docs/Optimizing.md#debugging-deoptimizations](https://github.com/oracle/graal/blob/master/truffle/docs/Optimizing.md#debugging-deoptimizations) To get possible asynchronous stack frames, use `TruffleStackTrace.getAsynchronousStackTrace(CallTarget, Frame)` and provide call target and frame from the last `FrameInstance`. Parameters: `visitor` `FrameInstanceVisitor`: the visitor that is called for every matching frame. `skipFrames` `int`: number of frames to skip before invoking the visitor. Returns `T`: the last result returned by the visitor (which is non-null to indicate that iteration should stop), or null if the whole stack was iterated. Cite: `com/oracle/truffle/api/TruffleRuntime.html#iterateFrames(com.oracle.truffle.api.frame.FrameInstanceVisitor,int)` ### getCapability(Class) ` T getCapability(Class capability)`. Since 0.8 or earlier. Requests a capability from the runtime. Parameters: `capability` `Class`: the type of the interface representing the capability. Returns `T`: an implementation of the capability or `null` if the runtime does not offer it. Cite: `com/oracle/truffle/api/TruffleRuntime.html#getCapability(java.lang.Class)` ### notifyTransferToInterpreter() `void notifyTransferToInterpreter()`. Since 0.8 or earlier. Internal API method. Do not use. Cite: `com/oracle/truffle/api/TruffleRuntime.html#notifyTransferToInterpreter()` ### isProfilingEnabled() `boolean isProfilingEnabled()`. Since 0.8 or earlier. Whether or not the `TruffleRuntime` implementation can or wants to use gathered profiling information Truffle compilation. If this method returns `false` then all profiles in the `com.oracle.truffle.api.utilities` package are returning void implementations. If it returns `true` then all implementations gather profilinig information. Cite: `com/oracle/truffle/api/TruffleRuntime.html#isProfilingEnabled()` # ◇ TruffleRuntimeAccess [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 0.8 or earlier. ```java public interface TruffleRuntimeAccess ``` A service that provides access to a [`TruffleRuntime`](com/oracle/truffle/api/TruffleRuntime.md) implementation. ## Methods ### getRuntime() `TruffleRuntime getRuntime()`. Since 0.8 or earlier. Gets the `TruffleRuntime` implementation available via this access object. Cite: `com/oracle/truffle/api/TruffleRuntimeAccess.html#getRuntime()` ### getPriority() `default int getPriority()`. Since 0.28. Allows disambiguation if more than one `TruffleRuntime` implementation is available. Cite: `com/oracle/truffle/api/TruffleRuntimeAccess.html#getPriority()` # ◆ TruffleSafepoint [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 21.1. ```java public abstract class TruffleSafepoint ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `TruffleSafepoint` Truffle safepoints allow interrupting the guest language execution to execute thread-local actions submitted by a language or tool. A safepoint is a location during the guest language execution where the state is consistent, and other operations can read its state. ### Supporting Safepoints in a Language Safepoints are explicitly polled by invoking the [`poll(Node)`](com/oracle/truffle/api/TruffleSafepoint.md#poll%28com.oracle.truffle.api.nodes.Node%29) method. Safepoints are [`polled`](com/oracle/truffle/api/TruffleSafepoint.md#poll%28com.oracle.truffle.api.nodes.Node%29) with relaxed location or with [`exact location`](com/oracle/truffle/api/TruffleSafepoint.md#pollHere%28com.oracle.truffle.api.nodes.Node%29). A poll with a relaxed location is significantly more efficient than a poll with a precise location as the compiler is able to move and combine the poll requests during compilation. A Truffle guest language implementation must ensure that a safepoint is polled repeatedly within a constant time interval. For example, a single arithmetic expression completes within a constant number of CPU cycles. However, a loop that summarizes values over an array uses a non-constant time dependent on the array size. This typically means that safepoints are best polled at the end of loops and at the end of function or method calls to cover recursion. In addition, any guest language code that blocks the execution, like guest language locks, need to use the [`blocking API`](com/oracle/truffle/api/TruffleSafepoint.md#setBlocked%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.TruffleSafepoint.Interrupter,com.oracle.truffle.api.TruffleSafepoint.Interruptible,T,java.lang.Runnable,java.util.function.Consumer%29) to allow polling of safepoints while the thread is waiting. Truffle's [`loop node`](com/oracle/truffle/api/nodes/LoopNode.md) and [`root node`](com/oracle/truffle/api/nodes/RootNode.md) support safepoint polling automatically. No further calls to [`poll(Node)`](com/oracle/truffle/api/TruffleSafepoint.md#poll%28com.oracle.truffle.api.nodes.Node%29) are therefore necessary. Custom loops or loops behind [`boundary`](com/oracle/truffle/api/CompilerDirectives.TruffleBoundary.md) annotated method calls are expected to be notified by the guest language implementation manually. Thread local actions optionally incur side-effects. By default side-effects are enabled. A language implementation may disable side-effects temporarily for the current thread using [`setAllowSideEffects(boolean)`](com/oracle/truffle/api/TruffleSafepoint.md#setAllowSideEffects%28boolean%29) method. ### Submitting thread local actions See [`ThreadLocalAction`](com/oracle/truffle/api/ThreadLocalAction.md) for details on how to submit actions. Further information can be found in the [safepoint tutorial](http://github.com/oracle/graal/blob/master/truffle/docs/Safepoints.md). **See also** - [`ThreadLocalAction`](com/oracle/truffle/api/ThreadLocalAction.md) - [`Context.safepoint()`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html#safepoint%28%29) ## Nested types - [`TruffleSafepoint.CompiledInterruptible`](com/oracle/truffle/api/TruffleSafepoint.CompiledInterruptible.md) (interface): Just like Interruptible but allows partial evaluation. - [`TruffleSafepoint.CompiledInterruptibleFunction`](com/oracle/truffle/api/TruffleSafepoint.CompiledInterruptibleFunction.md) (interface): Just like InterruptibleFunction but allows partial evaluation. - [`TruffleSafepoint.Interrupter`](com/oracle/truffle/api/TruffleSafepoint.Interrupter.md) (interface): An interrupter allows a foreign thread to interrupt the execution on a separate thread. - [`TruffleSafepoint.Interruptible`](com/oracle/truffle/api/TruffleSafepoint.Interruptible.md) (interface): Function interface that represent interruptable Java methods. - [`TruffleSafepoint.InterruptibleFunction`](com/oracle/truffle/api/TruffleSafepoint.InterruptibleFunction.md) (interface): Function interface that represent interruptable Java methods. ## Constructors ### TruffleSafepoint(Accessor.EngineSupport) `protected TruffleSafepoint(Accessor.EngineSupport support)`. Since 21.1. Do not extend this class. This class is intended to be implemented by a Truffle runtime implementation. Cite: `com/oracle/truffle/api/TruffleSafepoint.html#(com.oracle.truffle.api.impl.Accessor.EngineSupport)` ## Methods ### poll(Node) `public static void poll(Node location)`. Since 21.1. Polls a safepoint at the provided location. This allows to run thread local actions at this location. A Truffle guest language implementation must ensure that a safepoint is polled repeatedly within a constant time interval. See `TruffleSafepoint` for further details. In compiled code calls to this method are removed. Instead the compiler inserts safepoints automatically at loop ends and method exits. In this case the node location is approximated by frame state of method ends and loop exits in the compiler IR. For method ends the parent root node and for loop exits the loop node is passed as location. Guest language exceptions may be thrown by this method. If `side-effects` are allowed then also guest language exceptions may be thrown. Otherwise only internal or [`thread-death`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ThreadDeath.html) exceptions may be thrown. This method is safe to be used on compiled code paths. Polling may be performed on threads without entered polyglot context, polls are ignored there. Example usage with an unbounded loop sum behind a `TruffleBoundary`. Parameters: `location` `Node`: the location of the poll. May be `null`, but it is recommended to always pass a location node, if available. See also: `TruffleSafepoint`, `pollHere(Node)`. Cite: `com/oracle/truffle/api/TruffleSafepoint.html#poll(com.oracle.truffle.api.nodes.Node)` ```java @TruffleBoundary int sum(int[] array) { int sum = 0; for (int i = 0; i < array.length; i++) { sum += array[i]; TruffleSafepoint.poll(); } return sum; } ``` ### pollHere(Node) `public static void pollHere(Node location)`. Since 21.1. Similar to `poll(Node)` but with exact location. A poll with `relaxed location` is significantly more efficient than a poll with precise location as the compiler is able to move and combine the poll requests during compilation. This method is safe to be used on compiled code paths. Usage example: Parameters: `location` `Node`: the location of the poll. Must not be `null`. See also: `poll(Node)`. Cite: `com/oracle/truffle/api/TruffleSafepoint.html#pollHere(com.oracle.truffle.api.nodes.Node)` ```java TruffleSafepoint safepoint = TruffleSafepoint.getCurrent(); boolean prev = safepoint.setAllowSideEffects(false); try { // criticial section } finally { safepoint.setAllowSideEffects(prev); TruffleSafepoint.pollHere(this); } ``` ### setBlockedWithException(Node, TruffleSafepoint.Interrupter, …) `@Deprecated public void setBlockedWithException(Node location, TruffleSafepoint.Interrupter interrupter, TruffleSafepoint.Interruptible interruptible, T object, Runnable beforeInterrupt, Consumer afterInterrupt)`. Since 22.1. Deprecated. Use `setBlocked(Node, Interrupter, Interruptible, Object, Runnable, Consumer)`. Transitions the current thread into a blocked state and calls an interruptible functional method. The blocked state is restored when the interruptible method returns. Setting the blocked state allows safepoint notification while the current thread is blocked. This allows Truffle to interrupt e.g. locks temporarily to perform a thread local action. The `location>` parameter is used `poll` all pending thread local actions before transition to blocked state. The `interrupter` parameter specifies how the blocked state can be interrupted from another thread. The interrupter allows to interrupt the blocked state from other threads. For most blocking java.util.concurrent primitives the `thread interrupter` can be used. If the thread will be blocked in native code, other ways of interrupting, like signals may be used by implementing the `Interrupter` interface. The `interruptible` parameter provides the method that calls the blocking method which throws [`InterruptedException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/InterruptedException.html) on interrupt. In order to avoid allocations of the functional interface a single argument can be provided that is passed to the interface. This is typically the [`lock`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/locks/Lock.html) or [`semaphore`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/Semaphore.html) instance. The implementation of this method is expected to throw an [`InterruptedException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/InterruptedException.html) if the `Interrupter.interrupt(Thread)` method is invoked for this thread. For most java.util.concurrent primitives this is supported by using the interruptible blocking method variant, for example [`Lock.lockInterruptibly()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/locks/Lock.html#lockInterruptibly%28%29). Since it is common to use this method with method reference syntax e.g. `Lock::lockInterruptibly` for the interruptible parameter, we implicitlely apply a `boundary` for the entire method call by default. If the interruptible is called from a compiled code path and the interruptible should get partial evaluated, then `CompiledInterruptible` should be used instead of `Interruptible`. In this case the parameter must be a `partial evaluation constant`. The `beforeInterrupt` [`runnable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Runnable.html) and `afterInterrupt` [`consumer`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/Consumer.html) optional parameters allow to run code before and after a thread got interrupted and safepoint events are processed. If `null` is provided then no action will be performed. Arbitrary code may be executed in this runnable. Note that the blocked state is temporarily reset to its previous state while the afterInterrupt is called. If an exception is thrown during the processing of the safepoint, `afterInterrupt` will receive the throwable as argument, or `null` if the safepoint successfully completed. This exception will still be thrown after completion of `afterInterrupt`, unless `afterInterrupt` throws an exception of its own. Multiple recursive invocations of this method is supported. The previous blocked state will be restored when the method completes or fails. Example usage: Note there is a short-cut method to achieve the same behavior as in this example `setBlockedThreadInterruptible(Node, Interruptible, Object)`. See also: `TruffleSafepoint`. Cite: `com/oracle/truffle/api/TruffleSafepoint.html#setBlockedWithException(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.TruffleSafepoint.Interrupter,com.oracle.truffle.api.TruffleSafepoint.Interruptible,T,java.lang.Runnable,java.util.function.Consumer)` ```java Lock lock = new ReentrantLock(); TruffleSafepoint sp = TruffleSafepoint.getCurrent(); sp.setBlocked(location, Interrupter.THREAD_INTERRUPT, ReentrantLock::lockInterruptibly, lock, null, null); ``` ### setBlockedFunction(Node, TruffleSafepoint.Interrupter, …) `public abstract R setBlockedFunction(Node location, TruffleSafepoint.Interrupter interrupter, TruffleSafepoint.InterruptibleFunction interruptible, T object, Runnable beforeInterrupt, Consumer afterInterrupt)`. Since 23.1. Transitions the current thread into a blocked state and calls an interruptible functional method. The blocked state is restored when the interruptible method returns. Setting the blocked state allows safepoint notification while the current thread is blocked. This allows Truffle to interrupt e.g. locks temporarily to perform a thread local action. The `location` parameter is used to `poll` all pending thread local actions before transition to blocked state. It may be `null`, but it is recommended to always pass a location node, if available. The `interrupter` parameter specifies how the blocked state can be interrupted from another thread. The interrupter allows to interrupt the blocked state from other threads. For most blocking java.util.concurrent primitives the `thread interrupter` can be used. If the thread will be blocked in native code, other ways of interrupting, like signals may be used by implementing the `Interrupter` interface. The `interruptible` parameter provides the method that calls the blocking method which throws [`InterruptedException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/InterruptedException.html) on interrupt. In order to avoid allocations of the functional interface a single argument can be provided that is passed to the interface. This is typically the [`lock`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/locks/Lock.html) or [`semaphore`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/Semaphore.html) instance. The implementation of this method is expected to throw an [`InterruptedException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/InterruptedException.html) if the `Interrupter.interrupt(Thread)` method is invoked for this thread. For most java.util.concurrent primitives this is supported by using the interruptible blocking method variant, for example [`Lock.lockInterruptibly()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/locks/Lock.html#lockInterruptibly%28%29). `boundary` is applied for the entire interruptible method call by default. If the interruptible is called from a compiled code path and the interruptible should get partial evaluated, then `CompiledInterruptibleFunction` should be used instead of `InterruptibleFunction`. In this case the parameter must be a `partial evaluation constant`. The `beforeInterrupt` [`runnable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Runnable.html) and `afterInterrupt` [`consumer`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/Consumer.html) optional parameters allow to run code before and after a thread got interrupted and safepoint events are processed. If `null` is provided then no action will be performed. Arbitrary code may be executed in this runnable. Note that the blocked state is temporarily reset to its previous state while the afterInterrupt is called. If an exception is thrown during the processing of the safepoint, `afterInterrupt` will receive the throwable as argument, or `null` if the safepoint successfully completed. This exception will still be thrown after completion of `afterInterrupt`, unless `afterInterrupt` throws an exception of its own. Multiple recursive invocations of this method is supported. The previous blocked state will be restored when the method completes or fails. Example usage: Note there is a short-cut method to achieve the same behavior as in this example `setBlockedThreadInterruptibleFunction(Node, InterruptibleFunction, Object)`. See also: `TruffleSafepoint`. Cite: `com/oracle/truffle/api/TruffleSafepoint.html#setBlockedFunction(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.TruffleSafepoint.Interrupter,com.oracle.truffle.api.TruffleSafepoint.InterruptibleFunction,T,java.lang.Runnable,java.util.function.Consumer)` ```java Queue queue = new ArrayBlockingQueue<>(10); TruffleSafepoint sp = TruffleSafepoint.getCurrent(); sp.setBlockedFunction(location, Interrupter.THREAD_INTERRUPT, BlockingQueue::take, queue, null, null); ``` ### setBlocked(Node, TruffleSafepoint.Interrupter, …) `public abstract void setBlocked(Node location, TruffleSafepoint.Interrupter interrupter, TruffleSafepoint.Interruptible interruptible, T object, Runnable beforeInterrupt, Consumer afterInterrupt)`. Since 23.1. The same as `setBlockedFunction(Node, Interrupter, InterruptibleFunction, Object, Runnable, Consumer)`. The only difference is that the interruptible functional method does not return anything. Cite: `com/oracle/truffle/api/TruffleSafepoint.html#setBlocked(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.TruffleSafepoint.Interrupter,com.oracle.truffle.api.TruffleSafepoint.Interruptible,T,java.lang.Runnable,java.util.function.Consumer)` ### setBlockedThreadInterruptible(Node, TruffleSafepoint.Interruptible, T) `public static void setBlockedThreadInterruptible(Node location, TruffleSafepoint.Interruptible interruptible, T object)`. Since 21.1. Short-cut method to allow setting the blocked status for methods that throw [`InterruptedException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/InterruptedException.html) and support interrupting using [`Thread.interrupt()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Thread.html#interrupt%28%29). Parameters: `location` `Node`: the location with which the safepoint should be polled. `interruptible` `TruffleSafepoint.Interruptible`: the thread interruptable method to use for locking the object. `object` `T`: the instance to use the interruptable method with. Cite: `com/oracle/truffle/api/TruffleSafepoint.html#setBlockedThreadInterruptible(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.TruffleSafepoint.Interruptible,T)` ### setBlockedThreadInterruptibleFunction(Node, TruffleSafepoint.InterruptibleFunction, T) `public static R setBlockedThreadInterruptibleFunction(Node location, TruffleSafepoint.InterruptibleFunction interruptible, T object)`. Since 23.1. Short-cut method to allow setting the blocked status for methods that throw [`InterruptedException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/InterruptedException.html) and support interrupting using [`Thread.interrupt()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Thread.html#interrupt%28%29). Parameters: `location` `Node`: the location with which the safepoint should be polled. `interruptible` `TruffleSafepoint.InterruptibleFunction`: the thread interruptable method to use for locking the object. `object` `T`: the instance to use the interruptable method with. Cite: `com/oracle/truffle/api/TruffleSafepoint.html#setBlockedThreadInterruptibleFunction(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.TruffleSafepoint.InterruptibleFunction,T)` ### setAllowActions(boolean) `public abstract boolean setAllowActions(boolean enabled) throws IllegalStateException`. Since 22.1. Allows to temporarily delay all thread local actions on the current thread. It is recommended to delay actions only for a constant period of time and while trusted and internal guest code is running. Please consider using `setAllowSideEffects(boolean)` before using this method. While actions are disabled the value of `setAllowSideEffects(boolean)` has no effect. When `actions` are enabled again the value of `setAllowSideEffects(boolean)` will be interpreted again. Currently this method may only be used during `context finalization`. This could be necessary to free up native resources through guest code when a context is cancelled to avoid resource leakage. Any usage of this method should be subject to a detailed security review to ensure only internal and well-known guest code is executed. Disabling thread local actions may delay thread local actions like exit, cancellation and interruption. Example usage: Throws: `IllegalStateException`: if allow actions can currently not be set, for example outside the scope of a `context finalization`. See also: `TruffleLanguage.finalizeContext(Object)`. Cite: `com/oracle/truffle/api/TruffleSafepoint.html#setAllowActions(boolean)` ```java TruffleSafepoint sp = TruffleSafepoint.getCurrent(); boolean prev = sp.setAllowActions(false); try { // critical section } finally { sp.setAllowActions(prev); } ``` ### setAllowSideEffects(boolean) `public abstract boolean setAllowSideEffects(boolean enabled)`. Since 21.1. Allows to temporarily delay side-effecting thread local actions on the current thread. It is recommended to delay side-effecting actions only for a short and constant period of time. While side-effecting thread local actions are delayed on this thread, only non-side-effecting thread local actions will be scheduled in this thread. Non-side-effecting thread local actions do not mutate guest objects, run guest code or throw guest exceptions, but they might still throw internal errors. Example usage: Cite: `com/oracle/truffle/api/TruffleSafepoint.html#setAllowSideEffects(boolean)` ```java TruffleSafepoint sp = TruffleSafepoint.getCurrent(); boolean prev = sp.setAllowSideEffects(false); try { // critical section } finally { sp.setAllowSideEffects(prev); } ``` ### hasPendingSideEffectingActions() `public abstract boolean hasPendingSideEffectingActions()`. Since 21.1. Returns whether there is any pending side-effecting thread local action on this thread, due to being in a critical section using `setAllowSideEffects(boolean)`. When side-effecting actions are allowed, this method always returns `false`. This is useful if the language exposes a way to know if there are any pending side-effecting thread local action due to using `setAllowSideEffects(boolean)`. Cite: `com/oracle/truffle/api/TruffleSafepoint.html#hasPendingSideEffectingActions()` ### getCurrent() `public static TruffleSafepoint getCurrent()`. Since 21.1. Returns the current safepoint configuration for the current thread. This method is useful to access configuration methods like `setBlocked(Node, Interrupter, Interruptible, Object, Runnable, Consumer)` or `setAllowSideEffects(boolean)`. Important: The result of this method must not be stored or used on a different thread than the current thread. Throws: `IllegalStateException` (unchecked): if the current thread is not entered with a polyglot context. Cite: `com/oracle/truffle/api/TruffleSafepoint.html#getCurrent()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ TruffleSafepoint.CompiledInterruptible [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 21.1. Nested in [`TruffleSafepoint`](com/oracle/truffle/api/TruffleSafepoint.md). ```java @FunctionalInterface public interface TruffleSafepoint.CompiledInterruptible extends TruffleSafepoint.Interruptible ``` Extends: [`TruffleSafepoint.Interruptible`](com/oracle/truffle/api/TruffleSafepoint.Interruptible.md)`` Just like [`Interruptible`](com/oracle/truffle/api/TruffleSafepoint.Interruptible.md) but allows partial evaluation. ## Methods ### apply(T) `void apply(T arg) throws InterruptedException`. Since 21.1. Runs the interruptable method for a given object. Overrides `apply()`. Cite: `com/oracle/truffle/api/TruffleSafepoint.CompiledInterruptible.html#apply(T)` # ◇ TruffleSafepoint.CompiledInterruptibleFunction [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 23.1. Nested in [`TruffleSafepoint`](com/oracle/truffle/api/TruffleSafepoint.md). ```java @FunctionalInterface public interface TruffleSafepoint.CompiledInterruptibleFunction extends TruffleSafepoint.InterruptibleFunction ``` Extends: [`TruffleSafepoint.InterruptibleFunction`](com/oracle/truffle/api/TruffleSafepoint.InterruptibleFunction.md)`` Just like [`InterruptibleFunction`](com/oracle/truffle/api/TruffleSafepoint.InterruptibleFunction.md) but allows partial evaluation. ## Methods ### apply(T) `R apply(T arg) throws InterruptedException`. Since 23.1. Runs the interruptible method for a given object. Overrides `apply()`. Cite: `com/oracle/truffle/api/TruffleSafepoint.CompiledInterruptibleFunction.html#apply(T)` # ◇ TruffleSafepoint.Interrupter [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 21.1. Nested in [`TruffleSafepoint`](com/oracle/truffle/api/TruffleSafepoint.md). ```java public interface TruffleSafepoint.Interrupter ``` An interrupter allows a foreign thread to interrupt the execution on a separate thread. Used to allow the Truffle safepoint mechanism to interrupt a blocked thread and schedule a safepoint. **See also** - [`TruffleSafepoint.setBlocked(Node, Interrupter, Interruptible, Object, Runnable, Consumer)`](com/oracle/truffle/api/TruffleSafepoint.md#setBlocked%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.TruffleSafepoint.Interrupter,com.oracle.truffle.api.TruffleSafepoint.Interruptible,T,java.lang.Runnable,java.util.function.Consumer%29) - [`Interrupter.THREAD_INTERRUPT`](com/oracle/truffle/api/TruffleSafepoint.Interrupter.md#THREAD_INTERRUPT) ## Fields ### THREAD_INTERRUPT `TruffleSafepoint.Interrupter THREAD_INTERRUPT`. Since 21.1. A thread interrupter implementation that uses [`Thread.interrupt()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Thread.html#interrupt%28%29) and [`Thread.interrupted()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Thread.html#interrupted%28%29) to clear the thread state. Cite: `com/oracle/truffle/api/TruffleSafepoint.Interrupter.html#THREAD_INTERRUPT` ```java THREAD_INTERRUPT = new Interrupter() { @Override public void interrupt(Thread t) { t.interrupt(); } @Override public void interrupted() { Thread.interrupted(); } }; ``` ## Methods ### interrupt(Thread) `void interrupt(Thread thread)`. Since 21.1. Sets the interrupted state on a foreign thread. Internal locks are held while this method is invoked, therefore this method must not block or run complex or guest language code that could cause deadlocks. Parameters: `thread` `Thread`: the thread to interrupt. Cite: `com/oracle/truffle/api/TruffleSafepoint.Interrupter.html#interrupt(java.lang.Thread)` ### resetInterrupted() `void resetInterrupted()`. Since 21.1. Resets the interrupted state when executing on a thread after the thread was interrupted. If a thread was interrupted it is guaranteed to be reset at least once, but might be reset multiple times. Internal locks are held while this method is invoked, therefore this method must not block or run complex or guest language code that could cause deadlocks. Cite: `com/oracle/truffle/api/TruffleSafepoint.Interrupter.html#resetInterrupted()` # ◇ TruffleSafepoint.Interruptible [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 21.1. Nested in [`TruffleSafepoint`](com/oracle/truffle/api/TruffleSafepoint.md). ```java @FunctionalInterface public interface TruffleSafepoint.Interruptible ``` Function interface that represent interruptable Java methods. Examples are [`Lock::lockInterruptibly`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/locks/Lock.html#lockInterruptibly%28%29) or [`Semaphore::acquire`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/Semaphore.html#acquire%28%29). If used directly implies a [`boundary`](com/oracle/truffle/api/CompilerDirectives.TruffleBoundary.md). Use [`CompiledInterruptible`](com/oracle/truffle/api/TruffleSafepoint.CompiledInterruptible.md) if you need partial evaluation for this functional interface. **See also** - [`setBlocked(Node, Interrupter, Interruptible, Object, Runnable, Consumer)`](com/oracle/truffle/api/TruffleSafepoint.md#setBlocked%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.TruffleSafepoint.Interrupter,com.oracle.truffle.api.TruffleSafepoint.Interruptible,T,java.lang.Runnable,java.util.function.Consumer%29) ## Methods ### apply(T) `void apply(T arg) throws InterruptedException`. Since 21.1. Runs the interruptable method for a given object. Cite: `com/oracle/truffle/api/TruffleSafepoint.Interruptible.html#apply(T)` # ◇ TruffleSafepoint.InterruptibleFunction [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 23.1. Nested in [`TruffleSafepoint`](com/oracle/truffle/api/TruffleSafepoint.md). ```java @FunctionalInterface public interface TruffleSafepoint.InterruptibleFunction ``` Function interface that represent interruptable Java methods. Examples are [`Lock::lockInterruptibly`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/locks/Lock.html#lockInterruptibly%28%29) or [`Semaphore::acquire`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/Semaphore.html#acquire%28%29). If used directly implies a [`boundary`](com/oracle/truffle/api/CompilerDirectives.TruffleBoundary.md). Use [`CompiledInterruptibleFunction`](com/oracle/truffle/api/TruffleSafepoint.CompiledInterruptibleFunction.md) if you need partial evaluation for this functional interface. **See also** - [`TruffleSafepoint.setBlockedFunction(Node, Interrupter, InterruptibleFunction, Object, Runnable, Consumer)`](com/oracle/truffle/api/TruffleSafepoint.md#setBlockedFunction%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.TruffleSafepoint.Interrupter,com.oracle.truffle.api.TruffleSafepoint.InterruptibleFunction,T,java.lang.Runnable,java.util.function.Consumer%29) ## Methods ### apply(T) `R apply(T arg) throws InterruptedException`. Since 23.1. Runs the interruptible method for a given object. Cite: `com/oracle/truffle/api/TruffleSafepoint.InterruptibleFunction.html#apply(T)` # ⚡︎ TruffleStackTrace [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Exception in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 19.0. ```java public final class TruffleStackTrace extends Exception ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) > [`Exception`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Exception.html) > `TruffleStackTrace` Represents a guest language stack trace. A TruffleStackTrace is automatically added when a [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) passes through a [`call target`](com/oracle/truffle/api/CallTarget.md). [`ControlFlowException`](com/oracle/truffle/api/nodes/ControlFlowException.md) and [`PolyglotException`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/PolyglotException.html) do not get a TruffleStackTrace. An internal or host [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) is added a TruffleStackTrace, as long as suppression is not disabled for this throwable, via a Throwable added to the list of [suppressed exceptions](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#addSuppressed%28java.lang.Throwable%29). A guest language stack trace element is automatically added by the Truffle runtime every time the [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) passes through a [`call target`](com/oracle/truffle/api/CallTarget.md). This is incremental and therefore efficient if the exception is later caught in the same compilation unit. Note that if the Throwable is caught, its stack trace should be filled eagerly with [`fillIn(Throwable)`](com/oracle/truffle/api/TruffleStackTrace.md#fillIn%28java.lang.Throwable%29), unless it can be guaranteed to be re-thrown in the same [`call target`](com/oracle/truffle/api/CallTarget.md), or that the stack trace will not be used. See [`getStackTrace(Throwable)`](com/oracle/truffle/api/TruffleStackTrace.md#getStackTrace%28java.lang.Throwable%29) to retrieve the guest language stack trace from a [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html). ## Methods ### fillInStackTrace() `public Throwable fillInStackTrace()`. Since 19.0. Overrides `fillInStackTrace()`. Cite: `com/oracle/truffle/api/TruffleStackTrace.html#fillInStackTrace()` ### toString() `public String toString()`. Since 19.0. Overrides `toString()`. Cite: `com/oracle/truffle/api/TruffleStackTrace.html#toString()` ### getStackTrace(Throwable) `public static List getStackTrace(Throwable throwable)`. Since 19.0. Returns the guest language frames that are stored in this throwable or `null` if no guest language frames can ever be stored in this throwable. This method fills in the stacktrace by calling `fillIn(Throwable)`, so it is not necessary to call `fillIn(Throwable)` before. The returned list is not modifiable. The number of stack trace elements that are filled in can be customized by the `stackTraceElementLimit` parameter of the `AbstractTruffleException constructor`. Parameters: `throwable` `Throwable`: the [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) instance to look for guest language frames. Throws: `NullPointerException` (unchecked): if the [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) is `null`. Cite: `com/oracle/truffle/api/TruffleStackTrace.html#getStackTrace(java.lang.Throwable)` ### getAsynchronousStackTrace(CallTarget, Frame) `public static List getAsynchronousStackTrace(CallTarget target, Frame frame)`. Since 20.1.0. Returns asynchronous guest language stack frames that led to the execution of given `CallTarget` on the given `Frame`. Returns `null` if no asynchronous stack is known. Call this with a context entered only. Languages might not provide asynchronous stack frames by default for performance reasons. Instruments might need to instruct languages to provide the asynchronous stacks. Returns `List`: a list of asynchronous frames, or `null`. Cite: `com/oracle/truffle/api/TruffleStackTrace.html#getAsynchronousStackTrace(com.oracle.truffle.api.CallTarget,com.oracle.truffle.api.frame.Frame)` ### fillIn(Throwable) `public static TruffleStackTrace fillIn(Throwable throwable)`. Since 19.0. Fills in the guest language stack frames from the current frames on the stack. If the stack was already filled before then this method has no effect. The number stack trace elements that are filled in can be customized by the `stackTraceElementLimit` parameter of the `AbstractTruffleException constructor`. The implementation attaches a lightweight exception object as a suppressed exception to internal and host (but not guest) exceptions. Parameters: `throwable` `Throwable`: the [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) to fill. Throws: `NullPointerException` (unchecked): if the [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) is null. Cite: `com/oracle/truffle/api/TruffleStackTrace.html#fillIn(java.lang.Throwable)` ## Inherited members - From class [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html): [`addSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#addSuppressed%28java.lang.Throwable%29), [`getCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getCause%28%29), [`getLocalizedMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getLocalizedMessage%28%29), [`getMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getMessage%28%29), [`getStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getStackTrace%28%29), [`getSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getSuppressed%28%29), [`initCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#initCause%28java.lang.Throwable%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintStream%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintWriter%29), [`setStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#setStackTrace%28java.lang.StackTraceElement[]%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleStackTraceElement [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 0.27. ```java public final class TruffleStackTraceElement ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `TruffleStackTraceElement` Represents a guest stack trace element. ## Methods ### create(Node, RootCallTarget, Frame) `public static TruffleStackTraceElement create(Node location, RootCallTarget target, Frame frame)`. Since 20.1.0. Create a new stack trace element. Parameters: `location` `Node`: See `getLocation()`. `target` `RootCallTarget`: See `getTarget()`. `frame` `Frame`: See `getFrame()`. Cite: `com/oracle/truffle/api/TruffleStackTraceElement.html#create(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.RootCallTarget,com.oracle.truffle.api.frame.Frame)` ### create(Node, RootCallTarget, …) `public static TruffleStackTraceElement create(Node location, RootCallTarget target, Frame frame, int bytecodeIndex)`. Since 24.1. Create a new stack trace element. Parameters: `location` `Node`: See `getLocation()`. `target` `RootCallTarget`: See `getTarget()`. `frame` `Frame`: See `getFrame()`. `bytecodeIndex` `int`: See `getBytecodeIndex()`. Cite: `com/oracle/truffle/api/TruffleStackTraceElement.html#create(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.RootCallTarget,com.oracle.truffle.api.frame.Frame,int)` ### getLocation() `public Node getLocation()`. Since 0.27. Returns a node representing the callsite on the stack. Returns `null` if no detailed callsite information is available. This is the case when `CallTarget.call(Object...)` is used or for the top-of-the-stack element or if the exception is an internal exception or the `com.oracle.truffle.api.exception.AbstractTruffleException.getLocation()` returned `null`. See `FrameInstance.getCallNode()` for the relation between callsite and CallTarget. Cite: `com/oracle/truffle/api/TruffleStackTraceElement.html#getLocation()` ### getInstrumentableLocation() `public Node getInstrumentableLocation()`. Since 24.2. Returns an instrumentable call node from a frame instance. This method should be preferred over `getLocation()` by tools to find the instrumentable node associated with this stack trace element. In case of bytecode interpreters the instrumentable node needs to be resolved by the language and is not directly accessible from the `parent` chain of the regular `location`. Just like `getLocation()` this method may not directly return an instrumentable node. To find the eventual instrumentable node the `parent` chain must be searched. There is no guarantee that an instrumentable node can be found, e.g. if the language does not support instrumentation. See also: `RootNode.findInstrumentableCallNode`, `FrameInstance.getInstrumentableCallNode()`, `com.oracle.truffle.api.instrumentation.InstrumentableNode.findInstrumentableParent(Node)`. Cite: `com/oracle/truffle/api/TruffleStackTraceElement.html#getInstrumentableLocation()` ### getTarget() `public RootCallTarget getTarget()`. Since 0.27. Returns the call target on the stack. Never returns `null`. See `FrameInstance.getCallNode()` for the relation between callsite and CallTarget. Cite: `com/oracle/truffle/api/TruffleStackTraceElement.html#getTarget()` ### getFrame() `public Frame getFrame()`. Since 0.31. Returns the read-only frame. Returns `null` if the initial `RootNode` that filled in the stack trace did not request frames to be captured by overriding `RootNode.isCaptureFramesForTrace(Node)`. Bytecode DSL note: This method should **not** be used with Bytecode DSL interpreters. See `com.oracle.truffle.api.bytecode.GenerateBytecode.captureFramesForTrace` and `com.oracle.truffle.api.bytecode.BytecodeFrame` for more information. Cite: `com/oracle/truffle/api/TruffleStackTraceElement.html#getFrame()` ### hasBytecodeIndex() `public boolean hasBytecodeIndex()`. Since 24.1. Returns `true` if the stack trace element contains a valid bytecode index, else `false`. If this method returns `false` then `getBytecodeIndex()` will return a negative `int` value. Cite: `com/oracle/truffle/api/TruffleStackTraceElement.html#hasBytecodeIndex()` ### getBytecodeIndex() `public int getBytecodeIndex()`. Since 24.1. Returns the bytecode index at the time when this frame was created. If no bytecode index was captured then a negative `int` value is returned. When the stack trace element is captured `RootNode.findBytecodeIndex` is invoked to resolve the byte code index returned by this method. See also: `RootNode.findBytecodeIndex`. Cite: `com/oracle/truffle/api/TruffleStackTraceElement.html#getBytecodeIndex()` ### getGuestObject() `public Object getGuestObject()`. Since 20.3. Returns an interop object representing this TruffleStackTraceElement supporting the `hasExecutableName` and potentially `hasDeclaringMetaObject` and `hasSourceLocation` messages. This method must only be called on an interpreter thread with a valid `entered`. The current entered context can be accessed through the language or instrument environment. Cite: `com/oracle/truffle/api/TruffleStackTraceElement.html#getGuestObject()` ### toString() `public String toString()`. Since 24.0. Overrides `toString()`. Cite: `com/oracle/truffle/api/TruffleStackTraceElement.html#toString()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleThreadBuilder [truffle-api](index.md) › [com.oracle.truffle.api](com/oracle/truffle/api/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api`](com/oracle/truffle/api/index.md). Since 23.0. ```java public final class TruffleThreadBuilder ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `TruffleThreadBuilder` A builder for threads that have access to the appropriate [`TruffleContext`](com/oracle/truffle/api/TruffleContext.md). The context is either the one that corresponds to the [`language environment`](com/oracle/truffle/api/TruffleLanguage.Env.md) that was used to [`create`](com/oracle/truffle/api/TruffleLanguage.Env.md#newTruffleThreadBuilder%28java.lang.Runnable%29) the builder, or the one specified by [`TruffleThreadBuilder.context(TruffleContext)`](com/oracle/truffle/api/TruffleThreadBuilder.md#context%28com.oracle.truffle.api.TruffleContext%29). The method [`TruffleLanguage.Env.newTruffleThreadBuilder(Runnable)`](com/oracle/truffle/api/TruffleLanguage.Env.md#newTruffleThreadBuilder%28java.lang.Runnable%29) is the only way to create the builder. Threads without an associated context should be created by [`TruffleLanguage.Env.createSystemThread(Runnable)`](com/oracle/truffle/api/TruffleLanguage.Env.md#createSystemThread%28java.lang.Runnable%29). ## Methods ### context(TruffleContext) `public TruffleThreadBuilder context(TruffleContext innerContext)`. Since 23.1. Specifies `TruffleContext` for the threads created by the builder. It has to be an inner context created by `TruffleLanguage.Env.newInnerContextBuilder(String...)`.`build()`. If not specified, the context associated with the language environment that created this builder is used (`TruffleLanguage.Env.getContext()`). Threads without an associated context should be created by `TruffleLanguage.Env.createSystemThread(Runnable)`. Parameters: `innerContext` `TruffleContext`: `TruffleContext` for the threads created by this builder. Cite: `com/oracle/truffle/api/TruffleThreadBuilder.html#context(com.oracle.truffle.api.TruffleContext)` ### threadGroup(ThreadGroup) `public TruffleThreadBuilder threadGroup(ThreadGroup g)`. Since 23.1. Specifies thread group for the threads created by this builder. Parameters: `g` `ThreadGroup`: thread group for the threads created by this builder. Cite: `com/oracle/truffle/api/TruffleThreadBuilder.html#threadGroup(java.lang.ThreadGroup)` ### stackSize(long) `public TruffleThreadBuilder stackSize(long size)`. Since 23.1. Specifies stack size for the threads created by this builder. The default is 0 which means that the parameter is ignored. Parameters: `size` `long`: stack size for the threads created by this builder. Cite: `com/oracle/truffle/api/TruffleThreadBuilder.html#stackSize(long)` ### beforeEnter(Runnable) `public TruffleThreadBuilder beforeEnter(Runnable r)`. Since 23.1. Specifies before enter notification for the threads created by this builder. The notification runnable is invoked on the thread when the threads starts before the context is entered on the thread. The default value for the notification runnable is `null` which means that no notification is executed. If the notification runnable throws an exception, it is propagated up and can be handled by an [`uncaught exception handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Thread.html#setUncaughtExceptionHandler%28java.lang.Thread.UncaughtExceptionHandler%29). Parameters: `r` `Runnable`: before enter notification runnable for the threads created by this builder. Cite: `com/oracle/truffle/api/TruffleThreadBuilder.html#beforeEnter(java.lang.Runnable)` ### afterLeave(Runnable) `public TruffleThreadBuilder afterLeave(Runnable r)`. Since 23.1. Specifies after leave notification for the threads created by this builder. The notification runnable is invoked on the thread after the thread leaves the context for the last time, i.e. the thread is about to finish. The default value for the notification runnable is `null` which means that no notification is executed. If the notification runnable throws an exception, it is propagated up and can be handled by an [`uncaught exception handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Thread.html#setUncaughtExceptionHandler%28java.lang.Thread.UncaughtExceptionHandler%29). Parameters: `r` `Runnable`: after leave notification runnable for the threads created by this builder. Cite: `com/oracle/truffle/api/TruffleThreadBuilder.html#afterLeave(java.lang.Runnable)` ### virtual(boolean) `public TruffleThreadBuilder virtual(boolean v)`. Since 24.1. Specifies whether to create a virtual thread (Thread#ofVirtual()) or a regular platform thread (the default) for the threads created by this builder. Parameters: `v` `boolean`: whether to create a virtual thread. Cite: `com/oracle/truffle/api/TruffleThreadBuilder.html#virtual(boolean)` ### build() `public Thread build()`. Since 23.1. Creates a new thread based on the parameters specified by this builder. The thread is `initialized` when it is [`started`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Thread.html#start%28%29), and `finalized` and `disposed` when it finishes its execution. It is recommended to set an [`uncaught exception handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Thread.html#setUncaughtExceptionHandler%28java.lang.Thread.UncaughtExceptionHandler%29) for the created thread. For example the thread can throw an uncaught exception if one of the initialized language contexts don't support execution on this thread. The language that created and started the thread is responsible to stop and join it during the `finalizeContext`, otherwise an internal error is thrown. It's not safe to use the [`ExecutorService.awaitTermination(long, java.util.concurrent.TimeUnit)`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/ExecutorService.html#awaitTermination%28long,java.util.concurrent.TimeUnit%29) to detect Thread termination as the polyglot thread may be cancelled before executing the executor worker. A typical implementation looks like: `TruffleLanguageSnippets.AsyncThreadLanguage.finalizeContext`. Cite: `com/oracle/truffle/api/TruffleThreadBuilder.html#build()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ▣ com.oracle.truffle.api.bytecode [truffle-api](index.md) · Every page: [llms.txt](llms.txt) Package in truffle-api. Since 24.2. The Bytecode DSL is a DSL and runtime support component of Truffle that makes it easier to implement bytecode interpreters. Start [`here`](com/oracle/truffle/api/bytecode/GenerateBytecode.md). ## Interfaces - [`BytecodeParser`](com/oracle/truffle/api/bytecode/BytecodeParser.md): Functional interface containing a method to parse one or more nodes using a BytecodeBuilder. - [`BytecodeRootNode`](com/oracle/truffle/api/bytecode/BytecodeRootNode.md): Base interface to be implemented by the bytecode root node of a Bytecode DSL interpreter. - [`InstructionTracer`](com/oracle/truffle/api/bytecode/InstructionTracer.md): A low-overhead callback interface to observe instruction execution in Bytecode DSL interpreters. - [`TagTree`](com/oracle/truffle/api/bytecode/TagTree.md): Logical tree representation of the Tag operations of a bytecode program. ## Classes - [`BytecodeBuilder`](com/oracle/truffle/api/bytecode/BytecodeBuilder.md): Parent class for a bytecode builder generated by the Bytecode DSL. - [`BytecodeConfig`](com/oracle/truffle/api/bytecode/BytecodeConfig.md): The configuration to use while generating bytecode. - [`BytecodeConfigEncoder`](com/oracle/truffle/api/bytecode/BytecodeConfigEncoder.md): Abstract class implemented by generated code to encode BytecodeConfig data. - [`BytecodeDSLAccess`](com/oracle/truffle/api/bytecode/BytecodeDSLAccess.md): Accessor class used by generated code for low-level access to frames, bytecode arrays, and other bytecode classes. - [`BytecodeDescriptor`](com/oracle/truffle/api/bytecode/BytecodeDescriptor.md): Describes the bytecode interpreter generated for a specific BytecodeRootNode class and provides the management API for that interpreter. - [`BytecodeFrame`](com/oracle/truffle/api/bytecode/BytecodeFrame.md): Represents a captured Bytecode DSL frame, including the location metadata needed to access the data in the frame. - [`BytecodeLabel`](com/oracle/truffle/api/bytecode/BytecodeLabel.md): Abstract definition of a label. - [`BytecodeLocal`](com/oracle/truffle/api/bytecode/BytecodeLocal.md): Abstract definition of a local variable in the interpreter. - [`BytecodeLocation`](com/oracle/truffle/api/bytecode/BytecodeLocation.md): A materialized bytecode location. - [`BytecodeNode`](com/oracle/truffle/api/bytecode/BytecodeNode.md): Represents the current bytecode for a Bytecode DSL root node. - [`BytecodeRootNodes`](com/oracle/truffle/api/bytecode/BytecodeRootNodes.md): A BytecodeRootNodes instance encapsulates one or more bytecode root nodes produced from a single parse. - [`BytecodeSupport`](com/oracle/truffle/api/bytecode/BytecodeSupport.md): Contains code to support Bytecode DSL interpreters. - [`BytecodeTransition`](com/oracle/truffle/api/bytecode/BytecodeTransition.md): Encapsulates information about a transition of the bytecode interpreter from one bytecode node to another. - [`ContinuationResult`](com/oracle/truffle/api/bytecode/ContinuationResult.md): Representation of a continuation closure, consisting of a resumable RootNode, the interpreter state, and a yielded result. - [`ContinuationRootNode`](com/oracle/truffle/api/bytecode/ContinuationRootNode.md): Abstract class representing the root node for a continuation. - [`ExceptionHandler`](com/oracle/truffle/api/bytecode/ExceptionHandler.md): Introspection class modeling the meta-information of an exception handler in a bytecode interpreter. - [`Instruction`](com/oracle/truffle/api/bytecode/Instruction.md): Represents metadata for an instruction in a bytecode node. - [`InstructionDescriptor`](com/oracle/truffle/api/bytecode/InstructionDescriptor.md): Descriptor for a concrete bytecode instruction. - [`LocalAccessor`](com/oracle/truffle/api/bytecode/LocalAccessor.md): Operation parameter that allows an operation to get, set, and clear the value of a local. - [`LocalRangeAccessor`](com/oracle/truffle/api/bytecode/LocalRangeAccessor.md): Operation parameter that allows an operation to get, set, or clear locals declared in a contiguous range. - [`LocalVariable`](com/oracle/truffle/api/bytecode/LocalVariable.md): Introspection class modeling a local variable and its liveness info in a bytecode interpreter. - [`MaterializedLocalAccessor`](com/oracle/truffle/api/bytecode/MaterializedLocalAccessor.md): Operation parameter that allows an operation to get, set, and clear the value of a local from a materialized frame of the current root node or an outer root node. - [`SourceInformation`](com/oracle/truffle/api/bytecode/SourceInformation.md): Introspection class modeling source section information for a range of bytecodes. - [`SourceInformationTree`](com/oracle/truffle/api/bytecode/SourceInformationTree.md): Introspection class modeling a tree of SourceInformation instances. - [`StackValue`](com/oracle/truffle/api/bytecode/StackValue.md): Abstract definition of a stack value in the interpreter. - [`TagTreeNode`](com/oracle/truffle/api/bytecode/TagTreeNode.md): Class that implements tag tree NodeLibrary dispatch for tag tree items. - [`TagTreeNodeGen`](com/oracle/truffle/api/bytecode/TagTreeNodeGen.md): No description. ## Enums - [`BytecodeIndexMode`](com/oracle/truffle/api/bytecode/BytecodeIndexMode.md): Configures how a generated bytecode interpreter makes its current bytecode index available for stack walking and frame introspection. - [`BytecodeTier`](com/oracle/truffle/api/bytecode/BytecodeTier.md): Represents the tier of a given BytecodeNode. - [`BytecodeVersion`](com/oracle/truffle/api/bytecode/BytecodeVersion.md): Bytecode DSL behaviour versions selectable through GenerateBytecode.version(). ## Exceptions - [`BytecodeEncodingException`](com/oracle/truffle/api/bytecode/BytecodeEncodingException.md): Class representing an exception thrown by a BytecodeBuilder when the program cannot be encoded, for example, when the bytecode exceeds the maximum addressable bytecode size. ## Annotations - [`ConstantOperand`](com/oracle/truffle/api/bytecode/ConstantOperand.md): Defines a constant operand for an operation. - [`EpilogExceptional`](com/oracle/truffle/api/bytecode/EpilogExceptional.md): Defines an exceptional epilog operation. - [`EpilogReturn`](com/oracle/truffle/api/bytecode/EpilogReturn.md): Defines a return epilog operation. - [`ForceQuickening`](com/oracle/truffle/api/bytecode/ForceQuickening.md): Forces quickening for an Operation specialization. - [`GenerateBytecode`](com/oracle/truffle/api/bytecode/GenerateBytecode.md): Generates a bytecode interpreter using the Bytecode DSL. - [`GenerateBytecodeTestVariants`](com/oracle/truffle/api/bytecode/GenerateBytecodeTestVariants.md): This annotation should only be used for testing to generate multiple variants of the interpreter with slightly different configurations. - [`Instrumentation`](com/oracle/truffle/api/bytecode/Instrumentation.md): Instrumentations are operations that can be dynamically enabled at runtime. - [`Operation`](com/oracle/truffle/api/bytecode/Operation.md): Declares an operation. - [`OperationProxy`](com/oracle/truffle/api/bytecode/OperationProxy.md): Defines an operation using an existing com.oracle.truffle.api.nodes.Node. - [`Prolog`](com/oracle/truffle/api/bytecode/Prolog.md): Defines a prolog operation that executes before the body of a Root operation. - [`Return`](com/oracle/truffle/api/bytecode/Return.md): Declares a custom return operation. - [`ShortCircuitOperation`](com/oracle/truffle/api/bytecode/ShortCircuitOperation.md): Declares a short-circuiting operation. - [`StoreBytecodeIndex`](com/oracle/truffle/api/bytecode/StoreBytecodeIndex.md): Stores the BCI in the frame before an annotated Specialization or Fallback executes. - [`Variadic`](com/oracle/truffle/api/bytecode/Variadic.md): Annotation indicating a parameter that takes zero or more values. - [`Yield`](com/oracle/truffle/api/bytecode/Yield.md): Declares a custom yield operation. # ◆ BytecodeBuilder [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java public abstract class BytecodeBuilder ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `BytecodeBuilder` Parent class for a bytecode builder generated by the Bytecode DSL. A parser uses a [`BytecodeBuilder`](com/oracle/truffle/api/bytecode/BytecodeBuilder.md) instance to generate and validate bytecode for each root node. Since each [`BytecodeRootNode`](com/oracle/truffle/api/bytecode/BytecodeRootNode.md) defines its own set of operations, each [`BytecodeBuilder`](com/oracle/truffle/api/bytecode/BytecodeBuilder.md) has its own set of builder methods. Thus, this class is an opaque definition with no declared methods. Parser code should reference the builder class directly (e.g., `MyBytecodeRootNodeGen.Builder`). **See also** - [Bytecode DSL user guide](https://github.com/oracle/graal/blob/master/truffle/docs/bytecode_dsl/UserGuide.md) ## Constructors ### BytecodeBuilder(Object) `protected BytecodeBuilder(Object token)`. Since 24.2. Internal constructor for generated code. Do not use. Cite: `com/oracle/truffle/api/bytecode/BytecodeBuilder.html#(java.lang.Object)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ BytecodeConfig [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java public final class BytecodeConfig ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `BytecodeConfig` The configuration to use while generating bytecode. The configuration determines what optional information (source sections, instrumentation instructions, etc.) should be materialized during parsing. The interpreter memory footprint can be improved by omitting this information by default and lazily re-parsing it when it is needed. Instances of this class should be stored as static final constants. It is important for them to be constant so partial evaluation can detect when reparsing is unnecessary. Use [`matches(BytecodeConfig)`](com/oracle/truffle/api/bytecode/BytecodeConfig.md#matches%28com.oracle.truffle.api.bytecode.BytecodeConfig%29) to compare configurations. Do not use [`equals(Object)`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), which compares object identity. ## Nested types - [`BytecodeConfig.Builder`](com/oracle/truffle/api/bytecode/BytecodeConfig.Builder.md) (class): Builder to generate a BytecodeConfig programmatically. ## Fields ### DEFAULT `public static final BytecodeConfig DEFAULT`. Since 24.2. Do not materialize any source or instrumentation information. Cite: `com/oracle/truffle/api/bytecode/BytecodeConfig.html#DEFAULT` ### WITH_SOURCE `public static final BytecodeConfig WITH_SOURCE`. Since 24.2. Materialize source information. Cite: `com/oracle/truffle/api/bytecode/BytecodeConfig.html#WITH_SOURCE` ### WITH_SOURCE_CONTENT `public static final BytecodeConfig WITH_SOURCE_CONTENT`. Since 25.1. Materialize source information and load content. If the interpreter does not declare a `source content supplier`, this config is equivalent to `WITH_SOURCE`. Cite: `com/oracle/truffle/api/bytecode/BytecodeConfig.html#WITH_SOURCE_CONTENT` ### COMPLETE `public static final BytecodeConfig COMPLETE`. Since 24.2. Materialize all information. Cite: `com/oracle/truffle/api/bytecode/BytecodeConfig.html#COMPLETE` ## Methods ### newBuilder(BytecodeConfigEncoder) `public static BytecodeConfig.Builder newBuilder(BytecodeConfigEncoder encoder)`. Since 24.2. Produces a new `Builder` that can be used to programmatically build a `BytecodeConfig`. Note this method is not intended to be used directly. Use the generated method, for example `MyBytecodeRootNodeGen.newConfigBuilder()` instead. Cite: `com/oracle/truffle/api/bytecode/BytecodeConfig.html#newBuilder(com.oracle.truffle.api.bytecode.BytecodeConfigEncoder)` ### matches(BytecodeConfig) `public boolean matches(BytecodeConfig other)`. Since 25.7. Returns whether this configuration matches `other`. This method allows configs built for a particular interpreter to be compared with the generic singleton configurations declared in this class. For example, {MyRootNodeGen.newConfigBuilder().addSource().build()} matches the `WITH_SOURCE` singleton. Configurations built by different interpreters never match, even if they logically describe the same metadata. Use this method instead of [`equals(Object)`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29) to compare configurations. Matching is symmetric but not transitive: a generic configuration can match configurations from two different interpreters that do not match each other. Cite: `com/oracle/truffle/api/bytecode/BytecodeConfig.html#matches(com.oracle.truffle.api.bytecode.BytecodeConfig)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ BytecodeConfig.Builder [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. Nested in [`BytecodeConfig`](com/oracle/truffle/api/bytecode/BytecodeConfig.md). ```java public static final class BytecodeConfig.Builder ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Builder` Builder to generate a [`BytecodeConfig`](com/oracle/truffle/api/bytecode/BytecodeConfig.md) programmatically. ## Methods ### addSource() `public BytecodeConfig.Builder addSource()`. Since 24.2. Sets whether to materialize sources. Cite: `com/oracle/truffle/api/bytecode/BytecodeConfig.Builder.html#addSource()` ### addSourceContent() `public BytecodeConfig.Builder addSourceContent()`. Since 25.1. Sets whether to `materialize sources` and their content. This method has no effect unless a `source content supplier` is provided. Cite: `com/oracle/truffle/api/bytecode/BytecodeConfig.Builder.html#addSourceContent()` ### addTag(Class) `public BytecodeConfig.Builder addTag(Class tag)`. Since 24.2. Sets a specific set of tags to be materialized. Cite: `com/oracle/truffle/api/bytecode/BytecodeConfig.Builder.html#addTag(java.lang.Class)` ### addInstrumentation(Class) `public BytecodeConfig.Builder addInstrumentation(Class instrumentation)`. Since 24.2. Sets a specific set of instrumentations to be materialized. Cite: `com/oracle/truffle/api/bytecode/BytecodeConfig.Builder.html#addInstrumentation(java.lang.Class)` ### build() `public BytecodeConfig build()`. Since 24.2. Builds the config. Cite: `com/oracle/truffle/api/bytecode/BytecodeConfig.Builder.html#build()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ BytecodeConfigEncoder [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java public abstract class BytecodeConfigEncoder ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `BytecodeConfigEncoder` Abstract class implemented by generated code to encode [`BytecodeConfig`](com/oracle/truffle/api/bytecode/BytecodeConfig.md) data. Do not use directly. ## Constructors ### BytecodeConfigEncoder(Object) `protected BytecodeConfigEncoder(Object token)`. Cite: `com/oracle/truffle/api/bytecode/BytecodeConfigEncoder.html#(java.lang.Object)` ## Methods ### encodeInstrumentation(Class) `protected abstract long encodeInstrumentation(Class instrumentations) throws IllegalArgumentException`. Cite: `com/oracle/truffle/api/bytecode/BytecodeConfigEncoder.html#encodeInstrumentation(java.lang.Class)` ### encodeTag(Class) `protected abstract long encodeTag(Class tag) throws IllegalArgumentException`. Cite: `com/oracle/truffle/api/bytecode/BytecodeConfigEncoder.html#encodeTag(java.lang.Class)` ### getEncoding(BytecodeConfig) `protected static long getEncoding(BytecodeConfig config)`. Cite: `com/oracle/truffle/api/bytecode/BytecodeConfigEncoder.html#getEncoding(com.oracle.truffle.api.bytecode.BytecodeConfig)` ### getEncoder(BytecodeConfig) `protected static BytecodeConfigEncoder getEncoder(BytecodeConfig config)`. Cite: `com/oracle/truffle/api/bytecode/BytecodeConfigEncoder.html#getEncoder(com.oracle.truffle.api.bytecode.BytecodeConfig)` ### normalizeEncoding(long) `protected long normalizeEncoding(long encoding)`. Since 25.7. Normalizes configuration bits for this interpreter. The default implementation leaves the encoding unchanged. Cite: `com/oracle/truffle/api/bytecode/BytecodeConfigEncoder.html#normalizeEncoding(long)` ### decode(BytecodeConfigEncoder, long) `protected static BytecodeConfig decode(BytecodeConfigEncoder encoder, long encoding)`. Since 25.7. Decodes a configuration from its encoding. Cite: `com/oracle/truffle/api/bytecode/BytecodeConfigEncoder.html#decode(com.oracle.truffle.api.bytecode.BytecodeConfigEncoder,long)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ BytecodeDSLAccess [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Sealed abstract class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java public abstract sealed class BytecodeDSLAccess permits BytecodeDSLCheckedAccess, BytecodeDSLUncheckedAccess ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `BytecodeDSLAccess` Permitted subtypes: `BytecodeDSLCheckedAccess`, `BytecodeDSLUncheckedAccess` Accessor class used by generated code for low-level access to frames, bytecode arrays, and other bytecode classes. Do not use directly. ## Methods ### lookup(Object, boolean) `public static final BytecodeDSLAccess lookup(Object token, boolean allowUnsafe)`. Since 24.2. Obtains an accessor. Used by generated code; do not use directly. Cite: `com/oracle/truffle/api/bytecode/BytecodeDSLAccess.html#lookup(java.lang.Object,boolean)` ### getByteArraySupport() `public abstract ByteArraySupport getByteArraySupport()`. Since 24.2. Returns a `ByteArraySupport` to use for byte array accesses. Cite: `com/oracle/truffle/api/bytecode/BytecodeDSLAccess.html#getByteArraySupport()` ### getFrameExtensions() `public abstract FrameExtensions getFrameExtensions()`. Since 24.2. Returns a `FrameExtensions` to use for frame accesses. Cite: `com/oracle/truffle/api/bytecode/BytecodeDSLAccess.html#getFrameExtensions()` ### readInt(int[], int) `public abstract int readInt(int[] arr, int index)`. Since 24.2. Reads from an int array. Cite: `com/oracle/truffle/api/bytecode/BytecodeDSLAccess.html#readInt(int[],int)` ### writeInt(int[], int, int) `public abstract void writeInt(int[] arr, int index, int value)`. Since 24.2. Writes to an int array. Cite: `com/oracle/truffle/api/bytecode/BytecodeDSLAccess.html#writeInt(int[],int,int)` ### readObject(T[], int) `public abstract T readObject(T[] arr, int index)`. Since 24.2. Reads from an Object array. Cite: `com/oracle/truffle/api/bytecode/BytecodeDSLAccess.html#readObject(T[],int)` ### writeObject(T[], int, T) `public abstract void writeObject(T[] arr, int index, T value)`. Since 24.2. Writes to an Object array. Cite: `com/oracle/truffle/api/bytecode/BytecodeDSLAccess.html#writeObject(T[],int,T)` ### uncheckedCast(Object, Class) `public abstract T uncheckedCast(Object arr, Class clazz)`. Since 24.2. Casts a value to the given class. Also assumes non-null. If used in the form uncheckedCast(this.field, ...) and the field is a final field, then the field will get transformed into an immutable field read. Cite: `com/oracle/truffle/api/bytecode/BytecodeDSLAccess.html#uncheckedCast(java.lang.Object,java.lang.Class)` ### getSerializationKey(Object) `public final Object getSerializationKey(Object object)`. Since 25.6. Returns a key for deduplicating serialized constants. [`Float`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Float.html) and [`Double`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Double.html) `NaN` values are replaced with wrappers that preserve NaN bit patterns. Cite: `com/oracle/truffle/api/bytecode/BytecodeDSLAccess.html#getSerializationKey(java.lang.Object)` ### getLocalOffset(LocalAccessor) `public final int getLocalOffset(LocalAccessor accessor)`. Since 25.7. Returns the local offset of a local accessor. Cite: `com/oracle/truffle/api/bytecode/BytecodeDSLAccess.html#getLocalOffset(com.oracle.truffle.api.bytecode.LocalAccessor)` ### getLocalOffset(MaterializedLocalAccessor) `public final int getLocalOffset(MaterializedLocalAccessor accessor)`. Since 25.7. Returns the local offset of a materialized local accessor. Cite: `com/oracle/truffle/api/bytecode/BytecodeDSLAccess.html#getLocalOffset(com.oracle.truffle.api.bytecode.MaterializedLocalAccessor)` ### getLocalIndex(LocalAccessor) `public final int getLocalIndex(LocalAccessor accessor)`. Since 25.7. Returns the local index of a local accessor. Cite: `com/oracle/truffle/api/bytecode/BytecodeDSLAccess.html#getLocalIndex(com.oracle.truffle.api.bytecode.LocalAccessor)` ### getLocalIndex(MaterializedLocalAccessor) `public final int getLocalIndex(MaterializedLocalAccessor accessor)`. Since 25.7. Returns the local index of a materialized local accessor. Cite: `com/oracle/truffle/api/bytecode/BytecodeDSLAccess.html#getLocalIndex(com.oracle.truffle.api.bytecode.MaterializedLocalAccessor)` ### getStartOffset(LocalRangeAccessor) `public final int getStartOffset(LocalRangeAccessor accessor)`. Since 25.7. Returns the starting local offset of a local range accessor. Cite: `com/oracle/truffle/api/bytecode/BytecodeDSLAccess.html#getStartOffset(com.oracle.truffle.api.bytecode.LocalRangeAccessor)` ### getStartIndex(LocalRangeAccessor) `public final int getStartIndex(LocalRangeAccessor accessor)`. Since 25.7. Returns the starting local index of a local range accessor. Cite: `com/oracle/truffle/api/bytecode/BytecodeDSLAccess.html#getStartIndex(com.oracle.truffle.api.bytecode.LocalRangeAccessor)` ### getRootIndex(MaterializedLocalAccessor) `public final int getRootIndex(MaterializedLocalAccessor accessor)`. Since 25.7. Returns the index of the root declaring the local of a materialized local accessor. Cite: `com/oracle/truffle/api/bytecode/BytecodeDSLAccess.html#getRootIndex(com.oracle.truffle.api.bytecode.MaterializedLocalAccessor)` ### getLocalAccessorConstant(int, int) `public final LocalAccessor getLocalAccessorConstant(int offset, int index)`. Since 25.7. Obtains a `LocalAccessor` from its local offset and index. Cite: `com/oracle/truffle/api/bytecode/BytecodeDSLAccess.html#getLocalAccessorConstant(int,int)` ### getLocalRangeAccessorConstant(int, int, int) `public final LocalRangeAccessor getLocalRangeAccessorConstant(int startOffset, int startIndex, int length)`. Since 25.7. Obtains a `LocalRangeAccessor` from its starting local offset, index, and length. Cite: `com/oracle/truffle/api/bytecode/BytecodeDSLAccess.html#getLocalRangeAccessorConstant(int,int,int)` ### getMaterializedLocalAccessorConstant(int, int, int) `public final MaterializedLocalAccessor getMaterializedLocalAccessorConstant(int rootIndex, int offset, int index)`. Since 25.7. Obtains a `MaterializedLocalAccessor` from its root index, local offset, and local index. Cite: `com/oracle/truffle/api/bytecode/BytecodeDSLAccess.html#getMaterializedLocalAccessorConstant(int,int,int)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ BytecodeDescriptor [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 25.1. ```java public abstract class BytecodeDescriptor, B extends BytecodeBuilder> ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `BytecodeDescriptor` Describes the bytecode interpreter generated for a specific [`BytecodeRootNode`](com/oracle/truffle/api/bytecode/BytecodeRootNode.md) class and provides the management API for that interpreter. A generated bytecode interpreter exposes a public static `BYTECODE` field of the generated `*Gen.Bytecode` class. It is recommended to not refer to the [`BytecodeDescriptor`](com/oracle/truffle/api/bytecode/BytecodeDescriptor.md) directly and instead use the generated `*Gen.Bytecode` class to avoid the rather verbose generic type. That field is a concrete subclass of [`BytecodeDescriptor`](com/oracle/truffle/api/bytecode/BytecodeDescriptor.md), and acts as the central entry point for: - **Creating executable bytecode:** [`create(TruffleLanguage, BytecodeConfig, BytecodeParser)`](com/oracle/truffle/api/bytecode/BytecodeDescriptor.md#create%28L,com.oracle.truffle.api.bytecode.BytecodeConfig,com.oracle.truffle.api.bytecode.BytecodeParser%29) builds one or more [`BytecodeRootNode`](com/oracle/truffle/api/bytecode/BytecodeRootNode.md) instances by driving a [`BytecodeBuilder`](com/oracle/truffle/api/bytecode/BytecodeBuilder.md). - **Serialization support:** [`serializeBuilderBytecode`](com/oracle/truffle/api/bytecode/BytecodeDescriptor.md#serializeBuilderBytecode%28java.io.DataOutput,com.oracle.truffle.api.bytecode.serialization.BytecodeSerializer,com.oracle.truffle.api.bytecode.BytecodeParser%29), [`serializeExecutionBytecode`](com/oracle/truffle/api/bytecode/BytecodeDescriptor.md#serializeExecutionBytecode%28L,java.io.DataOutput,com.oracle.truffle.api.bytecode.BytecodeConfig,com.oracle.truffle.api.bytecode.serialization.BytecodeSerializer,com.oracle.truffle.api.bytecode.BytecodeParser%29), [`deserializeBuilderBytecode`](com/oracle/truffle/api/bytecode/BytecodeDescriptor.md#deserializeBuilderBytecode%28L,com.oracle.truffle.api.bytecode.BytecodeConfig,java.util.function.Supplier,com.oracle.truffle.api.bytecode.serialization.BytecodeDeserializer%29), and [`deserializeExecutionBytecode`](com/oracle/truffle/api/bytecode/BytecodeDescriptor.md#deserializeExecutionBytecode%28L,com.oracle.truffle.api.bytecode.BytecodeConfig,java.util.function.Supplier,java.util.function.Function,com.oracle.truffle.api.bytecode.serialization.BytecodeDeserializer%29) define the contract for turning parsed bytecode into a byte stream and restoring it. Generated interpreters that were built with `enableSerialization=true` implement these methods. The default implementation throws [`UnsupportedOperationException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/UnsupportedOperationException.html). - **Describing the instruction set:** [`getInstructionDescriptors()`](com/oracle/truffle/api/bytecode/BytecodeDescriptor.md#getInstructionDescriptors%28%29) and [`getInstructionDescriptor(int)`](com/oracle/truffle/api/bytecode/BytecodeDescriptor.md#getInstructionDescriptor%28int%29) expose all instructions, including normal language operations and injected instrumentation instructions. The descriptor can also produce a human readable dump via [`dump()`](com/oracle/truffle/api/bytecode/BytecodeDescriptor.md#dump%28%29). - **Per-language runtime configuration:** [`update(TruffleLanguage, BytecodeConfig)`](com/oracle/truffle/api/bytecode/BytecodeDescriptor.md#update%28L,com.oracle.truffle.api.bytecode.BytecodeConfig%29) applies configuration (for example enabling instrumentations) to all bytecode roots that were already created for the given language, and to any future roots. - **Instruction tracing:** [`addInstructionTracer(TruffleLanguage, InstructionTracer)`](com/oracle/truffle/api/bytecode/BytecodeDescriptor.md#addInstructionTracer%28L,com.oracle.truffle.api.bytecode.InstructionTracer%29) and [`removeInstructionTracer(TruffleLanguage, InstructionTracer)`](com/oracle/truffle/api/bytecode/BytecodeDescriptor.md#removeInstructionTracer%28L,com.oracle.truffle.api.bytecode.InstructionTracer%29) install and remove [`InstructionTracer`](com/oracle/truffle/api/bytecode/InstructionTracer.md)s for all roots created for a given language. After a tracer is installed, the interpreter automatically injects tracing instructions (for example `trace.instruction`) and invokes the tracer callback on every executed instruction. The descriptor also exposes metadata about the interpreter itself: [`getGeneratedClass()`](com/oracle/truffle/api/bytecode/BytecodeDescriptor.md#getGeneratedClass%28%29) returns the generated root node class that implements execution, and [`getSpecificationClass()`](com/oracle/truffle/api/bytecode/BytecodeDescriptor.md#getSpecificationClass%28%29) identifies the original user-declared `@GenerateBytecode` root node (when available). [`getLanguageClass()`](com/oracle/truffle/api/bytecode/BytecodeDescriptor.md#getLanguageClass%28%29) identifies the owning [`TruffleLanguage`](com/oracle/truffle/api/TruffleLanguage.md). In short, `BytecodeDescriptor` is both: *(1)* a static description of the generated bytecode interpreter (instruction set, generated classes, language binding), and *(2)* the runtime control surface for all bytecode roots created from that interpreter in a given language context (creation, tracing, instrumentation, serialization). ## Usage example ```java // Assume you have a language MyLanguage and a bytecode root node // declared as: // // @GenerateBytecode(languageClass = MyLanguage.class) // abstract class MyBytecodeRootNode extends RootNode implements BytecodeRootNode { ... } // // The annotation processor generates MyBytecodeRootNodeGen and a nested // MyBytecodeRootNodeGen.Bytecode class with a public static BYTECODE field: // // public static final MyBytecodeRootNodeGen.Bytecode BYTECODE; // // The BYTECODE field is a concrete BytecodeDescriptor. MyLanguage language = ...; // instance of the Truffle language // Create a new bytecode root node by emitting bytecode through the builder. // The parser lambda drives the builder to generate the bytecode body. MyBytecodeRootNode root = MyBytecodeRootNodeGen.BYTECODE .create(language, BytecodeConfig.DEFAULT, (builder) -> { builder.beginRoot(); builder.beginReturn(); builder.emitLoadArgument(0); // return the first argument builder.endReturn(); builder.endRoot(); }) .getNode(0); // obtain the first created root node // Execute the generated root node through its call target. Object result = root.getCallTarget().call(42); ``` **Type parameters** - ``: the [`specification class`](com/oracle/truffle/api/bytecode/BytecodeDescriptor.md#getSpecificationClass%28%29), which is both a [`RootNode`](com/oracle/truffle/api/nodes/RootNode.md) and a [`BytecodeRootNode`](com/oracle/truffle/api/bytecode/BytecodeRootNode.md) - ``: the Truffle language type - ``: the builder type used to emit bytecode for this interpreter ## Constructors ### BytecodeDescriptor(Object) `protected BytecodeDescriptor(Object token)`. Cite: `com/oracle/truffle/api/bytecode/BytecodeDescriptor.html#(java.lang.Object)` ## Methods ### getSpecificationClass() `public abstract Class getSpecificationClass()`. Since 25.1. Returns the specification class for this descriptor. This is the user defined `RootNode` subclass that was annotated to generate this bytecode interpreter. Returns `Class`: the specification class, never `null`. Cite: `com/oracle/truffle/api/bytecode/BytecodeDescriptor.html#getSpecificationClass()` ### getGeneratedClass() `public abstract Class getGeneratedClass()`. Since 25.1. Returns the generated root node class that implements the bytecode interpreter. This is the concrete `RootNode` subclass created by the bytecode generator. Returns `Class`: the generated root node class, never `null`. Cite: `com/oracle/truffle/api/bytecode/BytecodeDescriptor.html#getGeneratedClass()` ### getLanguageClass() `public abstract Class getLanguageClass()`. Since 25.1. Returns the `TruffleLanguage` class that this descriptor is associated with, never `null`. See also: `GenerateBytecode.languageClass()`. Cite: `com/oracle/truffle/api/bytecode/BytecodeDescriptor.html#getLanguageClass()` ### getInstructionDescriptor(int) `public abstract InstructionDescriptor getInstructionDescriptor(int operationCode)`. Since 25.1. Returns the `InstructionDescriptor` for the given operation code, or `null` if the code is not defined by this interpreter. Parameters: `operationCode` `int`: the numeric operation code of the instruction. See also: `InstructionDescriptor.getOperationCode()`, `Instruction.getOperationCode()`. Cite: `com/oracle/truffle/api/bytecode/BytecodeDescriptor.html#getInstructionDescriptor(int)` ### getInstructionDescriptors() `public abstract List getInstructionDescriptors()`. Since 25.1. Returns an immutable list of all instruction descriptors known to this interpreter. The list describes every instruction kind that can be executed by nodes generated from this interpreter. Cite: `com/oracle/truffle/api/bytecode/BytecodeDescriptor.html#getInstructionDescriptors()` ### cast(RootNode) `public abstract R cast(RootNode rootNode)`. Since 25.1. Casts a `RootNode` to the specification root node type `R`. This also handles `ContinuationRootNode` if yield is enabled. Returns `null` if the given root is not compatible with this descriptor. Parameters: `rootNode` `RootNode`: a root node, must not be `null`. Cite: `com/oracle/truffle/api/bytecode/BytecodeDescriptor.html#cast(com.oracle.truffle.api.nodes.RootNode)` ### cast(CallTarget) `public final R cast(CallTarget target)`. Since 25.1. Casts a `CallTarget` to the specification root node type `R`. Returns `null` if the given root is not compatible with this descriptor. Parameters: `target` `CallTarget`: a call target, must not be `null`. Cite: `com/oracle/truffle/api/bytecode/BytecodeDescriptor.html#cast(com.oracle.truffle.api.CallTarget)` ### newConfigBuilder() `public abstract BytecodeConfig.Builder newConfigBuilder()`. Since 25.1. Creates a new `BytecodeConfig.Builder` initialized with defaults that are valid for this descriptor. Returns `BytecodeConfig.Builder`: a new mutable configuration builder. Cite: `com/oracle/truffle/api/bytecode/BytecodeDescriptor.html#newConfigBuilder()` ### create(L, BytecodeConfig, BytecodeParser) `public abstract BytecodeRootNodes create(L language, BytecodeConfig config, BytecodeParser parser)`. Since 25.1. Creates one or more bytecode root nodes. This is the entrypoint for creating new `R` instances. The `parser` is invoked to emit builder calls on a `BytecodeBuilder` which is then materialized into executable bytecode. The returned `BytecodeRootNodes` contains the created root nodes, for example entry points and helper nodes. Parameters: `language` `L`: the language instance. `config` `BytecodeConfig`: the bytecode configuration, for example whether to include source information. `parser` `BytecodeParser`: the parser that drives the `BytecodeBuilder`. Returns `BytecodeRootNodes`: the created bytecode root nodes. Cite: `com/oracle/truffle/api/bytecode/BytecodeDescriptor.html#create(L,com.oracle.truffle.api.bytecode.BytecodeConfig,com.oracle.truffle.api.bytecode.BytecodeParser)` ### serialize(DataOutput, BytecodeSerializer, BytecodeParser) `@Deprecated(since = "25.7") public void serialize(DataOutput buffer, BytecodeSerializer callback, BytecodeParser parser) throws IOException`. Since 25.1. Deprecated since 25.7. Use `serializeBuilderBytecode`. Serializes builder bytecode for the nodes parsed by `parser`. Cite: `com/oracle/truffle/api/bytecode/BytecodeDescriptor.html#serialize(java.io.DataOutput,com.oracle.truffle.api.bytecode.serialization.BytecodeSerializer,com.oracle.truffle.api.bytecode.BytecodeParser)` ### serializeBuilderBytecode(DataOutput, BytecodeSerializer, BytecodeParser) `public void serializeBuilderBytecode(DataOutput buffer, BytecodeSerializer callback, BytecodeParser parser) throws IOException`. Since 25.7. Serializes the bytecode nodes parsed by the `parser` as a sequence of builder calls. All metadata (e.g., source information) is serialized, so the nodes can be deserialized with any configuration or reparsed later when more metadata is requested. This method does not validate the builder calls performed by `parser`. Validation happens when the builder calls are replayed during deserialization. Unlike `BytecodeRootNodes.serializeBuilderBytecode`, this method cannot serialize field values set outside the parser, since it does not have access to existing root node instances. Parameters: `buffer` `DataOutput`: the buffer to write the builder payload to. `callback` `BytecodeSerializer`: the language-specific serializer for constants in the bytecode. `parser` `BytecodeParser`: the parser. See also: `serializeExecutionBytecode`. Cite: `com/oracle/truffle/api/bytecode/BytecodeDescriptor.html#serializeBuilderBytecode(java.io.DataOutput,com.oracle.truffle.api.bytecode.serialization.BytecodeSerializer,com.oracle.truffle.api.bytecode.BytecodeParser)` ### serializeExecutionBytecode(L, DataOutput, …) `public void serializeExecutionBytecode(L language, DataOutput buffer, BytecodeConfig config, BytecodeSerializer callback, BytecodeParser parser) throws IOException`. Since 25.7. Serializes execution bytecode and its metadata for the requested `config`. This method invokes `parser` to construct a temporary representation with that configuration, validating its builder calls. The bytecodes are serialized in an unquickened form and do not preserve execution profiles. The output contains only the execution bytecode payload. A corresponding builder payload must be produced separately using `serializeBuilderBytecode` and supplied during deserialization to support reparsing. **Since execution bytecode skips builder validation during deserialization, it should only be used in trusted environments**. Each payload must be independently decodable. If constant object identity matters, its identity must be encoded consistently across both payloads, for example by sharing serializer state that assigns identity indices to constants. Unlike `BytecodeRootNodes.serializeExecutionBytecode`, this method cannot serialize field values that are set outside the parser, since it does not have access to existing root node instances. Parameters: `language` `L`: the language instance used to construct the temporary representation. `buffer` `DataOutput`: the buffer to write the execution bytecode payload to. `config` `BytecodeConfig`: the target configuration for execution bytecode. `callback` `BytecodeSerializer`: the language-specific serializer for constants in the bytecode. `parser` `BytecodeParser`: the parser. Cite: `com/oracle/truffle/api/bytecode/BytecodeDescriptor.html#serializeExecutionBytecode(L,java.io.DataOutput,com.oracle.truffle.api.bytecode.BytecodeConfig,com.oracle.truffle.api.bytecode.serialization.BytecodeSerializer,com.oracle.truffle.api.bytecode.BytecodeParser)` ### deserialize(L, BytecodeConfig, …) `@Deprecated(since = "25.7") public BytecodeRootNodes deserialize(L language, BytecodeConfig config, Supplier builderBytecodeInput, BytecodeDeserializer callback) throws IOException`. Since 25.1. Deprecated since 25.7. Use `deserializeBuilderBytecode`. Deserializes bytecode nodes by replaying serialized builder calls. Cite: `com/oracle/truffle/api/bytecode/BytecodeDescriptor.html#deserialize(L,com.oracle.truffle.api.bytecode.BytecodeConfig,java.util.function.Supplier,com.oracle.truffle.api.bytecode.serialization.BytecodeDeserializer)` ### deserializeBuilderBytecode(L, BytecodeConfig, …) `public BytecodeRootNodes deserializeBuilderBytecode(L language, BytecodeConfig config, Supplier builderBytecodeInput, BytecodeDeserializer callback) throws IOException`. Since 25.7. Deserializes bytecode nodes by replaying serialized builder calls. Parameters: `language` `L`: the language instance. `config` `BytecodeConfig`: the requested bytecode configuration, including optional metadata. `builderBytecodeInput` `Supplier`: a function that supplies the builder bytecode payload. It must produce a new [`DataInput`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/DataInput.html) on each invocation to support reparsing. `callback` `BytecodeDeserializer`: the language-specific deserializer for constants in the bytecode. See also: `deserializeExecutionBytecode`. Cite: `com/oracle/truffle/api/bytecode/BytecodeDescriptor.html#deserializeBuilderBytecode(L,com.oracle.truffle.api.bytecode.BytecodeConfig,java.util.function.Supplier,com.oracle.truffle.api.bytecode.serialization.BytecodeDeserializer)` ### deserializeExecutionBytecode(L, BytecodeConfig, …) `public BytecodeRootNodes deserializeExecutionBytecode(L language, BytecodeConfig config, Supplier builderBytecodeInput, Function executionBytecodeInput, BytecodeDeserializer callback) throws IOException`. Since 25.7. Deserializes bytecode nodes from a builder payload and an optional execution bytecode payload. Both payloads must describe the same program, with matching serialized root-node field values. Produce them using the same parser and input, or from the same BytecodeRootNodes instance. If `executionBytecodeInput` is non-null, it is called with the requested `config` augmented with any globally enabled metadata or instrumentation. The function should check whether the requested configuration `matches` an available execution bytecode payload; if one exists, it should return the payload, and otherwise it should return `null`. A returned payload is loaded directly without invoking `builderBytecodeInput`. Invalid execution bytecode, including a mismatched configuration, causes deserialization to fail. If the function is null or returns null, the serialized builder calls supplied by `builderBytecodeInput` are replayed. Subsequent metadata updates always replay the builder payload. **Since execution bytecode skips builder validation during deserialization, it should only be used in trusted environments**. Each payload must be independently decodable by `callback`. The same callback is retained for subsequent reparses. If constant object identity matters, the callback must return the same object for that logical constant across both payloads and reparses, for example by caching objects using identity indices shared by the two payloads. Parameters: `language` `L`: the language instance. `config` `BytecodeConfig`: the requested bytecode configuration, including optional metadata (e.g., source information). `builderBytecodeInput` `Supplier`: a function that supplies the builder payload. This supplier is always required and must produce a new [`DataInput`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/DataInput.html), since the bytes may be processed multiple times for reparsing. `executionBytecodeInput` `Function`: a function that supplies execution bytecode for the effective configuration, returning `null` if no matching payload is available. The function itself may also be `null` if the builder payload should be used. It is invoked at most once and is not retained for subsequent reparses. `callback` `BytecodeDeserializer`: The language-specific deserializer for constants in the bytecode. This callback must perform the inverse of the callback that was used to serialize each payload. Cite: `com/oracle/truffle/api/bytecode/BytecodeDescriptor.html#deserializeExecutionBytecode(L,com.oracle.truffle.api.bytecode.BytecodeConfig,java.util.function.Supplier,java.util.function.Function,com.oracle.truffle.api.bytecode.serialization.BytecodeDeserializer)` ### addInstructionTracer(L, InstructionTracer) `public void addInstructionTracer(L language, InstructionTracer tracer)`. Since 25.1. Registers an `InstructionTracer` for all bytecode root nodes created from this descriptor in the given language. After a tracer is installed, all existing and future `BytecodeRootNode` instances associated with this descriptor and `language` will start invoking the tracer's callback before executing each instruction. Installing a tracer is intentionally invasive and may be expensive: All affected bytecode roots may need to be invalidated and re-parsed so that tracing hooks (for example `trace.instruction`) can be inserted.; The change applies process-wide to that language instance, not just to a single root node. Tracing itself runs on the language execution thread and may be called at very high frequency. If this bytecode interpreter was generated without instruction tracing support (for example using `@GenerateBytecode(enableInstructionTracing = false)`), this method throws [`UnsupportedOperationException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/UnsupportedOperationException.html). Parameters: `language` `L`: the language instance whose bytecode roots should start reporting. `tracer` `InstructionTracer`: the tracer to install. Throws: `IllegalArgumentException` (unchecked): if `tracer` is exclusive to a different `BytecodeDescriptor`. `UnsupportedOperationException` (unchecked): if instruction tracing is not enabled for this descriptor. Cite: `com/oracle/truffle/api/bytecode/BytecodeDescriptor.html#addInstructionTracer(L,com.oracle.truffle.api.bytecode.InstructionTracer)` ### removeInstructionTracer(L, InstructionTracer) `public void removeInstructionTracer(L language, InstructionTracer tracer)`. Since 25.1. Unregisters a previously installed `InstructionTracer` for the given language. After removal, bytecode roots created from this descriptor for `language` will stop invoking the tracer's callback. Future roots created for the same language will also not attach the tracer. The `tracer` argument must be the same tracer instance that was passed to `addInstructionTracer(TruffleLanguage, InstructionTracer)`. Note that currently when all instruction tracers were removed, the trace instructions remain in the bytecode. This may be improved in the future. If this bytecode interpreter was generated without instruction tracing support (for example using `@GenerateBytecode(enableInstructionTracing = false)`), this method throws [`UnsupportedOperationException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/UnsupportedOperationException.html). Parameters: `language` `L`: the language instance whose bytecode roots should stop reporting. `tracer` `InstructionTracer`: the tracer to remove. Throws: `IllegalArgumentException` (unchecked): if `tracer` is exclusive to a different `BytecodeDescriptor`. `UnsupportedOperationException` (unchecked): if instruction tracing is not enabled for this descriptor. Cite: `com/oracle/truffle/api/bytecode/BytecodeDescriptor.html#removeInstructionTracer(L,com.oracle.truffle.api.bytecode.InstructionTracer)` ### update(L, BytecodeConfig) `public void update(L language, BytecodeConfig config)`. Since 25.1. Updates the bytecode configuration for all bytecode root nodes that were created by this descriptor for the given language instance. This can be used to enable features such as source information or instrumentation globally. Options are applied cumulatively and cannot be reverted for that language instance. Parameters: `language` `L`: the language instance. `config` `BytecodeConfig`: the configuration to apply. Cite: `com/oracle/truffle/api/bytecode/BytecodeDescriptor.html#update(L,com.oracle.truffle.api.bytecode.BytecodeConfig)` ### toString() `public String toString()`. Since 25.1. Returns a short string representation for debugging. Returns `String`: a concise descriptor string. Overrides `toString()`. Cite: `com/oracle/truffle/api/bytecode/BytecodeDescriptor.html#toString()` ### dump() `public String dump()`. Since 25.1. Returns a human readable dump of this bytecode descriptor. The dump includes the instruction set, statistics such as encoded size, and formatted instruction listings. This is intended for diagnostics and test assertions, not for programmatic parsing. Returns `String`: a multi line string describing the bytecode descriptor. Cite: `com/oracle/truffle/api/bytecode/BytecodeDescriptor.html#dump()` ### onTransition(TruffleLanguage, R, BytecodeTransition) `protected final void onTransition(TruffleLanguage language, R rootNode, BytecodeTransition transition)`. Since 25.1. Internal method called by generated code to notify the engine of a transition. This method unconditionally routes the transition to the engine-level logger and cannot be overridden by bytecode interpreter implementations. Cite: `com/oracle/truffle/api/bytecode/BytecodeDescriptor.html#onTransition(com.oracle.truffle.api.TruffleLanguage,R,com.oracle.truffle.api.bytecode.BytecodeTransition)` ### onPrepareForLoad(TruffleLanguage, R) `protected final void onPrepareForLoad(TruffleLanguage language, R rootNode)`. Since 25.1. Internal method called by generated code on root node load. Cite: `com/oracle/truffle/api/bytecode/BytecodeDescriptor.html#onPrepareForLoad(com.oracle.truffle.api.TruffleLanguage,R)` ### withGlobalConfig(TruffleLanguage, long) `protected final long withGlobalConfig(TruffleLanguage language, long config)`. Since 25.1. Internal method called by generated code whenever the a `BytecodeConfig` is used. Cite: `com/oracle/truffle/api/bytecode/BytecodeDescriptor.html#withGlobalConfig(com.oracle.truffle.api.TruffleLanguage,long)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ⚡︎ BytecodeEncodingException [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Exception in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java public final class BytecodeEncodingException extends RuntimeException ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) > [`Exception`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Exception.html) > [`RuntimeException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/RuntimeException.html) > `BytecodeEncodingException` Class representing an exception thrown by a [`BytecodeBuilder`](com/oracle/truffle/api/bytecode/BytecodeBuilder.md) when the program cannot be encoded, for example, when the bytecode exceeds the maximum addressable bytecode size. ## Methods ### create(String) `public static BytecodeEncodingException create(String reason)`. Since 24.2. Creates a bytecode encoding exception with a reason string. Cite: `com/oracle/truffle/api/bytecode/BytecodeEncodingException.html#create(java.lang.String)` ## Inherited members - From class [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html): [`addSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#addSuppressed%28java.lang.Throwable%29), [`fillInStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#fillInStackTrace%28%29), [`getCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getCause%28%29), [`getLocalizedMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getLocalizedMessage%28%29), [`getMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getMessage%28%29), [`getStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getStackTrace%28%29), [`getSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getSuppressed%28%29), [`initCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#initCause%28java.lang.Throwable%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintStream%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintWriter%29), [`setStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#setStackTrace%28java.lang.StackTraceElement[]%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ BytecodeFrame [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 25.1. ```java public final class BytecodeFrame ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `BytecodeFrame` Represents a captured Bytecode DSL frame, including the location metadata needed to access the data in the frame. [`BytecodeFrame`](com/oracle/truffle/api/bytecode/BytecodeFrame.md) is intended for use cases where the frame escapes or outlives the root node invocation. Prefer using a built-in operation or [`LocalAccessor`](com/oracle/truffle/api/bytecode/LocalAccessor.md) to access the frame whenever possible. [`BytecodeFrame`](com/oracle/truffle/api/bytecode/BytecodeFrame.md) should be used instead of [`TruffleStackTraceElement`](com/oracle/truffle/api/TruffleStackTraceElement.md) or [`FrameInstance`](com/oracle/truffle/api/frame/FrameInstance.md) to access frame data because the frame captured in these abstractions is not always the actual frame used in execution (e.g., it may be different for a resumed continuation). There are a few ways to capture the frame: - [`BytecodeNode.createCopiedFrame`](com/oracle/truffle/api/bytecode/BytecodeNode.md#createCopiedFrame%28int,com.oracle.truffle.api.frame.Frame%29) captures a copy. - [`BytecodeNode.createMaterializedFrame`](com/oracle/truffle/api/bytecode/BytecodeNode.md#createMaterializedFrame%28int,com.oracle.truffle.api.frame.MaterializedFrame%29) captures the original frame. - [`BytecodeFrame.get(FrameInstance, FrameAccess)`](com/oracle/truffle/api/bytecode/BytecodeFrame.md#get%28com.oracle.truffle.api.frame.FrameInstance,com.oracle.truffle.api.frame.FrameInstance.FrameAccess%29) captures a frame from a [`FrameInstance`](com/oracle/truffle/api/frame/FrameInstance.md). It captures the original frame if [`FrameAccess.READ_WRITE`](com/oracle/truffle/api/frame/FrameInstance.FrameAccess.md#READ_WRITE) or [`FrameAccess.MATERIALIZE`](com/oracle/truffle/api/frame/FrameInstance.FrameAccess.md#MATERIALIZE) is requested. Otherwise, it captures either the original frame or a copy. - [`BytecodeFrame.get(TruffleStackTraceElement)`](com/oracle/truffle/api/bytecode/BytecodeFrame.md#get%28com.oracle.truffle.api.TruffleStackTraceElement%29) captures a frame from a [`TruffleStackTraceElement`](com/oracle/truffle/api/TruffleStackTraceElement.md). It captures either the original frame or a copy. - [`BytecodeFrame.getNonVirtual(FrameInstance)`](com/oracle/truffle/api/bytecode/BytecodeFrame.md#getNonVirtual%28com.oracle.truffle.api.frame.FrameInstance%29) captures the original frame from a [`FrameInstance`](com/oracle/truffle/api/frame/FrameInstance.md), if it is non-virtual. - [`BytecodeFrame.getNonVirtual(TruffleStackTraceElement)`](com/oracle/truffle/api/bytecode/BytecodeFrame.md#getNonVirtual%28com.oracle.truffle.api.TruffleStackTraceElement%29) captures the original frame from a [`TruffleStackTraceElement`](com/oracle/truffle/api/TruffleStackTraceElement.md), if it is non-virtual and available in the stack trace. Copied frames do not observe updates made to the original frame. Note: if the interpreter uses [`block scoping`](com/oracle/truffle/api/bytecode/GenerateBytecode.md#enableBlockScoping%28%29), local offsets are location-dependent and physical frame slots may be reused for different locals as execution proceeds. After execution continues, a captured frame may therefore expose values belonging to a different lexical scope. Any non-copied [`BytecodeFrame`](com/oracle/truffle/api/bytecode/BytecodeFrame.md) is consequently only valid until the interpreter continues execution. The frame **must not** be used after this point; doing so can cause undefined behaviour. If you need to access the frame after execution continues, you should capture a copy or explicitly [`copy()`](com/oracle/truffle/api/bytecode/BytecodeFrame.md#copy%28%29) the captured bytecode frame. This restriction also applies to frames created by methods like [`BytecodeFrame.get(TruffleStackTraceElement)`](com/oracle/truffle/api/bytecode/BytecodeFrame.md#get%28com.oracle.truffle.api.TruffleStackTraceElement%29), which do not specify whether they capture the original frame or a copy. ## Methods ### copy() `public BytecodeFrame copy()`. Since 25.1. Returns a copy of this frame. This method can be used to snapshot the current state of a bytecode frame, in case it may be modified or become invalid in the future. Returns `BytecodeFrame`: a copy of this frame that is always valid and will not observe updates. Cite: `com/oracle/truffle/api/bytecode/BytecodeFrame.html#copy()` ### getLocation() `public BytecodeLocation getLocation()`. Since 25.1. Returns the bytecode location associated with the captured frame. This location is only valid until the bytecode interpreter resumes execution. Cite: `com/oracle/truffle/api/bytecode/BytecodeFrame.html#getLocation()` ### getBytecodeNode() `public BytecodeNode getBytecodeNode()`. Since 25.1. Returns the bytecode node associated with the captured frame. Cite: `com/oracle/truffle/api/bytecode/BytecodeFrame.html#getBytecodeNode()` ### getBytecodeIndex() `public int getBytecodeIndex()`. Since 25.1. Returns the bytecode index associated with the captured frame. Cite: `com/oracle/truffle/api/bytecode/BytecodeFrame.html#getBytecodeIndex()` ### getLocalCount() `public int getLocalCount()`. Since 25.1. Returns the number of live locals in the captured frame. Cite: `com/oracle/truffle/api/bytecode/BytecodeFrame.html#getLocalCount()` ### getLocalValue(int) `public Object getLocalValue(int localOffset)`. Since 25.1. Returns the value of the local at the given offset. The offset should be in the range `[0, getLocalCount())`. See also: `BytecodeNode.getLocalValue(int, Frame, int)`. Cite: `com/oracle/truffle/api/bytecode/BytecodeFrame.html#getLocalValue(int)` ### setLocalValue(int, Object) `public void setLocalValue(int localOffset, Object value)`. Since 25.1. Updates the value of the local at the given offset. The offset should be in the range `[0, getLocalCount())`. This method will throw an [`AssertionError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AssertionError.html) if the captured frame does not support writes. See also: `BytecodeNode.setLocalValue(int, Frame, int, Object)`. Cite: `com/oracle/truffle/api/bytecode/BytecodeFrame.html#setLocalValue(int,java.lang.Object)` ### getLocalNames() `public Object[] getLocalNames()`. Since 25.1. Returns the names associated with the live locals, if provided. Cite: `com/oracle/truffle/api/bytecode/BytecodeFrame.html#getLocalNames()` ### getArgumentCount() `public int getArgumentCount()`. Since 25.1. Returns the number of arguments in the captured frame. Cite: `com/oracle/truffle/api/bytecode/BytecodeFrame.html#getArgumentCount()` ### getArgument(int) `public Object getArgument(int argumentIndex)`. Since 25.1. Returns the value of the argument at the given index. The offset should be between 0 and `getArgumentCount()`. Cite: `com/oracle/truffle/api/bytecode/BytecodeFrame.html#getArgument(int)` ### setArgument(int, Object) `public void setArgument(int argumentIndex, Object value)`. Since 25.1. Updates the value of the local at the given offset. The offset should be between 0 and `getArgumentCount()`. Cite: `com/oracle/truffle/api/bytecode/BytecodeFrame.html#setArgument(int,java.lang.Object)` ### getFrameDescriptorInfo() `public Object getFrameDescriptorInfo()`. Since 25.1. Returns the `info` object associated with the frame's descriptor. Cite: `com/oracle/truffle/api/bytecode/BytecodeFrame.html#getFrameDescriptorInfo()` ### get(FrameInstance, FrameInstance.FrameAccess) `public static BytecodeFrame get(FrameInstance frameInstance, FrameInstance.FrameAccess access)`. Since 25.1. Creates a bytecode frame from the given frame instance. Parameters: `frameInstance` `FrameInstance`: the frame instance. `access` `FrameInstance.FrameAccess`: the access mode to use when capturing the frame. Returns `BytecodeFrame`: a bytecode frame, or null if the frame instance is missing location info. Cite: `com/oracle/truffle/api/bytecode/BytecodeFrame.html#get(com.oracle.truffle.api.frame.FrameInstance,com.oracle.truffle.api.frame.FrameInstance.FrameAccess)` ### get(TruffleStackTraceElement) `public static BytecodeFrame get(TruffleStackTraceElement element)`. Since 25.1. Creates a bytecode frame from the given stack trace element. This method will return null unless the interpreter specifies `GenerateBytecode.captureFramesForTrace`, which indicates whether frames should be captured. Parameters: `element` `TruffleStackTraceElement`: the stack trace element. Returns `BytecodeFrame`: a bytecode frame, or null if the frame was not captured or the stack trace element is missing location information. Throws: `IllegalArgumentException` (unchecked): if the element has an invalid bytecode index. Cite: `com/oracle/truffle/api/bytecode/BytecodeFrame.html#get(com.oracle.truffle.api.TruffleStackTraceElement)` ### getNonVirtual(FrameInstance) `public static BytecodeFrame getNonVirtual(FrameInstance frameInstance)`. Since 25.1. Attempts to create a bytecode frame from the given frame instance. Returns null if the corresponding frame is virtual. The frame can be read from, written to, and escaped. This method can be used to probe for a frame that can safely escape without forcing materialization. For example, if a language needs to capture local variables from a stack frame, it's often more efficient to use an existing non-virtual frame rather than create a copy of all variables. Parameters: `frameInstance` `FrameInstance`: the frame instance. Returns `BytecodeFrame`: a bytecode frame or null if the frame is virtual or if the frame instance is missing location info. Cite: `com/oracle/truffle/api/bytecode/BytecodeFrame.html#getNonVirtual(com.oracle.truffle.api.frame.FrameInstance)` ### getNonVirtual(TruffleStackTraceElement) `public static BytecodeFrame getNonVirtual(TruffleStackTraceElement element)`. Since 25.1. Attempts to create a bytecode frame from the given stack trace element. Returns null if the corresponding frame is virtual. The frame can be read from, written to, and escaped. This method can be used to probe for a frame that can safely escape without forcing materialization. For example, if a language needs to capture local variables from a stack frame, it's often more efficient to use an existing non-virtual frame rather than create a copy of all variables. Parameters: `element` `TruffleStackTraceElement`: the stack trace element. Returns `BytecodeFrame`: a bytecode frame or null if the frame is virtual/unavailable or if the frame instance is missing location info. Throws: `IllegalArgumentException` (unchecked): if the element has an invalid bytecode index. Cite: `com/oracle/truffle/api/bytecode/BytecodeFrame.html#getNonVirtual(com.oracle.truffle.api.TruffleStackTraceElement)` ### getTop(FrameInstance.FrameAccess, Node, int) `public static BytecodeFrame getTop(FrameInstance.FrameAccess access, Node topLocation, int topBytecodeIndex)`. Since 25.1. Returns the current top stack activation as a `bytecode frame`. The top frame's location is derived using `topLocation` and `topBytecodeIndex`. If `topBytecodeIndex` is `-1`, the bytecode index is resolved from `topLocation` and the resolved top `Frame`. Parameters: `access` `FrameInstance.FrameAccess`: the access mode used when resolving the top frame. `topLocation` `Node`: a node in the current top bytecode activation. `topBytecodeIndex` `int`: the bytecode index of the current top bytecode activation, or `-1` to resolve it from `topLocation` and the resolved frame. Returns `BytecodeFrame`: the current top bytecode frame. Throws: `IllegalArgumentException` (unchecked): if `topLocation` and `topBytecodeIndex` do not identify a valid location for the top frame, or if the top frame is not a bytecode frame. Cite: `com/oracle/truffle/api/bytecode/BytecodeFrame.html#getTop(com.oracle.truffle.api.frame.FrameInstance.FrameAccess,com.oracle.truffle.api.nodes.Node,int)` ### iterateBytecodeFrames(Function, FrameInstance.FrameAccess, …) `public static T iterateBytecodeFrames(Function visitor, FrameInstance.FrameAccess access, Node topLocation, int topBytecodeIndex, int skipBytecodeFrames)`. Since 25.1. Iterates the current stack as `bytecode frames`, starting with the current top activation. This method uses `com.oracle.truffle.api.TruffleRuntime.iterateFrames` to perform a stack walk, constructing each `BytecodeFrame` instance from an underlying `FrameInstance`. Frame instances that do not correspond to bytecode frames are ignored. The visitor is invoked for each available bytecode frame until it returns a non-`null` value, which is then returned from this method. If the visitor always returns `null`, this method returns `null`. The stack walk begins with the current (top) activation. The top frame's location is derived using `topLocation` and `topBytecodeIndex`. These parameters are necessary because the `FrameInstance` for the top activation does not necessarily provide location information. If `skipBytecodeFrames > 0`, the top frame is skipped and `topLocation` and `topBytecodeIndex` are ignored. Otherwise, `topLocation` must identify a node in the current top bytecode activation, and `topBytecodeIndex` must be a valid bytecode index or `-1`. When `topBytecodeIndex` is `-1`, the bytecode index of the top frame is computed using `topLocation` and the resolved top `Frame`. Parameters: `visitor` `Function`: the visitor applied to each bytecode frame. `access` `FrameInstance.FrameAccess`: the access mode used when resolving frames from runtime stack frames. `topLocation` `Node`: a node in the current top bytecode activation; ignored if `skipBytecodeFrames > 0`. `topBytecodeIndex` `int`: the bytecode index of the current top bytecode activation, or `-1` to resolve it from `topLocation` and the resolved frame; ignored if `skipBytecodeFrames > 0`. `skipBytecodeFrames` `int`: the number of bytecode frames to skip before invoking the visitor. Returns `T`: the first non-`null` value returned by `visitor`, or `null` if no visited frame produces one. Throws: `IllegalArgumentException` (unchecked): if the top frame is not skipped and `topLocation` and `topBytecodeIndex` do not identify a valid location for the top frame, or if the top frame is not a bytecode frame. Cite: `com/oracle/truffle/api/bytecode/BytecodeFrame.html#iterateBytecodeFrames(java.util.function.Function,com.oracle.truffle.api.frame.FrameInstance.FrameAccess,com.oracle.truffle.api.nodes.Node,int,int)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ≡ BytecodeIndexMode [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Enum class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 25.6. ```java public enum BytecodeIndexMode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html) > `BytecodeIndexMode` Configures how a generated bytecode interpreter makes its current bytecode index available for stack walking and frame introspection. **See also** - [`GenerateBytecode.bytecodeIndexMode()`](com/oracle/truffle/api/bytecode/GenerateBytecode.md#bytecodeIndexMode%28%29) ## Enum constants ### FRAME `FRAME`. Since 25.6. Stores the current bytecode index automatically in the frame in all interpreter tiers. The stored index can also be read or updated manually using `BytecodeNode.getBytecodeIndex` and `BytecodeNode.setBytecodeIndex`. A manual value persists until the next automatic update. Implicit stack-frame lookup still requires a non-null location node. Cite: `com/oracle/truffle/api/bytecode/BytecodeIndexMode.html#FRAME` ### CACHED_NODE `CACHED_NODE`. Since 25.6. Derives the bytecode index from the current operation node in the cached interpreter and stores it automatically in the frame in the uncached interpreter. This is the default mode. The frame slot is an implementation detail and cannot be accessed using `BytecodeNode.getBytecodeIndex` or `BytecodeNode.setBytecodeIndex`. Cite: `com/oracle/truffle/api/bytecode/BytecodeIndexMode.html#CACHED_NODE` ### MANUAL `MANUAL`. Since 25.6. Reserves a frame slot that is updated manually using `BytecodeNode.setBytecodeIndex` or explicitly for operations using `Operation.storeBytecodeIndex()` or `StoreBytecodeIndex`. Automatic operation storage is disabled by default. The stored index can be read using `BytecodeNode.getBytecodeIndex` and is used for implicit stack-frame lookup even when no location node is available. The slot is not initialized on a fresh invocation. Once stored, the index is preserved across tier transitions and translated when the bytecode layout changes during execution. Resuming a continuation always replaces the stored value with the resume bytecode index, even if the value was unset or cleared. Cite: `com/oracle/truffle/api/bytecode/BytecodeIndexMode.html#MANUAL` ### NONE `NONE`. Since 25.6. Does not reserve a frame slot or perform implicit bytecode index lookup. Bytecode indices must be passed explicitly to calls, exceptions, and other APIs that require them. Cite: `com/oracle/truffle/api/bytecode/BytecodeIndexMode.html#NONE` ## Methods ### values() `public static BytecodeIndexMode[] values()`. Returns the enum constants in declaration order. Returns `BytecodeIndexMode[]`: Returns the enum constants in declaration order. Cite: `com/oracle/truffle/api/bytecode/BytecodeIndexMode.html#values()` ### valueOf(String) `public static BytecodeIndexMode valueOf(String name)`. Returns the enum constant with the given name. Parameters: `name` `String`: The exact name of the enum constant. Returns `BytecodeIndexMode`: Returns the enum constant with the given name. Cite: `com/oracle/truffle/api/bytecode/BytecodeIndexMode.html#valueOf(java.lang.String)` ## Inherited members - From class [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#clone%28%29), [`compareTo`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#compareTo%28E%29), [`describeConstable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#describeConstable%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#finalize%28%29), [`getDeclaringClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#getDeclaringClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#hashCode%28%29), [`name`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#name%28%29), [`ordinal`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#ordinal%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#toString%28%29), [`valueOf`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#valueOf%28java.lang.Class,java.lang.String%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ BytecodeLabel [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java public abstract class BytecodeLabel ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `BytecodeLabel` Abstract definition of a label. Labels can be used to implement forward branches (for backward branches, use a `While` operation). The language parser can allocate labels using the builder's `createLabel` method, and subsequently emit it using `emitLabel`. Labels are specified as parameters to branch operations. ## Constructors ### BytecodeLabel(Object) `public BytecodeLabel(Object token)`. Since 24.2. Internal constructor for generated code. Do not use. Cite: `com/oracle/truffle/api/bytecode/BytecodeLabel.html#(java.lang.Object)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ BytecodeLocal [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java public abstract class BytecodeLocal ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `BytecodeLocal` Abstract definition of a local variable in the interpreter. Local variables are stored in the frame. They are typically accessed in the bytecode using `StoreLocal` and `LoadLocal` operations. For uncommon scenarios where locals need to be accessed programmatically (e.g., in a node), locals can be accessed using accessor methods on the [`BytecodeNode`](com/oracle/truffle/api/bytecode/BytecodeNode.md), such as [`BytecodeNode.getLocalValue(int, Frame, int)`](com/oracle/truffle/api/bytecode/BytecodeNode.md#getLocalValue%28int,com.oracle.truffle.api.frame.Frame,int%29) and [`BytecodeNode.setLocalValue(int, com.oracle.truffle.api.frame.Frame, int, Object)`](com/oracle/truffle/api/bytecode/BytecodeNode.md#setLocalValue%28int,com.oracle.truffle.api.frame.Frame,int,java.lang.Object%29). By default a local variable is live for the extent of the block that defines it ("block scoping"). Interpreters can also be configured so that locals live for the extent of the root node ("root scoping"). See [`GenerateBytecode.enableBlockScoping()`](com/oracle/truffle/api/bytecode/GenerateBytecode.md#enableBlockScoping%28%29) for details. Refer to the [user guide](https://github.com/oracle/graal/blob/master/truffle/docs/bytecode_dsl/UserGuide.md) for more details. ## Constructors ### BytecodeLocal(Object) `public BytecodeLocal(Object token)`. Since 24.2. Internal constructor for generated code. Do not use. Cite: `com/oracle/truffle/api/bytecode/BytecodeLocal.html#(java.lang.Object)` ## Methods ### getLocalOffset() `public abstract int getLocalOffset()`. Since 24.2. Returns the local offset to use when accessing local values with a local accessor like `BytecodeNode.getLocalValue(int, Frame, int)`. Cite: `com/oracle/truffle/api/bytecode/BytecodeLocal.html#getLocalOffset()` ### getLocalIndex() `public abstract int getLocalIndex()`. Since 24.2. Returns the index when accessing into the locals table with `BytecodeNode.getLocals()`. The local index is guaranteed to be equal to `getLocalOffset()` if `block scoping` is set to `false`. Otherwise, the local index is distinct from the local offset and should not be used in places an offset is expected. Cite: `com/oracle/truffle/api/bytecode/BytecodeLocal.html#getLocalIndex()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ BytecodeLocation [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java public final class BytecodeLocation ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `BytecodeLocation` A materialized bytecode location. The current bytecode location can be bound using `@Bind BytecodeLocation location` in [`operations`](com/oracle/truffle/api/bytecode/Operation.md). In order to avoid the overhead of the BytecodeLocation allocation, e.g. for exceptional cases, it is possible to create the bytecode location lazily from two fields: `@Bind BytecodeNode bytecode` and `@Bind("$bytecodeIndex") int bci`. This avoids the eager allocation of the bytecode location. To create a bytecode location when it is needed the [`BytecodeLocation.get(Node, int)`](com/oracle/truffle/api/bytecode/BytecodeLocation.md#get%28com.oracle.truffle.api.nodes.Node,int%29) method can be used. ## Methods ### getBytecodeIndex() `public int getBytecodeIndex()`. Since 24.2. Returns the bytecode index. This index is not stable and should only be used for debugging purposes. The bytecode index is only meaningful when coupled with a particular `bytecode node`. Cite: `com/oracle/truffle/api/bytecode/BytecodeLocation.html#getBytecodeIndex()` ### getBytecodeNode() `public BytecodeNode getBytecodeNode()`. Since 24.2. Returns the `BytecodeNode` associated with this location. The `bytecode index` is only valid for the returned node. Cite: `com/oracle/truffle/api/bytecode/BytecodeLocation.html#getBytecodeNode()` ### hashCode() `public int hashCode()`. Since 24.2. Overrides `hashCode()`. Cite: `com/oracle/truffle/api/bytecode/BytecodeLocation.html#hashCode()` ### equals(Object) `public boolean equals(Object obj)`. Since 24.2. Overrides `equals(java.lang.Object)`. Cite: `com/oracle/truffle/api/bytecode/BytecodeLocation.html#equals(java.lang.Object)` ### toString() `public String toString()`. Since 24.2. Overrides `toString()`. Cite: `com/oracle/truffle/api/bytecode/BytecodeLocation.html#toString()` ### dump() `public String dump()`. Since 24.2. Dumps the bytecode debug information, highlighting this location in the result. Returns `String`: dump string. See also: `BytecodeNode.dump(BytecodeLocation)`. Cite: `com/oracle/truffle/api/bytecode/BytecodeLocation.html#dump()` ### update() `public BytecodeLocation update()`. Since 24.2. Updates this location to the newest `bytecode node` of the parent `bytecode root node`, translating the `bytecode index` to the new bytecode node in the process. It is useful to update the location if source information or instrumentations were materialized in the meantime. Note that the `bytecode index` may be different in the updated location. Cite: `com/oracle/truffle/api/bytecode/BytecodeLocation.html#update()` ### ensureSourceInformation() `public BytecodeLocation ensureSourceInformation()`. Since 24.2. Ensures source information is available. If the current location already has source information, it is returned; otherwise, returns an `updated` location that has source information. This may be an expensive operation if the source information was not yet materialized. Cite: `com/oracle/truffle/api/bytecode/BytecodeLocation.html#ensureSourceInformation()` ### ensureSourceInformationWithContent() `public BytecodeLocation ensureSourceInformationWithContent()`. Since 25.1. Ensures source information with content is available. If the current location already has source information with content, it is returned; otherwise, returns an `updated` location that has source information with content. This may be an expensive operation if the source information with content was not yet materialized If the interpreter does not declare a `source content supplier`, this method is equivalent to `ensureSourceInformation`. Cite: `com/oracle/truffle/api/bytecode/BytecodeLocation.html#ensureSourceInformationWithContent()` ### getSourceLocation() `public SourceSection getSourceLocation()`. Since 24.2. Computes the most concrete source location of this bytecode location. See also: `BytecodeNode.getSourceLocation(int)`. Cite: `com/oracle/truffle/api/bytecode/BytecodeLocation.html#getSourceLocation()` ### getSourceLocations() `public SourceSection[] getSourceLocations()`. Since 24.2. Computes all source locations of this bytecode location. Returns an empty array if no source locations are available. The list is ordered from most to least concrete. See also: `BytecodeNode.getSourceLocations(int)`. Cite: `com/oracle/truffle/api/bytecode/BytecodeLocation.html#getSourceLocations()` ### getInstruction() `public Instruction getInstruction()`. Since 24.2. Returns the bytecode instruction at this location, which provides additional debug information for debugging and tracing. Cite: `com/oracle/truffle/api/bytecode/BytecodeLocation.html#getInstruction()` ### getExceptionHandlers() `public List getExceptionHandlers()`. Since 24.2. Returns all exception handlers that span over this bytecode location. Returns an empty list if no exception handlers span over this location. Cite: `com/oracle/truffle/api/bytecode/BytecodeLocation.html#getExceptionHandlers()` ### getSourceInformation() `public List getSourceInformation()`. Since 24.2. Returns all source informations available at this location. Cite: `com/oracle/truffle/api/bytecode/BytecodeLocation.html#getSourceInformation()` ### get(FrameInstance) `public static BytecodeLocation get(FrameInstance frameInstance)`. Since 24.2. Gets the bytecode location for a given FrameInstance. Frame instances are invalid as soon as the execution of a frame is continued. A bytecode location can be used to materialize an execution location in a bytecode interpreter, which can be used after the `FrameInstance` is no longer valid. Parameters: `frameInstance` `FrameInstance`: the frame instance. Returns `BytecodeLocation`: the corresponding bytecode location or null if no location can be found. Cite: `com/oracle/truffle/api/bytecode/BytecodeLocation.html#get(com.oracle.truffle.api.frame.FrameInstance)` ### get(Node, int) `public static BytecodeLocation get(Node location, int bci)`. Since 24.2. Creates a `BytecodeLocation` associated with the given node and bci. Parameters: `location` `Node`: a node in the interpreter (can be bound using `@Bind BytecodeNode bytecode`). `bci` `int`: a bytecode index (can be bound using `@Bind("$bytecodeIndex") int bci`). Returns `BytecodeLocation`: the `BytecodeLocation` or `null` if `location` is not adopted by a `BytecodeNode`. Cite: `com/oracle/truffle/api/bytecode/BytecodeLocation.html#get(com.oracle.truffle.api.nodes.Node,int)` ### get(TruffleStackTraceElement) `public static BytecodeLocation get(TruffleStackTraceElement element)`. Since 24.2. Creates a `BytecodeLocation` associated with a `TruffleStackTraceElement`. Returns `BytecodeLocation`: the `BytecodeLocation` or `null` if no bytecode interpreter can be found in the stack trace element. Throws: `IllegalArgumentException` (unchecked): if the element has an invalid bytecode index. Cite: `com/oracle/truffle/api/bytecode/BytecodeLocation.html#get(com.oracle.truffle.api.TruffleStackTraceElement)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ BytecodeNode [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java public abstract class BytecodeNode extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `BytecodeNode` Represents the current bytecode for a Bytecode DSL root node. The bytecode node may be replaced over time with newer versions whenever the [`bytecode configuration`](com/oracle/truffle/api/bytecode/BytecodeConfig.md) or the [`tier`](com/oracle/truffle/api/bytecode/BytecodeTier.md) changes. The [`tier`](com/oracle/truffle/api/bytecode/BytecodeNode.md#getTier%28%29) of a bytecode node initially always starts out as [`BytecodeTier.UNCACHED`](com/oracle/truffle/api/bytecode/BytecodeTier.md#UNCACHED). This means that no cached nodes were created yet. The [`uncached threshold`](com/oracle/truffle/api/bytecode/BytecodeNode.md#setUncachedThreshold%28int%29) determines how many calls/resumes and back-edges are necessary for the node to transition to the cached tier. By default the uncached threshold is 16 if the [`uncached interpreter`](com/oracle/truffle/api/bytecode/GenerateBytecode.md#enableUncachedInterpreter%28%29) is enabled, and 0 if not (i.e., it will transition to cached on the first execution). The intention of the uncached bytecode tier is to reduce the footprint of root nodes that are executed infrequently. The current bytecode node can be bound using `@Bind BytecodeNode bytecode` in the specialization of an [`Operation`](com/oracle/truffle/api/bytecode/Operation.md). Since the instructions for a root node can change when the bytecode node changes, a bytecode index is only valid for a particular bytecode node. It is therefore recommended to create a [`BytecodeLocation`](com/oracle/truffle/api/bytecode/BytecodeLocation.md) when storing a location (by using [`getBytecodeLocation(int)`](com/oracle/truffle/api/bytecode/BytecodeNode.md#getBytecodeLocation%28int%29) or binding it with `@Bind BytecodeLocation location`). This class is not intended to be subclassed by clients, only by code generated by the Bytecode DSL. **See also** - [`BytecodeLocation`](com/oracle/truffle/api/bytecode/BytecodeLocation.md) ## Fields ### INVALID `public static final Object INVALID`. Since 25.7. Represents an illegal frame slot returned by `getLocalValue(int, Frame, int)`. Pass this marker to `setLocalValue(int, Frame, int, Object)` to mark a slot illegal without changing its type profile. The marker is reserved for this API representation and should not be used as a guest value. See also: `BytecodeVersion.V2`. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#INVALID` ## Constructors ### BytecodeNode(Object) `protected BytecodeNode(Object token)`. Since 24.2. Internal constructor for generated code. Do not use. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#(java.lang.Object)` ## Methods ### getBytecodeLocation(Frame, Node) `public final BytecodeLocation getBytecodeLocation(Frame frame, Node location)`. Since 24.2. Returns the current bytecode location using the current frame and location. Parameters: `frame` `Frame`: the current frame. `location` `Node`: the current location. Returns `BytecodeLocation`: the bytecode location, or null if the frame and node do not originate from a Bytecode DSL root node. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getBytecodeLocation(com.oracle.truffle.api.frame.Frame,com.oracle.truffle.api.nodes.Node)` ### getBytecodeLocation(FrameInstance) `public final BytecodeLocation getBytecodeLocation(FrameInstance frameInstance)`. Since 24.2. Gets the bytecode location associated with a particular `FrameInstance` obtained from a stack walk. Parameters: `frameInstance` `FrameInstance`: the frame instance. Returns `BytecodeLocation`: the bytecode location, or `null` if the frame belongs to another bytecode node or its BCI is unavailable. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getBytecodeLocation(com.oracle.truffle.api.frame.FrameInstance)` ### getBytecodeLocation(int) `public final BytecodeLocation getBytecodeLocation(int bytecodeIndex)`. Since 24.2. Gets the bytecode location associated with a bytecode index. The result is only valid if the bytecode index was obtained from this bytecode node by binding `$bytecodeIndex` or calling `getBytecodeIndex`. Parameters: `bytecodeIndex` `int`: the current bytecode index. A valid bytecode index can be obtained by calling `BytecodeLocation.getBytecodeIndex()` or using @`Bind`("$bytecodeIndex") annotation. Throws: `IllegalArgumentException` (unchecked): if an invalid bytecode index was passed. This check is performed only if assertions (-ea) are enabled for performance reasons. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getBytecodeLocation(int)` ### getBytecodeIndex(Frame) `public int getBytecodeIndex(Frame frame)`. Since 24.2. Returns the BCI stored in the frame. Supported when `GenerateBytecode.bytecodeIndexMode()` is `BytecodeIndexMode.FRAME` or `BytecodeIndexMode.MANUAL`. In `MANUAL` mode, the value before the first store is unspecified. Parameters: `frame` `Frame`: the current frame. Returns `int`: the stored BCI, or `-1` if explicitly cleared. Throws: `UnsupportedOperationException` (unchecked): if the configured bytecode index mode does not support frame access. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getBytecodeIndex(com.oracle.truffle.api.frame.Frame)` ### setBytecodeIndex(Frame, int) `public void setBytecodeIndex(Frame frame, int bytecodeIndex)`. Since 25.6. Stores a bytecode index in the `frame`. This method is supported when `GenerateBytecode.bytecodeIndexMode()` is `BytecodeIndexMode.FRAME` or `BytecodeIndexMode.MANUAL`. In `BytecodeIndexMode.FRAME` mode, a subsequent automatic update may replace the manually stored value. In `BytecodeIndexMode.MANUAL` mode, resuming a continuation replaces the stored value with the resume bytecode index. Use at foreign-call boundaries; ordinary operations should bind `$bytecodeIndex` and pass it explicitly. Parameters: `frame` `Frame`: the current frame. `bytecodeIndex` `int`: the bytecode index to store, or `-1` to clear the manual value. Throws: `UnsupportedOperationException` (unchecked): if the configured bytecode index mode does not support frame access. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#setBytecodeIndex(com.oracle.truffle.api.frame.Frame,int)` ### setBytecodeIndex(Node, Frame, int) `public static void setBytecodeIndex(Node location, Frame frame, int bytecodeIndex)`. Since 25.6. Looks up the current bytecode node from `location` and stores a bytecode index. Prefer `setBytecodeIndex(Frame, int)` when the bytecode node is already available, for example through `@Bind BytecodeNode bytecodeNode`. Cached execution must provide a location, typically `this`. During uncached execution, null or non-adoptable locations use the current encapsulating node, which contains the bytecode node. Parameters: `location` `Node`: the current node location, which must be a partial evaluation constant, or null for uncached execution. `frame` `Frame`: the frame belonging to the resolved bytecode node. `bytecodeIndex` `int`: the index to store, or `-1` to clear it. Throws: `NullPointerException` (unchecked): if no bytecode node can be resolved. `UnsupportedOperationException` (unchecked): if the bytecode index mode does not support frame access. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#setBytecodeIndex(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.frame.Frame,int)` ```java BytecodeNode.setBytecodeIndex(this, frame, bytecodeIndex); ``` ### getSourceLocation(Frame, Node) `public final SourceSection getSourceLocation(Frame frame, Node location)`. Since 24.2. Gets the most concrete `source location` associated with a particular location. Returns `null` if the node was not parsed `with sources` or if there is no associated source section for the given location. Parameters: `frame` `Frame`: the current frame. `location` `Node`: the current location. Returns `SourceSection`: a source section corresponding to the location. Returns `null` if the location is invalid or source sections are not available. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getSourceLocation(com.oracle.truffle.api.frame.Frame,com.oracle.truffle.api.nodes.Node)` ### getSourceLocation(int) `public abstract SourceSection getSourceLocation(int bytecodeIndex)`. Since 24.2. Finds the most concrete source location associated with the given bytecode index. The method returns `null` if no source section could be found. If source sections have not yet been materialized, then `null` is returned. Source sections can be materialized by calling `ensureSourceInformation()`. Parameters: `bytecodeIndex` `int`: the bytecode index, used to determine liveness of source sections. A valid bytecode index can be obtained by calling `BytecodeLocation.getBytecodeIndex()` or using @`Bind`("$bytecodeIndex") annotation. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getSourceLocation(int)` ### getSourceLocation(FrameInstance) `public final SourceSection getSourceLocation(FrameInstance frameInstance)`. Since 24.2. Gets the source location associated with a particular `frameInstance`. If source sections have not yet been materialized, then `null` is returned. Source sections can be materialized by calling `ensureSourceInformation()`. Parameters: `frameInstance` `FrameInstance`: the frame instance. Returns `SourceSection`: the source location, or null if the frame instance does not originate from this bytecode node or a location could not be found. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getSourceLocation(com.oracle.truffle.api.frame.FrameInstance)` ### getSourceLocations(Frame, Node) `public final SourceSection[] getSourceLocations(Frame frame, Node location)`. Gets all `source locations` associated with a particular location. More concrete source sections appear earlier in the array. Returns `null` if the node was not parsed `with sources` or if there is no associated source section for the given location. If source sections have not yet been materialized, then `null` is returned. Source sections may be materialized by calling `ensureSourceInformation()`. Parameters: `frame` `Frame`: the current frame. `location` `Node`: the current location. Returns `SourceSection[]`: an array of source sections corresponding to the location. Returns `null` if the location is invalid or source sections are not available. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getSourceLocations(com.oracle.truffle.api.frame.Frame,com.oracle.truffle.api.nodes.Node)` ### getSourceLocations(int) `public abstract SourceSection[] getSourceLocations(int bytecodeIndex)`. Since 24.2. Finds all source locations associated with the given bytecode index. More concrete source sections appear earlier in the array. Typically, a given section will contain the previous source section, but there is no guarantee that this the case. If source sections have not yet been materialized, then `null` is returned. Source sections can be materialized by calling `ensureSourceInformation()`. Parameters: `bytecodeIndex` `int`: the bytecode index, used to determine liveness of source sections. A valid bytecode index can be obtained by calling `BytecodeLocation.getBytecodeIndex()` or using @`Bind`("$bytecodeIndex") annotation. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getSourceLocations(int)` ### getSourceLocations(FrameInstance) `public final SourceSection[] getSourceLocations(FrameInstance frameInstance)`. Since 24.2. Gets all source locations associated with a particular `frameInstance`. If source sections have not yet been materialized, then `null` is returned. Source sections can be materialized by calling `ensureSourceInformation()`. Parameters: `frameInstance` `FrameInstance`: the frame instance. Returns `SourceSection[]`: the source locations, or null if the frame instance does not originate from this bytecode node or locations could not be found. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getSourceLocations(com.oracle.truffle.api.frame.FrameInstance)` ### getBytecodeRootNode() `public final BytecodeRootNode getBytecodeRootNode()`. Since 24.2. Returns the `BytecodeRootNode` to which this node belongs. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getBytecodeRootNode()` ### getInstruction(int) `public final Instruction getInstruction(int bytecodeIndex)`. Since 24.2. Gets the instruction associated with the given bytecode index. The result is only valid if `bytecodeIndex` was obtained from this bytecode node by binding `$bytecodeIndex` or calling `getBytecodeIndex`. Compatibility note: The result of this method is subject to change without notice between Truffle versions. This introspection API is therefore intended to be used for debugging and tracing purposes only. Do not rely on instructions for your language semantics. Parameters: `bytecodeIndex` `int`: the current bytecode index. A valid bytecode index can be obtained by calling `BytecodeLocation.getBytecodeIndex()` or using @`Bind`("$bytecodeIndex") annotation. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getInstruction(int)` ### getInstructions() `public final Iterable getInstructions()`. Since 24.2. Returns the current set of `instructions` as an [`Iterable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Iterable.html). Compatibility note: The result of this method is subject to change without notice between Truffle versions. This introspection API is therefore intended to be used for debugging and tracing purposes only. Do not rely on instructions for your language semantics. Footprint note: the backing iterable implementation consumes a fixed amount of memory. It allocates the underlying instructions when it is iterated. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getInstructions()` ### getInstructionsAsList() `public final List getInstructionsAsList()`. Since 24.2. Returns the current set of `instructions` as a [`List`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/List.html) with random access. Compatibility note: The result of this method is subject to change without notice between Truffle versions. This introspection API is therefore intended to be used for debugging and tracing purposes only. Do not rely on instructions for your language semantics. Footprint note: this method eagerly materializes an entire list, unlike `getInstructions()`, which allocates its elements on demand. Prefer to use `getInstructions()` for simple iteration use cases. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getInstructionsAsList()` ### getSourceInformation() `public abstract List getSourceInformation()`. Since 24.2. Produces a list of `SourceInformation` for a bytecode node. If no source information is available, returns `null`. Footprint note: the backing list implementation consumes a fixed amount of memory. It allocates the underlying `SourceInformation` elements when it is [`accessed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/List.html#get%28int%29). Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getSourceInformation()` ### getSourceInformationTree() `public abstract SourceInformationTree getSourceInformationTree()`. Since 24.2. Produces a `SourceInformationTree` for this node. If no source information is available, returns `null`. The tree returned by this method will have a `source section` that spans the whole bytecode range, or a `null` section if no such section exists. For example, if Root operation directly contains two SourceSection operations covering different bytecode ranges, the tree's source section will be `null`. The source section can be `null` even if there is a single SourceSection operation containing the entire root body; for reliable source information that covers the entire bytecode range, the Root operation should be nested inside of a SourceSection operation. Footprint note: this method eagerly materializes an entire tree, unlike `getSourceInformation()`, which allocates its elements on demand. Prefer to use `getSourceInformation()` unless you need to traverse the source tree. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getSourceInformationTree()` ### ensureSourceInformation() `public final BytecodeNode ensureSourceInformation()`. Since 24.2. Ensures that sources are materialized for this node and returns an updated bytecode node if it changed during materialization. See also: `BytecodeLocation.ensureSourceInformation()`, `BytecodeRootNodes.ensureSourceInformation()`. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#ensureSourceInformation()` ### hasSourceInformation() `public abstract boolean hasSourceInformation()`. Since 24.2. Returns `true` if source information was materialized for this bytecode node, otherwise `false`. See also: `ensureSourceInformation()`. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#hasSourceInformation()` ### ensureSourceInformationWithContent() `public BytecodeNode ensureSourceInformationWithContent()`. Since 25.1. Ensures that sources are materialized for this node (see `ensureSourceInformation()`) and that content is loaded. This method has no effect unless the interpreter declares a `source content supplier`. See also: `BytecodeLocation.ensureSourceInformationWithContent()`, `BytecodeRootNodes.ensureSourceInformationWithContent()`. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#ensureSourceInformationWithContent()` ### hasSourceInformationWithContent() `public abstract boolean hasSourceInformationWithContent()`. Since 25.1. Returns `true` if source content was loaded for this bytecode node. If the interpreter does not declare a `source content supplier`, this method is equivalent to `hasSourceInformation`. See also: `ensureSourceInformationWithContent()`. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#hasSourceInformationWithContent()` ### getExceptionHandlers() `public abstract List getExceptionHandlers()`. Since 24.2. Returns all of the `exception handlers` associated with this node. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getExceptionHandlers()` ### getTagTree() `public abstract TagTree getTagTree()`. Since 24.2. Returns the `TagTree` for this node. The tree only contains tag operations for the tags that were enabled during parsing; if no tags were enabled, returns `null`. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getTagTree()` ### createMaterializedFrame(int, MaterializedFrame) `public final BytecodeFrame createMaterializedFrame(int bytecodeIndex, MaterializedFrame frame)`. Since 25.1. Returns a `BytecodeFrame` capturing the materialized interpreter state. Note that materialized frames **may become invalid** once the interpreter resumes; see the `BytecodeFrame` javadoc for more info. Prefer to capture the frame using this method (rather than `createCopiedFrame`) when capturing the frame is a frequent operation or when future updates to the frame should be observable. Parameters: `bytecodeIndex` `int`: the current bytecode index. `frame` `MaterializedFrame`: the current materialized frame. Returns `BytecodeFrame`: the captured bytecode frame. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#createMaterializedFrame(int,com.oracle.truffle.api.frame.MaterializedFrame)` ### createCopiedFrame(int, Frame) `public final BytecodeFrame createCopiedFrame(int bytecodeIndex, Frame frame)`. Since 25.1. Returns a `BytecodeFrame` capturing a copy of the interpreter state. The copy is always valid, but will not observe subsequent changes to the frame. Prefer to capture the frame using this method (rather than `createMaterializedFrame`) when capturing the frame is an infrequent operation or when the frame does not need to observe future updates. Parameters: `bytecodeIndex` `int`: the current bytecode index. `frame` `Frame`: the current frame. Returns `BytecodeFrame`: the captured bytecode frame. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#createCopiedFrame(int,com.oracle.truffle.api.frame.Frame)` ### getLocalValues(int, Frame) `public final Object[] getLocalValues(int bytecodeIndex, Frame frame)`. Since 24.2. Returns a new array containing the current value of each local in the frame. This method should only be used for slow-path use cases (like frame introspection). Prefer reading locals directly in the bytecode (via `LoadLocal` operations or `LocalAccessor`) when possible. An operation can use this method by binding the bytecode node to a specialization parameter (via `@Bind("$bytecodeNode")`) and then invoking the method on the bytecode node. The order of the locals corresponds to the order in which they were created using one of the `createLocal()` overloads. It is up to the language to track the creation order. Parameters: `bytecodeIndex` `int`: the current bytecode index of the given frame. A valid bytecode index can be obtained by calling `BytecodeLocation.getBytecodeIndex()` or using @`Bind`("$bytecodeIndex") annotation. The value must be a partial evaluation constant. If the bytecode index is inconsistent with the state of the frame passed then the result of this method is unspecified. `frame` `Frame`: the frame to read locals from. Returns `Object[]`: an array of local values, using the representation described by `getLocalValue(int, Frame, int)`. See also: `GenerateBytecode.enableBlockScoping`. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getLocalValues(int,com.oracle.truffle.api.frame.Frame)` ### getLocalValues(FrameInstance) `public static Object[] getLocalValues(FrameInstance frameInstance)`. Since 24.2. Returns a new array containing the current value of each live local in the `frameInstance`. Parameters: `frameInstance` `FrameInstance`: the frame instance. Returns `Object[]`: a new array of local values, or `null` if the frame instance does not correspond to a `BytecodeRootNode` or its bytecode index cannot be determined. See also: `getLocalValues(int, Frame)`, `BytecodeFrame.get(FrameInstance, FrameInstance.FrameAccess)`. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getLocalValues(com.oracle.truffle.api.frame.FrameInstance)` ### getLocalValue(int, Frame, int) `public abstract Object getLocalValue(int bytecodeIndex, Frame frame, int localOffset)`. Since 24.2. Returns the current value of the local at offset `localOffset` in the frame. This method should be used for uncommon scenarios, like when a node needs to read a local directly from the frame. Prefer reading locals directly in the bytecode (via `LoadLocal` operations or `LocalAccessor`) when possible. This accessor does not respect the `GenerateBytecode.illegalLocalException()` attribute; an illegal frame slot is returned as `INVALID`. Parameters: `bytecodeIndex` `int`: the current bytecode index of the given frame. A valid bytecode index can be obtained by calling `BytecodeLocation.getBytecodeIndex()` or using @`Bind`("$bytecodeIndex") annotation. The value must be a partial evaluation constant. If the bytecode index is inconsistent with the state of the frame passed then the result of this method is unspecified. `frame` `Frame`: the frame to read locals from. `localOffset` `int`: the offset of the local. The offset should be in the range `[0, getLocalCount(bytecodeIndex))` (and may come from `BytecodeLocal.getLocalOffset()` or `LocalVariable.getLocalOffset()`). The value must be a partial evaluation constant. Returns `Object`: the current local value or `INVALID` for an illegal frame slot. See also: `GenerateBytecode.enableBlockScoping`, `BytecodeVersion.V2`. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getLocalValue(int,com.oracle.truffle.api.frame.Frame,int)` ### getLocalNames(int) `public final Object[] getLocalNames(int bytecodeIndex)`. Since 24.2. Returns a new array containing the slot name of locals, as provided during bytecode building. If a local is not allocated using a `createLocal` overload that takes a `name`, its name will be `null`. The order of the local names corresponds to the order in which the locals were created using one of the `createLocal()` overloads. It is up to the language to track the creation order. Parameters: `bytecodeIndex` `int`: the current bytecode index, used to determine liveness of locals. A valid bytecode index can be obtained by calling `BytecodeLocation.getBytecodeIndex()` or using @`Bind`("$bytecodeIndex") annotation. The value must be a partial evaluation constant. Returns `Object[]`: an array of local names. See also: `GenerateBytecode.enableBlockScoping`. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getLocalNames(int)` ### getLocalNames(FrameInstance) `public static Object[] getLocalNames(FrameInstance frameInstance)`. Since 24.2. Returns a new array containing the names of the live locals in the `frameInstance`. Parameters: `frameInstance` `FrameInstance`: the frame instance. Returns `Object[]`: a new array of names, or `null` if the frame instance does not correspond to a `BytecodeRootNode` or its bytecode index cannot be determined. See also: `getLocalNames(int)`, `BytecodeFrame.get(FrameInstance, FrameInstance.FrameAccess)`. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getLocalNames(com.oracle.truffle.api.frame.FrameInstance)` ### getLocalName(int, int) `public abstract Object getLocalName(int bytecodeIndex, int localOffset)`. Since 24.2. Returns the name of the local at the given `localOffset`, as provided during bytecode building. If a local is not allocated using a `createLocal` overload that takes a `name`, its name will be `null`. Parameters: `bytecodeIndex` `int`: the current bytecode index, used to determine liveness of locals. A valid bytecode index can be obtained by calling `BytecodeLocation.getBytecodeIndex()` or using @`Bind`("$bytecodeIndex") annotation. The value must be a partial evaluation constant. `localOffset` `int`: the offset of the local. The offset should be in the range `[0, getLocalCount(bytecodeIndex))` (and may come from `BytecodeLocal.getLocalOffset()` or `LocalVariable.getLocalOffset()`). The value must be a partial evaluation constant. Returns `Object`: the local name as a partial evaluation constant. See also: `GenerateBytecode.enableBlockScoping`. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getLocalName(int,int)` ### getLocalInfos(int) `public final Object[] getLocalInfos(int bytecodeIndex)`. Since 24.2. Returns a new array containing the infos of locals, as provided during bytecode building. If a local is not allocated using a `createLocal` overload that takes an `info`, its info will be `null`. The order of the local infos corresponds to the order in which the locals were created using one of the `createLocal()` overloads. It is up to the language to track the creation order. Parameters: `bytecodeIndex` `int`: the current bytecode index, used to determine liveness of locals. A valid bytecode index can be obtained by calling `BytecodeLocation.getBytecodeIndex()` or using @`Bind`("$bytecodeIndex") annotation. The value must be a partial evaluation constant. Returns `Object[]`: an array of local names. See also: `GenerateBytecode.enableBlockScoping`. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getLocalInfos(int)` ### getLocalInfo(int, int) `public abstract Object getLocalInfo(int bytecodeIndex, int localOffset)`. Since 24.2. Returns the info of a local, as provided during bytecode building. If a local is not allocated using a `createLocal` overload that takes an `info`, its info will be `null`. Parameters: `bytecodeIndex` `int`: bytecodeIndex the current bytecode index, used to determine liveness of locals. A valid bytecode index can be obtained by calling `BytecodeLocation.getBytecodeIndex()` or using @`Bind`("$bytecodeIndex") annotation. The value must be a partial evaluation constant. `localOffset` `int`: the offset of the local. The offset should be in the range `[0, getLocalCount(bytecodeIndex))` (and may come from `BytecodeLocal.getLocalOffset()` or `LocalVariable.getLocalOffset()`). The value must be a partial evaluation constant. Returns `Object`: the local info as a partial evaluation constant. See also: `GenerateBytecode.enableBlockScoping`. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getLocalInfo(int,int)` ### setLocalValues(int, Frame, Object[]) `public final void setLocalValues(int bytecodeIndex, Frame frame, Object[] values)`. Since 24.2. Updates the values of the live locals in the frame. This method should be used for uncommon scenarios, like setting locals in the prolog/epilog or from another root node. Prefer setting locals directly in the bytecode (via `StoreLocal` operations or `LocalRangeAccessor`) when possible. Parameters: `bytecodeIndex` `int`: the current bytecode index of the given frame. A valid bytecode index can be obtained by calling `BytecodeLocation.getBytecodeIndex()` or using @`Bind`("$bytecodeIndex") annotation. The value must be a partial evaluation constant. If the bytecode index is inconsistent with the state of the frame passed then the result of this method is unspecified. `frame` `Frame`: the frame to store the local values into. `values` `Object[]`: the values to store into the frame. The length of this array should match the number of live locals. See also: `GenerateBytecode.enableBlockScoping`. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#setLocalValues(int,com.oracle.truffle.api.frame.Frame,java.lang.Object[])` ### setLocalValues(FrameInstance, Object[]) `public static boolean setLocalValues(FrameInstance frameInstance, Object[] values)`. Since 24.2. Sets the current values of the live locals in the `frameInstance`. Parameters: `frameInstance` `FrameInstance`: the frame instance. Returns `boolean`: whether the locals could be set; `false` if the frame instance does not correspond to a `BytecodeRootNode` or its bytecode index cannot be determined. See also: `setLocalValues(int, Frame, Object[])`, `BytecodeFrame.get(FrameInstance, FrameInstance.FrameAccess)`. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#setLocalValues(com.oracle.truffle.api.frame.FrameInstance,java.lang.Object[])` ### copyLocalValues(int, Frame, Frame) `public final void copyLocalValues(int bytecodeIndex, Frame source, Frame destination)`. Since 24.2. Copies the values of the live locals from the source frame to the destination frame. The frames must have the same `descriptor` as this bytecode node. Parameters: `bytecodeIndex` `int`: the current bytecode index of the given frames. A valid bytecode index can be obtained by calling `BytecodeLocation.getBytecodeIndex()` or using @`Bind`("$bytecodeIndex") annotation. The value must be a partial evaluation constant. If the bytecode index is inconsistent with the state of the frames passed then the result of this method is unspecified. `source` `Frame`: the frame to copy locals from. `destination` `Frame`: the frame to copy locals into. See also: `GenerateBytecode.enableBlockScoping`. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#copyLocalValues(int,com.oracle.truffle.api.frame.Frame,com.oracle.truffle.api.frame.Frame)` ### copyLocalValues(int, Frame, …) `public final void copyLocalValues(int bytecodeIndex, Frame source, Frame destination, int localOffset, int localCount)`. Since 24.2. Copies a range of locals from the `source` frame to the `destination` frame. The frames must have the same `descriptor` as this bytecode node. Compared to `copyLocalValues(int, Frame, Frame)`, this method allows languages to selectively copy a subset of the frame's locals. For example, suppose that in addition to regular locals, a root node uses temporary locals for intermediate computations. Suppose also that the node needs to be able to compute the values of its regular locals (e.g., for frame introspection). This method can be used to only copy the regular locals and not the temporary locals -- assuming all of the regular locals were allocated (using `createLocal()`) before the temporary locals. Parameters: `bytecodeIndex` `int`: the current bytecode index of the given frames. A valid bytecode index can be obtained by calling `BytecodeLocation.getBytecodeIndex()` or using @`Bind`("$bytecodeIndex") annotation. The value must be a partial evaluation constant. If the bytecode index is inconsistent with the state of the frame passed then the result of this method is unspecified. `source` `Frame`: the frame to copy locals from. `destination` `Frame`: the frame to copy locals into. `localOffset` `int`: the offset of the first local to be copied. The offset should be in the range `[0, getLocalCount(bytecodeIndex))` (and may come from `BytecodeLocal.getLocalOffset()` or `LocalVariable.getLocalOffset()`). The value must be a partial evaluation constant. `localCount` `int`: the number of locals to copy. The value must be a partial evaluation constant. See also: `GenerateBytecode.enableBlockScoping`. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#copyLocalValues(int,com.oracle.truffle.api.frame.Frame,com.oracle.truffle.api.frame.Frame,int,int)` ### setLocalValue(int, Frame, …) `public abstract void setLocalValue(int bytecodeIndex, Frame frame, int localOffset, Object value)`. Since 24.2. Updates the current value of the local at index `localOffset` in the frame. This method should be used for uncommon scenarios, like setting a local in the prolog/epilog or from another root node. Prefer setting locals directly in the bytecode (via `StoreLocal` operations or `LocalAccessor`) when possible. Passing `INVALID` marks the frame slot illegal without changing its type profile, even when a default local value is configured. Passing Java `null` stores a valid Java `null` value using normal value profiling. These representations are also used by `getLocalValues(int, Frame)`, `setLocalValues(int, Frame, Object[])`, and both `copyLocalValues` overloads, so copying preserves illegal slots and null values. Passing a value identical (`==`) to the configured `default local value` restores that default without changing the local's type profile. This method will be generated by the Bytecode DSL. Do not override. Parameters: `bytecodeIndex` `int`: the current bytecode index of the given frame. A valid bytecode index can be obtained by calling `BytecodeLocation.getBytecodeIndex()` or using @`Bind`("$bytecodeIndex") annotation. The value must be a partial evaluation constant. If the bytecode index is inconsistent with the state of the frame passed then the result of this method is unspecified. `frame` `Frame`: the frame to store the local value into. `localOffset` `int`: the offset of the local. The offset should be in the range `[0, getLocalCount(bytecodeIndex))` (and may come from `BytecodeLocal.getLocalOffset()` or `LocalVariable.getLocalOffset()`). The value must be a partial evaluation constant. `value` `Object`: the value to store into the local. See also: `GenerateBytecode.enableBlockScoping`, `BytecodeVersion.V2`. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#setLocalValue(int,com.oracle.truffle.api.frame.Frame,int,java.lang.Object)` ### getLocalValueInternal(Frame, int, int) `protected abstract Object getLocalValueInternal(Frame frame, int localOffset, int localIndex)`. Since 24.2. Internal method to be implemented by generated code. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getLocalValueInternal(com.oracle.truffle.api.frame.Frame,int,int)` ### getLocalValueInternalBoolean(Frame, int, int) `protected boolean getLocalValueInternalBoolean(Frame frame, int localOffset, int localIndex) throws UnexpectedResultException`. Since 24.2. Internal method to be implemented by generated code. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getLocalValueInternalBoolean(com.oracle.truffle.api.frame.Frame,int,int)` ### getLocalValueInternalByte(Frame, int, int) `protected byte getLocalValueInternalByte(Frame frame, int localOffset, int localIndex) throws UnexpectedResultException`. Since 24.2. Internal method to be implemented by generated code. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getLocalValueInternalByte(com.oracle.truffle.api.frame.Frame,int,int)` ### getLocalValueInternalInt(Frame, int, int) `protected int getLocalValueInternalInt(Frame frame, int localOffset, int localIndex) throws UnexpectedResultException`. Since 24.2. Internal method to be implemented by generated code. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getLocalValueInternalInt(com.oracle.truffle.api.frame.Frame,int,int)` ### getLocalValueInternalLong(Frame, int, int) `protected long getLocalValueInternalLong(Frame frame, int localOffset, int localIndex) throws UnexpectedResultException`. Since 24.2. Internal method to be implemented by generated code. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getLocalValueInternalLong(com.oracle.truffle.api.frame.Frame,int,int)` ### getLocalValueInternalFloat(Frame, int, int) `protected float getLocalValueInternalFloat(Frame frame, int localOffset, int localIndex) throws UnexpectedResultException`. Since 24.2. Internal method to be implemented by generated code. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getLocalValueInternalFloat(com.oracle.truffle.api.frame.Frame,int,int)` ### getLocalValueInternalDouble(Frame, int, int) `protected double getLocalValueInternalDouble(Frame frame, int localOffset, int localIndex) throws UnexpectedResultException`. Since 24.2. Internal method to be implemented by generated code. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getLocalValueInternalDouble(com.oracle.truffle.api.frame.Frame,int,int)` ### setLocalValueInternal(Frame, int, …) `protected abstract void setLocalValueInternal(Frame frame, int localOffset, int localIndex, Object value)`. Since 24.2. Internal method to be implemented by generated code. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#setLocalValueInternal(com.oracle.truffle.api.frame.Frame,int,int,java.lang.Object)` ### setLocalValueInternalBoolean(Frame, int, …) `protected void setLocalValueInternalBoolean(Frame frame, int localOffset, int localIndex, boolean value)`. Since 24.2. Internal method to be implemented by generated code. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#setLocalValueInternalBoolean(com.oracle.truffle.api.frame.Frame,int,int,boolean)` ### setLocalValueInternalByte(Frame, int, …) `protected void setLocalValueInternalByte(Frame frame, int localOffset, int localIndex, byte value)`. Since 24.2. Internal method to be implemented by generated code. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#setLocalValueInternalByte(com.oracle.truffle.api.frame.Frame,int,int,byte)` ### setLocalValueInternalInt(Frame, int, …) `protected void setLocalValueInternalInt(Frame frame, int localOffset, int localIndex, int value)`. Since 24.2. Internal method to be implemented by generated code. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#setLocalValueInternalInt(com.oracle.truffle.api.frame.Frame,int,int,int)` ### setLocalValueInternalLong(Frame, int, …) `protected void setLocalValueInternalLong(Frame frame, int localOffset, int localIndex, long value)`. Since 24.2. Internal method to be implemented by generated code. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#setLocalValueInternalLong(com.oracle.truffle.api.frame.Frame,int,int,long)` ### setLocalValueInternalFloat(Frame, int, …) `protected void setLocalValueInternalFloat(Frame frame, int localOffset, int localIndex, float value)`. Since 24.2. Internal method to be implemented by generated code. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#setLocalValueInternalFloat(com.oracle.truffle.api.frame.Frame,int,int,float)` ### setLocalValueInternalDouble(Frame, int, …) `protected void setLocalValueInternalDouble(Frame frame, int localOffset, int localIndex, double value)`. Since 24.2. Internal method to be implemented by generated code. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#setLocalValueInternalDouble(com.oracle.truffle.api.frame.Frame,int,int,double)` ### clearLocalValueInternal(Frame, int, int) `protected abstract void clearLocalValueInternal(Frame frame, int localOffset, int localIndex)`. Since 24.2. Internal method to be implemented by generated code. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#clearLocalValueInternal(com.oracle.truffle.api.frame.Frame,int,int)` ### isLocalClearedInternal(Frame, int, int) `protected abstract boolean isLocalClearedInternal(Frame frame, int localOffset, int localIndex)`. Since 24.2. Internal method to be implemented by generated code. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#isLocalClearedInternal(com.oracle.truffle.api.frame.Frame,int,int)` ### getLocalNameInternal(int, int) `protected abstract Object getLocalNameInternal(int localOffset, int localIndex)`. Since 24.2. Internal method to be implemented by generated code. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getLocalNameInternal(int,int)` ### getLocalInfoInternal(int, int) `protected abstract Object getLocalInfoInternal(int localOffset, int localIndex)`. Since 24.2. Internal method to be implemented by generated code. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getLocalInfoInternal(int,int)` ### getLocalCount(int) `public abstract int getLocalCount(int bytecodeIndex)`. Since 24.2. Returns the number of live locals at the given `bytecodeIndex`. Parameters: `bytecodeIndex` `int`: the current bytecode index, used to determine liveness of locals. A valid bytecode index can be obtained by calling `BytecodeLocation.getBytecodeIndex()` or using @`Bind`("$bytecodeIndex") annotation. The value must be a partial evaluation constant. Returns `int`: the number of live locals as a partial evaluation constant. See also: `GenerateBytecode.enableBlockScoping`. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getLocalCount(int)` ### getLocals() `public abstract List getLocals()`. Since 24.2. Returns a list of all of the `local variables` with liveness info. Returns `List`: a list of locals. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getLocals()` ### setUncachedThreshold(int) `public abstract void setUncachedThreshold(int threshold)`. Since 24.2. Sets the number of invocations/resumptions or backward branches for which this interpreter executes uncached before transitioning to cached on the next such event. See `GenerateBytecode.defaultUncachedThreshold` for information about the default threshold and the meaning of different `threshold` values. This method should be called before executing the root node. It will not have any effect on an uncached interpreter that is currently executing, an interpreter that is already cached, or an interpreter that does not `enable uncached`. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#setUncachedThreshold(int)` ### getTier() `public abstract BytecodeTier getTier()`. Since 24.2. Returns the tier of this bytecode node. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#getTier()` ### dump() `public final String dump()`. Since 24.2. Convert this bytecode node to a string representation for debugging purposes. See also: `dump(BytecodeLocation)`. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#dump()` ### dump(int) `public final String dump(int bytecodeIndex)`. Since 24.2. Convert this bytecode node to a string representation for debugging purposes. Highlights the location at the given bytecode index. Parameters: `bytecodeIndex` `int`: an optional location to highlight in the dump. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#dump(int)` ### dump(BytecodeLocation) `public final String dump(BytecodeLocation highlightedLocation)`. Since 24.2. Convert this bytecode node to a string representation for debugging purposes. Highlights the given bytecode location. Parameters: `highlightedLocation` `BytecodeLocation`: an optional location to highlight in the dump. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#dump(com.oracle.truffle.api.bytecode.BytecodeLocation)` ### findInstruction(int) `protected abstract Instruction findInstruction(int bytecodeIndex)`. Since 24.2. Internal method to be implemented by generated code. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#findInstruction(int)` ### findBytecodeIndex(Frame, Node) `protected abstract int findBytecodeIndex(Frame frame, Node operationNode)`. Since 24.2. Internal method to be implemented by generated code. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#findBytecodeIndex(com.oracle.truffle.api.frame.Frame,com.oracle.truffle.api.nodes.Node)` ### findBytecodeIndex(FrameInstance) `protected abstract int findBytecodeIndex(FrameInstance frameInstance)`. Since 24.2. Internal method to be implemented by generated code. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#findBytecodeIndex(com.oracle.truffle.api.frame.FrameInstance)` ### translateBytecodeIndex(BytecodeNode, int) `protected abstract int translateBytecodeIndex(BytecodeNode newNode, int bytecodeIndex)`. Since 24.2. Internal method to be implemented by generated code. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#translateBytecodeIndex(com.oracle.truffle.api.bytecode.BytecodeNode,int)` ### validateBytecodeIndex(int) `protected abstract boolean validateBytecodeIndex(int bytecodeIndex)`. Since 24.2. Internal method to be implemented by generated code. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#validateBytecodeIndex(int)` ### findLocation(int) `protected final BytecodeLocation findLocation(int bytecodeIndex)`. Since 24.2. Internal method called by generated code. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#findLocation(int)` ### createTransition(BytecodeNode, int, …) `protected abstract BytecodeTransition createTransition(BytecodeNode oldBytecodeNode, int oldBytecodeIndex, BytecodeNode newBytecodeNode, int newBytecodeIndex, boolean wasCompiled)`. Since 25.1. Internal method to be implemented by generated code. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#createTransition(com.oracle.truffle.api.bytecode.BytecodeNode,int,com.oracle.truffle.api.bytecode.BytecodeNode,int,boolean)` ### createDefaultStackTraceElement(TruffleStackTraceElement) `protected static final Object createDefaultStackTraceElement(TruffleStackTraceElement e)`. Since 24.2. Internal method called by generated code. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#createDefaultStackTraceElement(com.oracle.truffle.api.TruffleStackTraceElement)` ### resolveFrameImpl(FrameInstance, FrameInstance.FrameAccess) `protected abstract Frame resolveFrameImpl(FrameInstance frameInstance, FrameInstance.FrameAccess access)`. Since 25.1. Internal method to be overridden by generated code. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#resolveFrameImpl(com.oracle.truffle.api.frame.FrameInstance,com.oracle.truffle.api.frame.FrameInstance.FrameAccess)` ### resolveFrameImpl(TruffleStackTraceElement) `protected Frame resolveFrameImpl(TruffleStackTraceElement element)`. Since 25.1. Internal method to be overridden by generated code. By default, frames are unavailable in stack trace elements unless `GenerateBytecode.captureFramesForTrace()` is set. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#resolveFrameImpl(com.oracle.truffle.api.TruffleStackTraceElement)` ### resolveNonVirtualFrameImpl(TruffleStackTraceElement) `protected Frame resolveNonVirtualFrameImpl(TruffleStackTraceElement element)`. Since 25.1. Internal method to be overridden by generated code. By default, frames are unavailable in stack trace elements unless `GenerateBytecode.captureFramesForTrace()` is set. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#resolveNonVirtualFrameImpl(com.oracle.truffle.api.TruffleStackTraceElement)` ### get(FrameInstance) `public static BytecodeNode get(FrameInstance frameInstance)`. Since 24.2. Gets the bytecode node for a given FrameInstance. Frame instances are invalid as soon as the execution of a frame is continued. A bytecode node can be used to materialize a `BytecodeLocation`, which can be used after the `FrameInstance` is no longer valid. Parameters: `frameInstance` `FrameInstance`: the frame instance. Returns `BytecodeNode`: the corresponding bytecode node or null if no node can be found. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#get(com.oracle.truffle.api.frame.FrameInstance)` ### get(Node) `public static BytecodeNode get(Node node)`. Since 24.2. Gets the bytecode location for a given Node, if it can be found in the parent chain. Parameters: `node` `Node`: the node, which must be a partial evaluation constant. Returns `BytecodeNode`: the corresponding bytecode location or null if no location can be found. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#get(com.oracle.truffle.api.nodes.Node)` ### get(TruffleStackTraceElement) `public static BytecodeNode get(TruffleStackTraceElement element)`. Since 24.2. Gets the bytecode location for a given `TruffleStackTraceElement`, if it can be found using the stack trace location. Parameters: `element` `TruffleStackTraceElement`: the stack trace element. Returns `BytecodeNode`: the corresponding bytecode location or null if no location can be found. Cite: `com/oracle/truffle/api/bytecode/BytecodeNode.html#get(com.oracle.truffle.api.TruffleStackTraceElement)` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ BytecodeParser [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java @FunctionalInterface public interface BytecodeParser ``` Functional interface containing a method to parse one or more nodes using a [`BytecodeBuilder`](com/oracle/truffle/api/bytecode/BytecodeBuilder.md). Implementations are commonly written as tree traversals. For example: ```java BytecodeRootNodes nodes = MyBytecodeRootNodeGen.create(BytecodeConfig.DEFAULT, b -> { MyTree myTree = ...; // parse source code to AST b.beginRoot(...); myTree.accept(new MyTreeVisitor(b)); b.endRoot(); }) ``` In the above example, the visitor can use the builder `b` to emit bytecode. The parser should be idempotent (i.e., it can be repeatedly invoked and produces the same result). This is because a parser can be invoked multiple times to [reparse](https://github.com/oracle/graal/blob/master/truffle/docs/bytecode_dsl/UserGuide.md#reparsing-metadata) nodes (e.g., to add source information). Additionally, if serialization is used, the parser should be free of most side effects. The only side effects permitted are field writes on the generated root nodes (since fields are serialized); all other side effects (e.g., non-builder method calls) will not be captured during serialization. Since the parser is kept alive for reparsing, any references it captures will be kept alive in the heap. To reduce memory footprint, it is recommended (where possible) to construct input data (e.g., a parse tree) inside the parser instead of capturing a reference to it. **Type parameters** - ``: the builder class of the bytecode root node ## Methods ### parse(T) `void parse(T builder)`. Since 24.2. The parse method. Should be idempotent and free of side-effects. Cite: `com/oracle/truffle/api/bytecode/BytecodeParser.html#parse(T)` # ◇ BytecodeRootNode [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java public interface BytecodeRootNode ``` Base interface to be implemented by the bytecode root node of a Bytecode DSL interpreter. The bytecode root node should extend [`com.oracle.truffle.api.nodes.RootNode`](com/oracle/truffle/api/nodes/RootNode.md) and be annotated with [`@GenerateBytecode`](com/oracle/truffle/api/bytecode/GenerateBytecode.md). The current bytecode root node can be bound inside [`operations`](com/oracle/truffle/api/bytecode/Operation.md) using `@Bind`. For example, if the bytecode root node class is `MyBytecodeRootNode`, it can be bound using `@Bind MyBytecodeRootNode root`. Bytecode root nodes can declare a [`com.oracle.truffle.api.dsl.TypeSystemReference`](com/oracle/truffle/api/dsl/TypeSystemReference.md) that will be inherited by all declared operations (including operation proxies). Operations can also declare their own type system references to override the root type system. **See also** - [`GenerateBytecode`](com/oracle/truffle/api/bytecode/GenerateBytecode.md) ## Methods ### execute(VirtualFrame) `Object execute(VirtualFrame frame)`. Since 24.2. Entrypoint to the root node. This method will be generated by the Bytecode DSL. Do not override. Parameters: `frame` `VirtualFrame`: the frame used for execution. Returns `Object`: the value returned by the root node. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNode.html#execute(com.oracle.truffle.api.frame.VirtualFrame)` ### interceptIncomingValue(Object) `default Object interceptIncomingValue(Object value)`. Since 25.2. Optional hook invoked to convert a value received from tag instrumentation before it resumes guest-language execution. Instruments can introduce values by returning a non-`null` value from an unwind callback such as `ExecutionEventNode.onUnwind(VirtualFrame, Object)` or `ExecutionEventListener.onUnwind(EventContext, VirtualFrame, Object)`. Such values are interop values and may need to be converted to a representation supported by the guest language. Parameters: `value` `Object`: the interop value received from tag instrumentation. Returns `Object`: the value to resume execution with. See also: `EventContext.createUnwind(Object)`. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNode.html#interceptIncomingValue(java.lang.Object)` ### interceptOutgoingValue(Object) `default Object interceptOutgoingValue(Object value)`. Since 25.2. Optional hook invoked to convert every guest-language value before it is exposed to tag instrumentation. This can be used to replace an internal representation with an interop-capable value. The original value continues to be used for guest-language execution. The returned value must be an interop value or `null`. For values reported after successful execution of a standard tag, this requirement is checked when Java assertions are enabled, and a violation results in a [`ClassCastException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ClassCastException.html). Values not subject to this check are passed to tag instrumentation unchanged. The hook is not invoked when the instrumented operation does not produce a value. Parameters: `value` `Object`: the guest-language value being exposed to tag instrumentation. Returns `Object`: the interop value to report to tag instrumentation. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNode.html#interceptOutgoingValue(java.lang.Object)` ### getInstrumentationNodeObject(TagTreeNode) `default Object getInstrumentationNodeObject(TagTreeNode node)`. Since 25.6. Supplies the node object for a tagged bytecode region. The generated instrumentation node delegates `InstrumentableNode.getNodeObject()` to this hook. The default returns `null`, which instrumentation treats as an empty node object. Use the supplied node's tags and source sections to identify the region and expose language metadata. Source sections can be absent if source information has not been materialized or the parser did not supply a source section. The result must satisfy the interop and tag-specific contracts of `InstrumentableNode.getNodeObject()`. For example, `StandardTags.ReadVariableTag` and `StandardTags.WriteVariableTag` require a node object with the variable name. The same restrictions and usage details of `InstrumentableNode.getNodeObject()` also apply to this method. Since bytecode indices are not stable, they should not be used to identify the node's code region (unless accompanied by a `BytecodeNode`). Parameters: `node` `TagTreeNode`: the tagged region belonging to this root. Returns `Object`: an interop node object, or `null` if no properties are available. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNode.html#getInstrumentationNodeObject(com.oracle.truffle.api.bytecode.TagTreeNode)` ### interceptControlFlowException(ControlFlowException, VirtualFrame, …) `default Object interceptControlFlowException(ControlFlowException ex, VirtualFrame frame, BytecodeNode bytecodeNode, int bytecodeIndex) throws Throwable`. Since 24.2. Optional hook invoked when a `ControlFlowException` is thrown during execution. This hook is not invoked for exceptions configured by `GenerateBytecode.unwindExceptions()`. It can do one of four things: It can return a value. The value will be returned from the root node (this can be used to implement early returns).; It can throw the same or a different `ControlFlowException`. The thrown exception will be thrown from the root node.; It can throw an `AbstractTruffleException`. The thrown exception will be forwarded to the guest code for handling.; It can throw an internal error, which will be intercepted by `interceptInternalException`. Parameters: `ex` `ControlFlowException`: the control flow exception. `frame` `VirtualFrame`: the frame at the point the exception was thrown. `bytecodeNode` `BytecodeNode`: the bytecode node executing when the exception was thrown. `bytecodeIndex` `int`: the bytecode index of the instruction that caused the exception. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNode.html#interceptControlFlowException(com.oracle.truffle.api.nodes.ControlFlowException,com.oracle.truffle.api.frame.VirtualFrame,com.oracle.truffle.api.bytecode.BytecodeNode,int)` ### interceptInternalException(Throwable, VirtualFrame, …) `default Throwable interceptInternalException(Throwable t, VirtualFrame frame, BytecodeNode bytecodeNode, int bytecodeIndex)`. Since 24.2. Optional hook invoked when an internal exception (i.e., anything other than `AbstractTruffleException` or `ControlFlowException`) is thrown during execution. This hook is not invoked for exceptions configured by `GenerateBytecode.unwindExceptions()`. It can be used to convert other exceptions into guest-language exceptions that can be handled by guest code. For example, if a Java [`StackOverflowError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/StackOverflowError.html) is thrown, this hook can be used to return a guest-language equivalent exception that the guest code understands. If the return value is an `AbstractTruffleException`, it will be forwarded to the guest code for handling. The exception will also be intercepted by `interceptTruffleException`. If the return value is not an `AbstractTruffleException`, it will be rethrown. Thus, if an internal error cannot be converted to a guest exception, it can simply be returned. Parameters: `t` `Throwable`: the internal exception. `frame` `VirtualFrame`: the frame at the point the exception was thrown. `bytecodeNode` `BytecodeNode`: the bytecode node executing when the exception was thrown. `bytecodeIndex` `int`: the bytecode index of the instruction that caused the exception. Returns `Throwable`: an equivalent guest-language exception or an exception to be rethrown. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNode.html#interceptInternalException(java.lang.Throwable,com.oracle.truffle.api.frame.VirtualFrame,com.oracle.truffle.api.bytecode.BytecodeNode,int)` ### interceptTruffleException(AbstractTruffleException, VirtualFrame, …) `default AbstractTruffleException interceptTruffleException(AbstractTruffleException ex, VirtualFrame frame, BytecodeNode bytecodeNode, int bytecodeIndex)`. Since 24.2. Optional hook invoked when an `AbstractTruffleException` is thrown during execution. This hook is not invoked for exceptions configured by `GenerateBytecode.unwindExceptions()`. It can be used to preprocess other exceptions or replace them with another exception before they are handled. Parameters: `ex` `AbstractTruffleException`: the Truffle exception. `frame` `VirtualFrame`: the frame at the point the exception was thrown. `bytecodeNode` `BytecodeNode`: the bytecode node executing when the exception was thrown. `bytecodeIndex` `int`: the bytecode index of the instruction that caused the exception. Returns `AbstractTruffleException`: the Truffle exception to be handled by guest code. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNode.html#interceptTruffleException(com.oracle.truffle.api.exception.AbstractTruffleException,com.oracle.truffle.api.frame.VirtualFrame,com.oracle.truffle.api.bytecode.BytecodeNode,int)` ### traceTransition(BytecodeTransition, Frame) `default void traceTransition(BytecodeTransition transition, Frame frame)`. Since 25.1. Optional hook invoked when executing bytecode transitions from one bytecode node to another. Transitions are emitted only for on-stack changes observed during execution, for example when moving from uncached to cached tier, when reparsing updates the bytecode due to `BytecodeConfig` changes and execution continues in the new bytecode node, or when deoptimization transfers execution from Truffle runtime-compiled code back to the interpreter. The frame is only valid during the invocation of this method. The transition object may outlive the execution of this method. Engine-level transition logging (via `engine.TraceBytecodeTransition`) is always performed independently of this hook. Override this method only to add interpreter-specific behaviour on top of the engine logging. Parameters: `transition` `BytecodeTransition`: describes the transition that occurred. `frame` `Frame`: the current execution frame. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNode.html#traceTransition(com.oracle.truffle.api.bytecode.BytecodeTransition,com.oracle.truffle.api.frame.Frame)` ### getBytecodeNode() `default BytecodeNode getBytecodeNode()`. Since 24.2. Returns the current bytecode node. Note that the bytecode may change at any point in time. This method will be generated by the Bytecode DSL. Do not override. Returns `BytecodeNode`: the current bytecode node. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNode.html#getBytecodeNode()` ### getRootNodes() `default BytecodeRootNodes getRootNodes()`. Since 24.2. Returns the `BytecodeRootNodes` instance associated with this root node. This method will be generated by the Bytecode DSL. Do not override. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNode.html#getRootNodes()` ### getStartLocation() `default BytecodeLocation getStartLocation()`. Since 24.2. Returns the `location` associated with the start of this root node. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNode.html#getStartLocation()` ### getSource() `default Source getSource()`. Since 25.1. Returns the source for this root node. If no source information is available, returns `null`. This method will be generated by the Bytecode DSL. Do not override. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNode.html#getSource()` ### ensureSourceSection() `default SourceSection ensureSourceSection()`. Since 24.2. Returns the source section for this root node and materializes source information if it was not yet materialized. See also: `BytecodeNode.ensureSourceInformation()`. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNode.html#ensureSourceSection()` ### ensureSourceSectionWithContent() `default SourceSection ensureSourceSectionWithContent()`. Since 25.1. Returns the source section for this root node and materializes source information with content if it was not yet materialized. This method can only be used if the interpreter declares a `source content supplier`. See also: `BytecodeNode.ensureSourceInformationWithContent()`. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNode.html#ensureSourceSectionWithContent()` ### dump() `default String dump()`. Since 24.2. Helper method to dump the root node's bytecode. Returns `String`: a string representation of the bytecode. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNode.html#dump()` # ◆ BytecodeRootNodes [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java public abstract class BytecodeRootNodes ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `BytecodeRootNodes` A [`BytecodeRootNodes`](com/oracle/truffle/api/bytecode/BytecodeRootNodes.md) instance encapsulates one or more bytecode root nodes produced from a single parse. To reduce interpreter footprint, it supports on-demand reparsing to compute source and instrumentation metadata. This class will be overridden by the Bytecode DSL. Do not override manually. **Type parameters** - ``: the type of the bytecode root node ## Fields ### TOKEN `protected static final Object TOKEN`. Since 24.2. A singleton object used to ensure certain Bytecode DSL APIs are only used by generated code. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNodes.html#TOKEN` ### nodes `protected T[] nodes`. Since 24.2. The array of parsed nodes. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNodes.html#nodes` ## Constructors ### BytecodeRootNodes(Object, BytecodeParser) `protected BytecodeRootNodes(Object token, BytecodeParser parser)`. Since 24.2. Default constructor for a `BytecodeBuilder`. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNodes.html#(java.lang.Object,com.oracle.truffle.api.bytecode.BytecodeParser)` ## Methods ### getNodes() `public final List getNodes()`. Since 24.2. Returns the list of bytecode root nodes. The order of the list corresponds to the order of `beginRoot(...)` calls on the builder. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNodes.html#getNodes()` ### getNode(int) `public final T getNode(int i)`. Since 24.2. Returns the bytecode root node at index `i`. The order of the list corresponds to the order of `beginRoot(...)` calls on the builder. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNodes.html#getNode(int)` ### count() `public final int count()`. Since 24.2. Returns the number of root nodes produced from the parse. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNodes.html#count()` ### getParser() `protected final BytecodeParser getParser()`. Since 24.2. Returns the parser used to parse the root nodes. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNodes.html#getParser()` ### update(BytecodeConfig) `public final boolean update(BytecodeConfig config)`. Since 24.2. Updates the configuration for the given bytecode nodes. If the new configuration requires more information (e.g., sources, instrumentation or tags), this method may trigger a reparse to obtain it. **Performance considerations:** Updating and adding instrumentations or tags is a costly operation and requires reparsing all `root nodes` of a `BytecodeRootNodes` unit. Reparsing and modifying the generated bytecodes will also deoptimize and invalidate all currently optimized code of the reparsed root nodes. It also may or may not reset all profiling feedback gathered so far. Updating and adding just source information is a much less expensive operation and does not require any invalidation, but also requires to reparse all root nodes. Since compiled code is not invalidated when source information is added (and hence the `BytecodeNode` is not updated), lazily updated source information should not be accessed in compiled code. **Usage in compiled code**: This method may be used in compiled code, but the bytecode config must be a `partial evaluation constant`. If the bytecode config is changed in compiled code then `deoptimization` will be triggered. If an update does not require any changes then this operation will be a no-op in compiled code. In the interpreter it is also reasonably fast (a read and comparison of a volatile field), so it should reasonable to call this method on the fast path (e.g., in the `prolog`). Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNodes.html#update(com.oracle.truffle.api.bytecode.BytecodeConfig)` ### updateImpl(BytecodeConfigEncoder, long) `protected abstract boolean updateImpl(BytecodeConfigEncoder encoder, long encoding)`. Since 24.2. Implementation of reparse. This method will be generated by the Bytecode DSL. Do not override. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNodes.html#updateImpl(com.oracle.truffle.api.bytecode.BytecodeConfigEncoder,long)` ### serialize(DataOutput, BytecodeSerializer) `@Deprecated(since = "25.7") public void serialize(DataOutput buffer, BytecodeSerializer callback) throws IOException`. Since 24.2. Deprecated since 25.7. Use `serializeBuilderBytecode`. Serializes builder bytecode for these nodes. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNodes.html#serialize(java.io.DataOutput,com.oracle.truffle.api.bytecode.serialization.BytecodeSerializer)` ### serializeBuilderBytecode(DataOutput, BytecodeSerializer) `public void serializeBuilderBytecode(DataOutput buffer, BytecodeSerializer callback) throws IOException`. Since 25.7. Serializes the nodes as a sequence of builder calls, including all optional metadata (e.g., source information), so the nodes can be deserialized with any configuration or reparsed later when more metadata is requested. This method will always fail unless serialization is `enabled`. Unlike `BytecodeDescriptor.serializeBuilderBytecode`, this method serializes the nodes using their current field values. This method will be overridden by the Bytecode DSL. Do not override. Parameters: `buffer` `DataOutput`: The buffer to write the builder payload to. `callback` `BytecodeSerializer`: A language-defined method for serializing language constants. Throws: `IOException`: if an I/O error occurs with the buffer. See also: `serializeExecutionBytecode`. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNodes.html#serializeBuilderBytecode(java.io.DataOutput,com.oracle.truffle.api.bytecode.serialization.BytecodeSerializer)` ### serializeExecutionBytecode(DataOutput, BytecodeConfig, BytecodeSerializer) `public void serializeExecutionBytecode(DataOutput buffer, BytecodeConfig config, BytecodeSerializer callback) throws IOException`. Since 25.7. Serializes execution bytecode and its metadata for the requested `config`. This method will always fail unless serialization is `enabled`. The output contains only the execution bytecode payload. A corresponding builder payload must be produced separately using `serializeBuilderBytecode` and supplied during deserialization to support reparsing. Execution bytecode is serialized in an unquickened form and does not preserve execution profiles. **Since execution bytecode skips builder validation during deserialization, it should only be used in trusted environments**. Each payload must be independently decodable. If constant object identity matters, its identity must be encoded consistently across both payloads, for example by sharing serializer state that assigns identity indices to constants. To produce the execution bytecode representation, this method reruns the stored parser to construct a temporary representation with the requested configuration. Serialization does not update the live bytecodes or their configuration. Unlike `BytecodeDescriptor.serializeExecutionBytecode`, this method serializes the nodes using their current field values. This method will be overridden by the Bytecode DSL. Do not override. Parameters: `buffer` `DataOutput`: The buffer to write the execution bytecode payload to. `config` `BytecodeConfig`: The target configuration for execution bytecode. `callback` `BytecodeSerializer`: A language-defined method for serializing language constants. Throws: `IOException`: if an I/O error occurs with the buffer. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNodes.html#serializeExecutionBytecode(java.io.DataOutput,com.oracle.truffle.api.bytecode.BytecodeConfig,com.oracle.truffle.api.bytecode.serialization.BytecodeSerializer)` ### ensureSourceInformation() `public final boolean ensureSourceInformation()`. Since 24.2. Ensures that sources are available, reparsing if necessary. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNodes.html#ensureSourceInformation()` ### ensureSourceInformationWithContent() `public boolean ensureSourceInformationWithContent()`. Since 25.1. Ensures that sources are available (see `ensureSourceInformation()`) and that content is loaded. If the interpreter does not declare a `source content supplier`, this method is equivalent to `ensureSourceInformation`. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNodes.html#ensureSourceInformationWithContent()` ### ensureComplete() `public final boolean ensureComplete()`. Since 24.2. Ensures that all sources and instrumentation metadata is available, reparsing if necessary. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNodes.html#ensureComplete()` ### addInstructionTracer(InstructionTracer) `public void addInstructionTracer(InstructionTracer tracer)`. Since 25.1. Registers an `InstructionTracer` for this `BytecodeRootNodes` instance. This is a local variant of `BytecodeDescriptor.addInstructionTracer(TruffleLanguage, InstructionTracer)`: it only affects the root nodes contained in this `BytecodeRootNodes` object, not all bytecode roots for the entire language. Tracer invocation happens on the language execution thread, at instruction granularity, and may run at very high frequency. Implementations should avoid unnecessary allocation or blocking. The same tracer instance can only be attached once. If the tracer is already installed for this `BytecodeRootNodes` instance, then this method has no effect. The order in which multiple tracers are invoked is unspecified. If this bytecode interpreter was generated without instruction tracing support (for example using `@GenerateBytecode(enableInstructionTracing = false)`), this method throws [`UnsupportedOperationException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/UnsupportedOperationException.html). Parameters: `tracer` `InstructionTracer`: the tracer to install. Throws: `IllegalArgumentException` (unchecked): if `tracer` is exclusive to a different `BytecodeDescriptor` (see `InstructionTracer.getExclusiveBytecodeDescriptor()`). `UnsupportedOperationException` (unchecked): if instruction tracing is not enabled for this interpreter. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNodes.html#addInstructionTracer(com.oracle.truffle.api.bytecode.InstructionTracer)` ### removeInstructionTracer(InstructionTracer) `public void removeInstructionTracer(InstructionTracer tracer)`. Since 25.1. Unregisters a previously installed `InstructionTracer` from this `BytecodeRootNodes` instance. Note that currently when all instruction tracers were removed, the trace instructions remain in the bytecode. This may be improved in the future. If this bytecode interpreter was generated without instruction tracing support (for example using `@GenerateBytecode(enableInstructionTracing = false)`), this method throws [`UnsupportedOperationException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/UnsupportedOperationException.html). Parameters: `tracer` `InstructionTracer`: the tracer to remove. Throws: `IllegalArgumentException` (unchecked): if `tracer` is exclusive to a different `BytecodeDescriptor` (see `InstructionTracer.getExclusiveBytecodeDescriptor()`). `UnsupportedOperationException` (unchecked): if instruction tracing is not enabled for this interpreter. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNodes.html#removeInstructionTracer(com.oracle.truffle.api.bytecode.InstructionTracer)` ### updateGlobalInstructionTracers(InstructionTracer[]) `protected void updateGlobalInstructionTracers(InstructionTracer[] tracers)`. Since 25.1. Internal callback to the generated code to notify when global instruction tracers change. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNodes.html#updateGlobalInstructionTracers(com.oracle.truffle.api.bytecode.InstructionTracer[])` ### toString() `public String toString()`. Since 24.2. Returns a string representation of a `BytecodeRootNodes`. Overrides `toString()`. Cite: `com/oracle/truffle/api/bytecode/BytecodeRootNodes.html#toString()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ BytecodeSupport [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java public final class BytecodeSupport ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `BytecodeSupport` Contains code to support Bytecode DSL interpreters. This code should not be used directly by language implementations. ## Nested types - [`BytecodeSupport.CloneReferenceList`](com/oracle/truffle/api/bytecode/BytecodeSupport.CloneReferenceList.md) (class): Special list to weakly keep track of clones. - [`BytecodeSupport.ConstantsBuffer`](com/oracle/truffle/api/bytecode/BytecodeSupport.ConstantsBuffer.md) (class): Specialized reusable and allocation-free buffer for constants. ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ BytecodeSupport.CloneReferenceList [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. Nested in [`BytecodeSupport`](com/oracle/truffle/api/bytecode/BytecodeSupport.md). ```java public static final class BytecodeSupport.CloneReferenceList ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `CloneReferenceList` Special list to weakly keep track of clones. Assumes all operations run under a lock. Do not use directly. We deliberately do not use an memory intensive event queue here, we might leave around a few empty references here and there. ## Constructors ### CloneReferenceList() `public CloneReferenceList()`. Declared by the compiler. Creates a new CloneReferenceList instance. Cite: `com/oracle/truffle/api/bytecode/BytecodeSupport.CloneReferenceList.html#()` ## Methods ### add(T) `public void add(T reference)`. Since 24.2. Adds a new reference to the list. Note references cannot be removed. Cite: `com/oracle/truffle/api/bytecode/BytecodeSupport.CloneReferenceList.html#add(T)` ### forEach(Consumer) `public void forEach(Consumer forEach)`. Since 24.2. Walks all references contained in the list. Cite: `com/oracle/truffle/api/bytecode/BytecodeSupport.CloneReferenceList.html#forEach(java.util.function.Consumer)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ BytecodeSupport.ConstantsBuffer [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 25.0. Nested in [`BytecodeSupport`](com/oracle/truffle/api/bytecode/BytecodeSupport.md). ```java public static final class BytecodeSupport.ConstantsBuffer ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `ConstantsBuffer` Specialized reusable and allocation-free buffer for constants. The first `8` literals are stored linearly in `constants[]`. Once that threshold is crossed, all literals are also entered into an open-address hash table (`keys[]/values[]`) so that subsequent look-ups run in amortised O(1) without allocating any [`java.util.Map.Entry`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/Map.Entry.html) objects. After the client has finished emitting a method it must call [`materialize()`](com/oracle/truffle/api/bytecode/BytecodeSupport.ConstantsBuffer.md#materialize%28%29) to obtain an immutable snapshot of the constant pool for that method. The buffer can then be filled again without further allocations. Call [`clear()`](com/oracle/truffle/api/bytecode/BytecodeSupport.ConstantsBuffer.md#clear%28%29) at the end of using this buffer if you want to release the object references or down-size the backing arrays. Constants are deduplicated by [`Object.equals(Object)`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29). [`Float`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Float.html) and [`Double`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Double.html) are the exception: they are compared by their raw bits, so distinct NaN payloads stay distinct. `+0.0` and `-0.0` stay distinct as well. **Not thread-safe.** Intended for use in generated code. Do not use directly. ## Constructors ### ConstantsBuffer() `public ConstantsBuffer()`. Cite: `com/oracle/truffle/api/bytecode/BytecodeSupport.ConstantsBuffer.html#()` ## Methods ### add(Object) `public int add(Object c)`. Since 25.0. Inserts `constant` (non-`null`) and returns its pool index. If an equal constant is already present, its existing index is returned. [`Float`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Float.html) and [`Double`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Double.html) constants compare by raw bits rather than [`Object.equals(Object)`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29). Throws: `NullPointerException` (unchecked): if `constant` is `null`. Cite: `com/oracle/truffle/api/bytecode/BytecodeSupport.ConstantsBuffer.html#add(java.lang.Object)` ### addNull() `public int addNull()`. Since 25.0. Inserts a constant without value and returns its index. The added null values are intended to be later patched after `materialization`. The client must ensure that the reserved null slots do not contain duplicates already contained in the materialized constants array. Cite: `com/oracle/truffle/api/bytecode/BytecodeSupport.ConstantsBuffer.html#addNull()` ### materialize() `public Object[] materialize()`. Since 25.0. Copies the internal `constants[]` array and returns it. All auxiliary data structures are reset so that the buffer is ready for the next use. Note that this implementation deliberately does not clear all references contained in the buffer. If all references should be cleared, then `clear()` should be called after materialization. Returns `Object[]`: a freshly allocated array of exactly `size()` elements, never `null`. Cite: `com/oracle/truffle/api/bytecode/BytecodeSupport.ConstantsBuffer.html#materialize()` ### create() `public Object[] create()`. Cite: `com/oracle/truffle/api/bytecode/BytecodeSupport.ConstantsBuffer.html#create()` ### clear() `public void clear()`. Since 25.0. Clears all object references held in this buffer. If the pool had grown beyond `512` constants its internal arrays are replaced by new arrays of that bounded size; otherwise the existing arrays are reused. The buffer must be materialised before it can be cleared. Throws: `IllegalStateException` (unchecked): if `materialize()` has not been called since the last insertion. Cite: `com/oracle/truffle/api/bytecode/BytecodeSupport.ConstantsBuffer.html#clear()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ≡ BytecodeTier [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Enum class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java public enum BytecodeTier ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html) > `BytecodeTier` Represents the tier of a given [`BytecodeNode`](com/oracle/truffle/api/bytecode/BytecodeNode.md). ## Enum constants ### UNCACHED `UNCACHED`. Since 24.2. The uncached bytecode tier does not collect profiling feedback. This means that the node was either never executed or the `uncached threshold` did not yet reach zero. Cite: `com/oracle/truffle/api/bytecode/BytecodeTier.html#UNCACHED` ### CACHED `CACHED`. Since 24.2. The cached bytecode tier does collect profiling feedback. This means that the bytecode interpreter is already collecting profiling information. Cite: `com/oracle/truffle/api/bytecode/BytecodeTier.html#CACHED` ## Methods ### values() `public static BytecodeTier[] values()`. Returns the enum constants in declaration order. Returns `BytecodeTier[]`: Returns the enum constants in declaration order. Cite: `com/oracle/truffle/api/bytecode/BytecodeTier.html#values()` ### valueOf(String) `public static BytecodeTier valueOf(String name)`. Returns the enum constant with the given name. Parameters: `name` `String`: The exact name of the enum constant. Returns `BytecodeTier`: Returns the enum constant with the given name. Cite: `com/oracle/truffle/api/bytecode/BytecodeTier.html#valueOf(java.lang.String)` ## Inherited members - From class [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#clone%28%29), [`compareTo`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#compareTo%28E%29), [`describeConstable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#describeConstable%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#finalize%28%29), [`getDeclaringClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#getDeclaringClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#hashCode%28%29), [`name`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#name%28%29), [`ordinal`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#ordinal%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#toString%28%29), [`valueOf`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#valueOf%28java.lang.Class,java.lang.String%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ BytecodeTransition [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 25.1. ```java public abstract class BytecodeTransition ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `BytecodeTransition` Encapsulates information about a transition of the bytecode interpreter from one bytecode node to another. Transitions can be intercepted by overriding [`BytecodeRootNode.traceTransition(BytecodeTransition, Frame)`](com/oracle/truffle/api/bytecode/BytecodeRootNode.md#traceTransition%28com.oracle.truffle.api.bytecode.BytecodeTransition,com.oracle.truffle.api.frame.Frame%29). Transition kinds are not mutually exclusive; for example, a single transition can simultaneously report [`isBytecodeUpdate()`](com/oracle/truffle/api/bytecode/BytecodeTransition.md#isBytecodeUpdate%28%29) and [`isTransferToInterpreter()`](com/oracle/truffle/api/bytecode/BytecodeTransition.md#isTransferToInterpreter%28%29). Deoptimization transitions report precise bytecode locations for compilation roots and continuation resumes. If a Bytecode DSL root is inlined into another compiled root, a deoptimization in that inlined root may be reported at the enclosing compilation root instead of the inlined root. ## Constructors ### BytecodeTransition(Object) `protected BytecodeTransition(Object token)`. Since 25.1. Internal constructor for generated code. Do not use. Cite: `com/oracle/truffle/api/bytecode/BytecodeTransition.html#(java.lang.Object)` ## Methods ### isBytecodeUpdate() `public abstract boolean isBytecodeUpdate()`. Since 25.1. Returns `true` if bytecode metadata or instructions changed for this transition, e.g. due to a tier change, instrumentation update, or tag update. Cite: `com/oracle/truffle/api/bytecode/BytecodeTransition.html#isBytecodeUpdate()` ### isTransferToInterpreter() `public abstract boolean isTransferToInterpreter()`. Since 25.1. Returns `true` if this transition was triggered by a deoptimization from compiled code. A deoptimization in an inlined Bytecode DSL root may not create a separate transition for that inlined root. In such cases, the transition may instead be reported for the enclosing compilation root. Cite: `com/oracle/truffle/api/bytecode/BytecodeTransition.html#isTransferToInterpreter()` ### getAddedTags() `public abstract Set> getAddedTags()`. Since 25.1. Returns tags that were newly added by this transition. This set is typically non-empty only for `isBytecodeUpdate()` transitions. Cite: `com/oracle/truffle/api/bytecode/BytecodeTransition.html#getAddedTags()` ### getAddedInstrumentations() `public abstract Set> getAddedInstrumentations()`. Since 25.1. Returns instrumentations that were newly added by this transition. This set is typically non-empty only for `isBytecodeUpdate()` transitions. Cite: `com/oracle/truffle/api/bytecode/BytecodeTransition.html#getAddedInstrumentations()` ### getOldLocation() `public abstract BytecodeLocation getOldLocation()`. Since 25.1. Returns the bytecode location before the transition. Cite: `com/oracle/truffle/api/bytecode/BytecodeTransition.html#getOldLocation()` ### getNewLocation() `public abstract BytecodeLocation getNewLocation()`. Since 25.1. Returns the bytecode location after the transition. Cite: `com/oracle/truffle/api/bytecode/BytecodeTransition.html#getNewLocation()` ### toString() `public String toString()`. Overrides `toString()`. Cite: `com/oracle/truffle/api/bytecode/BytecodeTransition.html#toString()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ≡ BytecodeVersion [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Enum class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 25.7. ```java public enum BytecodeVersion ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html) > `BytecodeVersion` Bytecode DSL behaviour versions selectable through [`GenerateBytecode.version()`](com/oracle/truffle/api/bytecode/GenerateBytecode.md#version%28%29). Versions distinguish breaking behaviour changes that require migration of language implementations. They do not identify Truffle releases or version internal implementation details, optimizations, or performance changes. ## Enum constants ### V1 `V1`. Since 25.7. Original Bytecode DSL behaviour on initial release. Support will be removed in release 25.8. Cite: `com/oracle/truffle/api/bytecode/BytecodeVersion.html#V1` ### V2 `V2`. Since 25.7. Distinguishes illegal locals from valid null values in the `BytecodeNode` local APIs. `BytecodeNode.getLocalValue(int, Frame, int)` returns `BytecodeNode.INVALID` for an illegal slot instead of `null`. Java `null` continues to represent a null value.; `BytecodeNode.setLocalValue(int, Frame, int, Object)` marks a slot illegal when passed `INVALID` instead of storing `null`. Passing `null` continues to store a null value.; The bulk getters and setters use the same representation. Both `BytecodeNode.copyLocalValues` overloads preserve illegal slots and null values. To migrate, replace comparisons against `null` that detect illegal locals with comparisons against `BytecodeNode.INVALID`. Keep comparisons against `null` that detect null values. Pass `INVALID` when you intend to mark a slot illegal. Ordinary bytecode local loads and stores and `LocalAccessor` retain their behaviour. See also: `BytecodeNode.INVALID`, `BytecodeNode.getLocalValues(int, Frame)`, `BytecodeNode.setLocalValues(int, Frame, Object[])`, `BytecodeNode.copyLocalValues(int, Frame, Frame)`. Cite: `com/oracle/truffle/api/bytecode/BytecodeVersion.html#V2` ### LATEST `LATEST`. Since 25.7. The newest supported Bytecode DSL behaviour version. Using this constant explicitly opts into breaking behaviour changes when recompiling against a newer Truffle release. This constant should not be used in production language implementations; select an explicit version instead. See also: `GenerateBytecode.version()`. Cite: `com/oracle/truffle/api/bytecode/BytecodeVersion.html#LATEST` ## Methods ### values() `public static BytecodeVersion[] values()`. Returns the enum constants in declaration order. Returns `BytecodeVersion[]`: Returns the enum constants in declaration order. Cite: `com/oracle/truffle/api/bytecode/BytecodeVersion.html#values()` ### valueOf(String) `public static BytecodeVersion valueOf(String name)`. Returns the enum constant with the given name. Parameters: `name` `String`: The exact name of the enum constant. Returns `BytecodeVersion`: Returns the enum constant with the given name. Cite: `com/oracle/truffle/api/bytecode/BytecodeVersion.html#valueOf(java.lang.String)` ## Inherited members - From class [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#clone%28%29), [`compareTo`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#compareTo%28E%29), [`describeConstable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#describeConstable%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#finalize%28%29), [`getDeclaringClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#getDeclaringClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#hashCode%28%29), [`name`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#name%28%29), [`ordinal`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#ordinal%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#toString%28%29), [`valueOf`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#valueOf%28java.lang.Class,java.lang.String%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # @ ConstantOperand [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java @Retention(SOURCE) @Target({TYPE}) @Repeatable(com.oracle.truffle.api.bytecode.ConstantOperand.Repeat.class) public @interface ConstantOperand ``` Defines a constant operand for an operation. Constant operands are supported for [`Operation`](com/oracle/truffle/api/bytecode/Operation.md), [`Instrumentation`](com/oracle/truffle/api/bytecode/Instrumentation.md), [`Yield`](com/oracle/truffle/api/bytecode/Yield.md), [`Return`](com/oracle/truffle/api/bytecode/Return.md), and [`Prolog`](com/oracle/truffle/api/bytecode/Prolog.md) operations. Constant operands have a few benefits: - In contrast to dynamic operands, which are computed by executing the "children" of an operation at run time, constant operands are specified at parse time and require no run-time computation. - Constant operands have [`com.oracle.truffle.api.CompilerDirectives.CompilationFinal`](com/oracle/truffle/api/CompilerDirectives.CompilationFinal.md) semantics. Though an interpreter can use `LoadConstant` operations to supply dynamic operands, those constants are **not guaranteed to be compilation-final** (the constant is pushed onto and then popped from the stack, which PE cannot always constant fold). - [`Instrumentation`](com/oracle/truffle/api/bytecode/Instrumentation.md) and [`Prolog`](com/oracle/truffle/api/bytecode/Prolog.md) operations are restricted and cannot encode arbitrary dynamic operands. Constant operands can be used to encode other information needed by these operations. When an operation declares a constant operand, each specialization must declare a parameter for the operand before the dynamic operands. The parameter should have the exact [`type()`](com/oracle/truffle/api/bytecode/ConstantOperand.md#type%28%29) of the constant operand. When parsing the operation, a constant must be supplied as an additional parameter to the `begin` or `emit` method of the [`BytecodeBuilder`](com/oracle/truffle/api/bytecode/BytecodeBuilder.md). Constant operands to the [`Prolog`](com/oracle/truffle/api/bytecode/Prolog.md) should be supplied to the `beginRoot` method. Except for [`RootNode`](com/oracle/truffle/api/nodes/RootNode.md)s, a constant operand cannot be a subclass of [`Node`](com/oracle/truffle/api/nodes/Node.md). If an operation needs a compilation-final node operand, it can declare a [`NodeFactory`](com/oracle/truffle/api/dsl/NodeFactory.md) constant operand and then declare a [`Cached`](com/oracle/truffle/api/dsl/Cached.md) parameter initialized with the result of [`createNode`](com/oracle/truffle/api/dsl/NodeFactory.md#createNode%28java.lang.Object...%29). ## Nested types - [`ConstantOperand.Repeat`](com/oracle/truffle/api/bytecode/ConstantOperand.Repeat.md) (annotation interface): Repeat annotation for ConstantOperand. ## Elements ### type() `Class type()`. Since 24.2. The type of the constant operand. All specializations must declare a parameter with this exact type. Cite: `com/oracle/truffle/api/bytecode/ConstantOperand.html#type()` ### name() `String name() default ""`. Since 24.2. Optional name for the constant operand. When this field is not provided, the Bytecode DSL will infer a name from the specializations' parameters. Default: `""`. Cite: `com/oracle/truffle/api/bytecode/ConstantOperand.html#name()` ### javadoc() `String javadoc() default ""`. Since 24.2. Optional documentation for the constant operand. This documentation is included in the javadoc for the generated interpreter. Default: `""`. Cite: `com/oracle/truffle/api/bytecode/ConstantOperand.html#javadoc()` ### specifyAtEnd() `boolean specifyAtEnd() default false`. Since 24.2. By default, when an operation has dynamic operands, the constant operands appear before them in signatures and must be supplied to the operation's `begin` method of the `BytecodeBuilder`. When `specifyAtEnd()` is `true`, the constant operand instead appears after dynamic operands and is supplied to the operation's `end` method (constant operands to the `Prolog` can be supplied to the `endRoot` method). In some cases, it may be more convenient to specify a constant operand after parsing the child operations; for example, the constant may only be known after traversing child ASTs. This flag is meaningless if the operation does not take dynamic operands, since all constant operands will be supplied to a single `emit` method. The exception to this rule is `Prolog`s, which can receive their operands as arguments to either `beginRoot` or `endRoot`. Default: `false`. Cite: `com/oracle/truffle/api/bytecode/ConstantOperand.html#specifyAtEnd()` ### dimensions() `int dimensions() default 0`. Since 24.2. Specifies the number of array dimensions to be marked as compilation final. See `com.oracle.truffle.api.CompilerDirectives.CompilationFinal.dimensions`. The Bytecode DSL currently only supports a value of 0; that is, array elements are **not** compilation-final. Default: `0`. Cite: `com/oracle/truffle/api/bytecode/ConstantOperand.html#dimensions()` # @ ConstantOperand.Repeat [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. Nested in [`ConstantOperand`](com/oracle/truffle/api/bytecode/ConstantOperand.md). ```java @Retention(SOURCE) @Target({TYPE}) public @interface ConstantOperand.Repeat ``` Repeat annotation for [`ConstantOperand`](com/oracle/truffle/api/bytecode/ConstantOperand.md). ## Elements ### value() `ConstantOperand[] value()`. Since 24.2. Repeat value for `ConstantOperand`. Cite: `com/oracle/truffle/api/bytecode/ConstantOperand.Repeat.html#value()` # ◆ ContinuationResult [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java public final class ContinuationResult implements TruffleObject ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `ContinuationResult` Implements: [`TruffleObject`](com/oracle/truffle/api/interop/TruffleObject.md) Representation of a continuation closure, consisting of a resumable [`RootNode`](com/oracle/truffle/api/nodes/RootNode.md), the interpreter state, and a yielded result. A [`ContinuationResult`](com/oracle/truffle/api/bytecode/ContinuationResult.md) is returned when the interpreter yields. It can later be resumed to continue execution. It can be resumed only once. Below illustrates an example usage of [`ContinuationResult`](com/oracle/truffle/api/bytecode/ContinuationResult.md). ```java // Assume yieldingRootNode implements the following pseudocode: // // fun f(x): // y = yield (x + 1) // return x + y // MyBytecodeRootNode yieldingRootNode = ...; // The result is a ContinuationResult ContinuationResult yielded = (ContinuationResult) yieldingRootNode.getCallTarget().call(42); assert yielded.getResult() == 43; // Resume the continuation using continueWith. Pass 58 as the value for yield. Integer returned = (Integer) yielded.continueWith(58); assert returned == 100; ``` For performance reasons, a language may wish to define an inline cache over continuations. In such a case, they should not call [`continueWith`](com/oracle/truffle/api/bytecode/ContinuationResult.md#continueWith%28java.lang.Object%29), but instead cache and call the [`root node`](com/oracle/truffle/api/bytecode/ContinuationResult.md#getContinuationRootNode%28%29) or [`call target`](com/oracle/truffle/api/bytecode/ContinuationResult.md#getContinuationCallTarget%28%29) directly. This is necessary because continuation results are dynamic values, not partial evaluation constants. Be careful to conform to the [`calling convention`](com/oracle/truffle/api/bytecode/ContinuationResult.md#getContinuationCallTarget%28%29) when calling the continuation root node directly. **See also** - [Continuations tutorial](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.bytecode.test/src/com/oracle/truffle/api/bytecode/test/examples/ContinuationsTutorial.java) ## Constructors ### ContinuationResult(ContinuationRootNode, MaterializedFrame, Object) `public ContinuationResult(ContinuationRootNode rootNode, MaterializedFrame frame, Object result)`. Since 24.2. Creates a continuation. The generated interpreter will use this constructor. Continuations should not be created directly by user code. Cite: `com/oracle/truffle/api/bytecode/ContinuationResult.html#(com.oracle.truffle.api.bytecode.ContinuationRootNode,com.oracle.truffle.api.frame.MaterializedFrame,java.lang.Object)` ## Methods ### create(ContinuationRootNode, MaterializedFrame, Object) `public static ContinuationResult create(ContinuationRootNode rootNode, MaterializedFrame frame, Object result)`. Since 25.1. Public API for creating a continuation result. This method is mainly useful when using `custom yield operations` since the `built-in yield` creates continuation results automatically. Cite: `com/oracle/truffle/api/bytecode/ContinuationResult.html#create(com.oracle.truffle.api.bytecode.ContinuationRootNode,com.oracle.truffle.api.frame.MaterializedFrame,java.lang.Object)` ### continueWith(Object) `public Object continueWith(Object value)`. Since 24.2. Resumes the continuation. This method should generally not be used on compiled code paths. Each yield produces a unique `ContinuationResult`, so the receiver object cannot be easily `cached`, which means partial evaluation will be unable to resolve the call target. Instead, it is recommended to cache the `continuation call target` and call it directly. Parameters: `value` `Object`: the value produced by the yield operation in the resumed execution. Cite: `com/oracle/truffle/api/bytecode/ContinuationResult.html#continueWith(java.lang.Object)` ### getContinuationRootNode() `public ContinuationRootNode getContinuationRootNode()`. Since 24.2. Returns the root node that resumes execution. Note that the continuation root node has a specific calling convention. See `getContinuationCallTarget` for more details, or invoke the root node directly using `continueWith`. See also: `getContinuationCallTarget()`. Cite: `com/oracle/truffle/api/bytecode/ContinuationResult.html#getContinuationRootNode()` ### getContinuationCallTarget() `public RootCallTarget getContinuationCallTarget()`. Since 24.2. Returns the call target for the `continuation root node`. The call target can be invoked to resume the continuation. It is recommended to register this call target in an inline cache and call it directly. The call target takes two parameters: the materialized interpreter `frame` and an [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) value to resume execution with. The value becomes the value produced by the yield operation in the resumed execution. Cite: `com/oracle/truffle/api/bytecode/ContinuationResult.html#getContinuationCallTarget()` ### getFrame() `public MaterializedFrame getFrame()`. Since 24.2. Returns the state of the interpreter at the point that it was suspended. Cite: `com/oracle/truffle/api/bytecode/ContinuationResult.html#getFrame()` ### getResult() `public Object getResult()`. Since 24.2. Returns the value yielded by the yield operation. Cite: `com/oracle/truffle/api/bytecode/ContinuationResult.html#getResult()` ### getBytecodeLocation() `public BytecodeLocation getBytecodeLocation()`. Since 24.2. Returns the location at which the continuation was created. This location can have a different `BytecodeNode` from the `source root node` if the source bytecode was `updated` (explicitly or implicitly). Cite: `com/oracle/truffle/api/bytecode/ContinuationResult.html#getBytecodeLocation()` ### toString() `public String toString()`. Since 24.2. Returns a string representation of a `ContinuationResult`. Overrides `toString()`. Cite: `com/oracle/truffle/api/bytecode/ContinuationResult.html#toString()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ ContinuationRootNode [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java public abstract class ContinuationRootNode extends RootNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > [`ExecutableNode`](com/oracle/truffle/api/nodes/ExecutableNode.md) > [`RootNode`](com/oracle/truffle/api/nodes/RootNode.md) > `ContinuationRootNode` Abstract class representing the root node for a continuation. These root nodes have a precise calling convention; see [`ContinuationResult.getContinuationCallTarget()`](com/oracle/truffle/api/bytecode/ContinuationResult.md#getContinuationCallTarget%28%29). If a bytecode interpreter [`supports continuations`](com/oracle/truffle/api/bytecode/GenerateBytecode.md#enableYield%28%29), the Bytecode DSL will generate a concrete implementation of this interface. It should not be subclassed manually. ## Constructors ### ContinuationRootNode(Object, TruffleLanguage, FrameDescriptor) `protected ContinuationRootNode(Object token, TruffleLanguage language, FrameDescriptor frameDescriptor)`. Since 24.2. Internal constructor for generated code. Do not use. Cite: `com/oracle/truffle/api/bytecode/ContinuationRootNode.html#(java.lang.Object,com.oracle.truffle.api.TruffleLanguage,com.oracle.truffle.api.frame.FrameDescriptor)` ## Methods ### getSourceRootNode() `public abstract BytecodeRootNode getSourceRootNode()`. Since 24.2. Returns the original root node from which this continuation was created. Cite: `com/oracle/truffle/api/bytecode/ContinuationRootNode.html#getSourceRootNode()` ### getLocation() `public abstract BytecodeLocation getLocation()`. Since 24.2. Returns the `BytecodeLocation` associated with this continuation. Cite: `com/oracle/truffle/api/bytecode/ContinuationRootNode.html#getLocation()` ### findFrame(Frame) `protected abstract Frame findFrame(Frame frame)`. Since 24.2. Internal method implemented by the generated code. Do not use. Cite: `com/oracle/truffle/api/bytecode/ContinuationRootNode.html#findFrame(com.oracle.truffle.api.frame.Frame)` ## Inherited members - From class [`RootNode`](com/oracle/truffle/api/nodes/RootNode.md): [`call`](com/oracle/truffle/api/nodes/RootNode.md#call%28com.oracle.truffle.api.nodes.Node,int,java.lang.Object[]%29), [`cloneUninitialized`](com/oracle/truffle/api/nodes/RootNode.md#cloneUninitialized%28%29), [`computeSize`](com/oracle/truffle/api/nodes/RootNode.md#computeSize%28%29), [`copy`](com/oracle/truffle/api/nodes/RootNode.md#copy%28%29), [`countsTowardsStackTraceLimit`](com/oracle/truffle/api/nodes/RootNode.md#countsTowardsStackTraceLimit%28%29), [`createConstantNode`](com/oracle/truffle/api/nodes/RootNode.md#createConstantNode%28java.lang.Object%29), [`execute`](com/oracle/truffle/api/nodes/RootNode.md#execute%28com.oracle.truffle.api.frame.VirtualFrame%29), [`findAsynchronousFrames`](com/oracle/truffle/api/nodes/RootNode.md#findAsynchronousFrames%28com.oracle.truffle.api.frame.Frame%29), [`findBytecodeIndex`](com/oracle/truffle/api/nodes/RootNode.md#findBytecodeIndex%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.frame.Frame%29), [`findInstrumentableCallNode`](com/oracle/truffle/api/nodes/RootNode.md#findInstrumentableCallNode%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.frame.Frame,int%29), [`getCallTarget`](com/oracle/truffle/api/nodes/RootNode.md#getCallTarget%28%29), [`getFrameDescriptor`](com/oracle/truffle/api/nodes/RootNode.md#getFrameDescriptor%28%29), [`getName`](com/oracle/truffle/api/nodes/RootNode.md#getName%28%29), [`getParentFrameDescriptor`](com/oracle/truffle/api/nodes/RootNode.md#getParentFrameDescriptor%28%29), [`getQualifiedName`](com/oracle/truffle/api/nodes/RootNode.md#getQualifiedName%28%29), [`initializeCallTarget`](com/oracle/truffle/api/nodes/RootNode.md#initializeCallTarget%28%29), [`isCaptureFramesForTrace`](com/oracle/truffle/api/nodes/RootNode.md#isCaptureFramesForTrace%28%29), [`isCaptureFramesForTrace`](com/oracle/truffle/api/nodes/RootNode.md#isCaptureFramesForTrace%28boolean%29), [`isCaptureFramesForTrace`](com/oracle/truffle/api/nodes/RootNode.md#isCaptureFramesForTrace%28com.oracle.truffle.api.nodes.Node%29), [`isCloneUninitializedSupported`](com/oracle/truffle/api/nodes/RootNode.md#isCloneUninitializedSupported%28%29), [`isCloningAllowed`](com/oracle/truffle/api/nodes/RootNode.md#isCloningAllowed%28%29), [`isInstrumentable`](com/oracle/truffle/api/nodes/RootNode.md#isInstrumentable%28%29), [`isInternal`](com/oracle/truffle/api/nodes/RootNode.md#isInternal%28%29), [`isSameFrame`](com/oracle/truffle/api/nodes/RootNode.md#isSameFrame%28com.oracle.truffle.api.frame.Frame,com.oracle.truffle.api.frame.Frame%29), [`isTrivial`](com/oracle/truffle/api/nodes/RootNode.md#isTrivial%28%29), [`prepareForAOT`](com/oracle/truffle/api/nodes/RootNode.md#prepareForAOT%28%29), [`prepareForCall`](com/oracle/truffle/api/nodes/RootNode.md#prepareForCall%28%29), [`prepareForCompilation`](com/oracle/truffle/api/nodes/RootNode.md#prepareForCompilation%28boolean,int,boolean%29), [`prepareForInstrumentation`](com/oracle/truffle/api/nodes/RootNode.md#prepareForInstrumentation%28java.util.Set%29), [`translateStackTraceElement`](com/oracle/truffle/api/nodes/RootNode.md#translateStackTraceElement%28com.oracle.truffle.api.TruffleStackTraceElement%29), [`visitCloneableNodes`](com/oracle/truffle/api/nodes/RootNode.md#visitCloneableNodes%28com.oracle.truffle.api.nodes.NodeVisitor%29) - From class [`ExecutableNode`](com/oracle/truffle/api/nodes/ExecutableNode.md): [`getLanguage`](com/oracle/truffle/api/nodes/ExecutableNode.md#getLanguage%28java.lang.Class%29), [`getLanguageInfo`](com/oracle/truffle/api/nodes/ExecutableNode.md#getLanguageInfo%28%29) - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # @ EpilogExceptional [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java @Retention(SOURCE) @Target({TYPE}) public @interface EpilogExceptional ``` Defines an exceptional epilog operation. This epilog executes when an uncaught Truffle exception is thrown (whereas the [`return epilog`](com/oracle/truffle/api/bytecode/EpilogReturn.md) executes before returning normally). An exceptional epilog operation is defined the same way as an [`Operation`](com/oracle/truffle/api/bytecode/Operation.md). It has the additional restriction that its specializations must take one operand (the exception), which must be of type [`com.oracle.truffle.api.exception.AbstractTruffleException`](com/oracle/truffle/api/exception/AbstractTruffleException.md) or a subtype. The return type must also be void. The exceptional epilog is guarded by exception intercept methods (e.g., [`BytecodeRootNode.interceptInternalException(Throwable, VirtualFrame, BytecodeNode, int)`](com/oracle/truffle/api/bytecode/BytecodeRootNode.md#interceptInternalException%28java.lang.Throwable,com.oracle.truffle.api.frame.VirtualFrame,com.oracle.truffle.api.bytecode.BytecodeNode,int%29)), but not language-level exception handlers. **See also** - [`EpilogReturn`](com/oracle/truffle/api/bytecode/EpilogReturn.md) - [`Prolog`](com/oracle/truffle/api/bytecode/Prolog.md) ## Elements ### storeBytecodeIndex() `boolean storeBytecodeIndex() default true`. Since 25.1. Whether to store the BCI before executing this operation. See `Operation.storeBytecodeIndex()` for mode-dependent defaults. When `false`, `StoreBytecodeIndex` enables storage for individual `Specialization` or `Fallback` methods. Returns `boolean`: whether to enable operation-level BCI storage. Default: `true`. Cite: `com/oracle/truffle/api/bytecode/EpilogExceptional.html#storeBytecodeIndex()` # @ EpilogReturn [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java @Retention(SOURCE) @Target({TYPE}) public @interface EpilogReturn ``` Defines a return epilog operation. This epilog executes before returning a value (whereas the [`exceptional epilog`](com/oracle/truffle/api/bytecode/EpilogExceptional.md) handles uncaught Truffle exceptions). A return epilog operation is defined the same way as an [`Operation`](com/oracle/truffle/api/bytecode/Operation.md). It has the additional restriction that its specializations must take one operand (the returned value) and must return a value. The return value (which can simply be the input operand) is returned from the root node. The return epilog is guarded by exception intercept methods (e.g., [`BytecodeRootNode.interceptInternalException(Throwable, VirtualFrame, BytecodeNode, int)`](com/oracle/truffle/api/bytecode/BytecodeRootNode.md#interceptInternalException%28java.lang.Throwable,com.oracle.truffle.api.frame.VirtualFrame,com.oracle.truffle.api.bytecode.BytecodeNode,int%29)) and by the [`exceptional epilog`](com/oracle/truffle/api/bytecode/EpilogExceptional.md), if present. It is not guarded by user-defined language-level exception handlers that guard the return operation. **See also** - [`EpilogExceptional`](com/oracle/truffle/api/bytecode/EpilogExceptional.md) - [`Prolog`](com/oracle/truffle/api/bytecode/Prolog.md) ## Elements ### storeBytecodeIndex() `boolean storeBytecodeIndex() default true`. Since 25.1. Whether to store the BCI before executing this operation. See `Operation.storeBytecodeIndex()` for mode-dependent defaults. When `false`, `StoreBytecodeIndex` enables storage for individual `Specialization` or `Fallback` methods. Returns `boolean`: whether to enable operation-level BCI storage. Default: `true`. Cite: `com/oracle/truffle/api/bytecode/EpilogReturn.html#storeBytecodeIndex()` # ◆ ExceptionHandler [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java public abstract class ExceptionHandler ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `ExceptionHandler` Introspection class modeling the meta-information of an exception handler in a bytecode interpreter. An exception handler stores information for bytecode index ranges that determine how an exception should be handled at a particular location. Note: Introspection classes are intended to be used for debugging purposes only. These APIs may change in the future. **See also** - [`BytecodeNode.getExceptionHandlers()`](com/oracle/truffle/api/bytecode/BytecodeNode.md#getExceptionHandlers%28%29) - [`BytecodeLocation.getExceptionHandlers()`](com/oracle/truffle/api/bytecode/BytecodeLocation.md#getExceptionHandlers%28%29) ## Nested types - [`ExceptionHandler.HandlerKind`](com/oracle/truffle/api/bytecode/ExceptionHandler.HandlerKind.md) (enum class): Represents the kind of the exception handler. ## Constructors ### ExceptionHandler(Object) `protected ExceptionHandler(Object token)`. Since 24.2. Internal constructor for generated code. Do not use. Cite: `com/oracle/truffle/api/bytecode/ExceptionHandler.html#(java.lang.Object)` ## Methods ### getKind() `public abstract ExceptionHandler.HandlerKind getKind()`. Since 24.2. Returns a kind that determines whether the handler is a custom or special exception handler. See also: `HandlerKind`. Cite: `com/oracle/truffle/api/bytecode/ExceptionHandler.html#getKind()` ### getStartBytecodeIndex() `public abstract int getStartBytecodeIndex()`. Since 24.2. Returns the start bytecode index guarded by this exception handler (inclusive). Cite: `com/oracle/truffle/api/bytecode/ExceptionHandler.html#getStartBytecodeIndex()` ### getEndBytecodeIndex() `public abstract int getEndBytecodeIndex()`. Since 24.2. Returns the end bytecode index guarded by this exception handler (exclusive). Cite: `com/oracle/truffle/api/bytecode/ExceptionHandler.html#getEndBytecodeIndex()` ### getHandlerBytecodeIndex() `public int getHandlerBytecodeIndex() throws UnsupportedOperationException`. Since 24.2. Returns the bytecode index of the handler code if this exception handler is of kind `HandlerKind.CUSTOM`. Throws: `UnsupportedOperationException`: for handlers not of kind `HandlerKind.CUSTOM`. Cite: `com/oracle/truffle/api/bytecode/ExceptionHandler.html#getHandlerBytecodeIndex()` ### getTagTree() `public TagTree getTagTree() throws UnsupportedOperationException`. Since 24.2. Returns the tag tree of this exception handler if this exception handler is of kind `HandlerKind.TAG`. Throws: `UnsupportedOperationException`: for handlers not of kind `HandlerKind.TAG`. Cite: `com/oracle/truffle/api/bytecode/ExceptionHandler.html#getTagTree()` ### toString() `public final String toString()`. Since 24.2. Overrides `toString()`. Cite: `com/oracle/truffle/api/bytecode/ExceptionHandler.html#toString()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ≡ ExceptionHandler.HandlerKind [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Enum class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. Nested in [`ExceptionHandler`](com/oracle/truffle/api/bytecode/ExceptionHandler.md). ```java public enum ExceptionHandler.HandlerKind ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html) > `HandlerKind` Represents the kind of the exception handler. ## Enum constants ### CUSTOM `CUSTOM`. Since 24.2. Handler directly emitted with the bytecode builder. Cite: `com/oracle/truffle/api/bytecode/ExceptionHandler.HandlerKind.html#CUSTOM` ### TAG `TAG`. Since 24.2. A special handler which handles tag instrumentation exceptional behavior. Only emitted if `tag instrumentation` is enabled. Cite: `com/oracle/truffle/api/bytecode/ExceptionHandler.HandlerKind.html#TAG` ### EPILOG `EPILOG`. Since 24.2. A special handler which handles epilog exceptional behavior. Only emitted if the language specifies an `EpilogExceptional` annotated operation. Cite: `com/oracle/truffle/api/bytecode/ExceptionHandler.HandlerKind.html#EPILOG` ## Methods ### values() `public static ExceptionHandler.HandlerKind[] values()`. Returns the enum constants in declaration order. Returns `ExceptionHandler.HandlerKind[]`: Returns the enum constants in declaration order. Cite: `com/oracle/truffle/api/bytecode/ExceptionHandler.HandlerKind.html#values()` ### valueOf(String) `public static ExceptionHandler.HandlerKind valueOf(String name)`. Returns the enum constant with the given name. Parameters: `name` `String`: The exact name of the enum constant. Returns `ExceptionHandler.HandlerKind`: Returns the enum constant with the given name. Cite: `com/oracle/truffle/api/bytecode/ExceptionHandler.HandlerKind.html#valueOf(java.lang.String)` ## Inherited members - From class [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#clone%28%29), [`compareTo`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#compareTo%28E%29), [`describeConstable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#describeConstable%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#finalize%28%29), [`getDeclaringClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#getDeclaringClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#hashCode%28%29), [`name`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#name%28%29), [`ordinal`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#ordinal%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#toString%28%29), [`valueOf`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#valueOf%28java.lang.Class,java.lang.String%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # @ ForceQuickening [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java @Retention(SOURCE) @Target({METHOD}) @Repeatable(com.oracle.truffle.api.bytecode.ForceQuickening.Repeat.class) public @interface ForceQuickening ``` Forces quickening for an [`Operation`](com/oracle/truffle/api/bytecode/Operation.md) [`specialization`](com/oracle/truffle/api/dsl/Specialization.md). To quicken a combination of specializations, use the same [`name`](com/oracle/truffle/api/bytecode/ForceQuickening.md#value%28%29). If no name is specified then only the annotated specialization is quickened. It is possible to specify multiple quickenings per specialization (e.g., if a specialization is quickened individually and in a group of specializations). For example, the following code declares two quickenings: one that supports only `ints` (the plain `@ForceQuickening` on `doInts`), and another that supports both `ints` and `doubles` (`@ForceQuickening("primitives")`): ```java @Operation public static final class Add { @Specialization @ForceQuickening @ForceQuickening("primitives") public static int doInts(int lhs, int rhs) { return lhs + rhs; } @Specialization @ForceQuickening("primitives") public static double doDoubles(double lhs, double rhs) { return lhs + rhs; } @Specialization @TruffleBoundary public static String doStrings(String lhs, String rhs) { return lhs + rhs; } } ``` ## Nested types - [`ForceQuickening.Repeat`](com/oracle/truffle/api/bytecode/ForceQuickening.Repeat.md) (annotation interface): Repeat annotation for ForceQuickening. ## Elements ### value() `String value() default ""`. Since 24.2. The name of the quickening group. If nonempty, all specializations annotated with the same value will be included in a quickened instruction together. By default, this value is empty, which signifies that a specialization should have its own quickened instruction. Default: `""`. Cite: `com/oracle/truffle/api/bytecode/ForceQuickening.html#value()` # @ ForceQuickening.Repeat [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. Nested in [`ForceQuickening`](com/oracle/truffle/api/bytecode/ForceQuickening.md). ```java @Retention(SOURCE) @Target({METHOD}) public @interface ForceQuickening.Repeat ``` Repeat annotation for [`ForceQuickening`](com/oracle/truffle/api/bytecode/ForceQuickening.md). ## Elements ### value() `ForceQuickening[] value()`. Since 24.2. Repeat value for `ForceQuickening`. Cite: `com/oracle/truffle/api/bytecode/ForceQuickening.Repeat.html#value()` # @ GenerateBytecode [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java @Retention(SOURCE) @Target({TYPE}) public @interface GenerateBytecode ``` Generates a bytecode interpreter using the Bytecode DSL. The Bytecode DSL automatically produces an optimizing bytecode interpreter from a set of Node-like "operations". The following is an example of a Bytecode DSL interpreter with a single `Add` operation. ```java @GenerateBytecode(languageClass = MyLanguage.class) public abstract class MyBytecodeRootNode extends RootNode implements BytecodeRootNode { @Operation public static final class Add { @Specialization public static int doInts(int lhs, int rhs) { return lhs + rhs; } @Specialization @TruffleBoundary public static String doStrings(String lhs, String rhs) { return lhs + rhs; } } } ``` The Bytecode DSL generates a node suffixed with `Gen` (e.g., `MyBytecodeRootNodeGen`) that contains (among other things) a full bytecode encoding, an optimizing interpreter, and a `Builder` class to generate and validate bytecode automatically. A node can opt in to additional features, like an [`uncached interpreter`](com/oracle/truffle/api/bytecode/GenerateBytecode.md#enableUncachedInterpreter%28%29), [`boxing elimination`](com/oracle/truffle/api/bytecode/GenerateBytecode.md#boxingEliminationTypes%28%29), [`quickened instructions`](com/oracle/truffle/api/bytecode/GenerateBytecode.md#enableQuickening%28%29), and more. The fields of this annotation control which features are included in the generated interpreter. For information about using the Bytecode DSL, please consult the [tutorial](https://github.com/oracle/graal/blob/master/truffle/docs/bytecode_dsl/BytecodeDSL.md). ## Elements ### languageClass() `Class> languageClass()`. Since 24.2. The `TruffleLanguage` class associated with this node. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#languageClass()` ### version() `BytecodeVersion version() default V1`. Since 25.7. Selects the Bytecode DSL behaviour version. Versions distinguish breaking behaviour changes that require migration of language implementations. They do not identify Truffle releases or version internal implementation details, optimizations, or performance changes. Breaking changes are rare and avoided whenever possible. For details, refer to `BytecodeVersion`. This field allows you to pin the version so that updating Truffle does not automatically adopt breaking changes. Instead, when new breaking changes are introduced, the compiler will emit a warning referring to the `BytecodeVersion` Javadoc for migration instructions. It is recommended to always migrate to the newest version, since old versions are deprecated and will eventually be unsupported in future releases. You can specify `BytecodeVersion.LATEST` to always opt in to the newest behaviour. Your interpreter will be recompiled with the latest behaviour every time Truffle is updated. This option should not be used in production language implementations; select an explicit version instead. For compatibility, this field defaults to version 1, with a compiler warning to explicitly specify it. An explicit version will be required in subsequent releases. Default: `V1`. See also: `BytecodeVersion`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#version()` ### unwindExceptions() `Class[] unwindExceptions() default {}`. Since 25.5. Specifies exception types that unwind the bytecode interpreter through guest `finally` handlers. An exception that is an instance of one of the specified types bypasses exception interception hooks, guest exception handlers, and `EpilogExceptional`. Instrumentation is still notified, and `finally` handlers are executed before the original exception instance is rethrown. If a `finally` handler yields, the continuation preserves the pending exception and continues unwinding after the handler resumes. A return or exception from a `finally` handler supersedes the pending exception. It is recommended to use `ControlFlowException` subtypes for unwind exceptions, but any [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) subtype is permitted. [`ThreadDeath`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ThreadDeath.html) and its subtypes are reserved for instrumentation unwinds and cannot be specified explicitly. They retain their existing behavior even when a configured supertype would match them. Default: `{}`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#unwindExceptions()` ### enableUncachedInterpreter() `boolean enableUncachedInterpreter() default false`. Since 24.2. Whether to generate an uncached interpreter. The uncached interpreter improves start-up performance by executing `uncached` nodes instead of allocating and executing cached (specializing) nodes. The node will transition to a specializing interpreter after enough invocations/back-edges (as determined by `defaultUncachedThreshold`). To generate an uncached interpreter, all operations need to support uncached execution. If an operation cannot easily support uncached execution, it can instead `force a transition to cached` before the operation is executed (this may limit the utility of the uncached interpreter). Default: `false`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#enableUncachedInterpreter()` ### defaultUncachedThreshold() `String defaultUncachedThreshold() default "16"`. Since 24.2. Sets the default number of invocations/resumptions or backward branches for which the interpreter executes uncached before transitioning to cached on the next such event. The default uncached threshold expression supports a subset of Java (see the `Cached` documentation). It should evaluate to an int. It should be a positive value, `0`, or `Integer.MIN_VALUE`. A threshold of `0` will cause each bytecode node to immediately transition to cached on the first invocation/resume. A threshold of `Integer.MIN_VALUE` forces a bytecode node to stay uncached (i.e., it will not transition to cached). The default local value expression can be a constant literal (e.g., `"42"`), in which case the value will be validated at build time. However, the expression can also refer to static members of the bytecode root node (and validation is deferred to run time). The following example declares a default threshold of 32 that can be overridden with a system property: Other expressions like static method calls are also possible. Note that instance members of the root node cannot be bound with the default uncached threshold expression for efficiency reasons. To override this default threshold for a given bytecode node, an explicit threshold can be set using `BytecodeNode.setUncachedThreshold`. This field has no effect unless the uncached interpreter is `enabled`. Default: `"16"`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#defaultUncachedThreshold()` ```java @GenerateBytecode(..., defaultUncachedThreshold = "DEFAULT_UNCACHED_THRESHOLD") abstract class MyBytecodeRootNode extends RootNode implements BytecodeRootNode { static final int DEFAULT_UNCACHED_THRESHOLD = Integer.parseInt(System.getProperty("defaultUncachedThreshold", "32")); // ... } ``` ### enableSerialization() `boolean enableSerialization() default false`. Since 24.2. Whether the generated interpreter should support serialization and deserialization. When serialization is enabled, the Bytecode DSL generates code to convert bytecode nodes to and from a serialized byte array representation. The code effectively serializes the node's execution data (bytecode, constants, etc.) and all of its non-transient fields. The serialization logic is available through `BytecodeDescriptor.serializeBuilderBytecode`, `BytecodeDescriptor.serializeExecutionBytecode`, `BytecodeDescriptor.deserializeBuilderBytecode`, and `BytecodeDescriptor.deserializeExecutionBytecode`. Equivalent static methods are also generated on the root class. The generated `BytecodeRootNodes` class overrides `BytecodeRootNodes.serializeBuilderBytecode` and `BytecodeRootNodes.serializeExecutionBytecode`. This feature can be used to avoid the overhead of parsing source code on start up. Builder bytecode encodes builder method calls, which are replayed and validated during deserialization (balanced stack pointers, valid branches, etc.). When the serialized bytes are trusted, execution bytecode can be loaded directly to avoid builder replay for a particular configuration. The deserialization methods take [`Supplier`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/Supplier.html)s of [`DataInput`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/DataInput.html) rather than inputs directly. The builder bytecode supplier should produce a fresh [`DataInput`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/DataInput.html) each time because the input may be processed multiple times (due to `reparsing`). The execution bytecode supplier is invoked at most once during initial deserialization. Default: `false`. See also: `BytecodeSerializer`, `BytecodeDeserializer`, [Serialization tutorial](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.bytecode.test/src/com/oracle/truffle/api/bytecode/test/examples/SerializationTutorial.java). Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#enableSerialization()` ### enableTagInstrumentation() `boolean enableTagInstrumentation() default false`. Since 24.2. Whether the generated interpreter should support Truffle tag instrumentation. When instrumentation is enabled, the generated builder will define `beginTag(...)` and `endTag(...)` methods that can be used to annotate the bytecode with `tags`. Truffle tag instrumentation also allows you to specify implicit tagging using `Operation.tags()`. If tag instrumentation is enabled all tagged operations will automatically handle and insert `probes` from the Truffle instrumentation framework. Only tags that are `provided` by the specified `Truffle language` can be used. Default: `false`. See also: `enableRootTagging()`, `enableRootBodyTagging()`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#enableTagInstrumentation()` ### enableRootTagging() `boolean enableRootTagging() default true`. Since 24.2. Enables automatic root tagging if `instrumentation` is enabled. Automatic root tagging automatically tags each root with `RootTag` if the language `provides` it. Root tagging requires the probe to be notified before the `prolog` is executed. Implementing this behaviour manually is not trivial and not recommended. It is recommended to use automatic root tagging. For inlining performed by the parser it may be useful to emit custom `root` tag using the builder methods for inlined methods. This ensures that tools can still work correctly for inlined calls. Default: `true`. See also: `enableRootBodyTagging()`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#enableRootTagging()` ### enableRootBodyTagging() `boolean enableRootBodyTagging() default true`. Since 24.2. Enables automatic root body tagging if `instrumentation` is enabled. Automatic root body tagging automatically tags each root with `RootBodyTag` if the language `provides` it. Default: `true`. See also: `enableRootTagging()`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#enableRootBodyTagging()` ### tagTreeNodeLibrary() `Class tagTreeNodeLibrary() default com.oracle.truffle.api.bytecode.TagTreeNodeExports.class`. Since 24.2. Allows to customize the `NodeLibrary` implementation that is used for tag instrumentation. This option only makes sense if `enableTagInstrumentation()` is set to `true`. Common use-cases when implementing a custom tag tree node library is required: Allowing instruments to access the current receiver or function object.; Implementing custom scopes for local variables instead of the default scope.; Hiding certain local variables or arguments from instruments. Minimal example of a tag node library: See the `NodeLibrary` javadoc for more details. Default: `com.oracle.truffle.api.bytecode.TagTreeNodeExports.class`. See also: `TagTreeNode`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#tagTreeNodeLibrary()` ```java @ExportLibrary(value = NodeLibrary.class, receiverType = TagTreeNode.class) final class MyTagTreeNodeExports { @ExportMessage static boolean hasScope(TagTreeNode node, Frame frame) { return true; } @ExportMessage @SuppressWarnings("unused") static Object getScope(TagTreeNode node, Frame frame, boolean nodeEnter) throws UnsupportedMessageException { return new MyScope(node, frame); } } ``` ### allowUnsafe() `boolean allowUnsafe() default true`. Since 24.2. Whether to use unsafe array accesses. Unsafe accesses are faster, but they do not perform array bounds checks. This means it is possible (though unlikely) for unsafe accesses to cause undefined behaviour. Undefined behaviour may only happen due to a bug in the Bytecode DSL implementation and not language implementation code. Default: `true`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#allowUnsafe()` ### enableYield() `boolean enableYield() default false`. Since 24.2. Whether the generated interpreter should support coroutines via a built-in `yield` operation. The built-in yield operation returns a `ContinuationResult` from the current point in execution. The `ContinuationResult` saves the current state of the interpreter so that it can be resumed at a later time. The yield and resume actions pass values, enabling communication between the caller and callee. If more control over the yield process is required, consider defining a custom `Yield` instead. You can enable built-in and custom yields separately (i.e., `enableYield` does not need to be `true` if you only use a custom yield). Technical note: in theoretical terms, a `ContinuationResult` implements an asymmetric stack-less coroutine. Default: `false`. See also: `com.oracle.truffle.api.bytecode.ContinuationResult`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#enableYield()` ### enableMaterializedLocalAccesses() `boolean enableMaterializedLocalAccesses() default false`. Since 24.2. Enables materialized local accesses. Materialized local accesses allow a root node to access the locals of any outer root nodes (root nodes created by enclosing `Root` operations) in addition to its own locals. These accesses take the `materialized frame` containing the local as an operand. Materialized local accesses can be used to implement closures and nested functions with lexical scoping. When materialized local accesses are enabled, the interpreter defines two additional operations, `LoadLocalMaterialized` and `StoreLocalMaterialized`, which implement the local accesses. Implementations can also use `MaterializedLocalAccessor`s to access locals from user-defined operations. Materialized local accesses can *only* be used where the local is `in scope`. The bytecode generator guarantees that each materialized access's local is in scope at the static location of the access, but since root nodes can be called at any time, it is still possible to execute the root node (and thus perform the access) when the local is out of scope, leading to unexpected behaviour (e.g., reading an incorrect local value). When `bytecodeIndexMode()` is `BytecodeIndexMode.FRAME`, the interpreter will dynamically validate each materialized access, throwing a runtime exception when the local is not in scope. Thus, to diagnose issues with invalid materialized accesses, it is recommended to use `BytecodeIndexMode.FRAME`. Default: `false`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#enableMaterializedLocalAccesses()` ### enableBlockScoping() `boolean enableBlockScoping() default true`. Since 24.2. Enables block scoping, which limits a local's lifetime to the lifetime of the enclosing Block/Root operation. Block scoping is enabled by default. If this flag is set to `false`, locals use root scoping, which keeps locals alive for the lifetime of the root node (i.e., the entire invocation). The value of this flag significantly changes the behaviour of local variables, so the value of this flag should be decided relatively early in the development of a language. When block scoping is enabled, all local variables are scoped to the closest enclosing Block/Root operation. When a local variable's enclosing Block ends, it falls out of scope and its value is automatically `cleared` (or reset to a `default value`, if provided). Locals scoped to the Root operation are not cleared on exit. Block scoping allows the interpreter to reuse a frame index for multiple locals that have disjoint lifetimes, which can reduce the frame size. With block scoping, a different set of locals can be live at different bytecode indices. The interpreter retains extra metadata to track the lifetimes of each local. The local accessor methods of `BytecodeNode` (e.g., `BytecodeNode.getLocalValues(int, Frame)`) take the current bytecode index as a parameter so that they can correctly compute the locals in scope. These liveness computations can require extra computation, so accessing locals using bytecode instructions or `LocalAccessors` (which validate liveness at parse time) is encouraged when possible. The bytecode index should be a `partial evaluation constant` for performance reasons. The lifetime of local variables can also be accessed through introspection using `LocalVariable.getStartIndex()` and `LocalVariable.getEndIndex()`. When root scoping is enabled, all local variables are assigned a unique index in the frame regardless of the current source location. They are never cleared, and frame indexes are not reused. Consequently, the bytecode index parameter on the local accessor methods of `BytecodeNode` has no effect. Root scoping does not retain additional liveness metadata (which may be a useful footprint optimization); this also means `LocalVariable.getStartIndex()` and `LocalVariable.getEndIndex()` methods do not return lifetime data. Root scoping is primarily intended for cases where the implemented language does not use block scoping. It can also be useful if the default block scoping is not flexible enough and custom scoping rules are needed. Default: `true`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#enableBlockScoping()` ### enableQuickening() `boolean enableQuickening() default true`. Since 24.2. Whether to generate quickened bytecodes for user-provided operations. Quickened versions of instructions support a subset of the `specializations` defined by an operation. They can improve interpreted performance by reducing footprint and requiring fewer guards. Quickened versions of operations can be specified using `com.oracle.truffle.api.bytecode.ForceQuickening`. When an instruction re-specializes itself, the interpreter attempts to automatically replace it with a quickened instruction. Default: `true`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#enableQuickening()` ### bytecodeIndexMode() `BytecodeIndexMode bytecodeIndexMode() default CACHED_NODE`. Since 25.6. Configures how the generated interpreter makes its current bytecode index available for stack walking and frame introspection. Operations can always bind `@Bind("$bytecodeIndex") int bci` for explicit propagation. Returns `BytecodeIndexMode`: the lookup mode; defaults to `BytecodeIndexMode.CACHED_NODE`. Default: `CACHED_NODE`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#bytecodeIndexMode()` ### storeBytecodeIndexInFrame() `boolean storeBytecodeIndexInFrame() default false`. Since 24.2. Whether the generated interpreter should automatically store the bytecode index in the frame in all interpreter tiers. Setting this attribute to `true` is equivalent to setting `bytecodeIndexMode()` to `BytecodeIndexMode.FRAME`. It cannot be combined with a non-default bytecode index mode. Setting it to `false` does not override `bytecodeIndexMode()`. For new interpreters, prefer `bytecodeIndexMode()` with `BytecodeIndexMode.FRAME`. Default: `false`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#storeBytecodeIndexInFrame()` ### captureFramesForTrace() `boolean captureFramesForTrace() default false`. Since 25.1. Whether `stack trace elements` of the annotated root node should capture frames. This flag should be used instead of `RootNode.isCaptureFramesForTrace(boolean)`, which the Bytecode DSL prevents you from overriding. When this flag is non-null, you can use `BytecodeFrame.get(TruffleStackTraceElement)` to access frame data from a stack trace element. The frame only supports read-only access. Bytecode DSL interpreters **must not** access frames directly using `TruffleStackTraceElement.getFrame`. Default: `false`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#captureFramesForTrace()` ### boxingEliminationTypes() `Class[] boxingEliminationTypes() default {}`. Since 24.2. Primitive types the interpreter should attempt to avoid boxing up. Each type should be primitive class literal (e.g., `int.class`). If boxing elimination types are provided, the cached interpreter will generate instruction variants that load/store primitive values when possible. It will automatically use these instructions in a best-effort manner (falling back on boxed representations when necessary). Default: `{}`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#boxingEliminationTypes()` ### inlinePrimitiveConstants() `boolean inlinePrimitiveConstants() default true`. Since 25.1. Whether constant operands of primitive type should be encoded directly in the bytecode. Inlining can reduce the number of memory reads required to access constants. Currently, inlining is only supported for `ConstantOperand`s. Default: `true`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#inlinePrimitiveConstants()` ### enableSpecializationIntrospection() `boolean enableSpecializationIntrospection() default false`. Since 24.2. Whether to generate introspection data for specializations. The data is accessible using `com.oracle.truffle.api.bytecode.Instruction.Argument.getSpecializationInfo()`. Default: `false`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#enableSpecializationIntrospection()` ### defaultLocalValue() `String defaultLocalValue() default ""`. Since 24.2. Specifies the default value produced when attempting to load a cleared `local` (i.e., a local that has not been written to). This attribute is mutually exclusive with `illegalLocalException()`: the interpreter can either produce a default value or throw a user-provided exception when loading a cleared local. If neither is explicitly specified, the interpreter defaults to throwing a `FrameSlotTypeException`. It is recommended for the default local value expression to refer to a static and final constant in the bytecode root node. For example: The expression supports a subset of Java (see the `Cached` documentation), including other expressions like `null` or a static method call. Note that instance members of the root node cannot be bound with the default local value expression for efficiency reasons. Default: `""`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#defaultLocalValue()` ```java @GenerateBytecode(..., defaultLocalValue = "DEFAULT_VALUE") abstract class MyBytecodeRootNode extends RootNode implements BytecodeRootNode { static final DefaultValue DEFAULT_VALUE = DefaultValue.INSTANCE; // ... } ``` ### illegalLocalException() `Class illegalLocalException() default com.oracle.truffle.api.frame.FrameSlotTypeException.class`. Since 25.1. Specifies the exception to throw when attempting to load a cleared `local` (i.e., a local that has not been written to). This attribute is mutually exclusive with `defaultLocalValue()`: the interpreter can either produce a default value or throw a user-provided exception when loading a cleared local. If neither is explicitly specified, the interpreter defaults to throwing a `FrameSlotTypeException`. When an illegal local exception is specified, the interpreter checks if a local is cleared before each load; if the local is cleared, the interpreter creates and throws an instance of the exception using the factory method. The interpreter will attempt to `quicken` away the clear check when possible. Below is an example: The provided exception class must declare a static factory method for instantiating exceptions. By default, this method is named `create`, but this can be overridden using `illegalLocalExceptionFactory()`. The factory method should return an instance of the exception class. It may take zero or more parameters of the following types (in any order): `Node`: the current location (equivalent to `@Bind("$node")`); `BytecodeNode`: the current bytecode node; `BytecodeLocation`: the current bytecode location; `int`: the current bytecode index, or `-1` when the index is unavailable; `LocalVariable`: an introspection object modeling the local's metadata (name, info, etc.) If the provided exception class is a Truffle exception (i.e., it extends `com.oracle.truffle.api.exception.AbstractTruffleException`), the exception can be thrown from runtime compiled code without deoptimization; otherwise, it is considered an internal error and throwing the exception will always trigger deoptimization. Note: due to current limitations of the Bytecode DSL implementation, illegal local exceptions are not yet fully supported with local accessors: If an operation uses a `LocalAccessor` or `LocalRangeAccessor`, the factory method cannot declare a `BytecodeLocation` parameter.; If an operation uses a `MaterializedLocalAccessor`, illegal local exceptions cannot be used. Default: `com.oracle.truffle.api.frame.FrameSlotTypeException.class`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#illegalLocalException()` ```java @GenerateBytecode(..., illegalLocalException = MyIllegalLocalException.class) abstract class MyBytecodeRootNode extends RootNode implements BytecodeRootNode { // ... } class MyIllegalLocalException extends AbstractTruffleException { public static MyIllegalLocalException create(Node location, BytecodeNode bytecode, BytecodeLocation bytecodeLocation, LocalVariable variable) { // ... } } ``` ### illegalLocalExceptionFactory() `String illegalLocalExceptionFactory() default "create"`. Since 25.1. Specifies the name of the static factory method used to instantiate illegal local exceptions. This attribute is only applicable if an `illegalLocalException()` class is specified. Default: `"create"`. See also: `illegalLocalException()`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#illegalLocalExceptionFactory()` ### enableBytecodeDebugListener() `boolean enableBytecodeDebugListener() default true`. Since 24.2. Whether the `BytecodeDebugListener` methods should be notified by generated code. By default the debug bytecode listener is enabled if the root node implements `BytecodeDebugListener`. If this attribute is set to `false` then the debug bytecode listener won't be notified. This attribute may be useful to keep a default debug listener implementation permanently in the source code but only enable it temporarily during debug sessions. Default: `true`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#enableBytecodeDebugListener()` ### variadicStackLimit() `String variadicStackLimit() default "32"`. Since 25.0. Sets the maximum number of stack slots that will be used for parameters annotated with `Variadic`. The value must represent a power of 2 greater than 1 and must not exceed [`Short.MAX_VALUE`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Short.html#MAX_VALUE). The default value is "32". As with `defaultLocalValue()`, it is possible to specify this limit via an expression. If a constant value is provided, the limit is validated at compile time; otherwise, it is validated at class initialization. The expression supports a subset of Java (see `Cached`), and may include simple constants (for example, `0`) or static method calls. It must evaluate to an `int`. Note that only static members of the root node can be bound with the expression. Default: `"32"`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#variadicStackLimit()` ### additionalAssertions() `boolean additionalAssertions() default false`. Since 25.0. Enables additional assertions, that would be otherwise too costly outside testing. The additional assertions can also be enabled dynamically at build time by passing `-Atruffle.dsl.AdditionalAssertions=true` to the Java compiler. Default: `false`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#additionalAssertions()` ### enableThreadedSwitch() `boolean enableThreadedSwitch() default true`. Since 25.1. Enables the use of the `threaded switch` for the generated bytecode switch. The threaded-switch mechanism reduces dispatch overhead for large or frequently executed bytecode switches, improving interpreter performance. Disabling it forces a traditional (non-threaded) switch implementation, which can be useful for benchmarking or debugging but is generally slower. This option is enabled by default. It is not recommended to disable the threaded switch in production, as doing so may significantly reduce performance without improving stability. On JVMs that do not support `HostCompilerDirectives.markThreadedSwitch(int)` this flag has no effect. Default: `true`. See also: `HostCompilerDirectives.markThreadedSwitch(int)`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#enableThreadedSwitch()` ### enableInstructionTracing() `boolean enableInstructionTracing() default true`. Since 25.1. Enables instruction tracing support for the generated bytecode interpreter. If `true`, the interpreter is generated with tracing hooks so that `InstructionTracer`s can be attached at run time (via `BytecodeRootNodes.addInstructionTracer` or `BytecodeDescriptor.addInstructionTracer`). Attaching a tracer causes all executed instructions to invoke the tracer before execution. If `false`, no tracing hooks are generated and any attempt to attach a tracer will throw [`UnsupportedOperationException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/UnsupportedOperationException.html). Default: `true`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#enableInstructionTracing()` ### enableInstructionRewriting() `boolean enableInstructionRewriting() default true`. Since 25.1. Enables instruction rewriting support for the generated bytecode interpreter. Instruction rewriting is used to implement peephole optimizations (e.g., remove redundant loads) and other bytecode optimizations. Default: `true`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#enableInstructionRewriting()` ### enableTailCallHandlers() `boolean enableTailCallHandlers() default false`. Since 25.1. Enables tail call handlers for the generated bytecode interpreter. For more details, see the [ One Compilation per Bytecode Handler documentation](https://github.com/oracle/graal/blob/master/truffle/docs/OneCompilationPerBytecodeHandler.md). Default: `false`. See also: `BytecodeInterpreterHandlerConfig`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#enableTailCallHandlers()` ### sourceContentSupplier() `String sourceContentSupplier() default ""`. Since 25.1. Specifies the name of a supplier method used to convert a `Source` without content into one with content (i.e., one which has `characters` or `bytes`). Currently, only character-based sources are supported. Bytecode DSL interpreters reparse source information lazily to reduce memory footprint. By default, a root node can have either no source information or full source information: The following example demonstrates the default behavior: Some interpreters may use basic source information (e.g., line numbers) frequently, but rarely need full source content. Declaring a source content supplier allows a root node to load source information without content and later load source content only if needed: The following example demonstrates how to add a supplier method: The supplier should use the source argument's attributes (e.g., `Source.getURI`) to load content and then return a new source object. With a source content supplier, the previous example can be modified to avoid materializing source content until it is needed: The supplier may be called multiple times for a given source, so it is recommended to cache the loaded sources on the language instance, for example using a map: The supplier method must: be a `static` method defined on the root node.; declare two parameters: the `language` instance and a `Source` instance that does not have content.; return a `Source` instance with content. If loading the content can fail (e.g., a source file was deleted), the result can be a source without content (such as the original source argument), but in such a scenario the interpreter should not assume that sources will always have content after content is supplied. Default: `""`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#sourceContentSupplier()` ```java [No Source Information] --ensureSourceInformation()--> [Full Source Information] ``` ```java CharSequence content = ...; Source source = Source.newBuilder(MyLanguage.ID, content, ...).build(); var nodes = MyBytecodeRootNodeGen.create(myLanguage, BytecodeConfig.DEFAULT, b -> { b.beginSource(source); b.beginSourceSection(0, 10); b.beginRoot(); ... b.endRoot(); b.endSourceSection(); b.endSource(); }); nodes.getNode(0).getSourceSection(); // == null nodes.ensureSourceInformation(); // materializes sources by reparsing nodes.getNode(0).getSourceSection(); // == source.createSection(0, 10) nodes.getNode(0).getSourceSection().getCharacters(); // == content ``` ```java [No Source Information] ---ensureSourceInformationWithContent()---> [Full Source Information] | ^ | ensureSourceInformation() ensureSourceInformationWithContent() | v | +----------------> [Source Information (No Content)] ----------------+ ``` ```java @GenerateBytecode(sourceContentSupplier = "loadSourceContent", ...) public abstract class MyBytecodeRootNode extends RootNode implements BytecodeRootNode { public static Source loadSourceContent(MyLanguage language, Source sourceWithoutContent) { CharSequence characters = loadCharactersFromFile(sourceWithoutContent.getURI()); return Source.newBuilder(sourceWithoutContent).content(characters).build(); } } ``` ```java Source source = Source.newBuilder(MyLanguage.ID, "", ...) .content(Source.CONTENT_NONE) .build(); var nodes = MyBytecodeRootNodeGen.create(myLanguage, BytecodeConfig.DEFAULT, b -> { b.beginSource(source); b.beginSourceSection(0, 10); b.beginRoot(); ... b.endRoot(); b.endSourceSection(); b.endSource(); }); nodes.getNode(0).getSourceSection(); // == null nodes.ensureSourceInformation(); // materializes sources without content nodes.getNode(0).getSourceSection(); // == source.createSection(0, 10) nodes.getNode(0).getSourceSection().hasCharacters(); // == false nodes.ensureSourceInformationWithContent(); // materializes source content nodes.getNode(0).getSourceSection().getCharacters(); // == content supplied by loadSourceContent ``` ```java class MyLanguage extends TruffleLanguage { Map sourceContentCache = ...; } public static Source loadSourceContent(MyLanguage language, Source sourceWithoutContent) { return language.sourceContentCache.computeIfAbsent(sourceWithoutContent, unused -> { CharSequence characters = loadCharactersFromFile(sourceWithoutContent.getURI()); return Source.newBuilder(sourceWithoutContent).content(characters).build(); }); } ``` ### enableCompressedSources() `boolean enableCompressedSources() default true`. Since 25.4. Enables compression of source information tables. Source information can require a large amount of memory, and so this option makes source tables rely on a compressed encoding. This significantly reduces source table footprint, at the cost of making accessing source information less efficient because of the additional decoding step. It is set to \`true\` as a default, as the assumption is that the language is likely to only access source information infrequently, e.g. to get debugging information. Default: `true`. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecode.html#enableCompressedSources()` # @ GenerateBytecodeTestVariants [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java @Retention(SOURCE) @Target({TYPE}) public @interface GenerateBytecodeTestVariants ``` This annotation should only be used for testing to generate multiple variants of the interpreter with slightly different [`configurations`](com/oracle/truffle/api/bytecode/GenerateBytecode.md). Importantly, all of the variants' Builders share a common superclass, which allows tests to be written once and then executed with multiple configurations. In order for the variants and their Builders to be compatible, the configurations must agree on specific fields. In particular, the [`GenerateBytecode.languageClass`](com/oracle/truffle/api/bytecode/GenerateBytecode.md#languageClass%28%29) must match, and fields that generate new builder methods (e.g. [`GenerateBytecode.enableYield()`](com/oracle/truffle/api/bytecode/GenerateBytecode.md#enableYield%28%29)) must agree. These properties are checked by the Bytecode DSL processor. ## Nested types - [`GenerateBytecodeTestVariants.Variant`](com/oracle/truffle/api/bytecode/GenerateBytecodeTestVariants.Variant.md) (annotation interface): The annotation used to declare a variant. ## Elements ### value() `GenerateBytecodeTestVariants.Variant[] value()`. Since 24.2. The variants to generate. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecodeTestVariants.html#value()` # @ GenerateBytecodeTestVariants.Variant [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. Nested in [`GenerateBytecodeTestVariants`](com/oracle/truffle/api/bytecode/GenerateBytecodeTestVariants.md). ```java @Retention(SOURCE) @Target({TYPE}) public @interface GenerateBytecodeTestVariants.Variant ``` The annotation used to declare a variant. ## Elements ### suffix() `String suffix()`. Since 24.2. The class name suffix for this variant. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecodeTestVariants.Variant.html#suffix()` ### configuration() `GenerateBytecode configuration()`. Since 24.2. The configuration for this variant. Cite: `com/oracle/truffle/api/bytecode/GenerateBytecodeTestVariants.Variant.html#configuration()` # ◆ Instruction [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java public abstract class Instruction ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Instruction` Represents metadata for an instruction in a bytecode node. Compatibility note: The data contained in instruction classes is subject to change without notice between Truffle versions. This introspection API is therefore intended to be used for debugging and tracing purposes only. Do not rely on instructions for your language semantics. The current instruction can be bound using `@Bind Instruction instruction` from [`operations`](com/oracle/truffle/api/bytecode/Operation.md). This class is not intended to be subclassed by clients, only by code generated by the Bytecode DSL. **See also** - [`BytecodeNode.getInstructions()`](com/oracle/truffle/api/bytecode/BytecodeNode.md#getInstructions%28%29) - [`BytecodeNode.getInstructionsAsList()`](com/oracle/truffle/api/bytecode/BytecodeNode.md#getInstructionsAsList%28%29) - [`BytecodeNode.getInstruction(int)`](com/oracle/truffle/api/bytecode/BytecodeNode.md#getInstruction%28int%29) ## Nested types - [`Instruction.Argument`](com/oracle/truffle/api/bytecode/Instruction.Argument.md) (abstract class): Represents metadata for an argument of an instruction in a bytecode node. ## Constructors ### Instruction(Object) `protected Instruction(Object token)`. Since 24.2. Internal constructor for generated code. Do not use. Cite: `com/oracle/truffle/api/bytecode/Instruction.html#(java.lang.Object)` ## Methods ### getBytecodeNode() `public abstract BytecodeNode getBytecodeNode()`. Since 24.2. Returns the bytecode node this instruction belongs to. Cite: `com/oracle/truffle/api/bytecode/Instruction.html#getBytecodeNode()` ### getBytecodeIndex() `public abstract int getBytecodeIndex()`. Since 24.2. Returns the bytecode index of this instruction. A bytecode index is only valid for a given `BytecodeNode`, it is therefore recommended to use `getLocation()` instead whenever possible. See also: `getLocation()`. Cite: `com/oracle/truffle/api/bytecode/Instruction.html#getBytecodeIndex()` ### getDescriptor() `public InstructionDescriptor getDescriptor()`. Since 25.1. Returns the descriptor object for this instruction. The descriptor provides static metadata about the instruction executed at this bytecode index, such as its name, operation code, length in bytes, argument layout, and whether it is considered instrumentation. See also: `BytecodeDescriptor.getInstructionDescriptors()`. Cite: `com/oracle/truffle/api/bytecode/Instruction.html#getDescriptor()` ### getLength() `public int getLength()`. Since 24.2. Returns the length of this instruction in bytes. See also: `getDescriptor()`, `InstructionDescriptor.getLength()`. Cite: `com/oracle/truffle/api/bytecode/Instruction.html#getLength()` ### getLocation() `public final BytecodeLocation getLocation()`. Since 24.2. Converts this instruction pointer into a bytecode location. It is recommended to use `BytecodeLocation` to persist a bytecode location instead of using instruction. Cite: `com/oracle/truffle/api/bytecode/Instruction.html#getLocation()` ### getName() `public String getName()`. Since 24.2. Returns the name of this instruction. The name of the instruction is purely for human consumption and no structure should be assumed. If two instructions have the same instruction name then they also have the same `operation code`. The name is fixed for an `Instruction` object, but the name of an instruction at a particular `location` can change during execution due to quickening and other optimizations. See also: `getOperationCode()`, `getDescriptor()`, `InstructionDescriptor.getName()`. Cite: `com/oracle/truffle/api/bytecode/Instruction.html#getName()` ### getOperationCode() `public int getOperationCode()`. Since 24.2. Returns the operation code of this instruction. The operation code of the instruction is purely for human consumption and no values should be assumed. If two instructions have the same instruction operation code then they also have the same `name`. The operation code is fixed for an `Instruction` object, but the operation code of an instruction at a particular `location` can change during execution due to quickening and other optimizations. See also: `getName()`, `getDescriptor()`, `InstructionDescriptor.getOperationCode()`. Cite: `com/oracle/truffle/api/bytecode/Instruction.html#getOperationCode()` ### getArguments() `public abstract List getArguments()`. Since 24.2. Returns an immutable list of immediate arguments for this instructions. The number and kinds of arguments remain stable during execution, however, the actual values of the arguments (e.g., `Argument.asBranchProfile`) may change during execution. Cite: `com/oracle/truffle/api/bytecode/Instruction.html#getArguments()` ### isInstrumentation() `public boolean isInstrumentation()`. Since 24.2. Returns `true` if this instruction represents a bytecode or tag instrumentation instruction, else `false`. Instrumentation instructions may get inserted dynamically during execution, e.g., if a tag is materialized or an `Instrumentation` is `configured`. Cite: `com/oracle/truffle/api/bytecode/Instruction.html#isInstrumentation()` ### getSourceSection() `public final SourceSection getSourceSection()`. Since 24.2. Returns the most concrete source section associated with this instruction. If no source section is available for this instruction or source sections have not yet been materialized, then `null` is returned. Source sections may be materialized by calling `update` with `BytecodeConfig.WITH_SOURCE`. Cite: `com/oracle/truffle/api/bytecode/Instruction.html#getSourceSection()` ### getSourceSections() `public final SourceSection[] getSourceSections()`. Since 24.2. Returns all source section associated with this instruction starting with the most concrete source section. If no source sections are available, then an empty array is returned. If source sections have not yet been materialized, then `null` is returned. Source sections may be materialized by calling `update` with `BytecodeConfig.WITH_SOURCE`. Cite: `com/oracle/truffle/api/bytecode/Instruction.html#getSourceSections()` ### getNextBytecodeIndex() `public final int getNextBytecodeIndex()`. Since 24.2. Returns the bytecode index of the next instruction. This method is useful to quickly find the next instruction. The next bytecode index is computed as `getBytecodeIndex()`` + ``getLength()`. The next bytecode index may not be a valid index if this instruction is the last instruction. Use `BytecodeNode.getInstructions()` to walk all instructions efficiently and safely. Since the bytecode encoding is variable length, there is no efficient way to get to the previous bytecode index. Only forward traversial is efficient. If random access is desired use `BytecodeNode.getInstructionsAsList()`. Cite: `com/oracle/truffle/api/bytecode/Instruction.html#getNextBytecodeIndex()` ### next() `protected abstract Instruction next()`. Since 24.2. Returns the next instruction object. Implemented by generated code, intended for internal use only. Cite: `com/oracle/truffle/api/bytecode/Instruction.html#next()` ### hashCode() `public final int hashCode()`. Since 24.2. Overrides `hashCode()`. Cite: `com/oracle/truffle/api/bytecode/Instruction.html#hashCode()` ### equals(Object) `public final boolean equals(Object obj)`. Since 24.2. Overrides `equals(java.lang.Object)`. Cite: `com/oracle/truffle/api/bytecode/Instruction.html#equals(java.lang.Object)` ### toString() `public final String toString()`. Since 24.2. Overrides `toString()`. Cite: `com/oracle/truffle/api/bytecode/Instruction.html#toString()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ Instruction.Argument [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. Nested in [`Instruction`](com/oracle/truffle/api/bytecode/Instruction.md). ```java public abstract static class Instruction.Argument ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Argument` Represents metadata for an argument of an instruction in a bytecode node. Compatibility note: The data contained in instruction classes is subject to change without notice between Truffle versions. This introspection API is therefore intended to be used for debugging and tracing purposes only. Do not rely on instructions for your language semantics. **See also** - [`Instruction.getArguments()`](com/oracle/truffle/api/bytecode/Instruction.md#getArguments%28%29) ## Nested types - [`Instruction.Argument.BranchProfile`](com/oracle/truffle/api/bytecode/Instruction.Argument.BranchProfile.md) (record): Represents a branch profile. - [`Instruction.Argument.Kind`](com/oracle/truffle/api/bytecode/Instruction.Argument.Kind.md) (enum class): Represents the kind of an Argument. ## Constructors ### Argument(Object) `protected Argument(Object token)`. Since 24.2. Internal constructor for generated code. Do not use. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.html#(java.lang.Object)` ## Methods ### getDescriptor() `public InstructionDescriptor.ArgumentDescriptor getDescriptor()`. Since 25.1. Returns the descriptor object for this argument. The descriptor provides static metadata about the argument position and interpretation for this instruction, including its `Kind`, printable name, and encoded width in bytes. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.html#getDescriptor()` ### getKind() `public Instruction.Argument.Kind getKind()`. Since 24.2. Returns the `Kind` of this argument. The kind determines which `asX` method can be called on a given argument. For example, if the kind is `Kind.INTEGER`, the `asInteger` method will return the integer value. All other `asX` methods (e.g., `asBranchProfile`) will throw an exception. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.html#getKind()` ### getName() `public String getName()`. Since 24.2. Returns a human readable name for this argument. This could be for example `"localOffset"` for a local variable access instruction. Arguments with the same `getKind()` may have different `names`. A name is typically more descriptive than just the kind and should be preferred over the kind for debug output. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.html#getName()` ### asInteger() `public int asInteger() throws UnsupportedOperationException`. Since 24.2. Converts this argument to an `int` value. This method is only supported if the argument `kind` is `Kind.INTEGER`. If called for arguments of other kinds then an [`UnsupportedOperationException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/UnsupportedOperationException.html) is thrown. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.html#asInteger()` ### asBytecodeIndex() `public int asBytecodeIndex()`. Since 24.2. Converts this argument to a bytecode index. This method is only supported if the argument `kind` is `Kind.BYTECODE_INDEX`. If called for arguments of other kinds then an [`UnsupportedOperationException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/UnsupportedOperationException.html) is thrown. If the returned value is \>= 0 then the bytecode index can be used to be converted to a `BytecodeLocation`. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.html#asBytecodeIndex()` ### asConstant() `public Object asConstant()`. Since 24.2. Converts this argument to a object constant. This method is only supported if the argument `kind` is `Kind.CONSTANT`. If called for arguments of other kinds then an [`UnsupportedOperationException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/UnsupportedOperationException.html) is thrown. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.html#asConstant()` ### asCachedNode() `public Node asCachedNode()`. Since 24.2. Converts this argument to a `cached node`. This method is only supported if the argument `kind` is `Kind.NODE_PROFILE`. If called for arguments of other kinds then an [`UnsupportedOperationException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/UnsupportedOperationException.html) is thrown. The returned value is never `null` if the `BytecodeTier` is `BytecodeTier.CACHED`. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.html#asCachedNode()` ### asTagNode() `public TagTreeNode asTagNode()`. Since 24.2. Converts this argument to a `tag tree node`. This method is only supported if the argument `kind` is `Kind.TAG_NODE`. If called for arguments of other kinds then an [`UnsupportedOperationException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/UnsupportedOperationException.html) is thrown. The returned value is never `null`. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.html#asTagNode()` ### asLocalOffset() `public int asLocalOffset()`. Since 24.2. Converts this argument to a local offset. This method is only supported if the argument `kind` is `Kind.LOCAL_OFFSET`. If called for arguments of other kinds then an [`UnsupportedOperationException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/UnsupportedOperationException.html) is thrown. This index may be used to access locals with the local access methods in `BytecodeNode`. See also: `BytecodeNode.getLocalValue(int, com.oracle.truffle.api.frame.Frame, int)`. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.html#asLocalOffset()` ### asLocalIndex() `public int asLocalIndex()`. Since 24.2. Converts this argument to a local index. This method is only supported if the argument `kind` is `Kind.LOCAL_INDEX`. If called for arguments of other kinds then an [`UnsupportedOperationException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/UnsupportedOperationException.html) is thrown. The local index can be used to index into the list of `locals`. See also: `BytecodeNode.getLocals()`. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.html#asLocalIndex()` ### asBranchProfile() `public Instruction.Argument.BranchProfile asBranchProfile()`. Since 24.2. Converts this argument to a `branch profile`. This method is only supported if the argument `kind` is `Kind.BRANCH_PROFILE`. If called for arguments of other kinds then an [`UnsupportedOperationException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/UnsupportedOperationException.html) is thrown. The returned value is never `null`. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.html#asBranchProfile()` ### getSpecializationInfo() `public final List getSpecializationInfo()`. Since 24.2. Converts this argument to a `specialization info`. This method is only supported if the argument `kind` is `Kind.NODE_PROFILE`. If called for arguments of other kinds then an [`UnsupportedOperationException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/UnsupportedOperationException.html) is thrown. The specialization info is only available if `GenerateBytecode.enableSpecializationIntrospection()` is set to `true`. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.html#getSpecializationInfo()` ### getSpecializationInfoInternal() `protected List getSpecializationInfoInternal()`. Since 25.1. Allows the generated code to customize the specialization info lookup. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.html#getSpecializationInfoInternal()` ### toString() `public final String toString()`. Since 24.2. Overrides `toString()`. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.html#toString()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ▤ Instruction.Argument.BranchProfile [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Record in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. Nested in [`Instruction.Argument`](com/oracle/truffle/api/bytecode/Instruction.Argument.md). ```java public record Instruction.Argument.BranchProfile(int index, int trueCount, int falseCount) ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Record`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Record.html) > `BranchProfile` Represents a branch profile. **Record components** - `index` `int`: No description. - `trueCount` `int`: No description. - `falseCount` `int`: No description. ## Constructors ### BranchProfile(int, int, int) `public BranchProfile(int index, int trueCount, int falseCount)`. Declared by the compiler. Creates a new BranchProfile instance. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.BranchProfile.html#(int,int,int)` ## Methods ### getFrequency() `public double getFrequency()`. Since 24.2. Returns the frequency recorded by this profile. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.BranchProfile.html#getFrequency()` ### toString() `public String toString()`. Since 24.2. Overrides `toString()`. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.BranchProfile.html#toString()` ### hashCode() `public final int hashCode()`. Returns a hash code computed from the record components. Returns `int`: Returns a hash code computed from the record components. Overrides `hashCode()`. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.BranchProfile.html#hashCode()` ### equals(Object) `public final boolean equals(Object o)`. Returns whether the other object is a record of the same class with equal components. Parameters: `o` `Object`: The object to compare with this record. Returns `boolean`: Returns whether the other object is a record of the same class with equal components. Overrides `equals(java.lang.Object)`. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.BranchProfile.html#equals(java.lang.Object)` ### index() `public int index()`. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.BranchProfile.html#index()` ### trueCount() `public int trueCount()`. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.BranchProfile.html#trueCount()` ### falseCount() `public int falseCount()`. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.BranchProfile.html#falseCount()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ≡ Instruction.Argument.Kind [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Enum class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. Nested in [`Instruction.Argument`](com/oracle/truffle/api/bytecode/Instruction.Argument.md). ```java public enum Instruction.Argument.Kind ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html) > `Kind` Represents the kind of an [`Argument`](com/oracle/truffle/api/bytecode/Instruction.Argument.md). ## Enum constants ### CONSTANT `CONSTANT`. Since 24.2. A constant value. Typically, constants are used to encode `ConstantOperand` and LoadConstant builtin operations. See also: `Argument.asConstant()`. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.Kind.html#CONSTANT` ### BYTECODE_INDEX `BYTECODE_INDEX`. Since 24.2. A bytecode index. Typically, bytecode indices are used to encode branch targets or the locations of child instructions. See also: `Argument.asBytecodeIndex()`. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.Kind.html#BYTECODE_INDEX` ### INTEGER `INTEGER`. Since 24.2. An integer value. Typically, integer arguments are used to encode argument indices and other integer constants. See also: `Argument.asInteger()`. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.Kind.html#INTEGER` ### LOCAL_OFFSET `LOCAL_OFFSET`. Since 24.2. The logical frame offset of a local variable. If `block scoping` is enabled, multiple locals can share an offset; otherwise, a local's offset is the same as its index. Typically, local offset arguments are used to encode local variable metadata in local variable instructions. The local offset does *not* represent a frame index that can be used to directly access locals from the frame. Instead, use local accessor instructions, `LocalAccessor` operands, or the helper methods defined by the `BytecodeNode`. See also: `Argument.asLocalOffset()`. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.Kind.html#LOCAL_OFFSET` ### LOCAL_INDEX `LOCAL_INDEX`. Since 24.2. The unique index of a local variable. Typically, local index arguments are used to encode local variable metadata in local variable instructions. See also: `Argument.asLocalIndex()`. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.Kind.html#LOCAL_INDEX` ### NODE_PROFILE `NODE_PROFILE`. Since 24.2. A node profile. Typically, node profile arguments are used to encode cached nodes for user-defined `operations`. See also: `Argument.asCachedNode()`. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.Kind.html#NODE_PROFILE` ### BRANCH_PROFILE `BRANCH_PROFILE`. Since 24.2. A branch profile. Typically, branch profiles are used to profile the outcomes of conditional branch instructions. See also: `Argument.asBranchProfile()`. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.Kind.html#BRANCH_PROFILE` ### TAG_NODE `TAG_NODE`. A `TagTreeNode`. Typically, tag tree nodes are used to represent nodes in the logical tag tree defined by Tag operations. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.Kind.html#TAG_NODE` ## Methods ### values() `public static Instruction.Argument.Kind[] values()`. Returns the enum constants in declaration order. Returns `Instruction.Argument.Kind[]`: Returns the enum constants in declaration order. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.Kind.html#values()` ### valueOf(String) `public static Instruction.Argument.Kind valueOf(String name)`. Returns the enum constant with the given name. Parameters: `name` `String`: The exact name of the enum constant. Returns `Instruction.Argument.Kind`: Returns the enum constant with the given name. Cite: `com/oracle/truffle/api/bytecode/Instruction.Argument.Kind.html#valueOf(java.lang.String)` ## Inherited members - From class [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#clone%28%29), [`compareTo`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#compareTo%28E%29), [`describeConstable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#describeConstable%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#finalize%28%29), [`getDeclaringClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#getDeclaringClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#hashCode%28%29), [`name`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#name%28%29), [`ordinal`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#ordinal%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#toString%28%29), [`valueOf`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#valueOf%28java.lang.Class,java.lang.String%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ InstructionDescriptor [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 25.1. ```java public abstract class InstructionDescriptor ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `InstructionDescriptor` Descriptor for a concrete bytecode instruction. Instances describe static properties of an instruction, for example name, length and arguments. ## Nested types - [`InstructionDescriptor.ArgumentDescriptor`](com/oracle/truffle/api/bytecode/InstructionDescriptor.ArgumentDescriptor.md) (abstract class): Descriptor for a single immediate argument of an instruction. ## Constructors ### InstructionDescriptor(Object) `protected InstructionDescriptor(Object token)`. Since 25.1. Internal constructor for generated code. Do not use. Cite: `com/oracle/truffle/api/bytecode/InstructionDescriptor.html#(java.lang.Object)` ## Methods ### getLength() `public abstract int getLength()`. Since 25.1. Returns the encoded size of this instruction in bytes. Cite: `com/oracle/truffle/api/bytecode/InstructionDescriptor.html#getLength()` ### getName() `public abstract String getName()`. Since 25.1. Returns a human readable instruction name. Two descriptors with the same name also have the same `operation code`. See also: `getOperationCode()`. Cite: `com/oracle/truffle/api/bytecode/InstructionDescriptor.html#getName()` ### getOperationCode() `public abstract int getOperationCode()`. Since 25.1. Returns the operation code for this instruction. The value is only intended for debugging or tooling. Two descriptors with the same operation code also have the same `name`. See also: `getName()`. Cite: `com/oracle/truffle/api/bytecode/InstructionDescriptor.html#getOperationCode()` ### getOperationClass() `public Class getOperationClass()`. Since 25.7. Returns the class defining the custom operation that produced this instruction. Quickened instructions return the same class as their unquickened instruction. For an `OperationProxy`, this is the proxied class, not a generated node class. Returns `null` if the operation class is unavailable, including for built-in instructions and `short-circuit instructions`. Returns `Class`: the operation class, or `null` if unavailable. Cite: `com/oracle/truffle/api/bytecode/InstructionDescriptor.html#getOperationClass()` ### getArgumentDescriptors() `public abstract List getArgumentDescriptors()`. Since 25.1. Returns an immutable list describing the immediate arguments of this instruction. The list size and the descriptor kinds are stable, the runtime values of the arguments may change. Cite: `com/oracle/truffle/api/bytecode/InstructionDescriptor.html#getArgumentDescriptors()` ### isInstrumentation() `public abstract boolean isInstrumentation()`. Since 25.1. Returns `true` if this instruction represents a bytecode or tag instrumentation instruction, else `false`. Instrumentation instructions may get inserted dynamically during execution, e.g., if a tag is materialized or an `Instrumentation` is `configured`. Cite: `com/oracle/truffle/api/bytecode/InstructionDescriptor.html#isInstrumentation()` ### hashCode() `public int hashCode()`. Since 25.1. Overrides `hashCode()`. Cite: `com/oracle/truffle/api/bytecode/InstructionDescriptor.html#hashCode()` ### equals(Object) `public boolean equals(Object obj)`. Since 25.1. Overrides `equals(java.lang.Object)`. Cite: `com/oracle/truffle/api/bytecode/InstructionDescriptor.html#equals(java.lang.Object)` ### toString() `public String toString()`. Since 25.1. Overrides `toString()`. Cite: `com/oracle/truffle/api/bytecode/InstructionDescriptor.html#toString()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ InstructionDescriptor.ArgumentDescriptor [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 25.1. Nested in [`InstructionDescriptor`](com/oracle/truffle/api/bytecode/InstructionDescriptor.md). ```java public abstract static class InstructionDescriptor.ArgumentDescriptor ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `ArgumentDescriptor` Descriptor for a single immediate argument of an instruction. Captures kind, name and encoded width of the argument. ## Constructors ### ArgumentDescriptor(Object) `protected ArgumentDescriptor(Object token)`. Since 25.1. Internal constructor for generated code. Do not use. Cite: `com/oracle/truffle/api/bytecode/InstructionDescriptor.ArgumentDescriptor.html#(java.lang.Object)` ## Methods ### getKind() `public abstract Instruction.Argument.Kind getKind()`. Since 25.1. Returns the `Kind` of this argument descriptor. Cite: `com/oracle/truffle/api/bytecode/InstructionDescriptor.ArgumentDescriptor.html#getKind()` ### getName() `public abstract String getName()`. Since 25.1. Returns a human readable name for this argument. This could be for example `"localOffset"` for a local variable access instruction. Arguments with the same `getKind()` may have different `names`. A name is typically more descriptive than just the kind and should be preferred over the kind for debug output. Cite: `com/oracle/truffle/api/bytecode/InstructionDescriptor.ArgumentDescriptor.html#getName()` ### getLength() `public abstract int getLength()`. Since 25.1. Returns width in bytes. Cite: `com/oracle/truffle/api/bytecode/InstructionDescriptor.ArgumentDescriptor.html#getLength()` ### toString() `public String toString()`. Since 25.1. Overrides `toString()`. Cite: `com/oracle/truffle/api/bytecode/InstructionDescriptor.ArgumentDescriptor.html#toString()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ InstructionTracer [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 25.1. ```java public interface InstructionTracer ``` A low-overhead callback interface to observe instruction execution in Bytecode DSL interpreters. A tracer receives a notification immediately before the interpreter executes the instruction at a given bytecode index. The callback runs on the language thread that executes the bytecode, on the hot path, and may be invoked at very high frequency. Tracers for a [`BytecodeRootNodes`](com/oracle/truffle/api/bytecode/BytecodeRootNodes.md) instance may be attached via the [`BytecodeRootNodes.addInstructionTracer(InstructionTracer)`](com/oracle/truffle/api/bytecode/BytecodeRootNodes.md#addInstructionTracer%28com.oracle.truffle.api.bytecode.InstructionTracer%29) method. Attaching tracers to all root node instances of a [`BytecodeDescriptor`](com/oracle/truffle/api/bytecode/BytecodeDescriptor.md) is possible using [`BytecodeDescriptor.addInstructionTracer(TruffleLanguage, InstructionTracer)`](com/oracle/truffle/api/bytecode/BytecodeDescriptor.md#addInstructionTracer%28L,com.oracle.truffle.api.bytecode.InstructionTracer%29). Note that attaching a tracer requires all affected root nodes to be invalidated and is therefore a very expensive operation. It also potentially requires all root nodes to be re-parsed. As a trade-off, not using an instruction tracer is basically free, except for reserving instructions in the bytecode interpreter, similar to how the [`@Instrumentation`](com/oracle/truffle/api/bytecode/Instrumentation.md) annotation is implemented. Typical uses include printing a trace, maintaining per-opcode counters, or driving custom debugging or testing utilities. For convenience, the `com.oracle.truffle.api.bytecode.debug` package provides reference implementations such as a [`line printer`](com/oracle/truffle/api/bytecode/debug/PrintInstructionTracer.md) and a [`histogram tracer`](com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.md). **Performance considerations.** - Instruction tracers are subject to partial evaluation, with the tracer reference being a partial-evaluation constant, allowing the tracer to be optimized. - Prefer [`InstructionAccess.getTracedOperationCode(BytecodeNode, int)`](com/oracle/truffle/api/bytecode/InstructionTracer.InstructionAccess.md#getTracedOperationCode%28com.oracle.truffle.api.bytecode.BytecodeNode,int%29) for fast-path logic. In generated interpreters this typically avoids allocating an [`Instruction`](com/oracle/truffle/api/bytecode/Instruction.md) object. - [`InstructionAccess.getTracedInstruction(BytecodeNode, int)`](com/oracle/truffle/api/bytecode/InstructionTracer.InstructionAccess.md#getTracedInstruction%28com.oracle.truffle.api.bytecode.BytecodeNode,int%29) materializes an [`Instruction`](com/oracle/truffle/api/bytecode/Instruction.md) object and is therefore more expensive. Use it only when metadata is actually needed, for example to print the instruction name or retrieve source sections. **See also** - [`BytecodeRootNodes.addInstructionTracer(InstructionTracer)`](com/oracle/truffle/api/bytecode/BytecodeRootNodes.md#addInstructionTracer%28com.oracle.truffle.api.bytecode.InstructionTracer%29) - [`BytecodeDescriptor.addInstructionTracer(TruffleLanguage, InstructionTracer)`](com/oracle/truffle/api/bytecode/BytecodeDescriptor.md#addInstructionTracer%28L,com.oracle.truffle.api.bytecode.InstructionTracer%29) ## Nested types - [`InstructionTracer.InstructionAccess`](com/oracle/truffle/api/bytecode/InstructionTracer.InstructionAccess.md) (abstract class): Accessor for properties of the instruction about to execute. ## Methods ### onInstructionEnter(InstructionTracer.InstructionAccess, BytecodeNode, …) `void onInstructionEnter(InstructionTracer.InstructionAccess access, BytecodeNode bytecode, int bytecodeIndex, Frame frame)`. Since 25.1. Called immediately before executing the instruction at `bytecodeIndex` of the given `bytecode` node. Parameters: `access` `InstructionTracer.InstructionAccess`: accessor to query information about the current instruction, valid only during this call. `bytecode` `BytecodeNode`: the `BytecodeNode` currently being interpreted. `bytecodeIndex` `int`: the bytecode index (BCI) of the instruction to be executed. `frame` `Frame`: the current frame for the root being interpreted. Cite: `com/oracle/truffle/api/bytecode/InstructionTracer.html#onInstructionEnter(com.oracle.truffle.api.bytecode.InstructionTracer.InstructionAccess,com.oracle.truffle.api.bytecode.BytecodeNode,int,com.oracle.truffle.api.frame.Frame)` ### getExclusiveBytecodeDescriptor() `default BytecodeDescriptor getExclusiveBytecodeDescriptor()`. Since 25.1. Returns the `BytecodeDescriptor` that this tracer is exclusive for, or `null` if this instruction tracer may be used with any bytecode descriptor. Cite: `com/oracle/truffle/api/bytecode/InstructionTracer.html#getExclusiveBytecodeDescriptor()` # ◆ InstructionTracer.InstructionAccess [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 25.1. Nested in [`InstructionTracer`](com/oracle/truffle/api/bytecode/InstructionTracer.md). ```java public abstract class InstructionTracer.InstructionAccess ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `InstructionAccess` Accessor for properties of the instruction about to execute. Instances of this class are provided by the generated interpreter and are scoped to a single [`InstructionTracer.onInstructionEnter`](com/oracle/truffle/api/bytecode/InstructionTracer.md#onInstructionEnter%28com.oracle.truffle.api.bytecode.InstructionTracer.InstructionAccess,com.oracle.truffle.api.bytecode.BytecodeNode,int,com.oracle.truffle.api.frame.Frame%29) invocation. They must not be stored, shared across threads, or used after the callback returns. ## Constructors ### InstructionAccess(Object) `protected InstructionAccess(Object token)`. Since 25.1. Internal constructor for generated code. Cite: `com/oracle/truffle/api/bytecode/InstructionTracer.InstructionAccess.html#(java.lang.Object)` ## Methods ### getTracedInstruction(BytecodeNode, int) `public abstract Instruction getTracedInstruction(BytecodeNode bytecode, int bytecodeIndex)`. Since 25.1. Materializes the `Instruction` object for the instruction at the given bytecode index. Parameters: `bytecode` `BytecodeNode`: the `BytecodeNode` currently being interpreted. `bytecodeIndex` `int`: the bytecode index (BCI) of the instruction. Returns `Instruction`: the materialized `Instruction` representing the instruction at `BCI`. Cite: `com/oracle/truffle/api/bytecode/InstructionTracer.InstructionAccess.html#getTracedInstruction(com.oracle.truffle.api.bytecode.BytecodeNode,int)` ### getTracedOperationCode(BytecodeNode, int) `public abstract int getTracedOperationCode(BytecodeNode bytecode, int bytecodeIndex)`. Since 25.1. Returns the operation code for the instruction at the given bytecode index, without allocating an `Instruction` object. The returned value corresponds to `Instruction.getOperationCode()` for the same instruction. Parameters: `bytecode` `BytecodeNode`: the `BytecodeNode` currently being interpreted. `bytecodeIndex` `int`: the bytecode index (BCI) of the instruction. Returns `int`: the integer operation code of the instruction at `BCI`. See also: `Instruction.getOperationCode()`. Cite: `com/oracle/truffle/api/bytecode/InstructionTracer.InstructionAccess.html#getTracedOperationCode(com.oracle.truffle.api.bytecode.BytecodeNode,int)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # @ Instrumentation [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java @Retention(SOURCE) @Target({TYPE}) public @interface Instrumentation ``` Instrumentations are operations that can be dynamically enabled at runtime. Dynamically enabling them at runtime allows them to be used to implement features that are not commonly enabled, like tracing, language internal debugging, profiling or taint tracking. Instrumentations are emitted like regular operations with the [`builder`](com/oracle/truffle/api/bytecode/BytecodeBuilder.md), but only generate instructions if they are enabled in the [`BytecodeConfig`](com/oracle/truffle/api/bytecode/BytecodeConfig.md). A bytecode config with enabled instrumentations can be provided at parse time, when deserializing or using the [`update`](com/oracle/truffle/api/bytecode/BytecodeRootNodes.md#update%28com.oracle.truffle.api.bytecode.BytecodeConfig%29) method at any time. Unlike regular operations, instrumentations must have transparent stack effects. This is important to ensure that the stack layout remains compatible when instrumentations are enabled at runtime. This means that instrumentations can either have no dynamic operands and no return value or one dynamic operand and one return value. Note that instrumentations can declare [`constant operands`](com/oracle/truffle/api/bytecode/ConstantOperand.md) since those do not affect the stack. Instrumentations with one operand and return value may freely modify values observed at runtime. [`Boxing elimination`](com/oracle/truffle/api/bytecode/GenerateBytecode.md#boxingEliminationTypes%28%29) is reset when new instrumentations are enabled, but it will also work for instrumentation operations. Note that instrumentations cannot specify any [`tags`](com/oracle/truffle/api/bytecode/Operation.md#tags%28%29), because tags must be stable and new tags cannot be specified at runtime. Instrumentations can also not be used as boolean converters for [`short circuits`](com/oracle/truffle/api/bytecode/ShortCircuitOperation.md). ## Elements ### forceCached() `boolean forceCached() default false`. Since 24.2. Whether executing this operation should force the uncached interpreter (if enabled) to transition to cached. Default: `false`. See also: `Operation.forceCached()`. Cite: `com/oracle/truffle/api/bytecode/Instrumentation.html#forceCached()` ### javadoc() `String javadoc() default ""`. Since 24.2. Optional documentation for the instrumentation. This documentation is included in the javadoc for the generated interpreter. Default: `""`. Cite: `com/oracle/truffle/api/bytecode/Instrumentation.html#javadoc()` ### storeBytecodeIndex() `boolean storeBytecodeIndex() default true`. Since 25.1. Whether to store the BCI before executing this operation. See `Operation.storeBytecodeIndex()` for mode-dependent defaults. When `false`, `StoreBytecodeIndex` enables storage for individual `Specialization` or `Fallback` methods. Returns `boolean`: whether to enable operation-level BCI storage. Default: `true`. Cite: `com/oracle/truffle/api/bytecode/Instrumentation.html#storeBytecodeIndex()` # ◆ LocalAccessor [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java public final class LocalAccessor ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `LocalAccessor` Operation parameter that allows an operation to get, set, and clear the value of a local. To use a local accessor, declare a [`ConstantOperand`](com/oracle/truffle/api/bytecode/ConstantOperand.md) on the operation. The corresponding builder method for the operation will take a [`BytecodeLocal`](com/oracle/truffle/api/bytecode/BytecodeLocal.md) argument for the local to be accessed. At run time, a [`LocalAccessor`](com/oracle/truffle/api/bytecode/LocalAccessor.md) for the local will be supplied as a parameter to the operation. Local accessors are useful to implement behaviour that cannot be implemented with the builtin local operations (like StoreLocal). For example, if an operation produces multiple outputs, it can write one of the outputs to a local using a local accessor. Prefer builtin operations when possible, since they automatically work with [`boxing elimination`](com/oracle/truffle/api/bytecode/GenerateBytecode.md#boxingEliminationTypes%28%29). Local accessors should be preferred over [`BytecodeNode`](com/oracle/truffle/api/bytecode/BytecodeNode.md) helpers like [`BytecodeNode.getLocalValue(int, Frame, int)`](com/oracle/truffle/api/bytecode/BytecodeNode.md#getLocalValue%28int,com.oracle.truffle.api.frame.Frame,int%29), since the helpers use extra indirection. All of the accessor methods take a [`bytecode node`](com/oracle/truffle/api/bytecode/BytecodeNode.md) and the current [`frame`](com/oracle/truffle/api/frame/VirtualFrame.md). The bytecode node should be the current bytecode node and correspond to the root that declares the local; it should be compilation-final. The frame should contain the local. Example usage: ```java @Operation @ConstantOperand(type = LocalAccessor.class) public static final class GetLocal { @Specialization public static Object perform(VirtualFrame frame, LocalAccessor accessor, @Bind BytecodeNode bytecodeNode) { return accessor.getObject(bytecodeNode, frame); } } ``` ## Methods ### toString() `public String toString()`. Since 24.2. Returns a string representation of a `LocalAccessor`. Overrides `toString()`. Cite: `com/oracle/truffle/api/bytecode/LocalAccessor.html#toString()` ### getObject(BytecodeNode, VirtualFrame) `public Object getObject(BytecodeNode bytecodeNode, VirtualFrame frame)`. Since 24.2. Loads an object from the local. Cite: `com/oracle/truffle/api/bytecode/LocalAccessor.html#getObject(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame)` ### getBoolean(BytecodeNode, VirtualFrame) `public boolean getBoolean(BytecodeNode bytecodeNode, VirtualFrame frame) throws UnexpectedResultException`. Since 24.2. Loads a boolean from the local. Cite: `com/oracle/truffle/api/bytecode/LocalAccessor.html#getBoolean(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame)` ### getByte(BytecodeNode, VirtualFrame) `public byte getByte(BytecodeNode bytecodeNode, VirtualFrame frame) throws UnexpectedResultException`. Since 24.2. Loads a byte from the local. Cite: `com/oracle/truffle/api/bytecode/LocalAccessor.html#getByte(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame)` ### getInt(BytecodeNode, VirtualFrame) `public int getInt(BytecodeNode bytecodeNode, VirtualFrame frame) throws UnexpectedResultException`. Since 24.2. Loads an int from the local. Cite: `com/oracle/truffle/api/bytecode/LocalAccessor.html#getInt(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame)` ### getLong(BytecodeNode, VirtualFrame) `public long getLong(BytecodeNode bytecodeNode, VirtualFrame frame) throws UnexpectedResultException`. Since 24.2. Loads a long from the local. Cite: `com/oracle/truffle/api/bytecode/LocalAccessor.html#getLong(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame)` ### getFloat(BytecodeNode, VirtualFrame) `public float getFloat(BytecodeNode bytecodeNode, VirtualFrame frame) throws UnexpectedResultException`. Since 24.2. Loads a float from the local. Cite: `com/oracle/truffle/api/bytecode/LocalAccessor.html#getFloat(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame)` ### getDouble(BytecodeNode, VirtualFrame) `public double getDouble(BytecodeNode bytecodeNode, VirtualFrame frame) throws UnexpectedResultException`. Since 24.2. Loads a double from the local. Cite: `com/oracle/truffle/api/bytecode/LocalAccessor.html#getDouble(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame)` ### setObject(BytecodeNode, VirtualFrame, Object) `public void setObject(BytecodeNode bytecodeNode, VirtualFrame frame, Object value)`. Since 24.2. Stores an object into the local. Cite: `com/oracle/truffle/api/bytecode/LocalAccessor.html#setObject(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame,java.lang.Object)` ### setBoolean(BytecodeNode, VirtualFrame, boolean) `public void setBoolean(BytecodeNode bytecodeNode, VirtualFrame frame, boolean value)`. Since 24.2. Stores a short into the local. Cite: `com/oracle/truffle/api/bytecode/LocalAccessor.html#setBoolean(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame,boolean)` ### setByte(BytecodeNode, VirtualFrame, byte) `public void setByte(BytecodeNode bytecodeNode, VirtualFrame frame, byte value)`. Since 24.2. Stores a byte into the local. Cite: `com/oracle/truffle/api/bytecode/LocalAccessor.html#setByte(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame,byte)` ### setInt(BytecodeNode, VirtualFrame, int) `public void setInt(BytecodeNode bytecodeNode, VirtualFrame frame, int value)`. Since 24.2. Stores an int into the local. Cite: `com/oracle/truffle/api/bytecode/LocalAccessor.html#setInt(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame,int)` ### setLong(BytecodeNode, VirtualFrame, long) `public void setLong(BytecodeNode bytecodeNode, VirtualFrame frame, long value)`. Since 24.2. Stores a long into the local. Cite: `com/oracle/truffle/api/bytecode/LocalAccessor.html#setLong(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame,long)` ### setFloat(BytecodeNode, VirtualFrame, float) `public void setFloat(BytecodeNode bytecodeNode, VirtualFrame frame, float value)`. Since 24.2. Stores a float into the local. Cite: `com/oracle/truffle/api/bytecode/LocalAccessor.html#setFloat(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame,float)` ### setDouble(BytecodeNode, VirtualFrame, double) `public void setDouble(BytecodeNode bytecodeNode, VirtualFrame frame, double value)`. Since 24.2. Stores a double into the local. Cite: `com/oracle/truffle/api/bytecode/LocalAccessor.html#setDouble(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame,double)` ### clear(BytecodeNode, VirtualFrame) `public void clear(BytecodeNode bytecodeNode, VirtualFrame frame)`. Since 24.2. Clears the local from the frame. Clearing the slot marks the frame slot as `illegal`. An exception will be thrown if it is read before being set. Clearing does *not* insert a `default local value`, if specified. Cite: `com/oracle/truffle/api/bytecode/LocalAccessor.html#clear(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame)` ### isCleared(BytecodeNode, VirtualFrame) `public boolean isCleared(BytecodeNode bytecodeNode, VirtualFrame frame)`. Since 24.2. Checks whether the local has been `cleared` (and a new value has not been set). This method also returns `true` if a local has not been initialized and no `default local value` is specified. Cite: `com/oracle/truffle/api/bytecode/LocalAccessor.html#isCleared(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame)` ### getLocalName(BytecodeNode) `public Object getLocalName(BytecodeNode bytecodeNode)`. Since 24.2. Returns the name associated with the local. See also: `BytecodeNode.getLocalName(int, int)`. Cite: `com/oracle/truffle/api/bytecode/LocalAccessor.html#getLocalName(com.oracle.truffle.api.bytecode.BytecodeNode)` ### getLocalInfo(BytecodeNode) `public Object getLocalInfo(BytecodeNode bytecodeNode)`. Since 24.2. Returns the info associated with the local. See also: `BytecodeNode.getLocalInfo(int, int)`. Cite: `com/oracle/truffle/api/bytecode/LocalAccessor.html#getLocalInfo(com.oracle.truffle.api.bytecode.BytecodeNode)` ### constantOf(BytecodeLocal) `public static LocalAccessor constantOf(BytecodeLocal local)`. Since 24.2. Obtains a `LocalAccessor`. This method is invoked by the generated code and should not be called directly. Cite: `com/oracle/truffle/api/bytecode/LocalAccessor.html#constantOf(com.oracle.truffle.api.bytecode.BytecodeLocal)` ### equals(Object) `public boolean equals(Object obj)`. Overrides `equals(java.lang.Object)`. Cite: `com/oracle/truffle/api/bytecode/LocalAccessor.html#equals(java.lang.Object)` ### hashCode() `public int hashCode()`. Overrides `hashCode()`. Cite: `com/oracle/truffle/api/bytecode/LocalAccessor.html#hashCode()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ LocalRangeAccessor [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java public final class LocalRangeAccessor ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `LocalRangeAccessor` Operation parameter that allows an operation to get, set, or clear locals declared in a contiguous range. To use a local range accessor, declare a [`ConstantOperand`](com/oracle/truffle/api/bytecode/ConstantOperand.md) on the operation. The corresponding builder method for the operation will take a [`BytecodeLocal`](com/oracle/truffle/api/bytecode/BytecodeLocal.md) array argument for the locals to be accessed. These locals must be allocated sequentially during building. At run time, a [`LocalRangeAccessor`](com/oracle/truffle/api/bytecode/LocalRangeAccessor.md) for the locals will be supplied as a parameter to the operation. All of the accessor methods take a [`BytecodeNode`](com/oracle/truffle/api/bytecode/BytecodeNode.md), the current [`Frame`](com/oracle/truffle/api/frame/Frame.md), and an offset. The offset should be a valid compilation-final index into the array of locals. See the [`LocalAccessor`](com/oracle/truffle/api/bytecode/LocalAccessor.md) javadoc for restrictions on the other parameters and usage recommendations. ## Methods ### getLength() `public int getLength()`. Since 24.2. Returns the length of the range. Cite: `com/oracle/truffle/api/bytecode/LocalRangeAccessor.html#getLength()` ### hashCode() `public int hashCode()`. Overrides `hashCode()`. Cite: `com/oracle/truffle/api/bytecode/LocalRangeAccessor.html#hashCode()` ### equals(Object) `public boolean equals(Object obj)`. Overrides `equals(java.lang.Object)`. Cite: `com/oracle/truffle/api/bytecode/LocalRangeAccessor.html#equals(java.lang.Object)` ### toString() `public String toString()`. Since 24.2. Returns a string representation of a `LocalRangeAccessor`. Overrides `toString()`. Cite: `com/oracle/truffle/api/bytecode/LocalRangeAccessor.html#toString()` ### getObject(BytecodeNode, VirtualFrame, int) `public Object getObject(BytecodeNode bytecodeNode, VirtualFrame frame, int offset)`. Since 24.2. Loads an object from the local at the given offset into the range. Parameters: `offset` `int`: a partial evaluation constant offset into the range. Cite: `com/oracle/truffle/api/bytecode/LocalRangeAccessor.html#getObject(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame,int)` ### getBoolean(BytecodeNode, VirtualFrame, int) `public boolean getBoolean(BytecodeNode bytecodeNode, VirtualFrame frame, int offset) throws UnexpectedResultException`. Since 24.2. Loads a boolean from the local at the given offset into the range. Parameters: `offset` `int`: a partial evaluation constant offset into the range. Cite: `com/oracle/truffle/api/bytecode/LocalRangeAccessor.html#getBoolean(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame,int)` ### getByte(BytecodeNode, VirtualFrame, int) `public byte getByte(BytecodeNode bytecodeNode, VirtualFrame frame, int offset) throws UnexpectedResultException`. Since 24.2. Loads a byte from the local at the given offset into the range. Parameters: `offset` `int`: a partial evaluation constant offset into the range. Cite: `com/oracle/truffle/api/bytecode/LocalRangeAccessor.html#getByte(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame,int)` ### getInt(BytecodeNode, VirtualFrame, int) `public int getInt(BytecodeNode bytecodeNode, VirtualFrame frame, int offset) throws UnexpectedResultException`. Since 24.2. Loads an int from the local at the given offset into the range. Parameters: `offset` `int`: a partial evaluation constant offset into the range. Cite: `com/oracle/truffle/api/bytecode/LocalRangeAccessor.html#getInt(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame,int)` ### getLong(BytecodeNode, VirtualFrame, int) `public long getLong(BytecodeNode bytecodeNode, VirtualFrame frame, int offset) throws UnexpectedResultException`. Since 24.2. Loads a long from the local at the given offset into the range. Parameters: `offset` `int`: a partial evaluation constant offset into the range. Cite: `com/oracle/truffle/api/bytecode/LocalRangeAccessor.html#getLong(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame,int)` ### getFloat(BytecodeNode, VirtualFrame, int) `public float getFloat(BytecodeNode bytecodeNode, VirtualFrame frame, int offset) throws UnexpectedResultException`. Since 24.2. Loads a float from the local at the given offset into the range. Parameters: `offset` `int`: a partial evaluation constant offset into the range. Cite: `com/oracle/truffle/api/bytecode/LocalRangeAccessor.html#getFloat(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame,int)` ### getDouble(BytecodeNode, VirtualFrame, int) `public double getDouble(BytecodeNode bytecodeNode, VirtualFrame frame, int offset) throws UnexpectedResultException`. Since 24.2. Loads a double from the local at the given offset into the range. Parameters: `offset` `int`: a partial evaluation constant offset into the range. Cite: `com/oracle/truffle/api/bytecode/LocalRangeAccessor.html#getDouble(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame,int)` ### setObject(BytecodeNode, VirtualFrame, …) `public void setObject(BytecodeNode bytecodeNode, VirtualFrame frame, int offset, Object value)`. Since 24.2. Stores an object into the local at the given offset into the range. Parameters: `offset` `int`: a partial evaluation constant offset into the range. Cite: `com/oracle/truffle/api/bytecode/LocalRangeAccessor.html#setObject(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame,int,java.lang.Object)` ### setBoolean(BytecodeNode, VirtualFrame, …) `public void setBoolean(BytecodeNode bytecodeNode, VirtualFrame frame, int offset, boolean value)`. Since 24.2. Stores a boolean into the local at the given offset into the range. Parameters: `offset` `int`: a partial evaluation constant offset into the range. Cite: `com/oracle/truffle/api/bytecode/LocalRangeAccessor.html#setBoolean(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame,int,boolean)` ### setByte(BytecodeNode, VirtualFrame, …) `public void setByte(BytecodeNode bytecodeNode, VirtualFrame frame, int offset, byte value)`. Since 24.2. Stores a byte into the local at the given offset into the range. Parameters: `offset` `int`: a partial evaluation constant offset into the range. Cite: `com/oracle/truffle/api/bytecode/LocalRangeAccessor.html#setByte(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame,int,byte)` ### setInt(BytecodeNode, VirtualFrame, …) `public void setInt(BytecodeNode bytecodeNode, VirtualFrame frame, int offset, int value)`. Since 24.2. Stores an int into the local at the given offset into the range. Parameters: `offset` `int`: a partial evaluation constant offset into the range. Cite: `com/oracle/truffle/api/bytecode/LocalRangeAccessor.html#setInt(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame,int,int)` ### setLong(BytecodeNode, VirtualFrame, …) `public void setLong(BytecodeNode bytecodeNode, VirtualFrame frame, int offset, long value)`. Since 24.2. Stores a long into the local at the given offset into the range. Parameters: `offset` `int`: a partial evaluation constant offset into the range. Cite: `com/oracle/truffle/api/bytecode/LocalRangeAccessor.html#setLong(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame,int,long)` ### setFloat(BytecodeNode, VirtualFrame, …) `public void setFloat(BytecodeNode bytecodeNode, VirtualFrame frame, int offset, float value)`. Since 24.2. Stores a float into the local at the given offset into the range. Parameters: `offset` `int`: a partial evaluation constant offset into the range. Cite: `com/oracle/truffle/api/bytecode/LocalRangeAccessor.html#setFloat(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame,int,float)` ### setDouble(BytecodeNode, VirtualFrame, …) `public void setDouble(BytecodeNode bytecodeNode, VirtualFrame frame, int offset, double value)`. Since 24.2. Stores a double into the local at the given offset into the range. Parameters: `offset` `int`: a partial evaluation constant offset into the range. Cite: `com/oracle/truffle/api/bytecode/LocalRangeAccessor.html#setDouble(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame,int,double)` ### clear(BytecodeNode, VirtualFrame, int) `public void clear(BytecodeNode bytecodeNode, VirtualFrame frame, int offset)`. Since 24.2. Clears the local at the given offset into the range. Parameters: `offset` `int`: a partial evaluation constant offset into the range. See also: `LocalAccessor.clear`. Cite: `com/oracle/truffle/api/bytecode/LocalRangeAccessor.html#clear(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame,int)` ### isCleared(BytecodeNode, VirtualFrame, int) `public boolean isCleared(BytecodeNode bytecodeNode, VirtualFrame frame, int offset)`. Since 24.2. Checks whether the local at the given offset into the range has been `cleared` (and a new value has not been set). Parameters: `offset` `int`: a partial evaluation constant offset into the range. See also: `LocalAccessor.isCleared`. Cite: `com/oracle/truffle/api/bytecode/LocalRangeAccessor.html#isCleared(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.VirtualFrame,int)` ### getLocalName(BytecodeNode, int) `public Object getLocalName(BytecodeNode bytecodeNode, int offset)`. Since 24.2. Returns the name associated with the local. See also: `BytecodeNode.getLocalName(int, int)`. Cite: `com/oracle/truffle/api/bytecode/LocalRangeAccessor.html#getLocalName(com.oracle.truffle.api.bytecode.BytecodeNode,int)` ### getLocalInfo(BytecodeNode, int) `public Object getLocalInfo(BytecodeNode bytecodeNode, int offset)`. Since 24.2. Returns the info associated with the local. See also: `BytecodeNode.getLocalInfo(int, int)`. Cite: `com/oracle/truffle/api/bytecode/LocalRangeAccessor.html#getLocalInfo(com.oracle.truffle.api.bytecode.BytecodeNode,int)` ### constantOf(BytecodeLocal[]) `public static LocalRangeAccessor constantOf(BytecodeLocal[] locals)`. Since 24.2. Obtains a `LocalRangeAccessor`. This method is invoked by the generated code and should not be called directly. Cite: `com/oracle/truffle/api/bytecode/LocalRangeAccessor.html#constantOf(com.oracle.truffle.api.bytecode.BytecodeLocal[])` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ LocalVariable [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java public abstract class LocalVariable ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `LocalVariable` Introspection class modeling a local variable and its liveness info in a bytecode interpreter. There can be more than one local variable for a given [`BytecodeLocal`](com/oracle/truffle/api/bytecode/BytecodeLocal.md) because locals can be live for multiple disjoint bytecode ranges. Note: Introspection classes are intended to be used for debugging purposes only. These APIs may change in the future. **See also** - [`BytecodeNode.getLocals()`](com/oracle/truffle/api/bytecode/BytecodeNode.md#getLocals%28%29) ## Constructors ### LocalVariable(Object) `protected LocalVariable(Object token)`. Since 24.2. Internal constructor for generated code. Do not use. Cite: `com/oracle/truffle/api/bytecode/LocalVariable.html#(java.lang.Object)` ## Methods ### getStartIndex() `public int getStartIndex()`. Since 24.2. Returns the bytecode index at which this local starts being live. If `block scoping` is disabled, returns `-1`. Cite: `com/oracle/truffle/api/bytecode/LocalVariable.html#getStartIndex()` ### getEndIndex() `public int getEndIndex()`. Since 24.2. Returns the bytecode index at which this local stops being live. If `block scoping` is disabled, returns `-1`. Cite: `com/oracle/truffle/api/bytecode/LocalVariable.html#getEndIndex()` ### getLocalOffset() `public abstract int getLocalOffset()`. Since 24.2. Returns the logical frame offset of a local variable. The local index should be used with local accessor methods like `BytecodeNode.getLocalValue(int, Frame, int)` (it does *not* represent a frame index that can be used to directly access the frame). Always returns an integer greater or equal to zero. If `block scoping` is enabled, multiple locals can share an offset; otherwise, the local offset is the same as the `local index`. Using the local offset to access a local variable is only valid if the current bytecode index is in the range `[getStartIndex(), getEndIndex())`. Cite: `com/oracle/truffle/api/bytecode/LocalVariable.html#getLocalOffset()` ### getLocalIndex() `public abstract int getLocalIndex()`. Since 24.2. Returns the local index, a unique identifier for each `BytecodeLocal` in a root node. Cite: `com/oracle/truffle/api/bytecode/LocalVariable.html#getLocalIndex()` ### getTypeProfile() `public abstract FrameSlotKind getTypeProfile()`. Since 24.2. Returns the type profile that was collected for this local. Returns `null` if no profile was yet collected or the interpreter does not collect profiles. Cite: `com/oracle/truffle/api/bytecode/LocalVariable.html#getTypeProfile()` ### getInfo() `public abstract Object getInfo()`. Since 24.2. Returns the info provided for the local, or `null` if no info was provided. Cite: `com/oracle/truffle/api/bytecode/LocalVariable.html#getInfo()` ### getName() `public abstract Object getName()`. Since 24.2. Returns the name provided for the local, or `null` if no name was provided. Cite: `com/oracle/truffle/api/bytecode/LocalVariable.html#getName()` ### toString() `public String toString()`. Since 24.2. Overrides `toString()`. Cite: `com/oracle/truffle/api/bytecode/LocalVariable.html#toString()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ MaterializedLocalAccessor [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java public final class MaterializedLocalAccessor ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `MaterializedLocalAccessor` Operation parameter that allows an operation to get, set, and clear the value of a local from a materialized frame of the current root node or an outer root node. This class can only be used if the root node supports [`materialized local accesses`](com/oracle/truffle/api/bytecode/GenerateBytecode.md#enableMaterializedLocalAccesses%28%29). To use a materialized local accessor, declare a [`ConstantOperand`](com/oracle/truffle/api/bytecode/ConstantOperand.md) on the operation. The corresponding builder method for the operation will take a [`BytecodeLocal`](com/oracle/truffle/api/bytecode/BytecodeLocal.md) argument for the local to be accessed. At run time, a [`MaterializedLocalAccessor`](com/oracle/truffle/api/bytecode/MaterializedLocalAccessor.md) for the local will be supplied as a parameter to the operation. Materialized local accessors are useful to implement behaviour that cannot be implemented with the builtin materialized local operations (like StoreLocalMaterialized), nor with plain [`local accessors`](com/oracle/truffle/api/bytecode/LocalAccessor.md). All of the materialized accessor methods take a [`bytecode node`](com/oracle/truffle/api/bytecode/BytecodeNode.md) and the current [`frame`](com/oracle/truffle/api/frame/MaterializedFrame.md). The bytecode node should be the current bytecode node (not necessarily corresponding to the root node that declares the local); it should be compilation-final. The frame should contain the local and be materialized. Example usage: ```java @Operation @ConstantOperand(type = MaterializedLocalAccessor.class) public static final class GetMaterializedLocal { @Specialization public static Object perform(VirtualFrame frame, MaterializedLocalAccessor accessor, MaterializedFrame materializedFrame, @Bind BytecodeNode bytecodeNode) { return accessor.getObject(bytecodeNode, materializedFrame); } } ``` ## Methods ### toString() `public String toString()`. Since 24.2. Returns a string representation of a `MaterializedLocalAccessor`. Overrides `toString()`. Cite: `com/oracle/truffle/api/bytecode/MaterializedLocalAccessor.html#toString()` ### getObject(BytecodeNode, MaterializedFrame) `public Object getObject(BytecodeNode bytecodeNode, MaterializedFrame frame)`. Since 24.2. Loads an object from the local. Cite: `com/oracle/truffle/api/bytecode/MaterializedLocalAccessor.html#getObject(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.MaterializedFrame)` ### getBoolean(BytecodeNode, MaterializedFrame) `public boolean getBoolean(BytecodeNode bytecodeNode, MaterializedFrame frame) throws UnexpectedResultException`. Since 24.2. Loads a boolean from the local. Cite: `com/oracle/truffle/api/bytecode/MaterializedLocalAccessor.html#getBoolean(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.MaterializedFrame)` ### getByte(BytecodeNode, MaterializedFrame) `public byte getByte(BytecodeNode bytecodeNode, MaterializedFrame frame) throws UnexpectedResultException`. Since 24.2. Loads a byte from the local. Cite: `com/oracle/truffle/api/bytecode/MaterializedLocalAccessor.html#getByte(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.MaterializedFrame)` ### getInt(BytecodeNode, MaterializedFrame) `public int getInt(BytecodeNode bytecodeNode, MaterializedFrame frame) throws UnexpectedResultException`. Since 24.2. Loads an int from the local. Cite: `com/oracle/truffle/api/bytecode/MaterializedLocalAccessor.html#getInt(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.MaterializedFrame)` ### getLong(BytecodeNode, MaterializedFrame) `public long getLong(BytecodeNode bytecodeNode, MaterializedFrame frame) throws UnexpectedResultException`. Since 24.2. Loads a long from the local. Cite: `com/oracle/truffle/api/bytecode/MaterializedLocalAccessor.html#getLong(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.MaterializedFrame)` ### getFloat(BytecodeNode, MaterializedFrame) `public float getFloat(BytecodeNode bytecodeNode, MaterializedFrame frame) throws UnexpectedResultException`. Since 24.2. Loads a float from the local. Cite: `com/oracle/truffle/api/bytecode/MaterializedLocalAccessor.html#getFloat(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.MaterializedFrame)` ### getDouble(BytecodeNode, MaterializedFrame) `public double getDouble(BytecodeNode bytecodeNode, MaterializedFrame frame) throws UnexpectedResultException`. Since 24.2. Loads a double from the local. Cite: `com/oracle/truffle/api/bytecode/MaterializedLocalAccessor.html#getDouble(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.MaterializedFrame)` ### setObject(BytecodeNode, MaterializedFrame, Object) `public void setObject(BytecodeNode bytecodeNode, MaterializedFrame frame, Object value)`. Since 24.2. Stores an object into the local. Cite: `com/oracle/truffle/api/bytecode/MaterializedLocalAccessor.html#setObject(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.MaterializedFrame,java.lang.Object)` ### setBoolean(BytecodeNode, MaterializedFrame, boolean) `public void setBoolean(BytecodeNode bytecodeNode, MaterializedFrame frame, boolean value)`. Since 24.2. Stores a boolean into the local. Cite: `com/oracle/truffle/api/bytecode/MaterializedLocalAccessor.html#setBoolean(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.MaterializedFrame,boolean)` ### setByte(BytecodeNode, MaterializedFrame, byte) `public void setByte(BytecodeNode bytecodeNode, MaterializedFrame frame, byte value)`. Since 24.2. Stores a byte into the local. Cite: `com/oracle/truffle/api/bytecode/MaterializedLocalAccessor.html#setByte(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.MaterializedFrame,byte)` ### setInt(BytecodeNode, MaterializedFrame, int) `public void setInt(BytecodeNode bytecodeNode, MaterializedFrame frame, int value)`. Since 24.2. Stores an int into the local. Cite: `com/oracle/truffle/api/bytecode/MaterializedLocalAccessor.html#setInt(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.MaterializedFrame,int)` ### setLong(BytecodeNode, MaterializedFrame, long) `public void setLong(BytecodeNode bytecodeNode, MaterializedFrame frame, long value)`. Since 24.2. Stores a long into the local. Cite: `com/oracle/truffle/api/bytecode/MaterializedLocalAccessor.html#setLong(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.MaterializedFrame,long)` ### setFloat(BytecodeNode, MaterializedFrame, float) `public void setFloat(BytecodeNode bytecodeNode, MaterializedFrame frame, float value)`. Since 24.2. Stores a float into the local. Cite: `com/oracle/truffle/api/bytecode/MaterializedLocalAccessor.html#setFloat(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.MaterializedFrame,float)` ### setDouble(BytecodeNode, MaterializedFrame, double) `public void setDouble(BytecodeNode bytecodeNode, MaterializedFrame frame, double value)`. Since 24.2. Stores a double into the local. Cite: `com/oracle/truffle/api/bytecode/MaterializedLocalAccessor.html#setDouble(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.MaterializedFrame,double)` ### clear(BytecodeNode, MaterializedFrame) `public void clear(BytecodeNode bytecodeNode, MaterializedFrame frame)`. Since 24.2. Clears the local from the frame. Clearing the slot marks the frame slot as `illegal`. An exception will be thrown if it is read before being set. Clearing does *not* insert a `default local value`, if specified. Cite: `com/oracle/truffle/api/bytecode/MaterializedLocalAccessor.html#clear(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.MaterializedFrame)` ### isCleared(BytecodeNode, MaterializedFrame) `public boolean isCleared(BytecodeNode bytecodeNode, MaterializedFrame frame)`. Since 24.2. Checks whether the local has been `cleared` (and a new value has not been set). This method also returns `true` if a local has not been initialized and no `default local value` is specified. Cite: `com/oracle/truffle/api/bytecode/MaterializedLocalAccessor.html#isCleared(com.oracle.truffle.api.bytecode.BytecodeNode,com.oracle.truffle.api.frame.MaterializedFrame)` ### getLocalName(BytecodeNode) `public Object getLocalName(BytecodeNode bytecodeNode)`. Since 24.2. Returns the name associated with the local. See also: `BytecodeNode.getLocalName(int, int)`. Cite: `com/oracle/truffle/api/bytecode/MaterializedLocalAccessor.html#getLocalName(com.oracle.truffle.api.bytecode.BytecodeNode)` ### getLocalInfo(BytecodeNode) `public Object getLocalInfo(BytecodeNode bytecodeNode)`. Since 24.2. Returns the info associated with the local. See also: `BytecodeNode.getLocalInfo(int, int)`. Cite: `com/oracle/truffle/api/bytecode/MaterializedLocalAccessor.html#getLocalInfo(com.oracle.truffle.api.bytecode.BytecodeNode)` ### constantOf(int, BytecodeLocal) `public static MaterializedLocalAccessor constantOf(int rootIndex, BytecodeLocal local)`. Since 24.2. Obtains a `MaterializedLocalAccessor`. This method is invoked by the generated code and should not be called directly. Cite: `com/oracle/truffle/api/bytecode/MaterializedLocalAccessor.html#constantOf(int,com.oracle.truffle.api.bytecode.BytecodeLocal)` ### equals(Object) `public boolean equals(Object obj)`. Overrides `equals(java.lang.Object)`. Cite: `com/oracle/truffle/api/bytecode/MaterializedLocalAccessor.html#equals(java.lang.Object)` ### hashCode() `public int hashCode()`. Overrides `hashCode()`. Cite: `com/oracle/truffle/api/bytecode/MaterializedLocalAccessor.html#hashCode()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # @ Operation [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java @Retention(SOURCE) @Target({TYPE}) public @interface Operation ``` Declares an operation. An operation serves as a specification for a bytecode instruction in the generated interpreter. An operation class is declared the same way as a regular Truffle AST node. It declares a set of specializations that define the behaviour of the operation. The specializations should all have a specific number of operands (dynamic input parameters), and they should all be `void` or return a value. These properties make up the "signature" for an operation; for example, an operation may consume two input values and produce a value. Operations have a few additional restrictions compared to Truffle AST nodes: - The operation class should be nested inside the bytecode root node class. - The operation class should be `static` `final`, and have at least package-private visibility. - The operation class may extend other static classes to inherit specializations, but they must adhere to the same restrictions as operation classes. This is useful to share common specializations across multiple operations. - For convenient access to helper methods/fields from Truffle DSL expressions, consider using [`com.oracle.truffle.api.dsl.ImportStatic`](com/oracle/truffle/api/dsl/ImportStatic.md). Static imports can be declared on the root node or on individual operations; operation imports take precedence over root node imports. - The operation class should not contain instance members. - The specializations also have some differences: - Specializations should be `static` and have at least package-private visibility. Members referenced in Truffle DSL expressions (e.g., [`@Cached`](com/oracle/truffle/api/dsl/Cached.md) parameters) have the same restrictions. - The parameters of any [`com.oracle.truffle.api.dsl.Fallback`](com/oracle/truffle/api/dsl/Fallback.md) specialization must be of type [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html). Unlike ASTs, which can define execute methods with specialized parameter types, operation arguments are consumed from the stack, where the type is not guaranteed. - Specializations can bind some special parameters: `$rootNode`, `$bytecodeNode`, and `$bytecodeIndex`. To aid migration, there is also the [`OperationProxy`](com/oracle/truffle/api/bytecode/OperationProxy.md) annotation that creates an operation from an existing AST node. This proxy can be defined outside of the root node, which may be convenient for code organization. Refer to the [user guide](https://github.com/oracle/graal/blob/master/truffle/docs/bytecode_dsl/UserGuide.md) for more details. ## Elements ### forceCached() `boolean forceCached() default false`. Since 24.2. Whether executing this operation should force the uncached interpreter (if enabled) to transition to cached. This field allows you to generate an uncached interpreter with operations that cannot be easily rewritten to support uncached execution. It should only be set if the uncached interpreter is `enabled`. By default, to generate an uncached interpreter the Bytecode DSL requires every operation to support `uncached` execution. Setting this field to `true` overrides this requirement: instead, if the uncached interpreter tries to execute this operation, it will transition to cached and execute the cached operation. Bear in mind that the usefulness of such an interpreter depends on the frequency of the operation. For example, if a very common operation forces cached execution, it will cause most bytecode nodes to transition to cached, negating the intended benefits of an uncached interpreter. Default: `false`. Cite: `com/oracle/truffle/api/bytecode/Operation.html#forceCached()` ### tags() `Class[] tags() default {}`. Since 24.2. The instrumentation tags that should be implicitly associated with this operation. Default: `{}`. See also: `GenerateBytecode.enableTagInstrumentation()`. Cite: `com/oracle/truffle/api/bytecode/Operation.html#tags()` ### javadoc() `String javadoc() default ""`. Since 24.2. Optional documentation for the operation. This documentation is included in the javadoc for the generated interpreter. Default: `""`. Cite: `com/oracle/truffle/api/bytecode/Operation.html#javadoc()` ### storeBytecodeIndex() `boolean storeBytecodeIndex() default true`. Since 25.1. Whether to store the BCI in the frame before executing this operation. Applies in `BytecodeIndexMode.FRAME`, `BytecodeIndexMode.MANUAL`, and uncached `BytecodeIndexMode.CACHED_NODE` execution. When unspecified, storage is disabled in `MANUAL` mode and inferred from specialization caches (including bind parameters) in other modes. The DSL warns when an explicit choice is recommended. When `false`, `StoreBytecodeIndex` can enable storage for individual `Specialization` or `Fallback` methods. Returns `boolean`: whether to enable operation-level BCI storage. Default: `true`. See also: `StoreBytecodeIndex`. Cite: `com/oracle/truffle/api/bytecode/Operation.html#storeBytecodeIndex()` # @ OperationProxy [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java @Retention(SOURCE) @Target({TYPE}) @Repeatable(com.oracle.truffle.api.bytecode.OperationProxy.Repeat.class) public @interface OperationProxy ``` Defines an operation using an existing [`com.oracle.truffle.api.nodes.Node`](com/oracle/truffle/api/nodes/Node.md). The node class should be annotated [`Proxyable`](com/oracle/truffle/api/bytecode/OperationProxy.Proxyable.md) in order to validate the class for use as an operation. Operation proxies are useful for migrating AST interpreters to the Bytecode DSL. Additionally, they can be a code organization tool, separating operation classes from the bytecode root node class. There are some extra restrictions on nodes that are used as proxies. In general, the node should be written using static specializations with at least package-private visibility. There may be additional restrictions; the Truffle annotation processor will report any problems and describe how to fix them. Refer to the [user guide](https://github.com/oracle/graal/blob/master/truffle/docs/bytecode_dsl/UserGuide.md) for more details. **See also** - [`Operation`](com/oracle/truffle/api/bytecode/Operation.md) ## Nested types - [`OperationProxy.Proxyable`](com/oracle/truffle/api/bytecode/OperationProxy.Proxyable.md) (annotation interface): Designates a com.oracle.truffle.api.nodes.Node class as eligible for proxying. - [`OperationProxy.Repeat`](com/oracle/truffle/api/bytecode/OperationProxy.Repeat.md) (annotation interface): Repeat annotation for OperationProxy. ## Elements ### value() `Class value()`. Since 24.2. The `com.oracle.truffle.api.nodes.Node` class to proxy. Cite: `com/oracle/truffle/api/bytecode/OperationProxy.html#value()` ### name() `String name() default ""`. Since 24.2. The name to use for the operation. If no name is specified, the class name (without the "Node" suffix, if present) will be used. Default: `""`. Cite: `com/oracle/truffle/api/bytecode/OperationProxy.html#name()` ### forceCached() `boolean forceCached() default false`. Since 24.2. Whether executing this operation should force the uncached interpreter (if enabled) to transition to cached. Default: `false`. See also: `Operation.forceCached()`. Cite: `com/oracle/truffle/api/bytecode/OperationProxy.html#forceCached()` ### javadoc() `String javadoc() default ""`. Since 24.2. Optional documentation for the operation proxy. This documentation is included in the javadoc for the generated interpreter. Default: `""`. Cite: `com/oracle/truffle/api/bytecode/OperationProxy.html#javadoc()` ### tags() `Class[] tags() default {}`. Since 24.2. The instrumentation tags that should be implicitly associated with this operation. Default: `{}`. See also: `GenerateBytecode.enableTagInstrumentation()`. Cite: `com/oracle/truffle/api/bytecode/OperationProxy.html#tags()` # @ OperationProxy.Proxyable [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. Nested in [`OperationProxy`](com/oracle/truffle/api/bytecode/OperationProxy.md). ```java @Retention(CLASS) @Target({TYPE}) public @interface OperationProxy.Proxyable ``` Designates a [`com.oracle.truffle.api.nodes.Node`](com/oracle/truffle/api/nodes/Node.md) class as eligible for proxying. Execute parameters are ordered as: optional frame when [`bindFrame()`](com/oracle/truffle/api/bytecode/OperationProxy.Proxyable.md#bindFrame%28%29) is enabled, [`BytecodeNode`](com/oracle/truffle/api/bytecode/BytecodeNode.md) when [`bindBytecodeNode()`](com/oracle/truffle/api/bytecode/OperationProxy.Proxyable.md#bindBytecodeNode%28%29) is enabled, `int` when [`bindBytecodeIndex()`](com/oracle/truffle/api/bytecode/OperationProxy.Proxyable.md#bindBytecodeIndex%28%29) is enabled, then evaluated arguments. Enabled bytecode node and index parameters are required on every execute method and are not specialization operands. Specializations access metadata through `@Bind`: this metadata comes from execute arguments during AST execution and from current interpreter state during operation execution. Without `bindBytecodeIndex`, `$bytecodeIndex` is `-1` during AST execution. Binding `$bytecodeNode` during AST execution without enabling `bindBytecodeNode` is a generation error. ## Elements ### bindFrame() `boolean bindFrame() default true`. Since 25.6. Whether to recognize an optional leading frame as execution metadata, accessible through `@Bind("$frame")` or a leading specialization parameter. When disabled, frame parameters are evaluated arguments. Returns `boolean`: whether to bind the frame; defaults to `true`. Default: `true`. Cite: `com/oracle/truffle/api/bytecode/OperationProxy.Proxyable.html#bindFrame()` ### bindBytecodeNode() `boolean bindBytecodeNode() default false`. Since 25.6. Whether each execute method supplies a `BytecodeNode` metadata parameter for `@Bind("$bytecodeNode")`. See `Proxyable` for parameter order. Returns `boolean`: whether to bind the bytecode node; defaults to `false`. Default: `false`. Cite: `com/oracle/truffle/api/bytecode/OperationProxy.Proxyable.html#bindBytecodeNode()` ### bindBytecodeIndex() `boolean bindBytecodeIndex() default false`. Since 25.6. Whether each execute method supplies an `int` metadata parameter for `@Bind("$bytecodeIndex")`. See `Proxyable` for parameter order. Returns `boolean`: whether to bind the bytecode index; defaults to `false`. Default: `false`. Cite: `com/oracle/truffle/api/bytecode/OperationProxy.Proxyable.html#bindBytecodeIndex()` ### allowUncached() `boolean allowUncached() default false`. Since 24.2. Whether a proxyable node allows use for uncached. If uncached use is enabled, additional validations are performed to ensure the node supports uncached. Default: `false`. Cite: `com/oracle/truffle/api/bytecode/OperationProxy.Proxyable.html#allowUncached()` ### storeBytecodeIndex() `boolean storeBytecodeIndex() default true`. Since 25.1. Whether to store the BCI before executing this operation. See `Operation.storeBytecodeIndex()` for mode-dependent defaults. When `false`, `StoreBytecodeIndex` enables storage for individual `Specialization` or `Fallback` methods. Returns `boolean`: whether to enable operation-level BCI storage. Default: `true`. Cite: `com/oracle/truffle/api/bytecode/OperationProxy.Proxyable.html#storeBytecodeIndex()` # @ OperationProxy.Repeat [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. Nested in [`OperationProxy`](com/oracle/truffle/api/bytecode/OperationProxy.md). ```java @Retention(SOURCE) @Target({TYPE}) public @interface OperationProxy.Repeat ``` Repeat annotation for [`OperationProxy`](com/oracle/truffle/api/bytecode/OperationProxy.md). ## Elements ### value() `OperationProxy[] value()`. Since 24.2. Repeat value for `OperationProxy`. Cite: `com/oracle/truffle/api/bytecode/OperationProxy.Repeat.html#value()` # @ Prolog [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java @Retention(SOURCE) @Target({TYPE}) public @interface Prolog ``` Defines a prolog operation that executes before the body of a Root operation. A prolog operation is defined the same way as an [`Operation`](com/oracle/truffle/api/bytecode/Operation.md). It has the additional restriction that it must have no dynamic operands and must declare a `void` return type. It can declare [`constant operands`](com/oracle/truffle/api/bytecode/ConstantOperand.md). The prolog is guarded by exception intercept methods (e.g., [`BytecodeRootNode.interceptInternalException(Throwable, VirtualFrame, BytecodeNode, int)`](com/oracle/truffle/api/bytecode/BytecodeRootNode.md#interceptInternalException%28java.lang.Throwable,com.oracle.truffle.api.frame.VirtualFrame,com.oracle.truffle.api.bytecode.BytecodeNode,int%29)) as well as the [`exceptional epilog`](com/oracle/truffle/api/bytecode/EpilogExceptional.md), if present. When [`Tag`](com/oracle/truffle/api/instrumentation/Tag.md) instrumentation is enabled, the prolog will execute after [`root`](com/oracle/truffle/api/instrumentation/StandardTags.RootTag.md) probes and before [`root body`](com/oracle/truffle/api/instrumentation/StandardTags.RootBodyTag.md) probes. **See also** - [`EpilogReturn`](com/oracle/truffle/api/bytecode/EpilogReturn.md) - [`EpilogExceptional`](com/oracle/truffle/api/bytecode/EpilogExceptional.md) ## Elements ### storeBytecodeIndex() `boolean storeBytecodeIndex() default true`. Since 25.1. Whether to store the BCI before executing this operation. See `Operation.storeBytecodeIndex()` for mode-dependent defaults. When `false`, `StoreBytecodeIndex` enables storage for individual `Specialization` or `Fallback` methods. Returns `boolean`: whether to enable operation-level BCI storage. Default: `true`. Cite: `com/oracle/truffle/api/bytecode/Prolog.html#storeBytecodeIndex()` # @ Return [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 25.2. ```java @Retention(SOURCE) @Target({TYPE}) public @interface Return ``` Declares a custom return operation. A custom return operation has the same control-flow behavior as the built-in `Return` operation, but allows custom logic to compute the value returned from the bytecode root node. A custom return operation has many of the same restrictions and capabilities of a regular [`Operation`](com/oracle/truffle/api/bytecode/Operation.md), with a few differences: - It must take one or more dynamic operands. - It must have a return value. This value is returned from the bytecode root node and should be a [`valid interop type`](com/oracle/truffle/api/interop/InteropLibrary.md#isValidValue%28java.lang.Object%29). If a custom return takes multiple dynamic operands, [`resultOperandIndex()`](com/oracle/truffle/api/bytecode/Return.md#resultOperandIndex%28%29) specifies which operand represents the logical "result" of the return before the custom return executes. This result is used by [`tag instrumentation`](com/oracle/truffle/api/bytecode/GenerateBytecode.md#enableTagInstrumentation%28%29) and [`EpilogReturn`](com/oracle/truffle/api/bytecode/EpilogReturn.md). ## Elements ### forceCached() `boolean forceCached() default false`. Since 25.2. Whether executing this operation should force the uncached interpreter (if enabled) to transition to cached. Default: `false`. See also: `Operation.forceCached()`. Cite: `com/oracle/truffle/api/bytecode/Return.html#forceCached()` ### tags() `Class[] tags() default {}`. Since 25.2. The instrumentation tags that should be implicitly associated with this operation. Default: `{}`. See also: `GenerateBytecode.enableTagInstrumentation()`. Cite: `com/oracle/truffle/api/bytecode/Return.html#tags()` ### javadoc() `String javadoc() default ""`. Since 25.2. Optional documentation for the operation. This documentation is included in the javadoc for the generated interpreter. Default: `""`. Cite: `com/oracle/truffle/api/bytecode/Return.html#javadoc()` ### resultOperandIndex() `int resultOperandIndex() default 0`. Since 25.2. Index of the dynamic operand that represents the logical "result" of the return before the custom return executes. This result is used by `tag instrumentation` and `EpilogReturn`. This field must be specified for custom returns with multiple dynamic operands; it should not be specified for custom returns with no dynamic operands. Default: `0`. Cite: `com/oracle/truffle/api/bytecode/Return.html#resultOperandIndex()` # @ ShortCircuitOperation [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java @Retention(SOURCE) @Target({TYPE}) @Repeatable(com.oracle.truffle.api.bytecode.ShortCircuitOperation.Repeat.class) public @interface ShortCircuitOperation ``` Declares a short-circuiting operation. A short-circuiting operation serves as a specification for a short-circuiting bytecode instruction in the generated interpreter. Whereas regular operations evaluate all of their operands eagerly, short-circuiting operations evaluate them one at a time. A short-circuiting operation [`converts`](com/oracle/truffle/api/bytecode/ShortCircuitOperation.md#booleanConverter%28%29) each operand to a `boolean` to determine whether to continue execution. An OR operation continues until it encounters `true`; an AND operation continues until it encounters `false`. A short-circuiting operation produces either the last operand evaluated, or the `boolean` it converted to. Both the boolean operator and the return semantics are specified by the [`operator`](com/oracle/truffle/api/bytecode/ShortCircuitOperation.md#operator%28%29). For example, the following code declares a short-circuiting "Or" operation that continues to evaluate operands as long as they coerce to `false`: ```java @GenerateBytecode(...) @ShortCircuitOperation(name = "Or", operator=Operator.OR_RETURN_VALUE, booleanConverter = CoerceBoolean.class) public static final class MyBytecodeNode extends RootNode implements BytecodeRootNode { @Operation public static final class CoerceBoolean { @Specialization public static boolean fromInt(int x) { return x != 0; } @Specialization public static boolean fromBool(boolean x) { return x; } @Specialization public static boolean fromObject(Object x) { return x != null; } } ... } ``` In pseudocode, the `Or` operation declared above has the following semantics: ```java value_1 = // compute operand_1 if CoerceBoolean(value_1) != false return value_1 value_2 = // compute operand_2 if CoerceBoolean(value_2) != false return value_2 ... value_n = // compute operand_n return value_n ``` Since the operand value itself is returned, this operation can be used to implement null-coalescing operations (e.g., `someArray or []` in Python). ## Nested types - [`ShortCircuitOperation.Operator`](com/oracle/truffle/api/bytecode/ShortCircuitOperation.Operator.md) (enum class): Defines the behaviour of a ShortCircuitOperation. - [`ShortCircuitOperation.Repeat`](com/oracle/truffle/api/bytecode/ShortCircuitOperation.Repeat.md) (annotation interface): Repeat annotation for ShortCircuitOperation. ## Elements ### name() `String name()`. Since 24.2. The name of this operation. Cite: `com/oracle/truffle/api/bytecode/ShortCircuitOperation.html#name()` ### operator() `ShortCircuitOperation.Operator operator()`. Since 24.2. The short-circuit operator to use for this operation. The operator decides whether to perform a boolean AND or OR. It also determines whether the operation produces the original operand or the boolean that results from conversion. An OR operation will execute children until a `true` value; an AND operation will execute children until a `false` value. Note that this means `booleanConverter` can be negated by changing an OR to an AND (or vice-versa) and then inverting the result. For example, `!convert(A) OR !convert(B) OR ...` can be implemented using `!(convert(A) AND convert(B) AND ...)`. Cite: `com/oracle/truffle/api/bytecode/ShortCircuitOperation.html#operator()` ### booleanConverter() `Class booleanConverter() default void.class`. Since 24.2. A node or operation class. The short-circuit operation uses this class to convert each operand value to a `boolean` value used by the boolean operation. If no converter is provided, the operands must already be `boolean`s. The interpreter will cast each operand to `boolean` in order to compare it against `true` or `false` (throwing [`ClassCastException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ClassCastException.html) or [`NullPointerException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) as appropriate). However, since the last operand is not compared against `true` or `false`, it is **not checked**; it is the language's responsibility to ensure the operands are `boolean` (or to properly handle a non-`boolean` result in the consuming operation). The class can be (but does not need to be) declared as an `Operation` or `OperationProxy`. If it is not declared as either, it will undergo the same validation as an `Operation` (see the Operation Javadoc for the specific requirements). In addition, such a node/operation must: Only have specializations returning `boolean`.; Only have specializations that take a single dynamic operand. Default: `void.class`. Cite: `com/oracle/truffle/api/bytecode/ShortCircuitOperation.html#booleanConverter()` ### javadoc() `String javadoc() default ""`. Since 24.2. Optional documentation for the short circuit operation. This documentation is included in the javadoc for the generated interpreter. Default: `""`. Cite: `com/oracle/truffle/api/bytecode/ShortCircuitOperation.html#javadoc()` # ≡ ShortCircuitOperation.Operator [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Enum class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. Nested in [`ShortCircuitOperation`](com/oracle/truffle/api/bytecode/ShortCircuitOperation.md). ```java public enum ShortCircuitOperation.Operator ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html) > `Operator` Defines the behaviour of a [`ShortCircuitOperation`](com/oracle/truffle/api/bytecode/ShortCircuitOperation.md). ## Enum constants ### AND_RETURN_VALUE `AND_RETURN_VALUE`. AND operator that produces the operand value. Cite: `com/oracle/truffle/api/bytecode/ShortCircuitOperation.Operator.html#AND_RETURN_VALUE` ### AND_RETURN_CONVERTED `AND_RETURN_CONVERTED`. AND operator that produces the converted boolean value. Cite: `com/oracle/truffle/api/bytecode/ShortCircuitOperation.Operator.html#AND_RETURN_CONVERTED` ### OR_RETURN_VALUE `OR_RETURN_VALUE`. OR operator that produces the operand value. Cite: `com/oracle/truffle/api/bytecode/ShortCircuitOperation.Operator.html#OR_RETURN_VALUE` ### OR_RETURN_CONVERTED `OR_RETURN_CONVERTED`. OR operator that produces the converted boolean value. Cite: `com/oracle/truffle/api/bytecode/ShortCircuitOperation.Operator.html#OR_RETURN_CONVERTED` ## Methods ### values() `public static ShortCircuitOperation.Operator[] values()`. Returns the enum constants in declaration order. Returns `ShortCircuitOperation.Operator[]`: Returns the enum constants in declaration order. Cite: `com/oracle/truffle/api/bytecode/ShortCircuitOperation.Operator.html#values()` ### valueOf(String) `public static ShortCircuitOperation.Operator valueOf(String name)`. Returns the enum constant with the given name. Parameters: `name` `String`: The exact name of the enum constant. Returns `ShortCircuitOperation.Operator`: Returns the enum constant with the given name. Cite: `com/oracle/truffle/api/bytecode/ShortCircuitOperation.Operator.html#valueOf(java.lang.String)` ## Inherited members - From class [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#clone%28%29), [`compareTo`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#compareTo%28E%29), [`describeConstable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#describeConstable%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#finalize%28%29), [`getDeclaringClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#getDeclaringClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#hashCode%28%29), [`name`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#name%28%29), [`ordinal`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#ordinal%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#toString%28%29), [`valueOf`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#valueOf%28java.lang.Class,java.lang.String%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # @ ShortCircuitOperation.Repeat [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. Nested in [`ShortCircuitOperation`](com/oracle/truffle/api/bytecode/ShortCircuitOperation.md). ```java @Retention(SOURCE) @Target({TYPE}) public @interface ShortCircuitOperation.Repeat ``` Repeat annotation for [`ShortCircuitOperation`](com/oracle/truffle/api/bytecode/ShortCircuitOperation.md). ## Elements ### value() `ShortCircuitOperation[] value()`. Since 24.2. Repeat value for `ShortCircuitOperation`. Cite: `com/oracle/truffle/api/bytecode/ShortCircuitOperation.Repeat.html#value()` # ◆ SourceInformation [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). ```java public abstract class SourceInformation ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `SourceInformation` Introspection class modeling source section information for a range of bytecodes. Note: Introspection classes are intended to be used for debugging purposes only. These APIs may change in the future. **See also** - [`BytecodeNode.getSourceInformation()`](com/oracle/truffle/api/bytecode/BytecodeNode.md#getSourceInformation%28%29) - [`BytecodeLocation.getSourceInformation()`](com/oracle/truffle/api/bytecode/BytecodeLocation.md#getSourceInformation%28%29) ## Constructors ### SourceInformation(Object) `protected SourceInformation(Object token)`. Since 24.2. Internal constructor for generated code. Do not use. Cite: `com/oracle/truffle/api/bytecode/SourceInformation.html#(java.lang.Object)` ## Methods ### getStartBytecodeIndex() `public abstract int getStartBytecodeIndex()`. Since 24.2. Returns the start bytecode index for this source information object (inclusive). Cite: `com/oracle/truffle/api/bytecode/SourceInformation.html#getStartBytecodeIndex()` ### getEndBytecodeIndex() `public abstract int getEndBytecodeIndex()`. Since 24.2. Returns the end bytecode index for this source information object (exclusive). Cite: `com/oracle/truffle/api/bytecode/SourceInformation.html#getEndBytecodeIndex()` ### getSourceSection() `public abstract SourceSection getSourceSection()`. Since 24.2. Returns the source section associated with this source information object. The result is never `null`, with the possible exception of the root of a `SourceInformationTree` (see `BytecodeNode.getSourceInformationTree`). Cite: `com/oracle/truffle/api/bytecode/SourceInformation.html#getSourceSection()` ### toString() `public String toString()`. Since 24.2. Overrides `toString()`. Cite: `com/oracle/truffle/api/bytecode/SourceInformation.html#toString()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ SourceInformationTree [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java public abstract class SourceInformationTree extends SourceInformation ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`SourceInformation`](com/oracle/truffle/api/bytecode/SourceInformation.md) > `SourceInformationTree` Introspection class modeling a tree of [`SourceInformation`](com/oracle/truffle/api/bytecode/SourceInformation.md) instances. Like [`SourceInformation`](com/oracle/truffle/api/bytecode/SourceInformation.md), this class models the source section for a bytecode range. Its children model the source sections of subranges directly contained by this node's bytecode range. Note: it is possible for [`SourceInformationTree.getSourceSection()`](com/oracle/truffle/api/bytecode/SourceInformation.md#getSourceSection%28%29) to return `null` for the root of the tree when the Root operation is not enclosed in a SourceSection operation. See the discussion in [`BytecodeNode.getSourceInformationTree()`](com/oracle/truffle/api/bytecode/BytecodeNode.md#getSourceInformationTree%28%29) for more information. Note: Introspection classes are intended to be used for debugging purposes only. These APIs may change in the future. **See also** - [`BytecodeNode.getSourceInformationTree()`](com/oracle/truffle/api/bytecode/BytecodeNode.md#getSourceInformationTree%28%29) ## Constructors ### SourceInformationTree(Object) `protected SourceInformationTree(Object token)`. Since 24.2. Internal constructor for generated code. Do not use. Cite: `com/oracle/truffle/api/bytecode/SourceInformationTree.html#(java.lang.Object)` ## Methods ### getChildren() `public abstract List getChildren()`. Since 24.2. Returns a list of child trees, ordered by bytecode range. Cite: `com/oracle/truffle/api/bytecode/SourceInformationTree.html#getChildren()` ### toString() `public final String toString()`. Since 24.2. Overrides `toString()`. Cite: `com/oracle/truffle/api/bytecode/SourceInformationTree.html#toString()` ## Inherited members - From class [`SourceInformation`](com/oracle/truffle/api/bytecode/SourceInformation.md): [`getEndBytecodeIndex`](com/oracle/truffle/api/bytecode/SourceInformation.md#getEndBytecodeIndex%28%29), [`getSourceSection`](com/oracle/truffle/api/bytecode/SourceInformation.md#getSourceSection%28%29), [`getStartBytecodeIndex`](com/oracle/truffle/api/bytecode/SourceInformation.md#getStartBytecodeIndex%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ StackValue [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 25.4. ```java public abstract class StackValue ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `StackValue` Abstract definition of a stack value in the interpreter. Stack values are build-time handles to values on the operand stack. A stack value can be bound using `BindStackValue` and then accessed using `LoadStackValue` and `StoreStackValue`. A stack value is valid while the enclosing custom operation or `Block` is active. ## Constructors ### StackValue(Object) `public StackValue(Object token)`. Since 25.4. Internal constructor for generated code. Do not use. Cite: `com/oracle/truffle/api/bytecode/StackValue.html#(java.lang.Object)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # @ StoreBytecodeIndex [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 25.1. ```java @Retention(SOURCE) @Target({METHOD}) public @interface StoreBytecodeIndex ``` Stores the BCI in the frame before an annotated [`Specialization`](com/oracle/truffle/api/dsl/Specialization.md) or [`Fallback`](com/oracle/truffle/api/dsl/Fallback.md) executes. Requires [`Operation.storeBytecodeIndex()`](com/oracle/truffle/api/bytecode/Operation.md#storeBytecodeIndex%28%29) to be `false`, the default in [`BytecodeIndexMode.MANUAL`](com/oracle/truffle/api/bytecode/BytecodeIndexMode.md#MANUAL) mode. Applies in [`BytecodeIndexMode.FRAME`](com/oracle/truffle/api/bytecode/BytecodeIndexMode.md#FRAME), `MANUAL`, and uncached [`BytecodeIndexMode.CACHED_NODE`](com/oracle/truffle/api/bytecode/BytecodeIndexMode.md#CACHED_NODE) execution. **See also** - [`Operation.storeBytecodeIndex()`](com/oracle/truffle/api/bytecode/Operation.md#storeBytecodeIndex%28%29) # ◇ TagTree [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java public interface TagTree ``` Logical tree representation of the `Tag` operations of a bytecode program. **See also** - [`Tag`](com/oracle/truffle/api/instrumentation/Tag.md) - [`BytecodeNode.getTagTree`](com/oracle/truffle/api/bytecode/BytecodeNode.md#getTagTree%28%29) ## Methods ### getTreeChildren() `List getTreeChildren()`. Since 24.2. Returns the child trees corresponding to `Tag` operations nested in this node. Cite: `com/oracle/truffle/api/bytecode/TagTree.html#getTreeChildren()` ### getTags() `List> getTags()`. Since 24.2. Returns the `tags` associated with this node. Cite: `com/oracle/truffle/api/bytecode/TagTree.html#getTags()` ### hasTag(Class) `boolean hasTag(Class tag)`. Since 24.2. Returns whether the given `tag` is associated with this node. Parameters: `tag` `Class`: the tag to search for. Cite: `com/oracle/truffle/api/bytecode/TagTree.html#hasTag(java.lang.Class)` ### getEnterBytecodeIndex() `int getEnterBytecodeIndex()`. Since 24.2. Returns the bytecode index at which the interpreter enters the tag operation. The bytecode interpreter will invoke `ProbeNode.onEnter` at this point in the program. Cite: `com/oracle/truffle/api/bytecode/TagTree.html#getEnterBytecodeIndex()` ### getReturnBytecodeIndex() `int getReturnBytecodeIndex()`. Since 24.2. Returns the bytecode index at which the interpreter "returns" from the tag operation. The bytecode interpreter will invoke `ProbeNode.onReturnValue` with the child operation's result (if any) at this point in the program. Note: the instruction at this index is not necessarily a return, but the value it produces is treated as a return value for the sake of instrumentation. There can also be other return points if the child operation has early exits; this method returns the regular return point. Cite: `com/oracle/truffle/api/bytecode/TagTree.html#getReturnBytecodeIndex()` ### getSourceSection() `SourceSection getSourceSection()`. Since 24.2. Gets the most concrete `source location` associated with the tag operation. See also: `BytecodeNode.getSourceLocation(com.oracle.truffle.api.frame.Frame, com.oracle.truffle.api.nodes.Node)`. Cite: `com/oracle/truffle/api/bytecode/TagTree.html#getSourceSection()` ### getSourceSections() `SourceSection[] getSourceSections()`. Since 24.2. Gets all `source locations` associated with the tag operation, ordered from most to least concrete. See also: `BytecodeNode.getSourceLocations(com.oracle.truffle.api.frame.Frame, com.oracle.truffle.api.nodes.Node)`. Cite: `com/oracle/truffle/api/bytecode/TagTree.html#getSourceSections()` # ◆ TagTreeNode [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java public abstract class TagTreeNode extends Node implements TagTree ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `TagTreeNode` Implements: [`TagTree`](com/oracle/truffle/api/bytecode/TagTree.md) Class that implements tag tree [`NodeLibrary`](com/oracle/truffle/api/interop/NodeLibrary.md) dispatch for tag tree items. This class is intended to be used when implementing a custom [`tag tree node library`](com/oracle/truffle/api/bytecode/GenerateBytecode.md#tagTreeNodeLibrary%28%29) or [`instrumentation node objects`](com/oracle/truffle/api/bytecode/BytecodeRootNode.md#getInstrumentationNodeObject%28com.oracle.truffle.api.bytecode.TagTreeNode%29). All implementations of this class are intended to be generated and are not supposed to be implemented manually. ## Constructors ### TagTreeNode(Object) `protected TagTreeNode(Object token)`. Since 24.2. Internal constructor for generated code. Do not use. Cite: `com/oracle/truffle/api/bytecode/TagTreeNode.html#(java.lang.Object)` ## Methods ### getLanguage() `@Deprecated(since = "25.1") protected abstract Class> getLanguage()`. Since 24.2. Deprecated since 25.1. Use `getLanguageId()`. Allows to access the language instance associated with this node. Cite: `com/oracle/truffle/api/bytecode/TagTreeNode.html#getLanguage()` ### getLanguageId() `protected String getLanguageId()`. Since 25.1. Returns an id of a language associated with this node. Cite: `com/oracle/truffle/api/bytecode/TagTreeNode.html#getLanguageId()` ### dispatch() `protected Class dispatch()`. Since 24.2. Returns the currently used `NodeLibrary` exports for this tag library. Cite: `com/oracle/truffle/api/bytecode/TagTreeNode.html#dispatch()` ### getBytecodeNode() `public BytecodeNode getBytecodeNode()`. Since 24.2. Returns the bytecode node associated with this node. Cite: `com/oracle/truffle/api/bytecode/TagTreeNode.html#getBytecodeNode()` ### createDefaultScope(Frame, boolean) `public final Object createDefaultScope(Frame frame, boolean nodeEnter)`. Since 24.2. Creates a default scope implementation based on this tag tree node. The scope returned exposes the live locals at the given location in the program (respecting the configured `scoping mode`). It uses the `name`s supplied at local declaration time, falling back on generic names when unavailable. This is the default scope used by Bytecode DSL interpreters. The scope can be customized by setting `GenerateBytecode.tagTreeNodeLibrary()` to a class that exports `NodeLibrary.getScope(Object, Frame, boolean)` for `TagTreeNode`. Your library can use this method if the default scope implementation is appropriate for your language but other methods in `NodeLibrary` need to be implemented differently. Cite: `com/oracle/truffle/api/bytecode/TagTreeNode.html#createDefaultScope(com.oracle.truffle.api.frame.Frame,boolean)` ### toString() `public final String toString()`. Since 24.2. Converts this node to a textual representation useful for debugging. Overrides `toString()`. Cite: `com/oracle/truffle/api/bytecode/TagTreeNode.html#toString()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) - From interface [`TagTree`](com/oracle/truffle/api/bytecode/TagTree.md): [`getEnterBytecodeIndex`](com/oracle/truffle/api/bytecode/TagTree.md#getEnterBytecodeIndex%28%29), [`getReturnBytecodeIndex`](com/oracle/truffle/api/bytecode/TagTree.md#getReturnBytecodeIndex%28%29), [`getSourceSection`](com/oracle/truffle/api/bytecode/TagTree.md#getSourceSection%28%29), [`getSourceSections`](com/oracle/truffle/api/bytecode/TagTree.md#getSourceSections%28%29), [`getTags`](com/oracle/truffle/api/bytecode/TagTree.md#getTags%28%29), [`getTreeChildren`](com/oracle/truffle/api/bytecode/TagTree.md#getTreeChildren%28%29), [`hasTag`](com/oracle/truffle/api/bytecode/TagTree.md#hasTag%28java.lang.Class%29) # ◆ TagTreeNodeGen [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). ```java public final class TagTreeNodeGen ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `TagTreeNodeGen` ## Nested types - [`TagTreeNodeGen.DynamicDispatchLibraryExports`](com/oracle/truffle/api/bytecode/TagTreeNodeGen.DynamicDispatchLibraryExports.md) (class): No description. ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TagTreeNodeGen.DynamicDispatchLibraryExports [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Nested in [`TagTreeNodeGen`](com/oracle/truffle/api/bytecode/TagTreeNodeGen.md). ```java public static class TagTreeNodeGen.DynamicDispatchLibraryExports extends LibraryExport ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`LibraryExport`](com/oracle/truffle/api/library/LibraryExport.md) > `DynamicDispatchLibraryExports` ## Nested types - [`TagTreeNodeGen.DynamicDispatchLibraryExports.Cached`](com/oracle/truffle/api/bytecode/TagTreeNodeGen.DynamicDispatchLibraryExports.Cached.md) (class): No description. - [`TagTreeNodeGen.DynamicDispatchLibraryExports.Uncached`](com/oracle/truffle/api/bytecode/TagTreeNodeGen.DynamicDispatchLibraryExports.Uncached.md) (class): No description. ## Methods ### createUncached(Object) `protected DynamicDispatchLibrary createUncached(Object receiver)`. Implemented generated by `ExportLibrary`. Do not implement manually. Description copied from `createUncached()`. Overrides `createUncached()`. Cite: `com/oracle/truffle/api/bytecode/TagTreeNodeGen.DynamicDispatchLibraryExports.html#createUncached(java.lang.Object)` ### createCached(Object) `protected DynamicDispatchLibrary createCached(Object receiver)`. Implemented generated by `ExportLibrary`. Do not implement manually. Description copied from `createCached()`. Overrides `createCached()`. Cite: `com/oracle/truffle/api/bytecode/TagTreeNodeGen.DynamicDispatchLibraryExports.html#createCached(java.lang.Object)` ## Inherited members - From class [`LibraryExport`](com/oracle/truffle/api/library/LibraryExport.md): [`assertAdopted`](com/oracle/truffle/api/library/LibraryExport.md#assertAdopted%28com.oracle.truffle.api.nodes.Node%29), [`createDelegate`](com/oracle/truffle/api/library/LibraryExport.md#createDelegate%28com.oracle.truffle.api.library.LibraryFactory,T%29), [`createMessageBitSet`](com/oracle/truffle/api/library/LibraryExport.md#createMessageBitSet%28com.oracle.truffle.api.library.LibraryFactory,java.lang.String...%29), [`register`](com/oracle/truffle/api/library/LibraryExport.md#register%28java.lang.Class,com.oracle.truffle.api.library.LibraryExport...%29), [`toString`](com/oracle/truffle/api/library/LibraryExport.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TagTreeNodeGen.DynamicDispatchLibraryExports.Cached [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Nested in [`TagTreeNodeGen.DynamicDispatchLibraryExports`](com/oracle/truffle/api/bytecode/TagTreeNodeGen.DynamicDispatchLibraryExports.md). ```java public static class TagTreeNodeGen.DynamicDispatchLibraryExports.Cached extends DynamicDispatchLibrary ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > [`Library`](com/oracle/truffle/api/library/Library.md) > [`DynamicDispatchLibrary`](com/oracle/truffle/api/library/DynamicDispatchLibrary.md) > `Cached` ## Constructors ### Cached(Object) `protected Cached(Object receiver)`. Cite: `com/oracle/truffle/api/bytecode/TagTreeNodeGen.DynamicDispatchLibraryExports.Cached.html#(java.lang.Object)` ## Methods ### cast(Object) `public Object cast(Object receiver)`. Cast the object receiver type to the dispatched type. This is not supposed to be implemented by dynamic dispatch implementer but is automatically implemented when implementing dynamic dispatch. Description copied from `cast()`. Overrides `cast()`. Cite: `com/oracle/truffle/api/bytecode/TagTreeNodeGen.DynamicDispatchLibraryExports.Cached.html#cast(java.lang.Object)` ### accepts(Object) `public boolean accepts(Object receiver)`. Returns `true` if this library instance supports sending messages with the given receiver. If accepts returns `false` and a library message is sent anyway then an [`AssertionError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AssertionError.html) is thrown if assertions are enabled (-ea). Otherwise a [`NullPointerException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) or [`ClassCastException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ClassCastException.html) may be thrown by the method. A library that was created using a receiver value i.e. a `LibraryFactory.create(Object)` only guarantees to accept the value it was constructed with. For other values, the method may return `false`. Such libraries need to check for acceptance before calling a library method with a receiver. If receiver values are not accepted then a new library needs to be created or fetched. Dispatched versions of libraries always return `true` for any value as they take care of dispatching to any receiver type. It is not necessary to call accepts manually for most use cases. Instead the `CachedLibrary` should be used instead. For slow-paths the `internally dispatched` versions of the uncached library should be used. The accepts message may be exported by receiver types. When exported it can only be further restricted in addition to the default accepts implementation. Description copied from `accepts()`. Overrides `accepts()`. See also: `for ways how to dispatch libraries.`. Cite: `com/oracle/truffle/api/bytecode/TagTreeNodeGen.DynamicDispatchLibraryExports.Cached.html#accepts(java.lang.Object)` ### dispatch(Object) `public Class dispatch(Object receiver)`. Returns a class that `exports` at least one library with an explicit receiver. Returns `null` to indicate that the default dispatch of the library should be used. Description copied from `dispatch()`. Overrides `dispatch()`. Cite: `com/oracle/truffle/api/bytecode/TagTreeNodeGen.DynamicDispatchLibraryExports.Cached.html#dispatch(java.lang.Object)` ## Inherited members - From class [`DynamicDispatchLibrary`](com/oracle/truffle/api/library/DynamicDispatchLibrary.md): [`getFactory`](com/oracle/truffle/api/library/DynamicDispatchLibrary.md#getFactory%28%29) - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TagTreeNodeGen.DynamicDispatchLibraryExports.Uncached [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Nested in [`TagTreeNodeGen.DynamicDispatchLibraryExports`](com/oracle/truffle/api/bytecode/TagTreeNodeGen.DynamicDispatchLibraryExports.md). ```java public static class TagTreeNodeGen.DynamicDispatchLibraryExports.Uncached extends DynamicDispatchLibrary implements UnadoptableNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > [`Library`](com/oracle/truffle/api/library/Library.md) > [`DynamicDispatchLibrary`](com/oracle/truffle/api/library/DynamicDispatchLibrary.md) > `Uncached` Implements: [`UnadoptableNode`](com/oracle/truffle/api/nodes/UnadoptableNode.md) ## Constructors ### Uncached(Object) `protected Uncached(Object receiver)`. Cite: `com/oracle/truffle/api/bytecode/TagTreeNodeGen.DynamicDispatchLibraryExports.Uncached.html#(java.lang.Object)` ## Methods ### accepts(Object) `public boolean accepts(Object receiver)`. Returns `true` if this library instance supports sending messages with the given receiver. If accepts returns `false` and a library message is sent anyway then an [`AssertionError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AssertionError.html) is thrown if assertions are enabled (-ea). Otherwise a [`NullPointerException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) or [`ClassCastException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ClassCastException.html) may be thrown by the method. A library that was created using a receiver value i.e. a `LibraryFactory.create(Object)` only guarantees to accept the value it was constructed with. For other values, the method may return `false`. Such libraries need to check for acceptance before calling a library method with a receiver. If receiver values are not accepted then a new library needs to be created or fetched. Dispatched versions of libraries always return `true` for any value as they take care of dispatching to any receiver type. It is not necessary to call accepts manually for most use cases. Instead the `CachedLibrary` should be used instead. For slow-paths the `internally dispatched` versions of the uncached library should be used. The accepts message may be exported by receiver types. When exported it can only be further restricted in addition to the default accepts implementation. Description copied from `accepts()`. Overrides `accepts()`. See also: `for ways how to dispatch libraries.`. Cite: `com/oracle/truffle/api/bytecode/TagTreeNodeGen.DynamicDispatchLibraryExports.Uncached.html#accepts(java.lang.Object)` ### cast(Object) `public Object cast(Object receiver)`. Cast the object receiver type to the dispatched type. This is not supposed to be implemented by dynamic dispatch implementer but is automatically implemented when implementing dynamic dispatch. Description copied from `cast()`. Overrides `cast()`. Cite: `com/oracle/truffle/api/bytecode/TagTreeNodeGen.DynamicDispatchLibraryExports.Uncached.html#cast(java.lang.Object)` ### dispatch(Object) `public Class dispatch(Object receiver)`. Returns a class that `exports` at least one library with an explicit receiver. Returns `null` to indicate that the default dispatch of the library should be used. Description copied from `dispatch()`. Overrides `dispatch()`. Cite: `com/oracle/truffle/api/bytecode/TagTreeNodeGen.DynamicDispatchLibraryExports.Uncached.html#dispatch(java.lang.Object)` ## Inherited members - From class [`DynamicDispatchLibrary`](com/oracle/truffle/api/library/DynamicDispatchLibrary.md): [`getFactory`](com/oracle/truffle/api/library/DynamicDispatchLibrary.md#getFactory%28%29) - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # @ Variadic [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 24.2. ```java @Retention(SOURCE) @Target({PARAMETER, TYPE}) public @interface Variadic ``` Annotation indicating a parameter that takes zero or more values. If the final parameter of an operation is annotated with `@Variadic`, those values will be collected into an `Object[]` as the last argument. This annotation can also be applied to an [`Operation`](com/oracle/truffle/api/bytecode/Operation.md) class to mark its return type as variadic. Such return values are flattened into the variadic array when used as one or more operands to a [`Variadic`](com/oracle/truffle/api/bytecode/Variadic.md) parameter. All specializations of a variadic-return operation must always return a non-null [`Object[]`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) value. ## Elements ### startOffset() `int startOffset() default 0`. Since 25.0. Specifies the number of values reserved in the variadic object array. The array is sized accordingly, which can be useful when passing variadic arguments to a `call` without reallocating the array. Default: `0`. Cite: `com/oracle/truffle/api/bytecode/Variadic.html#startOffset()` ```java @Operation static final class FunctionCall { @Specialization public static Object variadic(CallTarget target, Object function, @Variadic(startOffset = 1) Object[] args, @Cached IndirectCallNode callNode) { args[0] = function; // use index 0 for the function instance return callNode.call(target, args); } } ``` # @ Yield [truffle-api](index.md) › [com.oracle.truffle.api.bytecode](com/oracle/truffle/api/bytecode/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.bytecode`](com/oracle/truffle/api/bytecode/index.md). Since 25.1. ```java @Retention(SOURCE) @Target({TYPE}) public @interface Yield ``` Declares a custom yield operation. A custom yield operation has the same control flow behaviour as the [`built-in yield`](com/oracle/truffle/api/bytecode/GenerateBytecode.md#enableYield%28%29), but allows to customize the result produced. For example, a custom yield can create a guest generator object instead of a [`ContinuationResult`](com/oracle/truffle/api/bytecode/ContinuationResult.md), or it can perform custom logic before [`creating`](com/oracle/truffle/api/bytecode/ContinuationResult.md#create%28com.oracle.truffle.api.bytecode.ContinuationRootNode,com.oracle.truffle.api.frame.MaterializedFrame,java.lang.Object%29) the continuation result. Below is an example of a custom yield that returns a guest language generator object: ```java @Yield public static final class CustomYield { @Specialization public static Object doYield(Object value, @Bind ContinuationRootNode root, @Bind MaterializedFrame frame) { return new MyGeneratorObject(root, frame, value); } } ``` A custom yield operation has many of the same restrictions and capabilities of a regular [`Operation`](com/oracle/truffle/api/bytecode/Operation.md), with a few differences: - It can take zero or more dynamic operands. - It yields a value to the caller, so it must have a return value. The result should be a [`valid interop type`](com/oracle/truffle/api/interop/InteropLibrary.md#isValidValue%28java.lang.Object%29). Typically, the result should encapsulate the continuation state so that the callee can resume execution at a later time. - It can [`Bind`](com/oracle/truffle/api/dsl/Bind.md) a [`ContinuationRootNode`](com/oracle/truffle/api/bytecode/ContinuationRootNode.md) operand, which can be used to resume execution at a later time. (Custom yields will typically also [`Bind`](com/oracle/truffle/api/dsl/Bind.md) the [`MaterializedFrame`](com/oracle/truffle/api/frame/MaterializedFrame.md) to capture the interpreter state, but this is possible in regular operations.) If a custom yield takes multiple dynamic operands, [`resultOperandIndex()`](com/oracle/truffle/api/bytecode/Yield.md#resultOperandIndex%28%29) specifies which operand represents the logical "result" of the yield before the custom yield executes. This result is used by [`tag instrumentation`](com/oracle/truffle/api/bytecode/GenerateBytecode.md#enableTagInstrumentation%28%29). Note that [`GenerateBytecode.enableYield`](com/oracle/truffle/api/bytecode/GenerateBytecode.md#enableYield%28%29) does not need to be `true` to use custom yields; it is only necessary if you need the built-in yield operation. The built-in yield operation is semantically equivalent to the following custom yield operation: ```java @Yield public static final class BuiltinYield { @Specialization public static Object doYield(Object result, @Bind ContinuationRootNode root, @Bind MaterializedFrame frame) { return ContinuationResult.create(root, frame, result); } } ``` **See also** - [`GenerateBytecode.enableYield()`](com/oracle/truffle/api/bytecode/GenerateBytecode.md#enableYield%28%29) ## Elements ### forceCached() `boolean forceCached() default false`. Since 25.1. Whether executing this operation should force the uncached interpreter (if enabled) to transition to cached. Default: `false`. See also: `Operation.forceCached()`. Cite: `com/oracle/truffle/api/bytecode/Yield.html#forceCached()` ### tags() `Class[] tags() default {}`. Since 25.1. The instrumentation tags that should be implicitly associated with this operation. Default: `{}`. See also: `GenerateBytecode.enableTagInstrumentation()`. Cite: `com/oracle/truffle/api/bytecode/Yield.html#tags()` ### javadoc() `String javadoc() default ""`. Since 25.1. Optional documentation for the instrumentation. This documentation is included in the javadoc for the generated interpreter. Default: `""`. Cite: `com/oracle/truffle/api/bytecode/Yield.html#javadoc()` ### resultOperandIndex() `int resultOperandIndex() default 0`. Since 25.2. Index of the dynamic operand that represents the logical "result" of the yield before the custom yield executes. This result is used by `tag instrumentation`. This field must be specified for custom yields with multiple dynamic operands; it should not be specified for custom yields with no dynamic operands. Default: `0`. Cite: `com/oracle/truffle/api/bytecode/Yield.html#resultOperandIndex()` # ▣ com.oracle.truffle.api.bytecode.debug [truffle-api](index.md) · Every page: [llms.txt](llms.txt) Package in truffle-api. Since 24.2. Debug utilities for the Bytecode DSL. These features are not intended to be used in production interpreters for performance reasons. ## Interfaces - [`BytecodeDebugListener`](com/oracle/truffle/api/bytecode/debug/BytecodeDebugListener.md): Base interface for a bytecode root node to get additional debug event that are normally not available. - [`BytecodeDebugTraceListener`](com/oracle/truffle/api/bytecode/debug/BytecodeDebugTraceListener.md): Implement this class to quickly get some debug output for events in the bytecode node. ## Classes - [`HistogramInstructionTracer`](com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.md): Instruction tracer that records per-opcode execution counts and optionally aggregates them into hierarchical histograms by user defined group clauses. - [`PrintInstructionTracer`](com/oracle/truffle/api/bytecode/debug/PrintInstructionTracer.md): An InstructionTracer implementation that prints a textual trace of executed bytecode instructions. # ◇ BytecodeDebugListener [truffle-api](index.md) › [com.oracle.truffle.api.bytecode.debug](com/oracle/truffle/api/bytecode/debug/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.bytecode.debug`](com/oracle/truffle/api/bytecode/debug/index.md). Since 24.2. ```java public interface BytecodeDebugListener ``` Base interface for a bytecode root node to get additional debug event that are normally not available. Useful for testing and debugging. Warning: Do not deploy with implementing this listener in production. It causes severe performance degradation. The debug listener can also be explicitly disabled by setting [`GenerateBytecode.enableBytecodeDebugListener()`](com/oracle/truffle/api/bytecode/GenerateBytecode.md#enableBytecodeDebugListener%28%29) to `false` . ## Methods ### beforeRootExecute(Instruction) `default void beforeRootExecute(Instruction enterInstruction)`. Since 24.2. Invoked before a root is executed. This has a very significant performance cost. Only override this method temporarily for debugging. This method may be called on partial evaluated code paths. Cite: `com/oracle/truffle/api/bytecode/debug/BytecodeDebugListener.html#beforeRootExecute(com.oracle.truffle.api.bytecode.Instruction)` ### afterRootExecute(Instruction, Object, Throwable) `default void afterRootExecute(Instruction leaveInstruction, Object returnValue, Throwable t)`. Since 24.2. Invoked before a root is left. This has a very significant performance cost. Only override this method temporarily for debugging. This method may be called on partial evaluated code paths. Parameters: `returnValue` `Object`: the value returned, or null if an exception was thrown. For yields, returnValue is the continuation result or custom yield return value. `t` `Throwable`: the exception thrown, or null if the root is exited normally. Cite: `com/oracle/truffle/api/bytecode/debug/BytecodeDebugListener.html#afterRootExecute(com.oracle.truffle.api.bytecode.Instruction,java.lang.Object,java.lang.Throwable)` ### beforeInstructionExecute(Instruction) `@Deprecated(since = "25.1") default void beforeInstructionExecute(Instruction instruction)`. Since 24.2. Deprecated since 25.1. no longer supported. Use `InstructionTracer` instead. Invoked before an instruction is executed. This has a very significant performance cost. Only override this method temporarily for debugging. This method may be called on partial evaluated code paths. Cite: `com/oracle/truffle/api/bytecode/debug/BytecodeDebugListener.html#beforeInstructionExecute(com.oracle.truffle.api.bytecode.Instruction)` ### afterInstructionExecute(Instruction, Throwable) `@Deprecated(since = "25.1") default void afterInstructionExecute(Instruction instruction, Throwable exception)`. Since 24.2. Deprecated since 25.1. no longer supported. Use `InstructionTracer` instead. Invoked after an instruction was executed. This has a very significant performance cost. Only override this method temporarily for debugging. This method may be called on partial evaluated code paths. Cite: `com/oracle/truffle/api/bytecode/debug/BytecodeDebugListener.html#afterInstructionExecute(com.oracle.truffle.api.bytecode.Instruction,java.lang.Throwable)` ### onSpecialize(Instruction, String) `default void onSpecialize(Instruction instruction, String specialization)`. Since 24.2. Invoked when an operation or instrumentation specializes itself. Cite: `com/oracle/truffle/api/bytecode/debug/BytecodeDebugListener.html#onSpecialize(com.oracle.truffle.api.bytecode.Instruction,java.lang.String)` ### onBytecodeStackTransition(Instruction, Instruction) `default void onBytecodeStackTransition(Instruction source, Instruction target)`. Since 24.2. Invoked when a bytecode node performs an on-stack transition. On stack transitions may happen if additional bytecode or tag instrumentations are applied during execution while the current method is on-stack. Cite: `com/oracle/truffle/api/bytecode/debug/BytecodeDebugListener.html#onBytecodeStackTransition(com.oracle.truffle.api.bytecode.Instruction,com.oracle.truffle.api.bytecode.Instruction)` ### onInvalidateInstruction(Instruction, Instruction) `default void onInvalidateInstruction(Instruction before, Instruction after)`. Since 24.2. Invoked when an instruction is invalidated. Instructions are invalidated to make bytecode nodes leave the current bytecode loop and update its own bytecodes. Cite: `com/oracle/truffle/api/bytecode/debug/BytecodeDebugListener.html#onInvalidateInstruction(com.oracle.truffle.api.bytecode.Instruction,com.oracle.truffle.api.bytecode.Instruction)` ### onQuicken(Instruction, Instruction) `default void onQuicken(Instruction before, Instruction after)`. Since 24.2. Invoked when an instruction was quickened. Cite: `com/oracle/truffle/api/bytecode/debug/BytecodeDebugListener.html#onQuicken(com.oracle.truffle.api.bytecode.Instruction,com.oracle.truffle.api.bytecode.Instruction)` ### onQuickenOperand(Instruction, int, …) `default void onQuickenOperand(Instruction baseInstruction, int operandIndex, Instruction operandBefore, Instruction operandAfter)`. Since 24.2. Invoked when an operand was quickened due to boxing elimination. Cite: `com/oracle/truffle/api/bytecode/debug/BytecodeDebugListener.html#onQuickenOperand(com.oracle.truffle.api.bytecode.Instruction,int,com.oracle.truffle.api.bytecode.Instruction,com.oracle.truffle.api.bytecode.Instruction)` # ◇ BytecodeDebugTraceListener [truffle-api](index.md) › [com.oracle.truffle.api.bytecode.debug](com/oracle/truffle/api/bytecode/debug/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.bytecode.debug`](com/oracle/truffle/api/bytecode/debug/index.md). Since 24.2. ```java public interface BytecodeDebugTraceListener extends BytecodeDebugListener ``` Extends: [`BytecodeDebugListener`](com/oracle/truffle/api/bytecode/debug/BytecodeDebugListener.md) Implement this class to quickly get some debug output for events in the bytecode node. ## Methods ### onQuicken(Instruction, Instruction) `default void onQuicken(Instruction before, Instruction after)`. Invoked when an instruction was quickened. Description copied from `onQuicken()`. Overrides `onQuicken()`. Cite: `com/oracle/truffle/api/bytecode/debug/BytecodeDebugTraceListener.html#onQuicken(com.oracle.truffle.api.bytecode.Instruction,com.oracle.truffle.api.bytecode.Instruction)` ### onQuickenOperand(Instruction, int, …) `default void onQuickenOperand(Instruction base, int operandIndex, Instruction operandBefore, Instruction operandAfter)`. Invoked when an operand was quickened due to boxing elimination. Description copied from `onQuickenOperand()`. Overrides `onQuickenOperand()`. Cite: `com/oracle/truffle/api/bytecode/debug/BytecodeDebugTraceListener.html#onQuickenOperand(com.oracle.truffle.api.bytecode.Instruction,int,com.oracle.truffle.api.bytecode.Instruction,com.oracle.truffle.api.bytecode.Instruction)` ### onSpecialize(Instruction, String) `default void onSpecialize(Instruction instruction, String specialization)`. Invoked when an operation or instrumentation specializes itself. Description copied from `onSpecialize()`. Overrides `onSpecialize()`. Cite: `com/oracle/truffle/api/bytecode/debug/BytecodeDebugTraceListener.html#onSpecialize(com.oracle.truffle.api.bytecode.Instruction,java.lang.String)` ## Inherited members - From interface [`BytecodeDebugListener`](com/oracle/truffle/api/bytecode/debug/BytecodeDebugListener.md): [`afterInstructionExecute`](com/oracle/truffle/api/bytecode/debug/BytecodeDebugListener.md#afterInstructionExecute%28com.oracle.truffle.api.bytecode.Instruction,java.lang.Throwable%29), [`afterRootExecute`](com/oracle/truffle/api/bytecode/debug/BytecodeDebugListener.md#afterRootExecute%28com.oracle.truffle.api.bytecode.Instruction,java.lang.Object,java.lang.Throwable%29), [`beforeInstructionExecute`](com/oracle/truffle/api/bytecode/debug/BytecodeDebugListener.md#beforeInstructionExecute%28com.oracle.truffle.api.bytecode.Instruction%29), [`beforeRootExecute`](com/oracle/truffle/api/bytecode/debug/BytecodeDebugListener.md#beforeRootExecute%28com.oracle.truffle.api.bytecode.Instruction%29), [`onBytecodeStackTransition`](com/oracle/truffle/api/bytecode/debug/BytecodeDebugListener.md#onBytecodeStackTransition%28com.oracle.truffle.api.bytecode.Instruction,com.oracle.truffle.api.bytecode.Instruction%29), [`onInvalidateInstruction`](com/oracle/truffle/api/bytecode/debug/BytecodeDebugListener.md#onInvalidateInstruction%28com.oracle.truffle.api.bytecode.Instruction,com.oracle.truffle.api.bytecode.Instruction%29) # ◆ HistogramInstructionTracer [truffle-api](index.md) › [com.oracle.truffle.api.bytecode.debug](com/oracle/truffle/api/bytecode/debug/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.bytecode.debug`](com/oracle/truffle/api/bytecode/debug/index.md). Since 25.1. ```java public final class HistogramInstructionTracer implements InstructionTracer ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `HistogramInstructionTracer` Implements: [`InstructionTracer`](com/oracle/truffle/api/bytecode/InstructionTracer.md) Instruction tracer that records per-opcode execution counts and optionally aggregates them into hierarchical histograms by user defined group clauses. The tracer is optimized for the no-filter, no-group case. In that mode the hot path avoids boundary calls and can be partially evaluated. When grouping or filtering is enabled, a small LRU cache avoids repeated evaluation of the grouping and filtering functions for the same [`BytecodeNode`](com/oracle/truffle/api/bytecode/BytecodeNode.md), current thread, and compilation tier. Thread safety: increments are performed via atomic counters and are safe under concurrent execution. Histogram creation is a snapshot that can be performed concurrently with counting. For interval semantics, prefer [`getHistogramAndReset()`](com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.md#getHistogramAndReset%28%29) over mixing [`getHistogram()`](com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.md#getHistogram%28%29) with [`reset()`](com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.md#reset%28%29). ### Basic usage The example below shows how to attach a [`HistogramInstructionTracer`](com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.md) directly to a generated bytecode root, execute code, then collect and print a histogram snapshot. ```java var root = MyRootNodeGen.BYTECODE.create(language, BytecodeConfig.DEFAULT, b -> { b.beginRoot(); b.beginReturn(); b.emitLoadArgument(0); b.endReturn(); b.endRoot(); }).getNode(0); // Create and attach the histogram tracer to the root. var tracer = HistogramInstructionTracer.newBuilder().build(MyRootNodeGen.BYTECODE); root.getRootNodes().addInstructionTracer(tracer); // Execute your program as usual. Object result = root.getCallTarget().call(42); // Take a consistent snapshot and reset counters for the next interval. var histogram = tracer.getHistogramAndReset(); // Inspect or print the histogram. long total = histogram.getInstructionsExecuted(); histogram.print(System.out); // Detach the tracer when done. root.getRootNodes().removeInstructionTracer(tracer); ``` ## Nested types - [`HistogramInstructionTracer.Builder`](com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.Builder.md) (class): Builder for HistogramInstructionTracer. - [`HistogramInstructionTracer.GroupClause`](com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.GroupClause.md) (interface): A grouping function that maps a BytecodeNode, the current Thread, and the compilation tier to an arbitrary grouping key. - [`HistogramInstructionTracer.Histogram`](com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.Histogram.md) (class): Represents a hierarchical histogram that can group instruction counts by arbitrary attributes. ## Methods ### onInstructionEnter(InstructionTracer.InstructionAccess, BytecodeNode, …) `public void onInstructionEnter(InstructionTracer.InstructionAccess access, BytecodeNode bytecode, int bytecodeIndex, Frame frame)`. Since 25.1. Records the execution of an instruction. This method is not intended to be called directly, but by the bytecode DSL framework as part of instruction tracing. Parameters: `access` `InstructionTracer.InstructionAccess`: accessor to query information about the current instruction, valid only during this call. `bytecode` `BytecodeNode`: the `BytecodeNode` currently being interpreted. `bytecodeIndex` `int`: the bytecode index (BCI) of the instruction to be executed. `frame` `Frame`: the current frame for the root being interpreted. Overrides `onInstructionEnter()`. Cite: `com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.html#onInstructionEnter(com.oracle.truffle.api.bytecode.InstructionTracer.InstructionAccess,com.oracle.truffle.api.bytecode.BytecodeNode,int,com.oracle.truffle.api.frame.Frame)` ### getExclusiveBytecodeDescriptor() `public BytecodeDescriptor getExclusiveBytecodeDescriptor()`. Returns the `BytecodeDescriptor` that this tracer is attached to. Returns `BytecodeDescriptor`: the descriptor used to resolve instruction metadata and opcodes. Overrides `getExclusiveBytecodeDescriptor()`. Cite: `com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.html#getExclusiveBytecodeDescriptor()` ### getHistogram() `public HistogramInstructionTracer.Histogram getHistogram()`. Since 25.1. Creates a hierarchical histogram snapshot of the recorded counters without resetting them. Use this to inspect cumulative counts. If you need interval semantics, prefer `getHistogramAndReset()`. Returns `HistogramInstructionTracer.Histogram`: a `Histogram` view of the current counters, possibly grouped. Cite: `com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.html#getHistogram()` ### getHistogramAndReset() `public HistogramInstructionTracer.Histogram getHistogramAndReset()`. Since 25.1. Creates a hierarchical histogram snapshot of the recorded counters and atomically resets the underlying counters to zero. Use this to obtain interval counts in long running applications. The reset is performed atomically per-counter, increments that occur after the swap will be visible in the next interval. Returns `HistogramInstructionTracer.Histogram`: a `Histogram` view of the counts since the previous reset. Cite: `com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.html#getHistogramAndReset()` ### dumpHistogram() `public String dumpHistogram()`. Since 25.1. Renders the current histogram snapshot into a string using `printHistogram(PrintStream)`. Returns `String`: a human readable histogram table as UTF-8 text. See also: `Histogram.dump()`. Cite: `com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.html#dumpHistogram()` ### printHistogram(PrintStream) `public void printHistogram(PrintStream out)`. Since 25.1. Prints the current histogram snapshot to the given [`PrintStream`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/PrintStream.html). The output is a single table with aligned numeric columns. Groups, if present, are printed as indented pseudo rows followed by their leaves. Parameters: `out` `PrintStream`: the stream to print to. See also: `Histogram.print(PrintStream)`. Cite: `com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.html#printHistogram(java.io.PrintStream)` ### reset() `public void reset()`. Since 25.1. Resets all counters to zero and discards previously recorded data. Do not mix this with `getHistogram()` if you need interval correctness, use `getHistogramAndReset()` instead. Cite: `com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.html#reset()` ### newBuilder() `public static HistogramInstructionTracer.Builder newBuilder()`. Since 25.1. Returns a builder for `HistogramInstructionTracer` that allows configuring a filter and one or more grouping clauses. Returns `HistogramInstructionTracer.Builder`: a new builder instance. Cite: `com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.html#newBuilder()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ HistogramInstructionTracer.Builder [truffle-api](index.md) › [com.oracle.truffle.api.bytecode.debug](com/oracle/truffle/api/bytecode/debug/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.bytecode.debug`](com/oracle/truffle/api/bytecode/debug/index.md). Since 25.1. Nested in [`HistogramInstructionTracer`](com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.md). ```java public static final class HistogramInstructionTracer.Builder ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Builder` Builder for [`HistogramInstructionTracer`](com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.md). The builder supports an optional filter predicate and an ordered list of group clauses. Group clauses are applied in the order they are added, producing a hierarchy of groups. ## Methods ### filter(Predicate) `public HistogramInstructionTracer.Builder filter(Predicate filterClause)`. Since 25.1. Sets an optional filter predicate. If present, only bytecode nodes that satisfy the predicate contribute to counters. Parameters: `filterClause` `Predicate`: the predicate to apply, may be `null`. Returns `HistogramInstructionTracer.Builder`: this builder. Cite: `com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.Builder.html#filter(java.util.function.Predicate)` ### groupBy(HistogramInstructionTracer.GroupClause) `public HistogramInstructionTracer.Builder groupBy(HistogramInstructionTracer.GroupClause clause)`. Since 25.1. Adds a grouping clause to the histogram. Multiple clauses create a hierarchy, the first clause forms the top level, the last clause forms the leaves. Parameters: `clause` `HistogramInstructionTracer.GroupClause`: the grouping clause to add, must not be `null`. Returns `HistogramInstructionTracer.Builder`: this builder. Throws: `NullPointerException` (unchecked): if `clause` is `null`. Cite: `com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.Builder.html#groupBy(com.oracle.truffle.api.bytecode.debug.HistogramInstructionTracer.GroupClause)` ### build(BytecodeDescriptor) `public HistogramInstructionTracer build(BytecodeDescriptor descriptor)`. Since 25.1. Builds a `HistogramInstructionTracer` for the given `BytecodeDescriptor`. Parameters: `descriptor` `BytecodeDescriptor`: the descriptor to attach to. Returns `HistogramInstructionTracer`: a new tracer configured with the previously set filter and groups. Cite: `com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.Builder.html#build(com.oracle.truffle.api.bytecode.BytecodeDescriptor)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ HistogramInstructionTracer.GroupClause [truffle-api](index.md) › [com.oracle.truffle.api.bytecode.debug](com/oracle/truffle/api/bytecode/debug/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.bytecode.debug`](com/oracle/truffle/api/bytecode/debug/index.md). Since 25.1. Nested in [`HistogramInstructionTracer`](com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.md). ```java @FunctionalInterface public interface HistogramInstructionTracer.GroupClause ``` A grouping function that maps a [`BytecodeNode`](com/oracle/truffle/api/bytecode/BytecodeNode.md), the current [`Thread`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Thread.html), and the compilation tier to an arbitrary grouping key. Keys are used to form hierarchical histograms. ## Methods ### group(BytecodeNode, Thread, int) `Object group(BytecodeNode bytecodeNode, Thread thread, int compilationTier)`. Since 25.1. Computes the grouping key for the given execution context. Parameters: `bytecodeNode` `BytecodeNode`: the bytecode node executing. `thread` `Thread`: the current thread. `compilationTier` `int`: 0 for interpreter, 1 for compiled with a next tier, 2 for final compiled. Returns `Object`: a non null grouping key, for example a string, an enum, or a small record. Cite: `com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.GroupClause.html#group(com.oracle.truffle.api.bytecode.BytecodeNode,java.lang.Thread,int)` # ◆ HistogramInstructionTracer.Histogram [truffle-api](index.md) › [com.oracle.truffle.api.bytecode.debug](com/oracle/truffle/api/bytecode/debug/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.bytecode.debug`](com/oracle/truffle/api/bytecode/debug/index.md). Since 25.1. Nested in [`HistogramInstructionTracer`](com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.md). ```java public static final class HistogramInstructionTracer.Histogram ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Histogram` Represents a hierarchical histogram that can group instruction counts by arbitrary attributes. A histogram is an immutable snapshot of the counters at the time it was created. ## Methods ### getCounters() `public Map getCounters()`. Since 25.1. Returns the per-instruction counts for this histogram level when it is a leaf. If this histogram has subgroups, this map may be empty, since counts then live in the children. Returns `Map`: an unmodifiable map from `InstructionDescriptor` to count. Cite: `com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.Histogram.html#getCounters()` ### getStatistics() `public Map getStatistics()`. Since 25.1. Returns aggregated statistics across this histogram level. For leaf histograms, this wraps each count in a [`LongSummaryStatistics`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/LongSummaryStatistics.html). For parent histograms, statistics are combined across all children. Returns `Map`: a map from `InstructionDescriptor` to aggregated statistics. Cite: `com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.Histogram.html#getStatistics()` ### getGroups() `public Map getGroups()`. Since 25.1. Returns the subgroups of this histogram, keyed by the grouping values produced by the configured `GroupClause`s. Returns `Map`: an unmodifiable map of subgroup keys to child histograms, or `null` if there are no groups. Cite: `com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.Histogram.html#getGroups()` ### dump() `public String dump()`. Since 25.1. Renders this histogram to a string using `print(PrintStream)`. Returns `String`: a human readable histogram table. Cite: `com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.Histogram.html#dump()` ### print(PrintStream) `public void print(PrintStream out)`. Since 25.1. Prints this histogram as a single indented table. Numeric columns are aligned. When groups are present, each group is shown as a row that displays the total for the group, followed by the indented rows of its children. Parameters: `out` `PrintStream`: the stream to print to. Cite: `com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.Histogram.html#print(java.io.PrintStream)` ### getInstructionsExecuted() `public long getInstructionsExecuted()`. Since 25.1. Returns the total number of executed instructions represented by this histogram. For grouped histograms, this is the sum across all children. For leaves, this is the sum of the per-instruction counts. Returns `long`: the total count represented by this histogram. Cite: `com/oracle/truffle/api/bytecode/debug/HistogramInstructionTracer.Histogram.html#getInstructionsExecuted()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ PrintInstructionTracer [truffle-api](index.md) › [com.oracle.truffle.api.bytecode.debug](com/oracle/truffle/api/bytecode/debug/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.bytecode.debug`](com/oracle/truffle/api/bytecode/debug/index.md). Since 25.1. ```java public final class PrintInstructionTracer implements InstructionTracer ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `PrintInstructionTracer` Implements: [`InstructionTracer`](com/oracle/truffle/api/bytecode/InstructionTracer.md) An [`InstructionTracer`](com/oracle/truffle/api/bytecode/InstructionTracer.md) implementation that prints a textual trace of executed bytecode instructions. Each time an instruction is about to execute, this tracer formats a single line containing: - a monotonically increasing instruction counter, - the qualified root name of the [`BytecodeNode`](com/oracle/truffle/api/bytecode/BytecodeNode.md) being interpreted, and - a human readable representation of the instruction at the current bytecode index. Output is delivered to a user-supplied [`Consumer`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/Consumer.html)\ (for example, `System.out::println`) or to a [`java.io.PrintStream`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/PrintStream.html) via the [`newBuilder(PrintStream)`](com/oracle/truffle/api/bytecode/debug/PrintInstructionTracer.md#newBuilder%28java.io.PrintStream%29) convenience factory. A tracer may optionally be restricted to a subset of bytecode roots by installing a filter predicate. If a [`BytecodeNode`](com/oracle/truffle/api/bytecode/BytecodeNode.md) does not match the filter, its instructions are skipped. This tracer is intended for debugging and profiling during development. It runs on the language execution thread and executes on the hot path before every instruction; it should not be left enabled in production code. ## Nested types - [`PrintInstructionTracer.Builder`](com/oracle/truffle/api/bytecode/debug/PrintInstructionTracer.Builder.md) (class): Builder for PrintInstructionTracer instances. ## Methods ### onInstructionEnter(InstructionTracer.InstructionAccess, BytecodeNode, …) `public void onInstructionEnter(InstructionTracer.InstructionAccess access, BytecodeNode bytecode, int bytecodeIndex, Frame frame)`. Since 25.1. Called immediately before executing the instruction at `bytecodeIndex` of the given `bytecode` node. This implementation formats and emits a single trace line for the current instruction, unless the `BytecodeNode` is excluded by the active filter. Parameters: `access` `InstructionTracer.InstructionAccess`: accessor to query information about the current instruction, valid only during this call. `bytecode` `BytecodeNode`: the `BytecodeNode` currently being interpreted. `bytecodeIndex` `int`: the bytecode index (BCI) of the instruction to be executed. `frame` `Frame`: the current frame for the root being interpreted. Overrides `onInstructionEnter()`. Cite: `com/oracle/truffle/api/bytecode/debug/PrintInstructionTracer.html#onInstructionEnter(com.oracle.truffle.api.bytecode.InstructionTracer.InstructionAccess,com.oracle.truffle.api.bytecode.BytecodeNode,int,com.oracle.truffle.api.frame.Frame)` ### reset() `public void reset()`. Since 25.1. Resets the internal instruction counter back to zero. This only affects the counter included in the printed trace lines. It does not clear any output sink or filter configuration. Cite: `com/oracle/truffle/api/bytecode/debug/PrintInstructionTracer.html#reset()` ### newBuilder(Consumer) `public static PrintInstructionTracer.Builder newBuilder(Consumer out)`. Since 25.1. Creates a new `Builder` that will emit trace lines to the given consumer. Each generated line is already formatted. The consumer is typically a logger or `System.out::println`, but any [`Consumer`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/Consumer.html) is accepted. Parameters: `out` `Consumer`: sink for formatted trace lines. Returns `PrintInstructionTracer.Builder`: a new builder. Cite: `com/oracle/truffle/api/bytecode/debug/PrintInstructionTracer.html#newBuilder(java.util.function.Consumer)` ### newBuilder(PrintStream) `public static PrintInstructionTracer.Builder newBuilder(PrintStream out)`. Since 25.1. Convenience overload of `newBuilder(Consumer)` that writes to a [`PrintStream`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/PrintStream.html). The resulting tracer will call [`PrintStream.println(String)`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/PrintStream.html#println%28java.lang.String%29) for every traced instruction. Parameters: `out` `PrintStream`: a print stream (for example `System.out`). Returns `PrintInstructionTracer.Builder`: a new builder. Cite: `com/oracle/truffle/api/bytecode/debug/PrintInstructionTracer.html#newBuilder(java.io.PrintStream)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) - From interface [`InstructionTracer`](com/oracle/truffle/api/bytecode/InstructionTracer.md): [`getExclusiveBytecodeDescriptor`](com/oracle/truffle/api/bytecode/InstructionTracer.md#getExclusiveBytecodeDescriptor%28%29) # ◆ PrintInstructionTracer.Builder [truffle-api](index.md) › [com.oracle.truffle.api.bytecode.debug](com/oracle/truffle/api/bytecode/debug/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.bytecode.debug`](com/oracle/truffle/api/bytecode/debug/index.md). Since 25.1. Nested in [`PrintInstructionTracer`](com/oracle/truffle/api/bytecode/debug/PrintInstructionTracer.md). ```java public static final class PrintInstructionTracer.Builder ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Builder` Builder for [`PrintInstructionTracer`](com/oracle/truffle/api/bytecode/debug/PrintInstructionTracer.md) instances. Call [`filter(Predicate)`](com/oracle/truffle/api/bytecode/debug/PrintInstructionTracer.Builder.md#filter%28java.util.function.Predicate%29) to restrict tracing to selected [`BytecodeNode`](com/oracle/truffle/api/bytecode/BytecodeNode.md)s, then [`build()`](com/oracle/truffle/api/bytecode/debug/PrintInstructionTracer.Builder.md#build%28%29) to create the tracer. ## Methods ### filter(Predicate) `public PrintInstructionTracer.Builder filter(Predicate filterClause)`. Since 25.1. Sets an optional filter that decides which `BytecodeNode`s should be traced. If the predicate returns `false` for a given node, instructions executed in that node are not printed. Parameters: `filterClause` `Predicate`: predicate that returns true if tracing should be enabled for the given node. Returns `PrintInstructionTracer.Builder`: this builder. Cite: `com/oracle/truffle/api/bytecode/debug/PrintInstructionTracer.Builder.html#filter(java.util.function.Predicate)` ### build() `public PrintInstructionTracer build()`. Since 25.1. Creates a new `PrintInstructionTracer` instance using the configured output sink and optional filter. Returns `PrintInstructionTracer`: a new tracer. Cite: `com/oracle/truffle/api/bytecode/debug/PrintInstructionTracer.Builder.html#build()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ▣ com.oracle.truffle.api.bytecode.serialization [truffle-api](index.md) · Every page: [llms.txt](llms.txt) Package in truffle-api. Since 24.2. Serialization-specific classes for the Bytecode DSL. ## Interfaces - [`BytecodeDeserializer`](com/oracle/truffle/api/bytecode/serialization/BytecodeDeserializer.md): Represents a class that can deserialize constants from a byte stream. - [`BytecodeSerializer`](com/oracle/truffle/api/bytecode/serialization/BytecodeSerializer.md): Represents a class that can serialize constants in a bytecode interpreter. ## Classes - [`ByteBufferDataInput`](com/oracle/truffle/api/bytecode/serialization/ByteBufferDataInput.md): A DataInput backed by a ByteBuffer. - [`SerializationUtils`](com/oracle/truffle/api/bytecode/serialization/SerializationUtils.md): Utility class with helpers for serialization code. # ◆ ByteBufferDataInput [truffle-api](index.md) › [com.oracle.truffle.api.bytecode.serialization](com/oracle/truffle/api/bytecode/serialization/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.bytecode.serialization`](com/oracle/truffle/api/bytecode/serialization/index.md). Since 25.1. ```java public final class ByteBufferDataInput implements DataInput ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `ByteBufferDataInput` Implements: [`DataInput`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/DataInput.html) A [`DataInput`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/DataInput.html) backed by a [`ByteBuffer`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/ByteBuffer.html). **See also** - [`SerializationUtils.createByteBufferDataInput(ByteBuffer)`](com/oracle/truffle/api/bytecode/serialization/SerializationUtils.md#createByteBufferDataInput%28java.nio.ByteBuffer%29) ## Methods ### readFully(byte[]) `public void readFully(byte[] b) throws IOException`. Since 25.1. Overrides `readFully(byte[])`. Cite: `com/oracle/truffle/api/bytecode/serialization/ByteBufferDataInput.html#readFully(byte[])` ### readFully(byte[], int, int) `public void readFully(byte[] b, int off, int len) throws IOException`. Since 25.1. Overrides `readFully(byte[],int,int)`. Cite: `com/oracle/truffle/api/bytecode/serialization/ByteBufferDataInput.html#readFully(byte[],int,int)` ### skipBytes(int) `public int skipBytes(int n) throws IOException`. Since 25.1. Overrides `skipBytes(int)`. Cite: `com/oracle/truffle/api/bytecode/serialization/ByteBufferDataInput.html#skipBytes(int)` ### readBoolean() `public boolean readBoolean() throws IOException`. Since 25.1. Overrides `readBoolean()`. Cite: `com/oracle/truffle/api/bytecode/serialization/ByteBufferDataInput.html#readBoolean()` ### readByte() `public byte readByte() throws IOException`. Since 25.1. Overrides `readByte()`. Cite: `com/oracle/truffle/api/bytecode/serialization/ByteBufferDataInput.html#readByte()` ### readUnsignedByte() `public int readUnsignedByte() throws IOException`. Since 25.1. Overrides `readUnsignedByte()`. Cite: `com/oracle/truffle/api/bytecode/serialization/ByteBufferDataInput.html#readUnsignedByte()` ### readShort() `public short readShort() throws IOException`. Since 25.1. Overrides `readShort()`. Cite: `com/oracle/truffle/api/bytecode/serialization/ByteBufferDataInput.html#readShort()` ### readUnsignedShort() `public int readUnsignedShort() throws IOException`. Since 25.1. Overrides `readUnsignedShort()`. Cite: `com/oracle/truffle/api/bytecode/serialization/ByteBufferDataInput.html#readUnsignedShort()` ### readChar() `public char readChar() throws IOException`. Since 25.1. Overrides `readChar()`. Cite: `com/oracle/truffle/api/bytecode/serialization/ByteBufferDataInput.html#readChar()` ### readInt() `public int readInt() throws IOException`. Since 25.1. Overrides `readInt()`. Cite: `com/oracle/truffle/api/bytecode/serialization/ByteBufferDataInput.html#readInt()` ### readLong() `public long readLong() throws IOException`. Since 25.1. Overrides `readLong()`. Cite: `com/oracle/truffle/api/bytecode/serialization/ByteBufferDataInput.html#readLong()` ### readFloat() `public float readFloat() throws IOException`. Since 25.1. Overrides `readFloat()`. Cite: `com/oracle/truffle/api/bytecode/serialization/ByteBufferDataInput.html#readFloat()` ### readDouble() `public double readDouble() throws IOException`. Since 25.1. Overrides `readDouble()`. Cite: `com/oracle/truffle/api/bytecode/serialization/ByteBufferDataInput.html#readDouble()` ### readLine() `@Deprecated public String readLine() throws IOException`. Since 25.1. Deprecated. Modified from [`DataInputStream.readLine()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/DataInputStream.html#readLine%28%29). Overrides `readLine()`. Cite: `com/oracle/truffle/api/bytecode/serialization/ByteBufferDataInput.html#readLine()` ### readUTF() `public String readUTF() throws IOException`. Since 25.1. Overrides `readUTF()`. Cite: `com/oracle/truffle/api/bytecode/serialization/ByteBufferDataInput.html#readUTF()` ### position() `public int position()`. Since 25.1. Returns the position in the underlying byte buffer. Cite: `com/oracle/truffle/api/bytecode/serialization/ByteBufferDataInput.html#position()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ BytecodeDeserializer [truffle-api](index.md) › [com.oracle.truffle.api.bytecode.serialization](com/oracle/truffle/api/bytecode/serialization/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.bytecode.serialization`](com/oracle/truffle/api/bytecode/serialization/index.md). Since 24.2. ```java @FunctionalInterface public interface BytecodeDeserializer ``` Represents a class that can deserialize constants from a byte stream. A [`BytecodeSerializer`](com/oracle/truffle/api/bytecode/serialization/BytecodeSerializer.md) establishes a byte encoding for objects. The [`BytecodeDeserializer`](com/oracle/truffle/api/bytecode/serialization/BytecodeDeserializer.md) used to deserialize an interpreter should follow the same encoding. For example: ```java public class MyBytecodeDeserializer implements BytecodeDeserializer { @Override public Object deserialize(DeserializerContext context, DataInput buffer) throws IOException { byte objectCode = buffer.readByte(); return switch (objectCode) { case 1 -> buffer.readLong(); case 2 -> buffer.readUTF(); case ... } } } ``` **See also** - [`com.oracle.truffle.api.bytecode.GenerateBytecode.enableSerialization`](com/oracle/truffle/api/bytecode/GenerateBytecode.md#enableSerialization%28%29) ## Nested types - [`BytecodeDeserializer.DeserializerContext`](com/oracle/truffle/api/bytecode/serialization/BytecodeDeserializer.DeserializerContext.md) (interface): Interface for a generated class that can deserialize a BytecodeRootNode from a byte input. ## Methods ### deserialize(BytecodeDeserializer.DeserializerContext, DataInput) `Object deserialize(BytecodeDeserializer.DeserializerContext context, DataInput buffer) throws IOException`. Since 24.2. The deserialization process. An `object` should be decoded from the `buffer` and returned. The `context` is supplied so that a `BytecodeDeserializer` can transitively deserialize other `root nodes` (e.g., inner functions) if necessary. Root nodes may not be fully initialized, so this method must not execute these roots or request call targets/metadata updates. Must be idempotent. This method may be invoked multiple times for the same logical constant. See `BytecodeSerializer.serialize` for encoding requirements and guidance on preserving object identity across invocations and reparses. Cite: `com/oracle/truffle/api/bytecode/serialization/BytecodeDeserializer.html#deserialize(com.oracle.truffle.api.bytecode.serialization.BytecodeDeserializer.DeserializerContext,java.io.DataInput)` # ◇ BytecodeDeserializer.DeserializerContext [truffle-api](index.md) › [com.oracle.truffle.api.bytecode.serialization](com/oracle/truffle/api/bytecode/serialization/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.bytecode.serialization`](com/oracle/truffle/api/bytecode/serialization/index.md). Since 24.2. Nested in [`BytecodeDeserializer`](com/oracle/truffle/api/bytecode/serialization/BytecodeDeserializer.md). ```java public interface BytecodeDeserializer.DeserializerContext ``` Interface for a generated class that can deserialize a [`BytecodeRootNode`](com/oracle/truffle/api/bytecode/BytecodeRootNode.md) from a byte input. ## Methods ### readBytecodeNode(DataInput) `BytecodeRootNode readBytecodeNode(DataInput buffer) throws IOException`. Since 24.2. Deserializes a `BytecodeRootNode` from the byte input. Cite: `com/oracle/truffle/api/bytecode/serialization/BytecodeDeserializer.DeserializerContext.html#readBytecodeNode(java.io.DataInput)` # ◇ BytecodeSerializer [truffle-api](index.md) › [com.oracle.truffle.api.bytecode.serialization](com/oracle/truffle/api/bytecode/serialization/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.bytecode.serialization`](com/oracle/truffle/api/bytecode/serialization/index.md). Since 24.2. ```java @FunctionalInterface public interface BytecodeSerializer ``` Represents a class that can serialize constants in a bytecode interpreter. A [`BytecodeSerializer`](com/oracle/truffle/api/bytecode/serialization/BytecodeSerializer.md) establishes a byte encoding for objects. The [`BytecodeDeserializer`](com/oracle/truffle/api/bytecode/serialization/BytecodeDeserializer.md) used to deserialize an interpreter should follow the same encoding. For example: ```java public class MyBytecodeSerializer implements BytecodeSerializer { @Override public void serialize(SerializerContext context, DataOutput buffer, Object object) throws IOException { if (object instanceof Integer i) { buffer.writeByte(0); buffer.writeInt(i); } else if (object instanceof String s) { buffer.writeByte(1); buffer.writeUTF(s); } else ... } } ``` A serializer is responsible for encoding: - objects used as constants in the bytecode (e.g., objects passed to `emitLoadConstant` or constant operands, except primitive ones that are [`inlined`](com/oracle/truffle/api/bytecode/GenerateBytecode.md#inlinePrimitiveConstants%28%29)) - objects stored in non-`transient` fields of the root node - [`Source`](com/oracle/truffle/api/source/Source.md) objects passed in builder calls (i.e., sources passed to `beginSource`) **See also** - [`GenerateBytecode.enableSerialization`](com/oracle/truffle/api/bytecode/GenerateBytecode.md#enableSerialization%28%29) ## Nested types - [`BytecodeSerializer.SerializerContext`](com/oracle/truffle/api/bytecode/serialization/BytecodeSerializer.SerializerContext.md) (interface): Interface for a generated class that can serialize a BytecodeRootNode to a byte buffer. ## Methods ### serialize(BytecodeSerializer.SerializerContext, DataOutput, Object) `void serialize(BytecodeSerializer.SerializerContext context, DataOutput buffer, Object object) throws IOException`. Since 24.2. The serialization process. The byte encoding of `object` should be written to `buffer`. The `context` is supplied so that a `BytecodeSerializer` can transitively serialize other `root nodes` (e.g., inner functions) if necessary. Root nodes may not be fully initialized, so this method must not execute these roots or request call targets/metadata updates. The serializer should not rely on side-effects of the language. The serializer should not try to deduplicate constants. The Bytecode DSL avoids serializing the same constant multiple times within a single serialization operation, using object equality to deduplicate constants (except for [`Float`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Float.html) and [`Double`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Double.html), which use raw bits to preserve distinct NaN payloads). However, the same serializer could be used for both `builder bytecode` and `execution bytecode`, and both payloads must be independently decodable. **Object identity**: When object identity matters, the above constraint means that the serializer and deserializer must cooperate to return the same object for repeated decodings. A simple way to achieve this is by caching objects by a language-assigned ID and encoding the ID with the description: on deserialization, the first occurrence of the ID can construct the object and subsequent occurrences can reuse the cached value. Reparsing also affects identity: a reparse should not construct a new object if its identity is important. Reparses use the same deserializer object, so if a caching scheme is used, reparsing should automatically reuse existing objects. If a language serializes both `builder bytecode` and `execution bytecode` it should be careful to reuse the same serializer instance to ensure cache IDs are consistent. Cite: `com/oracle/truffle/api/bytecode/serialization/BytecodeSerializer.html#serialize(com.oracle.truffle.api.bytecode.serialization.BytecodeSerializer.SerializerContext,java.io.DataOutput,java.lang.Object)` # ◇ BytecodeSerializer.SerializerContext [truffle-api](index.md) › [com.oracle.truffle.api.bytecode.serialization](com/oracle/truffle/api/bytecode/serialization/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.bytecode.serialization`](com/oracle/truffle/api/bytecode/serialization/index.md). Since 24.2. Nested in [`BytecodeSerializer`](com/oracle/truffle/api/bytecode/serialization/BytecodeSerializer.md). ```java public interface BytecodeSerializer.SerializerContext ``` Interface for a generated class that can serialize a [`BytecodeRootNode`](com/oracle/truffle/api/bytecode/BytecodeRootNode.md) to a byte buffer. ## Methods ### writeBytecodeNode(DataOutput, BytecodeRootNode) `void writeBytecodeNode(DataOutput buffer, BytecodeRootNode node) throws IOException`. Since 24.2. Serializes a `BytecodeRootNode` to the byte buffer. The given node must be created by the current parse, otherwise the behaviour of this method is undefined. Cite: `com/oracle/truffle/api/bytecode/serialization/BytecodeSerializer.SerializerContext.html#writeBytecodeNode(java.io.DataOutput,com.oracle.truffle.api.bytecode.BytecodeRootNode)` # ◆ SerializationUtils [truffle-api](index.md) › [com.oracle.truffle.api.bytecode.serialization](com/oracle/truffle/api/bytecode/serialization/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.bytecode.serialization`](com/oracle/truffle/api/bytecode/serialization/index.md). Since 24.2. ```java public final class SerializationUtils ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `SerializationUtils` Utility class with helpers for serialization code. ## Methods ### createDataInput(ByteBuffer) `@Deprecated(since = "25.1") public static DataInput createDataInput(ByteBuffer buffer)`. Since 24.2. Deprecated since 25.1. Use `createByteBufferDataInput(ByteBuffer)`. Creates a [`DataInput`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/DataInput.html) backed by a [`ByteBuffer`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/ByteBuffer.html). The result can be used as an input for `deserialize`. See also: `com.oracle.truffle.api.bytecode.GenerateBytecode.enableSerialization`. Cite: `com/oracle/truffle/api/bytecode/serialization/SerializationUtils.html#createDataInput(java.nio.ByteBuffer)` ### createByteBufferDataInput(ByteBuffer) `public static ByteBufferDataInput createByteBufferDataInput(ByteBuffer buffer)`. Since 25.1. Creates a `ByteBufferDataInput`. The result can be used as an input for `deserialize`. See also: `com.oracle.truffle.api.bytecode.GenerateBytecode.enableSerialization`. Cite: `com/oracle/truffle/api/bytecode/serialization/SerializationUtils.html#createByteBufferDataInput(java.nio.ByteBuffer)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ▣ com.oracle.truffle.api.debug [truffle-api](index.md) · Every page: [llms.txt](llms.txt) Package in truffle-api. Since 0.8 or older. The debug package contains a debugger API that can be used to install breakpoints, step through and control the execution of Truffle guest language applications. The debug package is designed to be used with multiple languages and multiple threads executing at the same time. ##### Getting started using the debugger First the debugger instance needs to be discovered using a Truffle guest language with [`com.oracle.truffle.api.debug.Debugger.find(com.oracle.truffle.api.TruffleLanguage.Env)`](com/oracle/truffle/api/debug/Debugger.md#find%28com.oracle.truffle.api.TruffleLanguage.Env%29). Next a debugger session needs to be started with [`com.oracle.truffle.api.debug.Debugger.startSession(SuspendedCallback)`](com/oracle/truffle/api/debug/Debugger.md#startSession%28com.oracle.truffle.api.debug.SuspendedCallback%29) providing a [`callback`](com/oracle/truffle/api/debug/SuspendedCallback.md) that will be invoked whenever the execution is suspended. The debugger client can either [`install`](com/oracle/truffle/api/debug/DebuggerSession.md#install%28com.oracle.truffle.api.debug.Breakpoint%29) a breakpoint or [`suspend`](com/oracle/truffle/api/debug/DebuggerSession.md#suspendNextExecution%28%29) the current or next execution. Whenever the execution is suspended and the [`callback`](com/oracle/truffle/api/debug/SuspendedCallback.md) is invoked the client can decide step into, step out or step over the next statements. For a usage example please refer to [`com.oracle.truffle.api.debug.DebuggerSession`](com/oracle/truffle/api/debug/DebuggerSession.md) and [`com.oracle.truffle.api.debug.Breakpoint`](com/oracle/truffle/api/debug/Breakpoint.md). ##### Enable Debugging for your Truffle guest language The platform's core support for [`debugging`](com/oracle/truffle/api/debug/Debugger.md) is language-agnostic. A [`language implementation`](com/oracle/truffle/api/TruffleLanguage.md) enables debugging by supplying extra information in every AST that configures debugger behavior for code written in that particular language. This extra information is expressed using so called tags. Tags can be applied to AST nodes by implementing the [`com.oracle.truffle.api.instrumentation.InstrumentableNode.hasTag(Class)`](com/oracle/truffle/api/instrumentation/InstrumentableNode.md#hasTag%28java.lang.Class%29) method. The debugger requires the guest language to implement statement and call tags from the set of standard Truffle tags. Please refer to [`com.oracle.truffle.api.instrumentation.StandardTags`](com/oracle/truffle/api/instrumentation/StandardTags.md) on how to implement them. ## Interfaces - [`DebugContextsListener`](com/oracle/truffle/api/debug/DebugContextsListener.md): Listener to be notified about changes of contexts in guest language application. - [`DebugThreadsListener`](com/oracle/truffle/api/debug/DebugThreadsListener.md): Listener to be notified about changes of threads in guest language application. - [`SuspendedCallback`](com/oracle/truffle/api/debug/SuspendedCallback.md): Callback invoked whenever the debugger suspends for a particular session. ## Classes - [`Breakpoint`](com/oracle/truffle/api/debug/Breakpoint.md): A request that guest language program execution be suspended at specified locations on behalf of a debugging client session. - [`DebugContext`](com/oracle/truffle/api/debug/DebugContext.md): Representation of a polyglot context in a guest language execution. - [`DebugScope`](com/oracle/truffle/api/debug/DebugScope.md): Representation of guest language scope at the current suspension point, or a top scope. - [`DebugStackFrame`](com/oracle/truffle/api/debug/DebugStackFrame.md): Represents a frame in the guest language stack. - [`DebugStackTraceElement`](com/oracle/truffle/api/debug/DebugStackTraceElement.md): Represents a trace element in the guest language stack trace. - [`DebugValue`](com/oracle/truffle/api/debug/DebugValue.md): Represents a value accessed using the debugger API. - [`Debugger`](com/oracle/truffle/api/debug/Debugger.md): Class that simplifies implementing a debugger on top of Truffle. - [`DebuggerSession`](com/oracle/truffle/api/debug/DebuggerSession.md): Represents a single debugging session of a Debugger. - [`DebuggerTags`](com/oracle/truffle/api/debug/DebuggerTags.md): Set of debugger-specific tags. - [`StepConfig`](com/oracle/truffle/api/debug/StepConfig.md): Represents a debugger step configuration. - [`SuspendedEvent`](com/oracle/truffle/api/debug/SuspendedEvent.md): Access for Debugger clients to the state of a guest language execution thread that has been suspended, for example by a Breakpoint or stepping action. - [`SuspensionFilter`](com/oracle/truffle/api/debug/SuspensionFilter.md): A filter to limit the suspension locations. ## Enums - [`SourceElement`](com/oracle/truffle/api/debug/SourceElement.md): Representation of a guest language source syntax element, that is used for debugging purposes. - [`SuspendAnchor`](com/oracle/truffle/api/debug/SuspendAnchor.md): Describes where, within a guest language source section, the suspend position is. ## Exceptions - [`DebugException`](com/oracle/truffle/api/debug/DebugException.md): Information about an exception thrown from a guest language. # ◆ Breakpoint [truffle-api](index.md) › [com.oracle.truffle.api.debug](com/oracle/truffle/api/debug/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.debug`](com/oracle/truffle/api/debug/index.md). Since 0.9. ```java public class Breakpoint ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Breakpoint` A request that guest language program execution be suspended at specified locations on behalf of a debugging client [session](com/oracle/truffle/api/debug/DebuggerSession.md). #### Breakpoint lifetime - A client of a [`DebuggerSession`](com/oracle/truffle/api/debug/DebuggerSession.md) uses a [`Builder`](com/oracle/truffle/api/debug/Breakpoint.Builder.md) to create a new breakpoint, choosing among multiple ways to specify the intended location. Examples include a specified [`source`](com/oracle/truffle/api/debug/Breakpoint.md#newBuilder%28com.oracle.truffle.api.source.Source%29), a specified [`URI`](com/oracle/truffle/api/debug/Breakpoint.md#newBuilder%28java.net.URI%29), line ranges, or an exact [`SourceSection`](com/oracle/truffle/api/debug/Breakpoint.md#newBuilder%28com.oracle.truffle.api.source.SourceSection%29). - A new breakpoint cannot affect execution until after it has been [installed](com/oracle/truffle/api/debug/DebuggerSession.md#install%28com.oracle.truffle.api.debug.Breakpoint%29) by a session, which may be done only once. - A breakpoint that is both installed and [enabled](com/oracle/truffle/api/debug/Breakpoint.md#isEnabled%28%29) (true by default) will suspend any guest language execution thread that arrives at a matching AST location. The breakpoint (synchronously) [calls back](com/oracle/truffle/api/debug/SuspendedCallback.md) to the responsible session on the execution thread. - A breakpoint may be enabled or disabled any number of times. - A breakpoint that is no longer needed may be [disposed](com/oracle/truffle/api/debug/Breakpoint.md#dispose%28%29). A disposed breakpoint: - is disabled - is not installed in any session - can have no effect on program execution, and - must not be used again. - A session being [closed](com/oracle/truffle/api/debug/DebuggerSession.md#close%28%29) disposes all installed breakpoints. Example usage: ```java try (DebuggerSession session = Debugger.find(instrumentEnvironment). startSession(suspendedCallback)) { // install breakpoint in someCode at line 3. session.install(Breakpoint.newBuilder(someCode). lineIs(3).build()); // install breakpoint for a URI at line 3 session.install(Breakpoint.newBuilder(someCode.getURI()). lineIs(3).build()); } ``` ## Nested types - [`Breakpoint.Builder`](com/oracle/truffle/api/debug/Breakpoint.Builder.md) (class): Builder implementation for a new breakpoint. - [`Breakpoint.ExceptionBuilder`](com/oracle/truffle/api/debug/Breakpoint.ExceptionBuilder.md) (class): Builder implementation for a new breakpoint of EXCEPTION kind. - [`Breakpoint.Kind`](com/oracle/truffle/api/debug/Breakpoint.Kind.md) (enum class): Specifies a breakpoint kind. - [`Breakpoint.ResolveListener`](com/oracle/truffle/api/debug/Breakpoint.ResolveListener.md) (interface): This listener is called when a breakpoint is resolved at the target location. ## Methods ### getKind() `public Breakpoint.Kind getKind()`. Since 19.0. Returns the kind of this breakpoint. Cite: `com/oracle/truffle/api/debug/Breakpoint.html#getKind()` ### isDisposed() `public boolean isDisposed()`. Since 0.17. Returns `boolean`: whether this breakpoint is permanently unable to affect execution. See also: `dispose()`. Cite: `com/oracle/truffle/api/debug/Breakpoint.html#isDisposed()` ### isEnabled() `public boolean isEnabled()`. Since 0.9. Returns `boolean`: whether this breakpoint is currently allowed to suspend execution (true by default). See also: `setEnabled(boolean)`. Cite: `com/oracle/truffle/api/debug/Breakpoint.html#isEnabled()` ### setEnabled(boolean) `public void setEnabled(boolean enabled)`. Since 0.9. Controls whether this breakpoint is currently allowed to suspend execution (true by default). This can be changed arbitrarily until breakpoint is disposed. When not `modifiable`, [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) is thrown. Parameters: `enabled` `boolean`: whether this breakpoint should be allowed to suspend execution. Cite: `com/oracle/truffle/api/debug/Breakpoint.html#setEnabled(boolean)` ### isResolved() `public boolean isResolved()`. Since 0.17. Returns `boolean`: whether at least one source has been loaded that contains a match for this breakpoint's location. Cite: `com/oracle/truffle/api/debug/Breakpoint.html#isResolved()` ### setCondition(String) `public void setCondition(String expression)`. Since 0.9. Assigns to this breakpoint a boolean expression whose evaluation will determine whether the breakpoint suspends execution (i.e. "hits"), `null` to remove any condition and always suspend. Breakpoints are by default unconditional. **Evaluation:** expressions are parsed and evaluated in the lexical context of the breakpoint's location. A conditional breakpoint that applies to multiple code locations will be parsed and evaluated separately for each location. **Evaluation failure:** when evaluation of a condition fails for any reason, including the return of a non-boolean value: execution suspends, as if evaluation had returned `true`, and; a message is logged that can be retrieved while execution is suspended. When not `modifiable`, [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) is thrown. Parameters: `expression` `String`: if non`-null`, a boolean expression, expressed in the guest language of the breakpoint's location. See also: `SuspendedEvent.getBreakpointConditionException(Breakpoint)`. Cite: `com/oracle/truffle/api/debug/Breakpoint.html#setCondition(java.lang.String)` ### getCondition() `public String getCondition()`. Since 0.20. Returns the expression used to create the current breakpoint condition, null if no condition set. Cite: `com/oracle/truffle/api/debug/Breakpoint.html#getCondition()` ### dispose() `public void dispose()`. Since 0.9. Permanently prevents this breakpoint from affecting execution. When not `modifiable`, [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) is thrown. Cite: `com/oracle/truffle/api/debug/Breakpoint.html#dispose()` ### isOneShot() `public boolean isOneShot()`. Since 0.9. Returns `boolean`: whether this breakpoint disables itself after suspending execution, i.e. on first hit. Cite: `com/oracle/truffle/api/debug/Breakpoint.html#isOneShot()` ### getIgnoreCount() `public int getIgnoreCount()`. Since 0.9. Returns `int`: the number of times breakpoint will be executed but not hit (i.e. suspend execution). See also: `setIgnoreCount(int)`. Cite: `com/oracle/truffle/api/debug/Breakpoint.html#getIgnoreCount()` ### setIgnoreCount(int) `public void setIgnoreCount(int ignoreCount)`. Since 0.9. Changes the number of times the breakpoint must be executed before it hits (i.e. suspends execution). When a breakpoint condition evaluates to `false`: execution is *not* suspended; it does not count as a hit; the remaining `ignoreCount` does not change. When not `modifiable`, [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) is thrown. Parameters: `ignoreCount` `int`: number of breakpoint activations to ignore before it hits. Cite: `com/oracle/truffle/api/debug/Breakpoint.html#setIgnoreCount(int)` ### getHitCount() `public int getHitCount()`. Since 0.9. Returns `int`: the number of times this breakpoint has suspended execution. Cite: `com/oracle/truffle/api/debug/Breakpoint.html#getHitCount()` ### getLocationDescription() `public String getLocationDescription()`. Since 0.9. Returns `String`: a description of this breakpoint's specified location. Cite: `com/oracle/truffle/api/debug/Breakpoint.html#getLocationDescription()` ### getSuspendAnchor() `public SuspendAnchor getSuspendAnchor()`. Since 0.32. Returns the suspended position within the guest language source location. Cite: `com/oracle/truffle/api/debug/Breakpoint.html#getSuspendAnchor()` ### isModifiable() `public boolean isModifiable()`. Since 0.27. Test whether this breakpoint can be modified. When `false`, methods that change breakpoint state throw [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html). Unmodifiable breakpoints are created from installed breakpoints as read-only copies to be available to clients other than the one who installed the original breakpoint. `Debugger.getBreakpoints()` returns unmodifiable breakpoints, for instance. Returns `boolean`: whether this breakpoint can be modified. Cite: `com/oracle/truffle/api/debug/Breakpoint.html#isModifiable()` ### toString() `public String toString()`. Since 0.9. Overrides `toString()`. Cite: `com/oracle/truffle/api/debug/Breakpoint.html#toString()` ### newBuilder(URI) `public static Breakpoint.Builder newBuilder(URI sourceUri)`. Since 0.17. Creates a new breakpoint builder based on a URI location. Parameters: `sourceUri` `URI`: a URI to specify breakpoint location. Cite: `com/oracle/truffle/api/debug/Breakpoint.html#newBuilder(java.net.URI)` ### newBuilder(Source) `public static Breakpoint.Builder newBuilder(Source source)`. Since 0.17. Creates a new breakpoint builder based on a `Source`. Parameters: `source` `Source`: a `Source` to specify breakpoint location. Cite: `com/oracle/truffle/api/debug/Breakpoint.html#newBuilder(com.oracle.truffle.api.source.Source)` ### newBuilder(SourceSection) `public static Breakpoint.Builder newBuilder(SourceSection sourceSection)`. Since 0.17. Creates a new breakpoint builder based on the textual region of a guest language source element. Parameters: `sourceSection` `SourceSection`: a specification for guest language source element. Cite: `com/oracle/truffle/api/debug/Breakpoint.html#newBuilder(com.oracle.truffle.api.source.SourceSection)` ### newExceptionBuilder(boolean, boolean) `public static Breakpoint.ExceptionBuilder newExceptionBuilder(boolean caught, boolean uncaught)`. Since 19.0. Creates a new exception breakpoint builder. The exception breakpoint can be set to intercept caught or uncaught exceptions, or both. At least one argument needs to be true. The builder creates `breakpoint` of `EXCEPTION` kind. Parameters: `caught` `boolean`: `true` to intercept exceptions that are caught by guest language code. `uncaught` `boolean`: `true` to intercept exceptions that are not caught by guest language code. Cite: `com/oracle/truffle/api/debug/Breakpoint.html#newExceptionBuilder(boolean,boolean)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ Breakpoint.Builder [truffle-api](index.md) › [com.oracle.truffle.api.debug](com/oracle/truffle/api/debug/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.debug`](com/oracle/truffle/api/debug/index.md). Since 0.17. Nested in [`Breakpoint`](com/oracle/truffle/api/debug/Breakpoint.md). ```java public final class Breakpoint.Builder ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Builder` Builder implementation for a new [`breakpoint`](com/oracle/truffle/api/debug/Breakpoint.md). **See also** - [`Breakpoint.newBuilder(Source)`](com/oracle/truffle/api/debug/Breakpoint.md#newBuilder%28com.oracle.truffle.api.source.Source%29) - [`Breakpoint.newBuilder(URI)`](com/oracle/truffle/api/debug/Breakpoint.md#newBuilder%28java.net.URI%29) - [`Breakpoint.newBuilder(SourceSection)`](com/oracle/truffle/api/debug/Breakpoint.md#newBuilder%28com.oracle.truffle.api.source.SourceSection%29) ## Methods ### lineIs(int) `public Breakpoint.Builder lineIs(int line)`. Since 0.17. Specifies the breakpoint's line number. Can only be invoked once per builder. Cannot be used together with `Breakpoint.newBuilder(SourceSection)`. Parameters: `line` `int`: 1-based line number. Throws: `IllegalStateException` (unchecked): if `line < 1`. Cite: `com/oracle/truffle/api/debug/Breakpoint.Builder.html#lineIs(int)` ### suspendAnchor(SuspendAnchor) `public Breakpoint.Builder suspendAnchor(SuspendAnchor anchor)`. Since 0.32. Specify the breakpoint suspension anchor within the guest language source location. By default, the breakpoint suspends `before` the source location. Parameters: `anchor` `SuspendAnchor`: the breakpoint suspension anchor. Cite: `com/oracle/truffle/api/debug/Breakpoint.Builder.html#suspendAnchor(com.oracle.truffle.api.debug.SuspendAnchor)` ### columnIs(int) `public Breakpoint.Builder columnIs(int column)`. Since 0.33. Specifies the breakpoint's column number. Can only be invoked once per builder. Cannot be used together with `Breakpoint.newBuilder(SourceSection)`. A line needs to be specified before a column can be set. Parameters: `column` `int`: 1-based column number. Throws: `IllegalStateException` (unchecked): if `column < 1`. Cite: `com/oracle/truffle/api/debug/Breakpoint.Builder.html#columnIs(int)` ### resolveListener(Breakpoint.ResolveListener) `public Breakpoint.Builder resolveListener(Breakpoint.ResolveListener resolveListener)`. Since 0.33. Set a resolve listener. The listener is called when the breakpoint is resolved at the target location. A breakpoint is not resolved till the target source section is loaded. The target resolved location may differ from the specified `line` and `column`. Cite: `com/oracle/truffle/api/debug/Breakpoint.Builder.html#resolveListener(com.oracle.truffle.api.debug.Breakpoint.ResolveListener)` ### ignoreCount(int) `public Breakpoint.Builder ignoreCount(int ignoreCount)`. Since 0.17. Specifies the number of times a breakpoint is ignored until it hits (i.e. suspends execution}. See also: `Breakpoint.setIgnoreCount(int)`. Cite: `com/oracle/truffle/api/debug/Breakpoint.Builder.html#ignoreCount(int)` ### oneShot() `public Breakpoint.Builder oneShot()`. Since 0.17. Specifies that the breakpoint will disable itself after suspending execution, i.e. on first hit. Disabled one-shot breakpoints can be re-enabled. Cite: `com/oracle/truffle/api/debug/Breakpoint.Builder.html#oneShot()` ### sourceElements(SourceElement...) `public Breakpoint.Builder sourceElements(SourceElement... sourceElements)`. Since 0.33. Specifies which source elements will this breakpoint adhere to. When not specified, breakpoint adhere to `SourceElement.STATEMENT` elements. Can only be invoked once per builder. Parameters: `sourceElements` `SourceElement...`: a non-empty list of source elements. Cite: `com/oracle/truffle/api/debug/Breakpoint.Builder.html#sourceElements(com.oracle.truffle.api.debug.SourceElement...)` ### rootInstance(DebugValue) `public Breakpoint.Builder rootInstance(DebugValue rootInstance)`. Since 19.3.0. Specifies the breakpoint's root instance. The breakpoint will be hit only when the `DebugScope.getRootInstance()` matches to the provided one. Parameters: `rootInstance` `DebugValue`: value of the root instance in which the breakpoint is to be hit. Cite: `com/oracle/truffle/api/debug/Breakpoint.Builder.html#rootInstance(com.oracle.truffle.api.debug.DebugValue)` ### build() `public Breakpoint build()`. Since 0.17. Returns `Breakpoint`: a new breakpoint instance of `SOURCE_LOCATION` kind. Cite: `com/oracle/truffle/api/debug/Breakpoint.Builder.html#build()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ Breakpoint.ExceptionBuilder [truffle-api](index.md) › [com.oracle.truffle.api.debug](com/oracle/truffle/api/debug/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.debug`](com/oracle/truffle/api/debug/index.md). Since 19.0. Nested in [`Breakpoint`](com/oracle/truffle/api/debug/Breakpoint.md). ```java public final class Breakpoint.ExceptionBuilder ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `ExceptionBuilder` Builder implementation for a new [`breakpoint`](com/oracle/truffle/api/debug/Breakpoint.md) of [`EXCEPTION`](com/oracle/truffle/api/debug/Breakpoint.Kind.md#EXCEPTION) kind. **See also** - [`Breakpoint.newExceptionBuilder(boolean, boolean)`](com/oracle/truffle/api/debug/Breakpoint.md#newExceptionBuilder%28boolean,boolean%29) ## Methods ### suspensionFilter(SuspensionFilter) `public Breakpoint.ExceptionBuilder suspensionFilter(SuspensionFilter filter)`. Since 19.0. A filter to limit source locations which intercept exceptions. Only the source locations matching the filter will report thrown exceptions. Cite: `com/oracle/truffle/api/debug/Breakpoint.ExceptionBuilder.html#suspensionFilter(com.oracle.truffle.api.debug.SuspensionFilter)` ### sourceElements(SourceElement...) `public Breakpoint.ExceptionBuilder sourceElements(SourceElement... sourceElements)`. Since 19.0. Specifies which source elements will this breakpoint adhere to. When not specified, breakpoint adhere to `SourceElement.STATEMENT` elements. Can only be invoked once per builder. Parameters: `sourceElements` `SourceElement...`: a non-empty list of source elements. Cite: `com/oracle/truffle/api/debug/Breakpoint.ExceptionBuilder.html#sourceElements(com.oracle.truffle.api.debug.SourceElement...)` ### build() `public Breakpoint build()`. Since 19.0. Returns `Breakpoint`: a new breakpoint instance of `EXCEPTION` kind. Cite: `com/oracle/truffle/api/debug/Breakpoint.ExceptionBuilder.html#build()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ≡ Breakpoint.Kind [truffle-api](index.md) › [com.oracle.truffle.api.debug](com/oracle/truffle/api/debug/index.md) · Every page: [llms.txt](llms.txt) Enum class in [`com.oracle.truffle.api.debug`](com/oracle/truffle/api/debug/index.md). Since 19.0. Nested in [`Breakpoint`](com/oracle/truffle/api/debug/Breakpoint.md). ```java public enum Breakpoint.Kind ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html) > `Kind` Specifies a breakpoint kind. Breakpoints with different kinds have different creation methods and address different debugging needs. ## Enum constants ### HALT_INSTRUCTION `HALT_INSTRUCTION`. Since 19.0. Represents breakpoints submitted for a halt instruction in a guest language program. For instance, in JavaScript this is `debugger` statement. Guest languages mark such nodes with `DebuggerTags.AlwaysHalt`. A breakpoint of this kind is created by `DebuggerSession` automatically. Cite: `com/oracle/truffle/api/debug/Breakpoint.Kind.html#HALT_INSTRUCTION` ### SOURCE_LOCATION `SOURCE_LOCATION`. Since 19.0. Represents breakpoints submitted for a particular source code location. Use one of the `newBuilder` methods to create a breakpoint of this kind. Cite: `com/oracle/truffle/api/debug/Breakpoint.Kind.html#SOURCE_LOCATION` ### EXCEPTION `EXCEPTION`. Since 19.0. Represents exception breakpoints that are hit when an exception is thrown from a guest language program. Use `newExceptionBuilder(boolean, boolean)` to create a breakpoint of this kind. Cite: `com/oracle/truffle/api/debug/Breakpoint.Kind.html#EXCEPTION` ## Methods ### values() `public static Breakpoint.Kind[] values()`. Returns the enum constants in declaration order. Returns `Breakpoint.Kind[]`: Returns the enum constants in declaration order. Cite: `com/oracle/truffle/api/debug/Breakpoint.Kind.html#values()` ### valueOf(String) `public static Breakpoint.Kind valueOf(String name)`. Returns the enum constant with the given name. Parameters: `name` `String`: The exact name of the enum constant. Returns `Breakpoint.Kind`: Returns the enum constant with the given name. Cite: `com/oracle/truffle/api/debug/Breakpoint.Kind.html#valueOf(java.lang.String)` ## Inherited members - From class [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#clone%28%29), [`compareTo`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#compareTo%28E%29), [`describeConstable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#describeConstable%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#finalize%28%29), [`getDeclaringClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#getDeclaringClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#hashCode%28%29), [`name`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#name%28%29), [`ordinal`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#ordinal%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#toString%28%29), [`valueOf`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#valueOf%28java.lang.Class,java.lang.String%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ Breakpoint.ResolveListener [truffle-api](index.md) › [com.oracle.truffle.api.debug](com/oracle/truffle/api/debug/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.debug`](com/oracle/truffle/api/debug/index.md). Since 0.33. Nested in [`Breakpoint`](com/oracle/truffle/api/debug/Breakpoint.md). ```java public interface Breakpoint.ResolveListener ``` This listener is called when a breakpoint is resolved at the target location. The breakpoint is not resolved till the target source section is loaded. The target resolved location may differ from the specified breakpoint location. ## Methods ### breakpointResolved(Breakpoint, SourceSection) `void breakpointResolved(Breakpoint breakpoint, SourceSection section)`. Since 0.33. Notify about a breakpoint resolved at the specified location. Parameters: `breakpoint` `Breakpoint`: The resolved breakpoint. `section` `SourceSection`: The resolved location. Cite: `com/oracle/truffle/api/debug/Breakpoint.ResolveListener.html#breakpointResolved(com.oracle.truffle.api.debug.Breakpoint,com.oracle.truffle.api.source.SourceSection)` # ◆ DebugContext [truffle-api](index.md) › [com.oracle.truffle.api.debug](com/oracle/truffle/api/debug/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.debug`](com/oracle/truffle/api/debug/index.md). Since 0.30. ```java public final class DebugContext ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `DebugContext` Representation of a polyglot context in a guest language execution. ## Methods ### evaluate(String, String) `public DebugValue evaluate(String code, String languageId)`. Since 0.30. Evaluate the given code in this context. Parameters: `code` `String`: the code to evaluate. `languageId` `String`: the language to evaluate the code in. Returns `DebugValue`: result of the evaluation. Cite: `com/oracle/truffle/api/debug/DebugContext.html#evaluate(java.lang.String,java.lang.String)` ### runInContext(Supplier) `public T runInContext(Supplier run)`. Since 0.30. Run supplied operations in this context. Use it to call methods on `DebugValue` that was obtained from `evaluate(java.lang.String, java.lang.String)`. Type parameters: ``: a type of the return value of the supplier. Parameters: `run` `Supplier`: a supplier representing operations to be run in this context. Returns `T`: the supplier's return value. Cite: `com/oracle/truffle/api/debug/DebugContext.html#runInContext(java.util.function.Supplier)` ### getParent() `public DebugContext getParent()`. Since 0.30. Get a parent context of this context, if any. This provides the hierarchy of inner contexts. Returns `DebugContext`: a parent context, or `null` if there is no parent. Cite: `com/oracle/truffle/api/debug/DebugContext.html#getParent()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ DebugContextsListener [truffle-api](index.md) › [com.oracle.truffle.api.debug](com/oracle/truffle/api/debug/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.debug`](com/oracle/truffle/api/debug/index.md). Since 0.30. ```java public interface DebugContextsListener ``` Listener to be notified about changes of contexts in guest language application. Use [`DebuggerSession.setContextsListener(com.oracle.truffle.api.debug.DebugContextsListener, boolean)`](com/oracle/truffle/api/debug/DebuggerSession.md#setContextsListener%28com.oracle.truffle.api.debug.DebugContextsListener,boolean%29) to register an implementation of this listener. The listener gets called when a new [`context`](com/oracle/truffle/api/debug/DebugContext.md) is created or disposed and when individual languages are initialized or disposed in that context. **See also** - [`DebuggerSession.setContextsListener(com.oracle.truffle.api.debug.DebugContextsListener, boolean)`](com/oracle/truffle/api/debug/DebuggerSession.md#setContextsListener%28com.oracle.truffle.api.debug.DebugContextsListener,boolean%29) ## Methods ### contextCreated(DebugContext) `void contextCreated(DebugContext context)`. Since 0.30. Notifies about creation of a new polyglot context. Cite: `com/oracle/truffle/api/debug/DebugContextsListener.html#contextCreated(com.oracle.truffle.api.debug.DebugContext)` ### languageContextCreated(DebugContext, LanguageInfo) `void languageContextCreated(DebugContext context, LanguageInfo language)`. Since 0.30. Notifies about creation of a language-specific context in an existing polyglot context. Parameters: `context` `DebugContext`: the polyglot context. `language` `LanguageInfo`: the language for which a language-specific context was created. Cite: `com/oracle/truffle/api/debug/DebugContextsListener.html#languageContextCreated(com.oracle.truffle.api.debug.DebugContext,com.oracle.truffle.api.nodes.LanguageInfo)` ### languageContextInitialized(DebugContext, LanguageInfo) `void languageContextInitialized(DebugContext context, LanguageInfo language)`. Since 0.30. Notifies about initialization of a language-specific context in an existing polyglot context. Parameters: `context` `DebugContext`: the polyglot context. `language` `LanguageInfo`: the language for which a language-specific context was initialized. Cite: `com/oracle/truffle/api/debug/DebugContextsListener.html#languageContextInitialized(com.oracle.truffle.api.debug.DebugContext,com.oracle.truffle.api.nodes.LanguageInfo)` ### languageContextFinalized(DebugContext, LanguageInfo) `void languageContextFinalized(DebugContext context, LanguageInfo language)`. Since 0.30. Notifies about finalization of a language-specific context in an existing polyglot context. Parameters: `context` `DebugContext`: the polyglot context. `language` `LanguageInfo`: the language for which a language-specific context was finalized. Cite: `com/oracle/truffle/api/debug/DebugContextsListener.html#languageContextFinalized(com.oracle.truffle.api.debug.DebugContext,com.oracle.truffle.api.nodes.LanguageInfo)` ### languageContextDisposed(DebugContext, LanguageInfo) `void languageContextDisposed(DebugContext context, LanguageInfo language)`. Since 0.30. Notifies about disposal of a language-specific context in an existing polyglot context. Parameters: `context` `DebugContext`: the polyglot context. `language` `LanguageInfo`: the language for which a language-specific context was disposed. Cite: `com/oracle/truffle/api/debug/DebugContextsListener.html#languageContextDisposed(com.oracle.truffle.api.debug.DebugContext,com.oracle.truffle.api.nodes.LanguageInfo)` ### contextClosed(DebugContext) `void contextClosed(DebugContext context)`. Since 0.30. Notifies about close of a polyglot context. Cite: `com/oracle/truffle/api/debug/DebugContextsListener.html#contextClosed(com.oracle.truffle.api.debug.DebugContext)` # ⚡︎ DebugException [truffle-api](index.md) › [com.oracle.truffle.api.debug](com/oracle/truffle/api/debug/index.md) · Every page: [llms.txt](llms.txt) Exception in [`com.oracle.truffle.api.debug`](com/oracle/truffle/api/debug/index.md). Since 19.0. ```java public final class DebugException extends RuntimeException ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) > [`Exception`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Exception.html) > [`RuntimeException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/RuntimeException.html) > `DebugException` Information about an exception thrown from a guest language. This exception does not contain a Java stack trace, use [`getDebugStackTrace()`](com/oracle/truffle/api/debug/DebugException.md#getDebugStackTrace%28%29) to find out the guest language stack trace. Debugger methods that run guest language code may throw this exception. ## Nested types - [`DebugException.CatchLocation`](com/oracle/truffle/api/debug/DebugException.CatchLocation.md) (class): Represents an exception catch location. ## Methods ### fillInStackTrace() `public Throwable fillInStackTrace()`. Since 19.0. Unsupported, `DebugException` instances are not writable therefore filling the stack trace has no effect for them. Overrides `fillInStackTrace()`. Cite: `com/oracle/truffle/api/debug/DebugException.html#fillInStackTrace()` ### setStackTrace(StackTraceElement[]) `public void setStackTrace(StackTraceElement[] stackTrace)`. Since 19.0. Unsupported, `DebugException` instances are not writable therefore setting the stack trace has no effect for them. Overrides `setStackTrace(java.lang.StackTraceElement[])`. Cite: `com/oracle/truffle/api/debug/DebugException.html#setStackTrace(java.lang.StackTraceElement[])` ### getStackTrace() `public StackTraceElement[] getStackTrace()`. Since 19.0. Gets stack trace elements of guest languages. It is recommended to use `getDebugStackTrace()` as the guest language stack elements do not always fit the Java format for stack trace elements. Overrides `getStackTrace()`. Cite: `com/oracle/truffle/api/debug/DebugException.html#getStackTrace()` ### getDebugStackTrace() `public List getDebugStackTrace()`. Since 19.0. Gets stack trace elements of guest languages. Cite: `com/oracle/truffle/api/debug/DebugException.html#getDebugStackTrace()` ### getDebugAsynchronousStacks() `public List> getDebugAsynchronousStacks()`. Since 20.1.0. Get a list of asynchronous stack traces that led to scheduling of the exception's execution. Returns an empty list if no asynchronous stack is known. The first asynchronous stack is at the first index in the list. A possible next asynchronous stack (that scheduled execution of the previous one) is at the next index in the list. Languages might not provide asynchronous stack traces by default for performance reasons. Call `DebuggerSession.setAsynchronousStackDepth(int)` to request asynchronous stacks. Languages may provide asynchronous stacks if it's of no performance penalty, or if requested by other options. See also: `DebuggerSession.setAsynchronousStackDepth(int)`. Cite: `com/oracle/truffle/api/debug/DebugException.html#getDebugAsynchronousStacks()` ### printStackTrace() `public void printStackTrace()`. Since 19.0. Overrides `printStackTrace()`. Cite: `com/oracle/truffle/api/debug/DebugException.html#printStackTrace()` ### printStackTrace(PrintStream) `public void printStackTrace(PrintStream s)`. Since 19.0. Overrides `printStackTrace(java.io.PrintStream)`. Cite: `com/oracle/truffle/api/debug/DebugException.html#printStackTrace(java.io.PrintStream)` ### printStackTrace(PrintWriter) `public void printStackTrace(PrintWriter s)`. Since 19.0. Overrides `printStackTrace(java.io.PrintWriter)`. Cite: `com/oracle/truffle/api/debug/DebugException.html#printStackTrace(java.io.PrintWriter)` ### isInternalError() `public boolean isInternalError()`. Since 19.0. Returns `true` if this exception indicates an internal error. Cite: `com/oracle/truffle/api/debug/DebugException.html#isInternalError()` ### getExceptionObject() `public DebugValue getExceptionObject()`. Since 19.0. Get a guest language object representing the exception, if any. Returns `DebugValue`: an exception object, or `null`. Cite: `com/oracle/truffle/api/debug/DebugException.html#getExceptionObject()` ### getThrowLocation() `public SourceSection getThrowLocation()`. Since 19.0. Get source code location where this exception was thrown from. Returns `SourceSection`: the thrown location, or `null` when the thrown location is not known. Cite: `com/oracle/truffle/api/debug/DebugException.html#getThrowLocation()` ### getCatchLocation() `public DebugException.CatchLocation getCatchLocation()`. Since 19.0. Get source code location where this exception is to be caught. In case this exception is going to be caught by guest language code, the catch location is provided. `null` is returned for uncaught exceptions. Returns `DebugException.CatchLocation`: the catch location, or `null` in case of uncaught exceptions. Cite: `com/oracle/truffle/api/debug/DebugException.html#getCatchLocation()` ### getRawException(Class) `public Throwable getRawException(Class> languageClass)`. Since 20.1. Returns the guest language representation of the exception, or `null` if the requesting language class does not match the root node language at the throw location. This method is permitted only if the guest language class is available. This is the case if you want to utilize the Debugger API directly from within a guest language, or if you are an instrument bound/dependent on a specific language. Parameters: `languageClass` `Class>`: the Truffle language class for a given guest language. Returns `Throwable`: the throwable guest language exception object. Cite: `com/oracle/truffle/api/debug/DebugException.html#getRawException(java.lang.Class)` ## Inherited members - From class [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html): [`addSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#addSuppressed%28java.lang.Throwable%29), [`getCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getCause%28%29), [`getLocalizedMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getLocalizedMessage%28%29), [`getMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getMessage%28%29), [`getSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getSuppressed%28%29), [`initCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#initCause%28java.lang.Throwable%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DebugException.CatchLocation [truffle-api](index.md) › [com.oracle.truffle.api.debug](com/oracle/truffle/api/debug/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.debug`](com/oracle/truffle/api/debug/index.md). Since 19.0. Nested in [`DebugException`](com/oracle/truffle/api/debug/DebugException.md). ```java public static final class DebugException.CatchLocation ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `CatchLocation` Represents an exception catch location. It provides a stack frame and a source section where the exception is going to be caught. ## Methods ### getSourceSection() `public SourceSection getSourceSection()`. Since 19.0. Returns `SourceSection`: a source section, or `null` if the catch source section is not known. Cite: `com/oracle/truffle/api/debug/DebugException.CatchLocation.html#getSourceSection()` ### getFrame() `public DebugStackFrame getFrame()`. Since 19.0. Returns `DebugStackFrame`: a frame in which the exception is going to be caught. Cite: `com/oracle/truffle/api/debug/DebugException.CatchLocation.html#getFrame()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DebugScope [truffle-api](index.md) › [com.oracle.truffle.api.debug](com/oracle/truffle/api/debug/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.debug`](com/oracle/truffle/api/debug/index.md). Since 0.26. ```java public final class DebugScope ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `DebugScope` Representation of guest language scope at the current suspension point, or a top scope. It contains a set of declared and valid variables, if any. The scope associated with a [`frame`](com/oracle/truffle/api/debug/DebugStackFrame.md) is only valid as long as the associated [`frame`](com/oracle/truffle/api/debug/DebugStackFrame.md) is valid and methods on such scope need to be called on the frame's thread. **See also** - [`DebugStackFrame.getScope()`](com/oracle/truffle/api/debug/DebugStackFrame.md#getScope%28%29) - [`DebuggerSession.getTopScope(String)`](com/oracle/truffle/api/debug/DebuggerSession.md#getTopScope%28java.lang.String%29) ## Methods ### getName() `public String getName()`. Since 0.26. Get a human readable name of this scope. Cite: `com/oracle/truffle/api/debug/DebugScope.html#getName()` ### getParent() `public DebugScope getParent() throws DebugException`. Since 0.26. Get a parent scope. Returns `DebugScope`: the parent scope, or `null`. Throws: `DebugException`: when guest language code throws an exception. Cite: `com/oracle/truffle/api/debug/DebugScope.html#getParent()` ### isFunctionScope() `public boolean isFunctionScope()`. Since 0.26. Test if this scope represents the function scope at the frame it was `obtained from`. Cite: `com/oracle/truffle/api/debug/DebugScope.html#isFunctionScope()` ### getSourceSection() `public SourceSection getSourceSection() throws DebugException`. Since 0.29. Get a source section representing this scope. Please note that while this scope does not provide variables that are valid only after the suspension point, the source section can actually span after the suspension point. Returns `SourceSection`: the source section, or `null` when not available. Throws: `DebugException`: when guest language code throws an exception. Cite: `com/oracle/truffle/api/debug/DebugScope.html#getSourceSection()` ### getReceiver() `public DebugValue getReceiver()`. Since 19.0. Get value that represents the receiver object of this scope. The receiver object is represented as `this` in Java or JavaScript and `self` in Ruby, for instance. The returned value has a name that represents the receiver in the guest language. The scope that `represents the function` provide receiver object, if there is one, other scopes do not provide it, unless they override it. Returns `DebugValue`: value that represents the receiver, or `null` when there is no receiver object. Cite: `com/oracle/truffle/api/debug/DebugScope.html#getReceiver()` ### getRootInstance() `public DebugValue getRootInstance()`. Since 19.3.0. Get value that represents root instance of this scope. The value is an instance of guest language representation of the root node of this scope, e.g. a guest language function. Returns `DebugValue`: the root instance value, or `null` when no such value exists. Cite: `com/oracle/truffle/api/debug/DebugScope.html#getRootInstance()` ### getDeclaredValues() `public Iterable getDeclaredValues() throws DebugException`. Since 0.26. Get local variables declared in this scope, valid at the current suspension point. Call this method on `parent`, to get values of variables declared in parent scope, if any. The declared values do not contain a `receiver`. This method is not thread-safe and will throw an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) if called on another thread than it was created with. Throws: `DebugException`: when guest language code throws an exception. Cite: `com/oracle/truffle/api/debug/DebugScope.html#getDeclaredValues()` ### getDeclaredValue(String) `public DebugValue getDeclaredValue(String name) throws DebugException`. Since 0.26. Get a local variable declared in this scope by name. Call this method on `parent`, to get value of a variable declared in parent scope, if any. This method is not thread-safe and will throw an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) if called on another thread than it was created with. Returns `DebugValue`: a value of requested name, or `null` when no such value was found. Throws: `DebugException`: when guest language code throws an exception. Cite: `com/oracle/truffle/api/debug/DebugScope.html#getDeclaredValue(java.lang.String)` ### convertRawValue(Class, Object) `public DebugValue convertRawValue(Class> languageClass, Object rawValue)`. Since 21.1. Converts the value to a DebugValue, or returns `null` if the requesting language class does not match the root node guest language. This method is permitted only if the guest language class is available. This is the case if you want to utilize the Debugger API directly from within a guest language, or if you are an instrument bound/dependent on a specific language. This method is opposite to `DebugValue.getRawValue(Class)` where the raw guest language value is obtained from the DebugValue. Note that the `rawValue` must be a valid Interop value. If not, the method throws IllegalArgumentException. Parameters: `languageClass` `Class>`: the Truffle language class for a given guest language. `rawValue` `Object`: the raw value. Returns `DebugValue`: the wrapped DebugValue. Throws: `IllegalArgumentException` (unchecked): when `rawValue` is not an Interop value. Cite: `com/oracle/truffle/api/debug/DebugScope.html#convertRawValue(java.lang.Class,java.lang.Object)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DebugStackFrame [truffle-api](index.md) › [com.oracle.truffle.api.debug](com/oracle/truffle/api/debug/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.debug`](com/oracle/truffle/api/debug/index.md). Since 0.17. ```java public final class DebugStackFrame ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `DebugStackFrame` Represents a frame in the guest language stack. A guest language stack frame consists of a [`name`](com/oracle/truffle/api/debug/DebugStackFrame.md#getName%28%29), the current [`source location`](com/oracle/truffle/api/debug/DebugStackFrame.md#getSourceSection%28%29) and [`scopes`](com/oracle/truffle/api/debug/DebugStackFrame.md#getScope%28%29) containing local variables and arguments. Furthermore it allows to [`evaluate`](com/oracle/truffle/api/debug/DebugStackFrame.md#eval%28java.lang.String%29) guest language expressions in the lexical context of a particular frame. Debug stack frames are only valid as long as [`suspended events`](com/oracle/truffle/api/debug/SuspendedEvent.md) are valid. Suspended events are valid as long while the originating [`SuspendedCallback`](com/oracle/truffle/api/debug/SuspendedCallback.md) is still executing. All methods of the frame throw [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) if they become invalid. Depending on the method, clients may access the stack frame only on the execution thread where the suspended event of the stack frame was created and the notification was received. For some methods, access from other threads may throw [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html). Please see the javadoc of the individual method for details. **See also** - [`SuspendedEvent.getStackFrames()`](com/oracle/truffle/api/debug/SuspendedEvent.md#getStackFrames%28%29) - [`SuspendedEvent.getTopStackFrame()`](com/oracle/truffle/api/debug/SuspendedEvent.md#getTopStackFrame%28%29) ## Methods ### isInternal() `public boolean isInternal()`. Since 0.17. Returns whether this stack frame is a language implementation artifact that should be hidden during normal guest language debugging, for example in stack traces. Language implementations sometimes create method calls internally that do not correspond to anything explicitly written by a programmer, for example when the body of a looping construct is implemented as callable block. Language implementors mark these methods as *internal*. Clients of the debugging API should assume that displaying *internal* frames is unlikely to help programmers debug guest language programs and might possibly create confusion. However, clients may choose to display all frames, for example in a special mode to support development of programming language implementations. The decision to mark a method as *internal* is language-specific, reflects judgments about tool usability, and is subject to change. This method is thread-safe. Cite: `com/oracle/truffle/api/debug/DebugStackFrame.html#isInternal()` ### isHost() `public boolean isHost()`. Since 20.3. Returns `true` if this frame is a host frame. Host frames provide `stack trace element`, have no `scope`, no `source section` and can not `evaluate` code. Host frames are provided only when `host info` is set to `true`. See also: `DebuggerSession.setShowHostStackFrames(boolean)`. Cite: `com/oracle/truffle/api/debug/DebugStackFrame.html#isHost()` ### getHostTraceElement() `public StackTraceElement getHostTraceElement()`. Since 20.3. Provides a host frame. Returns the host stack trace element if and only if this is `host` frame. Returns `StackTraceElement`: the host stack trace element, or `null` when not a host frame. See also: `isHost()`. Cite: `com/oracle/truffle/api/debug/DebugStackFrame.html#getHostTraceElement()` ### getName() `public String getName() throws DebugException`. Since 0.17. A description of the AST (expected to be a method or procedure name in most languages) that identifies the AST for the benefit of guest language programmers using tools; it might appear, for example in the context of a stack dump or trace and is not expected to be called often. If the language does not provide such a description then `null` is returned. This method is thread-safe. Cite: `com/oracle/truffle/api/debug/DebugStackFrame.html#getName()` ### getSourceSection() `public SourceSection getSourceSection()`. Since 0.17. Returns the source section of the location where the debugging session was suspended. The source section is `null` if the source location is not available. This method is thread-safe. Cite: `com/oracle/truffle/api/debug/DebugStackFrame.html#getSourceSection()` ### getLanguage() `public LanguageInfo getLanguage()`. Since 19.0. Returns public information about the language of this frame. Returns `LanguageInfo`: the language info, or `null` when no language is associated with this frame. Cite: `com/oracle/truffle/api/debug/DebugStackFrame.html#getLanguage()` ### getScope() `public DebugScope getScope() throws DebugException`. Since 0.26. Get the current inner-most scope. The scope remain valid as long as the current stack frame remains valid. Use `DebuggerSession.getTopScope(java.lang.String)` to get scopes with global validity. This method is not thread-safe and will throw an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) if called on another thread than it was created with. Returns `DebugScope`: the scope, or `null` when no language is associated with this frame location, or when no local scope exists. Throws: `DebugException`: when guest language code throws an exception. Cite: `com/oracle/truffle/api/debug/DebugStackFrame.html#getScope()` ### getRawNode(Class) `public Node getRawNode(Class> languageClass)`. Since 20.1. Returns the current node for this stack frame, or `null` if the requesting language class does not match the root node guest language. This method is permitted only if the guest language class is available. This is the case if you want to utilize the Debugger API directly from within a guest language, or if you are an instrument bound/dependent on a specific language. Parameters: `languageClass` `Class>`: the Truffle language class for a given guest language. Returns `Node`: the node associated with the frame. Cite: `com/oracle/truffle/api/debug/DebugStackFrame.html#getRawNode(java.lang.Class)` ### getRawFrame(Class, FrameInstance.FrameAccess) `public Frame getRawFrame(Class> languageClass, FrameInstance.FrameAccess access)`. Since 20.1. Returns the underlying frame for this debug stack frame or `null` if the requesting language class does not match the root node guest language. This method is permitted only if the guest language class is available. This is the case if you want to utilize the Debugger API directly from within a guest language, or if you are an instrument bound/dependent on a specific language. Parameters: `languageClass` `Class>`: the Truffle language class for a given guest language. `access` `FrameInstance.FrameAccess`: the frame access mode. Returns `Frame`: the frame. Cite: `com/oracle/truffle/api/debug/DebugStackFrame.html#getRawFrame(java.lang.Class,com.oracle.truffle.api.frame.FrameInstance.FrameAccess)` ### eval(String) `public DebugValue eval(String code) throws DebugException`. Since 0.17. Evaluates the given code in the state of the current execution and in the same guest language as the current language is defined in. Returns a heap value that remains valid even if this stack frame becomes invalid. This method is not thread-safe and will throw an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) if called on another thread than it was created with. Parameters: `code` `String`: the code to evaluate. Returns `DebugValue`: the return value of the expression. Throws: `DebugException`: when guest language code throws an exception. `IllegalStateException` (unchecked): if called on another thread than this frame was created with, or if `language` of this frame is not `interactive`. Cite: `com/oracle/truffle/api/debug/DebugStackFrame.html#eval(java.lang.String)` ### equals(Object) `public boolean equals(Object obj)`. Since 19.0. Overrides `equals(java.lang.Object)`. Cite: `com/oracle/truffle/api/debug/DebugStackFrame.html#equals(java.lang.Object)` ### hashCode() `public int hashCode()`. Since 19.0. Overrides `hashCode()`. Cite: `com/oracle/truffle/api/debug/DebugStackFrame.html#hashCode()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DebugStackTraceElement [truffle-api](index.md) › [com.oracle.truffle.api.debug](com/oracle/truffle/api/debug/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.debug`](com/oracle/truffle/api/debug/index.md). Since 19.0. ```java public final class DebugStackTraceElement ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `DebugStackTraceElement` Represents a trace element in the guest language stack trace. A guest language trace element consists of a [`name`](com/oracle/truffle/api/debug/DebugStackTraceElement.md#getName%28%29), the current [`source location`](com/oracle/truffle/api/debug/DebugStackTraceElement.md#getSourceSection%28%29) and [`scopes`](com/oracle/truffle/api/debug/DebugStackTraceElement.md#getScope%28%29) containing local variables and arguments. The difference between this class and [`DebugStackFrame`](com/oracle/truffle/api/debug/DebugStackFrame.md) is the limited life-time of [`DebugStackFrame`](com/oracle/truffle/api/debug/DebugStackFrame.md), that is associated with a [`SuspendedEvent`](com/oracle/truffle/api/debug/SuspendedEvent.md). **See also** - [`DebugException.getDebugStackTrace()`](com/oracle/truffle/api/debug/DebugException.md#getDebugStackTrace%28%29) ## Methods ### isInternal() `public boolean isInternal()`. Since 19.0. Returns whether this trace element is a language implementation artifact. The decision to mark a method as *internal* is language-specific, reflects judgments about tool usability, and is subject to change. Cite: `com/oracle/truffle/api/debug/DebugStackTraceElement.html#isInternal()` ### isHost() `public boolean isHost()`. Since 20.3. Returns `true` if this element is a host element. Host elements provide `stack trace element`, have no `scope`, and no `source section`. Host elements are provided only when `host info` is set to `true`. See also: `DebuggerSession.setShowHostStackFrames(boolean)`. Cite: `com/oracle/truffle/api/debug/DebugStackTraceElement.html#isHost()` ### getHostTraceElement() `public StackTraceElement getHostTraceElement()`. Since 20.3. Provides a host element. Returns the host stack trace element if and only if this is `host` element. Returns `StackTraceElement`: the host stack trace element, or `null` when not a host element. See also: `isHost()`. Cite: `com/oracle/truffle/api/debug/DebugStackTraceElement.html#getHostTraceElement()` ### getName() `public String getName()`. Since 19.0. A description of the trace element. If the language does not provide such a description then `null` is returned. Cite: `com/oracle/truffle/api/debug/DebugStackTraceElement.html#getName()` ### getSourceSection() `public SourceSection getSourceSection()`. Since 19.0. Returns the source section location of this trace element. The source section is `null` if the source location is not available. Cite: `com/oracle/truffle/api/debug/DebugStackTraceElement.html#getSourceSection()` ### getScope() `public DebugScope getScope()`. Since 19.0. Get the current inner-most scope. The scope might not provide valid information if the execution path diverges from this trace element. Returns `DebugScope`: the scope, or `null` when no language is associated with this frame location, or when no local scope exists. Cite: `com/oracle/truffle/api/debug/DebugStackTraceElement.html#getScope()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ DebugThreadsListener [truffle-api](index.md) › [com.oracle.truffle.api.debug](com/oracle/truffle/api/debug/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.debug`](com/oracle/truffle/api/debug/index.md). Since 0.30. ```java public interface DebugThreadsListener ``` Listener to be notified about changes of threads in guest language application. Use [`DebuggerSession.setThreadsListener(com.oracle.truffle.api.debug.DebugThreadsListener, boolean)`](com/oracle/truffle/api/debug/DebuggerSession.md#setThreadsListener%28com.oracle.truffle.api.debug.DebugThreadsListener,boolean%29) to register an implementation of this listener. The listener gets called when a thread is initialized for use in a [`context`](com/oracle/truffle/api/debug/DebugContext.md) or thread-related resources are disposed in a context. The notification calls do not say anything about the actual life-time of the thread as such, which may live before the initialization and may continue to live after the disposal. **See also** - [`DebuggerSession.setThreadsListener(com.oracle.truffle.api.debug.DebugThreadsListener, boolean)`](com/oracle/truffle/api/debug/DebuggerSession.md#setThreadsListener%28com.oracle.truffle.api.debug.DebugThreadsListener,boolean%29) ## Methods ### threadInitialized(DebugContext, Thread) `void threadInitialized(DebugContext context, Thread thread)`. Since 0.30. Notifies about initialization of a thread to be used for a guest language execution in a `DebugContext`. Parameters: `context` `DebugContext`: the context the thread is initialized in. `thread` `Thread`: the initialized thread. Cite: `com/oracle/truffle/api/debug/DebugThreadsListener.html#threadInitialized(com.oracle.truffle.api.debug.DebugContext,java.lang.Thread)` ### threadDisposed(DebugContext, Thread) `void threadDisposed(DebugContext context, Thread thread)`. Since 0.30. Notifies about disposal of thread-related resources that were used for a guest language execution in a `DebugContext`. Parameters: `context` `DebugContext`: the context the thread is disposed from. `thread` `Thread`: the thread. Cite: `com/oracle/truffle/api/debug/DebugThreadsListener.html#threadDisposed(com.oracle.truffle.api.debug.DebugContext,java.lang.Thread)` # ◆ DebugValue [truffle-api](index.md) › [com.oracle.truffle.api.debug](com/oracle/truffle/api/debug/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.debug`](com/oracle/truffle/api/debug/index.md). Since 0.17. ```java public abstract class DebugValue ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `DebugValue` Represents a value accessed using the debugger API. Please note that values can become invalid depending on the context in which they are used. For example stack values will only remain valid as long as the current stack element is active. Heap values on the other hand remain valid. If a value becomes invalid then setting or getting a value will throw an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) . [`DebugValue`](com/oracle/truffle/api/debug/DebugValue.md) instances neither support equality or preserve identity. Clients may access the debug value only on the execution thread where the suspended event of the stack frame was created and notification received; access from other threads will throw [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html). ## Methods ### set(DebugValue) `public abstract void set(DebugValue value) throws DebugException`. Since 0.17. Sets the value using another `DebugValue`. Throws an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) if the value is not writable, the passed value is not readable, this value or the passed value is invalid, or the guest language of the values do not match. Use `DebugStackFrame.eval(String)` to evaluate values to be set. Parameters: `value` `DebugValue`: the value to set. Throws: `DebugException`: when guest language code throws an exception. Cite: `com/oracle/truffle/api/debug/DebugValue.html#set(com.oracle.truffle.api.debug.DebugValue)` ### getName() `public abstract String getName()`. Since 0.17. Returns the name of this value as it is referred to from its origin. If this value is originated from the stack it returns the name of the local variable. If the value was returned from another objects then it returns the name of the property or field it is contained in. If no name is available `null` is returned. Cite: `com/oracle/truffle/api/debug/DebugValue.html#getName()` ### isReadable() `public abstract boolean isReadable()`. Since 0.17. Returns `true` if this value can be read else `false`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#isReadable()` ### hasReadSideEffects() `public abstract boolean hasReadSideEffects()`. Since 19.0. Returns `true` if reading of this value can have side-effects, else `false`. Read has side-effects if it changes runtime state. Cite: `com/oracle/truffle/api/debug/DebugValue.html#hasReadSideEffects()` ### hasWriteSideEffects() `public abstract boolean hasWriteSideEffects()`. Since 19.0. Returns `true` if setting a new value can have side-effects, else `false`. Write has side-effects if it changes runtime state besides this value. Cite: `com/oracle/truffle/api/debug/DebugValue.html#hasWriteSideEffects()` ### isWritable() `public abstract boolean isWritable()`. Since 0.26. Returns `true` if this value can be written to, else `false`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#isWritable()` ### isInternal() `public abstract boolean isInternal()`. Since 0.26. Returns `true` if this value represents an internal variable or property, `false` otherwise. Languages might have extra object properties or extra scope variables that are a part of the runtime, but do not correspond to anything what is an explicit part of the guest language representation. They may represent additional language artifacts, providing more in-depth information that can be valuable during debugging. Language implementors mark these variables as *internal*. An example of such internal values are internal slots in ECMAScript. Cite: `com/oracle/truffle/api/debug/DebugValue.html#isInternal()` ### getScope() `public DebugScope getScope()`. Since 0.26. Get the scope where this value is declared in. It returns a non-null value for local variables declared on a stack. It's `null` for object properties and other heap values. Returns `DebugScope`: the scope, or `null` when this value does not belong into any scope. Cite: `com/oracle/truffle/api/debug/DebugValue.html#getScope()` ### isNull() `public final boolean isNull()`. Since 19.0. Test if the value represents 'null'. Throws: `DebugException` (unchecked): when guest language code throws an exception. Cite: `com/oracle/truffle/api/debug/DebugValue.html#isNull()` ### isString() `public boolean isString()`. Since 20.1.0. Returns `true` if and only if this value represents a string. Throws: `DebugException` (unchecked): when guest language code throws an exception. Cite: `com/oracle/truffle/api/debug/DebugValue.html#isString()` ### asString() `public final String asString() throws DebugException`. Since 19.0. Returns the [`String`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html) value if this value represents a string. This method returns `null` otherwise. Throws: `DebugException`: when guest language code throws an exception. Cite: `com/oracle/truffle/api/debug/DebugValue.html#asString()` ### fitsInInt() `public boolean fitsInInt()`. Since 20.1.0. Returns `true` if this value represents a `number` and the value fits in `int`, else `false`. Throws: `DebugException` (unchecked): when guest language code throws an exception. See also: `asInt()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#fitsInInt()` ### asInt() `public int asInt()`. Since 20.1.0. Returns an `int` representation of this value if it is `number` and the value `fits`. Throws: `UnsupportedOperationException` (unchecked): if this value could not be converted. `DebugException` (unchecked): when guest language code throws an exception. See also: `fitsInInt()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#asInt()` ### isBoolean() `public boolean isBoolean()`. Since 20.1.0. Returns `true` if and only if this value represents a boolean value. Throws: `DebugException` (unchecked): when guest language code throws an exception. See also: `asBoolean()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#isBoolean()` ### asBoolean() `public boolean asBoolean()`. Since 20.1.0. Returns a `boolean` representation of this value if it is `boolean`. Throws: `UnsupportedOperationException` (unchecked): if this value could not be converted. `DebugException` (unchecked): when guest language code throws an exception. See also: `isBoolean()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#asBoolean()` ### isNumber() `public boolean isNumber()`. Since 20.1.0. Returns `true` if and only if this value represents a number. The number value may be accessed as `byte`, `short`, `int`, `long`, `float` or `double` value. Throws: `DebugException` (unchecked): when guest language code throws an exception. Cite: `com/oracle/truffle/api/debug/DebugValue.html#isNumber()` ### fitsInLong() `public boolean fitsInLong()`. Since 20.1.0. Returns `true` if this value represents a `number` and the value fits in `long`, else `false`. Throws: `DebugException` (unchecked): when guest language code throws an exception. See also: `asLong()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#fitsInLong()` ### asLong() `public long asLong()`. Since 20.1.0. Returns a `long` representation of this value if it is `number` and the value `fits`. Throws: `UnsupportedOperationException` (unchecked): if this value could not be converted. `DebugException` (unchecked): when guest language code throws an exception. See also: `fitsInLong()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#asLong()` ### fitsInBigInteger() `public boolean fitsInBigInteger()`. Since 23.0.0. Returns `true` if this value represents a `number` and the value fits in `BigInteger`, else `false`. Throws: `DebugException` (unchecked): when guest language code throws an exception. See also: `asBigInteger()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#fitsInBigInteger()` ### asBigInteger() `public BigInteger asBigInteger()`. Since 23.0.0. Returns a `BigInteger` representation of this value if it is `number` and the value `fits`. Throws: `UnsupportedOperationException` (unchecked): if this value could not be converted. `DebugException` (unchecked): when guest language code throws an exception. See also: `fitsInBigInteger()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#asBigInteger()` ### fitsInDouble() `public boolean fitsInDouble()`. Since 20.1.0. Returns `true` if this value represents a `number` and the value fits in `double`, else `false`. Throws: `DebugException` (unchecked): when guest language code throws an exception. See also: `asDouble()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#fitsInDouble()` ### asDouble() `public double asDouble()`. Since 20.1.0. Returns a `double` representation of this value if it is `number` and the value `fits`. Throws: `UnsupportedOperationException` (unchecked): if this value could not be converted. `DebugException` (unchecked): when guest language code throws an exception. See also: `fitsInDouble()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#asDouble()` ### fitsInFloat() `public boolean fitsInFloat()`. Since 20.1.0. Returns `true` if this value represents a `number` and the value fits in `float`, else `false`. Throws: `DebugException` (unchecked): when guest language code throws an exception. See also: `asFloat()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#fitsInFloat()` ### asFloat() `public float asFloat()`. Since 20.1.0. Returns a `float` representation of this value if it is `number` and the value `fits`. Throws: `UnsupportedOperationException` (unchecked): if this value could not be converted. `DebugException` (unchecked): when guest language code throws an exception. See also: `fitsInFloat()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#asFloat()` ### fitsInByte() `public boolean fitsInByte()`. Since 20.1.0. Returns `true` if this value represents a `number` and the value fits in `byte`, else `false`. Throws: `DebugException` (unchecked): when guest language code throws an exception. See also: `asByte()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#fitsInByte()` ### asByte() `public byte asByte()`. Since 20.1.0. Returns a `byte` representation of this value if it is `number` and the value `fits`. Throws: `UnsupportedOperationException` (unchecked): if this value could not be converted. `DebugException` (unchecked): when guest language code throws an exception. See also: `fitsInByte()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#asByte()` ### fitsInShort() `public boolean fitsInShort()`. Since 20.1.0. Returns `true` if this value represents a `number` and the value fits in `short`, else `false`. Throws: `DebugException` (unchecked): when guest language code throws an exception. See also: `asShort()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#fitsInShort()` ### asShort() `public short asShort()`. Since 20.1.0. Returns a `short` representation of this value if it is `number` and the value `fits`. Throws: `UnsupportedOperationException` (unchecked): if this value could not be converted. `DebugException` (unchecked): when guest language code throws an exception. See also: `fitsInShort()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#asShort()` ### isDate() `public boolean isDate()`. Since 20.1.0. Returns `true` if this value represents a date, else `false`. If this value is also a `timezone` then the date is aware, otherwise it is naive. Throws: `DebugException` (unchecked): when guest language code throws an exception. See also: `asDate()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#isDate()` ### asDate() `public LocalDate asDate()`. Since 20.1.0. Returns this value as date if it is a `date`. The returned date is either aware if the value has a `timezone` otherwise it is naive. Throws: `UnsupportedOperationException` (unchecked): if this value could not be converted. `DebugException` (unchecked): when guest language code throws an exception. See also: `isDate()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#asDate()` ### isTime() `public boolean isTime()`. Since 20.1.0. Returns `true` if this value represents a time, else `false`. If the value is also a `timezone` then the time is aware, otherwise it is naive. Throws: `DebugException` (unchecked): when guest language code throws an exception. See also: `asTime()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#isTime()` ### asTime() `public LocalTime asTime()`. Since 20.1.0. Returns this value as time if it is a `time`. The returned time is either aware if the value has a `timezone` otherwise it is naive. Throws: `UnsupportedOperationException` (unchecked): if this value could not be converted. `DebugException` (unchecked): when guest language code throws an exception. See also: `isTime()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#asTime()` ### isInstant() `public boolean isInstant()`. Since 20.1.0. Returns `true` if this value represents an instant. See `InteropLibrary.isInstant(Object)` for detailed description. Throws: `DebugException` (unchecked): when guest language code throws an exception. See also: `isDate()`, `isTime()`, `isInstant()`, `asInstant()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#isInstant()` ### asInstant() `public Instant asInstant()`. Since 20.1.0. Returns this value as instant if it is an `instant`. See `InteropLibrary.asInstant(Object)` for detailed description. Throws: `UnsupportedOperationException` (unchecked): if this value could not be converted. `DebugException` (unchecked): when guest language code throws an exception. See also: `isDate()`, `isTime()`, `isTimeZone()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#asInstant()` ### isTimeZone() `public boolean isTimeZone()`. Since 20.1.0. Returns `true` if this object represents a timezone, else `false`. See `InteropLibrary.isTimeZone(Object)` for detailed description. Throws: `UnsupportedOperationException` (unchecked): if this value could not be converted. `DebugException` (unchecked): when guest language code throws an exception. See also: `asTimeZone()`, `asInstant()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#isTimeZone()` ### asTimeZone() `public ZoneId asTimeZone()`. Since 20.1.0. Returns this value as timestamp if it represents a `timezone`. Throws: `UnsupportedOperationException` (unchecked): if this value could not be converted. `DebugException` (unchecked): when guest language code throws an exception. See also: `isTimeZone()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#asTimeZone()` ### isDuration() `public boolean isDuration()`. Since 20.1.0. Returns `true` if this object represents a duration, else `false`. Throws: `UnsupportedOperationException` (unchecked): if this value could not be converted. `DebugException` (unchecked): when guest language code throws an exception. See also: [`Duration`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/time/Duration.html), `asDuration()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#isDuration()` ### asDuration() `public Duration asDuration()`. Since 20.1.0. Returns this value as duration if this object represents a `duration`. Throws: `UnsupportedOperationException` (unchecked): if this value could not be converted. `DebugException` (unchecked): when guest language code throws an exception. See also: `isDuration()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#asDuration()` ### isMetaObject() `public boolean isMetaObject()`. Since 20.1. Returns `true` if the value represents a metaobject. See `InteropLibrary.isMetaObject(Object)` for detailed description. Throws: `DebugException` (unchecked): when guest language code throws an exception. See also: `getMetaQualifiedName()`, `getMetaSimpleName()`, `isMetaInstance(DebugValue)`, `getMetaObject()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#isMetaObject()` ### getMetaQualifiedName() `public String getMetaQualifiedName()`. Since 20.1.0. Returns the qualified name of a metaobject as `String`. See `InteropLibrary.getMetaQualifiedName(Object)` for detailed description. Throws: `UnsupportedOperationException` (unchecked): if and only if `isMetaObject()` returns `false` for the same value. `DebugException` (unchecked): when guest language code throws an exception. See also: `isMetaObject()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#getMetaQualifiedName()` ### getMetaSimpleName() `public String getMetaSimpleName()`. Since 20.1.0. Returns the simple name of a metaobject as `string`. See `InteropLibrary.getMetaSimpleName(Object)` for detailed description. Throws: `UnsupportedOperationException` (unchecked): if and only if `isMetaObject()` returns `false` for the same value. `DebugException` (unchecked): when guest language code throws an exception. See also: `isMetaObject()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#getMetaSimpleName()` ### isMetaInstance(DebugValue) `public boolean isMetaInstance(DebugValue instance)`. Since 20.1.0. Returns `true` if the given instance is an instance of this value, else `false`. See `InteropLibrary.isMetaInstance(Object, Object)` for detailed description. Parameters: `instance` `DebugValue`: the instance value to check. Throws: `UnsupportedOperationException` (unchecked): if and only if `isMetaObject()` returns `false` for the same value. `DebugException` (unchecked): when guest language code throws an exception. See also: `isMetaObject()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#isMetaInstance(com.oracle.truffle.api.debug.DebugValue)` ### getRootInstanceBreakpoints() `public final List getRootInstanceBreakpoints()`. Since 19.3.0. Get a list of breakpoints installed to the value's session and whose `root instance` is this value. Returns `List`: a list of breakpoints with this value as root instance. Cite: `com/oracle/truffle/api/debug/DebugValue.html#getRootInstanceBreakpoints()` ### getStaticScope() `public final DebugValue getStaticScope()`. Since 25.1. Returns a value that provides static members whose value is independent on a specific instance. Returns `null` when no static scope is available. Throws: `DebugException` (unchecked): when guest language code throws an exception. Cite: `com/oracle/truffle/api/debug/DebugValue.html#getStaticScope()` ### getProperties() `public final Collection getProperties() throws DebugException`. Since 0.19. Provides properties representing an internal structure of this value. The returned collection is not thread-safe. If the value is not `readable` then `null` is returned. Returns `Collection`: a collection of property values, or null when the value does not have any concept of properties. Throws: `DebugException`: when guest language code throws an exception. Cite: `com/oracle/truffle/api/debug/DebugValue.html#getProperties()` ### getProperty(String) `public final DebugValue getProperty(String name) throws DebugException`. Since 19.0. Get a property value by its name. Parameters: `name` `String`: name of a property. Returns `DebugValue`: the property value, or `null` if the property does not exist. Throws: `DebugException`: when guest language code throws an exception. Cite: `com/oracle/truffle/api/debug/DebugValue.html#getProperty(java.lang.String)` ### isArray() `public final boolean isArray() throws DebugException`. Since 0.19. Returns `true` if this value represents an array, `false` otherwise. Throws: `DebugException`: when guest language code throws an exception. Cite: `com/oracle/truffle/api/debug/DebugValue.html#isArray()` ### getArray() `public List getArray() throws DebugException`. Since 0.19. Provides array elements when this value represents an array. To test if this value represents an array, check `isArray()`. Returns `List`: a list of array elements, or `null` when the value does not represent an array. Throws: `DebugException`: when guest language code throws an exception. Cite: `com/oracle/truffle/api/debug/DebugValue.html#getArray()` ### getRawValue(Class) `public Object getRawValue(Class> languageClass)`. Since 20.1. Returns the underlying guest value object held by this `DebugValue`. This method is permitted only if the guest language class is available. This is the case if you want to utilize the Debugger API directly from within a guest language, or if you are an instrument bound/dependent on a specific language. This method is opposite to `DebugScope.convertRawValue(Class, Object)` where a raw guest language value is wrapped in a DebugValue. Parameters: `languageClass` `Class>`: the Truffle language class for a given guest language. Returns `Object`: the guest language object or null if the language differs from the language that created the underlying `DebugValue`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#getRawValue(java.lang.Class)` ### toDisplayString() `public final String toDisplayString()`. Since 20.1. Converts the value to a language-specific string representation. Is the same as `toDisplayString(true)`. See also: `toDisplayString(boolean)`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#toDisplayString()` ### toDisplayString(boolean) `public final String toDisplayString(boolean allowSideEffects) throws DebugException`. Since 20.1. Converts the value to a language-specific string representation. Parameters: `allowSideEffects` `boolean`: whether side-effects are allowed in the production of the string. Cite: `com/oracle/truffle/api/debug/DebugValue.html#toDisplayString(boolean)` ### getMetaObject() `public final DebugValue getMetaObject() throws DebugException`. Since 0.22. Get a meta-object of this value, if any. The meta-object represents a description of the value, reveals it's kind and it's features. See `InteropLibrary.getMetaObject(Object)` for detailed description. Returns `DebugValue`: a value representing the meta-object, or `null`. Throws: `DebugException`: when guest language code throws an exception. Cite: `com/oracle/truffle/api/debug/DebugValue.html#getMetaObject()` ### getSourceLocation() `public final SourceSection getSourceLocation() throws DebugException`. Since 0.22. Get a source location where this value is declared, if any. Returns `SourceSection`: a source location of the object, or `null`. Throws: `DebugException`: when guest language code throws an exception. Cite: `com/oracle/truffle/api/debug/DebugValue.html#getSourceLocation()` ### canExecute() `public final boolean canExecute() throws DebugException`. Since 19.0. Returns `true` if this value can be executed (represents a guest language function), else `false`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#canExecute()` ### execute(DebugValue...) `public final DebugValue execute(DebugValue... arguments) throws DebugException`. Since 19.0. Executes the executable represented by this value. Parameters: `arguments` `DebugValue...`: Arguments passed to the executable. Returns `DebugValue`: the result of the execution. Throws: `DebugException`: when guest language code throws an exception. See also: `canExecute()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#execute(com.oracle.truffle.api.debug.DebugValue...)` ### hasIterator() `public boolean hasIterator() throws DebugException`. Since 21.2. Returns `true` if the value provides an iterator. For details see `InteropLibrary.hasIterator(Object)`. Throws: `DebugException`: if guest language code throws an exception. See also: `getIterator()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#hasIterator()` ### getIterator() `public DebugValue getIterator() throws DebugException`. Since 21.3. Returns the iterator value. The return value is always an `iterator`. For details see `InteropLibrary.getIterator(Object)`. Throws: `DebugException`: if `hasIterator()` returns `false` or guest language code throws an exception. See also: `hasIterator()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#getIterator()` ### isIterator() `public boolean isIterator() throws DebugException`. Since 21.2. Returns `true` if this value represents an iterator. For details see `InteropLibrary.isIterator(Object)`. Throws: `DebugException`: if guest language code throws an exception. See also: `hasIterator()`, `getIterator()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#isIterator()` ### hasIteratorNextElement() `public boolean hasIteratorNextElement() throws DebugException`. Since 21.2. Returns `true` if the value `is an iterator` which has more elements, else `false`. For details see `InteropLibrary.hasIteratorNextElement(Object)`. Throws: `DebugException`: if `isIterator()` returns `false` or guest language code throws an exception. See also: `isIterator()`, `getIteratorNextElement()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#hasIteratorNextElement()` ### getIteratorNextElement() `public DebugValue getIteratorNextElement() throws NoSuchElementException, DebugException`. Since 21.2. Returns the next element in the iteration. When the underlying data structure is modified the `getIteratorNextElement()` may throw the [`NoSuchElementException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/NoSuchElementException.html) despite the `hasIteratorNextElement()` returned `true`. Throws: `DebugException`: if `isIterator()` returns `false` or when the underlying iterator element exists but is not readable, or guest language code throws an exception. `NoSuchElementException`: if the iteration has no more elements. See also: `isIterator()`, `hasIteratorNextElement()`, `InteropLibrary.getIteratorNextElement(Object)`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#getIteratorNextElement()` ### hasHashEntries() `public boolean hasHashEntries() throws DebugException`. Since 21.2. Returns `true` if the value may have hash map entries. For details see `InteropLibrary.hasHashEntries(Object)`. Throws: `DebugException`: if guest language code throws an exception. See also: `getHashEntriesIterator()`, `getHashSize()`, `isHashEntryReadable(DebugValue)`, `isHashEntryWritable(DebugValue)`, `isHashEntryInsertable(DebugValue)`, `isHashEntryRemovable(DebugValue)`, `getHashValue(DebugValue)`, `getHashValueOrDefault(DebugValue, DebugValue)`, `putHashEntry(DebugValue, DebugValue)`, `removeHashEntry(DebugValue)`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#hasHashEntries()` ### getHashSize() `public long getHashSize() throws DebugException`. Since 21.2. Returns the number of hash map entries. Throws: `DebugException`: if `hasHashEntries()` returns `false` or guest language code throws an exception. See also: `hasHashEntries()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#getHashSize()` ### isHashEntryReadable(DebugValue) `public boolean isHashEntryReadable(DebugValue key) throws DebugException`. Since 21.2. Returns `true` if mapping for the specified key exists and is readable. If the `key` is obtained from `getHashEntriesIterator()` or `getHashKeysIterator()`, it returns the same value as `key.``isReadable()`. For details see `InteropLibrary.isHashEntryReadable(Object, Object)`. Throws: `DebugException`: if guest language code throws an exception. See also: `getHashValue(DebugValue)`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#isHashEntryReadable(com.oracle.truffle.api.debug.DebugValue)` ### getHashValue(DebugValue) `public DebugValue getHashValue(DebugValue key) throws DebugException`. Since 21.2. Get value of a hash map for the specified key or `null` if the mapping for the specified key does not exist. The returned value, if any, is `writable` if and only if `isHashEntryWritable(DebugValue)` returns true for the entry key. Throws: `DebugException`: if the value has no `hash entries`, or guest language code throws an exception. See also: `isHashEntryReadable(DebugValue)`, `getHashValueOrDefault(DebugValue, DebugValue)`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#getHashValue(com.oracle.truffle.api.debug.DebugValue)` ### getHashValueOrDefault(DebugValue, DebugValue) `public DebugValue getHashValueOrDefault(DebugValue key, DebugValue defaultValue) throws DebugException`. Since 21.2. Get value of a hash map for the specified key or return the `defaultValue` when the mapping for the specified key does not exist or is not readable. Throws: `DebugException`: if the hash map does not support reading at all, or guest language code throws an exception. See also: `isHashEntryReadable(DebugValue)`, `getHashValue(DebugValue)`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#getHashValueOrDefault(com.oracle.truffle.api.debug.DebugValue,com.oracle.truffle.api.debug.DebugValue)` ### isHashEntryModifiable(DebugValue) `public boolean isHashEntryModifiable(DebugValue key) throws DebugException`. Since 21.2. Returns `true` if mapping for the specified key exists and is `writable`. If the corresponding value is obtained from `getHashValue(DebugValue)` or from `getHashEntriesIterator()`, then it returns the same value as `value.``isWritable()`. For details see `InteropLibrary.isHashEntryModifiable(Object, Object)`. Throws: `DebugException`: if guest language code throws an exception. See also: `putHashEntry(DebugValue, DebugValue)`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#isHashEntryModifiable(com.oracle.truffle.api.debug.DebugValue)` ### isHashEntryInsertable(DebugValue) `public boolean isHashEntryInsertable(DebugValue key) throws DebugException`. Since 21.2. Returns `true` if mapping for the specified key does not exist and is `writable`. For details see `InteropLibrary.isHashEntryInsertable(Object, Object)`. Throws: `DebugException`: if guest language code throws an exception. See also: `putHashEntry(DebugValue, DebugValue)`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#isHashEntryInsertable(com.oracle.truffle.api.debug.DebugValue)` ### isHashEntryWritable(DebugValue) `public boolean isHashEntryWritable(DebugValue key) throws DebugException`. Since 21.2. Returns `true` if mapping for the specified key is `modifiable` or `insertable`. Throws: `DebugException`: if guest language code throws an exception. Cite: `com/oracle/truffle/api/debug/DebugValue.html#isHashEntryWritable(com.oracle.truffle.api.debug.DebugValue)` ### putHashEntry(DebugValue, DebugValue) `public void putHashEntry(DebugValue key, DebugValue value) throws DebugException`. Since 21.2. Associates the specified value with the specified key in the hash map. Putting the entry is allowed if is existing and `modifiable`, or not existing and `insertable`. Throws: `DebugException`: if the hash map does not support writing at all, or mapping for the specified key is not `modifiable` nor `insertable`, or the provided key type or value type is not allowed to be written, or guest language code throws an exception. Cite: `com/oracle/truffle/api/debug/DebugValue.html#putHashEntry(com.oracle.truffle.api.debug.DebugValue,com.oracle.truffle.api.debug.DebugValue)` ### isHashEntryRemovable(DebugValue) `public boolean isHashEntryRemovable(DebugValue key) throws DebugException`. Since 21.2. Returns `true` if mapping for the specified key exists and is removable. For details see `InteropLibrary.isHashEntryRemovable(Object, Object)`. Throws: `DebugException`: if guest language code throws an exception. See also: `removeHashEntry(DebugValue)`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#isHashEntryRemovable(com.oracle.truffle.api.debug.DebugValue)` ### removeHashEntry(DebugValue) `public boolean removeHashEntry(DebugValue key) throws DebugException`. Since 21.2. Removes the mapping for a given key from the hash map. Mapping removing is allowed if it is `removable`. Returns `boolean`: `true` if the mapping was successfully removed, `false` if mapping for a given key does not exist. Throws: `DebugException`: if the value does not have any `hash entries` or if mapping for specified key `exists` but cannot be removed. See also: `isHashEntryRemovable(DebugValue)`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#removeHashEntry(com.oracle.truffle.api.debug.DebugValue)` ### isHashEntryExisting(DebugValue) `public boolean isHashEntryExisting(DebugValue key) throws DebugException`. Since 21.2. Returns `true` if mapping for a given key is existing. For details see `InteropLibrary.isHashEntryExisting(Object, Object)`. Throws: `DebugException`: if guest language code throws an exception. Cite: `com/oracle/truffle/api/debug/DebugValue.html#isHashEntryExisting(com.oracle.truffle.api.debug.DebugValue)` ### getHashEntriesIterator() `public DebugValue getHashEntriesIterator() throws DebugException`. Since 21.2. Returns the entries iterator of the hash map. The return value is always an `iterator` of `array` elements. The first array element is a key, the second array element is the associated value. Array elements returned by the iterator may be modifiable. `Set` of the elements updates the hash map. Throws: `DebugException`: if `hasHashEntries()` returns `false`, or if guest language code throws an exception. Cite: `com/oracle/truffle/api/debug/DebugValue.html#getHashEntriesIterator()` ### getHashKeysIterator() `public DebugValue getHashKeysIterator() throws DebugException`. Since 21.2. Returns the keys iterator of the hash map. The return value is always an `iterator`. Throws: `DebugException`: if `hasHashEntries()` returns `false`, or if guest language code throws an exception. Cite: `com/oracle/truffle/api/debug/DebugValue.html#getHashKeysIterator()` ### getHashValuesIterator() `public DebugValue getHashValuesIterator() throws DebugException`. Since 21.2. Returns the values iterator of the hash map. The return value is always an `iterator`. Throws: `DebugException`: if `hasHashEntries()` returns `false`, or if guest language code throws an exception. Cite: `com/oracle/truffle/api/debug/DebugValue.html#getHashValuesIterator()` ### hashCode() `public int hashCode() throws DebugException`. Since 21.2. Provides hash code of the value. Returns `int`: `identity hash code` of the guest object, if the object `has identity`. Throws: `DebugException`: when guest language code throws an exception. Overrides `hashCode()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#hashCode()` ### equals(Object) `public boolean equals(Object obj) throws DebugException`. Since 21.2. Indicates whether another `DebugValue` is equal to this. Two `DebugValue` objects are equal if and only if their guest objects are `identical`. Throws: `DebugException`: when guest language code throws an exception. Overrides `equals(java.lang.Object)`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#equals(java.lang.Object)` ### getOriginalLanguage() `public final LanguageInfo getOriginalLanguage() throws DebugException`. Since 0.27. Get the original language that created the value, if any. This method will return `null` for values representing a primitive value, or objects that are not associated with any language. Returns `LanguageInfo`: the language, or `null` when no language can be identified as the creator of the value. Throws: `DebugException`: when guest language code throws an exception. Cite: `com/oracle/truffle/api/debug/DebugValue.html#getOriginalLanguage()` ### asInLanguage(LanguageInfo) `public final DebugValue asInLanguage(LanguageInfo language)`. Since 0.27. Returns a debug value that presents itself as seen by the provided language. The language affects the output of `toDisplayString()`, `getMetaObject()`, `getSourceLocation()` and other methods that provide various representations of the value. The `original language` of the returned value remains the same as of this value. Parameters: `language` `LanguageInfo`: a language to get the value representation of. Returns `DebugValue`: the value as represented in the language. Cite: `com/oracle/truffle/api/debug/DebugValue.html#asInLanguage(com.oracle.truffle.api.nodes.LanguageInfo)` ### getSession() `public abstract DebuggerSession getSession()`. Since 21.2. Get the debugger session associated with this value. Cite: `com/oracle/truffle/api/debug/DebugValue.html#getSession()` ### toString() `public String toString()`. Since 0.17. Returns a string representation of the debug value. Overrides `toString()`. Cite: `com/oracle/truffle/api/debug/DebugValue.html#toString()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ Debugger [truffle-api](index.md) › [com.oracle.truffle.api.debug](com/oracle/truffle/api/debug/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.debug`](com/oracle/truffle/api/debug/index.md). Since 0.9. ```java public final class Debugger ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Debugger` Class that simplifies implementing a debugger on top of Truffle. Primarily used to implement debugging protocol support. Access to the (singleton) instance in an engine, is available via: - [`Debugger.find(Engine)`](com/oracle/truffle/api/debug/Debugger.md#find%28org.graalvm.polyglot.Engine%29) - [`Debugger.find(TruffleLanguage.Env)`](com/oracle/truffle/api/debug/Debugger.md#find%28com.oracle.truffle.api.TruffleLanguage.Env%29) - [`DebuggerSession.getDebugger()`](com/oracle/truffle/api/debug/DebuggerSession.md#getDebugger%28%29) To start new debugger session use [`startSession(SuspendedCallback)`](com/oracle/truffle/api/debug/Debugger.md#startSession%28com.oracle.truffle.api.debug.SuspendedCallback%29). Please see [`DebuggerSession`](com/oracle/truffle/api/debug/DebuggerSession.md) for a usage example. The debugger supports diagnostic tracing that can be enabled using the `-Dtruffle.debug.trace=true` Java property. The output of this tracing is not guaranteed and will change without notice. **See also** - [`Debugger.startSession(SuspendedCallback)`](com/oracle/truffle/api/debug/Debugger.md#startSession%28com.oracle.truffle.api.debug.SuspendedCallback%29) - [`DebuggerSession`](com/oracle/truffle/api/debug/DebuggerSession.md) - [`Breakpoint`](com/oracle/truffle/api/debug/Breakpoint.md) ## Methods ### startSession(SuspendedCallback) `public DebuggerSession startSession(SuspendedCallback callback)`. Since 0.17. Starts a new `session` provided with a callback that gets notified whenever the execution is suspended. Uses `SourceElement.STATEMENT` as the source element available for stepping. Use `startSession(SuspendedCallback, SourceElement...)` to specify a different set of source elements. Parameters: `callback` `SuspendedCallback`: the callback to notify. See also: `DebuggerSession`, `SuspendedEvent`, `startSession(SuspendedCallback, SourceElement...)`. Cite: `com/oracle/truffle/api/debug/Debugger.html#startSession(com.oracle.truffle.api.debug.SuspendedCallback)` ### startSession(SuspendedCallback, SourceElement...) `public DebuggerSession startSession(SuspendedCallback callback, SourceElement... defaultSourceElements)`. Since 0.33. Starts a new `session` provided with a callback that gets notified whenever the execution is suspended and with a list of source syntax elements on which it is possible to step. Only steps created with one of these element kinds are accepted in this session. All specified elements are used by steps by default, if not specified otherwise by `StepConfig.Builder.sourceElements(SourceElement...)`. When no elements are provided, stepping is not possible and the session itself has no instrumentation overhead. Parameters: `callback` `SuspendedCallback`: the callback to notify. `defaultSourceElements` `SourceElement...`: a list of source elements, an explicit empty list disables stepping. See also: `DebuggerSession`, `SuspendedEvent`. Cite: `com/oracle/truffle/api/debug/Debugger.html#startSession(com.oracle.truffle.api.debug.SuspendedCallback,com.oracle.truffle.api.debug.SourceElement...)` ### getSessionCount() `public int getSessionCount()`. Since 19.0. Returns the number of active debugger sessions. This is useful, for instance, in deciding whether to open a new debugger session, depending on whether there is an existing one or not. Cite: `com/oracle/truffle/api/debug/Debugger.html#getSessionCount()` ### install(Breakpoint) `public Breakpoint install(Breakpoint breakpoint)`. Since 0.27. Adds a new breakpoint to this Debugger instance and makes it available in all its sessions. The breakpoint suspends execution in all active `sessions` by making a callback to the appropriate session `callback handler`, together with an event description that includes which breakpoint(s) were hit. Parameters: `breakpoint` `Breakpoint`: a new breakpoint. Returns `Breakpoint`: the installed breakpoint. Throws: `IllegalStateException` (unchecked): if the session has been closed. Cite: `com/oracle/truffle/api/debug/Debugger.html#install(com.oracle.truffle.api.debug.Breakpoint)` ### getBreakpoints() `public List getBreakpoints()`. Since 0.27. Returns all breakpoints `installed` in this debugger instance, in the install order. The returned list contains a current snapshot of breakpoints, those that were `disposed` are not included. It's not possible to modify state of breakpoints returned from this list, or from methods on listeners, they are not `modifiable`. An attempt to modify breakpoints state using any of their set method, or an attempt to dispose such breakpoints, fails with an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html). Use the original installed breakpoint instance to change breakpoint state or dispose the breakpoint. See also: `DebuggerSession.getBreakpoints()`. Cite: `com/oracle/truffle/api/debug/Debugger.html#getBreakpoints()` ### addBreakpointAddedListener(Consumer) `public void addBreakpointAddedListener(Consumer listener)`. Since 19.0. Add a listener that is notified when a new breakpoint is added into `list of breakpoints`. The reported breakpoint is not `modifiable`. Cite: `com/oracle/truffle/api/debug/Debugger.html#addBreakpointAddedListener(java.util.function.Consumer)` ### removeBreakpointAddedListener(Consumer) `public void removeBreakpointAddedListener(Consumer listener)`. Since 19.0. Remove a listener that was added by `addBreakpointAddedListener(Consumer)`. Cite: `com/oracle/truffle/api/debug/Debugger.html#removeBreakpointAddedListener(java.util.function.Consumer)` ### addBreakpointRemovedListener(Consumer) `public void addBreakpointRemovedListener(Consumer listener)`. Since 19.0. Add a listener that is notified when a breakpoint is removed from `list of breakpoints`. The reported breakpoint is not `modifiable`. Cite: `com/oracle/truffle/api/debug/Debugger.html#addBreakpointRemovedListener(java.util.function.Consumer)` ### removeBreakpointRemovedListener(Consumer) `public void removeBreakpointRemovedListener(Consumer listener)`. Since 19.0. Remove a listener that was added by `addBreakpointRemovedListener(Consumer)`. Cite: `com/oracle/truffle/api/debug/Debugger.html#removeBreakpointRemovedListener(java.util.function.Consumer)` ### disableStepping() `public void disableStepping()`. Since 22.3. Disable stepping on the current thread. The current thread must be in an entered context. Assure that the stepping is restored again by calling `restoreStepping()` like: The typical usage is to disable stepping on a specific code path. E.g. when a guest code is executed as a safepoint action, which executes out of an apparent code flow. The calls to disable/restoreStepping can be nested. Every call to `disableStepping()` increments a disabled count by one and every call to `restoreStepping()` decrements the disabled count by one. Disabling of stepping does not prevent breakpoints from being hit. After a breakpoint is hit, stepping is allowed automatically for the breakpoint's session, so that the user can continue stepping from the breakpoint location. The stepping is allowed only on the level of the disabled count where the breakpoint is hit. The stepping is still disabled on other disabled count levels. Throws: `IllegalStateException` (unchecked): when not in an entered context. See also: `restoreStepping()`. Cite: `com/oracle/truffle/api/debug/Debugger.html#disableStepping()` ```java Debugger debugger = Debugger.find(engine); debugger.disableStepping(); try { // run code which debugger should not step into } finally { debugger.restoreStepping(); } ``` ### restoreStepping() `public void restoreStepping()`. Since 22.3. Restore the stepping on the current thread. The current thread must be in an entered context and after a call to `disableStepping()`. The restore decrements the disabled count by one and allows stepping when zero is reached. Throws: `IllegalStateException` (unchecked): when not in an entered context, or when called without the preceding call to `disableStepping()`. See also: `disableStepping()`. Cite: `com/oracle/truffle/api/debug/Debugger.html#restoreStepping()` ### find(TruffleInstrument.Env) `public static Debugger find(TruffleInstrument.Env env)`. Since 19.0. Finds the debugger associated with a given instrument environment. Parameters: `env` `TruffleInstrument.Env`: the instrument environment to find debugger for. Returns `Debugger`: an instance of associated debugger, never `null`. Cite: `com/oracle/truffle/api/debug/Debugger.html#find(com.oracle.truffle.api.instrumentation.TruffleInstrument.Env)` ### find(Engine) `public static Debugger find(Engine engine)`. Since 19.0. Finds the debugger associated with a given an engine. Parameters: `engine` `Engine`: the engine to find debugger for. Returns `Debugger`: an instance of associated debugger, never `null`. Cite: `com/oracle/truffle/api/debug/Debugger.html#find(org.graalvm.polyglot.Engine)` ### find(TruffleLanguage.Env) `public static Debugger find(TruffleLanguage.Env env)`. Since 0.17. Finds the debugger associated with a given language environment. There is at most one debugger associated with any [`org.graalvm.polyglot.Engine`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Engine.html). Please note that a debugger instance looked up with a language also has access to all other languages and sources that were loaded by them. Parameters: `env` `TruffleLanguage.Env`: the language environment to find debugger for. Returns `Debugger`: an instance of associated debugger, never `null`. Cite: `com/oracle/truffle/api/debug/Debugger.html#find(com.oracle.truffle.api.TruffleLanguage.Env)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DebuggerSession [truffle-api](index.md) › [com.oracle.truffle.api.debug](com/oracle/truffle/api/debug/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.debug`](com/oracle/truffle/api/debug/index.md). Since 0.17. ```java public final class DebuggerSession implements Closeable ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `DebuggerSession` Implements: [`Closeable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/Closeable.html) Represents a single debugging session of a Debugger. #### Session lifetime - A debugging client [requests](com/oracle/truffle/api/debug/Debugger.md#startSession%28com.oracle.truffle.api.debug.SuspendedCallback%29) a new [session](com/oracle/truffle/api/debug/DebuggerSession.md) from the [Debugger](com/oracle/truffle/api/debug/Debugger.md). - A client uses a session to request suspension of guest language execution threads, for example by setting breakpoints or stepping. - When a session suspends a guest language execution thread, it passes its client a new [`SuspendedEvent`](com/oracle/truffle/api/debug/SuspendedEvent.md) via synchronous [callback](com/oracle/truffle/api/debug/SuspendedCallback.md) on the execution thread. - A suspended guest language execution thread resumes language execution only after the client callback returns. - Sessions that are no longer needed should be [closed](com/oracle/truffle/api/debug/DebuggerSession.md#close%28%29); a closed session has no further affect on engine execution. #### Debugging requests Session clients can manage guest language execution in several ways: - [Install](com/oracle/truffle/api/debug/DebuggerSession.md#install%28com.oracle.truffle.api.debug.Breakpoint%29) a newly created [`Breakpoint`](com/oracle/truffle/api/debug/Breakpoint.md). - [Request](com/oracle/truffle/api/debug/DebuggerSession.md#suspendNextExecution%28%29) suspension of the next execution on the first thread that is encountered. - Request a stepping action (e.g. [step into](com/oracle/truffle/api/debug/SuspendedEvent.md#prepareStepInto%28int%29), [step over](com/oracle/truffle/api/debug/SuspendedEvent.md#prepareStepOver%28int%29), [kill](com/oracle/truffle/api/debug/SuspendedEvent.md#prepareKill%28%29)) on a suspended execution thread, to take effect after the client callback returns. #### Event merging A session may suspend a guest language execution thread in response to more than one request from its client. For example: - A stepping action may land where a breakpoint is installed. - Multiple installed breakpoints may apply to a particular location. In such cases the client receives a single *merged* event. A call to [SuspendedEvent.getBreakpoints()](com/oracle/truffle/api/debug/SuspendedEvent.md#getBreakpoints%28%29) lists all breakpoints (possibly none) that apply to the suspended event's location. #### Multiple sessions There can be multiple sessions associated with a single engine, which are independent of one another in the following ways: - Breakpoints created by a session are not visible to clients of other sessions. - A client receives no notification when guest language execution threads are suspended by sessions other than its own. - Events are *not merged* across sessions. For example, when a guest language execution thread hits a location where two sessions have installed breakpoints, each session notifies its client with a new [`SuspendedEvent`](com/oracle/truffle/api/debug/SuspendedEvent.md) instance. Because all sessions can control engine execution, some interactions are inherently possible. For example: - A session's client can [kill](com/oracle/truffle/api/debug/SuspendedEvent.md#prepareKill%28%29) an execution at just about any time. - A session's client can *starve* execution by not returning from the synchronous [callback](com/oracle/truffle/api/debug/SuspendedCallback.md) on the guest language execution thread. Usage example: ```java try (DebuggerSession session = Debugger.find(instrumentEnv). startSession(new SuspendedCallback() { public void onSuspend(SuspendedEvent event) { // step into the next event event.prepareStepInto(1); } })) { Source someCode = Source.newBuilder("...", "...", "example").build(); // install line breakpoint session.install(Breakpoint.newBuilder(someCode).lineIs(3).build()); } ``` ## Methods ### toString() `public String toString()`. Since 0.17. Overrides `toString()`. Cite: `com/oracle/truffle/api/debug/DebuggerSession.html#toString()` ### getDebugger() `public Debugger getDebugger()`. Since 0.17. Returns the `debugger` instance that this session is associated with. Can be used also after the session has already been closed. Cite: `com/oracle/truffle/api/debug/DebuggerSession.html#getDebugger()` ### getTopScope(String) `public DebugScope getTopScope(String languageId) throws DebugException`. Since 0.30. Returns a language top scope. The top scopes have global validity and unlike `DebugStackFrame.getScope()` have no relation to the suspended location. Throws: `DebugException`: when guest language code throws an exception. Cite: `com/oracle/truffle/api/debug/DebuggerSession.html#getTopScope(java.lang.String)` ### getExportedSymbols() `public Map getExportedSymbols()`. Since 0.30. Returns a polyglot scope - symbols explicitly exported by languages. Cite: `com/oracle/truffle/api/debug/DebuggerSession.html#getExportedSymbols()` ### setShowHostStackFrames(boolean) `public void setShowHostStackFrames(boolean showHostStackFrames)`. Since 20.3. Set to provide host information in stack traces. When `true`, `host frames` and `host trace elements` are provided, when available. See also: `DebugStackFrame.isHost()`, `DebugStackTraceElement.isHost()`. Cite: `com/oracle/truffle/api/debug/DebuggerSession.html#setShowHostStackFrames(boolean)` ### setSteppingFilter(SuspensionFilter) `public void setSteppingFilter(SuspensionFilter steppingFilter)`. Since 0.26. Set a stepping suspension filter. Prepared steps skip code that does not match this filter. Cite: `com/oracle/truffle/api/debug/DebuggerSession.html#setSteppingFilter(com.oracle.truffle.api.debug.SuspensionFilter)` ### suspendNextExecution() `public void suspendNextExecution()`. Since 0.17. Suspends the next execution on the first thread that is encountered. After the first thread was suspended no further executions are suspended unless `suspendNextExecution()` is called again. If multiple threads are executing at the same time then there are no guarantees on which thread is going to be suspended. Will throw an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) if the session is already closed. Cite: `com/oracle/truffle/api/debug/DebuggerSession.html#suspendNextExecution()` ### suspendHere(Node) `public boolean suspendHere(Node node)`. Since 20.3. Suspend immediately at the current location of the current execution thread. A `Node` argument can be provided as an exact current location, if known. This method can be called on the guest execution thread only. This method calls `SuspendedCallback.onSuspend(SuspendedEvent)` synchronously, with `SuspendedEvent` created at the actual location of the current thread. This method can not be called from an existing `callback`. Parameters: `node` `Node`: the top Node of the execution, or `null`. Returns `boolean`: `true` when there is a guest code execution on the current thread and `SuspendedCallback` was called, `false` otherwise. Throws: `IllegalStateException` (unchecked): when the current thread is suspended already. `IllegalArgumentException` (unchecked): when a node with no `RootNode` is provided, or it's root node does not match the current execution root, or the node does not match the current call node, if known. Cite: `com/oracle/truffle/api/debug/DebuggerSession.html#suspendHere(com.oracle.truffle.api.nodes.Node)` ### suspend(Thread) `public void suspend(Thread t)`. Since 20.0. Suspends the current or the next execution of a given thread. Will throw an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) if the session is already closed. Note that if a stepping strategy is currently active, we preserve the stepping state. Cite: `com/oracle/truffle/api/debug/DebuggerSession.html#suspend(java.lang.Thread)` ### suspendAll() `public void suspendAll()`. Since 20.0. Suspends the current or the next execution on all threads. All new executing threads will start suspended until `resumeAll()` is called or the session is closed. Will throw an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) if the session is already closed. Cite: `com/oracle/truffle/api/debug/DebuggerSession.html#suspendAll()` ### resumeAll() `public void resumeAll()`. Since 0.17. Resumes all suspended executions that have not yet been notified. Cite: `com/oracle/truffle/api/debug/DebuggerSession.html#resumeAll()` ### resume(Thread) `public void resume(Thread t)`. Since 20.0. Resumes the execution on a given thread if it has not been suspended yet. Parameters: `t` `Thread`: the thread to resume. Cite: `com/oracle/truffle/api/debug/DebuggerSession.html#resume(java.lang.Thread)` ### disposeStepping(Thread) `public void disposeStepping(Thread t)`. Since 25.1. Dispose stepping on the given thread. All pending steps prepared on a `SuspendedEvent` on the provided thread are disposed. If no stepping were prepared, this method has no effect. If this is called in combination with `resume(Thread)` or `resumeAll()`, be sure to `dispose stepping` first and then resume. Cite: `com/oracle/truffle/api/debug/DebuggerSession.html#disposeStepping(java.lang.Thread)` ### createPrimitiveValue(Object, LanguageInfo) `public DebugValue createPrimitiveValue(Object primitiveValue, LanguageInfo language) throws IllegalArgumentException`. Since 21.2. Creates a `DebugValue` object that wraps a primitive value. Strings and boxed Java primitive types are considered primitive. Throws [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) if the value is not primitive. Parameters: `primitiveValue` `Object`: a primitive value. `language` `LanguageInfo`: guest language this value is value is associated with. Some value attributes depend on the language, like `DebugValue.getMetaObject()`. Can be `null`. Returns `DebugValue`: a `DebugValue` that wraps the primitive value. Throws: `IllegalArgumentException`: if the value is not a boxed Java primitive or a String. Cite: `com/oracle/truffle/api/debug/DebuggerSession.html#createPrimitiveValue(java.lang.Object,com.oracle.truffle.api.nodes.LanguageInfo)` ### close() `public void close()`. Since 0.17. Closes the current debugging session and disposes all installed breakpoints. Overrides `close()`. Cite: `com/oracle/truffle/api/debug/DebuggerSession.html#close()` ### getBreakpoints() `public List getBreakpoints()`. Since 0.17. Returns all breakpoints `installed` in this session, in the install order. The returned list contains a current snapshot of breakpoints, those that were `disposed`, or `installed on Debugger` are not included. See also: `Debugger.getBreakpoints()`. Cite: `com/oracle/truffle/api/debug/DebuggerSession.html#getBreakpoints()` ### setBreakpointsActive(Breakpoint.Kind, boolean) `public void setBreakpointsActive(Breakpoint.Kind breakpointKind, boolean active)`. Since 19.0. Set whether breakpoints of the given kind are active in this session. This has no effect on breakpoints enabled/disabled state. Breakpoints need to be active to actually break the execution. The breakpoints are active by default. Parameters: `breakpointKind` `Breakpoint.Kind`: the kind of breakpoints to activate/deactivate. `active` `boolean`: `true` to make breakpoints active, `false` to make breakpoints inactive. Cite: `com/oracle/truffle/api/debug/DebuggerSession.html#setBreakpointsActive(com.oracle.truffle.api.debug.Breakpoint.Kind,boolean)` ### isBreakpointsActive(Breakpoint.Kind) `public boolean isBreakpointsActive(Breakpoint.Kind breakpointKind)`. Since 19.0. Test whether breakpoints of the given kind are active in this session. Breakpoints do not break execution when not active. Parameters: `breakpointKind` `Breakpoint.Kind`: the kind of breakpoints to test. Cite: `com/oracle/truffle/api/debug/DebuggerSession.html#isBreakpointsActive(com.oracle.truffle.api.debug.Breakpoint.Kind)` ### install(Breakpoint) `public Breakpoint install(Breakpoint breakpoint)`. Since 0.17. Adds a new breakpoint to this session and makes it capable of suspending execution. The breakpoint suspends execution by making a `callback` to this session, together with an event description that includes which breakpoint(s) were hit. Parameters: `breakpoint` `Breakpoint`: a new breakpoint. Returns `Breakpoint`: the installed breakpoint. Throws: `IllegalStateException` (unchecked): if the session has been closed. Cite: `com/oracle/truffle/api/debug/DebuggerSession.html#install(com.oracle.truffle.api.debug.Breakpoint)` ### setAsynchronousStackDepth(int) `public void setAsynchronousStackDepth(int depth)`. Since 20.1.0. Request for languages to provide stack frames of scheduled asynchronous execution. Languages might not provide asynchronous stack frames by default for performance reasons. At most `depth` asynchronous stack frames are asked for. When multiple debugger sessions or other instruments call this method, the languages get a maximum depth of these calls and may therefore provide longer asynchronous stacks than requested. Also, languages may provide asynchronous stacks if it's of no performance penalty, or if requested by other options. Asynchronous stacks can then be accessed via `SuspendedEvent.getAsynchronousStacks()`, or `DebugException.getDebugAsynchronousStacks()`. Parameters: `depth` `int`: the requested stack depth, 0 means no asynchronous stack frames are required. See also: `SuspendedEvent.getAsynchronousStacks()`, `DebugException.getDebugAsynchronousStacks()`. Cite: `com/oracle/truffle/api/debug/DebuggerSession.html#setAsynchronousStackDepth(int)` ### setContextsListener(DebugContextsListener, boolean) `public void setContextsListener(DebugContextsListener listener, boolean includeActiveContexts)`. Since 0.30. Set a `listener` to be notified about changes in contexts in guest language application. One listener can be set at a time, call with `null` to remove the current listener. Parameters: `listener` `DebugContextsListener`: a listener to receive the context events, or `null` to reset it. `includeActiveContexts` `boolean`: whether or not this listener should be notified for present active contexts. Cite: `com/oracle/truffle/api/debug/DebuggerSession.html#setContextsListener(com.oracle.truffle.api.debug.DebugContextsListener,boolean)` ### setThreadsListener(DebugThreadsListener, boolean) `public void setThreadsListener(DebugThreadsListener listener, boolean includeInitializedThreads)`. Since 0.30. Set a `listener` to be notified about changes in threads in guest language application. One listener can be set at a time, call with `null` to remove the current listener. Parameters: `listener` `DebugThreadsListener`: a listener to receive the context events. `includeInitializedThreads` `boolean`: whether or not this listener should be notified for present initialized threads. Cite: `com/oracle/truffle/api/debug/DebuggerSession.html#setThreadsListener(com.oracle.truffle.api.debug.DebugThreadsListener,boolean)` ### setSourcePath(Iterable) `public void setSourcePath(Iterable uris)`. Since 19.0. Set a list of source path roots that are used to resolve relative `source URIs`. All debugger methods that provide `Source` object, resolve relative sources with respect to this source-path. When the resolution does not succeed (the relative path does not exist under any of the supplied source-path elements), the original relative `Source` is provided. Parameters: `uris` `Iterable`: a list of absolute URIs. Throws: `IllegalArgumentException` (unchecked): when an URI is not absolute. See also: `resolveSource(Source)`. Cite: `com/oracle/truffle/api/debug/DebuggerSession.html#setSourcePath(java.lang.Iterable)` ### resolveSource(Source) `public Source resolveSource(Source source)`. Since 19.0. Resolve the source with respect to the actual `source path`. Sources with relative `URI` are subject to resolution to an existing absolute location. The first source-path URI that resolves to an existing location is used. Parameters: `source` `Source`: the source to resolve. Returns `Source`: the provided source if no resolution is necessary, or the resolved source, or `null` when it's not possible to resolve the provided source. Cite: `com/oracle/truffle/api/debug/DebuggerSession.html#resolveSource(com.oracle.truffle.api.source.Source)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DebuggerTags [truffle-api](index.md) › [com.oracle.truffle.api.debug](com/oracle/truffle/api/debug/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.debug`](com/oracle/truffle/api/debug/index.md). Since 0.14. ```java public final class DebuggerTags ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `DebuggerTags` Set of debugger-specific tags. Language should [`provide`](com/oracle/truffle/api/instrumentation/ProvidedTags.md) an implementation of these tags in order to support specific debugging features. ## Nested types - [`DebuggerTags.AlwaysHalt`](com/oracle/truffle/api/debug/DebuggerTags.AlwaysHalt.md) (class): Marks program locations where debugger should always halt like if on a breakpoint. ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DebuggerTags.AlwaysHalt [truffle-api](index.md) › [com.oracle.truffle.api.debug](com/oracle/truffle/api/debug/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.debug`](com/oracle/truffle/api/debug/index.md). Since 0.14. Nested in [`DebuggerTags`](com/oracle/truffle/api/debug/DebuggerTags.md). ```java public final class DebuggerTags.AlwaysHalt extends Tag ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Tag`](com/oracle/truffle/api/instrumentation/Tag.md) > `AlwaysHalt` Marks program locations where debugger should always halt like if on a breakpoint. [`TruffleLanguage`](com/oracle/truffle/api/TruffleLanguage.md)s that support concept similar to JavaScript's `debugger` statement (program locations where execution should always halt) should make sure that appropriate [`Node`](com/oracle/truffle/api/nodes/Node.md)s are tagged with the [`AlwaysHalt`](com/oracle/truffle/api/debug/DebuggerTags.AlwaysHalt.md) tag. ```java class DebuggerNode extends Node implements InstrumentableNode { public boolean hasTag(Class tag) { return tag == DebuggerTags.AlwaysHalt.class; } } ``` All created [`debugger sessions`](com/oracle/truffle/api/debug/DebuggerSession.md) will suspend on these locations unconditionally. ## Inherited members - From class [`Tag`](com/oracle/truffle/api/instrumentation/Tag.md): [`findProvidedTag`](com/oracle/truffle/api/instrumentation/Tag.md#findProvidedTag%28com.oracle.truffle.api.nodes.LanguageInfo,java.lang.String%29), [`getIdentifier`](com/oracle/truffle/api/instrumentation/Tag.md#getIdentifier%28java.lang.Class%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ≡ SourceElement [truffle-api](index.md) › [com.oracle.truffle.api.debug](com/oracle/truffle/api/debug/index.md) · Every page: [llms.txt](llms.txt) Enum class in [`com.oracle.truffle.api.debug`](com/oracle/truffle/api/debug/index.md). Since 0.33. ```java public enum SourceElement ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html) > `SourceElement` Representation of a guest language source syntax element, that is used for debugging purposes. It is based on [`Tag`](com/oracle/truffle/api/instrumentation/Tag.md) types and this enum defines the set of syntax element kinds known to the debugger. ## Enum constants ### STATEMENT `STATEMENT`. Since 0.33. Denotes program locations that represent a statement of a guest language. The appropriate nodes are tagged with `StatementTag`. Cite: `com/oracle/truffle/api/debug/SourceElement.html#STATEMENT` ### EXPRESSION `EXPRESSION`. Since 0.33. Denotes program locations that represent an expression of a guest language. The appropriate nodes are tagged with `ExpressionTag`. Cite: `com/oracle/truffle/api/debug/SourceElement.html#EXPRESSION` ### ROOT `ROOT`. Since 19.0. Denotes program locations that represent a function of a guest language. The appropriate nodes are tagged with `RootTag`. Cite: `com/oracle/truffle/api/debug/SourceElement.html#ROOT` ## Methods ### values() `public static SourceElement[] values()`. Returns the enum constants in declaration order. Returns `SourceElement[]`: Returns the enum constants in declaration order. Cite: `com/oracle/truffle/api/debug/SourceElement.html#values()` ### valueOf(String) `public static SourceElement valueOf(String name)`. Returns the enum constant with the given name. Parameters: `name` `String`: The exact name of the enum constant. Returns `SourceElement`: Returns the enum constant with the given name. Cite: `com/oracle/truffle/api/debug/SourceElement.html#valueOf(java.lang.String)` ## Inherited members - From class [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#clone%28%29), [`compareTo`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#compareTo%28E%29), [`describeConstable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#describeConstable%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#finalize%28%29), [`getDeclaringClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#getDeclaringClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#hashCode%28%29), [`name`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#name%28%29), [`ordinal`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#ordinal%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#toString%28%29), [`valueOf`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#valueOf%28java.lang.Class,java.lang.String%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ StepConfig [truffle-api](index.md) › [com.oracle.truffle.api.debug](com/oracle/truffle/api/debug/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.debug`](com/oracle/truffle/api/debug/index.md). Since 0.33. ```java public final class StepConfig ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `StepConfig` Represents a debugger step configuration. A debugger step is defined by it's depth and a set of additional properties. The step depth is specified by a usage of one of the appropriate prepare methods on [`SuspendedEvent`](com/oracle/truffle/api/debug/SuspendedEvent.md). The set of additional step properties is defined by this class. These are a step count and a list of [`source elements`](com/oracle/truffle/api/debug/SourceElement.md) the step can suspend at. The rules of stepping through the [`source elements`](com/oracle/truffle/api/debug/SourceElement.md) are following: - [`SourceElement.STATEMENT`](com/oracle/truffle/api/debug/SourceElement.md#STATEMENT): steps suspend [`before`](com/oracle/truffle/api/debug/SuspendAnchor.md#BEFORE) guest language statements, unless the step returns to a calling location, in which case they suspend [`after`](com/oracle/truffle/api/debug/SuspendAnchor.md#AFTER). Step depth is interpreted based on pushed stack frames. - [`SourceElement.EXPRESSION`](com/oracle/truffle/api/debug/SourceElement.md#EXPRESSION): steps suspend [`before`](com/oracle/truffle/api/debug/SuspendAnchor.md#BEFORE) and [`after`](com/oracle/truffle/api/debug/SuspendAnchor.md#AFTER) guest language expressions. Step depth is interpreted based on both pushed stack frames and expression nesting hierarchy. ## Nested types - [`StepConfig.Builder`](com/oracle/truffle/api/debug/StepConfig.Builder.md) (class): Builder of StepConfig. ## Methods ### newBuilder() `public static StepConfig.Builder newBuilder()`. Since 0.33. Create a new step configuration builder. Cite: `com/oracle/truffle/api/debug/StepConfig.html#newBuilder()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ StepConfig.Builder [truffle-api](index.md) › [com.oracle.truffle.api.debug](com/oracle/truffle/api/debug/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.debug`](com/oracle/truffle/api/debug/index.md). Since 0.33. Nested in [`StepConfig`](com/oracle/truffle/api/debug/StepConfig.md). ```java public final class StepConfig.Builder ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Builder` Builder of [`StepConfig`](com/oracle/truffle/api/debug/StepConfig.md). **See also** - [`StepConfig.newBuilder()`](com/oracle/truffle/api/debug/StepConfig.md#newBuilder%28%29) ## Methods ### sourceElements(SourceElement...) `public StepConfig.Builder sourceElements(SourceElement... elements)`. Since 0.33. Provide a list of `SourceElement`s that are enabled for the step. It must be a subset of `SourceElement`s enabled in `DebuggerSession` which the step is prepared for. At least one source element needs to be provided and can only be invoked once per builder. When not called, by default all source elements enabled in the debugger session are also enabled for the step. Parameters: `elements` `SourceElement...`: a non-empty list of source elements. Cite: `com/oracle/truffle/api/debug/StepConfig.Builder.html#sourceElements(com.oracle.truffle.api.debug.SourceElement...)` ### suspendAnchors(SourceElement, SuspendAnchor...) `public StepConfig.Builder suspendAnchors(SourceElement element, SuspendAnchor... anchors)`. Since 19.0. Provide a list of `SuspendAnchor`s for individual `SourceElement`s. By default, following suspend anchors are applied: This method can be called repeatedly to override the defaults. Parameters: `element` `SourceElement`: the element to set the suspend anchor for. `anchors` `SuspendAnchor...`: a list of suspend anchors. Cite: `com/oracle/truffle/api/debug/StepConfig.Builder.html#suspendAnchors(com.oracle.truffle.api.debug.SourceElement,com.oracle.truffle.api.debug.SuspendAnchor...)` | [`SourceElement`](com/oracle/truffle/api/debug/SourceElement.md) | [`SuspendAnchor`](com/oracle/truffle/api/debug/SuspendAnchor.md)s | | --- | --- | | [`ROOT`](com/oracle/truffle/api/debug/SourceElement.md#ROOT) | [`BEFORE`](com/oracle/truffle/api/debug/SuspendAnchor.md#BEFORE), [`AFTER`](com/oracle/truffle/api/debug/SuspendAnchor.md#AFTER) | | [`STATEMENT`](com/oracle/truffle/api/debug/SourceElement.md#STATEMENT) | [`BEFORE`](com/oracle/truffle/api/debug/SuspendAnchor.md#BEFORE) | | [`EXPRESSION`](com/oracle/truffle/api/debug/SourceElement.md#EXPRESSION) | [`BEFORE`](com/oracle/truffle/api/debug/SuspendAnchor.md#BEFORE), [`AFTER`](com/oracle/truffle/api/debug/SuspendAnchor.md#AFTER) | ### count(int) `public StepConfig.Builder count(int count)`. Since 0.33. Provide the step count. It specifies the number of times the step repeats itself before it suspends the execution. Can only be invoked once per builder. Throws: `IllegalArgumentException` (unchecked): if `count <= 0`. Cite: `com/oracle/truffle/api/debug/StepConfig.Builder.html#count(int)` ### build() `public StepConfig build()`. Since 0.33. Create a `step configuration` from this builder. Cite: `com/oracle/truffle/api/debug/StepConfig.Builder.html#build()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ≡ SuspendAnchor [truffle-api](index.md) › [com.oracle.truffle.api.debug](com/oracle/truffle/api/debug/index.md) · Every page: [llms.txt](llms.txt) Enum class in [`com.oracle.truffle.api.debug`](com/oracle/truffle/api/debug/index.md). Since 0.32. ```java public enum SuspendAnchor ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html) > `SuspendAnchor` Describes where, within a guest language source section, the suspend position is. **See also** - [`SuspendedEvent.getSuspendAnchor()`](com/oracle/truffle/api/debug/SuspendedEvent.md#getSuspendAnchor%28%29) ## Enum constants ### BEFORE `BEFORE`. Since 0.32. Denotes suspension just before execution of a guest language source location. Cite: `com/oracle/truffle/api/debug/SuspendAnchor.html#BEFORE` ### AFTER `AFTER`. Since 0.32. Denotes suspension just after execution of a guest language source location. Cite: `com/oracle/truffle/api/debug/SuspendAnchor.html#AFTER` ## Methods ### values() `public static SuspendAnchor[] values()`. Returns the enum constants in declaration order. Returns `SuspendAnchor[]`: Returns the enum constants in declaration order. Cite: `com/oracle/truffle/api/debug/SuspendAnchor.html#values()` ### valueOf(String) `public static SuspendAnchor valueOf(String name)`. Returns the enum constant with the given name. Parameters: `name` `String`: The exact name of the enum constant. Returns `SuspendAnchor`: Returns the enum constant with the given name. Cite: `com/oracle/truffle/api/debug/SuspendAnchor.html#valueOf(java.lang.String)` ## Inherited members - From class [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#clone%28%29), [`compareTo`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#compareTo%28E%29), [`describeConstable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#describeConstable%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#finalize%28%29), [`getDeclaringClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#getDeclaringClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#hashCode%28%29), [`name`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#name%28%29), [`ordinal`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#ordinal%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#toString%28%29), [`valueOf`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#valueOf%28java.lang.Class,java.lang.String%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ SuspendedCallback [truffle-api](index.md) › [com.oracle.truffle.api.debug](com/oracle/truffle/api/debug/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.debug`](com/oracle/truffle/api/debug/index.md). Since 0.17. ```java public interface SuspendedCallback ``` Callback invoked whenever the [`debugger`](com/oracle/truffle/api/debug/Debugger.md) suspends for a particular [`session`](com/oracle/truffle/api/debug/DebuggerSession.md). **See also** - [`DebuggerSession`](com/oracle/truffle/api/debug/DebuggerSession.md) - [`SuspendedEvent`](com/oracle/truffle/api/debug/SuspendedEvent.md) ## Methods ### onSuspend(SuspendedEvent) `void onSuspend(SuspendedEvent event)`. Since 0.17. Called whenever the `debugger` suspends for a particular `session`. If multiple threads would trigger a suspended event then each thread is going to get notified separately. Parameters: `event` `SuspendedEvent`: the suspended event. Cite: `com/oracle/truffle/api/debug/SuspendedCallback.html#onSuspend(com.oracle.truffle.api.debug.SuspendedEvent)` # ◆ SuspendedEvent [truffle-api](index.md) › [com.oracle.truffle.api.debug](com/oracle/truffle/api/debug/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.debug`](com/oracle/truffle/api/debug/index.md). Since 0.9. ```java public final class SuspendedEvent ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `SuspendedEvent` Access for [`Debugger`](com/oracle/truffle/api/debug/Debugger.md) clients to the state of a guest language execution thread that has been suspended, for example by a [`Breakpoint`](com/oracle/truffle/api/debug/Breakpoint.md) or stepping action. #### Event lifetime - A [`DebuggerSession`](com/oracle/truffle/api/debug/DebuggerSession.md) [`instruments`](com/oracle/truffle/api/instrumentation/Instrumenter.md) guest language code in order to implement [breakpoints](com/oracle/truffle/api/debug/Breakpoint.md), stepping actions, or other debugging actions on behalf of the session's [debugger](com/oracle/truffle/api/debug/Debugger.md) client. - A session may choose to suspend a guest language execution thread when it receives (synchronous) notification on the execution thread that it has reached an AST location instrumented by the session. - The session passes a new [`SuspendedEvent`](com/oracle/truffle/api/debug/SuspendedEvent.md) to the debugger client (synchronously) in a [callback](com/oracle/truffle/api/debug/SuspendedCallback.md#onSuspend%28com.oracle.truffle.api.debug.SuspendedEvent%29) on the guest language execution thread. - Clients may access certain event state only on the execution thread where the event was created and notification received; access from other threads can throws [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html). Please see the javadoc of the individual method for details. - A suspended thread resumes guest language execution after the client callback returns and the thread unwinds back to instrumentation code in the AST. - All event methods throw [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) after the suspended thread resumes guest language execution. #### Access to execution state - Method [`getStackFrames()`](com/oracle/truffle/api/debug/SuspendedEvent.md#getStackFrames%28%29) describes the suspended thread's location in guest language code. This information becomes unusable beyond the lifetime of the event and must not be stored. - Method [`getReturnValue()`](com/oracle/truffle/api/debug/SuspendedEvent.md#getReturnValue%28%29) describes a local result when the thread is suspended just [`after`](com/oracle/truffle/api/debug/SuspendAnchor.md#AFTER) the code source section. #### Next debugging action Clients use the following methods to request the debugging action(s) that will take effect when the event's thread resumes guest language execution. All prepare requests accumulate until resumed. - [`prepareStepInto(int)`](com/oracle/truffle/api/debug/SuspendedEvent.md#prepareStepInto%28int%29) - [`prepareStepInto(StepConfig)`](com/oracle/truffle/api/debug/SuspendedEvent.md#prepareStepInto%28com.oracle.truffle.api.debug.StepConfig%29) - [`prepareStepOut(int)`](com/oracle/truffle/api/debug/SuspendedEvent.md#prepareStepOut%28int%29) - [`prepareStepOut(StepConfig)`](com/oracle/truffle/api/debug/SuspendedEvent.md#prepareStepOut%28com.oracle.truffle.api.debug.StepConfig%29) - [`prepareStepOver(int)`](com/oracle/truffle/api/debug/SuspendedEvent.md#prepareStepOver%28int%29) - [`prepareStepOver(StepConfig)`](com/oracle/truffle/api/debug/SuspendedEvent.md#prepareStepOver%28com.oracle.truffle.api.debug.StepConfig%29) - [`prepareUnwindFrame(DebugStackFrame)`](com/oracle/truffle/api/debug/SuspendedEvent.md#prepareUnwindFrame%28com.oracle.truffle.api.debug.DebugStackFrame%29) - [`prepareUnwindFrame(DebugStackFrame, DebugValue)`](com/oracle/truffle/api/debug/SuspendedEvent.md#prepareUnwindFrame%28com.oracle.truffle.api.debug.DebugStackFrame,com.oracle.truffle.api.debug.DebugValue%29) - [`prepareKill()`](com/oracle/truffle/api/debug/SuspendedEvent.md#prepareKill%28%29) - [`prepareContinue()`](com/oracle/truffle/api/debug/SuspendedEvent.md#prepareContinue%28%29) If no debugging action is requested, the thread resumes, and any pending steps prepared by previous events remain active. An excplicit [`continue`](com/oracle/truffle/api/debug/SuspendedEvent.md#prepareContinue%28%29) cancels those pending steps. ## Methods ### getSession() `public DebuggerSession getSession()`. Since 0.17. Returns the debugger session this suspended event was created for. This method is thread-safe. Cite: `com/oracle/truffle/api/debug/SuspendedEvent.html#getSession()` ### getSourceSection() `public SourceSection getSourceSection()`. Since 0.17. Returns the guest language source section of the AST node before/after the execution is suspended. Returns `null` if no source section information is available. This method is thread-safe. Cite: `com/oracle/truffle/api/debug/SuspendedEvent.html#getSourceSection()` ### getSuspendAnchor() `public SuspendAnchor getSuspendAnchor()`. Since 0.32. Returns where, within the guest language `source section`, the suspended position is. Cite: `com/oracle/truffle/api/debug/SuspendedEvent.html#getSuspendAnchor()` ### hasSourceElement(SourceElement) `public boolean hasSourceElement(SourceElement sourceElement)`. Since 0.33. Returns `true` if the underlying guest language source location is denoted as the source element. Parameters: `sourceElement` `SourceElement`: the source element to check, must not be `null`. Cite: `com/oracle/truffle/api/debug/SuspendedEvent.html#hasSourceElement(com.oracle.truffle.api.debug.SourceElement)` ### isLanguageContextInitialized() `public boolean isLanguageContextInitialized()`. Since 0.26. Test if the language context of the source of the event is initialized. Cite: `com/oracle/truffle/api/debug/SuspendedEvent.html#isLanguageContextInitialized()` ### getInputValues() `public DebugValue[] getInputValues()`. Since 0.33. Returns the input values of the current source element gathered from return values of it's executed children. The input values are available only during stepping through the source elements hierarchy and only on `AFTER` `suspend anchor`. There can be `null` values in the returned array for children we did not intercept return values from. Returns `DebugValue[]`: the array of input values, or `null` when no input is available. Cite: `com/oracle/truffle/api/debug/SuspendedEvent.html#getInputValues()` ### getReturnValue() `public DebugValue getReturnValue()`. Since 0.17. Returns the return value of the currently executed source location. Returns `null` if the execution is suspended `before` a guest language location. The returned value is `null` if an exception occurred during execution of the instrumented source element, the exception is provided by `getException()`. This method is not thread-safe and will throw an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) if called on another thread than it was created with. Cite: `com/oracle/truffle/api/debug/SuspendedEvent.html#getReturnValue()` ### setReturnValue(DebugValue) `public void setReturnValue(DebugValue newValue)`. Since 19.0. Change the return value. When there is a `return value` at the current location, this method modifies the return value to a new one. Parameters: `newValue` `DebugValue`: the new return value, can not be `null`. Throws: `IllegalStateException` (unchecked): when `getReturnValue()` returns `null`. Cite: `com/oracle/truffle/api/debug/SuspendedEvent.html#setReturnValue(com.oracle.truffle.api.debug.DebugValue)` ### getException() `public DebugException getException()`. Since 19.0. Returns the debugger representation of a guest language exception that caused this suspended event (via an exception breakpoint, for instance). Returns `null` when no exception occurred. Cite: `com/oracle/truffle/api/debug/SuspendedEvent.html#getException()` ### isBreakpointHit() `public boolean isBreakpointHit()`. Since 24.1. Returns true if a breakpoint hit was the reason for the suspension. A breakpoint hit can happen at the same time as a step completed and/or an unwind. Hence, a caller of this method is responsible for also taking the results of `SuspendedEvent.isUnwind()` and `SuspendedEvent.isStep()` into account. Cite: `com/oracle/truffle/api/debug/SuspendedEvent.html#isBreakpointHit()` ### isStep() `public boolean isStep()`. Since 24.1. Returns true if a step was the reason for the suspension. A step can be either a step over, step into or a step out. A step that is completed can happen at the same time as an unwind and/or a breakpoint hit. Hence, a caller of this method is responsible for also taking the results of `SuspendedEvent.isUnwind()` and `SuspendedEvent.isBreakpointHit()` into account. Cite: `com/oracle/truffle/api/debug/SuspendedEvent.html#isStep()` ### isUnwind() `public boolean isUnwind()`. Since 24.1. Returns true if an unwind was the reason for the suspension. An unwind can complete at the same time as a step and/or a breakpoint hit. Hence, a caller of this method is responsible for also taking the results of `SuspendedEvent.isStep()` and `SuspendedEvent.isBreakpointHit()` into account. Cite: `com/oracle/truffle/api/debug/SuspendedEvent.html#isUnwind()` ### getBreakpointConditionException(Breakpoint) `public Throwable getBreakpointConditionException(Breakpoint breakpoint)`. Since 0.17. Returns the cause of failure, if any, during evaluation of a breakpoint's condition. This method is thread-safe. Parameters: `breakpoint` `Breakpoint`: a breakpoint associated with this event. Returns `Throwable`: the cause of condition failure. Cite: `com/oracle/truffle/api/debug/SuspendedEvent.html#getBreakpointConditionException(com.oracle.truffle.api.debug.Breakpoint)` ### getBreakpoints() `public List getBreakpoints()`. Since 0.17. Returns the `breakpoints` that individually would cause the "hit" where execution is suspended. If `Debugger-associated` breakpoint was hit, it is not possible to change the state of returned breakpoint. This method is thread-safe. Returns `List`: an unmodifiable list of breakpoints. Cite: `com/oracle/truffle/api/debug/SuspendedEvent.html#getBreakpoints()` ### getTopStackFrame() `public DebugStackFrame getTopStackFrame()`. Since 0.17. Returns the topmost stack frame returned by `getStackFrames()`. This method is not thread-safe and will throw an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) if called on another thread than it was created with. See also: `getStackFrames()`. Cite: `com/oracle/truffle/api/debug/SuspendedEvent.html#getTopStackFrame()` ### getStackFrames() `public Iterable getStackFrames()`. Since 0.17. Returns a list of guest language stack frame objects that indicate the current guest language location. There is always at least one, the topmost, stack frame available. The returned stack frames are usable only during `suspend` and should not be stored permanently. This method is not thread-safe and will throw an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) if called on another thread than it was created with. Cite: `com/oracle/truffle/api/debug/SuspendedEvent.html#getStackFrames()` ### getAsynchronousStacks() `public List> getAsynchronousStacks()`. Since 20.1.0. Get a list of asynchronous stack traces that led to scheduling of the current execution. Returns an empty list if no asynchronous stack is known. The first asynchronous stack is at the first index in the list. A possible next asynchronous stack (that scheduled execution of the previous one) is at the next index in the list. Languages might not provide asynchronous stack traces by default for performance reasons. Call `DebuggerSession.setAsynchronousStackDepth(int)` to request asynchronous stacks. Languages may provide asynchronous stacks if it's of no performance penalty, or if requested by other options. See also: `DebuggerSession.setAsynchronousStackDepth(int)`. Cite: `com/oracle/truffle/api/debug/SuspendedEvent.html#getAsynchronousStacks()` ### prepareContinue() `public void prepareContinue()`. Since 0.9. Prepare to execute in Continue mode when guest language program execution resumes. In this mode execution will continue until either: execution arrives at a node to which an enabled breakpoint is attached, **or:**; execution completes. This method is thread-safe and the prepared Continue mode is appended to any other previously prepared modes. No further modes can be prepared after continue. Throws: `IllegalStateException` (unchecked): when `continue` or `kill` is prepared already. Cite: `com/oracle/truffle/api/debug/SuspendedEvent.html#prepareContinue()` ### prepareStepInto(int) `public SuspendedEvent prepareStepInto(int stepCount)`. Since 0.9. Prepare to execute in **step into** mode when guest language program execution resumes. See the description of `prepareStepInto(StepConfig)` for details, calling this is identical to `prepareStepInto``.(``StepConfig``.``newBuilder``().``count``(stepCount).``build``())` . Parameters: `stepCount` `int`: the number of times to perform StepInto before halting. Returns `SuspendedEvent`: this event instance for an easy concatenation of method calls. Throws: `IllegalArgumentException` (unchecked): if `stepCount <= 0`. `IllegalStateException` (unchecked): when `continue` or `kill` is prepared already. Cite: `com/oracle/truffle/api/debug/SuspendedEvent.html#prepareStepInto(int)` ### prepareStepInto(StepConfig) `public SuspendedEvent prepareStepInto(StepConfig stepConfig)`. Since 0.33. Prepare to execute in **step into** mode when guest language program execution resumes. In this mode, the current thread continues until it arrives to a code location with one of the enabled `source elements` and repeats that process `step count` times. See `StepConfig` for the details about the stepping behavior. This mode persists until the thread resumes and then suspends, at which time the mode reverts to Continue, or the thread dies. A breakpoint set at a location where execution would suspend is treated specially as a single event, to avoid multiple suspensions at a single location. This method is thread-safe and the prepared StepInto mode is appended to any other previously prepared modes. Parameters: `stepConfig` `StepConfig`: the step configuration. Returns `SuspendedEvent`: this event instance for an easy concatenation of method calls. Throws: `IllegalStateException` (unchecked): when `continue` or `kill` is prepared already, or when the current debugger session has no source elements enabled for stepping. `IllegalArgumentException` (unchecked): when the `StepConfig` contains source elements not enabled for stepping in the current debugger session. Cite: `com/oracle/truffle/api/debug/SuspendedEvent.html#prepareStepInto(com.oracle.truffle.api.debug.StepConfig)` ### prepareStepOut(int) `public SuspendedEvent prepareStepOut(int stepCount)`. Since 0.26. Prepare to execute in **step out** mode when guest language program execution resumes. See the description of `prepareStepOut(StepConfig)` for details, calling this is identical to `prepareStepOut``.(``StepConfig``.``newBuilder``().``count``(stepCount).``build``())` . Parameters: `stepCount` `int`: the number of times to perform StepOver before halting. Returns `SuspendedEvent`: this event instance for an easy concatenation of method calls. Throws: `IllegalArgumentException` (unchecked): if `stepCount <= 0`. `IllegalStateException` (unchecked): when `continue` or `kill` is prepared already. Cite: `com/oracle/truffle/api/debug/SuspendedEvent.html#prepareStepOut(int)` ### prepareStepOut(StepConfig) `public SuspendedEvent prepareStepOut(StepConfig stepConfig)`. Since 0.33. Prepare to execute in **step out** mode when guest language program execution resumes. In this mode, the current thread continues until it arrives to an enclosing code location with one of the enabled `source elements` and repeats that process `step count` times. See `StepConfig` for the details about the stepping behavior. This mode persists until the thread resumes and then suspends, at which time the mode reverts to Continue, or the thread dies. A breakpoint set at a location where execution would suspend is treated specially as a single event, to avoid multiple suspensions at a single location. This method is thread-safe and the prepared StepInto mode is appended to any other previously prepared modes. Parameters: `stepConfig` `StepConfig`: the step configuration. Returns `SuspendedEvent`: this event instance for an easy concatenation of method calls. Throws: `IllegalStateException` (unchecked): when `continue` or `kill` is prepared already, or when the current debugger session has no source elements enabled for stepping. `IllegalArgumentException` (unchecked): when the `StepConfig` contains source elements not enabled for stepping in the current debugger session. Cite: `com/oracle/truffle/api/debug/SuspendedEvent.html#prepareStepOut(com.oracle.truffle.api.debug.StepConfig)` ### prepareStepOver(int) `public SuspendedEvent prepareStepOver(int stepCount)`. Since 0.9. Prepare to execute in **step over** mode when guest language program execution resumes. See the description of `prepareStepOver(StepConfig)` for details, calling this is identical to `prepareStepOver``.(``StepConfig``.``newBuilder``().``count``(stepCount).``build``())` . Parameters: `stepCount` `int`: the number of times to perform step over before halting. Returns `SuspendedEvent`: this event instance for an easy concatenation of method calls. Throws: `IllegalArgumentException` (unchecked): if `stepCount <= 0`. `IllegalStateException` (unchecked): when `continue` or `kill` is prepared already. Cite: `com/oracle/truffle/api/debug/SuspendedEvent.html#prepareStepOver(int)` ### prepareStepOver(StepConfig) `public SuspendedEvent prepareStepOver(StepConfig stepConfig)`. Since 0.33. Prepare to execute in **step over** mode when guest language program execution resumes. In this mode, the current thread continues until it arrives to a code location with one of the enabled `source elements`, ignoring any nested ones, and repeats that process `step count` times. See `StepConfig` for the details about the stepping behavior. This mode persists until the thread resumes and then suspends, at which time the mode reverts to Continue, or the thread dies. A breakpoint set at a location where execution would suspend is treated specially as a single event, to avoid multiple suspensions at a single location. This method is thread-safe and the prepared StepInto mode is appended to any other previously prepared modes. Parameters: `stepConfig` `StepConfig`: the step configuration. Returns `SuspendedEvent`: this event instance for an easy concatenation of method calls. Throws: `IllegalStateException` (unchecked): when `continue` or `kill` is prepared already, or when the current debugger session has no source elements enabled for stepping. `IllegalArgumentException` (unchecked): when the `StepConfig` contains source elements not enabled for stepping in the current debugger session. Cite: `com/oracle/truffle/api/debug/SuspendedEvent.html#prepareStepOver(com.oracle.truffle.api.debug.StepConfig)` ### prepareUnwindFrame(DebugStackFrame) `public void prepareUnwindFrame(DebugStackFrame frame) throws IllegalArgumentException`. Since 0.31. Prepare to unwind a frame. This frame and all frames above it are unwound off the execution stack. The frame needs to be on the `execution stack of this event`. Parameters: `frame` `DebugStackFrame`: the frame to unwind. Throws: `IllegalArgumentException`: when the frame is not on the execution stack of this event. Cite: `com/oracle/truffle/api/debug/SuspendedEvent.html#prepareUnwindFrame(com.oracle.truffle.api.debug.DebugStackFrame)` ### prepareUnwindFrame(DebugStackFrame, DebugValue) `public void prepareUnwindFrame(DebugStackFrame frame, DebugValue immediateReturnValue) throws IllegalArgumentException`. Since 21.1.0. Prepare to unwind a frame. This frame and all frames above it are unwound off the execution stack and the frame will return immediately with `immediateReturnValue`. If the return value is `null`, the unwound frame will instead be reentered upon thread resumption. The frame needs to be on the `execution stack of this event`. Parameters: `frame` `DebugStackFrame`: the frame to unwind. `immediateReturnValue` `DebugValue`: the value to return. Throws: `IllegalArgumentException`: when the frame is not on the execution stack of this event. Cite: `com/oracle/truffle/api/debug/SuspendedEvent.html#prepareUnwindFrame(com.oracle.truffle.api.debug.DebugStackFrame,com.oracle.truffle.api.debug.DebugValue)` ### prepareKill() `public void prepareKill()`. Since 0.12. Prepare to terminate the suspended execution represented by this event. One use-case for this method is to shield an execution of an unknown code with a timeout: This method is thread-safe and the prepared termination is appended to any other previously prepared modes. No further modes can be prepared after kill. Throws: `IllegalStateException` (unchecked): when `continue` or `kill` is prepared already. Cite: `com/oracle/truffle/api/debug/SuspendedEvent.html#prepareKill()` ### toString() `public String toString()`. Since 0.17. Overrides `toString()`. Cite: `com/oracle/truffle/api/debug/SuspendedEvent.html#toString()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ SuspensionFilter [truffle-api](index.md) › [com.oracle.truffle.api.debug](com/oracle/truffle/api/debug/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.debug`](com/oracle/truffle/api/debug/index.md). Since 0.26. ```java public final class SuspensionFilter ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `SuspensionFilter` A filter to limit the suspension locations. An instance of this filter can be provided to [`debugger session`](com/oracle/truffle/api/debug/DebuggerSession.md#setSteppingFilter%28com.oracle.truffle.api.debug.SuspensionFilter%29) to step on locations matching this filter only. **See also** - [`DebuggerSession.setSteppingFilter(com.oracle.truffle.api.debug.SuspensionFilter)`](com/oracle/truffle/api/debug/DebuggerSession.md#setSteppingFilter%28com.oracle.truffle.api.debug.SuspensionFilter%29) ## Nested types - [`SuspensionFilter.Builder`](com/oracle/truffle/api/debug/SuspensionFilter.Builder.md) (class): A builder for creating a suspension filter. ## Methods ### newBuilder() `public static SuspensionFilter.Builder newBuilder()`. Since 0.26. Returns a builder for creating a new suspension filter. Cite: `com/oracle/truffle/api/debug/SuspensionFilter.html#newBuilder()` ### isIgnoreLanguageContextInitialization() `public boolean isIgnoreLanguageContextInitialization()`. Since 0.26. Test if execution of language initialization code is to be ignored. Cite: `com/oracle/truffle/api/debug/SuspensionFilter.html#isIgnoreLanguageContextInitialization()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ SuspensionFilter.Builder [truffle-api](index.md) › [com.oracle.truffle.api.debug](com/oracle/truffle/api/debug/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.debug`](com/oracle/truffle/api/debug/index.md). Since 0.26. Nested in [`SuspensionFilter`](com/oracle/truffle/api/debug/SuspensionFilter.md). ```java public final class SuspensionFilter.Builder ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Builder` A builder for creating a suspension filter. ## Methods ### ignoreLanguageContextInitialization(boolean) `public SuspensionFilter.Builder ignoreLanguageContextInitialization(boolean ignore)`. Since 0.26. Set to ignore language initialization code. The language initialization code is not ignored by default. Parameters: `ignore` `boolean`: `true` to ignore execution of language context initialization code, `false` not to ignore it. Cite: `com/oracle/truffle/api/debug/SuspensionFilter.Builder.html#ignoreLanguageContextInitialization(boolean)` ### includeInternal(boolean) `public SuspensionFilter.Builder includeInternal(boolean internal)`. Since 0.29. Set to include or exclude `internal code` in the filter. Internal code is excluded by default. Parameters: `internal` `boolean`: `true` to include execution of internal code, `false` to exclude it. Cite: `com/oracle/truffle/api/debug/SuspensionFilter.Builder.html#includeInternal(boolean)` ### sourceSectionAvailableOnly(boolean) `public SuspensionFilter.Builder sourceSectionAvailableOnly(boolean availableOnly)`. Since 24.1. Set to suspend on available source sections only. By default all locations with or without available source sections are suspended. If this flag is set to `true` then `null` and not `available` source sections are not suspended. Parameters: `availableOnly` `boolean`: `true` to include only non-null and `available` `SourceSection`, `false` to include all. Cite: `com/oracle/truffle/api/debug/SuspensionFilter.Builder.html#sourceSectionAvailableOnly(boolean)` ### sourceIs(Predicate) `public SuspensionFilter.Builder sourceIs(Predicate filter)`. Since 0.29. Set a [`Predicate`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/Predicate.html) that filters based on a `Source`. The predicate must always return the same result for a source instance otherwise the behavior is undefined. The predicate should be able run on multiple threads at the same time. Parameters: `filter` `Predicate`: a source section filter. Cite: `com/oracle/truffle/api/debug/SuspensionFilter.Builder.html#sourceIs(java.util.function.Predicate)` ### build() `public SuspensionFilter build()`. Since 0.26. Create a new suspension filter configured by the builder methods. Cite: `com/oracle/truffle/api/debug/SuspensionFilter.Builder.html#build()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ▣ com.oracle.truffle.api.dsl [truffle-api](index.md) · Every page: [llms.txt](llms.txt) Package in truffle-api. Since 0.8 or older. Domain specific language that allows to specify specializing AST nodes in a declarative way. Uses annotation processor to generate the necessary subclass. ## Interfaces - [`ExecuteTracingSupport`](com/oracle/truffle/api/dsl/ExecuteTracingSupport.md): Allows tracing of calls to execute methods of a Node. - [`NodeFactory`](com/oracle/truffle/api/dsl/NodeFactory.md): Enables the dynamic creation of generated nodes. ## Classes - [`AOTSupport`](com/oracle/truffle/api/dsl/AOTSupport.md): Helper class to prepare AOT enabled nodes for AOT in RootNode.prepareForAOT. - [`DSLSupport`](com/oracle/truffle/api/dsl/DSLSupport.md): APIs to support share code in generated code. - [`InlineSupport`](com/oracle/truffle/api/dsl/InlineSupport.md): Contains classes to support node object inlining in Truffle. - [`Introspection`](com/oracle/truffle/api/dsl/Introspection.md): Contains introspection utilities for Truffle DSL. - [`SpecializationStatistics`](com/oracle/truffle/api/dsl/SpecializationStatistics.md): Represents a specialization statistics utiltiy that can be entered to collect additional statistics about Truffle DSL nodes. ## Exceptions - [`UnsupportedSpecializationException`](com/oracle/truffle/api/dsl/UnsupportedSpecializationException.md): Thrown by the generated code of Truffle-DSL if no compatible Specialization could be found for the provided values. ## Annotations - [`Bind`](com/oracle/truffle/api/dsl/Bind.md): Binds and executes an expression at most once for every execution of the node. - [`Cached`](com/oracle/truffle/api/dsl/Cached.md): A parameter annotated with Cached in a Specialization refers to a cached value of a specialization instance. - [`CreateCast`](com/oracle/truffle/api/dsl/CreateCast.md): Specifies a factory method that creates a Node which is used to cast this child. - [`Executed`](com/oracle/truffle/api/dsl/Executed.md): This annotation declares a child field to be executed and used as dynamic input values for specializations. - [`Fallback`](com/oracle/truffle/api/dsl/Fallback.md): A method annotated with Fallback is treated as a Specialization that implicitly links all the guards of all other declared Specialization annotated methods of the operation in a negated form. - [`GenerateAOT`](com/oracle/truffle/api/dsl/GenerateAOT.md): Allows nodes with specializations to be prepared for AOT. - [`GenerateCached`](com/oracle/truffle/api/dsl/GenerateCached.md): Allows to enable or disable the generation of the cached version of a Truffle DSL node. - [`GenerateInline`](com/oracle/truffle/api/dsl/GenerateInline.md): Generates code for a node that makes this node inlinable when used in cached parameters of specializations. - [`GenerateNodeFactory`](com/oracle/truffle/api/dsl/GenerateNodeFactory.md): Annotate nodes or base classes of nodes to generate factory handlers implementing the NodeFactory interface. - [`GeneratePackagePrivate`](com/oracle/truffle/api/dsl/GeneratePackagePrivate.md): Make the code generated for an annotated node package-private. - [`GenerateUncached`](com/oracle/truffle/api/dsl/GenerateUncached.md): Generates an uncached version of a node with specializations. - [`GeneratedBy`](com/oracle/truffle/api/dsl/GeneratedBy.md): Marks a type as being generated based on another class or method of a class. - [`Idempotent`](com/oracle/truffle/api/dsl/Idempotent.md): Methods annotated with Idempotent must be methods that may cause side effects but will always cause the same side effects for repeated invocations with the same parameters. - [`ImplicitCast`](com/oracle/truffle/api/dsl/ImplicitCast.md): Marks an implicit cast method. - [`ImportStatic`](com/oracle/truffle/api/dsl/ImportStatic.md): Imports all public and static methods and fields of the provided classes for the use in DSL expressions of the annotated class or its subclasses. - [`Introspectable`](com/oracle/truffle/api/dsl/Introspectable.md): Annotate a DSL operation using this annotation to be introspectable. - [`NeverDefault`](com/oracle/truffle/api/dsl/NeverDefault.md): Useful to annotate methods, fields or parameters bound by any DSL expression to indicate that it never returns a null or default primitive value. - [`NodeChild`](com/oracle/truffle/api/dsl/NodeChild.md): A NodeChild element defines an executable child for the enclosing Node. - [`NodeChildren`](com/oracle/truffle/api/dsl/NodeChildren.md): No description. - [`NodeField`](com/oracle/truffle/api/dsl/NodeField.md): A NodeField element defines a field for the generated Node. - [`NodeFields`](com/oracle/truffle/api/dsl/NodeFields.md): A NodeFields element defines a field for the generated Node. - [`NonIdempotent`](com/oracle/truffle/api/dsl/NonIdempotent.md): Methods annotated with NonIdempotent must be methods that may cause side effects but may not always cause the same side effects for repeated invocations with the same parameters. - [`ReportPolymorphism`](com/oracle/truffle/api/dsl/ReportPolymorphism.md): Enables reporting of polymorphic specializations from this node or exported message to the runtime. - [`Specialization`](com/oracle/truffle/api/dsl/Specialization.md): Defines a method of a node subclass to represent one specialization of an operation. - [`SuppressPackageWarnings`](com/oracle/truffle/api/dsl/SuppressPackageWarnings.md): Use to suppress Truffle DSL warnings in whole packages using a package-info.java class. - [`TypeCast`](com/oracle/truffle/api/dsl/TypeCast.md): Overrides the standard way of casting a certain type in a TypeSystem. - [`TypeCheck`](com/oracle/truffle/api/dsl/TypeCheck.md): Overrides the standard way of checking for a certain type in a TypeSystem. - [`TypeSystem`](com/oracle/truffle/api/dsl/TypeSystem.md): Type guards are the most common form of guards used in Truffle languages. - [`TypeSystemReference`](com/oracle/truffle/api/dsl/TypeSystemReference.md): References a TypeSystem on a node. # ◆ AOTSupport [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 21.1. ```java public final class AOTSupport ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `AOTSupport` Helper class to prepare AOT enabled nodes for AOT in [`RootNode.prepareForAOT`](com/oracle/truffle/api/nodes/RootNode.md#prepareForAOT%28%29). See also the [usage tutorial](https://github.com/oracle/graal/blob/master/truffle/docs/AOT.md) on the website. **See also** - [`GenerateAOT`](com/oracle/truffle/api/dsl/GenerateAOT.md) ## Methods ### prepareForAOT(RootNode) `public static void prepareForAOT(RootNode root)`. Since 21.1. Recursively prepares an AST for AOT compilation. If an AST is already prepared for AOT then this method has no effect. The AST lock will be held during this operation. See also: `GenerateAOT`, `RootNode.prepareForAOT`. Cite: `com/oracle/truffle/api/dsl/AOTSupport.html#prepareForAOT(com.oracle.truffle.api.nodes.RootNode)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # @ Bind [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 20.2. ```java @Retention(CLASS) @Target({PARAMETER}) public @interface Bind ``` Binds and executes an expression at most once for every execution of the node. This is useful if an expression cannot be repeated safely for a guard and its associated specialization method. For example, if a read of a field is volatile two consecutive reads might not lead to the same result. The name the extract parameter can be referred to in [`cached`](com/oracle/truffle/api/dsl/Cached.md), [`guard`](com/oracle/truffle/api/dsl/Specialization.md#guards%28%29), [`limit`](com/oracle/truffle/api/dsl/Specialization.md#limit%28%29), [`assumption`](com/oracle/truffle/api/dsl/Specialization.md#assumptions%28%29) expressions or the specialization body. The bind expression may refer to dynamic parameters, previously declared bind or cached parameters and [`node field`](com/oracle/truffle/api/dsl/NodeField.md) declarations. If a bind parameter only uses cached values, then it is considered also a cached value. If the parameter uses any dynamic parameter then the extract parameter is considered also a dynamic parameter. Usage examples: ```java static class DynamicObject { volatile Object storage; DynamicObject(Object storage) { this.storage = storage; } } abstract static class ExtractStorageNode extends Node { abstract Object execute(Object arg0); @Specialization(guards = "storage == cachedStorage", limit = "3") Object s0(DynamicObject a0, @Bind("a0.storage") Object storage, @Cached("storage") Object cachedStorage) { // use storage in specialization and in guard. return a0; } } ``` The special variable `$node` can be used to bind the current node, and `$frame` binds the execution frame. Bytecode DSL interpreters can also bind the special variables `$rootNode`, `$bytecodeNode`, and `$bytecodeIndex`. Proxyable nodes can enable explicit bytecode node and index execute parameters through `OperationProxy.Proxyable.bindBytecodeNode` and `OperationProxy.Proxyable.bindBytecodeIndex`. During ordinary AST execution, these bindings then use the supplied values rather than operation interpreter state. **See also** - [`Cached`](com/oracle/truffle/api/dsl/Cached.md) - [`Specialization`](com/oracle/truffle/api/dsl/Specialization.md) ## Nested types - [`Bind.DefaultExpression`](com/oracle/truffle/api/dsl/Bind.DefaultExpression.md) (annotation interface): Defines a default bind expression for a given type. ## Elements ### value() `String value() default ""`. Since 20.2. The extract expression. Default: `""`. See also: `Bind`. Cite: `com/oracle/truffle/api/dsl/Bind.html#value()` # @ Bind.DefaultExpression [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 24.2. Nested in [`Bind`](com/oracle/truffle/api/dsl/Bind.md). ```java @Retention(CLASS) @Target({TYPE}) @Inherited public @interface Bind.DefaultExpression ``` Defines a default bind expression for a given type. When a type defines a default bind expression, specialization methods can declare bind parameters of the type without specifying a [`bind expression`](com/oracle/truffle/api/dsl/Bind.md#value%28%29); the DSL will automatically use the [`default expression`](com/oracle/truffle/api/dsl/Bind.DefaultExpression.md#value%28%29) for the type. Usage example: ```java @Bind.DefaultExpression("get($node)") public final class MyLanguageContext { // ... public static MyLanguageContext get(Node node) { // ... } } abstract static class NodeWithBinding extends Node { abstract Object execute(); @Specialization Object perform(@Bind("MyLanguageContext.get($node)") MyLanguageContext boundWithExplicitExpression, @Bind MyLanguageContext boundWithDefaultExpression) { // ... } } ``` ## Elements ### value() `String value()`. Since 24.2. The default expression to be used for a particular type. See also: `Bind`. Cite: `com/oracle/truffle/api/dsl/Bind.DefaultExpression.html#value()` # @ Cached [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 0.8 or earlier. ```java @Retention(CLASS) @Target({PARAMETER}) public @interface Cached ``` A parameter annotated with [`Cached`](com/oracle/truffle/api/dsl/Cached.md) in a [`Specialization`](com/oracle/truffle/api/dsl/Specialization.md) refers to a **cached** value of a specialization instance. A cached parameter value is initialized once using the initializer expression at specialization instantiation. For each call of the specialization method the cached value is provided by using the annotated parameter from the method body. Cache initializers are potentially executed before guard expressions declared in [`Specialization.guards()`](com/oracle/truffle/api/dsl/Specialization.md#guards%28%29). A typical specialization may define multiple dynamic and multiple cached parameters. Dynamic parameter values are typically provided by executing child nodes of the operation. Cached parameters are initialized and stored once per specialization instantiation. Cached parameters are always constant at compile time. You may verify this by invoking [`CompilerAsserts.compilationConstant(Object)`](com/oracle/truffle/api/CompilerAsserts.md#compilationConstant%28java.lang.Object%29) on any cached parameter. For consistency between specialization declarations cached parameters must be declared last in a specialization method. The initializer expression of a cached parameter is defined using a subset of Java. This subset includes field/parameter accesses, function calls, type exact infix comparisons (==, !=, \<, \<=, \>, \>=), logical negation (!), logical disjunction (\|\|), null, true, false, and integer literals. The return type of the initializer expression must be assignable to the parameter type. If the annotated parameter type is derived from [`Node`](com/oracle/truffle/api/nodes/Node.md) then the [`Node`](com/oracle/truffle/api/nodes/Node.md) instance is allowed to use the [`Node.replace(Node)`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29) method to replace itself. Bound elements without receivers are resolved using the following order: 1. Dynamic and cached parameters of the enclosing specialization. 2. Fields defined using [`NodeField`](com/oracle/truffle/api/dsl/NodeField.md) for the enclosing node. 3. Public constructors of the type of the annotated parameter using the `new` keyword as method name. 4. Public and static methods or fields of the type of the annotated parameter. 5. Non-private, static or virtual methods or fields of enclosing node. 6. Non-private, static or virtual methods or fields of super types of the enclosing node. 7. Public and static methods or fields imported using [`ImportStatic`](com/oracle/truffle/api/dsl/ImportStatic.md). The following examples explain the intended use of the [`Cached`](com/oracle/truffle/api/dsl/Cached.md) annotation. All of the examples have to be enclosed in the following node declaration: ```java @NodeChild("operand") abstract TestNode extends Node { abstract void execute(Object operandValue); // ... example here ... } ``` 1. This example defines one dynamic and one cached parameter. The operand parameter is representing the dynamic value of the operand while the cachedOperand is initialized once at first execution of the specialization (specialization instantiation time). ```java @Specialization void doCached(int operand, @Cached("operand") int cachedOperand) { CompilerAsserts.compilationConstant(cachedOperand); ... } Example executions: execute(1) => doCached(1, 1) // new instantiation, localOperand is bound to 1 execute(0) => doCached(0, 1) execute(2) => doCached(2, 1) ``` 2. We extend the previous example by a guard for the cachedOperand value to be equal to the dynamic operand value. This specifies that the specialization is instantiated for each individual operand value that is provided. There are a lot of individual `int` values and for each individual `int` value a new specialization would get instantiated. The [`Specialization.limit()`](com/oracle/truffle/api/dsl/Specialization.md#limit%28%29) property defines a limit for the number of specializations that can get instantiated. If the specialization instantiation limit is reached then no further specializations are instantiated. Like for other specializations if there are no more specializations defined an [`UnsupportedSpecializationException`](com/oracle/truffle/api/dsl/UnsupportedSpecializationException.md) is thrown. The default specialization instantiation limit is `3`. ```java @Specialization(guards = "operand == cachedOperand") void doCached(int operand, @Cached("operand") int cachedOperand) { CompilerAsserts.compilationConstant(cachedOperand); ... } Example executions: execute(0) => doCached(0, 0) // new instantiation, cachedOperand is bound to 0 execute(1) => doCached(1, 1) // new instantiation, cachedOperand is bound to 1 execute(1) => doCached(1, 1) execute(2) => doCached(2, 2) // new instantiation, cachedOperand is bound to 2 execute(3) => throws UnsupportedSpecializationException // instantiation limit overflows ``` 3. To handle the limit overflow we extend our example by an additional specialization named `doNormal`. This specialization has the same type restrictions but does not have local state nor the operand identity guard. It is also declared after `doCached` therefore it is only instantiated if the limit of the `doCached` specialization has been reached. In other words `doNormal` is more generic than `doCached` . The `doNormal` specialization uses `replaces="doCached"` to specify that all instantiations of `doCached` get removed if `doNormal` is instantiated. Alternatively if the `replaces` relation is omitted then all `doCached` instances remain but no new instances are created. ```java @Specialization(guards = "operand == cachedOperand") void doCached(int operand, @Cached("operand") int cachedOperand) { CompilerAsserts.compilationConstant(cachedOperand); ... } @Specialization(replaces = "doCached") void doNormal(int operand) {...} Example executions with replaces = "doCached": execute(0) => doCached(0, 0) // new instantiation, cachedOperand is bound to 0 execute(1) => doCached(1, 1) // new instantiation, cachedOperand is bound to 1 execute(1) => doCached(1, 1) execute(2) => doCached(2, 2) // new instantiation, cachedOperand is bound to 2 execute(3) => doNormal(3) // new instantiation of doNormal due to limit overflow; doCached gets removed. execute(1) => doNormal(1) Example executions without replaces = "doCached": execute(0) => doCached(0, 0) // new instantiation, cachedOperand is bound to 0 execute(1) => doCached(1, 1) // new instantiation, cachedOperand is bound to 1 execute(1) => doCached(1, 1) execute(2) => doCached(2, 2) // new instantiation, cachedOperand is bound to 2 execute(3) => doNormal(3) // new instantiation of doNormal due to limit overflow execute(1) => doCached(1, 1) ``` 4. This next example shows how methods from the enclosing node can be used to initialize cached parameters. Please note that the visibility of transformLocal must not be `private`. ```java @Specialization void s(int operand, @Cached("transformLocal(operand)") int cachedOperand) { } int transformLocal(int operand) { return operand & 0x42; } ``` 5. The `new` keyword can be used to initialize a cached parameter using a constructor of the parameter type. ```java @Specialization void s(Object operand, @Cached("new()") OtherNode someNode) { someNode.execute(operand); } static class OtherNode extends Node { public String execute(Object value) { throw new UnsupportedOperationException(); } } ``` 6. Java types without public constructor but with a static factory methods can be initialized by just referencing its static factory method and its parameters. In this case [`com.oracle.truffle.api.profiles.BranchProfile.create()`](com/oracle/truffle/api/profiles/BranchProfile.md#create%28%29) is used to instantiate the [`com.oracle.truffle.api.profiles.BranchProfile`](com/oracle/truffle/api/profiles/BranchProfile.md) instance. ```java @Specialization void s(int operand, @Cached("create()") BranchProfile profile) { } ``` **See also** - [`Specialization.guards()`](com/oracle/truffle/api/dsl/Specialization.md#guards%28%29) - [`Specialization.replaces()`](com/oracle/truffle/api/dsl/Specialization.md#replaces%28%29) - [`Specialization.limit()`](com/oracle/truffle/api/dsl/Specialization.md#limit%28%29) - [`ImportStatic`](com/oracle/truffle/api/dsl/ImportStatic.md) ## Nested types - [`Cached.Exclusive`](com/oracle/truffle/api/dsl/Cached.Exclusive.md) (annotation interface): Disallows any sharing with other cached parameters. - [`Cached.Shared`](com/oracle/truffle/api/dsl/Cached.Shared.md) (annotation interface): Allows sharing between multiple Cached parameters between multiple specializations or exported library messages. ## Elements ### value() `String value() default "create($parameters)"`. Since 0.8 or earlier. Defines the initializer expression of the cached parameter value. Default: `"create($parameters)"`. See also: `Cached`. Cite: `com/oracle/truffle/api/dsl/Cached.html#value()` ### uncached() `String uncached() default "getUncached($parameters)"`. Since 19.0. Defines the initializer that is used for `uncached` nodes or uncached versions of exported library messages. Default: `"getUncached($parameters)"`. See also: `GenerateUncached`. Cite: `com/oracle/truffle/api/dsl/Cached.html#uncached()` ### dimensions() `int dimensions() default -1`. Since 0.26. Specifies the number of array dimensions to be marked as `compilation final`. This value must be specified for all array-typed cached values except `node` arrays and must be left unspecified in other cases where it has no meaning. The allowed range is from 0 to the number of declared array dimensions (inclusive). Specifically, a `dimensions` value of 0 marks only the reference to the (outermost) array as final but not its elements, a value of 1 marks the outermost array and all its elements as final but not the elements of any nested arrays. If not specified and the cached value type is an array type then this will cause a warning and in later releases an error. Default: `-1`. See also: `CompilationFinal.dimensions()`. Cite: `com/oracle/truffle/api/dsl/Cached.html#dimensions()` ### allowUncached() `boolean allowUncached() default false`. Since 19.0. Allows the `value()` to be used for `uncached()`. This is useful if the expression is the same for `value()` and `uncached()`. By setting `allowUncached()` to `true` it is not necessary to repeat the `value()` expression in the `uncached()` expression. This flag cannot be set in combination with `uncached()`. Default: `false`. Cite: `com/oracle/truffle/api/dsl/Cached.html#allowUncached()` ### inline() `boolean inline() default false`. Since 23.0. Enables inlining of the cached parameter if supported. The type of a cached parameter is considered inlinable if it declares a static method called `inline` with a single parameter of type `InlineTarget`. For specializing DSL nodes the `GenerateInline` is sufficient to be enabled for the cached target type, the static inline method will be resolved automatically from the generated code of the target type. Inlining is enabled by default if: `GenerateInline` is set to `true` for the declaring specializing node type.; The `GenerateCached.alwaysInlineCached()` property is set to `true` for the declaring specializing node type.; If a target parameter type is a specializing node and has `GenerateInline` enabled but `GenerateCached` disabled. Else, inlining is disabled by default. If a node is inlinable but is not inlined by default, the DSL will emit a warning to indicate this possibility. Default: `false`. See also: `InlineSupport`. Cite: `com/oracle/truffle/api/dsl/Cached.html#inline()` ### inlineMethod() `String inlineMethod() default ""`. Since 23.0. Specifies an alternative method name for node object inlining. Instead of looking up the inline method from the receiver type use an accessible enclosing method of the given name instead. The method must have a single parameter `InlineTarget` and return a type compatible to the cached type. This can be useful if you want to route calls to the inline method through an abstraction that does not allow direct type access to the node classes. It is expected that this property is only needed rarely. Default: `""`. Cite: `com/oracle/truffle/api/dsl/Cached.html#inlineMethod()` ### parameters() `String[] parameters() default {}`. Since 19.0. Specifies the bindings used for the $parameters variable in cached or uncached initializers. Default: `{}`. Cite: `com/oracle/truffle/api/dsl/Cached.html#parameters()` ### weak() `boolean weak() default false`. Since 20.2. If set to `true` then weak references will be used to refer to this cached value in the generated node. The default value is `false`. The weak cached parameter is guaranteed to not become `null` in guards or specialization method invocations. If a weak cached parameter gets collected by the GC, then any compiled code remain unaffected and the specialization instance will not be removed. Specializations with collected cached references continue to count to the specialization limit. This is necessary to provide an upper bound for the number of invalidations that may happen for this specialization. A weak cached parameter implicitly adds a `weakRef.get() != null` guard that is invoked before the cached value is referenced for the first time. This means that specializations which previously did not result in fall-through behavior may now fall-through. This is important if used in combination with `Fallback`. Weak cached parameters that are used as part of `uncached` nodes, execute the cached initializer for each execution and therefore implicitly do not use a weak reference. Example usage: Default: `false`. See also: `com.oracle.truffle.api.utilities.TruffleWeakReference`. Cite: `com/oracle/truffle/api/dsl/Cached.html#weak()` ```java @GenerateUncached abstract class WeakInlineCacheNode extends Node { abstract Object execute(Object arg0); @Specialization(guards = "cachedArg.equals(arg)", limit = "3") Object s0(String arg, @Cached(value = "arg", weak = true) String cachedArg) { assertNotNull(cachedStorage); return arg; } } ``` ### adopt() `boolean adopt() default true`. Since 20.2. Specifies whether the cached parameter values of type `NodeInterface` should be adopted as its child by the current node. The default value is `true`, therefore all cached values of type `NodeInterface` and arrays of the same type are adopted. If the value is set to `false`, then no adoption is performed. It is useful to set adopt to `false` when nodes need to be referenced more than once in the AST. If the type of the field is an `NodeInterface` array and adopt is set to `false`, then the compilation final `dimensions` attribute needs to be specified explicitly. Default: `true`. Cite: `com/oracle/truffle/api/dsl/Cached.html#adopt()` ### neverDefault() `boolean neverDefault() default false`. Since 23.0. Returns `true` if the cache initializer never returns the default value of its parameter type at runtime. For reference types the default value is `null`, for primitive values 0. By default, default values in cache initializers are allowed. The DSL may use the default state of a cache for optimizations in the generated code layout. The DSL informs with a warning when the use of this property has an effect and is recommended to be set. Alternatively to specifying `neverDefault()`, the `NeverDefault` annotation may be used on the method or field bound by the cache initializer. If a cache initializer returns the illegal default value when this property is set to `true` then the node will throw an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) at runtime. Default: `false`. See also: `NeverDefault`. Cite: `com/oracle/truffle/api/dsl/Cached.html#neverDefault()` # @ Cached.Exclusive [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 19.0. Nested in [`Cached`](com/oracle/truffle/api/dsl/Cached.md). ```java @Retention(CLASS) @Target({PARAMETER, METHOD, TYPE}) public @interface Cached.Exclusive ``` Disallows any sharing with other cached parameters. The DSL will indicate sharing opportunities to the user by showing a warning. # @ Cached.Shared [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 19.0. Nested in [`Cached`](com/oracle/truffle/api/dsl/Cached.md). ```java @Retention(CLASS) @Target({PARAMETER}) public @interface Cached.Shared ``` Allows sharing between multiple Cached parameters between multiple specializations or exported library messages. If no sharing is desired then the [`cached`](com/oracle/truffle/api/dsl/Cached.md) parameter can be annotated with [`exclusive`](com/oracle/truffle/api/dsl/Cached.Exclusive.md). The DSL will indicate sharing opportunities to the user by showing a warning. **See also** - [`Exclusive`](com/oracle/truffle/api/dsl/Cached.Exclusive.md) ## Elements ### value() `String value() default ""`. Since 19.0. Specifies the sharing group of the shared cached element. If not specified then the parameter name will be used as a group. Default: `""`. Cite: `com/oracle/truffle/api/dsl/Cached.Shared.html#value()` # @ CreateCast [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 0.8 or earlier. ```java @Retention(CLASS) @Target({METHOD}) public @interface CreateCast ``` Specifies a factory method that creates a [`Node`](com/oracle/truffle/api/nodes/Node.md) which is used to cast this child. ## Elements ### value() `String[] value()`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/dsl/CreateCast.html#value()` # ◆ DSLSupport [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 23.0. ```java public abstract class DSLSupport ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `DSLSupport` APIs to support share code in generated code. APIs in this class are aggressively deprecated and removed in this class. ## Nested types - [`DSLSupport.SpecializationDataNode`](com/oracle/truffle/api/dsl/DSLSupport.SpecializationDataNode.md) (interface): Interface implemented by specialization data classes. ## Methods ### lookupEnumConstants(Class) `public static > T[] lookupEnumConstants(Class c)`. Since 23.0. Looks up shared enum constants for DSL generated code. This avoids unnecessary enum arrays in the heap when the DSL creates constants with enum values to avoid the memory overhead of calling the values() method of enum classes. Cite: `com/oracle/truffle/api/dsl/DSLSupport.html#lookupEnumConstants(java.lang.Class)` ### maybeInsert(Node, T) `public static T maybeInsert(Node node, T o)`. Since 23.0. Inserts a node if a `NodeInterface` dynamically implements `Node`. Intended for generated code only. Cite: `com/oracle/truffle/api/dsl/DSLSupport.html#maybeInsert(com.oracle.truffle.api.nodes.Node,T)` ### maybeInsert(Node, T[]) `public static T[] maybeInsert(Node node, T[] o)`. Since 23.0. Inserts a node array if a `NodeInterface`[] dynamically implements `Node`[]. Intended for generated code only. Cite: `com/oracle/truffle/api/dsl/DSLSupport.html#maybeInsert(com.oracle.truffle.api.nodes.Node,T[])` ### assertIdempotence(boolean) `public static boolean assertIdempotence(boolean guardValue)`. Since 23.0. Helper method for DSL generated code to assert idempotence. See also: `Idempotent`, `NonIdempotent`. Cite: `com/oracle/truffle/api/dsl/DSLSupport.html#assertIdempotence(boolean)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ DSLSupport.SpecializationDataNode [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 23.1. Nested in [`DSLSupport`](com/oracle/truffle/api/dsl/DSLSupport.md). ```java public interface DSLSupport.SpecializationDataNode ``` Interface implemented by specialization data classes. This marker interface is needed for better validation and error handling during node object inlining. Intended to be used by the DSL implementation, please do not use otherwise. # ◇ ExecuteTracingSupport [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 21.3. ```java public interface ExecuteTracingSupport ``` Allows tracing of calls to `execute` methods of a [`Node`](com/oracle/truffle/api/nodes/Node.md). The methods declared in this interface are invoked by the code generated by Truffle DSL for nodes which directly or indirectly implement this interface. All tracing methods are called only if [`isTracingEnabled()`](com/oracle/truffle/api/dsl/ExecuteTracingSupport.md#isTracingEnabled%28%29) returns `true`. Example: ```java abstract static class BaseNode extends Node implements ExecuteTracingSupport { static final TruffleLogger LOGGER = TruffleLogger.getLogger("id", "trace"); @Override public boolean isTracingEnabled() { return LOGGER.isLoggable(Level.INFO); } @Override public void traceOnEnter(Object[] arguments) { // called before any execute method } @Override public void traceOnReturn(Object returnValue) { // called after any execute method if it returns normally } @Override public void traceOnException(Throwable t) { // called after any execute method which throws an exception } } abstract static class Operation1Node extends BaseNode { // any execute call would automatically be traced public abstract Object execute(int arg0, Object arg1); @Specialization int doInt(int a, int b) { return a + b; } } ``` ## Methods ### isTracingEnabled() `boolean isTracingEnabled()`. Since 21.3. Invoked by the generated code to determine whether tracing is enabled. If tracing is disabled, no other methods in this interface will be invoked. Returns `boolean`: `true` if tracing is enabled. Cite: `com/oracle/truffle/api/dsl/ExecuteTracingSupport.html#isTracingEnabled()` ### traceOnEnter(Object[]) `default void traceOnEnter(Object[] arguments)`. Since 21.3. Invoked by the generated `execute` methods before any `Specialization` is called, but after all `NodeChildren` are evaluated. Called only if `isTracingEnabled()` returns `true`. Parameters: `arguments` `Object[]`: the arguments of the specialization except the frame, if any. Cite: `com/oracle/truffle/api/dsl/ExecuteTracingSupport.html#traceOnEnter(java.lang.Object[])` ### traceOnReturn(Object) `default void traceOnReturn(Object returnValue)`. Since 21.3. Invoked by the generated `execute` methods when a `Specialization` returns normally. Called only if `isTracingEnabled()` returns `true`. Parameters: `returnValue` `Object`: the value returned by the specialization or `null` if the `execute` method is declared to return `void`. Cite: `com/oracle/truffle/api/dsl/ExecuteTracingSupport.html#traceOnReturn(java.lang.Object)` ### traceOnException(Throwable) `default void traceOnException(Throwable t)`. Since 21.3. Invoked by the generated `execute` methods when a `Specialization` throws an exception. Called only if `isTracingEnabled()` returns `true`. Exceptions thrown by child node invocations are not traced by the parent. Parameters: `t` `Throwable`: the exception thrown by the specialization. Cite: `com/oracle/truffle/api/dsl/ExecuteTracingSupport.html#traceOnException(java.lang.Throwable)` # @ Executed [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 0.33. ```java @Retention(CLASS) @Target({FIELD}) public @interface Executed ``` This annotation declares a [`child`](com/oracle/truffle/api/nodes/Node.Child.md) field to be executed and used as dynamic input values for [`specializations`](com/oracle/truffle/api/dsl/Specialization.md). The field must have package protected, protected or public visibility for the generated subclass to access the field. The field must be manually initialized. If the value was not initialized the execution of the node will fail with a [`NullPointerException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html). A field must also be annotated with [`Child`](com/oracle/truffle/api/nodes/Node.Child.md) or [`Children`](com/oracle/truffle/api/nodes/Node.Children.md). **Example usage:** ```java abstract class ExpressionNode extends Node { abstract Object execute(); } abstract class AddNode extends ExpressionNode { @Child @Executed ExpressionNode leftNode; @Child @Executed ExpressionNode rightNode; AddNode(ExpressionNode leftNode, ExpressionNode rightNode) { this.leftNode = leftNode; this.rightNode = rightNode; } @Specialization protected int doAdd(int left, int right) { return left + right; } } ``` ## Elements ### with() `String[] with() default {}`. Since 0.33. The `with()` property allows a node to pass the result of one child's executable as an input to another child's executable. These referenced children must be defined before the current node in the execution order. The static field type must declare execute methods with as many arguments as there values specified for `with()`. `Frame`, `VirtualFrame` and `MaterializedFrame` instances are passed along implicitly and do not count as argument. **Example usage:**. Default: `{}`. Cite: `com/oracle/truffle/api/dsl/Executed.html#with()` ```java abstract class ExpressionNode extends Node { abstract Object execute(); } abstract class ExecuteWithTargetNode extends Node { abstract Object execute(Object target); } abstract class CallNode extends ExpressionNode { @Child @Executed ExpressionNode targetNode; @Child @Executed(with = "targetNode") ExecuteWithTargetNode readProperty; CallNode(ExpressionNode targetNode, ExecuteWithTargetNode readProperty) { this.targetNode = targetNode; this.readProperty = readProperty; } @Specialization protected Object doCall(Object target, Object property) { // targetNode is executed once and its value is usable in readProperty } } ``` # @ Fallback [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 0.8 or earlier. ```java @Retention(CLASS) @Target({METHOD}) public @interface Fallback ``` A method annotated with [`Fallback`](com/oracle/truffle/api/dsl/Fallback.md) is treated as a [`Specialization`](com/oracle/truffle/api/dsl/Specialization.md) that implicitly links all the guards of all other declared [`Specialization`](com/oracle/truffle/api/dsl/Specialization.md) annotated methods of the operation in a negated form. As a consequence it cannot declare any other guards. The expected signature of the method must match to the signature of a [`Specialization`](com/oracle/truffle/api/dsl/Specialization.md) with the additional limitation that only generically executable argument types are allowed. A generically executable argument is an argument that can be executed from the child [`Node`](com/oracle/truffle/api/nodes/Node.md) using an execute method without [`UnsupportedOperationException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/UnsupportedOperationException.html). In many cases the generically executable type is [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html). An operation is limited to just one [`Fallback`](com/oracle/truffle/api/dsl/Fallback.md) specialization which is always ordered at the end of the specialization chain. A simple example showing the use of the [`Fallback`](com/oracle/truffle/api/dsl/Fallback.md) annotation in a DSL operation: ```java @Specialization int doInt(int a) {..} @Specialization int doDouble(double a) {..} @Fallback int orElse(Object a) {..} ``` The previous example could be redeclared just using [`Specialization`](com/oracle/truffle/api/dsl/Specialization.md) annotated methods as follows: ```java @Specialization int doInt(int a) {..} @Specialization int doDouble(double a) {..} @Specialization(guard={"!isInt(a)", "!isDouble(a)"}) int orElse(Object a) {..} ``` **Performance note:** For operations with a lot of [`Specialization`](com/oracle/truffle/api/dsl/Specialization.md) annotated methods the use of [`Fallback`](com/oracle/truffle/api/dsl/Fallback.md) might generate a guard that is very big. Try to avoid the use of [`Fallback`](com/oracle/truffle/api/dsl/Fallback.md) for specializations that are significantly important for peak performance. Fallback annotated methods support [`Cached`](com/oracle/truffle/api/dsl/Cached.md), [`Bind`](com/oracle/truffle/api/dsl/Bind.md) and dispatched [`com.oracle.truffle.api.library.CachedLibrary`](com/oracle/truffle/api/library/CachedLibrary.md). **See also** - [`Specialization`](com/oracle/truffle/api/dsl/Specialization.md) - [`NodeChild`](com/oracle/truffle/api/dsl/NodeChild.md) # @ GenerateAOT [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 21.1. ```java @Retention(CLASS) @Target({TYPE}) public @interface GenerateAOT ``` Allows nodes with specializations to be prepared for AOT. The annotation is automatically inherited by all subclasses. Specializations of annotated nodes will be validated for their suitability for AOT preparation. By default all specializations that are not [`replaced`](com/oracle/truffle/api/dsl/Specialization.md#replaces%28%29) by an AOT capable specializations are included for AOT validation and preparation. If a specialization is not suitable a compilation error will be shown. The following properties make a specialization incapable of being used for AOT preparation: - Dynamic parameters bound in cached initializers. At AOT preparation time no dynamic parameters are available, therefore the caches not be initialized. Values read from the node instance are supported. - If a Truffle library is used that is automatically dispatched or where the expression initializer is bound to a dynamic parameter value. - If a cached node is created that does not itself support [`GenerateAOT`](com/oracle/truffle/api/dsl/GenerateAOT.md). Additionally, to resolve compilation errors related to AOT the following resolutions may be applied: - Exclude this specialization from AOT with [`Exclude`](com/oracle/truffle/api/dsl/GenerateAOT.Exclude.md), if it is acceptable to deoptimize for this specialization in AOT compiled code. - Configure the specialization to be [`Specialization.replaces()`](com/oracle/truffle/api/dsl/Specialization.md#replaces%28%29) with a more generic specialization. After a node generates code for AOT preparation [`AOTSupport.prepareForAOT(RootNode)`](com/oracle/truffle/api/dsl/AOTSupport.md#prepareForAOT%28com.oracle.truffle.api.nodes.RootNode%29) may be used to prepare a root node in [`RootNode.prepareForAOT`](com/oracle/truffle/api/nodes/RootNode.md#prepareForAOT%28%29). This annotation can also be used for classes annotated with Truffle library declarations and exports. The same rules, as described here, for specializations declared in exported libraries apply. Multiple AOT exports may be specified for each library, but there must be at least one, otherwise an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) is thrown at runtime when AOT is prepared. See also the [usage tutorial](https://github.com/oracle/graal/blob/master/truffle/docs/AOT.md) on the website. **See also** - [`RootNode.prepareForAOT`](com/oracle/truffle/api/nodes/RootNode.md#prepareForAOT%28%29) ## Nested types - [`GenerateAOT.Exclude`](com/oracle/truffle/api/dsl/GenerateAOT.Exclude.md) (annotation interface): Excludes the annotated Specialization from AOT preparation. - [`GenerateAOT.Provider`](com/oracle/truffle/api/dsl/GenerateAOT.Provider.md) (interface): Implemented by generated code. # @ GenerateAOT.Exclude [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 21.1. Nested in [`GenerateAOT`](com/oracle/truffle/api/dsl/GenerateAOT.md). ```java @Retention(CLASS) @Target({METHOD}) public @interface GenerateAOT.Exclude ``` Excludes the annotated [`Specialization`](com/oracle/truffle/api/dsl/Specialization.md) from AOT preparation. # ◇ GenerateAOT.Provider [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 21.1. Nested in [`GenerateAOT`](com/oracle/truffle/api/dsl/GenerateAOT.md). ```java public interface GenerateAOT.Provider ``` Implemented by generated code. Do not reference directly ## Methods ### prepareForAOT(TruffleLanguage, RootNode) `default void prepareForAOT(TruffleLanguage language, RootNode root)`. Since 21.1. Called and implemented by framework code. Do not use directly. Cite: `com/oracle/truffle/api/dsl/GenerateAOT.Provider.html#prepareForAOT(com.oracle.truffle.api.TruffleLanguage,com.oracle.truffle.api.nodes.RootNode)` ### prepareForAOT(TruffleLanguage, RootNode, Node) `default void prepareForAOT(TruffleLanguage language, RootNode root, Node inlinedNode)`. Since 23.0. Called and implemented by framework code. Do not use directly. Cite: `com/oracle/truffle/api/dsl/GenerateAOT.Provider.html#prepareForAOT(com.oracle.truffle.api.TruffleLanguage,com.oracle.truffle.api.nodes.RootNode,com.oracle.truffle.api.nodes.Node)` # @ GenerateCached [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 23.0. ```java @Retention(CLASS) @Target({TYPE}) public @interface GenerateCached ``` Allows to enable or disable the generation of the cached version of a Truffle DSL node. By default any node generates a cached version of a node if it contains [`specialization methods`](com/oracle/truffle/api/dsl/Specialization.md). The cached version of a node is accessed through a generated class that is named with the suffix Gen of the source node. For example if the node containing specializations is named `TestNode` the generated node will be called `TestNodeGen`. Any node where generated cached is enabled will contain a `create` method. This annotation is useful if only an [`uncached`](com/oracle/truffle/api/dsl/GenerateUncached.md) or [`inlinable`](com/oracle/truffle/api/dsl/GenerateInline.md) version of the node should be generated. It also allows to disable code generation for abstract [`nodes`](com/oracle/truffle/api/nodes/Node.md) with specializations that should not generate code. ## Elements ### value() `boolean value() default true`. Since 23.0. If `true` enables the generation of a cached version of this `specializing` node. It is enabled by default. Default: `true`. Cite: `com/oracle/truffle/api/dsl/GenerateCached.html#value()` ### inherit() `boolean inherit() default false`. Since 23.0. If `true` enables inheritance of `value()` and `alwaysInlineCached()` to subclasses. It is `false` by default. Default: `false`. Cite: `com/oracle/truffle/api/dsl/GenerateCached.html#inherit()` ### alwaysInlineCached() `boolean alwaysInlineCached() default false`. Since 23.0. Configures whether a `cached` `inlinable` node is inlined by default. By default a warning is emitted if the inline flag is not enabled explicitly. This is not necessary for nodes annotated with `GenerateInline` they must always inline their cached values, as they are otherwise themselves not inlinable. Default: `false`. Cite: `com/oracle/truffle/api/dsl/GenerateCached.html#alwaysInlineCached()` # @ GenerateInline [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 23.0. ```java @Retention(CLASS) @Target({TYPE}) public @interface GenerateInline ``` Generates code for a node that makes this node inlinable when used in [`cached`](com/oracle/truffle/api/dsl/Cached.md) parameters of [`specializations`](com/oracle/truffle/api/dsl/Specialization.md). Inlining nodes significantly reduces the footprint of cached nodes as node allocations are avoided. A node subclass must fullfill the following requirements in order to be inlinable: - All execute methods of a the node must have a [`node`](com/oracle/truffle/api/nodes/Node.md) as first parameter type. - The node has no instance fields and must not use [`NodeChild`](com/oracle/truffle/api/dsl/NodeChild.md) or [`NodeField`](com/oracle/truffle/api/dsl/NodeField.md). - The cached node types must not be recursive. Truffle DSL emits warnings if the use of this annotation is recommended. In addition to inlining nodes automatically using this annotation, manually written nodes can also be written to become inlinable. See [`InlineSupport`](com/oracle/truffle/api/dsl/InlineSupport.md) for details. Please see the [node object inlining tutorial](https://github.com/oracle/graal/blob/master/truffle/docs/DSLNodeObjectInlining.md) for details on how to use this annotation. **See also** - [`GenerateCached`](com/oracle/truffle/api/dsl/GenerateCached.md) - [`GenerateUncached`](com/oracle/truffle/api/dsl/GenerateUncached.md) - [`GenerateAOT`](com/oracle/truffle/api/dsl/GenerateAOT.md) - [`InlineSupport`](com/oracle/truffle/api/dsl/InlineSupport.md) ## Elements ### value() `boolean value() default true`. Since 23.0. If `true` enables the generation of a inlined version of this `specializing` node. It is enabled by default. Default: `true`. Cite: `com/oracle/truffle/api/dsl/GenerateInline.html#value()` ### inherit() `boolean inherit() default false`. Since 23.0. If `true` enables inheritance of `value()` and `inlineByDefault()` to subclasses. It is `false` by default. Default: `false`. Cite: `com/oracle/truffle/api/dsl/GenerateInline.html#inherit()` ### inlineByDefault() `boolean inlineByDefault() default false`. Since 23.0. If `true` the inlined version is used by default when the node is used as a `cached` argument. Changing this value on an existing node class with existing and already compiled usages will not force the recompilation of the usages. One has to manually force recompilation of all the affected code. If the node class is part of supported public API, changing this value is a **source incompatible change**! Default: `false`. Cite: `com/oracle/truffle/api/dsl/GenerateInline.html#inlineByDefault()` # @ GenerateNodeFactory [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 23.0. ```java @Retention(CLASS) @Target({TYPE}) public @interface GenerateNodeFactory ``` Annotate nodes or base classes of nodes to generate factory handlers implementing the [`NodeFactory`](com/oracle/truffle/api/dsl/NodeFactory.md) interface. The generated factory handlers class name starts with the source original class and ends with 'Factory'. ## Elements ### value() `boolean value() default true`. Since 23.0. If `true` enables the generation of node factories of this `specializing` node. It is disabled by default. Default: `true`. Cite: `com/oracle/truffle/api/dsl/GenerateNodeFactory.html#value()` ### inherit() `boolean inherit() default true`. Since 23.0. Inherits the semantics of the annotation to subclasses. Default: `true`. Cite: `com/oracle/truffle/api/dsl/GenerateNodeFactory.html#inherit()` # @ GeneratePackagePrivate [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 22.1. ```java @Retention(CLASS) @Target({TYPE}) public @interface GeneratePackagePrivate ``` Make the code generated for an annotated [`node`](com/oracle/truffle/api/nodes/Node.md) package-private. # @ GenerateUncached [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 19.0. ```java @Retention(CLASS) @Target({TYPE}) public @interface GenerateUncached ``` Generates an uncached version of a node with specializations. Uncached versions of nodes don't specialize and don't use any profiling state. This allows to store them statically and to use them whenever no specialization/profiling is desired. The uncached version of the node is accessible using a static method called `getUncached()` on the generated node. GenerateUncached is inherited to subclasses if [`inherit()`](com/oracle/truffle/api/dsl/GenerateUncached.md#inherit%28%29) is set to `true` (default `false`). A node subclass must fullfill the following requirements in order to be uncachable: - At least one specialization and one execute method must be specified. - The node has no instance fields. - All [`Cached`](com/oracle/truffle/api/dsl/Cached.md) parameters provide valid [uncached](com/oracle/truffle/api/dsl/Cached.md#uncached%28%29) initializers. - All guards/cache/limit expressions must not bind the node receiver. If any of these requirements are violated then an error will be shown. If node uses the [`NodeChild`](com/oracle/truffle/api/dsl/NodeChild.md) or [`NodeField`](com/oracle/truffle/api/dsl/NodeField.md) annotations then they will return constant `null` or the primitive equivalent for the uncached node. \* By default every specialization is included for [`GenerateUncached`](com/oracle/truffle/api/dsl/GenerateUncached.md), except specializations that require a [`limit`](com/oracle/truffle/api/dsl/Specialization.md#limit%28%29) and are [`replaced`](com/oracle/truffle/api/dsl/Specialization.md#replaces%28%29), those are excluded by default. By setting [`Specialization.excludeForUncached()`](com/oracle/truffle/api/dsl/Specialization.md#excludeForUncached%28%29) explicitly the default behavior can be overridden, e.g. to include or exclude a specialization for uncached. **Example:** ```java @GenerateUncached abstract static class UncachableNode extends Node { abstract Object execute(Object arg); @Specialization(guards = "v == cachedV", limit = "3") static Object doCached(int v, @Cached("v") int cachedV) { // do cached } @Specialization(replaces = "doCached") static String doGeneric(int v) { // do uncached } } ``` This node produces the following uncached version of the execute method: ```java @Override Object execute(Object arg0Value) { if (arg0Value instanceof Integer) { int arg0Value_ = (int) arg0Value; return UncachableNode.doGeneric(arg0Value_); } throw new UnsupportedSpecializationException(this, new Node[]{null}, arg0Value); } ``` Note that the `doCached` specialization is removed from the uncached version by default. This behavior can be customized by setting [`Specialization.excludeForUncached()`](com/oracle/truffle/api/dsl/Specialization.md#excludeForUncached%28%29). **See also** - [`Cached`](com/oracle/truffle/api/dsl/Cached.md) - [`Specialization.excludeForUncached()`](com/oracle/truffle/api/dsl/Specialization.md#excludeForUncached%28%29) ## Elements ### value() `boolean value() default true`. Since 19.0. If `true` enables the generation of an uncached version of this `specializing` node. It is disabled by default. Default: `true`. Cite: `com/oracle/truffle/api/dsl/GenerateUncached.html#value()` ### inherit() `boolean inherit() default false`. Since 19.1.0. Inherits the semantics of the annotation to subclasses. Default: `false`. Cite: `com/oracle/truffle/api/dsl/GenerateUncached.html#inherit()` # @ GeneratedBy [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 0.8 or earlier. ```java @Retention(RUNTIME) @Target({TYPE}) public @interface GeneratedBy ``` Marks a type as being generated based on another class or method of a class. ## Elements ### value() `Class value()`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/dsl/GeneratedBy.html#value()` ### methodName() `String methodName() default ""`. Since 0.8 or earlier. Default: `""`. Cite: `com/oracle/truffle/api/dsl/GeneratedBy.html#methodName()` # @ Idempotent [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 23.0. ```java @Retention(CLASS) @Target({METHOD}) public @interface Idempotent ``` Methods annotated with [`Idempotent`](com/oracle/truffle/api/dsl/Idempotent.md) must be methods that may cause side effects but will always cause the same side effects for repeated invocations with the same parameters. From this follows that an idempotent method must return the same result after it was executed once for each consecutive execution given the same parameters. Truffle DSL uses this property to execute [`guards`](com/oracle/truffle/api/dsl/Specialization.md#guards%28%29) where all bound methods are idempotent once on the slow-path, during specialization, and never on the fast-path. By default, all methods that do not bind dynamic parameters are interpreted as idempotent for compatibility reasons. The DSL emits warnings whenever a method should be annotated either with [`Idempotent`](com/oracle/truffle/api/dsl/Idempotent.md) or [`NonIdempotent`](com/oracle/truffle/api/dsl/NonIdempotent.md). Note that guards that bind dynamic parameters will never be idempotent in the fast-path, so the DSL will not require annotations for such guards. Examples for non-idempotent methods are: - [`ContextThreadLocal.get()`](com/oracle/truffle/api/ContextThreadLocal.md#get%28%29) - [`Assumption.isValid()`](com/oracle/truffle/api/Assumption.md#isValid%28%29) - [`Assumption.isValidAssumption(Assumption)`](com/oracle/truffle/api/Assumption.md#isValidAssumption%28com.oracle.truffle.api.Assumption%29) - [`Assumption.isValidAssumption(Assumption[])`](com/oracle/truffle/api/Assumption.md#isValidAssumption%28com.oracle.truffle.api.Assumption[]%29) - [`ContextLocal.get()`](com/oracle/truffle/api/ContextLocal.md#get%28%29) if the language uses a context policy [`ContextPolicy.REUSE`](com/oracle/truffle/api/TruffleLanguage.ContextPolicy.md#REUSE) or [`ContextPolicy.SHARED`](com/oracle/truffle/api/TruffleLanguage.ContextPolicy.md#SHARED) Examples for idempotent methods are: - [`LanguageReference.get(Node)`](com/oracle/truffle/api/TruffleLanguage.LanguageReference.md#get%28com.oracle.truffle.api.nodes.Node%29) - [`DirectCallNode.getCallTarget()`](com/oracle/truffle/api/nodes/DirectCallNode.md#getCallTarget%28%29) - [`ContextLocal.get()`](com/oracle/truffle/api/ContextLocal.md#get%28%29) if the language uses context policy [`ContextPolicy.EXCLUSIVE`](com/oracle/truffle/api/TruffleLanguage.ContextPolicy.md#EXCLUSIVE). Note that usages may assume that the current language instance never changes for a given Node. Therefore it is safe to assume language reference accesses idempotent. **See also** - [`NonIdempotent`](com/oracle/truffle/api/dsl/NonIdempotent.md) # @ ImplicitCast [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 0.8 or earlier. ```java @Retention(CLASS) @Target({METHOD}) public @interface ImplicitCast ``` Marks an implicit cast method. Implicit cast methods are expected to have a return type, the target type and a source type the first parameter type. Any other method signature is not allowed. The source and target type must not be the same type. The order of implicit casts determines the order in which they are checked. This is important to optimize performance but also to provide a precedence for ambiguous type checks. Example usage: ```java @TypeSystem public static class ExampleTypeSystem { @ImplicitCast public static double castInt(int value) { return value; } @ImplicitCast public static double castShort(short value) { return value; } } ``` For details on how to use implicit casts see [`TypeSystem`](com/oracle/truffle/api/dsl/TypeSystem.md). **See also** - [`TypeSystem`](com/oracle/truffle/api/dsl/TypeSystem.md) # @ ImportStatic [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 0.8 or earlier. ```java @Retention(CLASS) @Target({TYPE}) public @interface ImportStatic ``` Imports all `public` and `static` methods and fields of the provided classes for the use in DSL expressions of the annotated class or its subclasses. **See also** - [`Specialization.guards()`](com/oracle/truffle/api/dsl/Specialization.md#guards%28%29) - [`Specialization.assumptions()`](com/oracle/truffle/api/dsl/Specialization.md#assumptions%28%29) - [`Specialization.limit()`](com/oracle/truffle/api/dsl/Specialization.md#limit%28%29) - [`Cached`](com/oracle/truffle/api/dsl/Cached.md) ## Elements ### value() `Class[] value()`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/dsl/ImportStatic.html#value()` # ◆ InlineSupport [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 23.0. ```java public final class InlineSupport ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `InlineSupport` Contains classes to support node object inlining in Truffle. These classes are only needed if manual node inlining is implemented. Typically Truffle DSL's [`GenerateInline`](com/oracle/truffle/api/dsl/GenerateInline.md) takes care of applying these APIs correctly. For manual usage see [`com.oracle.truffle.api.profiles.InlinedBranchProfile`](com/oracle/truffle/api/profiles/InlinedBranchProfile.md) as an example. **See also** - [`GenerateInline`](com/oracle/truffle/api/dsl/GenerateInline.md) ## Nested types - [`InlineSupport.BooleanField`](com/oracle/truffle/api/dsl/InlineSupport.BooleanField.md) (class): Represents a field for boolean primitives in inlined nodes. - [`InlineSupport.ByteField`](com/oracle/truffle/api/dsl/InlineSupport.ByteField.md) (class): Represents a field for byte primitives in inlined nodes. - [`InlineSupport.CharField`](com/oracle/truffle/api/dsl/InlineSupport.CharField.md) (class): Represents a field for char primitives in inlined nodes. - [`InlineSupport.DoubleField`](com/oracle/truffle/api/dsl/InlineSupport.DoubleField.md) (class): Represents a field for double primitives in inlined nodes. - [`InlineSupport.FloatField`](com/oracle/truffle/api/dsl/InlineSupport.FloatField.md) (class): Represents a field for float primitives in inlined nodes. - [`InlineSupport.InlinableField`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md) (abstract class): Base class for inlined field references. - [`InlineSupport.InlineTarget`](com/oracle/truffle/api/dsl/InlineSupport.InlineTarget.md) (class): An inline targert for an inlinable node. - [`InlineSupport.IntField`](com/oracle/truffle/api/dsl/InlineSupport.IntField.md) (class): Represents a field for int primitives in inlined nodes. - [`InlineSupport.LongField`](com/oracle/truffle/api/dsl/InlineSupport.LongField.md) (class): Represents a field for long primitives in inlined nodes. - [`InlineSupport.ReferenceField`](com/oracle/truffle/api/dsl/InlineSupport.ReferenceField.md) (class): Represents a field for references in inlined nodes. - [`InlineSupport.RequiredField`](com/oracle/truffle/api/dsl/InlineSupport.RequiredField.md) (annotation interface): Used to specify fields for node object inlining in inline methods for the inline target. - [`InlineSupport.RequiredFields`](com/oracle/truffle/api/dsl/InlineSupport.RequiredFields.md) (annotation interface): Used to specify multiple RequiredField. - [`InlineSupport.ShortField`](com/oracle/truffle/api/dsl/InlineSupport.ShortField.md) (class): Represents a field for short primitives in inlined nodes. - [`InlineSupport.StateField`](com/oracle/truffle/api/dsl/InlineSupport.StateField.md) (class): Represents a field for updating state fields in inlined nodes. - [`InlineSupport.UnsafeAccessedField`](com/oracle/truffle/api/dsl/InlineSupport.UnsafeAccessedField.md) (annotation interface): Marks a field to be accessed with unsafe. ## Methods ### validate(Node, InlineSupport.InlinableField, …) `public static boolean validate(Node node, InlineSupport.InlinableField field0, InlineSupport.InlinableField field1, InlineSupport.InlinableField... fields)`. Since 23.0. Shortcut to `validate` multiple inlinable fields. Cite: `com/oracle/truffle/api/dsl/InlineSupport.html#validate(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.dsl.InlineSupport.InlinableField,com.oracle.truffle.api.dsl.InlineSupport.InlinableField,com.oracle.truffle.api.dsl.InlineSupport.InlinableField...)` ### validate(Node, InlineSupport.InlinableField, InlineSupport.InlinableField) `public static boolean validate(Node node, InlineSupport.InlinableField field0, InlineSupport.InlinableField field1)`. Since 23.0. Shortcut to `validate` multiple inlinable fields. Cite: `com/oracle/truffle/api/dsl/InlineSupport.html#validate(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.dsl.InlineSupport.InlinableField,com.oracle.truffle.api.dsl.InlineSupport.InlinableField)` ### validate(Node, InlineSupport.InlinableField) `public static boolean validate(Node node, InlineSupport.InlinableField field0)`. Since 23.0. Shortcut to `validate` multiple inlinable fields. Cite: `com/oracle/truffle/api/dsl/InlineSupport.html#validate(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.dsl.InlineSupport.InlinableField)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ InlineSupport.BooleanField [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 23.0. Nested in [`InlineSupport`](com/oracle/truffle/api/dsl/InlineSupport.md). ```java public static final class InlineSupport.BooleanField extends InlineSupport.InlinableField ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `InlineSupport.UnsafeField` > [`InlineSupport.InlinableField`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md) > `BooleanField` Represents a field for boolean primitives in inlined nodes. ## Methods ### get(Node) `public boolean get(Node node)`. Since 23.0. This method returns the value of the target field given a target node. The node parameter must match the class the field was created with. If the type is not compatible, an [`ClassCastException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ClassCastException.html) is thrown. If `null` is provided, then a [`NullPointerException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) is thrown. Cite: `com/oracle/truffle/api/dsl/InlineSupport.BooleanField.html#get(com.oracle.truffle.api.nodes.Node)` ### set(Node, boolean) `public void set(Node node, boolean value)`. Since 23.0. This method sets the value of the target field giving the a target node. The node parameter must match the class the field was created with. If the type is not compatible, an [`ClassCastException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ClassCastException.html) is thrown. If `null` is provided, then a [`NullPointerException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) is thrown. Cite: `com/oracle/truffle/api/dsl/InlineSupport.BooleanField.html#set(com.oracle.truffle.api.nodes.Node,boolean)` ### create(MethodHandles.Lookup, String) `public static InlineSupport.BooleanField create(MethodHandles.Lookup declaringLookup, String field)`. Since 23.0. This method creates a new field given a lookup class and a field name. The lookup class requires access to the field and must be directly accessible. If the field is not found or the field type is not compatible, then an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. The given field must not be final. This method is intended to be used by DSL-generated code only. Cite: `com/oracle/truffle/api/dsl/InlineSupport.BooleanField.html#create(java.lang.invoke.MethodHandles.Lookup,java.lang.String)` ## Inherited members - From class [`InlineSupport.InlinableField`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md): [`validate`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md#validate%28com.oracle.truffle.api.nodes.Node%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ InlineSupport.ByteField [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 23.0. Nested in [`InlineSupport`](com/oracle/truffle/api/dsl/InlineSupport.md). ```java public static final class InlineSupport.ByteField extends InlineSupport.InlinableField ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `InlineSupport.UnsafeField` > [`InlineSupport.InlinableField`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md) > `ByteField` Represents a field for byte primitives in inlined nodes. ## Methods ### get(Node) `public byte get(Node node)`. Since 23.0. This method returns the value of the target field given a target node. The node parameter must match the class the field was created with. If the type is not compatible, an [`ClassCastException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ClassCastException.html) is thrown. If `null` is provided, then a [`NullPointerException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) is thrown. Cite: `com/oracle/truffle/api/dsl/InlineSupport.ByteField.html#get(com.oracle.truffle.api.nodes.Node)` ### set(Node, byte) `public void set(Node node, byte value)`. Since 23.0. This method sets the value of the target field giving the a target node. The node parameter must match the class the field was created with. If the type is not compatible, an [`ClassCastException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ClassCastException.html) is thrown. If `null` is provided, then a [`NullPointerException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) is thrown. Cite: `com/oracle/truffle/api/dsl/InlineSupport.ByteField.html#set(com.oracle.truffle.api.nodes.Node,byte)` ### create(MethodHandles.Lookup, String) `public static InlineSupport.ByteField create(MethodHandles.Lookup declaringLookup, String field)`. Since 23.0. This method creates a new field given a lookup class and a field name. The lookup class requires access to the field and must be directly accessible. If the field is not found or the field type is not compatible, then an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. The given field must not be final. This method is intended to be used by DSL-generated code only. Cite: `com/oracle/truffle/api/dsl/InlineSupport.ByteField.html#create(java.lang.invoke.MethodHandles.Lookup,java.lang.String)` ## Inherited members - From class [`InlineSupport.InlinableField`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md): [`validate`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md#validate%28com.oracle.truffle.api.nodes.Node%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ InlineSupport.CharField [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 23.0. Nested in [`InlineSupport`](com/oracle/truffle/api/dsl/InlineSupport.md). ```java public static final class InlineSupport.CharField extends InlineSupport.InlinableField ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `InlineSupport.UnsafeField` > [`InlineSupport.InlinableField`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md) > `CharField` Represents a field for char primitives in inlined nodes. ## Methods ### get(Node) `public char get(Node node)`. Since 23.0. This method returns the value of the target field given a target node. The node parameter must match the class the field was created with. If the type is not compatible, an [`ClassCastException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ClassCastException.html) is thrown. If `null` is provided, then a [`NullPointerException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) is thrown. Cite: `com/oracle/truffle/api/dsl/InlineSupport.CharField.html#get(com.oracle.truffle.api.nodes.Node)` ### set(Node, char) `public void set(Node node, char value)`. Since 23.0. This method sets the value of the target field giving the a target node. The node parameter must match the class the field was created with. If the type is not compatible, an [`ClassCastException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ClassCastException.html) is thrown. If `null` is provided, then a [`NullPointerException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) is thrown. Cite: `com/oracle/truffle/api/dsl/InlineSupport.CharField.html#set(com.oracle.truffle.api.nodes.Node,char)` ### create(MethodHandles.Lookup, String) `public static InlineSupport.CharField create(MethodHandles.Lookup declaringLookup, String field)`. Since 23.0. This method creates a new field given a lookup class and a field name. The lookup class requires access to the field and must be directly accessible. If the field is not found or the field type is not compatible, then an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. The given field must not be final. This method is intended to be used by DSL-generated code only. Cite: `com/oracle/truffle/api/dsl/InlineSupport.CharField.html#create(java.lang.invoke.MethodHandles.Lookup,java.lang.String)` ## Inherited members - From class [`InlineSupport.InlinableField`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md): [`validate`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md#validate%28com.oracle.truffle.api.nodes.Node%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ InlineSupport.DoubleField [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 23.0. Nested in [`InlineSupport`](com/oracle/truffle/api/dsl/InlineSupport.md). ```java public static final class InlineSupport.DoubleField extends InlineSupport.InlinableField ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `InlineSupport.UnsafeField` > [`InlineSupport.InlinableField`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md) > `DoubleField` Represents a field for double primitives in inlined nodes. ## Methods ### get(Node) `public double get(Node node)`. Since 23.0. This method returns the value of the target field given a target node. The node parameter must match the class the field was created with. If the type is not compatible, an [`ClassCastException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ClassCastException.html) is thrown. If `null` is provided, then a [`NullPointerException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) is thrown. Cite: `com/oracle/truffle/api/dsl/InlineSupport.DoubleField.html#get(com.oracle.truffle.api.nodes.Node)` ### set(Node, double) `public void set(Node node, double value)`. Since 23.0. This method sets the value of the target field giving the a target node. The node parameter must match the class the field was created with. If the type is not compatible, an [`ClassCastException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ClassCastException.html) is thrown. If `null` is provided, then a [`NullPointerException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) is thrown. Cite: `com/oracle/truffle/api/dsl/InlineSupport.DoubleField.html#set(com.oracle.truffle.api.nodes.Node,double)` ### create(MethodHandles.Lookup, String) `public static InlineSupport.DoubleField create(MethodHandles.Lookup declaringLookup, String field)`. Since 23.0. This method creates a new field given a lookup class and a field name. The lookup class requires access to the field and must be directly accessible. If the field is not found or the field type is not compatible, then an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. The given field must not be final. This method is intended to be used by DSL-generated code only. Cite: `com/oracle/truffle/api/dsl/InlineSupport.DoubleField.html#create(java.lang.invoke.MethodHandles.Lookup,java.lang.String)` ## Inherited members - From class [`InlineSupport.InlinableField`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md): [`validate`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md#validate%28com.oracle.truffle.api.nodes.Node%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ InlineSupport.FloatField [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 23.0. Nested in [`InlineSupport`](com/oracle/truffle/api/dsl/InlineSupport.md). ```java public static final class InlineSupport.FloatField extends InlineSupport.InlinableField ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `InlineSupport.UnsafeField` > [`InlineSupport.InlinableField`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md) > `FloatField` Represents a field for float primitives in inlined nodes. ## Methods ### get(Node) `public float get(Node node)`. Since 23.0. This method returns the value of the target field given a target node. The node parameter must match the class the field was created with. If the type is not compatible, an [`ClassCastException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ClassCastException.html) is thrown. If `null` is provided, then a [`NullPointerException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) is thrown. Cite: `com/oracle/truffle/api/dsl/InlineSupport.FloatField.html#get(com.oracle.truffle.api.nodes.Node)` ### set(Node, float) `public void set(Node node, float value)`. Since 23.0. This method sets the value of the target field giving the a target node. The node parameter must match the class the field was created with. If the type is not compatible, an [`ClassCastException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ClassCastException.html) is thrown. If `null` is provided, then a [`NullPointerException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) is thrown. Cite: `com/oracle/truffle/api/dsl/InlineSupport.FloatField.html#set(com.oracle.truffle.api.nodes.Node,float)` ### create(MethodHandles.Lookup, String) `public static InlineSupport.FloatField create(MethodHandles.Lookup declaringLookup, String field)`. Since 23.0. This method creates a new field given a lookup class and a field name. The lookup class requires access to the field and must be directly accessible. If the field is not found or the field type is not compatible, then an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. The given field must not be final. This method is intended to be used by DSL-generated code only. Cite: `com/oracle/truffle/api/dsl/InlineSupport.FloatField.html#create(java.lang.invoke.MethodHandles.Lookup,java.lang.String)` ## Inherited members - From class [`InlineSupport.InlinableField`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md): [`validate`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md#validate%28com.oracle.truffle.api.nodes.Node%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ InlineSupport.InlinableField [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 23.0. Nested in [`InlineSupport`](com/oracle/truffle/api/dsl/InlineSupport.md). ```java public abstract static class InlineSupport.InlinableField extends InlineSupport.UnsafeField ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `InlineSupport.UnsafeField` > `InlinableField` Base class for inlined field references. ## Methods ### validate(Node) `public final boolean validate(Node node)`. Since 23.0. Validates a receiver of an inlined field. This is used for generated DSL code to fail early for usage mistakes. Cite: `com/oracle/truffle/api/dsl/InlineSupport.InlinableField.html#validate(com.oracle.truffle.api.nodes.Node)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ InlineSupport.InlineTarget [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 23.0. Nested in [`InlineSupport`](com/oracle/truffle/api/dsl/InlineSupport.md). ```java public static final class InlineSupport.InlineTarget ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `InlineTarget` An inline targert for an inlinable node. This is used as first parameter of an inline method. The inline method is used by generated Truffle DSL code as well as manually written inlinable nodes. Usage example: ```java public static InlinedCountingConditionProfile inline( @RequiredField(value = StateField.class, bits = 7) // @RequiredField(value = PrimitiveIntField.class) // @RequiredField(value = ReferenceField.class, type = String.class) InlineTarget target) { StateField state = target.getState(0, 7); PrimitiveIntField primitive = target.getPrimitive(1, PrimitiveIntField.class); ReferenceField reference = target.getReference(2, String.class); // pass fields on to inline node } ``` ## Methods ### getTargetClass() `public Class getTargetClass()`. Since 23.0. Returns static target class this inlining specification was applied. Cite: `com/oracle/truffle/api/dsl/InlineSupport.InlineTarget.html#getTargetClass()` ### getPrimitive(int, Class) `public T getPrimitive(int index, Class fieldClass)`. Since 23.0. Requests a primitive field for a given field index. Fields that are requested from a target must match the required fields specified using `RequiredField` on the target parameter of an inline method otherwise an [`IncompatibleClassChangeError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IncompatibleClassChangeError.html) is thrown. Cite: `com/oracle/truffle/api/dsl/InlineSupport.InlineTarget.html#getPrimitive(int,java.lang.Class)` ### getState(int, int) `public InlineSupport.StateField getState(int index, int minimumBits)`. Since 23.0. Requests a state field for a given field index. Fields that are requested from a target must match the required fields specified using `RequiredField` on the target parameter of an inline method otherwise an [`IncompatibleClassChangeError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IncompatibleClassChangeError.html) is thrown. Cite: `com/oracle/truffle/api/dsl/InlineSupport.InlineTarget.html#getState(int,int)` ### getReference(int, Class) `public InlineSupport.ReferenceField getReference(int index, Class valueClass)`. Since 23.0. Requests a reference field for a given field index. Fields that are requested from a target must match the required fields specified using `RequiredField` on the target parameter of an inline method otherwise an [`IncompatibleClassChangeError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IncompatibleClassChangeError.html) is thrown. Cite: `com/oracle/truffle/api/dsl/InlineSupport.InlineTarget.html#getReference(int,java.lang.Class)` ### create(Class, InlineSupport.InlinableField...) `public static InlineSupport.InlineTarget create(Class targetClass, InlineSupport.InlinableField... updaters)`. Since 23.0. Creates an inline target for an inlined node. Intended for use by generated code only. Cite: `com/oracle/truffle/api/dsl/InlineSupport.InlineTarget.html#create(java.lang.Class,com.oracle.truffle.api.dsl.InlineSupport.InlinableField...)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ InlineSupport.IntField [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 23.0. Nested in [`InlineSupport`](com/oracle/truffle/api/dsl/InlineSupport.md). ```java public static final class InlineSupport.IntField extends InlineSupport.InlinableField ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `InlineSupport.UnsafeField` > [`InlineSupport.InlinableField`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md) > `IntField` Represents a field for int primitives in inlined nodes. ## Methods ### get(Node) `public int get(Node node)`. Since 23.0. This method returns the value of the target field given a target node. The node parameter must match the class the field was created with. If the type is not compatible, an [`ClassCastException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ClassCastException.html) is thrown. If `null` is provided, then a [`NullPointerException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) is thrown. Cite: `com/oracle/truffle/api/dsl/InlineSupport.IntField.html#get(com.oracle.truffle.api.nodes.Node)` ### set(Node, int) `public void set(Node node, int value)`. Since 23.0. This method sets the value of the target field giving the a target node. The node parameter must match the class the field was created with. If the type is not compatible, an [`ClassCastException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ClassCastException.html) is thrown. If `null` is provided, then a [`NullPointerException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) is thrown. Cite: `com/oracle/truffle/api/dsl/InlineSupport.IntField.html#set(com.oracle.truffle.api.nodes.Node,int)` ### create(MethodHandles.Lookup, String) `public static InlineSupport.IntField create(MethodHandles.Lookup declaringLookup, String field)`. Since 23.0. This method creates a new field given a lookup class and a field name. The lookup class requires access to the field and must be directly accessible. If the field is not found or the field type is not compatible, then an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. The given field must not be final. This method is intended to be used by DSL-generated code only. Cite: `com/oracle/truffle/api/dsl/InlineSupport.IntField.html#create(java.lang.invoke.MethodHandles.Lookup,java.lang.String)` ## Inherited members - From class [`InlineSupport.InlinableField`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md): [`validate`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md#validate%28com.oracle.truffle.api.nodes.Node%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ InlineSupport.LongField [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 23.0. Nested in [`InlineSupport`](com/oracle/truffle/api/dsl/InlineSupport.md). ```java public static final class InlineSupport.LongField extends InlineSupport.InlinableField ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `InlineSupport.UnsafeField` > [`InlineSupport.InlinableField`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md) > `LongField` Represents a field for long primitives in inlined nodes. ## Methods ### get(Node) `public long get(Node node)`. Since 23.0. This method returns the value of the target field given a target node. The node parameter must match the class the field was created with. If the type is not compatible, an [`ClassCastException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ClassCastException.html) is thrown. If `null` is provided, then a [`NullPointerException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) is thrown. Cite: `com/oracle/truffle/api/dsl/InlineSupport.LongField.html#get(com.oracle.truffle.api.nodes.Node)` ### set(Node, long) `public void set(Node node, long value)`. Since 23.0. This method sets the value of the target field giving the a target node. The node parameter must match the class the field was created with. If the type is not compatible, an [`ClassCastException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ClassCastException.html) is thrown. If `null` is provided, then a [`NullPointerException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) is thrown. Cite: `com/oracle/truffle/api/dsl/InlineSupport.LongField.html#set(com.oracle.truffle.api.nodes.Node,long)` ### create(MethodHandles.Lookup, String) `public static InlineSupport.LongField create(MethodHandles.Lookup declaringLookup, String field)`. Since 23.0. This method creates a new field given a lookup class and a field name. The lookup class requires access to the field and must be directly accessible. If the field is not found or the field type is not compatible, then an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. The given field must not be final. This method is intended to be used by DSL-generated code only. Cite: `com/oracle/truffle/api/dsl/InlineSupport.LongField.html#create(java.lang.invoke.MethodHandles.Lookup,java.lang.String)` ## Inherited members - From class [`InlineSupport.InlinableField`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md): [`validate`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md#validate%28com.oracle.truffle.api.nodes.Node%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ InlineSupport.ReferenceField [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 23.0. Nested in [`InlineSupport`](com/oracle/truffle/api/dsl/InlineSupport.md). ```java public static final class InlineSupport.ReferenceField extends InlineSupport.InlinableField ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `InlineSupport.UnsafeField` > [`InlineSupport.InlinableField`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md) > `ReferenceField` Represents a field for references in inlined nodes. ## Methods ### get(Node) `public T get(Node node)`. Since 23.0. This method returns the value of the target field given a target node. The node parameter must match the class the field was created with. If the type is not compatible, an [`ClassCastException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ClassCastException.html) is thrown. If `null` is provided, then a [`NullPointerException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) is thrown. Cite: `com/oracle/truffle/api/dsl/InlineSupport.ReferenceField.html#get(com.oracle.truffle.api.nodes.Node)` ### set(Node, T) `public void set(Node node, T value)`. Since 23.0. This method sets the value of the target field giving the a target node. The node parameter must match the class the field was created with. If the type is not compatible, an [`ClassCastException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ClassCastException.html) is thrown. If `null` is provided, then a [`NullPointerException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) is thrown. Cite: `com/oracle/truffle/api/dsl/InlineSupport.ReferenceField.html#set(com.oracle.truffle.api.nodes.Node,T)` ### getVolatile(Node) `public T getVolatile(Node node)`. Since 23.0. This method returns the value of the target field given a target node using volatile semantics. The node parameter must match the class the field was created with. If the type is not compatible, an [`ClassCastException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ClassCastException.html) is thrown. If `null` is provided, then a [`NullPointerException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) is thrown. Cite: `com/oracle/truffle/api/dsl/InlineSupport.ReferenceField.html#getVolatile(com.oracle.truffle.api.nodes.Node)` ### compareAndSet(Node, T, T) `public boolean compareAndSet(Node node, T expect, T update)`. Since 23.0. This method sets the value of the target field giving the a target node and expected value using compare and set semantics. The node parameter must match the class the field was created with. If the type is not compatible, an [`ClassCastException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ClassCastException.html) is thrown. If `null` is provided, then a [`NullPointerException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) is thrown. Cite: `com/oracle/truffle/api/dsl/InlineSupport.ReferenceField.html#compareAndSet(com.oracle.truffle.api.nodes.Node,T,T)` ### create(MethodHandles.Lookup, String, Class) `public static InlineSupport.ReferenceField create(MethodHandles.Lookup declaringLookup, String field, Class valueClass)`. Since 23.0. This method creates a new field given a lookup class, field name and value class. The lookup class requires access to the field and must be directly accessible. If the field is not found or the field type is not compatible, then an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. The given field must not be final. This method is intended to be used by DSL-generated code only. Cite: `com/oracle/truffle/api/dsl/InlineSupport.ReferenceField.html#create(java.lang.invoke.MethodHandles.Lookup,java.lang.String,java.lang.Class)` ## Inherited members - From class [`InlineSupport.InlinableField`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md): [`validate`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md#validate%28com.oracle.truffle.api.nodes.Node%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # @ InlineSupport.RequiredField [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 23.0. Nested in [`InlineSupport`](com/oracle/truffle/api/dsl/InlineSupport.md). ```java @Retention(CLASS) @Target({PARAMETER}) @Repeatable(com.oracle.truffle.api.dsl.InlineSupport.RequiredFields.class) public @interface InlineSupport.RequiredField ``` Used to specify fields for node object inlining in inline methods for the [`inline target`](com/oracle/truffle/api/dsl/InlineSupport.InlineTarget.md). See [`InlineTarget`](com/oracle/truffle/api/dsl/InlineSupport.InlineTarget.md) for a full usage example. ## Elements ### value() `Class value()`. Since 23.0. Species which field type is expected. See subclasses of `InlinableField`. Cite: `com/oracle/truffle/api/dsl/InlineSupport.RequiredField.html#value()` ### bits() `int bits() default 0`. Since 23.0. Specifies the number of bits needed for `state fields`. This property only has an effect for `StateField`. The number of bits must be between `1` and`32`. Default: `0`. Cite: `com/oracle/truffle/api/dsl/InlineSupport.RequiredField.html#bits()` ### type() `Class type() default com.oracle.truffle.api.dsl.InlineSupport.InlinableField.class`. Since 23.0. 90 Specifies the value type for `reference` required fields. This property only has an effect for `ReferenceField`. Default: `com.oracle.truffle.api.dsl.InlineSupport.InlinableField.class`. Cite: `com/oracle/truffle/api/dsl/InlineSupport.RequiredField.html#type()` ### dimensions() `int dimensions() default 0`. Since 23.0. Specifies the compilation final `dimensions` of the required inlined field. This property has only an effect with array types and `reference fields`. Default: `0`. Cite: `com/oracle/truffle/api/dsl/InlineSupport.RequiredField.html#dimensions()` # @ InlineSupport.RequiredFields [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 23.0. Nested in [`InlineSupport`](com/oracle/truffle/api/dsl/InlineSupport.md). ```java @Retention(CLASS) @Target({PARAMETER}) public @interface InlineSupport.RequiredFields ``` Used to specify multiple [`RequiredField`](com/oracle/truffle/api/dsl/InlineSupport.RequiredField.md). **See also** - [`RequiredField`](com/oracle/truffle/api/dsl/InlineSupport.RequiredField.md) ## Elements ### value() `InlineSupport.RequiredField[] value()`. Since 23.0. Used to specify multiple `RequiredField`. Cite: `com/oracle/truffle/api/dsl/InlineSupport.RequiredFields.html#value()` # ◆ InlineSupport.ShortField [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 23.0. Nested in [`InlineSupport`](com/oracle/truffle/api/dsl/InlineSupport.md). ```java public static final class InlineSupport.ShortField extends InlineSupport.InlinableField ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `InlineSupport.UnsafeField` > [`InlineSupport.InlinableField`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md) > `ShortField` Represents a field for short primitives in inlined nodes. ## Methods ### get(Node) `public short get(Node node)`. Since 23.0. This method returns the value of the target field given a target node. The node parameter must match the class the field was created with. If the type is not compatible, an [`ClassCastException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ClassCastException.html) is thrown. If `null` is provided, then a [`NullPointerException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) is thrown. Cite: `com/oracle/truffle/api/dsl/InlineSupport.ShortField.html#get(com.oracle.truffle.api.nodes.Node)` ### set(Node, short) `public void set(Node node, short value)`. Since 23.0. This method sets the value of the target field giving the a target node. The node parameter must match the class the field was created with. If the type is not compatible, an [`ClassCastException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ClassCastException.html) is thrown. If `null` is provided, then a [`NullPointerException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) is thrown. Cite: `com/oracle/truffle/api/dsl/InlineSupport.ShortField.html#set(com.oracle.truffle.api.nodes.Node,short)` ### create(MethodHandles.Lookup, String) `public static InlineSupport.ShortField create(MethodHandles.Lookup declaringLookup, String field)`. Since 23.0. This method creates a new field given a lookup class and a field name. The lookup class requires access to the field and must be directly accessible. If the field is not found or the field type is not compatible, then an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. The given field must not be final. This method is intended to be used by DSL-generated code only. Cite: `com/oracle/truffle/api/dsl/InlineSupport.ShortField.html#create(java.lang.invoke.MethodHandles.Lookup,java.lang.String)` ## Inherited members - From class [`InlineSupport.InlinableField`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md): [`validate`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md#validate%28com.oracle.truffle.api.nodes.Node%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ InlineSupport.StateField [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 23.0. Nested in [`InlineSupport`](com/oracle/truffle/api/dsl/InlineSupport.md). ```java public static final class InlineSupport.StateField extends InlineSupport.InlinableField ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `InlineSupport.UnsafeField` > [`InlineSupport.InlinableField`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md) > `StateField` Represents a field for updating state fields in inlined nodes. ## Methods ### subUpdater(int, int) `public InlineSupport.StateField subUpdater(int newOffset, int newLength)`. Since 23.0. Creates a sub updater for a subset of bits in a state field. This method is intended to be used by DSL-generated code only. Cite: `com/oracle/truffle/api/dsl/InlineSupport.StateField.html#subUpdater(int,int)` ### get(Node) `public int get(Node node)`. Since 23.0. This method returns the value of the target field given a target node. The node parameter must match the class the field was created with. If the type is not compatible, an [`ClassCastException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ClassCastException.html) is thrown. If `null` is provided, then a [`NullPointerException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) is thrown. Cite: `com/oracle/truffle/api/dsl/InlineSupport.StateField.html#get(com.oracle.truffle.api.nodes.Node)` ### set(Node, int) `public void set(Node node, int value)`. Since 23.0. This method sets the value of the target field giving the a target node. The node parameter must match the class the field was created with. If the type is not compatible, an [`ClassCastException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ClassCastException.html) is thrown. If `null` is provided, then a [`NullPointerException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) is thrown. Cite: `com/oracle/truffle/api/dsl/InlineSupport.StateField.html#set(com.oracle.truffle.api.nodes.Node,int)` ### create(MethodHandles.Lookup, String) `public static InlineSupport.StateField create(MethodHandles.Lookup declaringLookup, String field)`. Since 23.0. This method creates a new field given a lookup class and a field name. The lookup class requires access to the field and must be directly accessible. If the field is not found or the field type is not compatible, then an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. The given field must not be final. This method is intended to be used by DSL-generated code only. Cite: `com/oracle/truffle/api/dsl/InlineSupport.StateField.html#create(java.lang.invoke.MethodHandles.Lookup,java.lang.String)` ## Inherited members - From class [`InlineSupport.InlinableField`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md): [`validate`](com/oracle/truffle/api/dsl/InlineSupport.InlinableField.md#validate%28com.oracle.truffle.api.nodes.Node%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # @ InlineSupport.UnsafeAccessedField [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 23.0. Nested in [`InlineSupport`](com/oracle/truffle/api/dsl/InlineSupport.md). ```java @Retention(CLASS) @Target({FIELD}) public @interface InlineSupport.UnsafeAccessedField ``` Marks a field to be accessed with unsafe. This annotation is useful to communicate fields that must not be rewritten by code obfuscation tools like Proguard. # @ Introspectable [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 0.22. ```java @Retention(CLASS) @Target({TYPE}) public @interface Introspectable ``` Annotate a DSL operation using this annotation to be introspectable. The methods in [`Introspection`](com/oracle/truffle/api/dsl/Introspection.md) can only be used if the operation is annotated with [`Introspectable`](com/oracle/truffle/api/dsl/Introspectable.md). # ◆ Introspection [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 0.22. ```java public final class Introspection ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Introspection` Contains introspection utilities for Truffle DSL. The contained utilities are only usable if the operation node is annotated with [`Introspectable`](com/oracle/truffle/api/dsl/Introspectable.md). Introspection is useful for using testing the node declaration and verifying that particular specializations become active. Example for using introspection in unit testing: ```java @Introspectable abstract static class NegateNode extends Node { abstract Object execute(Object o); @Specialization(guards = "cachedvalue == value", limit = "1") protected static int doInt(int value, @Cached("value") int cachedvalue) { return -cachedvalue; } @Specialization(replaces = "doInt") protected static int doGeneric(int value) { return -value; } } public void testUsingIntrospection() { NegateNode node = null; // NegateNodeGen.create(); SpecializationInfo info; node.execute(1); info = Introspection.getSpecialization(node, "doInt"); assert info.getInstances() == 1; node.execute(1); info = Introspection.getSpecialization(node, "doInt"); assert info.getInstances() == 1; node.execute(2); info = Introspection.getSpecialization(node, "doInt"); assert info.getInstances() == 0; info = Introspection.getSpecialization(node, "doGeneric"); assert info.getInstances() == 1; } ``` **See also** - [`Introspectable`](com/oracle/truffle/api/dsl/Introspectable.md) ## Nested types - [`Introspection.Provider`](com/oracle/truffle/api/dsl/Introspection.Provider.md) (interface): Internal marker interface for DSL generated code to access reflection information. - [`Introspection.SpecializationInfo`](com/oracle/truffle/api/dsl/Introspection.SpecializationInfo.md) (class): Represents dynamic introspection information of a specialization of a DSL operation. ## Methods ### isIntrospectable(Node) `public static boolean isIntrospectable(Node node)`. Since 0.22. Returns `true` if the given node is introspectable. If something is introspectable is determined by if the node is generated by Truffle DSL, if is annotated with `Introspectable` and if the DSL implementation supports introspection. Parameters: `node` `Node`: a DSL generated node. Returns `boolean`: true if the given node is introspectable. Cite: `com/oracle/truffle/api/dsl/Introspection.html#isIntrospectable(com.oracle.truffle.api.nodes.Node)` ### getSpecialization(Node, String) `public static Introspection.SpecializationInfo getSpecialization(Node node, String methodName)`. Since 0.22. Returns introspection information for the first specialization that matches a given method name. A node must declare at least one specialization and must be annotated with `Introspectable` otherwise an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. If multiple specializations with the same method name are declared then an undefined specialization is going to be returned. In such cases disambiguate them by renaming the specialzation method name. The returned introspection information is not updated when the state of the given operation node is updated. The implementation of this method might be slow, do not use it in performance critical code. For a node was `inlined` use `getSpecialization(Node, Node, String)`. Parameters: `node` `Node`: a introspectable DSL operation with at least one specialization. `methodName` `String`: the Java method name of the specialization to introspect. Returns `Introspection.SpecializationInfo`: introspection info for the method. See also: `example usage`. Cite: `com/oracle/truffle/api/dsl/Introspection.html#getSpecialization(com.oracle.truffle.api.nodes.Node,java.lang.String)` ### getSpecialization(Node, Node, String) `public static Introspection.SpecializationInfo getSpecialization(Node inlineParent, Node node, String methodName)`. Since 23.0. Like `getSpecialization(Node, String)` but must be used for nodes that were `inlined`. Parameters: `inlineParent` `Node`: the inlined parent node. `node` `Node`: a introspectable DSL operation with at least one specialization. `methodName` `String`: the Java method name of the specialization to introspect. Returns `Introspection.SpecializationInfo`: introspection info for the method. See also: `example usage`. Cite: `com/oracle/truffle/api/dsl/Introspection.html#getSpecialization(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.String)` ### getSpecialization(Node, int, …) `public static Introspection.SpecializationInfo getSpecialization(Node bytecodeNode, int bytecodeIndex, Node node, String methodName)`. Since 25.1. Like `getSpecialization(Node, String)` but must be used for nodes that were used as part of a bytecode interpreter. Parameters: `bytecodeNode` `Node`: the bytecode node. `bytecodeIndex` `int`: the bytecode index. `node` `Node`: a introspectable DSL node with at least one specialization. `methodName` `String`: the Java method name of the specialization to introspect. Cite: `com/oracle/truffle/api/dsl/Introspection.html#getSpecialization(com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.nodes.Node,java.lang.String)` ### getSpecializations(Node) `public static List getSpecializations(Node node)`. Since 0.22. Returns introspection information for all declared specializations as unmodifiable list. A given node must declare at least one specialization and must be annotated with `Introspectable` otherwise an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. The returned introspection information is not updated when the state of the given operation node is updated. The implementation of this method might be slow, do not use it in performance critical code. For a node was `inlined` use `getSpecialization(Node, Node, String)`. Parameters: `node` `Node`: a introspectable DSL operation with at least one specialization. See also: `example usage`. Cite: `com/oracle/truffle/api/dsl/Introspection.html#getSpecializations(com.oracle.truffle.api.nodes.Node)` ### getSpecializations(Node, Node) `public static List getSpecializations(Node inlineParent, Node node)`. Since 23.0. Like `getSpecializations(Node)` but must be used for nodes that were `inlined`. Parameters: `inlineParent` `Node`: the inlined parent node. `node` `Node`: a introspectable DSL operation with at least one specialization. See also: `example usage`. Cite: `com/oracle/truffle/api/dsl/Introspection.html#getSpecializations(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node)` ### getSpecializations(Node, int, Node) `public static List getSpecializations(Node bytecodeNode, int bytecodeIndex, Node node)`. Since 25.1. Like `getSpecializations(Node)` but must be used for nodes that were used as part of a bytecode interpreter. Parameters: `bytecodeNode` `Node`: the bytecode node. `bytecodeIndex` `int`: the bytecode index. `node` `Node`: a introspectable DSL node with at least one specialization. Cite: `com/oracle/truffle/api/dsl/Introspection.html#getSpecializations(com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.nodes.Node)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ Introspection.Provider [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 0.22. Nested in [`Introspection`](com/oracle/truffle/api/dsl/Introspection.md). ```java public interface Introspection.Provider ``` Internal marker interface for DSL generated code to access reflection information. A DSL user must not refer to this type manually. ## Methods ### getIntrospectionData() `default Introspection getIntrospectionData()`. Since 0.22. Returns internal reflection data in undefined format. A DSL user must not call this method. Cite: `com/oracle/truffle/api/dsl/Introspection.Provider.html#getIntrospectionData()` ### getIntrospectionData(Node) `default Introspection getIntrospectionData(Node inlinedParent)`. Since 23.0. Returns internal reflection data in undefined format. A DSL user must not call this method. Cite: `com/oracle/truffle/api/dsl/Introspection.Provider.html#getIntrospectionData(com.oracle.truffle.api.nodes.Node)` ### getIntrospectionData(Node, int) `default Introspection getIntrospectionData(Node bytecodeNode, int bytecodeIndex)`. Since 26.0. Returns internal reflection data in undefined format. A DSL user must not call this method. Cite: `com/oracle/truffle/api/dsl/Introspection.Provider.html#getIntrospectionData(com.oracle.truffle.api.nodes.Node,int)` ### create(Object...) `static Introspection create(Object... data)`. Since 0.22. Factory method to create `Node` introspection data. The factory is used to create `Introspection` data to be returned from the `getIntrospectionData()` method. The format of the `data` parameters is internal, thus this method shall only be used by the nodes generated by the DSL processor. A DSL user must not call this method. Parameters: `data` `Object...`: introspection data in an internal format. Returns `Introspection`: wrapped data to be used by `Introspection.getSpecializations(com.oracle.truffle.api.nodes.Node)` and similar methods. Cite: `com/oracle/truffle/api/dsl/Introspection.Provider.html#create(java.lang.Object...)` # ◆ Introspection.SpecializationInfo [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 0.22. Nested in [`Introspection`](com/oracle/truffle/api/dsl/Introspection.md). ```java public static final class Introspection.SpecializationInfo ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `SpecializationInfo` Represents dynamic introspection information of a specialization of a DSL operation. ## Methods ### getMethodName() `public String getMethodName()`. Since 0.22. Returns the method name of the introspected specialization. Please note that the returned method name might not be unique for a given node. Cite: `com/oracle/truffle/api/dsl/Introspection.SpecializationInfo.html#getMethodName()` ### isActive() `public boolean isActive()`. Since 0.22. Returns `true` if the specialization was active at the time when the introspection was performed. Cite: `com/oracle/truffle/api/dsl/Introspection.SpecializationInfo.html#isActive()` ### isExcluded() `public boolean isExcluded()`. Since 0.22. Returns `true` if the specialization was excluded at the time when the introspection was performed. Cite: `com/oracle/truffle/api/dsl/Introspection.SpecializationInfo.html#isExcluded()` ### getInstances() `public int getInstances()`. Since 0.22. Returns the number of dynamic specialization instances that are active for this specialization. Cite: `com/oracle/truffle/api/dsl/Introspection.SpecializationInfo.html#getInstances()` ### getCachedData(int) `public List getCachedData(int instanceIndex)`. Since 0.22. Returns the cached state for a given specialization instance. The provided instance index must be greater or equal `0` and smaller `getInstances()`. The returned list is unmodifiable and never `null`. Cite: `com/oracle/truffle/api/dsl/Introspection.SpecializationInfo.html#getCachedData(int)` ### toString() `public String toString()`. Since 21.1. Overrides `toString()`. Cite: `com/oracle/truffle/api/dsl/Introspection.SpecializationInfo.html#toString()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # @ NeverDefault [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 23.0. ```java @Retention(CLASS) @Target({METHOD, FIELD, PARAMETER}) public @interface NeverDefault ``` Useful to annotate methods, fields or parameters bound by any DSL expression to indicate that it never returns a `null` or default primitive value. This may in some case be preferential to specifying [`Cached.neverDefault()`](com/oracle/truffle/api/dsl/Cached.md#neverDefault%28%29) for each cache expression. The DSL emits a warnings when the usage of this method is recommended. **See also** - [`Cached.neverDefault()`](com/oracle/truffle/api/dsl/Cached.md#neverDefault%28%29) # @ NodeChild [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 0.8 or earlier. ```java @Retention(CLASS) @Target({TYPE}) @Repeatable(com.oracle.truffle.api.dsl.NodeChildren.class) public @interface NodeChild ``` A [`NodeChild`](com/oracle/truffle/api/dsl/NodeChild.md) element defines an executable child for the enclosing [`Node`](com/oracle/truffle/api/nodes/Node.md). A [`Node`](com/oracle/truffle/api/nodes/Node.md) contains multiple [`NodeChildren`](com/oracle/truffle/api/dsl/NodeChildren.md) specified in linear execution order. ## Elements ### value() `String value() default ""`. Since 0.8 or earlier. Default: `""`. Cite: `com/oracle/truffle/api/dsl/NodeChild.html#value()` ### type() `Class type() default com.oracle.truffle.api.nodes.Node.class`. Since 0.8 or earlier. Default: `com.oracle.truffle.api.nodes.Node.class`. Cite: `com/oracle/truffle/api/dsl/NodeChild.html#type()` ### executeWith() `String[] executeWith() default {}`. Since 0.8 or earlier. The `executeWith()` property allows a node to pass the result of one child's executable as an input to another child's executable. These referenced children must be defined before the current node in the execution order. The current node `type()` attribute must be set to a `Node` which supports the evaluated execution with the number of `executeWith()` arguments that are defined. For example if this child is executed with one argument, the `type()` attribute must define a node which publicly declares a method with the signature `Object execute*(VirtualFrame, Object)`. Default: `{}`. Cite: `com/oracle/truffle/api/dsl/NodeChild.html#executeWith()` ### implicit() `boolean implicit() default false`. Since 21.1. Allows implicit creation of this child node. If this property is `false` (the default), the factory method of the parent node needs to be called with an instance of the child node as argument. If `implicit` is `true`, the child node will be implicitly created when calling the factory method of the parent node. Default: `false`. Cite: `com/oracle/truffle/api/dsl/NodeChild.html#implicit()` ### implicitCreate() `String implicitCreate() default "create()"`. Since 21.1. Defines the initializer expression for implicit child node creation. Specifying this property will enable `implicit()` mode on this child node automatically, this should not be specified together with `implicit()`. If `implicit()` is `true`, the initializer expression defaults to `"create()"`. Default: `"create()"`. See also: `implicit()`, `Cached`. Cite: `com/oracle/truffle/api/dsl/NodeChild.html#implicitCreate()` ### allowUncached() `boolean allowUncached() default false`. Since 21.1. Allow this child node to be used in uncached mode. If set to `false` (the default), only execute methods that have an explicit argument for the child value can be used on the uncached version of the parent node. If set to `true`, execute methods that do not have an explicit argument for the child value use an uncached version of the child node to compute the missing value. Default: `false`. See also: `GenerateUncached`. Cite: `com/oracle/truffle/api/dsl/NodeChild.html#allowUncached()` ### uncached() `String uncached() default "getUncached()"`. Since 21.1. Defines the expression to get an uncached instance of the child node. Specifying this property will implicitly enable `allowUncached()` on this child node, this should not be specified together with `allowUncached()`. If `allowUncached()` is `true`, the uncached expression defaults to `"getUncached()"`. Default: `"getUncached()"`. See also: `allowUncached()`, `Cached`. Cite: `com/oracle/truffle/api/dsl/NodeChild.html#uncached()` # @ NodeChildren [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 0.8 or earlier. ```java @Retention(CLASS) @Target({TYPE}) public @interface NodeChildren ``` ## Elements ### value() `NodeChild[] value() default {}`. Since 0.8 or earlier. Default: `{}`. Cite: `com/oracle/truffle/api/dsl/NodeChildren.html#value()` # ◇ NodeFactory [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 0.8 or earlier. ```java public interface NodeFactory ``` Enables the dynamic creation of generated nodes. It provides an convenient way to instantiate generated node classes without using reflection. ## Methods ### createNode(Object...) `T createNode(Object... arguments)`. Since 0.8 or earlier. Instantiates the node using the arguments array. The arguments length and types must suffice one of the returned signatures in `getNodeSignatures()`. If the arguments array does not suffice one of the node signatures an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. Parameters: `arguments` `Object...`: the argument values. Returns `T`: the instantiated node. Throws: `IllegalArgumentException` (unchecked). Cite: `com/oracle/truffle/api/dsl/NodeFactory.html#createNode(java.lang.Object...)` ### getNodeClass() `Class getNodeClass()`. Since 0.8 or earlier. Returns the node class that will get created by `createNode(Object...)`. The node class does not match exactly to the instantiated object but they are guaranteed to be assignable. Cite: `com/oracle/truffle/api/dsl/NodeFactory.html#getNodeClass()` ### getNodeSignatures() `List>> getNodeSignatures()`. Since 0.8 or earlier. Returns a list of signatures that can be used to invoke `createNode(Object...)`. Cite: `com/oracle/truffle/api/dsl/NodeFactory.html#getNodeSignatures()` ### getExecutionSignature() `List> getExecutionSignature()`. Since 0.8 or earlier. Returns a list of children that will be executed by the created node. This is useful for base nodes that can execute a variable amount of nodes. Cite: `com/oracle/truffle/api/dsl/NodeFactory.html#getExecutionSignature()` ### getUncachedInstance() `default T getUncachedInstance()`. Since 19.1.0. Returns the uncached version of this node or `null` if `GenerateUncached` was not applied to the node. Cite: `com/oracle/truffle/api/dsl/NodeFactory.html#getUncachedInstance()` # @ NodeField [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 0.8 or earlier. ```java @Retention(CLASS) @Target({TYPE}) @Repeatable(com.oracle.truffle.api.dsl.NodeFields.class) public @interface NodeField ``` A [`NodeField`](com/oracle/truffle/api/dsl/NodeField.md) element defines a field for the generated [`Node`](com/oracle/truffle/api/nodes/Node.md). A [`Node`](com/oracle/truffle/api/nodes/Node.md) contains multiple [`NodeFields`](com/oracle/truffle/api/dsl/NodeFields.md) specified in linear declaration order. The field can be accessed by declaring an abstract getter or setter named `"get" + firstLetterUpperCase(`[`name()`](com/oracle/truffle/api/dsl/NodeField.md#name%28%29)`)()` (or `"is" + firstLetterUpperCase(`[`name()`](com/oracle/truffle/api/dsl/NodeField.md#name%28%29)`)()` in case of a boolean node field) and `"set" + firstLetterUpperCase(`[`name()`](com/oracle/truffle/api/dsl/NodeField.md#name%28%29)`)()`. If no setter is specified then the resulting field will be final and passed in as constructor argument to the create factory method. If an abstract setter was specified then the field will be mutable and not passed in as constructor argument. Note that the generated mutable field will not be [`CompilationFinal`](com/oracle/truffle/api/CompilerDirectives.CompilationFinal.md). If the [`NodeField`](com/oracle/truffle/api/dsl/NodeField.md) is used in combination with [`GenerateUncached`](com/oracle/truffle/api/dsl/GenerateUncached.md) then the generated getters or setters throw an [`UnsupportedOperationException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/UnsupportedOperationException.html) for the uncached variant of the node. **See also** - [`GenerateUncached`](com/oracle/truffle/api/dsl/GenerateUncached.md) ## Elements ### name() `String name()`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/dsl/NodeField.html#name()` ### type() `Class type()`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/dsl/NodeField.html#type()` # @ NodeFields [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 0.8 or earlier. ```java @Retention(CLASS) @Target({TYPE}) public @interface NodeFields ``` A [`NodeFields`](com/oracle/truffle/api/dsl/NodeFields.md) element defines a field for the generated [`Node`](com/oracle/truffle/api/nodes/Node.md). A [`Node`](com/oracle/truffle/api/nodes/Node.md) contains multiple [`NodeFields`](com/oracle/truffle/api/dsl/NodeFields.md) specified in linear declaration order. The field can be accessed by declaring an abstract getter named `"get" + firstLetterUpperCase(`[`value()`](com/oracle/truffle/api/dsl/NodeFields.md#value%28%29)`)()`. ## Elements ### value() `NodeField[] value() default {}`. Since 0.8 or earlier. Default: `{}`. Cite: `com/oracle/truffle/api/dsl/NodeFields.html#value()` # @ NonIdempotent [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 23.0. ```java @Retention(CLASS) @Target({METHOD}) public @interface NonIdempotent ``` Methods annotated with [`NonIdempotent`](com/oracle/truffle/api/dsl/NonIdempotent.md) must be methods that may cause side effects but may not always cause the same side effects for repeated invocations with the same parameters. From this follows that an non-idempotent method may return different results for consecutive invocations given the same parameters. Truffle DSL uses this property to execute [`guards`](com/oracle/truffle/api/dsl/Specialization.md#guards%28%29) where all bound methods are idempotent once on the slow-path, during specialization, and never on the fast-path. By default, all methods that do not bind dynamic parameters are interpreted as idempotent for compatibility reasons. The DSL emits warnings whenever a method should be annotated either with [`Idempotent`](com/oracle/truffle/api/dsl/Idempotent.md) or [`NonIdempotent`](com/oracle/truffle/api/dsl/NonIdempotent.md). Note that guards that bind dynamic parameters will never be idempotent in the fast-path, so the DSL will not require annotations for such guards. Examples for non-idempotent methods are: - [`ContextThreadLocal.get()`](com/oracle/truffle/api/ContextThreadLocal.md#get%28%29) - [`Assumption.isValid()`](com/oracle/truffle/api/Assumption.md#isValid%28%29) - [`Assumption.isValidAssumption(Assumption)`](com/oracle/truffle/api/Assumption.md#isValidAssumption%28com.oracle.truffle.api.Assumption%29) - [`Assumption.isValidAssumption(Assumption[])`](com/oracle/truffle/api/Assumption.md#isValidAssumption%28com.oracle.truffle.api.Assumption[]%29) - [`ContextLocal.get()`](com/oracle/truffle/api/ContextLocal.md#get%28%29) if the language uses a context policy [`ContextPolicy.REUSE`](com/oracle/truffle/api/TruffleLanguage.ContextPolicy.md#REUSE) or [`ContextPolicy.SHARED`](com/oracle/truffle/api/TruffleLanguage.ContextPolicy.md#SHARED) Examples for idempotent methods are: - [`LanguageReference.get(Node)`](com/oracle/truffle/api/TruffleLanguage.LanguageReference.md#get%28com.oracle.truffle.api.nodes.Node%29) - [`DirectCallNode.getCallTarget()`](com/oracle/truffle/api/nodes/DirectCallNode.md#getCallTarget%28%29) - [`ContextLocal.get()`](com/oracle/truffle/api/ContextLocal.md#get%28%29) if the language uses context policy [`ContextPolicy.EXCLUSIVE`](com/oracle/truffle/api/TruffleLanguage.ContextPolicy.md#EXCLUSIVE). Note that usages may assume that the current language instance never changes for a given Node. Therefore it is safe to assume language reference accesses idempotent. **See also** - [`Idempotent`](com/oracle/truffle/api/dsl/Idempotent.md) # @ ReportPolymorphism [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 0.33. ```java @Retention(CLASS) @Target({TYPE}) @Inherited public @interface ReportPolymorphism ``` Enables reporting of polymorphic specializations from this node or exported message to the runtime. Polymorphic specializations include, but are not limited to, activating another specialization, increasing the number of instances of an active specialization, excluding a specialization, etc. Additional information on the effect of [`ReportPolymorphism`](com/oracle/truffle/api/dsl/ReportPolymorphism.md) can be found in [ ReportingPolymorphism.md](https://github.com/oracle/graal/blob/master/truffle/docs/splitting/ReportingPolymorphism.md). ## Nested types - [`ReportPolymorphism.Exclude`](com/oracle/truffle/api/dsl/ReportPolymorphism.Exclude.md) (annotation interface): Nodes (and their subclasses) or specializations annotated with this annotation will be excluded from consideration when reporting polymorphic specializations. - [`ReportPolymorphism.Megamorphic`](com/oracle/truffle/api/dsl/ReportPolymorphism.Megamorphic.md) (annotation interface): Specializations annotated with this annotation are considered megamorphic. # @ ReportPolymorphism.Exclude [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 0.33. Nested in [`ReportPolymorphism`](com/oracle/truffle/api/dsl/ReportPolymorphism.md). ```java @Retention(CLASS) @Target({METHOD, TYPE}) @Inherited public @interface ReportPolymorphism.Exclude ``` Nodes (and their subclasses) or specializations annotated with this annotation will be excluded from consideration when [`reporting polymorphic specializations`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29). Individual specializations can be excluded from this consideration by using the [`ReportPolymorphism.Exclude`](com/oracle/truffle/api/dsl/ReportPolymorphism.Exclude.md) Polymorphic specializations are never reported on the first specialization. # @ ReportPolymorphism.Megamorphic [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 20.3. Nested in [`ReportPolymorphism`](com/oracle/truffle/api/dsl/ReportPolymorphism.md). ```java @Retention(CLASS) @Target({METHOD}) public @interface ReportPolymorphism.Megamorphic ``` Specializations annotated with this annotation are considered megamorphic. This means that on the first activation of such a specialization the node will [`report a polymorphic specialization`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29). This annotation can be used independently of [`ReportPolymorphism`](com/oracle/truffle/api/dsl/ReportPolymorphism.md). This means that a node need not report every polymorphic specialization as with [`ReportPolymorphism`](com/oracle/truffle/api/dsl/ReportPolymorphism.md) but only ones that produce generic and expensive cases. For example, if a node has several fast specializations and a very slow generic specialization it does not make sense to report activations of these fast specializations as polymorphic specializations as they perform well even without runtime intervention (e.g. Splitting). On the other hand, the activation of the generic case is slow and something that the runtime might be able to remove. # @ Specialization [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 0.8 or earlier. ```java @Retention(RUNTIME) @Target({METHOD}) public @interface Specialization ``` Defines a method of a node subclass to represent one specialization of an operation. Multiple specializations can be defined in a node representing an operation. A specialization defines which kind of input is expected using the method signature and the annotation attributes. The specialized semantics of the operation are defined using the body of the annotated Java method. A specialization method must be declared in a class that is derived from [`Node`](com/oracle/truffle/api/nodes/Node.md) that references a [`TypeSystem`](com/oracle/truffle/api/dsl/TypeSystem.md). At least one specialization must be defined per operation. If no specialization is valid for the given set of input values then an [`UnsupportedSpecializationException`](com/oracle/truffle/api/dsl/UnsupportedSpecializationException.md) is thrown instead of invoking any specialization method. A specialization must have at least as many parameters as there are [`NodeChild`](com/oracle/truffle/api/dsl/NodeChild.md) annotations declared for the enclosing operation node. These parameters are declared in the same order as the [`NodeChild`](com/oracle/truffle/api/dsl/NodeChild.md) annotations (linear execution order). We call such parameters dynamic input parameters. Every specialization that is declared within an operation must have an equal number of dynamic input parameters. The supported kind of input values for a specialization are declared using guards. A specialization may provide declarative specifications for four kinds of guards: - **Type guards** optimistically assume the type of an input value. A value that matches the type is cast to its expected type automatically. Type guards are modeled using the parameter type of the specialization method. Types used for type guards must be defined in the [`TypeSystem`](com/oracle/truffle/api/dsl/TypeSystem.md). If the type of the parameter is [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) then no type guard is used for the dynamic input parameter. - **Expression guards** optimistically assume the return value of a user-defined expression to be `true`. Expression guards are modeled using Java expressions that return a `boolean` value. If the guard expression returns `false`, the specialization is no longer applicable and the operation is re-specialized. Guard expressions are declared using the [`guards()`](com/oracle/truffle/api/dsl/Specialization.md#guards%28%29) attribute. - **Event guards** trigger re-specialization in case an exception is thrown in the specialization body. The [`rewriteOn()`](com/oracle/truffle/api/dsl/Specialization.md#rewriteOn%28%29) attribute can be used to declare a list of such exceptions. Guards of this kind are useful to avoid calculating a value twice when it is used in the guard and its specialization. - **Assumption guards** optimistically assume that the state of an [`Assumption`](com/oracle/truffle/api/Assumption.md) remains `true`. Assumptions can be assigned to specializations using the [`assumptions()`](com/oracle/truffle/api/dsl/Specialization.md#assumptions%28%29) attribute. The enclosing [`Node`](com/oracle/truffle/api/nodes/Node.md) of a specialization method must have at least one `public` and non-`final` execute method. An execute method is a method that starts with 'execute'. If all execute methods declare the first parameter type as [`Frame`](com/oracle/truffle/api/frame/Frame.md), [`VirtualFrame`](com/oracle/truffle/api/frame/VirtualFrame.md) or [`MaterializedFrame`](com/oracle/truffle/api/frame/MaterializedFrame.md) then the same frame type can be used as optional first parameter of the specialization. This parameter does not count to the number of dynamic parameters. A specialization method may declare multiple parameters annotated with [`Cached`](com/oracle/truffle/api/dsl/Cached.md). Cached parameters are initialized and stored once per specialization instantiation. For consistency between specialization declarations cached parameters must be declared last in a specialization method. If the operation is re-specialized or if it is executed for the first time then all declared specializations of the operation are tried in declaration order until the guards of the first specialization accepts the current input values. The new specialization is then added to the chain of current specialization instances which might consist of one (monomorph) or multiple instances (polymorph). If an assumption of an instantiated specialization is violated then re-specialization is triggered again. With guards in combination with cached parameters it is possible that multiple instances of the same specialization are created. The [`limit()`](com/oracle/truffle/api/dsl/Specialization.md#limit%28%29) attribute can be used to limit the number of instantiations per specialization. **See also** - [`NodeChild`](com/oracle/truffle/api/dsl/NodeChild.md) - [`Fallback`](com/oracle/truffle/api/dsl/Fallback.md) - [`Cached`](com/oracle/truffle/api/dsl/Cached.md) - [`TypeSystem`](com/oracle/truffle/api/dsl/TypeSystem.md) - [`TypeSystemReference`](com/oracle/truffle/api/dsl/TypeSystemReference.md) - [`UnsupportedSpecializationException`](com/oracle/truffle/api/dsl/UnsupportedSpecializationException.md) ## Elements ### insertBefore() `String insertBefore() default ""`. Since 0.8 or earlier. References a specialization of a super class by its method name where this specialization is inserted before. The declaration order of a specialization is not usable for nodes where specializations are partly declared in the super class and partly declared in a derived class. By default all specializations declared in the derived class are appended to those in the super class. This attribute can be used to override the default behavior. Default: `""`. Cite: `com/oracle/truffle/api/dsl/Specialization.html#insertBefore()` ### rewriteOn() `Class[] rewriteOn() default {}`. Since 0.8 or earlier. Declares an event guards that trigger re-specialization in case an exception is thrown in the specialization body. This attribute can be used to declare a list of such exceptions. Guards of this kind are useful to avoid calculating a value twice when it is used in the guard and its specialization. If an event guard exception is triggered then all instantiations of this specialization are removed. If one of theses exceptions is thrown once then no further instantiations of this specialization are going to be created for this node. **Example usage:** In case of explicitly declared `UnexpectedResultException`s, the result from the exception will be used. For all other exception types, the next available specialization will be executed, so that the original specialization must ensure that no non-repeatable side-effect is caused until the rewrite is triggered. If a specialization declares an `UnexpectedResultException` which is `replaced` by another specialization with the same signature and state, but without declared `UnexpectedResultException` then the specialization is used as so-called boxing overload of the replacing specialization. Boxing overloads share the same state and must be implemented in a way such that they perform exactly the same operation, with the exception of the unexpected result. Boxing overloads are used as direct replacements when code for boxing elimination is generated. They are only used if an execute method with the return type of the boxing overload and an `UnexpectedResultException` is declared in the node, or alternatively in the Bytecode DSL if the return type is configured to be boxing eliminated. Boxing overloads share the state with its replacing specialization, which makes them particularly useful to implement read nodes with boxing elimination. **Usage for boxing elimination:**. Default: `{}`. See also: [`Math.addExact(int, int)`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Math.html#addExact%28int,int%29). Cite: `com/oracle/truffle/api/dsl/Specialization.html#rewriteOn()` ```java @Specialization(rewriteOn = ArithmeticException.class) int doAddNoOverflow(int a, int b) { return Math.addExact(a, b); } @Specialization long doAddWithOverflow(int a, int b) { return a + b; } ... Example executions: execute(Integer.MAX_VALUE - 1, 1) => doAddNoOverflow(Integer.MAX_VALUE - 1, 1) execute(Integer.MAX_VALUE, 1) => doAddNoOverflow(Integer.MAX_VALUE, 1) => throws ArithmeticException => doAddWithOverflow(Integer.MAX_VALUE, 1) execute(Integer.MAX_VALUE - 1, 1) => doAddWithOverflow(Integer.MAX_VALUE - 1, 1) ``` ```java @Specialization(guards = "arg == cachedArg", limit = "2", rewriteOn = UnexpectedResultException.class) int doInt(Object arg, @Cached("arg") Object cachedArg) throws UnexpectedResultException { if (cachedArg instanceof Integer i) { return 42; } throw new UnexpectedResultException(cachedArg); } @Specialization(guards = "arg == cachedArg", limit = "2", replaces = "doInt") Object doGeneric(Object arg, @Cached("arg") Object cachedArg) { return cachedArg; } ... Example executions: execute(42) => doGeneric(42, 42) executeInt(43) => doInt(43, 43) executeInt(42) => doInt(42, 42) // shared inline cache limit of 2 reached execute(44) => UnsupportedSpecializationException ``` ### replaces() `String[] replaces() default {}`. Since 0.22. Declares other specializations of the same operation to be replaced by this specialization. Other specializations are referenced using their unique method name. If this specialization is instantiated then all replaced specialization instances are removed and never instantiated again for this node instance. Therefore this specialization should handle strictly more inputs than which were handled by the replaced specialization, otherwise the removal of the replaced specialization will lead to unspecialized types of input values. The replaces declaration is transitive for multiple involved specializations. **Example usage:**. Default: `{}`. See also: `guards()`. Cite: `com/oracle/truffle/api/dsl/Specialization.html#replaces()` ```java @Specialization(guards = "b == 2") void doDivPowerTwo(int a, int b) { return a >> 1; } @Specialization(replaces ="doDivPowerTwo", guards = "b > 0") void doDivPositive(int a, int b) { return a / b; } ... Example executions with replaces="doDivPowerTwo": execute(4, 2) => doDivPowerTwo(4, 2) execute(9, 3) => doDivPositive(9, 3) // doDivPowerTwo instances get removed execute(4, 2) => doDivPositive(4, 2) Same executions without replaces="doDivPowerTwo" execute(4, 2) => doDivPowerTwo(4, 2) execute(9, 3) => doDivPositive(9, 3) execute(4, 2) => doDivPowerTwo(4, 2) ``` ### guards() `String[] guards() default {}`. Since 0.8 or earlier. Declares `boolean` expressions that define whether or not input values are applicable to this specialization instance. Guard expressions must always return the same result for each combination of the enclosing node instance and the bound input values. If a guard expression does not bind any dynamic input parameters then the DSL, by default, assumes that the result will not change for this node after specialization instantiation. In other words the DSL assumes idempotence for this guard on the fast-path, by default. The `Idempotent` and `NonIdempotent` annotations may be used to configure this explicitly. The DSL will also emit warnings in case the use of such annotations is recommended. If assertions are enabled (-ea), then the DSL will assert that the idempotence property does hold at runtime. Guard expressions are defined using a subset of Java. This subset includes field/parameter accesses, function calls, type exact infix comparisons (==, !=, \<, \<=, \>, \>=), logical negation (!), logical disjunction (\|\|), null, true, false, and integer literals. The return type of guard expressions must be `boolean`. Bound elements without receivers are resolved using the following order: Dynamic and cached parameters of the enclosing specialization.; Fields defined using `NodeField` for the enclosing node.; Non-private, static or virtual methods or fields of enclosing node.; Non-private, static or virtual methods or fields of super types of the enclosing node.; Public and static methods or fields imported using `ImportStatic`. **Example usage:**. Default: `{}`. See also: `Cached`, `ImportStatic`. Cite: `com/oracle/truffle/api/dsl/Specialization.html#guards()` ```java static boolean acceptOperand(int operand) { assert operand <= 42; return (operand & 1) == 1; } @Specialization(guards = {"operand <= 42", "acceptOperand(operand)"}) void doSpecialization(int operand) {...} ``` ### assumptions() `String[] assumptions() default {}`. Since 0.8 or earlier. Declares assumption guards that optimistically assume that the state of an `Assumption` remains valid. Assumption expressions are cached once per specialization instantiation. If one of the returned assumptions gets invalidated then the specialization instance is removed. If the assumption expression returns an array of assumptions then all assumptions of the array are checked. This is limited to one-dimensional arrays. Assumption expressions are defined using a subset of Java. This subset includes field/parameter accesses, function calls, type exact infix comparisons (==, !=, \<, \<=, \>, \>=), logical negation (!), logical disjunction (\|\|), null, true, false, and integer literals. The return type of the expression must be `Assumption` or an array of `Assumption` instances. Assumption expressions are not allowed to bind to dynamic parameter values of the specialization. Bound elements without receivers are resolved using the following order: Cached parameters of the enclosing specialization.; Fields defined using `NodeField` for the enclosing node.; Non-private, static or virtual methods or fields of enclosing node.; Non-private, static or virtual methods or fields of super types of the enclosing node.; Public and static methods or fields imported using `ImportStatic`. **Example usage:**. Default: `{}`. See also: `Cached`, `ImportStatic`. Cite: `com/oracle/truffle/api/dsl/Specialization.html#assumptions()` ```java abstract static class DynamicObject() { abstract Shape getShape(); ... } abstract static class Shape() { abstract Assumption getUnmodifiedAssuption(); ... } @Specialization(guards = "operand.getShape() == cachedShape", assumptions = "cachedShape.getUnmodifiedAssumption()") void doAssumeUnmodifiedShape(DynamicObject operand, @Cached("operand.getShape()") Shape cachedShape) {...} ``` ### limit() `String limit() default ""`. Since 0.8 or earlier. Declares the expression that limits the number of specialization instantiations. The default limit for specialization instantiations is defined as `"3"`. If the limit is exceeded no more instantiations of the enclosing specialization method are created. Please note that the existing specialization instantiations are **not** removed from the specialization chain. You can use `replaces()` to remove unnecessary specializations instances. The limit expression is defined using a subset of Java. This subset includes field/parameter accesses, function calls, type exact infix comparisons (==, !=, \<, \<=, \>, \>=), logical negation (!), logical disjunction (\|\|), null, true, false, and integer literals. The return type of the limit expression must be `int`. Limit expressions are not allowed to bind to dynamic parameter values of the specialization. Bound elements without receivers are resolved using the following order: Cached parameters of the enclosing specialization.; Fields defined using `NodeField` for the enclosing node.; Non-private, static or virtual methods or fields of enclosing node.; Non-private, static or virtual methods or fields of super types of the enclosing node.; Public and static methods or fields imported using `ImportStatic`. **Example usage:**. Default: `""`. See also: `guards()`, `replaces()`, `Cached`, `ImportStatic`. Cite: `com/oracle/truffle/api/dsl/Specialization.html#limit()` ```java static int getCacheLimit() { return Integer.parseInt(System.getProperty("language.cacheLimit")); } @Specialization(guards = "operand == cachedOperand", limit = "getCacheLimit()") void doCached(Object operand, @Cached("operand") Object cachedOperand) {...} ``` ### unroll() `int unroll() default 0`. Since 23.0. Instructs the specialization to unroll a specialization with multiple instances. Unrolling causes fields of the inline cache to be directly stored in the node instead of a chained inline cache. At most 8 instances of a specialization can be unrolled to avoid code explosion in the interpreter. A common use-case for this feature is to unroll the first instance of an inline cache. It is often the case that specializations with multiple instances are instantiated only once. By unrolling the first instance we can optimize for this common situation which may lead to footprint and interpreter performance improvements. This feature is prone to cause inefficiencies if used too aggressively. Extra care should be taken, e.g. the generated code should be inspected and profiled to verify that the new code is better than the previous version. Consider the following example: In this example we unroll the first instance of an inline cache on `int` values. This is equivalent to manually specifying the following specializations: Default: `0`. Cite: `com/oracle/truffle/api/dsl/Specialization.html#unroll()` ```java class MyNode extends Node { static int limit = 2; abstract int execute(int value); @Specialization(guards = "value == cachedValue", limit = "limit", unroll = 1) int doDefault(int value, @Cached("value") int cachedValue) { return value; } } ``` ```java class MyUnrollNode extends Node { static int limit = 2; abstract int execute(int value); @Specialization(guards = "value == cachedValue", limit = "1") int doUnrolled0(int value, @Cached("value") int cachedValue) { return value; } @Specialization(guards = "value == cachedValue", limit = "limit - 1") int doDefault(int value, @Cached("value") int cachedValue) { return value; } } ``` ### excludeForUncached() `boolean excludeForUncached() default false`. Since 25.0. Excludes this specialization from use with `GenerateUncached`. By default every specialization is included for `GenerateUncached`, except specializations that require a `limit` and are `replaced`, those are excluded by default. By setting `Specialization.excludeForUncached()` explicitly the default behavior can be overridden, e.g. to include or exclude a specialization for `GenerateUncached`. Mark a specialization as excluded only when it is `replaced` by a more generic one; otherwise cached and uncached nodes may diverge semantically. Any specialization may be excluded from uncached. It is considered an error if all specializations are excluded from uncached. Default: `false`. Cite: `com/oracle/truffle/api/dsl/Specialization.html#excludeForUncached()` # ◆ SpecializationStatistics [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 20.3. ```java public final class SpecializationStatistics ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `SpecializationStatistics` Represents a specialization statistics utiltiy that can be [`entered`](com/oracle/truffle/api/dsl/SpecializationStatistics.md#enter%28%29) to collect additional statistics about Truffle DSL nodes. In order for the statistics to be useful the nodes need to be regenerated using the `-Atruffle.dsl.GenerateSpecializationStatistics=true` flag or using the [`AlwaysEnabled`](com/oracle/truffle/api/dsl/SpecializationStatistics.AlwaysEnabled.md) annotation. The easiest way to use this utility is to enable the `--engine.SpecializationStatistics` polyglot option. This should print the histogram when the engine is closed. See also the [usage tutorial](https://github.com/oracle/graal/blob/master/truffle/docs/SpecializationHistogram.md) on the website. ## Nested types - [`SpecializationStatistics.AlwaysEnabled`](com/oracle/truffle/api/dsl/SpecializationStatistics.AlwaysEnabled.md) (annotation interface): Used on nodes to always enable specialization statistics. - [`SpecializationStatistics.NodeStatistics`](com/oracle/truffle/api/dsl/SpecializationStatistics.NodeStatistics.md) (abstract class): Class to collect statistics information per node. ## Methods ### hasData() `public boolean hasData()`. Since 20.3. Returns `true` if the statistics did collect any data, else `false`. Cite: `com/oracle/truffle/api/dsl/SpecializationStatistics.html#hasData()` ### printHistogram(PrintWriter) `public void printHistogram(PrintWriter writer)`. Since 20.3. Prints the specialization histogram to the provided writer. Does not print anything if no `data` was collected. See also: `printHistogram(PrintWriter)`. Cite: `com/oracle/truffle/api/dsl/SpecializationStatistics.html#printHistogram(java.io.PrintWriter)` ### printHistogram(PrintStream) `public void printHistogram(PrintStream stream)`. Since 20.3. Prints the specialization histogram to the provided stream. Does not print anything if no `data` was collected. See also: `printHistogram(PrintWriter)`. Cite: `com/oracle/truffle/api/dsl/SpecializationStatistics.html#printHistogram(java.io.PrintStream)` ### create() `public static SpecializationStatistics create()`. Since 20.3. Creates a new specialization statistics instance. Note specialization statistics need to be `entered` to collect data on a thread. Cite: `com/oracle/truffle/api/dsl/SpecializationStatistics.html#create()` ### enter() `public SpecializationStatistics enter()`. Since 20.3. Enters this specialization instance object on the current thread. After entering a specialization statistics instance will gather statistics for all nodes with `specializations` that were created on this entered thread. Multiple threads may be entered at the same time. The caller must make sure to `leave(SpecializationStatistics)` the current statistics after entering in all cases. Cite: `com/oracle/truffle/api/dsl/SpecializationStatistics.html#enter()` ### leave(SpecializationStatistics) `public void leave(SpecializationStatistics prev)`. Since 20.3. Leaves the currently `entered` entered statistics. It is required to leave a statistics block after it was entered. It is recommended to use a finally block for this purpose. Cite: `com/oracle/truffle/api/dsl/SpecializationStatistics.html#leave(com.oracle.truffle.api.dsl.SpecializationStatistics)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # @ SpecializationStatistics.AlwaysEnabled [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 20.3. Nested in [`SpecializationStatistics`](com/oracle/truffle/api/dsl/SpecializationStatistics.md). ```java @Retention(CLASS) @Target({TYPE}) public @interface SpecializationStatistics.AlwaysEnabled ``` Used on nodes to always enable specialization statistics. The Truffle DSL processor will not generate statistics code unless the `-J-Dtruffle.dsl.GenerateSpecializationStatistics=true` javac system property is set. This annotation can be used to annotate node types that want to force enable the statistics independent of the system property. This annotation is inherited by sub classes. # ◆ SpecializationStatistics.NodeStatistics [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 20.3. Nested in [`SpecializationStatistics`](com/oracle/truffle/api/dsl/SpecializationStatistics.md). ```java public abstract static class SpecializationStatistics.NodeStatistics ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `NodeStatistics` Class to collect statistics information per node. This class is intended to be used by Truffle DSL generated code only. Do not use directly. ## Methods ### acceptExecute(int, Class) `public abstract void acceptExecute(int specializationIndex, Class arg0)`. Since 20.3. Called when a node specialization was executed. This method is intended to be used by Truffle DSL generated code only. Do not use directly. Cite: `com/oracle/truffle/api/dsl/SpecializationStatistics.NodeStatistics.html#acceptExecute(int,java.lang.Class)` ### acceptExecute(int, Class, Class) `public abstract void acceptExecute(int specializationIndex, Class arg0, Class arg1)`. Since 20.3. Called when a node specialization was executed. This method is intended to be used by Truffle DSL generated code only. Do not use directly. Cite: `com/oracle/truffle/api/dsl/SpecializationStatistics.NodeStatistics.html#acceptExecute(int,java.lang.Class,java.lang.Class)` ### acceptExecute(int, Class...) `public abstract void acceptExecute(int specializationIndex, Class... args)`. Since 20.3. Called when a node specialization was executed. This method is intended to be used by Truffle DSL generated code only. Do not use directly. Cite: `com/oracle/truffle/api/dsl/SpecializationStatistics.NodeStatistics.html#acceptExecute(int,java.lang.Class...)` ### resolveValueClass(Object) `public abstract Class resolveValueClass(Object value)`. Since 20.3. Called to resolve the class of a value provided in `acceptExecute(int, Class)`. This method is intended to be used by Truffle DSL generated code only. Do not use directly. Cite: `com/oracle/truffle/api/dsl/SpecializationStatistics.NodeStatistics.html#resolveValueClass(java.lang.Object)` ### create(Node, String[]) `public static SpecializationStatistics.NodeStatistics create(Node node, String[] specializations)`. Since 20.3. Called when a new node statistics object is created. This method is intended to be used by Truffle DSL generated code only. Do not use directly. Cite: `com/oracle/truffle/api/dsl/SpecializationStatistics.NodeStatistics.html#create(com.oracle.truffle.api.nodes.Node,java.lang.String[])` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # @ SuppressPackageWarnings [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 23.0. ```java @Retention(CLASS) @Target({PACKAGE}) public @interface SuppressPackageWarnings ``` Use to suppress Truffle DSL warnings in whole packages using a package-info.java class. For regular Java elements use [`SuppressWarnings`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/SuppressWarnings.html). https://github.com/oracle/graal/blob/master/truffle/docs/DSLWarnings.md ## Elements ### value() `String[] value()`. Since 23.0. Cite: `com/oracle/truffle/api/dsl/SuppressPackageWarnings.html#value()` # @ TypeCast [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 0.8 or earlier. ```java @Retention(CLASS) @Target({METHOD}) public @interface TypeCast ``` Overrides the standard way of casting a certain type in a [`TypeSystem`](com/oracle/truffle/api/dsl/TypeSystem.md). This is useful for types where the guest language specific type cast can be implemented more efficiently than a direct cast. The annotated method must be contained in a [`TypeSystem`](com/oracle/truffle/api/dsl/TypeSystem.md) annotated class. Type checks must conform to the following signature: `public static Type as{TypeName}(Object value)`. The casted type must be a type declared in the [`TypeSystem`](com/oracle/truffle/api/dsl/TypeSystem.md). If no [`TypeCast`](com/oracle/truffle/api/dsl/TypeCast.md) is declared then the type system implicitly uses a type cast that can be declared as follows: ```java @TypeCast(Type.class) public static Type asType(Object value) { return (Type) value; } ``` **See also** - [`TypeCheck`](com/oracle/truffle/api/dsl/TypeCheck.md) ## Elements ### value() `Class value()`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/dsl/TypeCast.html#value()` # @ TypeCheck [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 0.8 or earlier. ```java @Retention(CLASS) @Target({METHOD}) public @interface TypeCheck ``` Overrides the standard way of checking for a certain type in a [`TypeSystem`](com/oracle/truffle/api/dsl/TypeSystem.md). This is useful for types where the guest language specific type check can be implemented more efficiently than an instanceof check. The annotated method must be contained in a [`TypeSystem`](com/oracle/truffle/api/dsl/TypeSystem.md) annotated class. Type checks must conform to the following signature: `public static boolean is{TypeName}(Object value)`. The checked type must be a type declared in the [`TypeSystem`](com/oracle/truffle/api/dsl/TypeSystem.md). If no [`TypeCheck`](com/oracle/truffle/api/dsl/TypeCheck.md) is declared then the type system implicitly uses a type check that can be declared as follows: ```java @TypeCheck(Type.class) public static boolean isType(Object value) { return value instanceof Type; } ``` **See also** - [`TypeCast`](com/oracle/truffle/api/dsl/TypeCast.md) ## Elements ### value() `Class value()`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/dsl/TypeCheck.html#value()` # @ TypeSystem [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 0.8 or earlier. ```java @Retention(CLASS) @Target({TYPE}) public @interface TypeSystem ``` Type guards are the most common form of guards used in Truffle languages. By default all type checks and casts use the default method of checking and casting a type in Java. A default type check is performed using the `instanceof` operator, and a default cast is done using a standard Java cast conversion. However, for some types, this behavior needs to be customized or extended. Therefore, operations can decide to use type systems. If used, type systems are applied to operation classes using the [`TypeSystemReference`](com/oracle/truffle/api/dsl/TypeSystemReference.md) annotation. Only one type system can be active for a single operation. Type systems are inherited from operation superclasses so that the most concrete type system reference is used. If no type system reference is found in the type hierarchy, all type checks and casts are kept default. Example usage: ```java @TypeSystem public static class ExampleTypeSystem { @TypeCast(Undefined.class) public static Undefined asUndefined(Object value) { return Undefined.INSTANCE; } @TypeCheck(Undefined.class) public static boolean isUndefined(Object value) { return value == Undefined.INSTANCE; } @ImplicitCast public static double castInt(int value) { return value; } } @TypeSystemReference(ExampleTypeSystem.class) public abstract class BaseNode extends Node { abstract Object execute(); } public static final class Undefined { public static final Undefined INSTANCE = new Undefined(); } ``` The example type system declared in here defines a special type check and cast for the type Undefined using methods annotated with [`TypeCheck`](com/oracle/truffle/api/dsl/TypeCheck.md) and [`TypeCast`](com/oracle/truffle/api/dsl/TypeCast.md). Undefined is a singleton type and therefore, only a single instance of it exists at a time. For singleton types the type check can be implemented using an identity comparison and instead of casting a value to Undefined we can implement it by returning a constant value. Both the singleton check and cast are considered more efficient than the default check and cast behavior. Multiple distinct Java types can be used to represent values of the same semantic guest language type. For example our JavaScript implementation uses the Java types `int` and `double` to represent the JavaScript numeric type. Whenever a type needs to be checked for the type numeric we need to check the value for each representation type. Defining a specialization with two numeric parameters would normally require us to specify four specializations, for each combination of the representation type. However, in Java, an `int` type has the interesting property of always being representable with a double value without losing precision. Type systems allows the user to specify such relationships using implicit casts such as the `castInt` method declared in the example After declaring an implicit cast from `int` to `double` we can specify a single specialization with double type guards to implicitly represent all the cases of the JavaScript numeric type. Whenever the DSL implementation needs to cast a value from `int` to `double` then the implicit cast method is called. Specializations with `int` type guards can be declared before specializations with `double` type guards. If an int specialization is declared after the `double` specialization then the `int` specialization is unreachable due to the implicit cast. The requirements for implicit casts can vary between guest languages. Therefore, no implicit cast is enabled by default or if no type system is referenced. If multiple implicit casts are declared for a single target type then their types are checked in declaration order. Languages implementations are encouraged to optimize their implicit cast declaration order by sorting them starting with the most frequently used type. **See also** - [`TypeCast`](com/oracle/truffle/api/dsl/TypeCast.md) - [`TypeCheck`](com/oracle/truffle/api/dsl/TypeCheck.md) - [`ImplicitCast`](com/oracle/truffle/api/dsl/ImplicitCast.md) ## Elements ### value() `Class[] value() default {}`. Since 0.8 or earlier. The list of types as child elements of the `TypeSystem`. Each precedes its super type. Default: `{}`. Cite: `com/oracle/truffle/api/dsl/TypeSystem.html#value()` # @ TypeSystemReference [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 0.8 or earlier. ```java @Retention(CLASS) @Target({TYPE}) public @interface TypeSystemReference ``` References a [`TypeSystem`](com/oracle/truffle/api/dsl/TypeSystem.md) on a node. Must be applied on a [`Node`](com/oracle/truffle/api/nodes/Node.md) class. At least one [`TypeSystem`](com/oracle/truffle/api/dsl/TypeSystem.md) must be referenced in a [`Node`](com/oracle/truffle/api/nodes/Node.md)'s type hierarchy. **See also** - [`TypeSystem`](com/oracle/truffle/api/dsl/TypeSystem.md) - [`Node`](com/oracle/truffle/api/nodes/Node.md) ## Elements ### value() `Class value()`. Since 0.8 or earlier. The `TypeSystem` java type. Cite: `com/oracle/truffle/api/dsl/TypeSystemReference.html#value()` # ⚡︎ UnsupportedSpecializationException [truffle-api](index.md) › [com.oracle.truffle.api.dsl](com/oracle/truffle/api/dsl/index.md) · Every page: [llms.txt](llms.txt) Exception in [`com.oracle.truffle.api.dsl`](com/oracle/truffle/api/dsl/index.md). Since 0.8 or earlier. ```java public final class UnsupportedSpecializationException extends RuntimeException ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) > [`Exception`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Exception.html) > [`RuntimeException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/RuntimeException.html) > `UnsupportedSpecializationException` Thrown by the generated code of Truffle-DSL if no compatible Specialization could be found for the provided values. ## Constructors ### UnsupportedSpecializationException(Node, Node[], Object...) `public UnsupportedSpecializationException(Node node, Node[] suppliedNodes, Object... suppliedValues)`. Since 0.8 or earlier. Constructs a new `UnsupportedSpecializationException`. Parameters: `node` `Node`: The node that does not support the provided values in any of its specializations. May be null. `suppliedNodes` `Node[]`: The evaluated nodes that supplied the values. The array must much the length of `suppliedValues`, and may contain null elements for values not not provided by a child node but through an execute method parameter. If the array would consist of only nulls, as in the case of `uncached` and `inlined` nodes, `null` may be provided instead and will be treated as an array of nulls of the expected length. `suppliedValues` `Object...`: The values for which no compatible specialization could be found. The array reference must not be `null`. Cite: `com/oracle/truffle/api/dsl/UnsupportedSpecializationException.html#(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node[],java.lang.Object...)` ## Methods ### getMessage() `public String getMessage()`. Since 0.8 or earlier. Overrides `getMessage()`. Cite: `com/oracle/truffle/api/dsl/UnsupportedSpecializationException.html#getMessage()` ### getNode() `public Node getNode()`. Since 0.8 or earlier. Returns the `Node` that caused the this `UnsupportedSpecializationException`. Cite: `com/oracle/truffle/api/dsl/UnsupportedSpecializationException.html#getNode()` ### getSuppliedNodes() `public Node[] getSuppliedNodes()`. Since 0.8 or earlier. Returns the children of the `Node` returned by `getNode()` which produced the values returned by `getSuppliedValues()`. The array returned by `getSuppliedNodes()` has the same length as the array returned by `getSuppliedValues()`. Never returns null. Cite: `com/oracle/truffle/api/dsl/UnsupportedSpecializationException.html#getSuppliedNodes()` ### getSuppliedValues() `public Object[] getSuppliedValues()`. Since 0.8 or earlier. Returns the dynamic values that were supplied to the node.The array returned by `getSuppliedNodes()` has the same length as the array returned by `getSuppliedValues()`. Never returns null. Cite: `com/oracle/truffle/api/dsl/UnsupportedSpecializationException.html#getSuppliedValues()` ## Inherited members - From class [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html): [`addSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#addSuppressed%28java.lang.Throwable%29), [`fillInStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#fillInStackTrace%28%29), [`getCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getCause%28%29), [`getLocalizedMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getLocalizedMessage%28%29), [`getStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getStackTrace%28%29), [`getSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getSuppressed%28%29), [`initCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#initCause%28java.lang.Throwable%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintStream%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintWriter%29), [`setStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#setStackTrace%28java.lang.StackTraceElement[]%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ▣ com.oracle.truffle.api.exception [truffle-api](index.md) · Every page: [llms.txt](llms.txt) Package in truffle-api. Since 20.3. This package contains a Truffle exception base class. **See also** - [`com.oracle.truffle.api.exception.AbstractTruffleException`](com/oracle/truffle/api/exception/AbstractTruffleException.md) ## Exceptions - [`AbstractTruffleException`](com/oracle/truffle/api/exception/AbstractTruffleException.md): A base class for an exception thrown during the execution of a guest language program. The following snippet shows the guest language exception implementation. # ⚡︎ AbstractTruffleException [truffle-api](index.md) › [com.oracle.truffle.api.exception](com/oracle/truffle/api/exception/index.md) · Every page: [llms.txt](llms.txt) Abstract exception in [`com.oracle.truffle.api.exception`](com/oracle/truffle/api/exception/index.md). Since 20.3. ```java public abstract class AbstractTruffleException extends RuntimeException implements TruffleObject ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) > [`Exception`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Exception.html) > [`RuntimeException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/RuntimeException.html) > `AbstractTruffleException` Implements: [`TruffleObject`](com/oracle/truffle/api/interop/TruffleObject.md) A base class for an exception thrown during the execution of a guest language program. The following snippet shows the guest language exception implementation. ```java final class MyLanguageException extends AbstractTruffleException { MyLanguageException(String message, Node location) { super(message, location); } } ``` The following snippet shows a typical implementation of a syntax error exception supporting also incomplete sources. ```java @ExportLibrary(InteropLibrary.class) final class MyLanguageParseError extends AbstractTruffleException { private final Source source; private final int line; private final int column; private final int length; private final boolean incompleteSource; MyLanguageParseError(Source source, int line, int column, int length, boolean incomplete, String message) { super(message); this.source = source; this.line = line; this.column = column; this.length = length; this.incompleteSource = incomplete; } @ExportMessage ExceptionType getExceptionType() { return ExceptionType.PARSE_ERROR; } @ExportMessage boolean isExceptionIncompleteSource() { return incompleteSource; } @ExportMessage boolean hasSourceLocation() { return source != null; } @ExportMessage(name = "getSourceLocation") SourceSection getSourceSection() throws UnsupportedMessageException { if (source == null) { throw UnsupportedMessageException.create(); } return source.createSection(line, column, length); } } ``` The following snippet shows a typical implementation of an interrupt exception. ```java @ExportLibrary(InteropLibrary.class) final class MyLanguageInterruptException extends AbstractTruffleException { MyLanguageInterruptException(String message, Node location) { super(message, location); } @ExportMessage ExceptionType getExceptionType() { return ExceptionType.INTERRUPT; } } ``` The following snippet shows a typical implementation of an soft exit exception. ```java @ExportLibrary(InteropLibrary.class) final class MyLanguageExitException extends AbstractTruffleException { private final int exitStatus; MyLanguageExitException(String message, int exitStatus, Node location) { super(message, location); this.exitStatus = exitStatus; } @ExportMessage ExceptionType getExceptionType() { return ExceptionType.EXIT; } @ExportMessage int getExceptionExitStatus() { return exitStatus; } } ``` ## Fields ### UNLIMITED_STACK_TRACE `public static final int UNLIMITED_STACK_TRACE`. Since 20.3. The constant for an unlimited stack trace element limit. Constant value: `-1`. Cite: `com/oracle/truffle/api/exception/AbstractTruffleException.html#UNLIMITED_STACK_TRACE` ## Constructors ### AbstractTruffleException() `protected AbstractTruffleException()`. Since 20.3. Creates a new AbstractTruffleException. Cite: `com/oracle/truffle/api/exception/AbstractTruffleException.html#()` ### AbstractTruffleException(Node) `protected AbstractTruffleException(Node location)`. Since 20.3. Creates a new AbstractTruffleException with given location. Cite: `com/oracle/truffle/api/exception/AbstractTruffleException.html#(com.oracle.truffle.api.nodes.Node)` ### AbstractTruffleException(String) `protected AbstractTruffleException(String message)`. Since 20.3. Creates a new AbstractTruffleException with given message. Cite: `com/oracle/truffle/api/exception/AbstractTruffleException.html#(java.lang.String)` ### AbstractTruffleException(String, Node) `protected AbstractTruffleException(String message, Node location)`. Since 20.3. Creates a new AbstractTruffleException with given message and location. Cite: `com/oracle/truffle/api/exception/AbstractTruffleException.html#(java.lang.String,com.oracle.truffle.api.nodes.Node)` ### AbstractTruffleException(AbstractTruffleException) `protected AbstractTruffleException(AbstractTruffleException prototype)`. Since 20.3. Copies the prototype's message, cause, stack trace limit, location, BCI, suppressed exceptions, and Truffle stack trace. Parameters: `prototype` `AbstractTruffleException`: the exception to copy. Cite: `com/oracle/truffle/api/exception/AbstractTruffleException.html#(com.oracle.truffle.api.exception.AbstractTruffleException)` ### AbstractTruffleException(String, Throwable, …) `protected AbstractTruffleException(String message, Throwable cause, int stackTraceElementLimit, Node location)`. Since 20.3. Creates a new AbstractTruffleException. Parameters: `message` `String`: the exception message or `null`. `cause` `Throwable`: an internal or `AbstractTruffleException` causing this exception or `null`. If internal errors are passed as cause, they are not accessible by other languages or the embedder. In other words, `InteropLibrary.getExceptionCause(Object)` or [`PolyglotException.getCause()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getCause%28%29) will return `null` for internal errors. `stackTraceElementLimit` `int`: a stack trace limit. Use `UNLIMITED_STACK_TRACE` for unlimited stack trace length. Cite: `com/oracle/truffle/api/exception/AbstractTruffleException.html#(java.lang.String,java.lang.Throwable,int,com.oracle.truffle.api.nodes.Node)` ### AbstractTruffleException(String, Throwable, …) `protected AbstractTruffleException(String message, Throwable cause, int stackTraceElementLimit, Node location, int bytecodeIndex)`. Since 25.6. Creates a new AbstractTruffleException with an explicit bytecode index for the exception location. Parameters: `message` `String`: the exception message or `null`. `cause` `Throwable`: the cause or `null`; internal causes are hidden from interop and the embedder. `stackTraceElementLimit` `int`: a stack trace limit. Use `UNLIMITED_STACK_TRACE` for unlimited stack trace length. `location` `Node`: a location node or `null`. `bytecodeIndex` `int`: a bytecode index for `location`, or `-1` if unavailable. Cite: `com/oracle/truffle/api/exception/AbstractTruffleException.html#(java.lang.String,java.lang.Throwable,int,com.oracle.truffle.api.nodes.Node,int)` ## Methods ### fillInStackTrace() `public final Throwable fillInStackTrace()`. Since 20.3. Overrides `fillInStackTrace()`. Cite: `com/oracle/truffle/api/exception/AbstractTruffleException.html#fillInStackTrace()` ### getLocation() `public final Node getLocation()`. Since 20.3. Returns a node indicating the location where this exception occurred in the AST. This method may return `null` to indicate that the location is not available. Cite: `com/oracle/truffle/api/exception/AbstractTruffleException.html#getLocation()` ### getBytecodeIndex() `public final int getBytecodeIndex()`. Since 25.6. Returns the explicit BCI associated with `getLocation()`. Returns `int`: the BCI, or a negative value if unavailable. Cite: `com/oracle/truffle/api/exception/AbstractTruffleException.html#getBytecodeIndex()` ### getEncapsulatingSourceSection() `public SourceSection getEncapsulatingSourceSection()`. Since 24.2. Returns a source section associated with the exception. This method may return `null` to indicate that the source section is not available. Note: This method is expensive as it requires to access the current stack trace to get the to-most source section. Cite: `com/oracle/truffle/api/exception/AbstractTruffleException.html#getEncapsulatingSourceSection()` ### getStackTraceElementLimit() `public final int getStackTraceElementLimit()`. Since 20.3. Returns the number of guest language frames that should be collected for this exception. Returns a negative integer by default for unlimited guest language frames. This is intended to be used by guest languages to limit the number of guest language stack frames. Languages might want to limit the number of frames for performance reasons. Only frames whose `RootNode.countsTowardsStackTraceLimit()` method return true count towards the limit. Cite: `com/oracle/truffle/api/exception/AbstractTruffleException.html#getStackTraceElementLimit()` ### getCause() `public final Throwable getCause()`. Since 20.3. Overrides `getCause()`. Cite: `com/oracle/truffle/api/exception/AbstractTruffleException.html#getCause()` ### createGuestStackTrace(Throwable) `protected final Object createGuestStackTrace(Throwable throwable)`. Since 25.1. Creates an interop representation of the stack trace for the given `throwable`. The returned object is suitable for use as the result of `InteropLibrary.getExceptionStackTrace(Object)`. Cite: `com/oracle/truffle/api/exception/AbstractTruffleException.html#createGuestStackTrace(java.lang.Throwable)` ## Inherited members - From class [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html): [`addSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#addSuppressed%28java.lang.Throwable%29), [`getLocalizedMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getLocalizedMessage%28%29), [`getMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getMessage%28%29), [`getStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getStackTrace%28%29), [`getSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getSuppressed%28%29), [`initCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#initCause%28java.lang.Throwable%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintStream%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintWriter%29), [`setStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#setStackTrace%28java.lang.StackTraceElement[]%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ▣ com.oracle.truffle.api.frame [truffle-api](index.md) · Every page: [llms.txt](llms.txt) Package in truffle-api. Since 0.8 or older. Package containing stack frame representation classes. Such a frames can be converted into [`com.oracle.truffle.api.frame.MaterializedFrame`](com/oracle/truffle/api/frame/MaterializedFrame.md) stored on a heap for later access when the actual stack is elsewhere. ## Interfaces - [`Frame`](com/oracle/truffle/api/frame/Frame.md): Represents a frame containing values of local variables of the guest language. - [`FrameInstance`](com/oracle/truffle/api/frame/FrameInstance.md): Represents a current frame instance on the stack. - [`FrameInstanceVisitor`](com/oracle/truffle/api/frame/FrameInstanceVisitor.md): Callback interface for TruffleRuntime.iterateFrames. - [`MaterializedFrame`](com/oracle/truffle/api/frame/MaterializedFrame.md): Represents a materialized frame containing values of local variables of the guest language. - [`VirtualFrame`](com/oracle/truffle/api/frame/VirtualFrame.md): Represents a frame containing values of local variables of the guest language. ## Classes - [`FrameDescriptor`](com/oracle/truffle/api/frame/FrameDescriptor.md): Descriptor of the slots of frame objects. - [`FrameExtensions`](com/oracle/truffle/api/frame/FrameExtensions.md): Internal frame accessor methods for internal Truffle components that are trusted. ## Enums - [`FrameSlotKind`](com/oracle/truffle/api/frame/FrameSlotKind.md): No description. ## Exceptions - [`FrameSlotTypeException`](com/oracle/truffle/api/frame/FrameSlotTypeException.md): Exception thrown if the frame slot kind does not match the expected kind. # ◇ Frame [truffle-api](index.md) › [com.oracle.truffle.api.frame](com/oracle/truffle/api/frame/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.frame`](com/oracle/truffle/api/frame/index.md). Since 0.8 or earlier. ```java public interface Frame ``` Represents a frame containing values of local variables of the guest language. Instances of this type must not be stored in a field or cast to [`java.lang.Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html). ## Methods ### getFrameDescriptor() `FrameDescriptor getFrameDescriptor()`. Since 0.8 or earlier. Returns `FrameDescriptor`: the object describing the layout of this frame. Cite: `com/oracle/truffle/api/frame/Frame.html#getFrameDescriptor()` ### getArguments() `Object[] getArguments()`. Since 0.8 or earlier. Retrieves the arguments object from this frame. The runtime assumes that the arguments object is never null. Returns `Object[]`: the arguments used when calling this method. Cite: `com/oracle/truffle/api/frame/Frame.html#getArguments()` ### materialize() `MaterializedFrame materialize()`. Since 0.8 or earlier. Materializes this frame, which allows it to be stored in a field or cast to [`java.lang.Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html). Returns `MaterializedFrame`: the new materialized frame. Cite: `com/oracle/truffle/api/frame/Frame.html#materialize()` ### getObject(int) `default Object getObject(int slot) throws FrameSlotTypeException`. Since 22.0. Read access to a local variable of type [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html). Parameters: `slot` `int`: the slot of the local variable. Returns `Object`: the current value of the local variable. Throws: `FrameSlotTypeException`: if the current value is not of type object. Cite: `com/oracle/truffle/api/frame/Frame.html#getObject(int)` ### expectObject(int) `default Object expectObject(int slot) throws UnexpectedResultException`. Since 24.2. Read and expects a value of type object for a given slot. Expect methods are intended to be used to implement speculative behavior where slots are expected to be tagged with a type. If the type changes an `UnexpectedResultException` will be thrown containing the result of `getValue(slot)`. Clients of this API are then expected to rewrite and no longer use an expect methods for future reads of that slot. Expect methods are particularly useful to implement stack like behavior with a frame. Parameters: `slot` `int`: the index of the slot. Returns `Object`: the value of the slot in this frame. Throws: `UnexpectedResultException`: if the current value is not of type object. Cite: `com/oracle/truffle/api/frame/Frame.html#expectObject(int)` ### setObject(int, Object) `default void setObject(int slot, Object value)`. Since 22.0. Write access to a local variable of type [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html). Parameters: `slot` `int`: the slot of the local variable. `value` `Object`: the new value of the local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#setObject(int,java.lang.Object)` ### getByte(int) `default byte getByte(int slot) throws FrameSlotTypeException`. Since 22.0. Read access to a local variable of type byte. Parameters: `slot` `int`: the slot of the local variable. Returns `byte`: the current value of the local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#getByte(int)` ### expectByte(int) `default byte expectByte(int slot) throws UnexpectedResultException`. Since 24.2. Read and expects a value of type byte for a given slot. Expect methods are intended to be used to implement speculative behavior where slots are expected to be tagged with a type. If the type changes an `UnexpectedResultException` will be thrown containing the result of `getValue(slot)`. Clients of this API are then expected to rewrite and no longer use an expect methods for future reads of that slot. Expect methods are particularly useful to implement stack like behavior with a frame. Parameters: `slot` `int`: the index of the slot. Returns `byte`: the value of the slot in this frame. Throws: `UnexpectedResultException`: if the current value is not of type byte. Cite: `com/oracle/truffle/api/frame/Frame.html#expectByte(int)` ### setByte(int, byte) `default void setByte(int slot, byte value)`. Since 22.0. Write access to a local variable of type byte. Parameters: `slot` `int`: the slot of the local variable. `value` `byte`: the new value of the local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#setByte(int,byte)` ### getBoolean(int) `default boolean getBoolean(int slot) throws FrameSlotTypeException`. Since 22.0. Read access to a local variable of type boolean. Parameters: `slot` `int`: the slot of the local variable. Returns `boolean`: the current value of the local variable. Throws: `FrameSlotTypeException`: if the current value is not of type boolean. Cite: `com/oracle/truffle/api/frame/Frame.html#getBoolean(int)` ### expectBoolean(int) `default boolean expectBoolean(int slot) throws UnexpectedResultException`. Since 24.2. Read and expects a value of type boolean for a given slot. Expect methods are intended to be used to implement speculative behavior where slots are expected to be tagged with a type. If the type changes an `UnexpectedResultException` will be thrown containing the result of `getValue(slot)`. Clients of this API are then expected to rewrite and no longer use an expect methods for future reads of that slot. Expect methods are particularly useful to implement stack like behavior with a frame. Parameters: `slot` `int`: the index of the slot. Returns `boolean`: the value of the slot in this frame. Throws: `UnexpectedResultException`: if the current value is not of type boolean. Cite: `com/oracle/truffle/api/frame/Frame.html#expectBoolean(int)` ### setBoolean(int, boolean) `default void setBoolean(int slot, boolean value)`. Since 22.0. Write access to a local variable of type boolean. Parameters: `slot` `int`: the slot of the local variable. `value` `boolean`: the new value of the local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#setBoolean(int,boolean)` ### getInt(int) `default int getInt(int slot) throws FrameSlotTypeException`. Since 22.0. Read access to a local variable of type int. Parameters: `slot` `int`: the slot of the local variable. Returns `int`: the current value of the local variable. Throws: `FrameSlotTypeException`: if the current value is not of type int. Cite: `com/oracle/truffle/api/frame/Frame.html#getInt(int)` ### expectInt(int) `default int expectInt(int slot) throws UnexpectedResultException`. Since 24.2. Read and expects a value of type int for a given slot. Expect methods are intended to be used to implement speculative behavior where slots are expected to be tagged with a type. If the type changes an `UnexpectedResultException` will be thrown containing the result of `getValue(slot)`. Clients of this API are then expected to rewrite and no longer use an expect methods for future reads of that slot. Expect methods are particularly useful to implement stack like behavior with a frame. Parameters: `slot` `int`: the index of the slot. Returns `int`: the value of the slot in this frame. Throws: `UnexpectedResultException`: if the current value is not of type int. Cite: `com/oracle/truffle/api/frame/Frame.html#expectInt(int)` ### setInt(int, int) `default void setInt(int slot, int value)`. Since 22.0. Write access to a local variable of type int. Parameters: `slot` `int`: the slot of the local variable. `value` `int`: the new value of the local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#setInt(int,int)` ### getLong(int) `default long getLong(int slot) throws FrameSlotTypeException`. Since 22.0. Read access to a local variable of type long. Parameters: `slot` `int`: the slot of the local variable. Returns `long`: the current value of the local variable. Throws: `FrameSlotTypeException`: if the current value is not of type long. Cite: `com/oracle/truffle/api/frame/Frame.html#getLong(int)` ### expectLong(int) `default long expectLong(int slot) throws UnexpectedResultException`. Since 24.2. Read and expects a value of type long for a given slot. Expect methods are intended to be used to implement speculative behavior where slots are expected to be tagged with a type. If the type changes an `UnexpectedResultException` will be thrown containing the result of `getValue(slot)`. Clients of this API are then expected to rewrite and no longer use an expect methods for future reads of that slot. Expect methods are particularly useful to implement stack like behavior with a frame. Parameters: `slot` `int`: the index of the slot. Returns `long`: the value of the slot in this frame. Throws: `UnexpectedResultException`: if the current value is not of type long. Cite: `com/oracle/truffle/api/frame/Frame.html#expectLong(int)` ### setLong(int, long) `default void setLong(int slot, long value)`. Since 22.0. Write access to a local variable of type long. Parameters: `slot` `int`: the slot of the local variable. `value` `long`: the new value of the local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#setLong(int,long)` ### getFloat(int) `default float getFloat(int slot) throws FrameSlotTypeException`. Since 22.0. Read access to a local variable of type float. Parameters: `slot` `int`: the slot of the local variable. Returns `float`: the current value of the local variable. Throws: `FrameSlotTypeException`: if the current value is not of type float. Cite: `com/oracle/truffle/api/frame/Frame.html#getFloat(int)` ### expectFloat(int) `default float expectFloat(int slot) throws UnexpectedResultException`. Since 24.2. Read and expects a value of type float for a given slot. Expect methods are intended to be used to implement speculative behavior where slots are expected to be tagged with a type. If the type changes an `UnexpectedResultException` will be thrown containing the result of `getValue(slot)`. Clients of this API are then expected to rewrite and no longer use an expect methods for future reads of that slot. Expect methods are particularly useful to implement stack like behavior with a frame. Parameters: `slot` `int`: the index of the slot. Returns `float`: the value of the slot in this frame. Throws: `UnexpectedResultException`: if the current value is not of type float. Cite: `com/oracle/truffle/api/frame/Frame.html#expectFloat(int)` ### setFloat(int, float) `default void setFloat(int slot, float value)`. Since 22.0. Write access to a local variable of type float. Parameters: `slot` `int`: the slot of the local variable. `value` `float`: the new value of the local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#setFloat(int,float)` ### getDouble(int) `default double getDouble(int slot) throws FrameSlotTypeException`. Since 22.0. Read access to a local variable of type double. Parameters: `slot` `int`: the slot of the local variable. Returns `double`: the current value of the local variable. Throws: `FrameSlotTypeException`: if the current value is not of type double. Cite: `com/oracle/truffle/api/frame/Frame.html#getDouble(int)` ### expectDouble(int) `default double expectDouble(int slot) throws UnexpectedResultException`. Since 24.2. Read and expects a value of type double for a given slot. Expect methods are intended to be used to implement speculative behavior where slots are expected to be tagged with a type. If the type changes an `UnexpectedResultException` will be thrown containing the result of `getValue(slot)`. Clients of this API are then expected to rewrite and no longer use an expect methods for future reads of that slot. Expect methods are particularly useful to implement stack like behavior with a frame. Parameters: `slot` `int`: the index of the slot. Returns `double`: the value of the slot in this frame. Throws: `UnexpectedResultException`: if the current value is not of type double. Cite: `com/oracle/truffle/api/frame/Frame.html#expectDouble(int)` ### setDouble(int, double) `default void setDouble(int slot, double value)`. Since 22.0. Write access to a local variable of type double. Parameters: `slot` `int`: the slot of the local variable. `value` `double`: the new value of the local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#setDouble(int,double)` ### getValue(int) `default Object getValue(int slot)`. Since 22.0. Read access to a local variable of any type. Parameters: `slot` `int`: the slot of the local variable. Returns `Object`: the current value of the local variable or defaultValue if unset. Cite: `com/oracle/truffle/api/frame/Frame.html#getValue(int)` ### copy(int, int) `default void copy(int srcSlot, int destSlot)`. Since 22.0. Copies, including the type, from one slot to another. Parameters: `srcSlot` `int`: the slot of the source local variable. `destSlot` `int`: the slot of the target local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#copy(int,int)` ### swap(int, int) `default void swap(int first, int second)`. Since 22.0. Swaps, including the type, the contents of two slots. Parameters: `first` `int`: the slot of the first local variable. `second` `int`: the slot of the second local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#swap(int,int)` ### getTag(int) `default byte getTag(int slot)`. Since 22.0. Determines the actual `FrameSlotKind` of the value in the slot, and returns it as `FrameSlotKind.tag`. Parameters: `slot` `int`: the slot of the local variable. Returns `byte`: the tag of the value in the slot. Cite: `com/oracle/truffle/api/frame/Frame.html#getTag(int)` ### isObject(int) `default boolean isObject(int slot)`. Since 22.0. Check whether the given indexed slot is of type object. This method should not be used with static slots. Parameters: `slot` `int`: the slot of the local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#isObject(int)` ### isByte(int) `default boolean isByte(int slot)`. Since 22.0. Check whether the given indexed slot is of type byte. This method should not be used with static slots. Parameters: `slot` `int`: the slot of the local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#isByte(int)` ### isBoolean(int) `default boolean isBoolean(int slot)`. Since 22.0. Check whether the given indexed slot is of type boolean. This method should not be used with static slots. Parameters: `slot` `int`: the slot of the local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#isBoolean(int)` ### isInt(int) `default boolean isInt(int slot)`. Since 22.0. Check whether the given indexed slot is of type int. This method should not be used with static slots. Parameters: `slot` `int`: the slot of the local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#isInt(int)` ### isLong(int) `default boolean isLong(int slot)`. Since 22.0. Check whether the given indexed slot is of type long. This method should not be used with static slots. Parameters: `slot` `int`: the slot of the local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#isLong(int)` ### isFloat(int) `default boolean isFloat(int slot)`. Since 22.0. Check whether the given indexed slot is of type float. This method should not be used with static slots. Parameters: `slot` `int`: the slot of the local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#isFloat(int)` ### isDouble(int) `default boolean isDouble(int slot)`. Since 22.0. Check whether the given indexed slot is of type double. This method should not be used with static slots. Parameters: `slot` `int`: the slot of the local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#isDouble(int)` ### isStatic(int) `default boolean isStatic(int slot)`. Since 22.2. Checks whether the given indexed slot is static. This method should not be used with static slots. Parameters: `slot` `int`: the slot of the local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#isStatic(int)` ### clear(int) `default void clear(int slot)`. Since 22.0. Clears the given indexed slot in the frame. Writing over a previously cleared slot is still allowed. Subsequent reads to this slot, unless re-written to, will fail with `FrameSlotTypeException`. This method is intended to be used for implementations of liveness analysis. As such, the compiler will find and report any inconsistency with respect to liveness analysis when using this method, such as clearing a slot in a branch, but not on another one, and their execution merge. Liveness analysis implementations are expected to clear unused slots on method entry. Parameters: `slot` `int`: the slot of the local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#clear(int)` ### getAuxiliarySlot(int) `default Object getAuxiliarySlot(int slot)`. Since 22.0. Parameters: `slot` `int`: the auxiliary slot index to query. Returns `Object`: the current value of the auxiliary slot - `null` if it was never set (not the frame descriptor's default value). Cite: `com/oracle/truffle/api/frame/Frame.html#getAuxiliarySlot(int)` ### setAuxiliarySlot(int, Object) `default void setAuxiliarySlot(int slot, Object value)`. Since 22.0. Sets the value of the given auxiliary slot. Parameters: `slot` `int`: the auxiliary slot index. `value` `Object`: the new value. Cite: `com/oracle/truffle/api/frame/Frame.html#setAuxiliarySlot(int,java.lang.Object)` ### getObjectStatic(int) `default Object getObjectStatic(int slot)`. Since 22.2. Static read access to a local variable of type [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html). Requires the given slot to use `FrameSlotKind.Static`. Since this method does not perform any type checks, language implementations have to guarantee that the variable in the given slot is of type [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html). Parameters: `slot` `int`: the slot of the local variable. Returns `Object`: the current value of the local variable, or `null` if slot is uninitialized. Cite: `com/oracle/truffle/api/frame/Frame.html#getObjectStatic(int)` ### setObjectStatic(int, Object) `default void setObjectStatic(int slot, Object value)`. Since 22.2. Static write access to a local variable of type [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html). Requires the given slot to use `FrameSlotKind.Static`. Since this method does not update the internal slot type, language implementations have to track this information. Parameters: `slot` `int`: the slot of the local variable. `value` `Object`: the new value of the local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#setObjectStatic(int,java.lang.Object)` ### getByteStatic(int) `default byte getByteStatic(int slot)`. Since 22.2. Static read access to a local variable of type byte. Requires the given slot to use `FrameSlotKind.Static`. Since this method does not perform any type checks, language implementations have to guarantee that the variable in the given slot is of type byte. Parameters: `slot` `int`: the slot of the local variable. Returns `byte`: the current value of the local variable, or `0` if slot is uninitialized. Cite: `com/oracle/truffle/api/frame/Frame.html#getByteStatic(int)` ### setByteStatic(int, byte) `default void setByteStatic(int slot, byte value)`. Since 22.2. Static write access to a local variable of type byte. Requires the given slot to use `FrameSlotKind.Static`. Since this method does not update the internal slot type, language implementations have to track this information. Parameters: `slot` `int`: the slot of the local variable. `value` `byte`: the new value of the local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#setByteStatic(int,byte)` ### getBooleanStatic(int) `default boolean getBooleanStatic(int slot)`. Since 22.2. Static read access to a local variable of type boolean. Requires the given slot to use `FrameSlotKind.Static`. Since this method does not perform any type checks, language implementations have to guarantee that the variable in the given slot is of type boolean. Parameters: `slot` `int`: the slot of the local variable. Returns `boolean`: the current value of the local variable, or `false` if slot is uninitialized. Cite: `com/oracle/truffle/api/frame/Frame.html#getBooleanStatic(int)` ### setBooleanStatic(int, boolean) `default void setBooleanStatic(int slot, boolean value)`. Since 22.2. Static write access to a local variable of type boolean. Requires the given slot to use `FrameSlotKind.Static`. Since this method does not update the internal slot type, language implementations have to track this information. Parameters: `slot` `int`: the slot of the local variable. `value` `boolean`: the new value of the local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#setBooleanStatic(int,boolean)` ### getIntStatic(int) `default int getIntStatic(int slot)`. Since 22.2. Static read access to a local variable of type int. Requires the given slot to use `FrameSlotKind.Static`. Since this method does not perform any type checks, language implementations have to guarantee that the variable in the given slot can is of type int. Parameters: `slot` `int`: the slot of the local variable. Returns `int`: the current value of the local variable, or `0` if slot is uninitialized. Cite: `com/oracle/truffle/api/frame/Frame.html#getIntStatic(int)` ### setIntStatic(int, int) `default void setIntStatic(int slot, int value)`. Since 22.2. Static write access to a local variable of type int. Requires the given slot to use `FrameSlotKind.Static`. Since this method does not update the internal slot type, language implementations have to track this information. Parameters: `slot` `int`: the slot of the local variable. `value` `int`: the new value of the local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#setIntStatic(int,int)` ### getLongStatic(int) `default long getLongStatic(int slot)`. Since 22.2. Static read access to a local variable of type long. Requires the given slot to use `FrameSlotKind.Static`. Since this method does not perform any type checks, language implementations have to guarantee that the variable in the given slot is of type long. Parameters: `slot` `int`: the slot of the local variable. Returns `long`: the current value of the local variable, or `0` if slot is uninitialized. Cite: `com/oracle/truffle/api/frame/Frame.html#getLongStatic(int)` ### setLongStatic(int, long) `default void setLongStatic(int slot, long value)`. Since 22.2. Static write access to a local variable of type long. Requires the given slot to use `FrameSlotKind.Static`. Since this method does not update the internal slot type, language implementations have to track this information. Parameters: `slot` `int`: the slot of the local variable. `value` `long`: the new value of the local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#setLongStatic(int,long)` ### getFloatStatic(int) `default float getFloatStatic(int slot)`. Since 22.2. Static read access to a local variable of type float. Requires the given slot to use `FrameSlotKind.Static`. Since this method does not perform any type checks, language implementations have to guarantee that the variable in the given slot is of type float. Parameters: `slot` `int`: the slot of the local variable. Returns `float`: the current value of the local variable, or `0` if slot is uninitialized. Cite: `com/oracle/truffle/api/frame/Frame.html#getFloatStatic(int)` ### setFloatStatic(int, float) `default void setFloatStatic(int slot, float value)`. Since 22.2. Static write access to a local variable of type float. Requires the given slot to use `FrameSlotKind.Static`. Since this method does not update the internal slot type, language implementations have to track this information. Parameters: `slot` `int`: the slot of the local variable. `value` `float`: the new value of the local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#setFloatStatic(int,float)` ### getDoubleStatic(int) `default double getDoubleStatic(int slot)`. Since 22.2. Static read access to a local variable of type double. Requires the given slot to use `FrameSlotKind.Static`. Since this method does not perform any type checks, language implementations have to guarantee that the variable in the given slot is of type double. Parameters: `slot` `int`: the slot of the local variable. Returns `double`: the current value of the local variable, or `0` if slot is uninitialized. Cite: `com/oracle/truffle/api/frame/Frame.html#getDoubleStatic(int)` ### setDoubleStatic(int, double) `default void setDoubleStatic(int slot, double value)`. Since 22.2. Static write access to a local variable of type double. Requires the given slot to use `FrameSlotKind.Static`. Since this method does not update the internal slot type, language implementations have to track this information. Parameters: `slot` `int`: the slot of the local variable. `value` `double`: the new value of the local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#setDoubleStatic(int,double)` ### copyPrimitiveStatic(int, int) `default void copyPrimitiveStatic(int srcSlot, int destSlot)`. Since 22.2. Copies a primitive value from one slot to another. Requires both slots to use `FrameSlotKind.Static`. Since this method does not perform any type checks, language implementations have to guarantee that the variable at the source slot is a primitive value. Parameters: `srcSlot` `int`: the slot of the source local variable. `destSlot` `int`: the slot of the target local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#copyPrimitiveStatic(int,int)` ### copyObjectStatic(int, int) `default void copyObjectStatic(int srcSlot, int destSlot)`. Since 22.2. Copies an object value from one slot to another. Requires both slots to use `FrameSlotKind.Static`. Since this method does not perform any type checks, language implementations have to guarantee that the variable at the source slot is an [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html). Parameters: `srcSlot` `int`: the slot of the source local variable. `destSlot` `int`: the slot of the target local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#copyObjectStatic(int,int)` ### copyStatic(int, int) `default void copyStatic(int srcSlot, int destSlot)`. Since 22.3. Copies from one slot to another. Requires both slots to use `FrameSlotKind.Static`. In cases where the underlying slot type is known, `Frame.copyPrimitiveStatic` and `Frame.copyObjectStatic` should be used for performance reasons. Parameters: `srcSlot` `int`: the slot of the source local variable. `destSlot` `int`: the slot of the target local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#copyStatic(int,int)` ### swapPrimitiveStatic(int, int) `default void swapPrimitiveStatic(int first, int second)`. Since 22.3. Swaps the primitive values of two slots. Requires both slots to use `FrameSlotKind.Static`. Since this method does not perform any type checks, language implementations have to guarantee that the variables in both slots are primitive values. Parameters: `first` `int`: the slot of the first local variable. `second` `int`: the slot of the second local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#swapPrimitiveStatic(int,int)` ### swapObjectStatic(int, int) `default void swapObjectStatic(int first, int second)`. Since 22.3. Swaps the object values of two slots. Requires both slots to use `FrameSlotKind.Static`. Since this method does not perform any type checks, language implementations have to guarantee that the variables in both slots are [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html)s. Parameters: `first` `int`: the slot of the first local variable. `second` `int`: the slot of the second local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#swapObjectStatic(int,int)` ### swapStatic(int, int) `default void swapStatic(int first, int second)`. Since 22.3. Swaps the contents of two slots. Requires both slots to use `FrameSlotKind.Static`. In cases where the underlying slot type is known, `Frame.swapPrimitiveStatic` and `Frame.swapObjectStatic` should be used for performance reasons. Parameters: `first` `int`: the slot of the first local variable. `second` `int`: the slot of the second local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#swapStatic(int,int)` ### clearPrimitiveStatic(int) `default void clearPrimitiveStatic(int slot)`. Since 22.2. Clears the primitive value at the given slot in the frame. Requires the given slot to use `FrameSlotKind.Static`. Writing over a previously cleared slot is still allowed. Subsequent reads to the slot, unless re-written to, are not allowed and will fail with an [`AssertionError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AssertionError.html) if assertions are enabled. Since this method does not perform any type checks, language implementations have to guarantee that the variable at the given slot is a primitive value. This method is intended to be used for implementations of liveness analysis. As such, the compiler will find and report any inconsistency with respect to liveness analysis when using this method, such as clearing a slot in a branch, but not on another one, and their execution merge. Liveness analysis implementations are expected to clear unused slots on method entry. Parameters: `slot` `int`: the slot of the local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#clearPrimitiveStatic(int)` ### clearObjectStatic(int) `default void clearObjectStatic(int slot)`. Since 22.2. Clears the object value at the given slot in the frame. Requires the given slot to use `FrameSlotKind.Static`. Writing over a previously cleared slot is still allowed. Subsequent reads to the slot, unless re-written to, are not allowed and will fail with an [`AssertionError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AssertionError.html) if assertions are enabled. Since this method does not perform any type checks, language implementations have to guarantee that the variable at the given slot is an [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html). This method is intended to be used for implementations of liveness analysis. As such, the compiler will find and report any inconsistency with respect to liveness analysis when using this method, such as clearing a slot in a branch, but not on another one, and their execution merge. Liveness analysis implementations are expected to clear unused slots on method entry. Parameters: `slot` `int`: the slot of the local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#clearObjectStatic(int)` ### clearStatic(int) `default void clearStatic(int slot)`. Since 22.3. Clears the value at the given slot in the frame. Requires the given slot to use `FrameSlotKind.Static`. Writing over a previously cleared slot is still allowed. Subsequent reads to the slot, unless re-written to, are not allowed and will fail with an [`AssertionError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AssertionError.html) if assertions are enabled. In cases where the underlying slot type is known, `Frame.clearPrimitiveStatic` and `Frame.clearObjectStatic` should be used for performance reasons. Parameters: `slot` `int`: The slot of the local variable. Cite: `com/oracle/truffle/api/frame/Frame.html#clearStatic(int)` ### copyTo(int, Frame, …) `default void copyTo(int sourceOffset, Frame destination, int destinationOffset, int length)`. Since 24.2. Copies values from this frame to the given frame. The frames are required to have the same `frame descriptors`. Parameters: `sourceOffset` `int`: the slot of the first local variable. `destination` `Frame`: the destination frame. `destinationOffset` `int`: the first slot to copy locals into. `length` `int`: the number of slots to copy. Throws: `IllegalArgumentException` (unchecked): if a frame using a different `FrameDescriptor` is passed. `IndexOutOfBoundsException` (unchecked): if an invalid offset or length was passed. Cite: `com/oracle/truffle/api/frame/Frame.html#copyTo(int,com.oracle.truffle.api.frame.Frame,int,int)` # ◆ FrameDescriptor [truffle-api](index.md) › [com.oracle.truffle.api.frame](com/oracle/truffle/api/frame/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.frame`](com/oracle/truffle/api/frame/index.md). Since 0.8 or earlier. ```java public final class FrameDescriptor implements Cloneable ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `FrameDescriptor` Implements: [`Cloneable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Cloneable.html) Descriptor of the slots of frame objects. Multiple frame instances are associated with one such descriptor. The FrameDescriptor is thread-safe. ## Nested types - [`FrameDescriptor.Builder`](com/oracle/truffle/api/frame/FrameDescriptor.Builder.md) (class): Builder API for frame descriptors with indexed slots. ## Constructors ### FrameDescriptor() `public FrameDescriptor()`. Since 0.8 or earlier. Constructs empty descriptor. The `getDefaultValue()` is `null`. Cite: `com/oracle/truffle/api/frame/FrameDescriptor.html#()` ### FrameDescriptor(Object) `public FrameDescriptor(Object defaultValue)`. Since 0.8 or earlier. Constructs new descriptor with specified `getDefaultValue()`. Parameters: `defaultValue` `Object`: to be returned from `getDefaultValue()`. Cite: `com/oracle/truffle/api/frame/FrameDescriptor.html#(java.lang.Object)` ## Methods ### copy() `public FrameDescriptor copy()`. Since 0.8 or earlier. Deeper copy of the descriptor. Copies all slots in the descriptor, but only their identifier and info but not their kind! Returns `FrameDescriptor`: new instance of a descriptor with copies of values from this one. Cite: `com/oracle/truffle/api/frame/FrameDescriptor.html#copy()` ### getDefaultValue() `public Object getDefaultValue()`. Since 0.8 or earlier. Default value for the created slots. Returns `Object`: value provided to `FrameDescriptor(java.lang.Object)`. Cite: `com/oracle/truffle/api/frame/FrameDescriptor.html#getDefaultValue()` ### toString() `public String toString()`. Since 0.8 or earlier. Overrides `toString()`. Cite: `com/oracle/truffle/api/frame/FrameDescriptor.html#toString()` ### getNumberOfSlots() `public int getNumberOfSlots()`. Since 22.0. Returns `int`: the number of indexed slots in this frame descriptor. Cite: `com/oracle/truffle/api/frame/FrameDescriptor.html#getNumberOfSlots()` ### getSlotKind(int) `public FrameSlotKind getSlotKind(int slot)`. Since 22.0. Returns the `FrameSlotKind` associated with the given indexed slot. Parameters: `slot` `int`: index of the slot. Returns `FrameSlotKind`: a non-null `FrameSlotKind`. Cite: `com/oracle/truffle/api/frame/FrameDescriptor.html#getSlotKind(int)` ### setSlotKind(int, FrameSlotKind) `public void setSlotKind(int slot, FrameSlotKind kind)`. Since 22.0. Sets the `FrameSlotKind` of the given indexed slot. Parameters: `slot` `int`: index of the slot. `kind` `FrameSlotKind`: new non-null `FrameSlotKind`. Cite: `com/oracle/truffle/api/frame/FrameDescriptor.html#setSlotKind(int,com.oracle.truffle.api.frame.FrameSlotKind)` ### getSlotName(int) `public Object getSlotName(int slot)`. Since 22.0. Queries the name for a given indexed slot. Parameters: `slot` `int`: index of the slot. Returns `Object`: the name of the slot (may be `null`). Cite: `com/oracle/truffle/api/frame/FrameDescriptor.html#getSlotName(int)` ### getSlotInfo(int) `public Object getSlotInfo(int slot)`. Since 22.0. Queries the info object for a given indexed slot. Parameters: `slot` `int`: index of the slot. Returns `Object`: the info object of the slot (may be `null`). Cite: `com/oracle/truffle/api/frame/FrameDescriptor.html#getSlotInfo(int)` ### findOrAddAuxiliarySlot(Object) `public int findOrAddAuxiliarySlot(Object key)`. Since 22.0. Find or adds an auxiliary slot to this frame descriptor. Returns an integer index that can be used to access the auxiliary slot in the frame. Parameters: `key` `Object`: used as a hash map entry. Returns `int`: an integer that can be used to access the auxiliary slot in the frame. Cite: `com/oracle/truffle/api/frame/FrameDescriptor.html#findOrAddAuxiliarySlot(java.lang.Object)` ### disableAuxiliarySlot(Object) `public void disableAuxiliarySlot(Object key)`. Since 22.0. Disables the auxiliary slot with the given key, so that subsequently created `Frame` instances may avoid allocating storage for it. Depending on the internal storage layout, it may not be possible to remove the storage for individual slots, so it is important to disable \_all\_ unused slots. Parameters: `key` `Object`: the key, as passed to `findOrAddAuxiliarySlot(Object)`. Cite: `com/oracle/truffle/api/frame/FrameDescriptor.html#disableAuxiliarySlot(java.lang.Object)` ### getAuxiliarySlots() `public Map getAuxiliarySlots()`. Since 22.0. Returns all currently active auxiliary slots along with their indexes. This is a slow operation that returns a data structure that is not backed by the frame descriptor, i.e., which does not reflect changes to the set of active auxiliary slots in either direction. Cite: `com/oracle/truffle/api/frame/FrameDescriptor.html#getAuxiliarySlots()` ### getNumberOfAuxiliarySlots() `public int getNumberOfAuxiliarySlots()`. Since 22.0. Returns `int`: the current number of auxiliary slots in this frame descriptor. Cite: `com/oracle/truffle/api/frame/FrameDescriptor.html#getNumberOfAuxiliarySlots()` ### getInfo() `public Object getInfo()`. Since 22.1. Returns `Object`: the user-defined info object associated with this frame descriptor. Cite: `com/oracle/truffle/api/frame/FrameDescriptor.html#getInfo()` ### newBuilder() `public static FrameDescriptor.Builder newBuilder()`. Since 22.0. Builds a new frame descriptor with index-based frame slots. Cite: `com/oracle/truffle/api/frame/FrameDescriptor.html#newBuilder()` ### newBuilder(int) `public static FrameDescriptor.Builder newBuilder(int capacity)`. Since 22.0. Builds a new frame descriptor with index-based frame slots. Parameters: `capacity` `int`: the expected number of index-based frame slots (taken as a hint when allocating internal data structures). Cite: `com/oracle/truffle/api/frame/FrameDescriptor.html#newBuilder(int)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ FrameDescriptor.Builder [truffle-api](index.md) › [com.oracle.truffle.api.frame](com/oracle/truffle/api/frame/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.frame`](com/oracle/truffle/api/frame/index.md). Since 22.0. Nested in [`FrameDescriptor`](com/oracle/truffle/api/frame/FrameDescriptor.md). ```java public static final class FrameDescriptor.Builder ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Builder` Builder API for frame descriptors with indexed slots. ## Methods ### defaultValue(Object) `public FrameDescriptor.Builder defaultValue(Object newDefaultValue)`. Since 22.0. Sets the default value for the frame slots in this frame descriptor. Parameters: `newDefaultValue` `Object`: the default value for the resulting frame descriptor. Cite: `com/oracle/truffle/api/frame/FrameDescriptor.Builder.html#defaultValue(java.lang.Object)` ### defaultValueIllegal() `public FrameDescriptor.Builder defaultValueIllegal()`. Since 24.2. Sets the default value to illegal, this means that an `FrameSlotTypeException` is thrown if a slot is read before it is written. A frame descriptor can either have a concrete `default value` or an `illegal default value`, but not both. Cite: `com/oracle/truffle/api/frame/FrameDescriptor.Builder.html#defaultValueIllegal()` ### addSlots(int, FrameSlotKind) `public int addSlots(int count, FrameSlotKind kind)`. Since 22.0. Adds the given number of consecutive indexed slots to the `FrameDescriptor`, and initializes them with the given kind. Parameters: `count` `int`: number of slots to be added. `kind` `FrameSlotKind`: default type of the newly added frame slots. Returns `int`: index of the first slot. Cite: `com/oracle/truffle/api/frame/FrameDescriptor.Builder.html#addSlots(int,com.oracle.truffle.api.frame.FrameSlotKind)` ### addSlots(int) `public int addSlots(int count)`. Since 24.2. Adds the given number of consecutive indexed slots to the `FrameDescriptor`, and initializes them without a kind. If the kind is read anyway then Illegal will be returned and setting the kind will throw an [`UnsupportedOperationException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/UnsupportedOperationException.html). Parameters: `count` `int`: the number of slots to add. See also: `to disable slot kinds all together.`. Cite: `com/oracle/truffle/api/frame/FrameDescriptor.Builder.html#addSlots(int)` ### useSlotKinds(boolean) `public FrameDescriptor.Builder useSlotKinds(boolean b)`. Since 24.2. Enables the use of slot kinds like `FrameDescriptor.getSlotKind(int)`. By default slot kinds are enabled. If they are disabled then `FrameDescriptor.getSlotKind(int)` always returns `FrameSlotKind.Illegal` and no slot with a different slot kind than `FrameSlotKind.Illegal` must be added. Cite: `com/oracle/truffle/api/frame/FrameDescriptor.Builder.html#useSlotKinds(boolean)` ### addSlot(FrameSlotKind, Object, Object) `public int addSlot(FrameSlotKind kind, Object name, Object info)`. Since 22.0. Adds an indexed frame slot to the `FrameDescriptor`. The frame descriptor's internal arrays for storing `name` and `info` are allocated only when needed, so using only `null` reduces memory footprint. Parameters: `kind` `FrameSlotKind`: default type of the newly added frame slot. `name` `Object`: Name of the newly added frame slot. Can (and should, if possible) be null. `info` `Object`: Info object for the newly added frame slot. Can (and should, if possible) be null. Cite: `com/oracle/truffle/api/frame/FrameDescriptor.Builder.html#addSlot(com.oracle.truffle.api.frame.FrameSlotKind,java.lang.Object,java.lang.Object)` ### info(Object) `public FrameDescriptor.Builder info(Object info)`. Since 22.1. Adds a user-defined info object to the frame descriptor. The contents of this object are strongly referenced from the frame descriptor and can be queried using `FrameDescriptor.getInfo()`. They do not influence the semantics of the frame descriptor in any other way. Parameters: `info` `Object`: the user-defined info object. Cite: `com/oracle/truffle/api/frame/FrameDescriptor.Builder.html#info(java.lang.Object)` ### build() `public FrameDescriptor build()`. Since 22.0. Uses the data provided to this builder to create a new `FrameDescriptor`. Returns `FrameDescriptor`: the newly created `FrameDescriptor`. Cite: `com/oracle/truffle/api/frame/FrameDescriptor.Builder.html#build()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ FrameExtensions [truffle-api](index.md) › [com.oracle.truffle.api.frame](com/oracle/truffle/api/frame/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.frame`](com/oracle/truffle/api/frame/index.md). ```java public abstract class FrameExtensions ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `FrameExtensions` Internal frame accessor methods for internal Truffle components that are trusted. ## Constructors ### FrameExtensions() `protected FrameExtensions()`. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#()` ## Methods ### getObject(Frame, int) `public abstract Object getObject(Frame frame, int slot) throws FrameSlotTypeException`. Since 24.2. Reads an object from the frame. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#getObject(com.oracle.truffle.api.frame.Frame,int)` ### getObject(Frame, long) `public Object getObject(Frame frame, long slot) throws FrameSlotTypeException`. Since 25.1. Reads an object from the frame. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#getObject(com.oracle.truffle.api.frame.Frame,long)` ### setObject(Frame, int, Object) `public abstract void setObject(Frame frame, int slot, Object value)`. Since 24.2. Stores an Object into the frame. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#setObject(com.oracle.truffle.api.frame.Frame,int,java.lang.Object)` ### setObject(Frame, long, Object) `public void setObject(Frame frame, long slot, Object value)`. Since 25.1. Stores an Object into the frame. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#setObject(com.oracle.truffle.api.frame.Frame,long,java.lang.Object)` ### setBoolean(Frame, int, boolean) `public abstract void setBoolean(Frame frame, int slot, boolean value)`. Since 24.2. Stores a boolean into the frame. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#setBoolean(com.oracle.truffle.api.frame.Frame,int,boolean)` ### setBoolean(Frame, long, boolean) `public void setBoolean(Frame frame, long slot, boolean value)`. Since 25.1. Stores a boolean into the frame. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#setBoolean(com.oracle.truffle.api.frame.Frame,long,boolean)` ### setByte(Frame, int, byte) `public abstract void setByte(Frame frame, int slot, byte value)`. Since 24.2. Stores a byte into the frame. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#setByte(com.oracle.truffle.api.frame.Frame,int,byte)` ### setByte(Frame, long, byte) `public void setByte(Frame frame, long slot, byte value)`. Since 25.1. Stores a byte into the frame. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#setByte(com.oracle.truffle.api.frame.Frame,long,byte)` ### setInt(Frame, int, int) `public abstract void setInt(Frame frame, int slot, int value)`. Since 24.2. Stores an int into the frame. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#setInt(com.oracle.truffle.api.frame.Frame,int,int)` ### setInt(Frame, long, int) `public void setInt(Frame frame, long slot, int value)`. Since 25.1. Stores an int into the frame. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#setInt(com.oracle.truffle.api.frame.Frame,long,int)` ### setLong(Frame, int, long) `public abstract void setLong(Frame frame, int slot, long value)`. Since 24.2. Stores a long into the frame. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#setLong(com.oracle.truffle.api.frame.Frame,int,long)` ### setLong(Frame, long, long) `public void setLong(Frame frame, long slot, long value)`. Since 25.1. Stores a long into the frame. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#setLong(com.oracle.truffle.api.frame.Frame,long,long)` ### setLongOrObject(Frame, int, Object) `public final void setLongOrObject(Frame frame, int slot, Object value)`. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#setLongOrObject(com.oracle.truffle.api.frame.Frame,int,java.lang.Object)` ### setLongOrObject(Frame, long, Object) `public void setLongOrObject(Frame frame, long slot, Object value)`. Since 25.1. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#setLongOrObject(com.oracle.truffle.api.frame.Frame,long,java.lang.Object)` ### setIntOrObject(Frame, int, Object) `public final void setIntOrObject(Frame frame, int slot, Object value)`. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#setIntOrObject(com.oracle.truffle.api.frame.Frame,int,java.lang.Object)` ### setIntOrObject(Frame, long, Object) `public void setIntOrObject(Frame frame, long slot, Object value)`. Since 25.1. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#setIntOrObject(com.oracle.truffle.api.frame.Frame,long,java.lang.Object)` ### setByteOrObject(Frame, int, Object) `public final void setByteOrObject(Frame frame, int slot, Object value)`. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#setByteOrObject(com.oracle.truffle.api.frame.Frame,int,java.lang.Object)` ### setByteOrObject(Frame, long, Object) `public void setByteOrObject(Frame frame, long slot, Object value)`. Since 25.1. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#setByteOrObject(com.oracle.truffle.api.frame.Frame,long,java.lang.Object)` ### setBooleanOrObject(Frame, int, Object) `public final void setBooleanOrObject(Frame frame, int slot, Object value)`. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#setBooleanOrObject(com.oracle.truffle.api.frame.Frame,int,java.lang.Object)` ### setBooleanOrObject(Frame, long, Object) `public void setBooleanOrObject(Frame frame, long slot, Object value)`. Since 25.1. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#setBooleanOrObject(com.oracle.truffle.api.frame.Frame,long,java.lang.Object)` ### setFloatOrObject(Frame, int, Object) `public final void setFloatOrObject(Frame frame, int slot, Object value)`. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#setFloatOrObject(com.oracle.truffle.api.frame.Frame,int,java.lang.Object)` ### setFloatOrObject(Frame, long, Object) `public void setFloatOrObject(Frame frame, long slot, Object value)`. Since 25.1. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#setFloatOrObject(com.oracle.truffle.api.frame.Frame,long,java.lang.Object)` ### setDoubleOrObject(Frame, int, Object) `public final void setDoubleOrObject(Frame frame, int slot, Object value)`. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#setDoubleOrObject(com.oracle.truffle.api.frame.Frame,int,java.lang.Object)` ### setDoubleOrObject(Frame, long, Object) `public void setDoubleOrObject(Frame frame, long slot, Object value)`. Since 25.1. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#setDoubleOrObject(com.oracle.truffle.api.frame.Frame,long,java.lang.Object)` ### setFloat(Frame, int, float) `public abstract void setFloat(Frame frame, int slot, float value)`. Since 24.2. Stores a float into the frame. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#setFloat(com.oracle.truffle.api.frame.Frame,int,float)` ### setFloat(Frame, long, float) `public void setFloat(Frame frame, long slot, float value)`. Since 25.1. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#setFloat(com.oracle.truffle.api.frame.Frame,long,float)` ### setDouble(Frame, int, double) `public abstract void setDouble(Frame frame, int slot, double value)`. Since 24.2. Stores a double into the frame. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#setDouble(com.oracle.truffle.api.frame.Frame,int,double)` ### setDouble(Frame, long, double) `public void setDouble(Frame frame, long slot, double value)`. Since 25.1. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#setDouble(com.oracle.truffle.api.frame.Frame,long,double)` ### expectBoolean(Frame, int) `public abstract boolean expectBoolean(Frame frame, int slot) throws UnexpectedResultException`. Since 24.2. Reads a boolean from the frame, throwing an `UnexpectedResultException` with the slot value when the tag does not match. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#expectBoolean(com.oracle.truffle.api.frame.Frame,int)` ### expectBoolean(Frame, long) `public boolean expectBoolean(Frame frame, long slot) throws UnexpectedResultException`. Since 25.1. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#expectBoolean(com.oracle.truffle.api.frame.Frame,long)` ### expectByte(Frame, int) `public abstract byte expectByte(Frame frame, int slot) throws UnexpectedResultException`. Since 24.2. Reads a byte from the frame, throwing an `UnexpectedResultException` with the slot value when the tag does not match. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#expectByte(com.oracle.truffle.api.frame.Frame,int)` ### expectByte(Frame, long) `public byte expectByte(Frame frame, long slot) throws UnexpectedResultException`. Since 25.1. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#expectByte(com.oracle.truffle.api.frame.Frame,long)` ### expectInt(Frame, int) `public abstract int expectInt(Frame frame, int slot) throws UnexpectedResultException`. Since 24.2. Reads an int from the frame, throwing an `UnexpectedResultException` with the slot value when the tag does not match. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#expectInt(com.oracle.truffle.api.frame.Frame,int)` ### expectInt(Frame, long) `public int expectInt(Frame frame, long slot) throws UnexpectedResultException`. Since 25.1. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#expectInt(com.oracle.truffle.api.frame.Frame,long)` ### expectLong(Frame, int) `public abstract long expectLong(Frame frame, int slot) throws UnexpectedResultException`. Since 24.2. Reads a long from the frame, throwing an `UnexpectedResultException` with the slot value when the tag does not match. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#expectLong(com.oracle.truffle.api.frame.Frame,int)` ### expectLong(Frame, long) `public long expectLong(Frame frame, long slot) throws UnexpectedResultException`. Since 25.1. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#expectLong(com.oracle.truffle.api.frame.Frame,long)` ### expectObject(Frame, int) `public abstract Object expectObject(Frame frame, int slot) throws UnexpectedResultException`. Since 24.2. Reads an Object from the frame, throwing an `UnexpectedResultException` with the slot value when the tag does not match. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#expectObject(com.oracle.truffle.api.frame.Frame,int)` ### expectObject(Frame, long) `public Object expectObject(Frame frame, long slot) throws UnexpectedResultException`. Since 25.1. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#expectObject(com.oracle.truffle.api.frame.Frame,long)` ### expectFloat(Frame, int) `public abstract float expectFloat(Frame frame, int slot) throws UnexpectedResultException`. Since 24.2. Reads a float from the frame, throwing an `UnexpectedResultException` with the slot value when the tag does not match. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#expectFloat(com.oracle.truffle.api.frame.Frame,int)` ### expectFloat(Frame, long) `public float expectFloat(Frame frame, long slot) throws UnexpectedResultException`. Since 25.1. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#expectFloat(com.oracle.truffle.api.frame.Frame,long)` ### expectDouble(Frame, int) `public abstract double expectDouble(Frame frame, int slot) throws UnexpectedResultException`. Since 24.2. Reads a double from the frame, throwing an `UnexpectedResultException` with the slot value when the tag does not match. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#expectDouble(com.oracle.truffle.api.frame.Frame,int)` ### expectDouble(Frame, long) `public double expectDouble(Frame frame, long slot) throws UnexpectedResultException`. Since 25.1. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#expectDouble(com.oracle.truffle.api.frame.Frame,long)` ### requireObject(Frame, int) `public final Object requireObject(Frame frame, int slot)`. Since 24.2. Reads an Object from the frame, recovering gracefully when the slot is not Object. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#requireObject(com.oracle.truffle.api.frame.Frame,int)` ### requireObject(Frame, long) `public Object requireObject(Frame frame, long slot)`. Since 25.1. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#requireObject(com.oracle.truffle.api.frame.Frame,long)` ### uncheckedGetObject(Frame, int) `public abstract Object uncheckedGetObject(Frame frame, int slot)`. Since 24.2. Reads an object from the frame without checking the slot's tag. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#uncheckedGetObject(com.oracle.truffle.api.frame.Frame,int)` ### uncheckedGetObject(Frame, long) `public Object uncheckedGetObject(Frame frame, long slot)`. Since 25.1. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#uncheckedGetObject(com.oracle.truffle.api.frame.Frame,long)` ### copy(Frame, int, int) `public abstract void copy(Frame frame, int srcSlot, int dstSlot)`. Since 24.2. Copies a value from one slot to another. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#copy(com.oracle.truffle.api.frame.Frame,int,int)` ### copy(Frame, long, long) `public void copy(Frame frame, long srcSlot, long dstSlot)`. Since 25.1. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#copy(com.oracle.truffle.api.frame.Frame,long,long)` ### copyTo(Frame, int, …) `public abstract void copyTo(Frame srcFrame, int srcOffset, Frame dstFrame, int dstOffset, int length)`. Since 24.2. Copies a range of values from one frame to another. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#copyTo(com.oracle.truffle.api.frame.Frame,int,com.oracle.truffle.api.frame.Frame,int,int)` ### copyTo(Frame, long, …) `public void copyTo(Frame srcFrame, long srcOffset, Frame dstFrame, long dstOffset, long length)`. Since 25.1. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#copyTo(com.oracle.truffle.api.frame.Frame,long,com.oracle.truffle.api.frame.Frame,long,long)` ### clear(Frame, int) `public abstract void clear(Frame frame, int slot)`. Since 24.2. Clears a frame slot. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#clear(com.oracle.truffle.api.frame.Frame,int)` ### clear(Frame, long) `public void clear(Frame frame, long slot)`. Since 25.1. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#clear(com.oracle.truffle.api.frame.Frame,long)` ### getValue(Frame, int) `public final Object getValue(Frame frame, int slot)`. Since 24.2. Reads the value of a slot from the frame. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#getValue(com.oracle.truffle.api.frame.Frame,int)` ### getValue(Frame, long) `public Object getValue(Frame frame, long slot)`. Since 25.1. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#getValue(com.oracle.truffle.api.frame.Frame,long)` ### resetFrame(Frame) `public abstract void resetFrame(Frame frame)`. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#resetFrame(com.oracle.truffle.api.frame.Frame)` ### getTag(Frame, long) `public byte getTag(Frame frame, long slot)`. Since 25.1. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#getTag(com.oracle.truffle.api.frame.Frame,long)` ### getTag(Frame, int) `public byte getTag(Frame frame, int slot)`. Since 25.1. Cite: `com/oracle/truffle/api/frame/FrameExtensions.html#getTag(com.oracle.truffle.api.frame.Frame,int)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ FrameInstance [truffle-api](index.md) › [com.oracle.truffle.api.frame](com/oracle/truffle/api/frame/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.frame`](com/oracle/truffle/api/frame/index.md). Since 0.8 or earlier. ```java public interface FrameInstance ``` Represents a current frame instance on the stack. Please note that any frame instance must not be used after the [`iterateFrames()`](com/oracle/truffle/api/TruffleRuntime.md#iterateFrames%28com.oracle.truffle.api.frame.FrameInstanceVisitor%29) method returned. **See also** - [`To iterate the current frame instances on the stack.`](com/oracle/truffle/api/TruffleRuntime.md#iterateFrames%28com.oracle.truffle.api.frame.FrameInstanceVisitor%29) ## Nested types - [`FrameInstance.FrameAccess`](com/oracle/truffle/api/frame/FrameInstance.FrameAccess.md) (enum class): Access mode for FrameInstance.getFrame(FrameAccess). ## Methods ### getFrame(FrameInstance.FrameAccess) `Frame getFrame(FrameInstance.FrameAccess access)`. Since 0.23. Accesses the underlying frame using a specified `access mode`. Bytecode DSL note: This method should **not** be used with Bytecode DSL interpreters. See `com.oracle.truffle.api.bytecode.BytecodeFrame` for more information. See also: `FrameAccess`. Cite: `com/oracle/truffle/api/frame/FrameInstance.html#getFrame(com.oracle.truffle.api.frame.FrameInstance.FrameAccess)` ### isVirtualFrame() `boolean isVirtualFrame()`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/frame/FrameInstance.html#isVirtualFrame()` ### getCompilationTier() `default int getCompilationTier()`. Since 21.3.0. Returns an integer for the optimized tier of this method. If `0` is returned then this means that the frame is currently being interpreted without any optimization. The number of tiers is unlimited, but is typically restricted to a small set. e.g. 0-2. Where 0 could indicate interpreted, 1 indicates first tier and 2 indicates last tier compilation. It is best to not interpret this number and just print it for the user. Cite: `com/oracle/truffle/api/frame/FrameInstance.html#getCompilationTier()` ### isCompilationRoot() `default boolean isCompilationRoot()`. Since 21.3.0. Returns whether or not the current frame is a compilation root. A compilation root is a compiled `CallTarget` which was itself compiled i.e. not inlined into another target. Cite: `com/oracle/truffle/api/frame/FrameInstance.html#isCompilationRoot()` ### getCallNode() `Node getCallNode()`. Since 0.8 or earlier. Returns a node representing the callsite of the next new target on the stack. This picture indicates how `FrameInstance` groups the stack. Returns `Node`: a node representing the callsite of the next new target on the stack. Returns `null` in case there is no upper target or location. The set of possible call nodes is restricted to any node that was passed to `CallTarget.call(Node, Object...)` or `CallTarget.call(Node, int, Object[])` or the node set using `EncapsulatingNodeReference` when invoking `CallTarget.call(Object...)`. If a cached variant of `DirectCallNode` or `IndirectCallNode` was used then the call node will be the `DirectCallNode` or `IndirectCallNode` respectively. Cite: `com/oracle/truffle/api/frame/FrameInstance.html#getCallNode()` ```java =============== Current: ,>| CallTarget | FrameInstance | =============== Caller: '-| CallNode | FrameInstance ,>| CallTarget | | =============== '-| CallNode | FrameInstance | CallTarget | =============== ... =============== | CallNode | FrameInstance Initial call: | CallTarget | =============== ``` ### getInstrumentableCallNode() `default Node getInstrumentableCallNode()`. Since 24.2. Returns an instrumentable call node from a frame instance. This method should be preferred over `getCallNode()` by tools to find the instrumentable node associated with this call node. In case of bytecode interpreters the instrumentable node needs to be resolved by the language and is not directly accessible from the `parent` chain of the regular `call node`. Just like `getCallNode()` this method may not directly return an instrumentable node. To find the eventual instrumentable node the `parent` chain must be searched. There is no guarantee that an instrumentable node can be found, e.g. if the language does not support instrumentation. See also: `RootNode.findInstrumentableCallNode`. Cite: `com/oracle/truffle/api/frame/FrameInstance.html#getInstrumentableCallNode()` ### getCallTarget() `CallTarget getCallTarget()`. Since 0.8 or earlier. The `CallTarget` being invoked in this frame. See `getCallNode()` for the relation between call node and CallTarget. Cite: `com/oracle/truffle/api/frame/FrameInstance.html#getCallTarget()` ### getBytecodeIndex() `default int getBytecodeIndex()`. Since 24.1. Returns the bytecode index of this frame's call site. If this frame called the next target on the stack using `CallTarget.call(Node, int, Object[])`, and the supplied bytecode index was not `-1`, returns that explicit index. Otherwise, returns the result of `RootNode.findBytecodeIndex(Node, Frame)` on the root node associated with this frame's `getCallTarget()`. Negative values indicate invalid or unavailable indices; their meaning is language-specific. Returns `int`: the BCI, or a negative value if invalid or unavailable. See also: `RootNode.findBytecodeIndex`. Cite: `com/oracle/truffle/api/frame/FrameInstance.html#getBytecodeIndex()` # ≡ FrameInstance.FrameAccess [truffle-api](index.md) › [com.oracle.truffle.api.frame](com/oracle/truffle/api/frame/index.md) · Every page: [llms.txt](llms.txt) Enum class in [`com.oracle.truffle.api.frame`](com/oracle/truffle/api/frame/index.md). Since 0.8 or earlier. Nested in [`FrameInstance`](com/oracle/truffle/api/frame/FrameInstance.md). ```java public enum FrameInstance.FrameAccess ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html) > `FrameAccess` Access mode for [`FrameInstance.getFrame(FrameAccess)`](com/oracle/truffle/api/frame/FrameInstance.md#getFrame%28com.oracle.truffle.api.frame.FrameInstance.FrameAccess%29). **See also** - [`FrameInstance.getFrame(FrameAccess)`](com/oracle/truffle/api/frame/FrameInstance.md#getFrame%28com.oracle.truffle.api.frame.FrameInstance.FrameAccess%29) ## Enum constants ### READ_ONLY `READ_ONLY`. Since 0.8 or earlier. This mode allows to read the frame and provides read only access to its local variables. The returned frame must not be stored/persisted. Writing local variables in this mode will result in an [`AssertionError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AssertionError.html) only if assertions (-ea) are enabled. Cite: `com/oracle/truffle/api/frame/FrameInstance.FrameAccess.html#READ_ONLY` ### READ_WRITE `READ_WRITE`. Since 0.8 or earlier. This mode allows to read the frame and provides read and write access to its local variables. The returned frame must not be stored/persisted. Cite: `com/oracle/truffle/api/frame/FrameInstance.FrameAccess.html#READ_WRITE` ### MATERIALIZE `MATERIALIZE`. Since 0.8 or earlier. This mode allows to read a materialized version of the frame and provides read and write access to its local variables. In addition to `READ_WRITE` this mode allows to store/persist the returned frame. Cite: `com/oracle/truffle/api/frame/FrameInstance.FrameAccess.html#MATERIALIZE` ## Methods ### values() `public static FrameInstance.FrameAccess[] values()`. Returns the enum constants in declaration order. Returns `FrameInstance.FrameAccess[]`: Returns the enum constants in declaration order. Cite: `com/oracle/truffle/api/frame/FrameInstance.FrameAccess.html#values()` ### valueOf(String) `public static FrameInstance.FrameAccess valueOf(String name)`. Returns the enum constant with the given name. Parameters: `name` `String`: The exact name of the enum constant. Returns `FrameInstance.FrameAccess`: Returns the enum constant with the given name. Cite: `com/oracle/truffle/api/frame/FrameInstance.FrameAccess.html#valueOf(java.lang.String)` ## Inherited members - From class [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#clone%28%29), [`compareTo`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#compareTo%28E%29), [`describeConstable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#describeConstable%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#finalize%28%29), [`getDeclaringClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#getDeclaringClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#hashCode%28%29), [`name`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#name%28%29), [`ordinal`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#ordinal%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#toString%28%29), [`valueOf`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#valueOf%28java.lang.Class,java.lang.String%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ FrameInstanceVisitor [truffle-api](index.md) › [com.oracle.truffle.api.frame](com/oracle/truffle/api/frame/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.frame`](com/oracle/truffle/api/frame/index.md). Since 0.8 or earlier. ```java public interface FrameInstanceVisitor ``` Callback interface for [`TruffleRuntime.iterateFrames`](com/oracle/truffle/api/TruffleRuntime.md#iterateFrames%28com.oracle.truffle.api.frame.FrameInstanceVisitor%29). Implementations of [`visitFrame`](com/oracle/truffle/api/frame/FrameInstanceVisitor.md#visitFrame%28com.oracle.truffle.api.frame.FrameInstance%29) return null to indicate that frame iteration should continue and the next caller frame should be visited; and return any non-null value to indicate that frame iteration should stop. ## Methods ### visitFrame(FrameInstance) `T visitFrame(FrameInstance frameInstance)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/frame/FrameInstanceVisitor.html#visitFrame(com.oracle.truffle.api.frame.FrameInstance)` # ≡ FrameSlotKind [truffle-api](index.md) › [com.oracle.truffle.api.frame](com/oracle/truffle/api/frame/index.md) · Every page: [llms.txt](llms.txt) Enum class in [`com.oracle.truffle.api.frame`](com/oracle/truffle/api/frame/index.md). Since 0.8 or earlier. ```java public enum FrameSlotKind ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html) > `FrameSlotKind` ## Enum constants ### Object `Object`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/frame/FrameSlotKind.html#Object` ### Long `Long`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/frame/FrameSlotKind.html#Long` ### Int `Int`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/frame/FrameSlotKind.html#Int` ### Double `Double`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/frame/FrameSlotKind.html#Double` ### Float `Float`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/frame/FrameSlotKind.html#Float` ### Boolean `Boolean`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/frame/FrameSlotKind.html#Boolean` ### Byte `Byte`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/frame/FrameSlotKind.html#Byte` ### Illegal `Illegal`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/frame/FrameSlotKind.html#Illegal` ### Static `Static`. Since 22.2. Cite: `com/oracle/truffle/api/frame/FrameSlotKind.html#Static` ## Fields ### tag `public final byte tag`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/frame/FrameSlotKind.html#tag` ## Methods ### values() `public static FrameSlotKind[] values()`. Returns the enum constants in declaration order. Returns `FrameSlotKind[]`: Returns the enum constants in declaration order. Cite: `com/oracle/truffle/api/frame/FrameSlotKind.html#values()` ### valueOf(String) `public static FrameSlotKind valueOf(String name)`. Returns the enum constant with the given name. Parameters: `name` `String`: The exact name of the enum constant. Returns `FrameSlotKind`: Returns the enum constant with the given name. Cite: `com/oracle/truffle/api/frame/FrameSlotKind.html#valueOf(java.lang.String)` ### fromTag(byte) `public static FrameSlotKind fromTag(byte tag)`. Since 22.0. Converts from the numeric representation used in the implementation of `Frame` to the `FrameSlotKind`. Parameters: `tag` `byte`: the numeric (byte) representation of the kind. Returns `FrameSlotKind`: the FrameSlotKind. Cite: `com/oracle/truffle/api/frame/FrameSlotKind.html#fromTag(byte)` ## Inherited members - From class [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#clone%28%29), [`compareTo`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#compareTo%28E%29), [`describeConstable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#describeConstable%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#finalize%28%29), [`getDeclaringClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#getDeclaringClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#hashCode%28%29), [`name`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#name%28%29), [`ordinal`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#ordinal%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#toString%28%29), [`valueOf`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#valueOf%28java.lang.Class,java.lang.String%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ⚡︎ FrameSlotTypeException [truffle-api](index.md) › [com.oracle.truffle.api.frame](com/oracle/truffle/api/frame/index.md) · Every page: [llms.txt](llms.txt) Exception in [`com.oracle.truffle.api.frame`](com/oracle/truffle/api/frame/index.md). Since 0.8 or earlier. ```java public final class FrameSlotTypeException extends IllegalStateException ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) > [`Exception`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Exception.html) > [`RuntimeException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/RuntimeException.html) > [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) > `FrameSlotTypeException` Exception thrown if the frame slot kind does not match the expected kind. ## Constructors ### FrameSlotTypeException() `@Deprecated public FrameSlotTypeException()`. Since 0.8 or earlier. Deprecated. use `create(int, FrameSlotKind, FrameSlotKind)` instead. Cite: `com/oracle/truffle/api/frame/FrameSlotTypeException.html#()` ## Methods ### getMessage() `public String getMessage()`. Since 24.2. Overrides `getMessage()`. Cite: `com/oracle/truffle/api/frame/FrameSlotTypeException.html#getMessage()` ### getSlot() `public int getSlot()`. Since 24.2. Returns the frame slot index that was read. Cite: `com/oracle/truffle/api/frame/FrameSlotTypeException.html#getSlot()` ### getExpectedKind() `public FrameSlotKind getExpectedKind()`. Since 24.2. Returns the expected frame slot kind when the exception occurred. Cite: `com/oracle/truffle/api/frame/FrameSlotTypeException.html#getExpectedKind()` ### getActualKind() `public FrameSlotKind getActualKind()`. Since 24.2. Returns the actual frame slot kind when the exception occurred. Cite: `com/oracle/truffle/api/frame/FrameSlotTypeException.html#getActualKind()` ### create(int, FrameSlotKind, FrameSlotKind) `public static FrameSlotTypeException create(int slot, FrameSlotKind expectedKind, FrameSlotKind actualKind)`. Since 24.2. Creates a new frame slot type exception. Parameters: `slot` `int`: the frame slot index used when reading. `expectedKind` `FrameSlotKind`: the expected frame slot kind when reading. `actualKind` `FrameSlotKind`: the actual frame slot kind when reading. Cite: `com/oracle/truffle/api/frame/FrameSlotTypeException.html#create(int,com.oracle.truffle.api.frame.FrameSlotKind,com.oracle.truffle.api.frame.FrameSlotKind)` ## Inherited members - From class [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html): [`addSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#addSuppressed%28java.lang.Throwable%29), [`fillInStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#fillInStackTrace%28%29), [`getCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getCause%28%29), [`getLocalizedMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getLocalizedMessage%28%29), [`getStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getStackTrace%28%29), [`getSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getSuppressed%28%29), [`initCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#initCause%28java.lang.Throwable%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintStream%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintWriter%29), [`setStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#setStackTrace%28java.lang.StackTraceElement[]%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ MaterializedFrame [truffle-api](index.md) › [com.oracle.truffle.api.frame](com/oracle/truffle/api/frame/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.frame`](com/oracle/truffle/api/frame/index.md). Since 0.8 or earlier. ```java public interface MaterializedFrame extends VirtualFrame ``` Extends: [`VirtualFrame`](com/oracle/truffle/api/frame/VirtualFrame.md) Represents a materialized frame containing values of local variables of the guest language. It can be created using the [`VirtualFrame.materialize()`](com/oracle/truffle/api/frame/Frame.md#materialize%28%29) method. Instances of this type are the only frame instances that may be stored in fields or cast to [`java.lang.Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html). ## Inherited members - From interface [`Frame`](com/oracle/truffle/api/frame/Frame.md): [`clear`](com/oracle/truffle/api/frame/Frame.md#clear%28int%29), [`clearObjectStatic`](com/oracle/truffle/api/frame/Frame.md#clearObjectStatic%28int%29), [`clearPrimitiveStatic`](com/oracle/truffle/api/frame/Frame.md#clearPrimitiveStatic%28int%29), [`clearStatic`](com/oracle/truffle/api/frame/Frame.md#clearStatic%28int%29), [`copy`](com/oracle/truffle/api/frame/Frame.md#copy%28int,int%29), [`copyObjectStatic`](com/oracle/truffle/api/frame/Frame.md#copyObjectStatic%28int,int%29), [`copyPrimitiveStatic`](com/oracle/truffle/api/frame/Frame.md#copyPrimitiveStatic%28int,int%29), [`copyStatic`](com/oracle/truffle/api/frame/Frame.md#copyStatic%28int,int%29), [`copyTo`](com/oracle/truffle/api/frame/Frame.md#copyTo%28int,com.oracle.truffle.api.frame.Frame,int,int%29), [`expectBoolean`](com/oracle/truffle/api/frame/Frame.md#expectBoolean%28int%29), [`expectByte`](com/oracle/truffle/api/frame/Frame.md#expectByte%28int%29), [`expectDouble`](com/oracle/truffle/api/frame/Frame.md#expectDouble%28int%29), [`expectFloat`](com/oracle/truffle/api/frame/Frame.md#expectFloat%28int%29), [`expectInt`](com/oracle/truffle/api/frame/Frame.md#expectInt%28int%29), [`expectLong`](com/oracle/truffle/api/frame/Frame.md#expectLong%28int%29), [`expectObject`](com/oracle/truffle/api/frame/Frame.md#expectObject%28int%29), [`getArguments`](com/oracle/truffle/api/frame/Frame.md#getArguments%28%29), [`getAuxiliarySlot`](com/oracle/truffle/api/frame/Frame.md#getAuxiliarySlot%28int%29), [`getBoolean`](com/oracle/truffle/api/frame/Frame.md#getBoolean%28int%29), [`getBooleanStatic`](com/oracle/truffle/api/frame/Frame.md#getBooleanStatic%28int%29), [`getByte`](com/oracle/truffle/api/frame/Frame.md#getByte%28int%29), [`getByteStatic`](com/oracle/truffle/api/frame/Frame.md#getByteStatic%28int%29), [`getDouble`](com/oracle/truffle/api/frame/Frame.md#getDouble%28int%29), [`getDoubleStatic`](com/oracle/truffle/api/frame/Frame.md#getDoubleStatic%28int%29), [`getFloat`](com/oracle/truffle/api/frame/Frame.md#getFloat%28int%29), [`getFloatStatic`](com/oracle/truffle/api/frame/Frame.md#getFloatStatic%28int%29), [`getFrameDescriptor`](com/oracle/truffle/api/frame/Frame.md#getFrameDescriptor%28%29), [`getInt`](com/oracle/truffle/api/frame/Frame.md#getInt%28int%29), [`getIntStatic`](com/oracle/truffle/api/frame/Frame.md#getIntStatic%28int%29), [`getLong`](com/oracle/truffle/api/frame/Frame.md#getLong%28int%29), [`getLongStatic`](com/oracle/truffle/api/frame/Frame.md#getLongStatic%28int%29), [`getObject`](com/oracle/truffle/api/frame/Frame.md#getObject%28int%29), [`getObjectStatic`](com/oracle/truffle/api/frame/Frame.md#getObjectStatic%28int%29), [`getTag`](com/oracle/truffle/api/frame/Frame.md#getTag%28int%29), [`getValue`](com/oracle/truffle/api/frame/Frame.md#getValue%28int%29), [`isBoolean`](com/oracle/truffle/api/frame/Frame.md#isBoolean%28int%29), [`isByte`](com/oracle/truffle/api/frame/Frame.md#isByte%28int%29), [`isDouble`](com/oracle/truffle/api/frame/Frame.md#isDouble%28int%29), [`isFloat`](com/oracle/truffle/api/frame/Frame.md#isFloat%28int%29), [`isInt`](com/oracle/truffle/api/frame/Frame.md#isInt%28int%29), [`isLong`](com/oracle/truffle/api/frame/Frame.md#isLong%28int%29), [`isObject`](com/oracle/truffle/api/frame/Frame.md#isObject%28int%29), [`isStatic`](com/oracle/truffle/api/frame/Frame.md#isStatic%28int%29), [`materialize`](com/oracle/truffle/api/frame/Frame.md#materialize%28%29), [`setAuxiliarySlot`](com/oracle/truffle/api/frame/Frame.md#setAuxiliarySlot%28int,java.lang.Object%29), [`setBoolean`](com/oracle/truffle/api/frame/Frame.md#setBoolean%28int,boolean%29), [`setBooleanStatic`](com/oracle/truffle/api/frame/Frame.md#setBooleanStatic%28int,boolean%29), [`setByte`](com/oracle/truffle/api/frame/Frame.md#setByte%28int,byte%29), [`setByteStatic`](com/oracle/truffle/api/frame/Frame.md#setByteStatic%28int,byte%29), [`setDouble`](com/oracle/truffle/api/frame/Frame.md#setDouble%28int,double%29), [`setDoubleStatic`](com/oracle/truffle/api/frame/Frame.md#setDoubleStatic%28int,double%29), [`setFloat`](com/oracle/truffle/api/frame/Frame.md#setFloat%28int,float%29), [`setFloatStatic`](com/oracle/truffle/api/frame/Frame.md#setFloatStatic%28int,float%29), [`setInt`](com/oracle/truffle/api/frame/Frame.md#setInt%28int,int%29), [`setIntStatic`](com/oracle/truffle/api/frame/Frame.md#setIntStatic%28int,int%29), [`setLong`](com/oracle/truffle/api/frame/Frame.md#setLong%28int,long%29), [`setLongStatic`](com/oracle/truffle/api/frame/Frame.md#setLongStatic%28int,long%29), [`setObject`](com/oracle/truffle/api/frame/Frame.md#setObject%28int,java.lang.Object%29), [`setObjectStatic`](com/oracle/truffle/api/frame/Frame.md#setObjectStatic%28int,java.lang.Object%29), [`swap`](com/oracle/truffle/api/frame/Frame.md#swap%28int,int%29), [`swapObjectStatic`](com/oracle/truffle/api/frame/Frame.md#swapObjectStatic%28int,int%29), [`swapPrimitiveStatic`](com/oracle/truffle/api/frame/Frame.md#swapPrimitiveStatic%28int,int%29), [`swapStatic`](com/oracle/truffle/api/frame/Frame.md#swapStatic%28int,int%29) # ◇ VirtualFrame [truffle-api](index.md) › [com.oracle.truffle.api.frame](com/oracle/truffle/api/frame/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.frame`](com/oracle/truffle/api/frame/index.md). Since 0.8 or earlier. ```java public interface VirtualFrame extends Frame ``` Extends: [`Frame`](com/oracle/truffle/api/frame/Frame.md) Represents a frame containing values of local variables of the guest language. Instances of this type must not be stored in a field or cast to [`java.lang.Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html). If this is necessary, the frame must be explicitly converted into a materialized frame using the [`VirtualFrame.materialize()`](com/oracle/truffle/api/frame/Frame.md#materialize%28%29) method. ## Inherited members - From interface [`Frame`](com/oracle/truffle/api/frame/Frame.md): [`clear`](com/oracle/truffle/api/frame/Frame.md#clear%28int%29), [`clearObjectStatic`](com/oracle/truffle/api/frame/Frame.md#clearObjectStatic%28int%29), [`clearPrimitiveStatic`](com/oracle/truffle/api/frame/Frame.md#clearPrimitiveStatic%28int%29), [`clearStatic`](com/oracle/truffle/api/frame/Frame.md#clearStatic%28int%29), [`copy`](com/oracle/truffle/api/frame/Frame.md#copy%28int,int%29), [`copyObjectStatic`](com/oracle/truffle/api/frame/Frame.md#copyObjectStatic%28int,int%29), [`copyPrimitiveStatic`](com/oracle/truffle/api/frame/Frame.md#copyPrimitiveStatic%28int,int%29), [`copyStatic`](com/oracle/truffle/api/frame/Frame.md#copyStatic%28int,int%29), [`copyTo`](com/oracle/truffle/api/frame/Frame.md#copyTo%28int,com.oracle.truffle.api.frame.Frame,int,int%29), [`expectBoolean`](com/oracle/truffle/api/frame/Frame.md#expectBoolean%28int%29), [`expectByte`](com/oracle/truffle/api/frame/Frame.md#expectByte%28int%29), [`expectDouble`](com/oracle/truffle/api/frame/Frame.md#expectDouble%28int%29), [`expectFloat`](com/oracle/truffle/api/frame/Frame.md#expectFloat%28int%29), [`expectInt`](com/oracle/truffle/api/frame/Frame.md#expectInt%28int%29), [`expectLong`](com/oracle/truffle/api/frame/Frame.md#expectLong%28int%29), [`expectObject`](com/oracle/truffle/api/frame/Frame.md#expectObject%28int%29), [`getArguments`](com/oracle/truffle/api/frame/Frame.md#getArguments%28%29), [`getAuxiliarySlot`](com/oracle/truffle/api/frame/Frame.md#getAuxiliarySlot%28int%29), [`getBoolean`](com/oracle/truffle/api/frame/Frame.md#getBoolean%28int%29), [`getBooleanStatic`](com/oracle/truffle/api/frame/Frame.md#getBooleanStatic%28int%29), [`getByte`](com/oracle/truffle/api/frame/Frame.md#getByte%28int%29), [`getByteStatic`](com/oracle/truffle/api/frame/Frame.md#getByteStatic%28int%29), [`getDouble`](com/oracle/truffle/api/frame/Frame.md#getDouble%28int%29), [`getDoubleStatic`](com/oracle/truffle/api/frame/Frame.md#getDoubleStatic%28int%29), [`getFloat`](com/oracle/truffle/api/frame/Frame.md#getFloat%28int%29), [`getFloatStatic`](com/oracle/truffle/api/frame/Frame.md#getFloatStatic%28int%29), [`getFrameDescriptor`](com/oracle/truffle/api/frame/Frame.md#getFrameDescriptor%28%29), [`getInt`](com/oracle/truffle/api/frame/Frame.md#getInt%28int%29), [`getIntStatic`](com/oracle/truffle/api/frame/Frame.md#getIntStatic%28int%29), [`getLong`](com/oracle/truffle/api/frame/Frame.md#getLong%28int%29), [`getLongStatic`](com/oracle/truffle/api/frame/Frame.md#getLongStatic%28int%29), [`getObject`](com/oracle/truffle/api/frame/Frame.md#getObject%28int%29), [`getObjectStatic`](com/oracle/truffle/api/frame/Frame.md#getObjectStatic%28int%29), [`getTag`](com/oracle/truffle/api/frame/Frame.md#getTag%28int%29), [`getValue`](com/oracle/truffle/api/frame/Frame.md#getValue%28int%29), [`isBoolean`](com/oracle/truffle/api/frame/Frame.md#isBoolean%28int%29), [`isByte`](com/oracle/truffle/api/frame/Frame.md#isByte%28int%29), [`isDouble`](com/oracle/truffle/api/frame/Frame.md#isDouble%28int%29), [`isFloat`](com/oracle/truffle/api/frame/Frame.md#isFloat%28int%29), [`isInt`](com/oracle/truffle/api/frame/Frame.md#isInt%28int%29), [`isLong`](com/oracle/truffle/api/frame/Frame.md#isLong%28int%29), [`isObject`](com/oracle/truffle/api/frame/Frame.md#isObject%28int%29), [`isStatic`](com/oracle/truffle/api/frame/Frame.md#isStatic%28int%29), [`materialize`](com/oracle/truffle/api/frame/Frame.md#materialize%28%29), [`setAuxiliarySlot`](com/oracle/truffle/api/frame/Frame.md#setAuxiliarySlot%28int,java.lang.Object%29), [`setBoolean`](com/oracle/truffle/api/frame/Frame.md#setBoolean%28int,boolean%29), [`setBooleanStatic`](com/oracle/truffle/api/frame/Frame.md#setBooleanStatic%28int,boolean%29), [`setByte`](com/oracle/truffle/api/frame/Frame.md#setByte%28int,byte%29), [`setByteStatic`](com/oracle/truffle/api/frame/Frame.md#setByteStatic%28int,byte%29), [`setDouble`](com/oracle/truffle/api/frame/Frame.md#setDouble%28int,double%29), [`setDoubleStatic`](com/oracle/truffle/api/frame/Frame.md#setDoubleStatic%28int,double%29), [`setFloat`](com/oracle/truffle/api/frame/Frame.md#setFloat%28int,float%29), [`setFloatStatic`](com/oracle/truffle/api/frame/Frame.md#setFloatStatic%28int,float%29), [`setInt`](com/oracle/truffle/api/frame/Frame.md#setInt%28int,int%29), [`setIntStatic`](com/oracle/truffle/api/frame/Frame.md#setIntStatic%28int,int%29), [`setLong`](com/oracle/truffle/api/frame/Frame.md#setLong%28int,long%29), [`setLongStatic`](com/oracle/truffle/api/frame/Frame.md#setLongStatic%28int,long%29), [`setObject`](com/oracle/truffle/api/frame/Frame.md#setObject%28int,java.lang.Object%29), [`setObjectStatic`](com/oracle/truffle/api/frame/Frame.md#setObjectStatic%28int,java.lang.Object%29), [`swap`](com/oracle/truffle/api/frame/Frame.md#swap%28int,int%29), [`swapObjectStatic`](com/oracle/truffle/api/frame/Frame.md#swapObjectStatic%28int,int%29), [`swapPrimitiveStatic`](com/oracle/truffle/api/frame/Frame.md#swapPrimitiveStatic%28int,int%29), [`swapStatic`](com/oracle/truffle/api/frame/Frame.md#swapStatic%28int,int%29) # ▣ com.oracle.truffle.api.instrumentation [truffle-api](index.md) · Every page: [llms.txt](llms.txt) Package in truffle-api. Since 0.8 or older. The instrumentation API provides a way to introspect and inject behavior into interpreters written using the Truffle framework. To adopt instrumentation support for a guest language implementation you need to subclass syntax nodes of your language with [`com.oracle.truffle.api.instrumentation.InstrumentableNode`](com/oracle/truffle/api/instrumentation/InstrumentableNode.md). For details please refer to [`com.oracle.truffle.api.instrumentation.InstrumentableNode`](com/oracle/truffle/api/instrumentation/InstrumentableNode.md). To use the instrumentation framework implementors must implement the [`com.oracle.truffle.api.instrumentation.TruffleInstrument`](com/oracle/truffle/api/instrumentation/TruffleInstrument.md) interface. Please refer to [`com.oracle.truffle.api.instrumentation.TruffleInstrument`](com/oracle/truffle/api/instrumentation/TruffleInstrument.md) for further details. Guest languages that want to use the capabilities of the instrumentation framework can access [`com.oracle.truffle.api.instrumentation.Instrumenter`](com/oracle/truffle/api/instrumentation/Instrumenter.md) for their [`com.oracle.truffle.api.TruffleLanguage`](com/oracle/truffle/api/TruffleLanguage.md) by calling [`com.oracle.truffle.api.TruffleLanguage.Env.lookup(Class)`](com/oracle/truffle/api/TruffleLanguage.Env.md#lookup%28java.lang.Class%29). [`com.oracle.truffle.api.instrumentation.SourceSectionFilter`](com/oracle/truffle/api/instrumentation/SourceSectionFilter.md) created using guest languages may be used to implement guest language features that require meta-programming capabilities. **See also** - [`com.oracle.truffle.api.instrumentation.TruffleInstrument`](com/oracle/truffle/api/instrumentation/TruffleInstrument.md) - [`com.oracle.truffle.api.instrumentation.InstrumentableNode`](com/oracle/truffle/api/instrumentation/InstrumentableNode.md) ## Interfaces - [`AllocationListener`](com/oracle/truffle/api/instrumentation/AllocationListener.md): Listener to be notified about guest language value allocations. - [`ContextsListener`](com/oracle/truffle/api/instrumentation/ContextsListener.md): Listener to be notified about changes of contexts in guest language application. - [`ExecuteSourceListener`](com/oracle/truffle/api/instrumentation/ExecuteSourceListener.md): A listener attached by an Instrumenter to specific sources of a guest language program to listen to execute source events. - [`ExecutionEventListener`](com/oracle/truffle/api/instrumentation/ExecutionEventListener.md): A listener attached by an Instrumenter to specific locations of a guest language program to listen to execution events. - [`ExecutionEventNodeFactory`](com/oracle/truffle/api/instrumentation/ExecutionEventNodeFactory.md): Event node factories are factories of event nodes for a program location. - [`InstrumentableNode`](com/oracle/truffle/api/instrumentation/InstrumentableNode.md): Interface implemented by AST nodes that may be instrumentable: an AST location where Truffle instruments are permitted to listen to before and after using execution event listeners. - [`LoadSourceListener`](com/oracle/truffle/api/instrumentation/LoadSourceListener.md): A listener attached by an Instrumenter to specific locations of a guest language program to listen to load source events. - [`LoadSourceSectionListener`](com/oracle/truffle/api/instrumentation/LoadSourceSectionListener.md): A listener attached by an Instrumenter to specific locations of a guest language program to listen to sources section load events. - [`ThreadsActivationListener`](com/oracle/truffle/api/instrumentation/ThreadsActivationListener.md): Listener that allows to be notified when threads become active and deactivated. - [`ThreadsListener`](com/oracle/truffle/api/instrumentation/ThreadsListener.md): Listener to be notified about changes of threads in guest language application. ## Classes - [`AllocationEvent`](com/oracle/truffle/api/instrumentation/AllocationEvent.md): An event representing an allocation of a guest language value. - [`AllocationEventFilter`](com/oracle/truffle/api/instrumentation/AllocationEventFilter.md): An instrumentation filter of allocations of guest language values. - [`AllocationReporter`](com/oracle/truffle/api/instrumentation/AllocationReporter.md): Reporter of guest language value allocations. - [`EventBinding`](com/oracle/truffle/api/instrumentation/EventBinding.md): An instrumentation handle for a subscription to a filtered stream of execution event notifications. - [`EventContext`](com/oracle/truffle/api/instrumentation/EventContext.md): Represents the context of an execution event. - [`ExecuteSourceEvent`](com/oracle/truffle/api/instrumentation/ExecuteSourceEvent.md): Represents a source execute event from a ExecuteSourceListener. - [`ExecutionEventNode`](com/oracle/truffle/api/instrumentation/ExecutionEventNode.md): An event node created by an ExecutionEventNodeFactory for a specific locations of a guest language program to listen to instrumentation events. - [`Instrumenter`](com/oracle/truffle/api/instrumentation/Instrumenter.md): Provides capabilities to attach listeners for execution, load, output and allocation events. - [`LoadSourceEvent`](com/oracle/truffle/api/instrumentation/LoadSourceEvent.md): Represents a source load event from a LoadSourceListener. - [`LoadSourceSectionEvent`](com/oracle/truffle/api/instrumentation/LoadSourceSectionEvent.md): Represents a source section load event from a LoadSourceSectionListener. - [`NearestSectionFilter`](com/oracle/truffle/api/instrumentation/NearestSectionFilter.md): Add a filter for source sections that are nearest to the given source position, according to the guest language control flow. - [`ProbeNode`](com/oracle/truffle/api/instrumentation/ProbeNode.md): Represents an event sink for instrumentation events that is embedded in the AST using wrappers if needed. - [`SourceFilter`](com/oracle/truffle/api/instrumentation/SourceFilter.md): A source filter represents an expression for a subset of guest language sources that are used in an Truffle interpreter. - [`SourceSectionFilter`](com/oracle/truffle/api/instrumentation/SourceSectionFilter.md): A source section filter represents an expression for a subset of tagged source sections that are used in an Truffle interpreter. - [`StandardTags`](com/oracle/truffle/api/instrumentation/StandardTags.md): Set of standard tags usable by language agnostic tools. - [`Tag`](com/oracle/truffle/api/instrumentation/Tag.md): Base class for tags used in the Truffle instrumentation framework. - [`TruffleInstrument`](com/oracle/truffle/api/instrumentation/TruffleInstrument.md): The service provider interface (SPI) for Truffle instruments: clients of Truffle instrumentation that may observe and inject behavior into interpreters written using the Truffle framework. ## Annotations - [`GenerateWrapper`](com/oracle/truffle/api/instrumentation/GenerateWrapper.md): Generates a default wrapper subclass of an annotated InstrumentableNode subclass. - [`ProvidedTags`](com/oracle/truffle/api/instrumentation/ProvidedTags.md): Specifies a set of tags that are provided by a language implementation. # ◆ AllocationEvent [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.27. ```java public final class AllocationEvent ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `AllocationEvent` An event representing an allocation of a guest language value. ## Methods ### getLanguage() `public LanguageInfo getLanguage()`. Since 0.27. Returns the language performing the allocation. Cite: `com/oracle/truffle/api/instrumentation/AllocationEvent.html#getLanguage()` ### getOldSize() `public long getOldSize()`. Since 0.27. Returns an old size of the value prior to the allocation, in bytes. Returns `0` when a new value is to be allocated, or the size of the value prior to the re-allocation. When the old size is unknown, `AllocationReporter.SIZE_UNKNOWN` is returned. Cite: `com/oracle/truffle/api/instrumentation/AllocationEvent.html#getOldSize()` ### getNewSize() `public long getNewSize()`. Since 0.27. Returns a size of the allocated value in bytes. When called from `AllocationListener.onEnter(com.oracle.truffle.api.instrumentation.AllocationEvent)` an estimated size of the allocated value is provided. When called from `AllocationListener.onReturnValue(com.oracle.truffle.api.instrumentation.AllocationEvent)` a corrected size can be provided, which might differ from the one reported in `onEnter`. When the allocated size is unknown, `AllocationReporter.SIZE_UNKNOWN` is returned. The change in memory consumption caused by the allocation is `getNewSize()`` - ``getOldSize()` when both old size and new size are known. The change can be either positive or negative. Cite: `com/oracle/truffle/api/instrumentation/AllocationEvent.html#getNewSize()` ### getValue() `public Object getValue()`. Since 0.27. Returns the value which is a subject of allocation. When called from `AllocationListener.onEnter(com.oracle.truffle.api.instrumentation.AllocationEvent)` the returned value is either `null` when a new one is to be allocated, or non- `null` when the value is to be re-allocated. When called from `AllocationListener.onReturnValue(com.oracle.truffle.api.instrumentation.AllocationEvent)` it is always non-`null` and it is either the newly allocated value, or the same instance of the re-allocated value as was provided in the preceding call to `AllocationListener.onEnter(com.oracle.truffle.api.instrumentation.AllocationEvent)`. Cite: `com/oracle/truffle/api/instrumentation/AllocationEvent.html#getValue()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ AllocationEventFilter [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.27. ```java public final class AllocationEventFilter ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `AllocationEventFilter` An instrumentation filter of allocations of guest language values. To create the filter, use [`newBuilder()`](com/oracle/truffle/api/instrumentation/AllocationEventFilter.md#newBuilder%28%29) and complete that by calling [`Builder.build()`](com/oracle/truffle/api/instrumentation/AllocationEventFilter.Builder.md#build%28%29). **See also** - [`newBuilder()`](com/oracle/truffle/api/instrumentation/AllocationEventFilter.md#newBuilder%28%29) - [`Instrumenter.attachAllocationListener(com.oracle.truffle.api.instrumentation.AllocationEventFilter, com.oracle.truffle.api.instrumentation.AllocationListener)`](com/oracle/truffle/api/instrumentation/Instrumenter.md#attachAllocationListener%28com.oracle.truffle.api.instrumentation.AllocationEventFilter,T%29) ## Nested types - [`AllocationEventFilter.Builder`](com/oracle/truffle/api/instrumentation/AllocationEventFilter.Builder.md) (class): A builder of AllocationEventFilter. ## Fields ### ANY `public static final AllocationEventFilter ANY`. Since 0.27. A filter that matches all allocations in all languages. Cite: `com/oracle/truffle/api/instrumentation/AllocationEventFilter.html#ANY` ## Methods ### newBuilder() `public static AllocationEventFilter.Builder newBuilder()`. Since 0.27. Creates a new `AllocationEventFilter` instance through a `Builder`. Cite: `com/oracle/truffle/api/instrumentation/AllocationEventFilter.html#newBuilder()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ AllocationEventFilter.Builder [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.27. Nested in [`AllocationEventFilter`](com/oracle/truffle/api/instrumentation/AllocationEventFilter.md). ```java public class AllocationEventFilter.Builder ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Builder` A builder of [`AllocationEventFilter`](com/oracle/truffle/api/instrumentation/AllocationEventFilter.md). Use methods in this class to set the filter parameters. ## Methods ### languages(LanguageInfo...) `public AllocationEventFilter.Builder languages(LanguageInfo... languages)`. Since 0.27. Specify languages that are instrumented for allocations of guest language values. Initially the filter accepts any language. Multiple calls to this method rewrite the set of languages. Cite: `com/oracle/truffle/api/instrumentation/AllocationEventFilter.Builder.html#languages(com.oracle.truffle.api.nodes.LanguageInfo...)` ### build() `public AllocationEventFilter build()`. Since 0.27. Create an instance of `AllocationEventFilter` based on the current setup of this builder. Cite: `com/oracle/truffle/api/instrumentation/AllocationEventFilter.Builder.html#build()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ AllocationListener [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.27. ```java public interface AllocationListener ``` Listener to be notified about guest language value allocations. Calls to this listener are initiated by [`AllocationReporter`](com/oracle/truffle/api/instrumentation/AllocationReporter.md). Use [`Instrumenter.attachAllocationListener(com.oracle.truffle.api.instrumentation.AllocationEventFilter, com.oracle.truffle.api.instrumentation.AllocationListener)`](com/oracle/truffle/api/instrumentation/Instrumenter.md#attachAllocationListener%28com.oracle.truffle.api.instrumentation.AllocationEventFilter,T%29) to register an implementation of this listener. Use [`EventBinding.dispose()`](com/oracle/truffle/api/instrumentation/EventBinding.md#dispose%28%29) to unregister. The listener gets called [`before`](com/oracle/truffle/api/instrumentation/AllocationListener.md#onEnter%28com.oracle.truffle.api.instrumentation.AllocationEvent%29) the actual allocation and right [`after`](com/oracle/truffle/api/instrumentation/AllocationListener.md#onReturnValue%28com.oracle.truffle.api.instrumentation.AllocationEvent%29) it. The calls to these methods are always in pairs, unless the programs crashes in between. Nested allocations are supported, several calls to `onEnter` prior every sub-value allocation can be followed by the appropriate number of `onReturnValue` calls after the sub-values are allocated, in the opposite order. **See also** - [`Instrumenter.attachAllocationListener(com.oracle.truffle.api.instrumentation.AllocationEventFilter, com.oracle.truffle.api.instrumentation.AllocationListener)`](com/oracle/truffle/api/instrumentation/Instrumenter.md#attachAllocationListener%28com.oracle.truffle.api.instrumentation.AllocationEventFilter,T%29) - [`AllocationReporter`](com/oracle/truffle/api/instrumentation/AllocationReporter.md) ## Methods ### onEnter(AllocationEvent) `void onEnter(AllocationEvent event)`. Since 0.27. Notifies about an intent to allocate or re-allocate a guest language value. This method is called prior to the actual allocation and is followed by a call to `onReturnValue(com.oracle.truffle.api.instrumentation.AllocationEvent)` after the successful allocation. Parameters: `event` `AllocationEvent`: the event describing the intended allocation. Cite: `com/oracle/truffle/api/instrumentation/AllocationListener.html#onEnter(com.oracle.truffle.api.instrumentation.AllocationEvent)` ### onReturnValue(AllocationEvent) `void onReturnValue(AllocationEvent event)`. Since 0.27. Notifies about an allocated guest language value. This method is called after a preceding `onEnter(com.oracle.truffle.api.instrumentation.AllocationEvent)` call and right after the allocation is performed. When `onEnter` provided a non-`null` value in the event, it was re-allocated and the same value instance is in this event. Parameters: `event` `AllocationEvent`: the event describing the finished allocation. Cite: `com/oracle/truffle/api/instrumentation/AllocationListener.html#onReturnValue(com.oracle.truffle.api.instrumentation.AllocationEvent)` # ◆ AllocationReporter [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.27. ```java public final class AllocationReporter ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `AllocationReporter` Reporter of guest language value allocations. Language implementation ought to use this class to report all allocations and re-allocations of guest language values. An instance of this class can be obtained from [`Env.lookup(AllocationReporter.class)`](com/oracle/truffle/api/TruffleLanguage.Env.md#lookup%28java.lang.Class%29). If used from compiled code paths, then the allocation reporter must be stored in a compilation final or final field. Usage example: ```java @Override protected ContextObject createContext(Env env) { AllocationReporter reporter = env.lookup(AllocationReporter.class); return new ContextObject(reporter); } Object allocateNew() { AllocationReporter reporter = ContextObject.get(null).getReporter(); // Test if the reporter is active, we should compute the size estimate if (reporter.isActive()) { long size = findSizeEstimate(); reporter.onEnter(null, 0, size); } // Do the allocation itself Object newObject = new MyTruffleObject(); // Test if the reporter is active, // we should compute the allocated object size if (reporter.isActive()) { long size = findSize(newObject); reporter.onReturnValue(newObject, 0, size); } return newObject; } Object allocateComplex() { AllocationReporter reporter = ContextObject.get(null).getReporter(); // If the allocated size is a constant, onEnter() and onReturnValue() // can be called without a fast-path performance penalty when not active reporter.onEnter(null, 0, 16); // Do the allocation itself Object newObject = createComplexObject(); // Report the allocation reporter.onReturnValue(newObject, 0, 16); return newObject; } ``` ## Fields ### SIZE_UNKNOWN `public static final long SIZE_UNKNOWN`. Since 0.27. Constant specifying an unknown size. Use it when it's not possible to estimate size of the memory being allocated. Constant value: `-9223372036854775808L`. Cite: `com/oracle/truffle/api/instrumentation/AllocationReporter.html#SIZE_UNKNOWN` ## Methods ### addActiveListener(Consumer) `public void addActiveListener(Consumer listener)`. Since 19.0. Add a listener that is notified when `active` value of this reporter changes. The listener [`accept`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/Consumer.html#accept%28T%29) method is called with the new value of `isActive()`. Cite: `com/oracle/truffle/api/instrumentation/AllocationReporter.html#addActiveListener(java.util.function.Consumer)` ### removeActiveListener(Consumer) `public void removeActiveListener(Consumer listener)`. Since 19.0. Remove a listener that is notified when `active` value of this reporter changes. Cite: `com/oracle/truffle/api/instrumentation/AllocationReporter.html#removeActiveListener(java.util.function.Consumer)` ### isActive() `public boolean isActive()`. Since 0.27. Test if the reporter instance is actually doing some reporting when notify methods are called. Methods `onEnter(java.lang.Object, long, long)` and `onReturnValue(java.lang.Object, long, long)` have no effect when this method returns false. A listener can be `added` to listen on changes of this value. Returns `boolean`: `true` when there are some `AllocationListener`s attached, `false` otherwise. Cite: `com/oracle/truffle/api/instrumentation/AllocationReporter.html#isActive()` ### onEnter(Object, long, long) `public void onEnter(Object valueToReallocate, long oldSize, long newSizeEstimate)`. Since 0.27. Report an intent to allocate a new guest language value, or re-allocate an existing one. This method delegates to all registered listeners `AllocationListener.onEnter(com.oracle.truffle.api.instrumentation.AllocationEvent)`. Only primitive types, String and `com.oracle.truffle.api.interop.TruffleObject` are accepted value types. The change in memory consumption caused by the allocation is going to be `newSizeEstimate - oldSize` when both old size and new size are known. The change can be either positive or negative. A call to this method needs to be followed by a call to `onReturnValue(java.lang.Object, long, long)` with the actual allocated value, or with the same (re-allocated) value. Nested allocations are supported, several calls to `onEnter` prior every sub-value allocation can be followed by the appropriate number of `onReturnValue` calls after the sub-values are allocated, in the opposite order. Parameters: `valueToReallocate` `Object`: `null` in case of a new allocation, or the value that is to be re-allocated. `oldSize` `long`: `0` in case of a new allocation, or the size in bytes of value to be re-allocated. Can be `SIZE_UNKNOWN` when the value size is not known. `newSizeEstimate` `long`: an estimate of the allocation size of the value which is to be created or re-allocated, in bytes. Can be `SIZE_UNKNOWN` when the allocation size is not known. Cite: `com/oracle/truffle/api/instrumentation/AllocationReporter.html#onEnter(java.lang.Object,long,long)` ### onReturnValue(Object, long, long) `public void onReturnValue(Object value, long oldSize, long newSize)`. Since 0.27. Report an allocation of a new one or re-allocation of an existing guest language value. This method notifies all registered listeners `AllocationListener.onReturnValue(com.oracle.truffle.api.instrumentation.AllocationEvent)` . Only primitive types, String and `com.oracle.truffle.api.interop.TruffleObject` are accepted value types. The change in memory consumption caused by the allocation is `newSize - oldSize` when both old size and new size are known. The change can be either positive or negative. A call to `onEnter(java.lang.Object, long, long)` must precede this call. In case of re-allocation, the value object passed to `onEnter(java.lang.Object, long, long)` must be the same instance as the value passed to this method. Parameters: `value` `Object`: the value that was newly allocated, or the re-allocated value. Must not be `null`. `oldSize` `long`: size in bytes of an old value, if any. Must be `0` for newly allocated values. In case of re-allocation it's the size of the original value before re-allocation. Can be `SIZE_UNKNOWN` when not known. `newSize` `long`: the size of the allocated value in bytes. In case of re-allocation, it's the size of the object after re-allocation. The `newSize` may be less than `oldSize` when the object size shrinks. Can be `SIZE_UNKNOWN` when not known. Cite: `com/oracle/truffle/api/instrumentation/AllocationReporter.html#onReturnValue(java.lang.Object,long,long)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ ContextsListener [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.30. ```java public interface ContextsListener ``` Listener to be notified about changes of contexts in guest language application. Use [`Instrumenter.attachContextsListener(com.oracle.truffle.api.instrumentation.ContextsListener, boolean)`](com/oracle/truffle/api/instrumentation/Instrumenter.md#attachContextsListener%28T,boolean%29) to register an implementation of this listener. Use [`EventBinding.dispose()`](com/oracle/truffle/api/instrumentation/EventBinding.md#dispose%28%29) to unregister. The listener gets called when a new [`context`](com/oracle/truffle/api/TruffleContext.md) is created or disposed and when individual languages are initialized or disposed in that context. **See also** - [`Instrumenter.attachContextsListener(com.oracle.truffle.api.instrumentation.ContextsListener, boolean)`](com/oracle/truffle/api/instrumentation/Instrumenter.md#attachContextsListener%28T,boolean%29) ## Methods ### onContextCreated(TruffleContext) `void onContextCreated(TruffleContext context)`. Since 0.30. Notifies about creation of a new polyglot context. Cite: `com/oracle/truffle/api/instrumentation/ContextsListener.html#onContextCreated(com.oracle.truffle.api.TruffleContext)` ### onLanguageContextCreate(TruffleContext, LanguageInfo) `default void onLanguageContextCreate(TruffleContext context, LanguageInfo language)`. Since 21.1. Notifies before creation of a language-specific context in an existing polyglot context. Parameters: `context` `TruffleContext`: the polyglot context. `language` `LanguageInfo`: the language for which a language-specific context is being created. Cite: `com/oracle/truffle/api/instrumentation/ContextsListener.html#onLanguageContextCreate(com.oracle.truffle.api.TruffleContext,com.oracle.truffle.api.nodes.LanguageInfo)` ### onLanguageContextCreated(TruffleContext, LanguageInfo) `void onLanguageContextCreated(TruffleContext context, LanguageInfo language)`. Since 0.30. Notifies about creation of a language-specific context in an existing polyglot context. Parameters: `context` `TruffleContext`: the polyglot context. `language` `LanguageInfo`: the language for which a language-specific context was created. Cite: `com/oracle/truffle/api/instrumentation/ContextsListener.html#onLanguageContextCreated(com.oracle.truffle.api.TruffleContext,com.oracle.truffle.api.nodes.LanguageInfo)` ### onLanguageContextCreateFailed(TruffleContext, LanguageInfo) `default void onLanguageContextCreateFailed(TruffleContext context, LanguageInfo language)`. Since 21.1. Notifies after failed creation of a language-specific context in an existing polyglot context. Parameters: `context` `TruffleContext`: the polyglot context. `language` `LanguageInfo`: the language for which a language-specific context creation failed. Cite: `com/oracle/truffle/api/instrumentation/ContextsListener.html#onLanguageContextCreateFailed(com.oracle.truffle.api.TruffleContext,com.oracle.truffle.api.nodes.LanguageInfo)` ### onLanguageContextInitialize(TruffleContext, LanguageInfo) `default void onLanguageContextInitialize(TruffleContext context, LanguageInfo language)`. Since 21.1. Notifies before initialization of a language-specific context in an existing polyglot context. Parameters: `context` `TruffleContext`: the polyglot context. `language` `LanguageInfo`: the language for which a language-specific context is being initialized. Cite: `com/oracle/truffle/api/instrumentation/ContextsListener.html#onLanguageContextInitialize(com.oracle.truffle.api.TruffleContext,com.oracle.truffle.api.nodes.LanguageInfo)` ### onLanguageContextInitialized(TruffleContext, LanguageInfo) `void onLanguageContextInitialized(TruffleContext context, LanguageInfo language)`. Since 0.30. Notifies about initialization of a language-specific context in an existing polyglot context. Parameters: `context` `TruffleContext`: the polyglot context. `language` `LanguageInfo`: the language for which a language-specific context was initialized. Cite: `com/oracle/truffle/api/instrumentation/ContextsListener.html#onLanguageContextInitialized(com.oracle.truffle.api.TruffleContext,com.oracle.truffle.api.nodes.LanguageInfo)` ### onLanguageContextInitializeFailed(TruffleContext, LanguageInfo) `default void onLanguageContextInitializeFailed(TruffleContext context, LanguageInfo language)`. Since 21.1. Notifies after failed initialization of a language-specific context in an existing polyglot context. Parameters: `context` `TruffleContext`: the polyglot context. `language` `LanguageInfo`: the language for which a language-specific context initialization failed. Cite: `com/oracle/truffle/api/instrumentation/ContextsListener.html#onLanguageContextInitializeFailed(com.oracle.truffle.api.TruffleContext,com.oracle.truffle.api.nodes.LanguageInfo)` ### onLanguageContextFinalized(TruffleContext, LanguageInfo) `void onLanguageContextFinalized(TruffleContext context, LanguageInfo language)`. Since 0.30. Notifies about finalization of a language-specific context in an existing polyglot context. Parameters: `context` `TruffleContext`: the polyglot context. `language` `LanguageInfo`: the language for which a language-specific context was finalized. Cite: `com/oracle/truffle/api/instrumentation/ContextsListener.html#onLanguageContextFinalized(com.oracle.truffle.api.TruffleContext,com.oracle.truffle.api.nodes.LanguageInfo)` ### onLanguageContextDisposed(TruffleContext, LanguageInfo) `void onLanguageContextDisposed(TruffleContext context, LanguageInfo language)`. Since 0.30. Notifies about disposal of a language-specific context in an existing polyglot context. Parameters: `context` `TruffleContext`: the polyglot context. `language` `LanguageInfo`: the language for which a language-specific context was disposed. Cite: `com/oracle/truffle/api/instrumentation/ContextsListener.html#onLanguageContextDisposed(com.oracle.truffle.api.TruffleContext,com.oracle.truffle.api.nodes.LanguageInfo)` ### onContextClosed(TruffleContext) `void onContextClosed(TruffleContext context)`. Since 0.30. Notifies about close of a polyglot context. Cite: `com/oracle/truffle/api/instrumentation/ContextsListener.html#onContextClosed(com.oracle.truffle.api.TruffleContext)` ### onContextResetLimits(TruffleContext) `default void onContextResetLimits(TruffleContext context)`. Since 20.3. Invoked when the resource consumption limits were reset for a particular context. For example this is method each time the [`Context.resetLimits()`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html#resetLimits%28%29) method is called. Cite: `com/oracle/truffle/api/instrumentation/ContextsListener.html#onContextResetLimits(com.oracle.truffle.api.TruffleContext)` # ◆ EventBinding [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.12. ```java public class EventBinding ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `EventBinding` An [instrumentation](com/oracle/truffle/api/instrumentation/Instrumenter.md) handle for a subscription to a [filtered](com/oracle/truffle/api/instrumentation/SourceSectionFilter.md) stream of execution event notifications. The subscription remains active until: - explicit [disposal](com/oracle/truffle/api/instrumentation/EventBinding.md#dispose%28%29) of the subscription; or - the instrumented engine is [closed](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Engine.html#close%28%29). **Type parameters** - ``: subscriber type: [`ExecutionEventListener`](com/oracle/truffle/api/instrumentation/ExecutionEventListener.md) or [`ExecutionEventNodeFactory`](com/oracle/truffle/api/instrumentation/ExecutionEventNodeFactory.md). **See also** - [`Instrumenter.attachExecutionEventListener(SourceSectionFilter, ExecutionEventListener)`](com/oracle/truffle/api/instrumentation/Instrumenter.md#attachExecutionEventListener%28com.oracle.truffle.api.instrumentation.SourceSectionFilter,T%29) - [`Instrumenter.attachExecutionEventFactory(SourceSectionFilter, ExecutionEventNodeFactory)`](com/oracle/truffle/api/instrumentation/Instrumenter.md#attachExecutionEventFactory%28com.oracle.truffle.api.instrumentation.SourceSectionFilter,T%29) ## Methods ### getElement() `public T getElement()`. Since 0.12. Returns `T`: the subscriber: an `ExecutionEventNodeFactory` or `ExecutionEventListener`. Cite: `com/oracle/truffle/api/instrumentation/EventBinding.html#getElement()` ### isAttached() `public final boolean isAttached()`. Since 21.1. Test if this binding is attached. Cite: `com/oracle/truffle/api/instrumentation/EventBinding.html#isAttached()` ### attach() `public final void attach()`. Since 21.1. Attach this binding to receive the associated notifications by the `subscriber`. When notification about existing sources were requested in binding creation, notifications will be performed in this call. The binding is attached automatically, when one of the `Instrumenter` attach methods were used. Use this for bindings created by `Instrumenter` create methods only. Throws: `IllegalStateException` (unchecked): when the binding is `attached` already, or when it was `disposed`. Cite: `com/oracle/truffle/api/instrumentation/EventBinding.html#attach()` ### tryAttach() `public final boolean tryAttach()`. Since 23.1. Try to attach this binding, if not disposed or attached already. Works the same as `attach()`, but returns `false` instead of throwing an exception when not successful. The binding is attached automatically, when one of the `Instrumenter` attach methods were used. Use this for bindings created by `Instrumenter` create methods only. Returns `boolean`: `true` when the binding was attached successfully, `false` when disposed or attached already. Cite: `com/oracle/truffle/api/instrumentation/EventBinding.html#tryAttach()` ### isDisposed() `public boolean isDisposed()`. Since 0.12. Returns `boolean`: whether the subscription has been permanently canceled. Cite: `com/oracle/truffle/api/instrumentation/EventBinding.html#isDisposed()` ### dispose() `public void dispose()`. Since 0.12. Cancels the subscription permanently. Cite: `com/oracle/truffle/api/instrumentation/EventBinding.html#dispose()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ EventContext [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.12. ```java public final class EventContext ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `EventContext` Represents the context of an execution event. Instances of [`EventContext`](com/oracle/truffle/api/instrumentation/EventContext.md) should be neither stored, cached nor hashed. One exception is when they are stored in [`ExecutionEventNode`](com/oracle/truffle/api/instrumentation/ExecutionEventNode.md) implementations. The equality and hashing behavior is undefined. **See also** - [`ExecutionEventNodeFactory`](com/oracle/truffle/api/instrumentation/ExecutionEventNodeFactory.md) - [`ExecutionEventListener`](com/oracle/truffle/api/instrumentation/ExecutionEventListener.md) ## Methods ### hasTag(Class) `public boolean hasTag(Class tag)`. Since 0.33. Returns `true` if the underlying instrumented AST is tagged with a particular tag. The return value of `hasTag(Class)` always returns the same value for a particular tag and `EventContext`. The method may be used on compiled code paths. Parameters: `tag` `Class`: the tag to check to check, must not be `null`. Cite: `com/oracle/truffle/api/instrumentation/EventContext.html#hasTag(java.lang.Class)` ### getNodeObject() `public Object getNodeObject()`. Since 0.33. Returns a language provided object that represents the instrumented node properties. The returned is always a valid interop object. The returned object is never `null` and always returns `true` for the HAS_KEYS message. Multiple calls to `getNodeObject()` return the same node object instance. See also: `InstrumentableNode.getNodeObject()`. Cite: `com/oracle/truffle/api/instrumentation/EventContext.html#getNodeObject()` ### getInstrumentedSourceSection() `public SourceSection getInstrumentedSourceSection()`. Since 0.12. Returns the `SourceSection` that is being instrumented. The returned source section is final for each `EventContext` instance. The returned source section may be null if the node does not provide sources section. **Performance note:** this is method may be invoked in compiled code and is guaranteed to always return a compilation constant . Cite: `com/oracle/truffle/api/instrumentation/EventContext.html#getInstrumentedSourceSection()` ### getInstrumentedNode() `public Node getInstrumentedNode()`. Since 0.12. Accessor to the instrumented node at which the event occurred. The returned AST must not be mutated by the user. **Performance note:** this is method may be invoked in compiled code and is guaranteed to always return a compilation constant . Cite: `com/oracle/truffle/api/instrumentation/EventContext.html#getInstrumentedNode()` ### isLanguageContextInitialized() `public boolean isLanguageContextInitialized()`. Since 0.26. Test if language context of the source of the event is initialized. Cite: `com/oracle/truffle/api/instrumentation/EventContext.html#isLanguageContextInitialized()` ### lookupExecutionEventNode(EventBinding) `public ExecutionEventNode lookupExecutionEventNode(EventBinding binding)`. Since 0.17. Returns the execution event node that was inserted at this location given an event binding. This is useful to disambiguate multiple bindings from each other when installed at the same source location. Parameters: `binding` `EventBinding`: the binding to lookup. Cite: `com/oracle/truffle/api/instrumentation/EventContext.html#lookupExecutionEventNode(com.oracle.truffle.api.instrumentation.EventBinding)` ### lookupExecutionEventNodes(Collection) `public Iterator lookupExecutionEventNodes(Collection> bindings)`. Since 19.0. Returns all execution event nodes in the insertion order at this location, whose event bindings are contained in the given collection. This is useful to be able to sort out multiple bindings when installed at the same source location. Parameters: `bindings` `Collection>`: a collection of bindings to find the event nodes for at this context location. Cite: `com/oracle/truffle/api/instrumentation/EventContext.html#lookupExecutionEventNodes(java.util.Collection)` ### createUnwind(Object) `public ThreadDeath createUnwind(Object info)`. Since 0.31. Create an unwind throwable, that when thrown, abruptly breaks execution of a node and unwinds it off the execution stack. This is a a shortcut for `createUnwind(Object, EventBinding)` with the current binding, only the event listener instance that threw the unwind throwable gets called `onUnwind`. Parameters: `info` `Object`: an info that is passed into `ExecutionEventListener.onUnwind(EventContext, VirtualFrame, Object)` or `ExecutionEventNode.onUnwind(VirtualFrame, Object)`. It can be used for arbitrary client data that help to control the unwind process. See also: `createUnwind(Object, EventBinding)`. Cite: `com/oracle/truffle/api/instrumentation/EventContext.html#createUnwind(java.lang.Object)` ### createUnwind(Object, EventBinding) `public ThreadDeath createUnwind(Object info, EventBinding unwindBinding)`. Since 0.31. Create an unwind throwable, that when thrown, abruptly breaks execution of a node and unwinds it off the execution stack. It's to be thrown in `onEnter`, `onReturnValue` or `onReturnExceptional` methods of `ExecutionEventListener` or `ExecutionEventNode`, to initiate the unwind process. It acts in connection with `ExecutionEventListener.onUnwind(EventContext, VirtualFrame, Object)` or `ExecutionEventNode.onUnwind(VirtualFrame, Object)`. Only the event listener instance that is associated with the provided `unwindBinding` gets called `onUnwind`, use `createUnwind(java.lang.Object)` to have the current event listener called `onUnwind`. Other bindings that happen to instrument the unwound nodes get called `onReturnExceptional`. The returned throwable can be kept and thrown again later to repeat the unwind process. A repeating unwind process is possible without deoptimization. A single throwable instance cannot be used on multiple threads concurrently. It can be thrown on a different thread only after the unwind finishes on the last thread. Usage example of forced return: Usage example of reenter: Parameters: `info` `Object`: an info that is passed into `ExecutionEventListener.onUnwind(EventContext, VirtualFrame, Object)` or `ExecutionEventNode.onUnwind(VirtualFrame, Object)`. It can be used for arbitrary client data that help to control the unwind process. `unwindBinding` `EventBinding`: the binding whose listener's `onUnwind` is to be called, or `null` to call the current listener that throws the returned throwable. Cite: `com/oracle/truffle/api/instrumentation/EventContext.html#createUnwind(java.lang.Object,com.oracle.truffle.api.instrumentation.EventBinding)` ```java protected void onCreate(TruffleInstrument.Env env) { // Register a listener that checks the return value to all call nodes // If the return value is not 42, it forces to return 42. env.getInstrumenter().attachExecutionEventListener( SourceSectionFilter.newBuilder(). tagIs(StandardTags.CallTag.class).build(), new ExecutionEventListener() { public void onEnter(EventContext context, VirtualFrame f) { } public void onReturnValue(EventContext context, VirtualFrame f, Object result) { if (!Objects.equals(result, 42)) { CompilerDirectives.transferToInterpreter(); throw context.createUnwind(42); } } public Object onUnwind(EventContext context, VirtualFrame f, Object info) { // return 42 on unwind return info; } public void onReturnExceptional(EventContext context, VirtualFrame f, Throwable ex) { } }); } ``` ```java protected void onCreate(TruffleInstrument.Env env) { // Two event bindings are created: one for reenter, one for unwind // Listener that reenters on unwind, attached to root nodes. EventBinding functionReenter = env.getInstrumenter().attachExecutionEventListener( SourceSectionFilter.newBuilder(). tagIs(StandardTags.RootTag.class).build(), new ExecutionEventListener() { public Object onUnwind(EventContext context, VirtualFrame f, Object info) { // Reenters on unwind. return ProbeNode.UNWIND_ACTION_REENTER; } public void onEnter(EventContext context, VirtualFrame f) { } public void onReturnValue(EventContext context, VirtualFrame f, Object result) { } public void onReturnExceptional(EventContext context, VirtualFrame f, Throwable ex) { } }); // Listener that initiates unwind at line 20, attached to statements. env.getInstrumenter().attachExecutionEventListener( SourceSectionFilter.newBuilder(). tagIs(StandardTags.StatementTag.class).build(), new ExecutionEventListener() { public void onEnter(EventContext context, VirtualFrame f) { SourceSection ss = context.getInstrumentedSourceSection(); if (ss.getStartLine() == 20) { CompilerDirectives.transferToInterpreter(); // Unwind to nodes instrumented by functionReenter throw context.createUnwind(null, functionReenter); } } public void onReturnValue(EventContext context, VirtualFrame f, Object result) { } public void onReturnExceptional(EventContext context, VirtualFrame f, Throwable ex) { } }); } ``` ### toString() `public String toString()`. Since 0.12. Overrides `toString()`. Cite: `com/oracle/truffle/api/instrumentation/EventContext.html#toString()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ ExecuteSourceEvent [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.33. ```java public final class ExecuteSourceEvent ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `ExecuteSourceEvent` Represents a source execute event from a [`ExecuteSourceListener`](com/oracle/truffle/api/instrumentation/ExecuteSourceListener.md). Instances of [`ExecuteSourceEvent`](com/oracle/truffle/api/instrumentation/ExecuteSourceEvent.md) should be neither stored, cached nor hashed. The equality and hashing behavior is undefined. **See also** - [`ExecuteSourceListener`](com/oracle/truffle/api/instrumentation/ExecuteSourceListener.md) ## Methods ### getSource() `public Source getSource()`. Since 0.33. Returns the executed source that caused this event. Cite: `com/oracle/truffle/api/instrumentation/ExecuteSourceEvent.html#getSource()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ ExecuteSourceListener [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.33. ```java public interface ExecuteSourceListener ``` A listener attached by an [`Instrumenter`](com/oracle/truffle/api/instrumentation/Instrumenter.md) to specific sources of a guest language program to listen to execute source events. ## Methods ### onExecute(ExecuteSourceEvent) `void onExecute(ExecuteSourceEvent event)`. Since 0.33. Invoked whenever a new `source` is executed. The order in which multiple source event listeners are notified matches the order they are `attached`. **Implementation Note:** Source execute events are notified when the guest language implementation executes a new `source` by invoking any `RootNode` that uses the new source in `Node.getSourceSection()`. It assumes that all nodes of an AST have the same `source` as their root. Parameters: `event` `ExecuteSourceEvent`: an event with context information. Cite: `com/oracle/truffle/api/instrumentation/ExecuteSourceListener.html#onExecute(com.oracle.truffle.api.instrumentation.ExecuteSourceEvent)` # ◇ ExecutionEventListener [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.12. ```java public interface ExecutionEventListener ``` A listener attached by an [`Instrumenter`](com/oracle/truffle/api/instrumentation/Instrumenter.md) to specific locations of a guest language program to listen to execution events. ## Methods ### onEnter(EventContext, VirtualFrame) `void onEnter(EventContext context, VirtualFrame frame)`. Since 0.12. Invoked immediately before the `instrumented node` is executed. The order in which multiple event listeners are notified matches the order they are `attached` . Parameters: `context` `EventContext`: indicating the current location in the guest language AST. `frame` `VirtualFrame`: the frame that was used for executing instrumented node. Cite: `com/oracle/truffle/api/instrumentation/ExecutionEventListener.html#onEnter(com.oracle.truffle.api.instrumentation.EventContext,com.oracle.truffle.api.frame.VirtualFrame)` ### onReturnValue(EventContext, VirtualFrame, Object) `void onReturnValue(EventContext context, VirtualFrame frame, Object result)`. Since 0.12. Invoked immediately after an `instrumented node` is successfully executed. The order in which multiple event listeners are notified matches the order they are `attached`. Parameters: `context` `EventContext`: indicating the current location in the guest language AST. `frame` `VirtualFrame`: the frame that was used for executing instrumented node. Cite: `com/oracle/truffle/api/instrumentation/ExecutionEventListener.html#onReturnValue(com.oracle.truffle.api.instrumentation.EventContext,com.oracle.truffle.api.frame.VirtualFrame,java.lang.Object)` ### onReturnExceptional(EventContext, VirtualFrame, Throwable) `void onReturnExceptional(EventContext context, VirtualFrame frame, Throwable exception)`. Since 0.12. Invoked immediately after an `instrumented node` did not successfully execute. The order in which multiple event listeners are notified matches the order they are `attached`. When the `exception` is an instance of [`ThreadDeath`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ThreadDeath.html) the execution was abruptly interrupted. `EventContext.createUnwind(Object)` creates a [`ThreadDeath`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ThreadDeath.html) to unwind nodes off, for instance. Listener instances that threw an unwind throwable get called `onUnwind(EventContext, VirtualFrame, Object)` instead. Parameters: `context` `EventContext`: indicating the current location in the guest language AST. `frame` `VirtualFrame`: the frame that was used for executing instrumented node. `exception` `Throwable`: the exception that occurred during the node's execution. Cite: `com/oracle/truffle/api/instrumentation/ExecutionEventListener.html#onReturnExceptional(com.oracle.truffle.api.instrumentation.EventContext,com.oracle.truffle.api.frame.VirtualFrame,java.lang.Throwable)` ### onUnwind(EventContext, VirtualFrame, Object) `default Object onUnwind(EventContext context, VirtualFrame frame, Object info)`. Since 0.31. Invoked when an `instrumented node` is unwound from the execution stack by `unwind throwable` thrown in this listener instance. Any nodes between the instrumented ones are unwound off without any notification. The default implementation returns `null`. Parameters: `context` `EventContext`: indicating the current location in the guest language AST. `frame` `VirtualFrame`: the frame that was used for executing instrumented node. `info` `Object`: an info associated with the unwind - the object passed to `EventContext.createUnwind(Object)`. Returns `Object`: `null` to continue to unwind the parent node, `ProbeNode.UNWIND_ACTION_REENTER` to reenter the current node, or an interop value to return that value early from the current node (void nodes just return, ignoring the return value). Cite: `com/oracle/truffle/api/instrumentation/ExecutionEventListener.html#onUnwind(com.oracle.truffle.api.instrumentation.EventContext,com.oracle.truffle.api.frame.VirtualFrame,java.lang.Object)` ### onYield(EventContext, VirtualFrame, Object) `default void onYield(EventContext context, VirtualFrame frame, Object value)`. Since 24.0. Invoked on a yield of the current thread. A yield interrupts the current execution, which is `resumed` later on. Delegates to `onReturnValue(EventContext, VirtualFrame, Object)` by default. Parameters: `context` `EventContext`: indicating the current location in the guest language AST. `frame` `VirtualFrame`: the frame that was used for executing instrumented node. Cite: `com/oracle/truffle/api/instrumentation/ExecutionEventListener.html#onYield(com.oracle.truffle.api.instrumentation.EventContext,com.oracle.truffle.api.frame.VirtualFrame,java.lang.Object)` ### onResume(EventContext, VirtualFrame) `default void onResume(EventContext context, VirtualFrame frame)`. Since 24.0. Invoked on a resume of the execution on the current thread after a `yield`. Delegates to `onEnter(EventContext, VirtualFrame)` by default. Use `TruffleInstrument.Env.isSameFrame(RootNode, Frame, Frame)` to match the interrupted and resumed execution. Parameters: `context` `EventContext`: indicating the current location in the guest language AST. `frame` `VirtualFrame`: the frame that was used for executing instrumented node. Cite: `com/oracle/truffle/api/instrumentation/ExecutionEventListener.html#onResume(com.oracle.truffle.api.instrumentation.EventContext,com.oracle.truffle.api.frame.VirtualFrame)` # ◆ ExecutionEventNode [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.12. ```java public abstract class ExecutionEventNode extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `ExecutionEventNode` An event node created by an [`ExecutionEventNodeFactory`](com/oracle/truffle/api/instrumentation/ExecutionEventNodeFactory.md) for a specific locations of a guest language program to listen to instrumentation events. In addition to [`listeners`](com/oracle/truffle/api/instrumentation/ExecutionEventListener.md) event nodes allow to store state for a particular [`program location`](com/oracle/truffle/api/instrumentation/EventContext.md). ## Constructors ### ExecutionEventNode() `protected ExecutionEventNode()`. Since 0.12. Cite: `com/oracle/truffle/api/instrumentation/ExecutionEventNode.html#()` ## Methods ### onEnter(VirtualFrame) `protected void onEnter(VirtualFrame frame)`. Since 0.12. Invoked immediately before the `instrumented node` is executed. The order in which multiple event listeners are notified matches the order they are `attached`. Parameters: `frame` `VirtualFrame`: the current frame used in the instrumented node. Cite: `com/oracle/truffle/api/instrumentation/ExecutionEventNode.html#onEnter(com.oracle.truffle.api.frame.VirtualFrame)` ### onInputValue(VirtualFrame, EventContext, …) `protected void onInputValue(VirtualFrame frame, EventContext inputContext, int inputIndex, Object inputValue)`. Since 0.33. Invoked immediately after each return value event of instrumented input child node that match the `input filter`. Whether, when and how often input child value events are triggered depends on the semantics of the instrumented node. For example, if the instrumented node represents binary arithmetic then two input value events will be triggered for index `0` and `1`. For short-circuited child values not all input child nodes may be executed therefore they might not trigger events for `all inputs`. For instrumented loop nodes input value events with the same `index` may be triggered many times. The total number of input nodes that may produce input events can be accessed using `getInputCount()`. Other input contexts than the currently input context can be accessed using `getInputContext(int)`. Input values can be `saved` to make them `getSavedInputValues(VirtualFrame)` accessible in `onReturn` or `onReturnExceptional` events. Parameters: `frame` `VirtualFrame`: the current frame in use. `inputContext` `EventContext`: the event context of the input child node. `inputIndex` `int`: the child index of the input. `inputValue` `Object`: the return value of the input child. See also: `saveInputValue(VirtualFrame, int, Object)`, `getSavedInputValues(VirtualFrame)`. Cite: `com/oracle/truffle/api/instrumentation/ExecutionEventNode.html#onInputValue(com.oracle.truffle.api.frame.VirtualFrame,com.oracle.truffle.api.instrumentation.EventContext,int,java.lang.Object)` ### onReturnValue(VirtualFrame, Object) `protected void onReturnValue(VirtualFrame frame, Object result)`. Since 0.12. Invoked immediately after an `instrumented node` is successfully executed. The order in which multiple event listeners are notified matches the order they are `attached`. Parameters: `frame` `VirtualFrame`: the frame that was used for executing instrumented node. Cite: `com/oracle/truffle/api/instrumentation/ExecutionEventNode.html#onReturnValue(com.oracle.truffle.api.frame.VirtualFrame,java.lang.Object)` ### onReturnExceptional(VirtualFrame, Throwable) `protected void onReturnExceptional(VirtualFrame frame, Throwable exception)`. Since 0.12. Invoked immediately after the execution of an `instrumented node` resulted in an exception. Note that this could be a `com.oracle.truffle.api.nodes.ControlFlowException`, which is expected and considered a successful execution of the node. The order in which multiple event listeners are notified matches the order they are `attached`. Parameters: `frame` `VirtualFrame`: the frame that was used for executing instrumented node. `exception` `Throwable`: the exception that occurred during the node's execution. Cite: `com/oracle/truffle/api/instrumentation/ExecutionEventNode.html#onReturnExceptional(com.oracle.truffle.api.frame.VirtualFrame,java.lang.Throwable)` ### onUnwind(VirtualFrame, Object) `protected Object onUnwind(VirtualFrame frame, Object info)`. Since 0.31. Invoked when an `instrumented node` is unwound from the execution stack by `unwind throwable` thrown in this node implementation. Any nodes between the instrumented ones are unwound off without any notification. The default implementation returns `null` to indicate continue unwind. Parameters: `frame` `VirtualFrame`: the frame that was used for executing instrumented node. `info` `Object`: an info associated with the unwind - the object passed to `EventContext.createUnwind(Object)`. Returns `Object`: `null` to continue to unwind the parent node, `ProbeNode.UNWIND_ACTION_REENTER` to reenter the current node, or an interop value to return that value early from the current node (void nodes just return, ignoring the return value). Cite: `com/oracle/truffle/api/instrumentation/ExecutionEventNode.html#onUnwind(com.oracle.truffle.api.frame.VirtualFrame,java.lang.Object)` ### onYield(VirtualFrame, Object) `protected void onYield(VirtualFrame frame, Object value)`. Since 24.0. Invoked on a yield of the current thread. A yield interrupts the current execution, which is `resumed` later on. Delegates to `onReturnValue(VirtualFrame, Object)` by default. Parameters: `frame` `VirtualFrame`: the frame that was used for executing instrumented node. Cite: `com/oracle/truffle/api/instrumentation/ExecutionEventNode.html#onYield(com.oracle.truffle.api.frame.VirtualFrame,java.lang.Object)` ### onResume(VirtualFrame) `protected void onResume(VirtualFrame frame)`. Since 24.0. Invoked on a resume of the execution on the current thread after a `yield`. Delegates to `onEnter(VirtualFrame)` by default. Use `TruffleInstrument.Env.isSameFrame(RootNode, Frame, Frame)` to match the interrupted and resumed execution. Parameters: `frame` `VirtualFrame`: the frame that was used for executing instrumented node. Cite: `com/oracle/truffle/api/instrumentation/ExecutionEventNode.html#onResume(com.oracle.truffle.api.frame.VirtualFrame)` ### onDispose(VirtualFrame) `protected void onDispose(VirtualFrame frame)`. Since 0.12. Invoked when an event node is removed from the AST. This happens if the underlying binding, language/instrument or engine is disposed. Event nodes are removed lazily. This means that `onDispose(VirtualFrame)` is invoked the next time the particular part of the AST is executed. If the `instrumented node` is not invoked anymore after it was disposed then `onDispose(VirtualFrame)` might or might not be executed. Parameters: `frame` `VirtualFrame`: the frame that was used for executing instrumented node. Cite: `com/oracle/truffle/api/instrumentation/ExecutionEventNode.html#onDispose(com.oracle.truffle.api.frame.VirtualFrame)` ### getInputContext(int) `protected final EventContext getInputContext(int index)`. Since 0.33. Returns the event context of an input by index. The returned input context matches the input context provided in `onInputValue(VirtualFrame, EventContext, int, Object)`. The total number of instrumented input nodes can be accessed using `getInputCount()`. This method returns a constant event context for a constant input index, when called in partially evaluated code paths. Parameters: `index` `int`: the context index. Throws: `IndexOutOfBoundsException` (unchecked): if the index is out of bounds. See also: `onInputValue(VirtualFrame, EventContext, int, Object)`, `getInputCount()`. Cite: `com/oracle/truffle/api/instrumentation/ExecutionEventNode.html#getInputContext(int)` ### getInputCount() `protected final int getInputCount()`. Since 0.33. Returns the total number of instrumented input nodes that may produce `input events` when executed. See also: `onInputValue(VirtualFrame, EventContext, int, Object)`. Cite: `com/oracle/truffle/api/instrumentation/ExecutionEventNode.html#getInputCount()` ### saveInputValue(VirtualFrame, int, Object) `protected final void saveInputValue(VirtualFrame frame, int inputIndex, Object inputValue)`. Since 0.33. Saves an input value reported by `onInputValue(VirtualFrame, EventContext, int, Object)` for use in later events. Saved input values can be restored using `getSavedInputValues(VirtualFrame)` in `onReturn` or `onReturnExceptional` events. The implementation ensures that a minimal number of frame slots is used to save input values. It uses the AST structure to reuse frame slots efficiently whenever possible. The used frame slots are freed if the event binding is `disposed`. Parameters: `frame` `VirtualFrame`: the frame to store the input value in. `inputIndex` `int`: the child input index. `inputValue` `Object`: the input value. Throws: `IllegalArgumentException` (unchecked): for invalid input indexes for non-existing input nodes. See also: `onInputValue(VirtualFrame, EventContext, int, Object)`. Cite: `com/oracle/truffle/api/instrumentation/ExecutionEventNode.html#saveInputValue(com.oracle.truffle.api.frame.VirtualFrame,int,java.lang.Object)` ### getSavedInputValues(VirtualFrame) `protected final Object[] getSavedInputValues(VirtualFrame frame)`. Since 0.33. Returns all saved input values. For valid input indices that did not save any value `null` is returned. If all inputs were filtered or a `null` input filter was provided then an empty array is returned. Parameters: `frame` `VirtualFrame`: the frame to read the input values from. See also: `saveInputValue(VirtualFrame, int, Object)`, `onInputValue(VirtualFrame, EventContext, int, Object)`. Cite: `com/oracle/truffle/api/instrumentation/ExecutionEventNode.html#getSavedInputValues(com.oracle.truffle.api.frame.VirtualFrame)` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ ExecutionEventNodeFactory [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.12. ```java public interface ExecutionEventNodeFactory ``` Event node factories are factories of event nodes for a [`program location`](com/oracle/truffle/api/instrumentation/EventContext.md). The factory might be invoked multiple times for one and the same source location but the location does never change for a particular returned event node. For example it makes sense to register a performance counter on [`create(EventContext)`](com/oracle/truffle/api/instrumentation/ExecutionEventNodeFactory.md#create%28com.oracle.truffle.api.instrumentation.EventContext%29) and increment the counter in the [`ExecutionEventNode`](com/oracle/truffle/api/instrumentation/ExecutionEventNode.md) implementation. The counter can be stored as a [`compilation final`](com/oracle/truffle/api/CompilerDirectives.CompilationFinal.md), so no peak performance overhead persists for looking up the counter on the fast path. ## Methods ### create(EventContext) `ExecutionEventNode create(EventContext context)`. Since 0.12. Returns a new instance of `ExecutionEventNode` for this particular source location. This method might be invoked multiple times for one particular source location `context`. The implementation must ensure that this is handled accordingly. Parameters: `context` `EventContext`: the current context where this event node should get created. Returns `ExecutionEventNode`: a new event node instance, or `null` for no event node at the location. Cite: `com/oracle/truffle/api/instrumentation/ExecutionEventNodeFactory.html#create(com.oracle.truffle.api.instrumentation.EventContext)` # @ GenerateWrapper [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.33. ```java @Retention(CLASS) @Target({TYPE}) public @interface GenerateWrapper ``` Generates a default wrapper subclass of an annotated [`InstrumentableNode`](com/oracle/truffle/api/instrumentation/InstrumentableNode.md) subclass. The generated subclass has the same class name as the original class name plus the 'Wrapper' suffix. The generated class has default package visibility. All non-final and non-private methods starting with execute or [`resume prefix (when specified)`](com/oracle/truffle/api/instrumentation/GenerateWrapper.md#resumeMethodPrefix%28%29) are overridden by the generated wrapper. The generated overrides notifies execution events as required by [`probes`](com/oracle/truffle/api/instrumentation/ProbeNode.md). Other abstract methods are directly delegated to the wrapped node. No other methods are overridden by the generated wrapper. At least one method starting with execute must be non-private and non-final. Every execute method must have [`VirtualFrame`](com/oracle/truffle/api/frame/VirtualFrame.md) as the first declared parameter. Use methods with `execute` prefix for ordinary guest code execution. If the guest language supports yield, add [`yieldExceptions()`](com/oracle/truffle/api/instrumentation/GenerateWrapper.md#yieldExceptions%28%29) argument and specify [`resume prefix`](com/oracle/truffle/api/instrumentation/GenerateWrapper.md#resumeMethodPrefix%28%29) to mark method(s) that resume the yielded execution. To successfully match the yielded/resumed execution, override [`RootNode.isSameFrame(Frame, Frame)`](com/oracle/truffle/api/nodes/RootNode.md#isSameFrame%28com.oracle.truffle.api.frame.Frame,com.oracle.truffle.api.frame.Frame%29) in case the resumed frame is not an identical instance to the yielded frame. **Example Usage:** ```java @GenerateWrapper abstract class ExpressionNode extends Node implements InstrumentableNode { abstract Object execute(VirtualFrame frame); @Override public WrapperNode createWrapper(ProbeNode probeNode) { return new ExpressionNodeWrapper(this, probeNode); } } ``` **Example that ignores return values:** ```java @GenerateWrapper abstract class ExpressionNode extends Node implements InstrumentableNode { abstract Object execute(VirtualFrame frame); @Override public WrapperNode createWrapper(ProbeNode probeNode) { return new ExpressionNodeWrapper(this, probeNode); } @GenerateWrapper.OutgoingConverter final Object convertOutgoing(Object outgoingValue) { return null; } } ``` **Example that converts incoming byte values to int:** ```java @GenerateWrapper abstract class ExpressionNode extends Node implements InstrumentableNode { abstract Object execute(VirtualFrame frame); @Override public WrapperNode createWrapper(ProbeNode probeNode) { return new ExpressionNodeWrapper(this, probeNode); } @GenerateWrapper.IncomingConverter final Object convertIncoming(Object incomingValue) { if (incomingValue instanceof Byte) { return (int) ((byte) incomingValue); } return incomingValue; } } ``` **Example that prevents instrumentation from being added to a method:** ```java @GenerateWrapper abstract class ExpressionNode extends Node implements InstrumentableNode { abstract Object execute(VirtualFrame frame); @Override public WrapperNode createWrapper(ProbeNode probeNode) { return new ExpressionNodeWrapper(this, probeNode); } @GenerateWrapper.Ignore abstract Object executeWithoutInstrumentation(VirtualFrame frame); } ``` **See also** - [`InstrumentableNode`](com/oracle/truffle/api/instrumentation/InstrumentableNode.md) - [`ProbeNode`](com/oracle/truffle/api/instrumentation/ProbeNode.md) ## Nested types - [`GenerateWrapper.Ignore`](com/oracle/truffle/api/instrumentation/GenerateWrapper.Ignore.md) (annotation interface): Annotates a method which should not be instrumented in the generated wrapper subclass. - [`GenerateWrapper.IncomingConverter`](com/oracle/truffle/api/instrumentation/GenerateWrapper.IncomingConverter.md) (annotation interface): Annotates a method to be used as incoming value converter. - [`GenerateWrapper.OutgoingConverter`](com/oracle/truffle/api/instrumentation/GenerateWrapper.OutgoingConverter.md) (annotation interface): Annotates a method to be used as outgoing value converter. - [`GenerateWrapper.YieldException`](com/oracle/truffle/api/instrumentation/GenerateWrapper.YieldException.md) (interface): An interface to be implemented by yield exceptions. ## Elements ### yieldExceptions() `Class[] yieldExceptions() default {}`. Since 24.0. Exceptions that are thrown to yield the execution of a thread. They must implement `YieldException` interface. When one of them is thrown, `onYield()` is called automatically. To indicate resume of the execution, provide `resumeMethodPrefix()`. Default: `{}`. Cite: `com/oracle/truffle/api/instrumentation/GenerateWrapper.html#yieldExceptions()` ### resumeMethodPrefix() `String resumeMethodPrefix() default ""`. Since 24.0. Prefix of methods that resume execution after `yield`. The prefix is empty by default, which means no resume methods. When non-empty, the generated wrapper calls `ProbeNode.onResume(VirtualFrame)` instead of `ProbeNode.onEnter(VirtualFrame)`. Default: `""`. Cite: `com/oracle/truffle/api/instrumentation/GenerateWrapper.html#resumeMethodPrefix()` # @ GenerateWrapper.Ignore [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 21.3. Nested in [`GenerateWrapper`](com/oracle/truffle/api/instrumentation/GenerateWrapper.md). ```java @Retention(CLASS) @Target({METHOD}) public @interface GenerateWrapper.Ignore ``` Annotates a method which should not be instrumented in the generated wrapper subclass. The generated wrapper can still delegate to this method if it is abstract and can be overridden. **See also** - [`for usage examples`](com/oracle/truffle/api/instrumentation/GenerateWrapper.md) # @ GenerateWrapper.IncomingConverter [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 19.0. Nested in [`GenerateWrapper`](com/oracle/truffle/api/instrumentation/GenerateWrapper.md). ```java @Retention(CLASS) @Target({METHOD}) public @interface GenerateWrapper.IncomingConverter ``` Annotates a method to be used as incoming value converter. The annotated method can be used to convert incoming values that were introduced by instruments. Instruments may introduce new values to the interpreter using the [`unwind`](com/oracle/truffle/api/instrumentation/EventContext.md#createUnwind%28java.lang.Object%29) feature. Introduced values are interop values. If the language only supports a subset of interop values or requires them to be wrapped then the incoming converter can be used to perform the necessary conversion. The incoming converter is only invoked if a wrapper is currently inserted. The return type and the single parameter of the annotated method must be of type [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html). The annotated method must have at least package-protected visibility. There can only be a single method annotated with [`IncomingConverter`](com/oracle/truffle/api/instrumentation/GenerateWrapper.IncomingConverter.md) per class annotated with [`GenerateWrapper`](com/oracle/truffle/api/instrumentation/GenerateWrapper.md). **See also** - [`for usage examples`](com/oracle/truffle/api/instrumentation/GenerateWrapper.md) # @ GenerateWrapper.OutgoingConverter [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 19.0. Nested in [`GenerateWrapper`](com/oracle/truffle/api/instrumentation/GenerateWrapper.md). ```java @Retention(CLASS) @Target({METHOD}) public @interface GenerateWrapper.OutgoingConverter ``` Annotates a method to be used as outgoing value converter. The annotated method can be used to convert outgoing return values of instrumentable nodes to instruments. This may be used to convert internal non-interop capable values to interop values before instruments can access it. The outgoing converter can also be used to just return `null` to indicate that return value should be ignored from this wrapped node. The outgoing converter is only invoked if a wrapper is currently inserted. The annotated method is used to convert an guest language value to a format that can be read by other guest languages and tools. The return type and the single parameter of the annotated method must be of type [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html). There can only be a single method annotated with [`OutgoingConverter`](com/oracle/truffle/api/instrumentation/GenerateWrapper.OutgoingConverter.md) per class annotated with [`GenerateWrapper`](com/oracle/truffle/api/instrumentation/GenerateWrapper.md). **See also** - [`for usage examples`](com/oracle/truffle/api/instrumentation/GenerateWrapper.md) # ◇ GenerateWrapper.YieldException [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 24.0. Nested in [`GenerateWrapper`](com/oracle/truffle/api/instrumentation/GenerateWrapper.md). ```java public interface GenerateWrapper.YieldException ``` An interface to be implemented by [`yield exceptions`](com/oracle/truffle/api/instrumentation/GenerateWrapper.md#yieldExceptions%28%29). When a yield exception is thrown from an [`InstrumentableNode`](com/oracle/truffle/api/instrumentation/InstrumentableNode.md) wrapped by [`GenerateWrapper`](com/oracle/truffle/api/instrumentation/GenerateWrapper.md), [`onYield()`](com/oracle/truffle/api/instrumentation/ProbeNode.md#onYield%28com.oracle.truffle.api.frame.VirtualFrame,java.lang.Object%29) is called automatically. ## Methods ### getYieldValue() `Object getYieldValue()`. Since 24.0. Get the value provided by the yield. Cite: `com/oracle/truffle/api/instrumentation/GenerateWrapper.YieldException.html#getYieldValue()` # ◇ InstrumentableNode [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.33. ```java public interface InstrumentableNode extends NodeInterface ``` Extends: [`NodeInterface`](com/oracle/truffle/api/nodes/NodeInterface.md) Interface implemented by AST [`nodes`](com/oracle/truffle/api/nodes/Node.md) that may be *instrumentable*: an AST location where [Truffle instruments](com/oracle/truffle/api/instrumentation/TruffleInstrument.md) are permitted to listen to before and after using execution event listeners. If a node is instrumentable depends on the return value of [`isInstrumentable()`](com/oracle/truffle/api/instrumentation/InstrumentableNode.md#isInstrumentable%28%29). All instrumentable nodes must also extend [`node`](com/oracle/truffle/api/nodes/Node.md). All other member methods of this interface are only allowed to be invoked if [`isInstrumentable()`](com/oracle/truffle/api/instrumentation/InstrumentableNode.md#isInstrumentable%28%29) returns `true` . Every instrumentable node is required to create a wrapper for this instrumentable node in [`createWrapper(ProbeNode)`](com/oracle/truffle/api/instrumentation/InstrumentableNode.md#createWrapper%28com.oracle.truffle.api.instrumentation.ProbeNode%29). The instrumentation framework will, when needed during execution, [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29) the instrumentable node with a [`wrapper`](com/oracle/truffle/api/instrumentation/InstrumentableNode.WrapperNode.md) and delegate to the original node. After the replacement of an instrumentable node with a wrapper we refer to the original node as an instrumented node. Wrappers can be generated automatically using an annotation processor by annotating the class with @[`GenerateWrapper`](com/oracle/truffle/api/instrumentation/GenerateWrapper.md). If an instrumentable node subclass has additional declared methods than its instrumentable base class that are used by other nodes, then a new wrapper should be generated or implemented for the subclass, otherwise the replacement of the wrapper will fail. Instrumentable nodes may return `true` to indicate that they were tagged by [`tag`](com/oracle/truffle/api/instrumentation/Tag.md). Tags are used by guest languages to indicate that a [`node`](com/oracle/truffle/api/nodes/Node.md) is a member of a certain category of nodes. For example a debugger [`instrument`](com/oracle/truffle/api/instrumentation/TruffleInstrument.md) might require a guest language to tag all nodes as [`statements`](com/oracle/truffle/api/instrumentation/StandardTags.StatementTag.md) that should be considered as such. See [`hasTag(Class)`](com/oracle/truffle/api/instrumentation/InstrumentableNode.md#hasTag%28java.lang.Class%29) for further details on how to use tags. **Example minimal implementation of an instrumentable node:** ```java @GenerateWrapper abstract static class SimpleNode extends Node implements InstrumentableNode { public abstract Object execute(VirtualFrame frame); public boolean isInstrumentable() { return true; } public WrapperNode createWrapper(ProbeNode probe) { // ASTNodeWrapper is generated by @GenerateWrapper return new SimpleNodeWrapper(this, probe); } } ``` Example for a typical implementation of an instrumentable node with support for source sections: ```java @GenerateWrapper abstract static class RecommendedNode extends Node implements InstrumentableNode { private static final int NO_SOURCE = -1; private int sourceCharIndex = NO_SOURCE; private int sourceLength; public abstract Object execute(VirtualFrame frame); // invoked by the parser to set the source void setSourceSection(int charIndex, int length) { assert sourceCharIndex == NO_SOURCE : "source should only be set once"; this.sourceCharIndex = charIndex; this.sourceLength = length; } public final boolean isInstrumentable() { // all AST nodes with source are instrumentable return sourceCharIndex != NO_SOURCE; } @Override @TruffleBoundary public final SourceSection getSourceSection() { if (sourceCharIndex == NO_SOURCE) { // AST node without source return null; } RootNode rootNode = getRootNode(); if (rootNode == null) { // not yet adopted yet return null; } Source source = rootNode.getSourceSection().getSource(); return source.createSection(sourceCharIndex, sourceLength); } public WrapperNode createWrapper(ProbeNode probe) { // ASTNodeWrapper is generated by @GenerateWrapper return new RecommendedNodeWrapper(this, probe); } } ``` **See also** - [`to decide whether node is instrumentable.`](com/oracle/truffle/api/instrumentation/InstrumentableNode.md#isInstrumentable%28%29) - [`Implement hasTag to decide whether an instrumentable node is tagged with a tag.`](com/oracle/truffle/api/instrumentation/InstrumentableNode.md#hasTag%28java.lang.Class%29) - [`Use an annotation processor to generate the wrapper class.`](com/oracle/truffle/api/instrumentation/GenerateWrapper.md) - [`Instrumenter.attachExecutionEventListener(SourceSectionFilter, ExecutionEventListener)`](com/oracle/truffle/api/instrumentation/Instrumenter.md#attachExecutionEventListener%28com.oracle.truffle.api.instrumentation.SourceSectionFilter,T%29) ## Nested types - [`InstrumentableNode.WrapperNode`](com/oracle/truffle/api/instrumentation/InstrumentableNode.WrapperNode.md) (interface): Nodes that the instrumentation framework inserts into guest language ASTs (between instrumentable guest language nodes and their parents) for the purpose of interposing on execution events and reporting them via the instrumentation framework. ## Methods ### isInstrumentable() `boolean isInstrumentable()`. Since 0.33. Returns `true` if this node is instrumentable. Instrumentable nodes are points where instrumenters can attach execution events. The return values of instrumentable nodes must always be interop capable values. The implementation of this method must ensure that its result is stable after the parent `root node` was wrapped in a `CallTarget` using `RootNode.getCallTarget()`. The result is stable if the result of calling this method remains always the same. This method might be called in parallel from multiple threads even if the language is single threaded. The method may be invoked without a language context currently being active. Cite: `com/oracle/truffle/api/instrumentation/InstrumentableNode.html#isInstrumentable()` ### createWrapper(ProbeNode) `InstrumentableNode.WrapperNode createWrapper(ProbeNode probe)`. Since 0.33. Returns a new, never adopted, unshared `wrapper` node implementation for this `instrumentable` node. The returned wrapper implementation must extend the same type that implements `InstrumentableNode`. The instrumentation framework will, when needed during execution, `replace` the instrumentable node with a `wrapper` and delegate to the original node. After the replacement of an instrumentable node with a wrapper we refer to the original node as an instrumented node. Wrappers can be generated automatically using an annotation processor by annotating the class with @`GenerateWrapper`. Please note that if an instrumentable node subclass has additional execute methods then a new wrapper must be generated or implemented. Otherwise the `replacement` of the instrumentable node with the wrapper will fail if the subtype is used as static type in nodes `children`. A wrapper forwards the following events concerning the delegate to the given `probe` for propagation through the instrumentation framework, e.g. to event listeners bound to this guest language program location: onEnter(Frame): an *execute* method on the delegate is ready to be called;; onReturnValue(Frame,Object): an *execute* method on the delegate has just returned a (possibly `null`) value;; onReturnExceptionalOrUnwind(Frame,Throwable, boolean): an *execute* method on the delegate has just thrown an exception. This method is always invoked on an interpreter thread. The method may be invoked without a language context currently being active. If `findProbe()` is overriden and never returns a `null` value, then `createWrapper(ProbeNode)` does not need to be implemented and may throw an [`UnsupportedOperationException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/UnsupportedOperationException.html) instead. Parameters: `probe` `ProbeNode`: the `probe node` to be adopted and sent execution events by the wrapper. Returns `InstrumentableNode.WrapperNode`: a `wrapper` implementation. Cite: `com/oracle/truffle/api/instrumentation/InstrumentableNode.html#createWrapper(com.oracle.truffle.api.instrumentation.ProbeNode)` ### findProbe() `default ProbeNode findProbe()`. Since 24.2. Determines how to find a probe given an instrumentable node. Implementing this method allows to customize probe storage, e.g. if a different strategy should be used other than the default wrapper node strategy. The default implementation discovers the probe through the parent wrapper node by calling `WrapperNode.getProbeNode()`. A probe can be initialized lazily on `findProbe()` calls using `createProbe(SourceSection)`. This method will never be invoked if `isInstrumentable()` returns `false`. If this method returns `null` then the default wrapper node strategy will be applied for this instrumentable node. A custom probe storage strategy must therefore ensure that this method never returns `null`. The probe must be stored/read from a reference with volatile semantics. This method must produce a `partial evaluation constant` if the receiver is a PE constant. See also: `createProbe(SourceSection)`. Cite: `com/oracle/truffle/api/instrumentation/InstrumentableNode.html#findProbe()` ### hasTag(Class) `default boolean hasTag(Class tag)`. Since 0.33. Returns `true` if this node should be considered tagged by a given tag else `false`. In order for a Truffle language to support a particular tag, the tag must also be marked as `provided` by the language. Tags are used by guest languages to indicate that a `node` is a member of a certain category of nodes. For example a debugger `instrument` might require a guest language to tag all nodes as statements that should be considered as such. The node implementor may decide how to implement tagging for nodes. The simplest way to implement tagging using Java types is by overriding the `hasTag(Class)` method. This example shows how to tag a node subclass and all its subclasses as statement: Often it is impossible to just rely on the node's Java type to implement tagging. This example shows how to use local state to implement tagging for a node. The implementation of hasTag method must ensure that its result is stable after the parent `root node` was wrapped in a `CallTarget` using `RootNode.getCallTarget()`. The result is stable if the result of calling this method for a particular tag remains always the same. This method might be called in parallel from multiple threads even if the language is single threaded. The method may be invoked without a language context currently being active. Parameters: `tag` `Class`: the class `provided` by the `language`. Returns `boolean`: `true` if the node should be considered tagged by a tag else `false`. Cite: `com/oracle/truffle/api/instrumentation/InstrumentableNode.html#hasTag(java.lang.Class)` ```java @GenerateWrapper abstract static class StatementNode extends SimpleNode implements InstrumentableNode { @Override public final Object execute(VirtualFrame frame) { executeVoid(frame); return null; } public abstract void executeVoid(VirtualFrame frame); @Override public final WrapperNode createWrapper(ProbeNode probe) { return StatementNodeWrapper.create(this, probe); } public boolean hasTag(Class tag) { if (tag == StandardTags.StatementTag.class) { return true; } return false; } } ``` ```java @GenerateWrapper static class HaltNode extends Node implements InstrumentableNode { private boolean isDebuggerHalt; public void setDebuggerHalt(boolean isDebuggerHalt) { this.isDebuggerHalt = isDebuggerHalt; } public Object execute(VirtualFrame frame) { // does nothing; return null; } public boolean isInstrumentable() { return true; } public boolean hasTag(Class tag) { if (tag == Debugger.HaltTag.class) { return isDebuggerHalt; } return false; } public WrapperNode createWrapper(ProbeNode probe) { return new HaltNodeWrapper(this, probe); } } ``` ### getNodeObject() `default Object getNodeObject()`. Since 0.33. Returns an interop capable object that contains all keys and values of attributes associated with this node. The returned object must return `true` in response to the `has members` message. If `null` is returned then an empty tag object without any readable keys will be assumed. Multiple calls to `getNodeObject()` for a particular node may return the same or objects with different identity. The returned object must not support any write operation. The returned object must not support execution or instantiation and must not have a size. For performance reasons it is not recommended to eagerly collect all properties of the node object when `getNodeObject()` is invoked. Instead, the language should lazily compute them when they are read. If the node object contains dynamic properties, that change during the execution of the AST, then the node must return an updated value for each key when it is read repeatedly. In other words the node object must always represent the current state of this AST `node`. The implementer should not cache the node instance in the AST. The instrumentation framework will take care of caching node object instances when they are requested by tools. **Compatibility:** In addition to the expected keys by the tag specification, the language implementation may provide any set of additional keys and values. Tools might depend on these language specific tags and might break if keys or values are changed without notice. For a memory efficient implementation the language might make the instrumentable `Node` a TruffleObject and return this instance. This method might be called in parallel from multiple threads even if the language is single threaded. The method may be invoked without a language context currently being active. The `AST lock` is held while `getNodeObject()` object is invoked. There is no lock held when the object is read. Returns `Object`: the node object as TruffleObject or `null` if no node object properties are available for this instrumented node. Cite: `com/oracle/truffle/api/instrumentation/InstrumentableNode.html#getNodeObject()` ### materializeInstrumentableNodes(Set) `default InstrumentableNode materializeInstrumentableNodes(Set> materializedTags)`. Since 0.33. Removes optimizations performed in this AST node to restore the syntactic AST structure. Guest languages may decide to group multiple nodes together into a single node. This is useful to reduce the memory consumed by the AST representation and it can also improve the execution performance when interpreting the AST. Performing such optimizations often modify the syntactic AST structure, leading to invalid execution events reported to the instrumentation framework. Implementing this method allows the instrumented node to restore the syntactic AST structure when needed. It provides a list of tags that were requested by all current execution event bindings to allow the language to do the materialization selectively for instrumentable nodes with certain tags only. The returned instrumentable nodes must return themselves when this method is called on them with the same tags. Materialized nodes should not be re-materialized again. Instrumentation relies on the stability of materialized nodes. Use `Node.notifyInserted(Node)` when you need to change the structure of instrumentable nodes. Node must return itself from this method when it has already seen all the materializedTags specified as an argument, i.e., not only if the set of tags is exactly the same as before, but also if the current set of tags is completely contained in the union of all the sets of tags specified in all the calls of this method that led to creation of this materialized node. If the node returns a new node from this method, the subtree rooted at the new node must be completely unadopted, i.e., all nodes it contains must not have existed in the original AST. Also, the new subtree must be completely materialized, so that no new materializations occur when the instrumentation framework instruments the new subtree during the current traversal. The AST lock is acquired while this method is invoked. Therefore it is not allowed to run guest language code while this method is invoked. This method might be called in parallel from multiple threads even if the language is single threaded. The method may be invoked without a language context currently being active. Language reference is always available. In the example below, we show how the `IncrementNode` with a `ConstantNode` child is optimized into a `ConstantIncrementNode` and how it can implement `materializeSyntaxNodes` to restore the syntactic structure of the AST: Parameters: `materializedTags` `Set>`: a set of tags that requested to be materialized. Cite: `com/oracle/truffle/api/instrumentation/InstrumentableNode.html#materializeInstrumentableNodes(java.util.Set)` ```java @GenerateWrapper abstract static class ExpressionNode extends Node implements InstrumentableNode { abstract int execute(VirtualFrame frame); public boolean isInstrumentable() { return true; } public boolean hasTag(Class tag) { return tag == StandardTags.ExpressionTag.class; } public WrapperNode createWrapper(ProbeNode probe) { return new ExpressionNodeWrapper(this, probe); } } class ConstantNode extends ExpressionNode { private final int constant; ConstantNode(int constant) { this.constant = constant; } @Override int execute(VirtualFrame frame) { return constant; } } // node with constant folded operation class ConstantIncrementNode extends ExpressionNode { final int constantIncremented; ConstantIncrementNode(int constant) { this.constantIncremented = constant + 1; } // desguar to restore syntactic structure of the AST public InstrumentableNode materializeInstrumentableNodes( Set> tags) { if (tags.contains(StandardTags.ExpressionTag.class)) { return new IncrementNode( new ConstantNode(constantIncremented - 1)); } return this; } @Override int execute(VirtualFrame frame) { return constantIncremented; } } // node with full semantics of the node. class IncrementNode extends ExpressionNode { @Child ExpressionNode child; IncrementNode(ExpressionNode child) { this.child = child; } @Override int execute(VirtualFrame frame) { return child.execute(frame) + 1; } } ``` ### findNearestNodeAt(int, Set) `default Node findNearestNodeAt(int sourceCharIndex, Set> tags)`. Since 0.33. Find the nearest `node` to the given source character index according to the guest language control flow, that is tagged with some of the given tags. The source character index is in this node's source. The nearest node will preferably be in the same block/function as the character index. This node acts as a context node - either a node containing the character index if such node exists, or node following the character index if exists, or node preceding the character index otherwise. Return an instrumentable node that is tagged with some of the tags and containing the character index, if such exists and there is not a more suitable sibling node inside the container source section. Return the next sibling tagged node otherwise, or the previous one when the next one does not exist. Use Case The current use-case of this method is a relocation of breakpoint position, for instance. When a user submits a breakpoint at the source character index, a nearest logical instrumentable node that has suitable tags needs to be found to move the breakpoint accordingly. Default Implementation This method has a default implementation, which assumes that the materialized Truffle `Node` hierarchy corresponds with the logical guest language AST structure. If this is not the case for a particular guest language, this method needs to be implemented, possibly with the help of language specific AST node classes. The default algorithm is following: If the character index is smaller than the start index of this node's source section, return the first tagged child of this node.; If the character index is larger than the end index of this node's source section, return the last tagged child of this node.; Otherwise, this node's source section contains the character index. Use following steps to find the nearest tagged node in this node's hierarchy: Traverse the node children in declaration order (AST breadth-first order). For every child do: When the child is not instrumentable, include its children into the traversal.; When the child does not have a source section assigned, ignore it.; When the `sourceCharIndex` is inside the child's source section, find if it's tagged with one of the tags (store as `isTagged`) and repeat recursively from **3.a.** using this child as the node.; When the child is above the character index, remember a sorted list of such children up to the lowest tagged child (store in `higherNodes` list).; When the child is below the character index, remember a sorted list of such children down to the highest tagged child (store in `lowerNodes` list).; If a tagged child node was found in **3.a** with source section matching the `sourceCharIndex`, return it.; Otherwise, we check the list of lower/higher nodes: Prefer the node after the character index.; Traverse `higherNodes` in ascending order. When the node is tagged, return it, when not, repeat with that node from **3.a.**; If no tagged node was found, traverse `lowerNodes` in descending order. When the node is tagged, return it, when not, repeat with that node from **3.a.**; When nothing was found in the steps above, return `null`.; If **c.** didn't provide a tagged node, apply this algorithm recursively to a parent of this node, if exists. If you encounter the nearest tagged parent node found in **3.a**, return it. Otherwise, return a tagged child found in the steps above, if any. Parameters: `sourceCharIndex` `int`: the 0-based character index in this node's source, to find the nearest tagged node from. `tags` `Set>`: a set of tags, the nearest node needs to be tagged with at least one tag from this set. Returns `Node`: the nearest instrumentable node according to the execution flow and tagged with some of the tags, or `null` when none was found. See also: `findNearestNodeAt(int, int, Set)`. Cite: `com/oracle/truffle/api/instrumentation/InstrumentableNode.html#findNearestNodeAt(int,java.util.Set)` ### findNearestNodeAt(int, int, Set) `default Node findNearestNodeAt(int line, int column, Set> tags)`. Since 23.0. Find the nearest `node` to the given source line and column position, according to the guest language control flow, that is tagged with some of the given tags. Behaves in the same way as `findNearestNodeAt(int, Set)` but uses line/column as the position specification instead of a character index. Parameters: `line` `int`: 1-based line number. `column` `int`: 1-based column number, or less than one when the column is unknown. `tags` `Set>`: a set of tags, the nearest node needs to be tagged with at least one tag from this set. Returns `Node`: the nearest instrumentable node according to the execution flow and tagged with some of the tags, or `null` when none was found. See also: `findNearestNodeAt(int, Set)`. Cite: `com/oracle/truffle/api/instrumentation/InstrumentableNode.html#findNearestNodeAt(int,int,java.util.Set)` ### findInstrumentableParent(Node) `static Node findInstrumentableParent(Node node)`. Since 20.3. Find the first `instrumentable` node on it's parent chain. If the provided node is instrumentable itself, it is returned. If not, the first parent node that is instrumentable is returned, if any. Parameters: `node` `Node`: a Node. Returns `Node`: the first instrumentable node, or `null` when no instrumentable parent exists. Cite: `com/oracle/truffle/api/instrumentation/InstrumentableNode.html#findInstrumentableParent(com.oracle.truffle.api.nodes.Node)` ### createProbe(SourceSection) `default ProbeNode createProbe(SourceSection sourceSection)`. Since 24.2. Method allows to create an eager probe node given an instrumentable node. This is useful to implement custom probe storage by implementing `findProbe()`. Parameters: `sourceSection` `SourceSection`: the eager materialized source section for this probe. Cite: `com/oracle/truffle/api/instrumentation/InstrumentableNode.html#createProbe(com.oracle.truffle.api.source.SourceSection)` # ◇ InstrumentableNode.WrapperNode [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.33. Nested in [`InstrumentableNode`](com/oracle/truffle/api/instrumentation/InstrumentableNode.md). ```java public interface InstrumentableNode.WrapperNode extends NodeInterface ``` Extends: [`NodeInterface`](com/oracle/truffle/api/nodes/NodeInterface.md) Nodes that the instrumentation framework inserts into guest language ASTs (between [`instrumentable`](com/oracle/truffle/api/instrumentation/InstrumentableNode.md) guest language nodes and their parents) for the purpose of interposing on execution events and reporting them via the instrumentation framework. **See also** - [`createWrapper(ProbeNode)`](com/oracle/truffle/api/instrumentation/InstrumentableNode.md#createWrapper%28com.oracle.truffle.api.instrumentation.ProbeNode%29) ## Methods ### getDelegateNode() `Node getDelegateNode()`. Since 0.33. The `instrumentable` guest language node, adopted as a child, whose execution events the wrapper reports to the instrumentation framework. This method might be called in parallel from multiple threads. The method may be invoked without a language context currently being active. Cite: `com/oracle/truffle/api/instrumentation/InstrumentableNode.WrapperNode.html#getDelegateNode()` ### getProbeNode() `ProbeNode getProbeNode()`. Since 0.33. A child of the wrapper, through which the wrapper reports execution events related to the guest language *delegate* node. This method might be called in parallel from multiple threads. The method may be invoked without a language context currently being active. Cite: `com/oracle/truffle/api/instrumentation/InstrumentableNode.WrapperNode.html#getProbeNode()` # ◆ Instrumenter [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.12. ```java public abstract class Instrumenter ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Instrumenter` Provides capabilities to attach listeners for execution, load, output and allocation events. The instrumenter remains usable as long as the engine is not closed. The instrumenter methods are safe to be used from arbitrary other threads. ## Methods ### attachExecutionEventListener(SourceSectionFilter, T) `public final EventBinding attachExecutionEventListener(SourceSectionFilter eventFilter, T listener)`. Since 0.33. Starts execution event notification for a given `event filter` and `listener`. The execution events are delivered to the `ExecutionEventListener`. Returns a `binding` which allows to dispose the attached execution event binding. Disposing the binding removes all probes and wrappers from the AST that were created for this instrument. The removal of probes and wrappers is performed lazily on the next execution of the AST. By default no `input value events` are delivered to the listener. Parameters: `eventFilter` `SourceSectionFilter`: filters the events that are reported to the given `listener`. `listener` `T`: that listens to execution events. See also: `ExecutionEventListener`. Cite: `com/oracle/truffle/api/instrumentation/Instrumenter.html#attachExecutionEventListener(com.oracle.truffle.api.instrumentation.SourceSectionFilter,T)` ### attachExecutionEventFactory(SourceSectionFilter, T) `public final EventBinding attachExecutionEventFactory(SourceSectionFilter eventFilter, T factory)`. Since 0.33. Starts execution event notification for a given `event filter` and `factory`. Events are delivered to the `ExecutionEventNode` instances created by the factory. Returns a `binding` which allows to dispose the attached execution event binding. Disposing the binding removes all probes and wrappers from the AST that were created for this instrument. The removal of probes and wrappers is performed lazily on the next execution of the AST. By default no `input value events` are delivered to the created execution event nodes. To deliver inputs events use `attachExecutionEventFactory(SourceSectionFilter, SourceSectionFilter, ExecutionEventNodeFactory)` instead. Parameters: `eventFilter` `SourceSectionFilter`: filters the events that are reported to the `execution event nodes` created by the factory. `factory` `T`: the factory that creates `execution event nodes`. See also: `ExecutionEventNodeFactory`, `attachExecutionEventFactory(SourceSectionFilter, SourceSectionFilter, ExecutionEventNodeFactory)`. Cite: `com/oracle/truffle/api/instrumentation/Instrumenter.html#attachExecutionEventFactory(com.oracle.truffle.api.instrumentation.SourceSectionFilter,T)` ### attachExecutionEventFactory(SourceSectionFilter, SourceSectionFilter, T) `public abstract EventBinding attachExecutionEventFactory(SourceSectionFilter eventFilter, SourceSectionFilter inputFilter, T factory)`. Since 0.33. Starts execution event notification for a given `event filter` and `factory`. Events are delivered to the `ExecutionEventNode` instances created by the factory. Returns a `binding` which allows to dispose the attached execution event binding. Disposing the binding removes all probes and wrappers from the AST that were created for this instrument. The removal of probes and wrappers is performed lazily on the next execution of the AST. The input filter argument filters which `input events` are delivered to the created execution event nodes. Parameters: `eventFilter` `SourceSectionFilter`: filters the events that are reported to the `execution event nodes` created by the factory. `inputFilter` `SourceSectionFilter`: filters input events, `null` for no input values. `factory` `T`: the factory that creates `execution event nodes`. See also: `ExecutionEventNodeFactory`, `ExecutionEventNode.onInputValue(com.oracle.truffle.api.frame.VirtualFrame, EventContext, int, Object)`. Cite: `com/oracle/truffle/api/instrumentation/Instrumenter.html#attachExecutionEventFactory(com.oracle.truffle.api.instrumentation.SourceSectionFilter,com.oracle.truffle.api.instrumentation.SourceSectionFilter,T)` ### attachExecutionEventFactory(NearestSectionFilter, SourceSectionFilter, T) `public abstract EventBinding attachExecutionEventFactory(NearestSectionFilter nearestFilter, SourceSectionFilter baseFilter, T factory)`. Since 23.0. Starts execution event notification for the nearest `SourceSection` as specified by the `NearestSectionFilter`. Events are delivered to the `ExecutionEventNode` instances created by the `factory`. Returns a `binding` which allows to dispose the attached execution event binding. Disposing the binding removes all probes and wrappers from the AST that were created for this instrument. The removal of probes and wrappers is performed lazily on the next execution of the AST. The final nearest node is selected from the sections filtered by the `baseFilter` by applying `InstrumentableNode.findNearestNodeAt(int, int, Set)`. Parameters: `nearestFilter` `NearestSectionFilter`: a filter describing the nearest section. `baseFilter` `SourceSectionFilter`: a filter selecting sections we find the nearest from. `factory` `T`: the factory that creates `execution event nodes`. Returns `EventBinding`: a handle to dispose the execution event binding. See also: `ExecutionEventNodeFactory`. Cite: `com/oracle/truffle/api/instrumentation/Instrumenter.html#attachExecutionEventFactory(com.oracle.truffle.api.instrumentation.NearestSectionFilter,com.oracle.truffle.api.instrumentation.SourceSectionFilter,T)` ### attachLoadSourceListener(SourceFilter, T, boolean) `public abstract EventBinding attachLoadSourceListener(SourceFilter filter, T listener, boolean includeExistingSources)`. Since 0.33. Starts notifications for each newly loaded `Source` and returns a binding that can be used to terminate notifications. Only subsequent loads will be notified unless `includeExistingSources` is true, in which case a notification for each previous load will be delivered before this method returns. Parameters: `filter` `SourceFilter`: a filter on which sources events are triggered. `listener` `T`: a listener that gets notified if a source was loaded. `includeExistingSources` `boolean`: whether or not this listener should be notified for sources which were already loaded at the time when this listener was attached. Returns `EventBinding`: a handle for stopping the notification stream. See also: `LoadSourceListener.onLoad(LoadSourceEvent)`. Cite: `com/oracle/truffle/api/instrumentation/Instrumenter.html#attachLoadSourceListener(com.oracle.truffle.api.instrumentation.SourceFilter,T,boolean)` ### attachExecuteSourceListener(SourceFilter, T, boolean) `public abstract EventBinding attachExecuteSourceListener(SourceFilter filter, T listener, boolean includeExecutedSources)`. Since 0.33. Starts notifications for each newly executed `Source` and returns a binding that can be used to terminate notifications. Only subsequent executions will be notified unless `includeExecutedSources` is true, in which case a notification for each previously executed source will be delivered before this method returns. A source is reported as executed if any of it's `RootNode`s start to be executed. Every source is reported at most once. Parameters: `filter` `SourceFilter`: a filter on which source events are triggered. `listener` `T`: a listener that gets notified if a source was executed. `includeExecutedSources` `boolean`: whether or not this listener should be notified for sources which were already executed at the time when this listener was attached. Returns `EventBinding`: a handle for stopping the notification stream. See also: `ExecuteSourceListener.onExecute(ExecuteSourceEvent)`. Cite: `com/oracle/truffle/api/instrumentation/Instrumenter.html#attachExecuteSourceListener(com.oracle.truffle.api.instrumentation.SourceFilter,T,boolean)` ### attachLoadSourceSectionListener(SourceSectionFilter, T, boolean) `public abstract EventBinding attachLoadSourceSectionListener(SourceSectionFilter filter, T listener, boolean includeExistingSourceSections)`. Since 0.15. Starts notifications for each `SourceSection` in every newly loaded `Source` and returns a binding that can be used to terminate notifications. Only subsequent loads will be notified unless `includeExistingSourceSections` is true, in which case a notification for each previous load will be delivered before this method returns. Every source is reported at most once. Parameters: `filter` `SourceSectionFilter`: a filter on which sources sections trigger events. `listener` `T`: a listener that gets notified if a source section was loaded. `includeExistingSourceSections` `boolean`: whether or not this listener should be notified for sources which were already loaded at the time when this listener was attached. Returns `EventBinding`: a handle for stopping the notification stream. See also: `LoadSourceSectionListener.onLoad(LoadSourceSectionEvent)`. Cite: `com/oracle/truffle/api/instrumentation/Instrumenter.html#attachLoadSourceSectionListener(com.oracle.truffle.api.instrumentation.SourceSectionFilter,T,boolean)` ### attachLoadSourceSectionListener(NearestSectionFilter, SourceSectionFilter, …) `public abstract EventBinding attachLoadSourceSectionListener(NearestSectionFilter nearestFilter, SourceSectionFilter baseFilter, T listener, boolean includeExistingSourceSections)`. Since 23.0. Starts notifications for the nearest `SourceSection` as specified by the `NearestSectionFilter` and returns a binding that can be used to terminate notifications. The final nearest node is selected from the sections filtered by the `baseFilter` by applying `InstrumentableNode.findNearestNodeAt(int, int, Set)`. Only subsequent loads will be notified unless `includeExistingSourceSections` is true, in which case a notification for each previously loaded source section will be delivered before this method returns. Parameters: `nearestFilter` `NearestSectionFilter`: a filter describing the nearest section. `baseFilter` `SourceSectionFilter`: a filter selecting sections we find the nearest from. `listener` `T`: a listener that gets notified if a source section was loaded. `includeExistingSourceSections` `boolean`: whether or not this listener should be notified for source sections which were already loaded at the time when this listener was attached. Returns `EventBinding`: a handle for stopping the notification stream. See also: `LoadSourceSectionListener.onLoad(LoadSourceSectionEvent)`. Cite: `com/oracle/truffle/api/instrumentation/Instrumenter.html#attachLoadSourceSectionListener(com.oracle.truffle.api.instrumentation.NearestSectionFilter,com.oracle.truffle.api.instrumentation.SourceSectionFilter,T,boolean)` ### createLoadSourceBinding(SourceFilter, T, boolean) `public abstract EventBinding createLoadSourceBinding(SourceFilter filter, T listener, boolean includeExistingSources)`. Since 21.1. Create a binding to get notifications for each newly loaded `Source`. The binding needs to be `attached` to receive notifications. Only subsequent loads will be notified after `attach`, unless `includeExistingSources` is true, in which case a notification for each previously loaded source will be delivered before attach method returns. The difference from `attachLoadSourceListener(SourceFilter, LoadSourceListener, boolean)` is in having the binding object before notifications are produced when existing sources are requested. Parameters: `filter` `SourceFilter`: a filter on which sources events are triggered. `listener` `T`: a listener that gets notified if a source was loaded. `includeExistingSources` `boolean`: whether or not this listener should be notified for sources which were already loaded at the time when this listener was attached. Returns `EventBinding`: a binding handle to `attach` and `stop` the notification stream. See also: `LoadSourceListener.onLoad(LoadSourceEvent)`. Cite: `com/oracle/truffle/api/instrumentation/Instrumenter.html#createLoadSourceBinding(com.oracle.truffle.api.instrumentation.SourceFilter,T,boolean)` ### createExecuteSourceBinding(SourceFilter, T, boolean) `public abstract EventBinding createExecuteSourceBinding(SourceFilter filter, T listener, boolean includeExecutedSources)`. Since 21.1. Create a binding to get notifications for each newly executed `Source`. The binding needs to be `attached` to receive notifications. Only subsequent executions will be notified after `attach`, unless `includeExecutedSources` is true, in which case a notification for each previously executed source will be delivered before attach method returns. Every source is reported at most once. The difference from `attachExecuteSourceListener(SourceFilter, ExecuteSourceListener, boolean)` is in having the binding object before notifications are produced when executed sources are requested. Parameters: `filter` `SourceFilter`: a filter on which sources events are triggered. `listener` `T`: a listener that gets notified if a source was executed. `includeExecutedSources` `boolean`: whether or not this listener should be notified for sources which were already executed at the time when this listener was attached. Returns `EventBinding`: a binding handle to `attach` and `stop` the notification stream. See also: `ExecuteSourceListener.onExecute(ExecuteSourceEvent)`. Cite: `com/oracle/truffle/api/instrumentation/Instrumenter.html#createExecuteSourceBinding(com.oracle.truffle.api.instrumentation.SourceFilter,T,boolean)` ### createLoadSourceSectionBinding(SourceSectionFilter, T, boolean) `public abstract EventBinding createLoadSourceSectionBinding(SourceSectionFilter filter, T listener, boolean includeExistingSourceSections)`. Since 21.1. Create a binding to get notifications for each newly loaded `SourceSection` in every newly loaded `Source`. The binding needs to be `attached` to receive notifications. Only subsequent loads will be notified after `attach`, unless `includeExistingSourceSections` is true, in which case a notification for each previously loaded source section will be delivered before attach method returns. Every source is reported at most once. The difference from `attachLoadSourceSectionListener(SourceSectionFilter, LoadSourceSectionListener, boolean)` is in having the binding object before notifications are produced when existing source sections are requested. Parameters: `filter` `SourceSectionFilter`: a filter on which sources events are triggered. `listener` `T`: a listener that gets notified if a source section was loaded. `includeExistingSourceSections` `boolean`: whether or not this listener should be notified for source sections which were already loaded at the time when this listener was attached. Returns `EventBinding`: a binding handle to `attach` and `stop` the notification stream. See also: `LoadSourceSectionListener.onLoad(LoadSourceSectionEvent)`. Cite: `com/oracle/truffle/api/instrumentation/Instrumenter.html#createLoadSourceSectionBinding(com.oracle.truffle.api.instrumentation.SourceSectionFilter,T,boolean)` ### createLoadSourceSectionBinding(NearestSectionFilter, SourceSectionFilter, …) `public abstract EventBinding createLoadSourceSectionBinding(NearestSectionFilter nearestFilter, SourceSectionFilter baseFilter, T listener, boolean includeExistingSourceSections)`. Since 23.0. Create a binding to get notification for the nearest source section to the given position as specified by the `NearestSectionFilter`. The final nearest node is selected from the sections filtered by the `baseFilter` by applying `InstrumentableNode.findNearestNodeAt(int, int, Set)`. The binding needs to be `attached` to receive notifications. Only subsequent loads will be notified after `attach`, unless `includeExistingSourceSections` is true, in which case a notification for each previously loaded source section will be delivered before attach method returns. The difference from `attachLoadSourceSectionListener(NearestSectionFilter, SourceSectionFilter, LoadSourceSectionListener, boolean)` is in having the binding object before notifications are produced when existing source sections are requested. Parameters: `nearestFilter` `NearestSectionFilter`: a filter describing the nearest section. `baseFilter` `SourceSectionFilter`: a filter selecting sections we find the nearest from. `listener` `T`: a listener that gets notified if a source section was loaded. `includeExistingSourceSections` `boolean`: whether or not this listener should be notified for source sections which were already loaded at the time when this listener was attached. Returns `EventBinding`: a binding handle to `attach` and `stop` the notification stream. See also: `LoadSourceSectionListener.onLoad(LoadSourceSectionEvent)`. Cite: `com/oracle/truffle/api/instrumentation/Instrumenter.html#createLoadSourceSectionBinding(com.oracle.truffle.api.instrumentation.NearestSectionFilter,com.oracle.truffle.api.instrumentation.SourceSectionFilter,T,boolean)` ### visitLoadedSourceSections(SourceSectionFilter, LoadSourceSectionListener) `public abstract void visitLoadedSourceSections(SourceSectionFilter filter, LoadSourceSectionListener listener)`. Since 19.0. Notifies the listener for each `SourceSection` in every loaded `Source` that corresponds to the filter. Only loaded sections are notified, synchronously. Parameters: `filter` `SourceSectionFilter`: a filter on which source sections trigger events. `listener` `LoadSourceSectionListener`: a listener that gets notified with loaded source sections. See also: `LoadSourceSectionListener.onLoad(LoadSourceSectionEvent)`. Cite: `com/oracle/truffle/api/instrumentation/Instrumenter.html#visitLoadedSourceSections(com.oracle.truffle.api.instrumentation.SourceSectionFilter,com.oracle.truffle.api.instrumentation.LoadSourceSectionListener)` ### attachOutConsumer(T) `public abstract EventBinding attachOutConsumer(T stream)`. Since 0.25. Attach an output stream as a consumer of the `standard output`. The consumer output stream receives all output that goes to `TruffleInstrument.Env.out()` since this call, including output emitted by the [`org.graalvm.polyglot.Engine`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Engine.html) this instrumenter is being executed in, output from instruments (including this one), etc. Be sure to `dispose` the binding when it's not used any more. Cite: `com/oracle/truffle/api/instrumentation/Instrumenter.html#attachOutConsumer(T)` ### attachErrConsumer(T) `public abstract EventBinding attachErrConsumer(T stream)`. Since 0.25. Attach an output stream as a consumer of the `error output` . The consumer output stream receives all error output that goes to `TruffleInstrument.Env.err()` since this call, including error output emitted by the [`org.graalvm.polyglot.Engine`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Engine.html) this instrumenter is being executed in, error output from instruments (including this one), etc. Be sure to `dispose` the binding when it's not used any more. Cite: `com/oracle/truffle/api/instrumentation/Instrumenter.html#attachErrConsumer(T)` ### attachAllocationListener(AllocationEventFilter, T) `public abstract EventBinding attachAllocationListener(AllocationEventFilter filter, T listener)`. Since 0.27. Attach a `listener` to be notified about allocations of guest language values. Be sure to `dispose` the binding when it's not used any more. Cite: `com/oracle/truffle/api/instrumentation/Instrumenter.html#attachAllocationListener(com.oracle.truffle.api.instrumentation.AllocationEventFilter,T)` ### attachContextsListener(T, boolean) `public abstract EventBinding attachContextsListener(T listener, boolean includeActiveContexts)`. Since 0.30. Attach a `listener` to be notified about changes in contexts in guest language application. This is supported in `TruffleInstrument.Env.getInstrumenter()` only. Parameters: `listener` `T`: a listener to receive the context events. `includeActiveContexts` `boolean`: whether or not this listener should be notified for present active contexts. Returns `EventBinding`: a handle for unregistering the listener. Cite: `com/oracle/truffle/api/instrumentation/Instrumenter.html#attachContextsListener(T,boolean)` ### attachThreadsListener(T, boolean) `public abstract EventBinding attachThreadsListener(T listener, boolean includeInitializedThreads)`. Since 0.30. Attach a `listener` to be notified about changes in threads in guest language application. This is supported in `TruffleInstrument.Env.getInstrumenter()` only. Parameters: `listener` `T`: a listener to receive the context events. `includeInitializedThreads` `boolean`: whether or not this listener should be notified for present initialized threads. Returns `EventBinding`: a handle for unregistering the listener. Cite: `com/oracle/truffle/api/instrumentation/Instrumenter.html#attachThreadsListener(T,boolean)` ### attachThreadsActivationListener(ThreadsActivationListener) `public abstract EventBinding attachThreadsActivationListener(ThreadsActivationListener listener)`. Since 20.3. Attach a `listener` to be notified about when a thread gets entered or left in guest language applications. The event notification starts after the listener registration is completed. This means that currently activated threads won't get a notification. It is also possible that `ThreadsActivationListener.onLeaveThread(TruffleContext)` is called without ever invoking `ThreadsActivationListener.onEnterThread(TruffleContext)`. Returns `EventBinding`: a handle for unregistering the listener. Cite: `com/oracle/truffle/api/instrumentation/Instrumenter.html#attachThreadsActivationListener(com.oracle.truffle.api.instrumentation.ThreadsActivationListener)` ### querySourceSections(SourceSectionFilter) `public final List querySourceSections(SourceSectionFilter filter)`. Since 0.18. Returns a filtered list of loaded `SourceSection` instances. Parameters: `filter` `SourceSectionFilter`: criterion for inclusion. Returns `List`: unmodifiable list of instances that pass the filter. Cite: `com/oracle/truffle/api/instrumentation/Instrumenter.html#querySourceSections(com.oracle.truffle.api.instrumentation.SourceSectionFilter)` ### queryTags(Node) `public abstract Set> queryTags(Node node)`. Since 0.12. Returns an unmodifiable [`Set`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/Set.html) of tag classes which where associated with this node. If the instrumenter is used as a `TruffleLanguage` then only nodes can be queried for tags that are associated with the current language otherwise an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. The given node must not be `null`. If the given node is not instrumentable, the given node is not yet adopted by a `RootNode` or the given tag was not `provided` by the language then always an empty [`Set`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/Set.html) is returned. Parameters: `node` `Node`: the node to query. Returns `Set>`: an unmodifiable [`Set`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/Set.html) of tag classes which where associated with this node. Cite: `com/oracle/truffle/api/instrumentation/Instrumenter.html#queryTags(com.oracle.truffle.api.nodes.Node)` ### lookupExecutionEventNode(Node, EventBinding) `public abstract ExecutionEventNode lookupExecutionEventNode(Node node, EventBinding binding)`. Since 19.0. Returns the execution event node that was inserted at the node's location given an event binding, if any. This is useful to identify and find information from nodes that were created for a specific instrumentation. Parameters: `node` `Node`: an instrumentable node specifying the location. `binding` `EventBinding`: the binding to lookup the execution nodes of. Returns `ExecutionEventNode`: the `ExecutionEventNode`, or `null`. Cite: `com/oracle/truffle/api/instrumentation/Instrumenter.html#lookupExecutionEventNode(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.instrumentation.EventBinding)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ LoadSourceEvent [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.15. ```java public final class LoadSourceEvent ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `LoadSourceEvent` Represents a source load event from a [`LoadSourceListener`](com/oracle/truffle/api/instrumentation/LoadSourceListener.md). Instances of [`LoadSourceEvent`](com/oracle/truffle/api/instrumentation/LoadSourceEvent.md) should be neither stored, cached nor hashed. The equality and hashing behavior is undefined. **See also** - [`LoadSourceListener`](com/oracle/truffle/api/instrumentation/LoadSourceListener.md) ## Methods ### getSource() `public Source getSource()`. Since 0.15. Returns the loaded source that caused this event. Cite: `com/oracle/truffle/api/instrumentation/LoadSourceEvent.html#getSource()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ LoadSourceListener [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.15. ```java public interface LoadSourceListener ``` A listener attached by an [`Instrumenter`](com/oracle/truffle/api/instrumentation/Instrumenter.md) to specific locations of a guest language program to listen to load source events. ## Methods ### onLoad(LoadSourceEvent) `void onLoad(LoadSourceEvent event)`. Since 0.15. Invoked whenever a new `source` is loaded. The order in which multiple source event listeners are notified matches the order they are `attached`. **Implementation Note:** Source load events are notified when the guest language implementation uses a new `source` by invoking `RootNode.getCallTarget()` with a root node that uses a new source in `Node.getSourceSection()`. It assumes that all nodes of an AST have the same `source` as their root. Parameters: `event` `LoadSourceEvent`: an event with context information. Cite: `com/oracle/truffle/api/instrumentation/LoadSourceListener.html#onLoad(com.oracle.truffle.api.instrumentation.LoadSourceEvent)` # ◆ LoadSourceSectionEvent [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.15. ```java public final class LoadSourceSectionEvent ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `LoadSourceSectionEvent` Represents a source section load event from a [`LoadSourceSectionListener`](com/oracle/truffle/api/instrumentation/LoadSourceSectionListener.md). Instances of [`LoadSourceSectionEvent`](com/oracle/truffle/api/instrumentation/LoadSourceSectionEvent.md) should be neither stored, cached nor hashed. The equality and hashing behavior is undefined. **See also** - [`LoadSourceSectionListener`](com/oracle/truffle/api/instrumentation/LoadSourceSectionListener.md) ## Methods ### getSourceSection() `public SourceSection getSourceSection()`. Since 0.15. Returns the loaded source section that caused this event. Cite: `com/oracle/truffle/api/instrumentation/LoadSourceSectionEvent.html#getSourceSection()` ### getNode() `public Node getNode()`. Since 0.15. Returns the instrumentable Truffle node that caused this event. Cite: `com/oracle/truffle/api/instrumentation/LoadSourceSectionEvent.html#getNode()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ LoadSourceSectionListener [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.15. ```java public interface LoadSourceSectionListener ``` A listener attached by an [`Instrumenter`](com/oracle/truffle/api/instrumentation/Instrumenter.md) to specific locations of a guest language program to listen to sources section load events. ## Methods ### onLoad(LoadSourceSectionEvent) `void onLoad(LoadSourceSectionEvent event)`. Since 0.15. Invoked whenever a new `source section` is loaded. The listener might be notified for one source section multiple times but never with the same instrumented node. The order in which multiple source section event listeners are notified matches the order they are `attached`. **Implementation Note:** Source load events are notified when the guest language implementation uses a new `source` by invoking `RootNode.getCallTarget()` with a root node that uses a new source in `Node.getSourceSection()`. It assumes that all nodes of an AST have the same `source` as their root. Parameters: `event` `LoadSourceSectionEvent`: an event with context information. Cite: `com/oracle/truffle/api/instrumentation/LoadSourceSectionListener.html#onLoad(com.oracle.truffle.api.instrumentation.LoadSourceSectionEvent)` # ◆ NearestSectionFilter [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 23.0. ```java public final class NearestSectionFilter ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `NearestSectionFilter` Add a filter for source sections that are nearest to the given source position, according to the guest language control flow. The selection of the nearest source location happens based on the provided [`SourceSectionFilter`](com/oracle/truffle/api/instrumentation/SourceSectionFilter.md) and this nearest section filter to the [`Instrumenter`](com/oracle/truffle/api/instrumentation/Instrumenter.md) create/attach methods. First location candidates are selected according to the [`SourceSectionFilter`](com/oracle/truffle/api/instrumentation/SourceSectionFilter.md). Based on this selection a nearest location is found using this [`NearestSectionFilter`](com/oracle/truffle/api/instrumentation/NearestSectionFilter.md). If new nearer locations are loaded then the listener/factory will be notified again. There is at most one nearest [`SourceSection`](com/oracle/truffle/api/source/SourceSection.md) at a time, therefore it is possible to detect updates by remembering and comparing the source section in the listener/factory. Start building the nearest filter by calling [`NearestSectionFilter.newBuilder(int, int)`](com/oracle/truffle/api/instrumentation/NearestSectionFilter.md#newBuilder%28int,int%29) and complete it by calling [`Builder.build()`](com/oracle/truffle/api/instrumentation/NearestSectionFilter.Builder.md#build%28%29). A use-case is a debugger breakpoint, for instance, where the exact line or column is not always precise and the location needs to be updated when new code is loaded. **See also** - [`NearestSectionFilter.newBuilder(int, int)`](com/oracle/truffle/api/instrumentation/NearestSectionFilter.md#newBuilder%28int,int%29) - [`Instrumenter.createLoadSourceSectionBinding(NearestSectionFilter, SourceSectionFilter, LoadSourceSectionListener, boolean)`](com/oracle/truffle/api/instrumentation/Instrumenter.md#createLoadSourceSectionBinding%28com.oracle.truffle.api.instrumentation.NearestSectionFilter,com.oracle.truffle.api.instrumentation.SourceSectionFilter,T,boolean%29) - [`Instrumenter.attachLoadSourceSectionListener(NearestSectionFilter, SourceSectionFilter, LoadSourceSectionListener, boolean)`](com/oracle/truffle/api/instrumentation/Instrumenter.md#attachLoadSourceSectionListener%28com.oracle.truffle.api.instrumentation.NearestSectionFilter,com.oracle.truffle.api.instrumentation.SourceSectionFilter,T,boolean%29) - [`Instrumenter.attachExecutionEventFactory(NearestSectionFilter, SourceSectionFilter, ExecutionEventNodeFactory)`](com/oracle/truffle/api/instrumentation/Instrumenter.md#attachExecutionEventFactory%28com.oracle.truffle.api.instrumentation.NearestSectionFilter,com.oracle.truffle.api.instrumentation.SourceSectionFilter,T%29) ## Nested types - [`NearestSectionFilter.Builder`](com/oracle/truffle/api/instrumentation/NearestSectionFilter.Builder.md) (class): Builder to configure NearestSectionFilter before creating its instance. ## Methods ### newBuilder(int, int) `public static NearestSectionFilter.Builder newBuilder(int line, int column)`. Since 23.0. Creates a new `NearestSectionFilter` using a `builder` pattern. The filter will find source sections that are nearest to the given source line and column. To create the final filter finalize it using `Builder.build()`. Parameters: `line` `int`: the line, greater than or equal to `1`. `column` `int`: the column, or \< 1 when column is unknown. Returns `NearestSectionFilter.Builder`: a new builder to create new `NearestSectionFilter` instances. Cite: `com/oracle/truffle/api/instrumentation/NearestSectionFilter.html#newBuilder(int,int)` ### toString() `public String toString()`. Since 23.0. Returns `String`: the filter attributes in a human readable form for debugging. Overrides `toString()`. Cite: `com/oracle/truffle/api/instrumentation/NearestSectionFilter.html#toString()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ NearestSectionFilter.Builder [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 23.0. Nested in [`NearestSectionFilter`](com/oracle/truffle/api/instrumentation/NearestSectionFilter.md). ```java public static final class NearestSectionFilter.Builder ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Builder` Builder to configure [`NearestSectionFilter`](com/oracle/truffle/api/instrumentation/NearestSectionFilter.md) before creating its instance. Specify various parameters by calling individual [`Builder`](com/oracle/truffle/api/instrumentation/NearestSectionFilter.Builder.md) methods. When done, call [`build()`](com/oracle/truffle/api/instrumentation/NearestSectionFilter.Builder.md#build%28%29). ## Methods ### anchorStart(boolean) `public NearestSectionFilter.Builder anchorStart(boolean start)`. Since 23.0. Specify the nearest anchor. By default, the start of source section is used. Parameters: `start` `boolean`: specify if we search for the nearest start or nearest end of the filtered source sections to the given location. `true` for the start and `false` for the end. Returns `NearestSectionFilter.Builder`: the builder to chain calls. Cite: `com/oracle/truffle/api/instrumentation/NearestSectionFilter.Builder.html#anchorStart(boolean)` ### tagIs(Class...) `public NearestSectionFilter.Builder tagIs(Class... tags)`. Since 23.0. Specify tags of the nearest source section. More accurate result might be provided when tags are not specified in the base source section filter by `SourceSectionFilter.Builder.tagIs(Class...)`, but here instead. Parameters: `tags` `Class...`: a set of tags, the nearest node needs to be tagged with at least one tag from this set. Returns `NearestSectionFilter.Builder`: the builder to chain calls. Cite: `com/oracle/truffle/api/instrumentation/NearestSectionFilter.Builder.html#tagIs(java.lang.Class...)` ### build() `public NearestSectionFilter build()`. Since 23.0. Finalizes and constructs the `NearestSectionFilter` instance. Returns `NearestSectionFilter`: the built filter. Cite: `com/oracle/truffle/api/instrumentation/NearestSectionFilter.Builder.html#build()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ ProbeNode [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.12. ```java public final class ProbeNode extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `ProbeNode` Represents an event sink for instrumentation events that is embedded in the AST using wrappers if needed. Instances of this class are provided by [`InstrumentableNode.createWrapper(ProbeNode)`](com/oracle/truffle/api/instrumentation/InstrumentableNode.md#createWrapper%28com.oracle.truffle.api.instrumentation.ProbeNode%29) to notify the instrumentation API about execution events. It is strongly recommended to use [`GenerateWrapper`](com/oracle/truffle/api/instrumentation/GenerateWrapper.md) to generate implementations of wrapper nodes. If needed to be done manually then the recommended implementation of an execute method looks as follows: ```java @Override public Object execute(VirtualFrame frame) { Object returnValue; for (;;) { boolean wasOnReturnExecuted = false; try { probeNode.onEnter(frame); returnValue = delegateNode.executeGeneric(frame); wasOnReturnExecuted = true; probeNode.onReturnValue(frame, returnValue); break; } catch (Throwable t) { Object result = probeNode.onReturnExceptionalOrUnwind(frame, t, wasOnReturnExecuted); if (result == ProbeNode.UNWIND_ACTION_REENTER) { continue; } else if (result != null) { returnValue = result; break; } throw t; } } return returnValue; } ``` ## Fields ### UNWIND_ACTION_REENTER `public static final Object UNWIND_ACTION_REENTER`. Since 0.31. A constant that performs reenter of the current node when returned from `ExecutionEventListener.onUnwind(EventContext, VirtualFrame, Object)` or `ExecutionEventNode.onUnwind(VirtualFrame, Object)`. Cite: `com/oracle/truffle/api/instrumentation/ProbeNode.html#UNWIND_ACTION_REENTER` ## Methods ### onEnter(VirtualFrame) `public void onEnter(VirtualFrame frame)`. Since 0.12. Should get invoked before the node is invoked. Parameters: `frame` `VirtualFrame`: the current frame of the execution. Cite: `com/oracle/truffle/api/instrumentation/ProbeNode.html#onEnter(com.oracle.truffle.api.frame.VirtualFrame)` ### onReturnValue(VirtualFrame, Object) `public void onReturnValue(VirtualFrame frame, Object result)`. Since 0.12. Should get invoked after the node is invoked successfully. Parameters: `frame` `VirtualFrame`: the current frame of the execution. `result` `Object`: the result value of the operation, must be an interop type (i.e. either implementing TruffleObject or be a primitive value), or `null`. Cite: `com/oracle/truffle/api/instrumentation/ProbeNode.html#onReturnValue(com.oracle.truffle.api.frame.VirtualFrame,java.lang.Object)` ### copy() `public Node copy()`. Since 0.31. Creates a shallow copy of this node. Returns `Node`: the new copy. Overrides `copy()`. Cite: `com/oracle/truffle/api/instrumentation/ProbeNode.html#copy()` ### onReturnExceptionalOrUnwind(VirtualFrame, Throwable, boolean) `public Object onReturnExceptionalOrUnwind(VirtualFrame frame, Throwable exception, boolean isReturnCalled)`. Since 0.31. Should get invoked if the node did not complete successfully and handle a possible unwind. When a non-`null` value is returned, a change of the execution path was requested by an `unwind`. Parameters: `frame` `VirtualFrame`: the current frame of the execution. `exception` `Throwable`: the exception that occurred during the execution. `isReturnCalled` `boolean`: `true` when `onReturnValue(VirtualFrame, Object)` was called already for this node's execution, `false` otherwise. This helps to assure correct pairing of enter/return notifications. Returns `Object`: `null` to proceed to throw of the exception, `UNWIND_ACTION_REENTER` to reenter the current node, or an interop value to return that value early from the current node (void nodes just return, ignoring the return value). Cite: `com/oracle/truffle/api/instrumentation/ProbeNode.html#onReturnExceptionalOrUnwind(com.oracle.truffle.api.frame.VirtualFrame,java.lang.Throwable,boolean)` ### onYield(VirtualFrame, Object) `public void onYield(VirtualFrame frame, Object result)`. Since 24.0. Should be invoked when the node yields execution. Use `GenerateWrapper.yieldExceptions()` when possible, to have `onYield()` called automatically. When the yielded execution is resumed, call `onResume(VirtualFrame)`, or use `GenerateWrapper.resumeMethodPrefix()`. Parameters: `frame` `VirtualFrame`: the current frame of the execution. Cite: `com/oracle/truffle/api/instrumentation/ProbeNode.html#onYield(com.oracle.truffle.api.frame.VirtualFrame,java.lang.Object)` ### onResume(VirtualFrame) `public void onResume(VirtualFrame frame)`. Since 24.0. Should be invoked when execution is resumed after a `yield`. Use `GenerateWrapper.resumeMethodPrefix()` when possible, to have this method called automatically by the wrapper node. Override `RootNode.isSameFrame(Frame, Frame)` if necessary, to be able to match the yielded and resumed executions. Parameters: `frame` `VirtualFrame`: the current frame of the execution. Cite: `com/oracle/truffle/api/instrumentation/ProbeNode.html#onResume(com.oracle.truffle.api.frame.VirtualFrame)` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # @ ProvidedTags [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.12. ```java @Retention(RUNTIME) @Target({TYPE}) public @interface ProvidedTags ``` Specifies a set of tags that are provided by a [`language`](com/oracle/truffle/api/TruffleLanguage.md) implementation. Tags are used by guest languages to indicate that a [`node`](com/oracle/truffle/api/nodes/Node.md) is a member of a certain category of nodes. For example a debugger [`instrument`](com/oracle/truffle/api/instrumentation/TruffleInstrument.md) might require a guest language to tag all nodes as halt locations that should be considered as such. ## Elements ### value() `Class[] value()`. Since 0.12. Returns `Class[]`: the set of tags that are provided by the `language` implementation. See also: `class documentation for further details`. Cite: `com/oracle/truffle/api/instrumentation/ProvidedTags.html#value()` # ◆ SourceFilter [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.32. ```java public final class SourceFilter ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `SourceFilter` A source filter represents an expression for a subset of guest language sources that are used in an Truffle interpreter. Start building event filters by calling [`SourceFilter.newBuilder()`](com/oracle/truffle/api/instrumentation/SourceFilter.md#newBuilder%28%29) and complete them by calling [`Builder.build()`](com/oracle/truffle/api/instrumentation/SourceFilter.Builder.md#build%28%29). **See also** - [`SourceFilter.newBuilder()`](com/oracle/truffle/api/instrumentation/SourceFilter.md#newBuilder%28%29) - [`Instrumenter.attachLoadSourceListener(SourceFilter, LoadSourceListener, boolean)`](com/oracle/truffle/api/instrumentation/Instrumenter.md#attachLoadSourceListener%28com.oracle.truffle.api.instrumentation.SourceFilter,T,boolean%29) ## Nested types - [`SourceFilter.Builder`](com/oracle/truffle/api/instrumentation/SourceFilter.Builder.md) (class): Configure your own SourceFilter before creating its instance. ## Fields ### ANY `public static final SourceFilter ANY`. Since 0.32. A filter that matches any source. Cite: `com/oracle/truffle/api/instrumentation/SourceFilter.html#ANY` ## Methods ### newBuilder() `public static SourceFilter.Builder newBuilder()`. Since 0.32. Creates a new `SourceFilter` expression using a `builder` pattern. Individual builder statements are interpreted as conjunctions (AND) while multiple parameters for individual filter expressions are treated as disjunctions (OR). To create the final filter finalize the expression using `Builder.build()`. Returns `SourceFilter.Builder`: a new builder to create new `SourceFilter` instances. See also: `Builder.sourceIs(Source...)`, `Builder.sourceIs(Predicate)`, `Builder.languageIs(String...)`, `Builder.includeInternal(boolean)`, `Builder.build()`. Cite: `com/oracle/truffle/api/instrumentation/SourceFilter.html#newBuilder()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ SourceFilter.Builder [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.32. Nested in [`SourceFilter`](com/oracle/truffle/api/instrumentation/SourceFilter.md). ```java public final class SourceFilter.Builder ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Builder` Configure your own [`SourceFilter`](com/oracle/truffle/api/instrumentation/SourceFilter.md) before creating its instance. Specify various parameters by calling individual [`Builder`](com/oracle/truffle/api/instrumentation/SourceFilter.Builder.md) methods. When done, call [`build()`](com/oracle/truffle/api/instrumentation/SourceFilter.Builder.md#build%28%29). ## Methods ### sourceIs(Source...) `public SourceFilter.Builder sourceIs(Source... source)`. Since 0.32. Add a filter for one of the given sources. Cite: `com/oracle/truffle/api/instrumentation/SourceFilter.Builder.html#sourceIs(com.oracle.truffle.api.source.Source...)` ### sourceIs(Predicate) `public SourceFilter.Builder sourceIs(Predicate predicate)`. Since 0.32. Adds custom predicate to filter inclusion of `sources`. The predicate must always return the same result for a source instance otherwise the behavior is undefined. The predicate should be able run on multiple threads at the same time. Parameters: `predicate` `Predicate`: a test for source inclusion. Cite: `com/oracle/truffle/api/instrumentation/SourceFilter.Builder.html#sourceIs(java.util.function.Predicate)` ### languageIs(String...) `public SourceFilter.Builder languageIs(String... languageIds)`. Since 0.32. Add a filter for all sources that specify one of the given `language ID`. Parameters: `languageIds` `String...`: matches one of the given language ID. Returns `SourceFilter.Builder`: the builder to chain calls. Cite: `com/oracle/truffle/api/instrumentation/SourceFilter.Builder.html#languageIs(java.lang.String...)` ### includeInternal(boolean) `public SourceFilter.Builder includeInternal(boolean internal)`. Since 0.32. Add a filter that includes or excludes `internal sources`. By default, internal sources are included, call with `false` to exclude internal code from instrumentation. Returns `SourceFilter.Builder`: the builder to chain calls. Cite: `com/oracle/truffle/api/instrumentation/SourceFilter.Builder.html#includeInternal(boolean)` ### build() `public SourceFilter build()`. Since 0.32. Finalizes and constructs the `SourceFilter` instance. Returns `SourceFilter`: the built filter expression. Cite: `com/oracle/truffle/api/instrumentation/SourceFilter.Builder.html#build()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ SourceSectionFilter [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.12. ```java public final class SourceSectionFilter ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `SourceSectionFilter` A source section filter represents an expression for a subset of tagged source sections that are used in an Truffle interpreter. Start building event filters by calling [`SourceSectionFilter.newBuilder()`](com/oracle/truffle/api/instrumentation/SourceSectionFilter.md#newBuilder%28%29) and complete them by calling [`Builder.build()`](com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.md#build%28%29). **See also** - [`SourceSectionFilter.newBuilder()`](com/oracle/truffle/api/instrumentation/SourceSectionFilter.md#newBuilder%28%29) - [`Instrumenter.attachExecutionEventFactory(SourceSectionFilter, ExecutionEventNodeFactory)`](com/oracle/truffle/api/instrumentation/Instrumenter.md#attachExecutionEventFactory%28com.oracle.truffle.api.instrumentation.SourceSectionFilter,T%29) - [`Instrumenter.attachExecutionEventListener(SourceSectionFilter, ExecutionEventListener)`](com/oracle/truffle/api/instrumentation/Instrumenter.md#attachExecutionEventListener%28com.oracle.truffle.api.instrumentation.SourceSectionFilter,T%29) ## Nested types - [`SourceSectionFilter.Builder`](com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.md) (class): Configure your own SourceSectionFilter before creating its instance. - [`SourceSectionFilter.IndexRange`](com/oracle/truffle/api/instrumentation/SourceSectionFilter.IndexRange.md) (class): Represents a range between two indices within a source section filter. - [`SourceSectionFilter.SourcePredicate`](com/oracle/truffle/api/instrumentation/SourceSectionFilter.SourcePredicate.md) (interface): Represents a predicate for source objects. ## Fields ### ANY `public static final SourceSectionFilter ANY`. Since 0.18. A filter that matches everything. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.html#ANY` ## Methods ### newBuilder() `public static SourceSectionFilter.Builder newBuilder()`. Since 0.12. Creates a new `SourceSectionFilter` expression using a `builder` pattern. Individual builder statements are interpreted as conjunctions (AND) while multiple parameters for individual filter expressions are treated as disjunctions (OR). To create the final filter finalize the expression using `Builder.build()`. Returns `SourceSectionFilter.Builder`: a new builder to create new `SourceSectionFilter` instances. See also: `Builder.sourceIs(Source...)`, `Builder.mimeTypeIs(String...)`, `Builder.tagIs(Class...)`, `Builder.tagIsNot(Class...)`, `Builder.sourceSectionEquals(SourceSection...)`, `Builder.indexIn(int, int)`, `Builder.lineIn(int, int)`, `Builder.lineIs(int)`, `Builder.rootNameIs(Predicate)`, `Builder.build()`. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.html#newBuilder()` ### toString() `public String toString()`. Since 0.12. Returns `String`: the filter expressions in a human readable form for debugging. Overrides `toString()`. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.html#toString()` ### includes(Node) `public boolean includes(Node node)`. Since 19.0.. Checks if the filter includes the given node, i.e. do the properties of the node's source section meet the conditions set by the filter. Parameters: `node` `Node`: The node to check. Returns `boolean`: True of the filter includes the node, false otherwise. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.html#includes(com.oracle.truffle.api.nodes.Node)` ### includes(RootNode, SourceSection, Set) `public boolean includes(RootNode rootNode, SourceSection nodeSourceSection, Set> originalTags)`. Since 21.3.0. Checks if the filter includes the given root node, i.e. do the properties of the given source section meet the conditions set by the filter without an instrumented node. Parameters: `rootNode` `RootNode`: The root node to be checked against the filter. `nodeSourceSection` `SourceSection`: The source section of the node to be checked against the filter. Returns `boolean`: `true` if the filter includes the source section and node. `false` otherwise. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.html#includes(com.oracle.truffle.api.nodes.RootNode,com.oracle.truffle.api.source.SourceSection,java.util.Set)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ SourceSectionFilter.Builder [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.12. Nested in [`SourceSectionFilter`](com/oracle/truffle/api/instrumentation/SourceSectionFilter.md). ```java public final class SourceSectionFilter.Builder ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Builder` Configure your own [`SourceSectionFilter`](com/oracle/truffle/api/instrumentation/SourceSectionFilter.md) before creating its instance. Specify various parameters by calling individual [`Builder`](com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.md) methods. When done, call [`build()`](com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.md#build%28%29). ## Methods ### sourceFilter(SourceFilter) `public SourceSectionFilter.Builder sourceFilter(SourceFilter sourceFilter)`. Since 0.32. Add a source filter. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.html#sourceFilter(com.oracle.truffle.api.instrumentation.SourceFilter)` ### sourceIs(Source...) `public SourceSectionFilter.Builder sourceIs(Source... source)`. Since 0.12. Add a filter for all source sections that reference one of the given sources. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.html#sourceIs(com.oracle.truffle.api.source.Source...)` ### sourceIs(SourceSectionFilter.SourcePredicate) `public SourceSectionFilter.Builder sourceIs(SourceSectionFilter.SourcePredicate predicate)`. Since 0.17. Adds custom predicate to filter inclusion of `sources`. The predicate must always return the same result for a source instance otherwise the behavior is undefined. The predicate should be able run on multiple threads at the same time. Parameters: `predicate` `SourceSectionFilter.SourcePredicate`: a test for inclusion. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.html#sourceIs(com.oracle.truffle.api.instrumentation.SourceSectionFilter.SourcePredicate)` ### rootNameIs(Predicate) `public SourceSectionFilter.Builder rootNameIs(Predicate predicate)`. Since 0.27. Adds custom predicate to filter inclusion for `root names`. The root name might be `null` if not provided by the guest language. If the language returns a changing value it is unspecified which root name is going to be matched. The predicate must always return the same result for a [`String`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html) instance otherwise the behavior is undefined. The predicate should be able run on multiple threads at the same time. Parameters: `predicate` `Predicate`: a test for inclusion. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.html#rootNameIs(java.util.function.Predicate)` ### mimeTypeIs(String...) `public SourceSectionFilter.Builder mimeTypeIs(String... mimeTypes)`. Since 0.12. Add a filter for all source sections that declare one of the given mime-types. Mime-types which are compared must match exactly one of the mime-types specified by the target guest language. Parameters: `mimeTypes` `String...`: matches one of the given mime types. Returns `SourceSectionFilter.Builder`: the builder to chain calls. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.html#mimeTypeIs(java.lang.String...)` ### tagIs(Class...) `public SourceSectionFilter.Builder tagIs(Class... tags)`. Since 0.12. Add a filter for all source sections that are tagged with one of the given tags. Parameters: `tags` `Class...`: matches one of the given tags. Returns `SourceSectionFilter.Builder`: the builder to chain calls. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.html#tagIs(java.lang.Class...)` ### tagIsNot(Class...) `public SourceSectionFilter.Builder tagIsNot(Class... tags)`. Since 0.12. Add a filter for all source sections that are not tagged with one of the given tags. Parameters: `tags` `Class...`: matches not one of the given tags. Returns `SourceSectionFilter.Builder`: the builder to chain calls. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.html#tagIsNot(java.lang.Class...)` ### sourceSectionEquals(SourceSection...) `public SourceSectionFilter.Builder sourceSectionEquals(SourceSection... section)`. Since 0.12. Add a filter for all source sections that equal one of the given source sections. Parameters: `section` `SourceSection...`: matches one of the given source sections. Returns `SourceSectionFilter.Builder`: the builder to chain calls. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.html#sourceSectionEquals(com.oracle.truffle.api.source.SourceSection...)` ### sourceSectionAvailableOnly(boolean) `public SourceSectionFilter.Builder sourceSectionAvailableOnly(boolean availableOnly)`. Since 24.1. Add a filter for available source sections. By default all locations with or without available source sections are provided. If this flag is set to `true` then `null` and not `available` source sections are filtered out. Parameters: `availableOnly` `boolean`: `true` to include only non-null and `available` source sections, `false` to include all. Returns `SourceSectionFilter.Builder`: the builder to chain calls. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.html#sourceSectionAvailableOnly(boolean)` ### rootSourceSectionEquals(SourceSection...) `public SourceSectionFilter.Builder rootSourceSectionEquals(SourceSection... section)`. Since 0.12. Add a filter for all root source sections that equal one of the given source sections. All descendant source sections of a matching root source section are included in the filter. This can mean in the dynamic language domain that all nodes of a function for which the root source section matches the given source section is instrumented but its inner functions and its nodes are not instrumented. Parameters: `section` `SourceSection...`: matches one of the given root source sections. Returns `SourceSectionFilter.Builder`: the builder to chain calls. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.html#rootSourceSectionEquals(com.oracle.truffle.api.source.SourceSection...)` ### indexNotIn(SourceSectionFilter.IndexRange...) `public SourceSectionFilter.Builder indexNotIn(SourceSectionFilter.IndexRange... ranges)`. Since 0.12. Add a filter for all source sections which indices are not contained in one of the given index ranges. Parameters: `ranges` `SourceSectionFilter.IndexRange...`: matches indices that are not contained in one of the given index ranges. Returns `SourceSectionFilter.Builder`: the builder to chain calls. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.html#indexNotIn(com.oracle.truffle.api.instrumentation.SourceSectionFilter.IndexRange...)` ### indexIn(SourceSectionFilter.IndexRange...) `public SourceSectionFilter.Builder indexIn(SourceSectionFilter.IndexRange... ranges)`. Since 0.12. Add a filter for all source sections which indices are contained in one of the given index ranges. Parameters: `ranges` `SourceSectionFilter.IndexRange...`: matches indices that are contained in one of the given index ranges. Returns `SourceSectionFilter.Builder`: the builder to chain calls. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.html#indexIn(com.oracle.truffle.api.instrumentation.SourceSectionFilter.IndexRange...)` ### indexIn(int, int) `public SourceSectionFilter.Builder indexIn(int startIndex, int length)`. Since 0.12. Add a filter for all source sections where the index is inside a startIndex (inclusive) plus a given length (exclusive). Parameters: `startIndex` `int`: the start index (inclusive). `length` `int`: the number of matched characters. Returns `SourceSectionFilter.Builder`: the builder to chain calls. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.html#indexIn(int,int)` ### lineIn(SourceSectionFilter.IndexRange...) `public SourceSectionFilter.Builder lineIn(SourceSectionFilter.IndexRange... ranges)`. Since 0.12. Add a filter for all source sections where lines are contained in one of the given index ranges. Line indices must be greater than or equal to `1`. Parameters: `ranges` `SourceSectionFilter.IndexRange...`: matches lines that are contained in one of the given index ranges. Returns `SourceSectionFilter.Builder`: the builder to chain calls. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.html#lineIn(com.oracle.truffle.api.instrumentation.SourceSectionFilter.IndexRange...)` ### lineIn(int, int) `public SourceSectionFilter.Builder lineIn(int startLine, int length)`. Since 0.12. Add a filter for all source sections where the line is inside a startLine (first index inclusive) plus a given length (last index exclusive). Parameters: `startLine` `int`: the start line (inclusive). `length` `int`: the number of matched lines. Returns `SourceSectionFilter.Builder`: the builder to chain calls. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.html#lineIn(int,int)` ### lineNotIn(SourceSectionFilter.IndexRange...) `public SourceSectionFilter.Builder lineNotIn(SourceSectionFilter.IndexRange... ranges)`. Since 0.12. Add a filter for all source sections where lines are not contained in one of the given index ranges. Line indices must be greater than or equal to `1`. Parameters: `ranges` `SourceSectionFilter.IndexRange...`: matches lines that are not contained in one of the given index ranges. Returns `SourceSectionFilter.Builder`: the builder to chain calls. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.html#lineNotIn(com.oracle.truffle.api.instrumentation.SourceSectionFilter.IndexRange...)` ### lineStartsIn(SourceSectionFilter.IndexRange...) `public SourceSectionFilter.Builder lineStartsIn(SourceSectionFilter.IndexRange... ranges)`. Since 0.12. Add a filter for all source sections where the line starts in one of the given index ranges. Line indices must be greater than or equal to `1`. Parameters: `ranges` `SourceSectionFilter.IndexRange...`: matches lines that start in one of the given index ranges. Returns `SourceSectionFilter.Builder`: the builder to chain calls. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.html#lineStartsIn(com.oracle.truffle.api.instrumentation.SourceSectionFilter.IndexRange...)` ### lineEndsIn(SourceSectionFilter.IndexRange...) `public SourceSectionFilter.Builder lineEndsIn(SourceSectionFilter.IndexRange... ranges)`. Since 0.12. Add a filter for all source sections where the line ends in one of the given index ranges. Line indices must be greater than or equal to `1`. Parameters: `ranges` `SourceSectionFilter.IndexRange...`: matches lines that end in one of the given index ranges. Returns `SourceSectionFilter.Builder`: the builder to chain calls. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.html#lineEndsIn(com.oracle.truffle.api.instrumentation.SourceSectionFilter.IndexRange...)` ### columnIn(SourceSectionFilter.IndexRange...) `public SourceSectionFilter.Builder columnIn(SourceSectionFilter.IndexRange... ranges)`. Since 0.33. Add a filter for all source sections where the columns are contained in one of the given index ranges. Column indices must be greater than or equal to `1`. Parameters: `ranges` `SourceSectionFilter.IndexRange...`: matches columns that are contained in one of the given index ranges. Returns `SourceSectionFilter.Builder`: the builder to chain calls. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.html#columnIn(com.oracle.truffle.api.instrumentation.SourceSectionFilter.IndexRange...)` ### columnIn(int, int) `public SourceSectionFilter.Builder columnIn(int startColumn, int length)`. Since 0.33. Add a filter for all source sections where the column is inside a startColumn (first index inclusive) plus a given length (last index exclusive). Parameters: `startColumn` `int`: the start column (inclusive). `length` `int`: the number of matched columns. Returns `SourceSectionFilter.Builder`: the builder to chain calls. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.html#columnIn(int,int)` ### columnNotIn(SourceSectionFilter.IndexRange...) `public SourceSectionFilter.Builder columnNotIn(SourceSectionFilter.IndexRange... ranges)`. Since 0.33. Add a filter for all source sections where columns are not contained in one of the given index ranges. Column indices must be greater than or equal to `1`. Parameters: `ranges` `SourceSectionFilter.IndexRange...`: matches columns that are not contained in one of the given index ranges. Returns `SourceSectionFilter.Builder`: the builder to chain calls. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.html#columnNotIn(com.oracle.truffle.api.instrumentation.SourceSectionFilter.IndexRange...)` ### columnStartsIn(SourceSectionFilter.IndexRange...) `public SourceSectionFilter.Builder columnStartsIn(SourceSectionFilter.IndexRange... ranges)`. Since 0.33. Add a filter for all source sections where the column starts in one of the given index ranges. Column indices must be greater than or equal to `1`. Parameters: `ranges` `SourceSectionFilter.IndexRange...`: matches columns that start in one of the given index ranges. Returns `SourceSectionFilter.Builder`: the builder to chain calls. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.html#columnStartsIn(com.oracle.truffle.api.instrumentation.SourceSectionFilter.IndexRange...)` ### columnEndsIn(SourceSectionFilter.IndexRange...) `public SourceSectionFilter.Builder columnEndsIn(SourceSectionFilter.IndexRange... ranges)`. Since 0.33. Add a filter for all sources sections where the column ends in one of the given index ranges. Column indices must be greater than or equal to `1`. Parameters: `ranges` `SourceSectionFilter.IndexRange...`: matches columns that end in one of the given index ranges. Returns `SourceSectionFilter.Builder`: the builder to chain calls. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.html#columnEndsIn(com.oracle.truffle.api.instrumentation.SourceSectionFilter.IndexRange...)` ### lineIs(int) `public SourceSectionFilter.Builder lineIs(int line)`. Since 0.12. Add a filter for all sources sections where the line is exactly the given line. Line indices must be greater than or equal to `1`. \*. Parameters: `line` `int`: the line to be matched. Returns `SourceSectionFilter.Builder`: the builder to chain calls. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.html#lineIs(int)` ### includeInternal(boolean) `public SourceSectionFilter.Builder includeInternal(boolean internal)`. Since 0.29. Add a filter that includes or excludes `internal root nodes`. By default, internal roots are included, call with `false` to exclude internal code from instrumentation. Returns `SourceSectionFilter.Builder`: the builder to chain calls. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.html#includeInternal(boolean)` ### and(SourceSectionFilter) `public SourceSectionFilter.Builder and(SourceSectionFilter filter)`. Since 0.30. Adds all the filters defined in the given `filter`. Parameters: `filter` `SourceSectionFilter`: an existing filter to be included. Returns `SourceSectionFilter.Builder`: the builder to chain calls. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.html#and(com.oracle.truffle.api.instrumentation.SourceSectionFilter)` ### build() `public SourceSectionFilter build()`. Since 0.12. Finalizes and constructs the `SourceSectionFilter` instance. Returns `SourceSectionFilter`: the built filter expression. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.Builder.html#build()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ SourceSectionFilter.IndexRange [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.12. Nested in [`SourceSectionFilter`](com/oracle/truffle/api/instrumentation/SourceSectionFilter.md). ```java public static final class SourceSectionFilter.IndexRange ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `IndexRange` Represents a range between two indices within a [`source section filter`](com/oracle/truffle/api/instrumentation/SourceSectionFilter.md). Instances are immutable. **See also** - [`SourceSectionFilter`](com/oracle/truffle/api/instrumentation/SourceSectionFilter.md) - [`between(int, int)`](com/oracle/truffle/api/instrumentation/SourceSectionFilter.IndexRange.md#between%28int,int%29) - [`byLength(int, int)`](com/oracle/truffle/api/instrumentation/SourceSectionFilter.IndexRange.md#byLength%28int,int%29) ## Methods ### between(int, int) `public static SourceSectionFilter.IndexRange between(int startIndex, int endIndex)`. Since 0.12. Constructs a new index range between one a first index inclusive and a second index exclusive. Parameters must comply `startIndex >= 0` and `startIndex <= endIndex`. Parameters: `startIndex` `int`: the start index (inclusive). `endIndex` `int`: the end index (exclusive). Returns `SourceSectionFilter.IndexRange`: a new index range. Throws: `IllegalArgumentException` (unchecked): if parameter invariants are violated. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.IndexRange.html#between(int,int)` ### byLength(int, int) `public static SourceSectionFilter.IndexRange byLength(int startIndex, int length)`. Since 0.12. Constructs a new index range with a given first index inclusive and a given length. Parameters must comply `startIndex >= 0` and `length >= 0`. Parameters: `startIndex` `int`: the start index (inclusive). `length` `int`: the length of the range. Returns `SourceSectionFilter.IndexRange`: a new index range. Throws: `IllegalArgumentException` (unchecked): if parameter invariants are violated. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.IndexRange.html#byLength(int,int)` ### toString() `public String toString()`. Since 0.12. Returns `String`: a human readable version of the index range. Overrides `toString()`. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.IndexRange.html#toString()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ SourceSectionFilter.SourcePredicate [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.17. Nested in [`SourceSectionFilter`](com/oracle/truffle/api/instrumentation/SourceSectionFilter.md). ```java public interface SourceSectionFilter.SourcePredicate extends Predicate ``` Extends: [`Predicate`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/Predicate.html)`<`[`Source`](com/oracle/truffle/api/source/Source.md)`>` Represents a predicate for source objects. ## Methods ### test(Source) `boolean test(Source source)`. Since 0.17. Returns `true` if the given source should be tested positive and `false` if the sources should be filtered. Parameters: `source` `Source`: the source object to filter. Overrides `test(T)`. Cite: `com/oracle/truffle/api/instrumentation/SourceSectionFilter.SourcePredicate.html#test(com.oracle.truffle.api.source.Source)` ## Inherited members - From interface [`Predicate`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/Predicate.html): [`and`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/Predicate.html#and%28java.util.function.Predicate%29), [`negate`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/Predicate.html#negate%28%29), [`or`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/Predicate.html#or%28java.util.function.Predicate%29) # ◆ StandardTags [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.12. ```java public final class StandardTags ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `StandardTags` Set of standard tags usable by language agnostic tools. Language should [`provide`](com/oracle/truffle/api/instrumentation/ProvidedTags.md) an implementation of these tags in order to support a wide variety of tools. ## Nested types - [`StandardTags.CallTag`](com/oracle/truffle/api/instrumentation/StandardTags.CallTag.md) (class): Marks program locations that represent a call to other guest language functions, methods or closures. - [`StandardTags.ExpressionTag`](com/oracle/truffle/api/instrumentation/StandardTags.ExpressionTag.md) (class): Marks program locations as to be considered expressions of the languages. - [`StandardTags.ReadVariableTag`](com/oracle/truffle/api/instrumentation/StandardTags.ReadVariableTag.md) (class): Marks program locations to be considered as reads of variables of the languages. - [`StandardTags.RootBodyTag`](com/oracle/truffle/api/instrumentation/StandardTags.RootBodyTag.md) (class): Marks program locations as bodies of a function, method or closure. - [`StandardTags.RootTag`](com/oracle/truffle/api/instrumentation/StandardTags.RootTag.md) (class): Marks program locations as root of a function, method or closure. - [`StandardTags.StatementTag`](com/oracle/truffle/api/instrumentation/StandardTags.StatementTag.md) (class): Marks program locations that represent a statement of a language. - [`StandardTags.TryBlockTag`](com/oracle/truffle/api/instrumentation/StandardTags.TryBlockTag.md) (class): Marks program locations to be considered as try blocks, that are followed by catch. - [`StandardTags.WriteVariableTag`](com/oracle/truffle/api/instrumentation/StandardTags.WriteVariableTag.md) (class): Marks program locations to be considered as writes of variables of the languages. ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ StandardTags.CallTag [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.12. Nested in [`StandardTags`](com/oracle/truffle/api/instrumentation/StandardTags.md). ```java public static final class StandardTags.CallTag extends Tag ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Tag`](com/oracle/truffle/api/instrumentation/Tag.md) > `CallTag` Marks program locations that represent a call to other guest language functions, methods or closures. Use case descriptions: - **Debugger:** Marks program locations where *returning* or *stepping out* from a method/procedure/closure call should halt. The debugger will halt at the code location that has just executed the call that returned. The CallTag uses the [`identifier`](com/oracle/truffle/api/instrumentation/Tag.Identifier.md) `"CALL"`. A node tagged with [`CallTag`](com/oracle/truffle/api/instrumentation/StandardTags.CallTag.md) must provide a [`source section`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), if its root node provides a source section. If the a node tagged with [`call`](com/oracle/truffle/api/instrumentation/StandardTags.CallTag.md) returns a non `null` value then it must be an interop value. There are assertions in place verifying this when Java assertions are enabled (-ea). ## Inherited members - From class [`Tag`](com/oracle/truffle/api/instrumentation/Tag.md): [`findProvidedTag`](com/oracle/truffle/api/instrumentation/Tag.md#findProvidedTag%28com.oracle.truffle.api.nodes.LanguageInfo,java.lang.String%29), [`getIdentifier`](com/oracle/truffle/api/instrumentation/Tag.md#getIdentifier%28java.lang.Class%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ StandardTags.ExpressionTag [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.33. Nested in [`StandardTags`](com/oracle/truffle/api/instrumentation/StandardTags.md). ```java public static final class StandardTags.ExpressionTag extends Tag ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Tag`](com/oracle/truffle/api/instrumentation/Tag.md) > `ExpressionTag` Marks program locations as to be considered expressions of the languages. Common examples for expressions are: - Literal expressions - Arithmetic expressions like addition and multiplication - Condition expressions - Function calls - Array, Object or variable reads and writes - Instantiations Use case descriptions: - **Coverage:** To compute expression coverage. - **Debugger:** Fine grained debugging of expressions. It is optional to implement the expression tag to support debuggers. The ExpressionTag uses the [`identifier`](com/oracle/truffle/api/instrumentation/Tag.Identifier.md) `"EXPRESSION"`. A node tagged with [`ExpressionTag`](com/oracle/truffle/api/instrumentation/StandardTags.ExpressionTag.md) must provide a [`source section`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), if its root node provides a source section. \* If the a node tagged with [`expression`](com/oracle/truffle/api/instrumentation/StandardTags.ExpressionTag.md) returns a non `null` value then it must be an interop value. There are assertions in place verifying this when Java assertions are enabled (-ea). ## Inherited members - From class [`Tag`](com/oracle/truffle/api/instrumentation/Tag.md): [`findProvidedTag`](com/oracle/truffle/api/instrumentation/Tag.md#findProvidedTag%28com.oracle.truffle.api.nodes.LanguageInfo,java.lang.String%29), [`getIdentifier`](com/oracle/truffle/api/instrumentation/Tag.md#getIdentifier%28java.lang.Class%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ StandardTags.ReadVariableTag [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 20.0.0. Nested in [`StandardTags`](com/oracle/truffle/api/instrumentation/StandardTags.md). ```java public static final class StandardTags.ReadVariableTag extends Tag ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Tag`](com/oracle/truffle/api/instrumentation/Tag.md) > `ReadVariableTag` Marks program locations to be considered as reads of variables of the languages. Use case descriptions: - **Language Server Protocol:** Marks every read of a variable to support the *documentHighlight*, *hover*, *definition* and *references* requests. To determine the name of the variable, it is required that a node tagged with [`ReadVariableTag`](com/oracle/truffle/api/instrumentation/StandardTags.ReadVariableTag.md) also provides a [`node object`](com/oracle/truffle/api/instrumentation/InstrumentableNode.md#getNodeObject%28%29) that has [`ReadVariableTag.NAME`](com/oracle/truffle/api/instrumentation/StandardTags.ReadVariableTag.md#NAME) property. The value of that property is either: - a String name of the variable (in that case the node's [`source section`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29) is considered as the variable's source section), - an object that provides name and [`SourceSection`](com/oracle/truffle/api/source/SourceSection.md) via [`InteropLibrary.asString(Object)`](com/oracle/truffle/api/interop/InteropLibrary.md#asString%28java.lang.Object%29) and [`InteropLibrary.getSourceLocation(Object)`](com/oracle/truffle/api/interop/InteropLibrary.md#getSourceLocation%28java.lang.Object%29) respectively, - an array of objects when multiple variables are being read, where each array element provides name and [`SourceSection`](com/oracle/truffle/api/source/SourceSection.md) as specified above. Furthermore, nodes tagged with [`ReadVariableTag`](com/oracle/truffle/api/instrumentation/StandardTags.ReadVariableTag.md) have to provide a [`source section`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29). ## Fields ### NAME `public static final String NAME`. Since 20.0.0. Property of the node object that contains name of the variable. Constant value: `"readVariableName"`. Cite: `com/oracle/truffle/api/instrumentation/StandardTags.ReadVariableTag.html#NAME` ## Inherited members - From class [`Tag`](com/oracle/truffle/api/instrumentation/Tag.md): [`findProvidedTag`](com/oracle/truffle/api/instrumentation/Tag.md#findProvidedTag%28com.oracle.truffle.api.nodes.LanguageInfo,java.lang.String%29), [`getIdentifier`](com/oracle/truffle/api/instrumentation/Tag.md#getIdentifier%28java.lang.Class%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ StandardTags.RootBodyTag [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 19.2.0. Nested in [`StandardTags`](com/oracle/truffle/api/instrumentation/StandardTags.md). ```java public static final class StandardTags.RootBodyTag extends Tag ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Tag`](com/oracle/truffle/api/instrumentation/Tag.md) > `RootBodyTag` Marks program locations as bodies of a function, method or closure. The root prolog and epilog is not a part of this node, what makes a difference from [`RootTag`](com/oracle/truffle/api/instrumentation/StandardTags.RootTag.md). In particular, when the implementation copies [`Frame.getArguments()`](com/oracle/truffle/api/frame/Frame.md#getArguments%28%29) into frame slots, it should do it before this node for the instrumentation to work correctly. Use case descriptions: - **Profiler:** Marks body of every root that should be profiled and where local variables are initialized and ready to be retrieved. The RootBodyTag uses the [`identifier`](com/oracle/truffle/api/instrumentation/Tag.Identifier.md) `"ROOT_BODY"`. A node tagged with [`RootBodyTag`](com/oracle/truffle/api/instrumentation/StandardTags.RootBodyTag.md) must provide a [`source section`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29) , if its root node provides a source section. If the a node tagged with [`root body`](com/oracle/truffle/api/instrumentation/StandardTags.RootBodyTag.md) returns a non `null` value then it must be an interop value. There are assertions in place verifying this when Java assertions are enabled (-ea). ## Inherited members - From class [`Tag`](com/oracle/truffle/api/instrumentation/Tag.md): [`findProvidedTag`](com/oracle/truffle/api/instrumentation/Tag.md#findProvidedTag%28com.oracle.truffle.api.nodes.LanguageInfo,java.lang.String%29), [`getIdentifier`](com/oracle/truffle/api/instrumentation/Tag.md#getIdentifier%28java.lang.Class%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ StandardTags.RootTag [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.12. Nested in [`StandardTags`](com/oracle/truffle/api/instrumentation/StandardTags.md). ```java public static final class StandardTags.RootTag extends Tag ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Tag`](com/oracle/truffle/api/instrumentation/Tag.md) > `RootTag` Marks program locations as root of a function, method or closure. The root prolog should be executed by this node. In particular, when the implementation copies [`Frame.getArguments()`](com/oracle/truffle/api/frame/Frame.md#getArguments%28%29) into frame slots, it should do it here for the instrumentation to work correctly. As a result, local scope might be incomplete for instruments, as the prolog does not run before this node is entered and epilog may do destructions before this node is exited. Use case descriptions: - **Debugger:** Use this tag to unwind frames. The RootTag uses the [`identifier`](com/oracle/truffle/api/instrumentation/Tag.Identifier.md) `"ROOT"`. A node tagged with [`RootTag`](com/oracle/truffle/api/instrumentation/StandardTags.RootTag.md) must provide a [`source section`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), if its root node provides a source section. If the a node tagged with [`root`](com/oracle/truffle/api/instrumentation/StandardTags.RootTag.md) returns a non `null` value then it must be an interop value. There are assertions in place verifying this when Java assertions are enabled (-ea). ## Inherited members - From class [`Tag`](com/oracle/truffle/api/instrumentation/Tag.md): [`findProvidedTag`](com/oracle/truffle/api/instrumentation/Tag.md#findProvidedTag%28com.oracle.truffle.api.nodes.LanguageInfo,java.lang.String%29), [`getIdentifier`](com/oracle/truffle/api/instrumentation/Tag.md#getIdentifier%28java.lang.Class%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ StandardTags.StatementTag [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.12. Nested in [`StandardTags`](com/oracle/truffle/api/instrumentation/StandardTags.md). ```java public static final class StandardTags.StatementTag extends Tag ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Tag`](com/oracle/truffle/api/instrumentation/Tag.md) > `StatementTag` Marks program locations that represent a statement of a language. Use case descriptions: - **Debugger:** Marks program locations where ordinary stepping should halt. The debugger will halt just *before* a code location is executed that is marked with this tag. In most languages, this means statements are distinct from expressions and only one node representing the statement should be tagged. Subexpressions are typically not tagged so that for example a step-over operation will stop at the next independent statement to get the desired behavior. The StatemenTag uses the [`identifier`](com/oracle/truffle/api/instrumentation/Tag.Identifier.md) `"STATEMENT"`. A node tagged with [`StatementTag`](com/oracle/truffle/api/instrumentation/StandardTags.StatementTag.md) must provide a [`source section`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), if its root node provides a source section. If the a node tagged with [`statement`](com/oracle/truffle/api/instrumentation/StandardTags.StatementTag.md) returns a non `null` value then it must be an interop value. There are assertions in place verifying this when Java assertions are enabled (-ea). ## Inherited members - From class [`Tag`](com/oracle/truffle/api/instrumentation/Tag.md): [`findProvidedTag`](com/oracle/truffle/api/instrumentation/Tag.md#findProvidedTag%28com.oracle.truffle.api.nodes.LanguageInfo,java.lang.String%29), [`getIdentifier`](com/oracle/truffle/api/instrumentation/Tag.md#getIdentifier%28java.lang.Class%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ StandardTags.TryBlockTag [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 19.0. Nested in [`StandardTags`](com/oracle/truffle/api/instrumentation/StandardTags.md). ```java public static final class StandardTags.TryBlockTag extends Tag ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Tag`](com/oracle/truffle/api/instrumentation/Tag.md) > `TryBlockTag` Marks program locations to be considered as try blocks, that are followed by catch. To determine which exceptions are caught by [`InstrumentableNode`](com/oracle/truffle/api/instrumentation/InstrumentableNode.md) tagged with this tag, the node might provide a [`node object`](com/oracle/truffle/api/instrumentation/InstrumentableNode.md#getNodeObject%28%29) that has `catches` function, which takes a an interop value that returns `true` for [`InteropLibrary.isException(Object)`](com/oracle/truffle/api/interop/InteropLibrary.md#isException%28java.lang.Object%29) and returns a boolean value indicating whether the try block catches the exception, or not. When this block catches all exceptions, no special node object or catches function needs to be provided. ## Fields ### CATCHES `public static final String CATCHES`. Since 19.0. Name of the `catches` function. Constant value: `"catches"`. Cite: `com/oracle/truffle/api/instrumentation/StandardTags.TryBlockTag.html#CATCHES` ## Inherited members - From class [`Tag`](com/oracle/truffle/api/instrumentation/Tag.md): [`findProvidedTag`](com/oracle/truffle/api/instrumentation/Tag.md#findProvidedTag%28com.oracle.truffle.api.nodes.LanguageInfo,java.lang.String%29), [`getIdentifier`](com/oracle/truffle/api/instrumentation/Tag.md#getIdentifier%28java.lang.Class%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ StandardTags.WriteVariableTag [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 20.0.0. Nested in [`StandardTags`](com/oracle/truffle/api/instrumentation/StandardTags.md). ```java public static final class StandardTags.WriteVariableTag extends Tag ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Tag`](com/oracle/truffle/api/instrumentation/Tag.md) > `WriteVariableTag` Marks program locations to be considered as writes of variables of the languages. Use case descriptions: - **Language Server Protocol:** Marks every write of a variable to support the *documentHighlight*, *hover*, *definition* and *references* requests. To determine the name of the variable, it is required that a node tagged with [`WriteVariableTag`](com/oracle/truffle/api/instrumentation/StandardTags.WriteVariableTag.md) also provides a [`node object`](com/oracle/truffle/api/instrumentation/InstrumentableNode.md#getNodeObject%28%29) that has [`WriteVariableTag.NAME`](com/oracle/truffle/api/instrumentation/StandardTags.WriteVariableTag.md#NAME) property. The value of that property is either: - a String name of the variable (in that case the node's [`source section`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29) is considered as the variable's source section), - an object that provides name and [`SourceSection`](com/oracle/truffle/api/source/SourceSection.md) via [`InteropLibrary.asString(Object)`](com/oracle/truffle/api/interop/InteropLibrary.md#asString%28java.lang.Object%29) and [`InteropLibrary.getSourceLocation(Object)`](com/oracle/truffle/api/interop/InteropLibrary.md#getSourceLocation%28java.lang.Object%29) respectively, - an array of objects when multiple variables are being read, where each array element provides name and [`SourceSection`](com/oracle/truffle/api/source/SourceSection.md) as specified above. Furthermore, nodes tagged with [`WriteVariableTag`](com/oracle/truffle/api/instrumentation/StandardTags.WriteVariableTag.md) have to provide a [`source section`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29). ## Fields ### NAME `public static final String NAME`. Since 20.0.0. Property of the node object that contains name of the variable. Constant value: `"writeVariableName"`. Cite: `com/oracle/truffle/api/instrumentation/StandardTags.WriteVariableTag.html#NAME` ## Inherited members - From class [`Tag`](com/oracle/truffle/api/instrumentation/Tag.md): [`findProvidedTag`](com/oracle/truffle/api/instrumentation/Tag.md#findProvidedTag%28com.oracle.truffle.api.nodes.LanguageInfo,java.lang.String%29), [`getIdentifier`](com/oracle/truffle/api/instrumentation/Tag.md#getIdentifier%28java.lang.Class%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ Tag [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.33. ```java public abstract class Tag ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Tag` Base class for tags used in the Truffle instrumentation framework. **See also** - [`For the standard set of tags`](com/oracle/truffle/api/instrumentation/StandardTags.md) - [`to find a provided tag of a language`](com/oracle/truffle/api/instrumentation/Tag.md#findProvidedTag%28com.oracle.truffle.api.nodes.LanguageInfo,java.lang.String%29) ## Nested types - [`Tag.Identifier`](com/oracle/truffle/api/instrumentation/Tag.Identifier.md) (annotation interface): Annotation applied to Tag subclasses to specify the tag identifier. ## Constructors ### Tag() `protected Tag()`. Since 0.33. No instances of tags allowed. Tags are marker classes. Cite: `com/oracle/truffle/api/instrumentation/Tag.html#()` ## Methods ### findProvidedTag(LanguageInfo, String) `public static Class findProvidedTag(LanguageInfo language, String tagId)`. Since 0.33. Finds a provided tag by the language using its `identifier`. If the language implementation class is not yet loaded then this method will force the loading. Therefore it is not recommended to iterate over the entire list of languages and request all provided tags. It is guaranteed that there is only one provided tag class per tag identifier and language. For different languages the same tag id might refer to different tag classes. Cite: `com/oracle/truffle/api/instrumentation/Tag.html#findProvidedTag(com.oracle.truffle.api.nodes.LanguageInfo,java.lang.String)` ### getIdentifier(Class) `public static String getIdentifier(Class tag)`. Since 0.33. Returns the alias of a particular tag or `null` if no alias was specified for this tag. Parameters: `tag` `Class`: the tag to return the alias for. Returns `String`: the alias string. Cite: `com/oracle/truffle/api/instrumentation/Tag.html#getIdentifier(java.lang.Class)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # @ Tag.Identifier [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.33. Nested in [`Tag`](com/oracle/truffle/api/instrumentation/Tag.md). ```java @Retention(RUNTIME) @Target({TYPE}) public @interface Tag.Identifier ``` Annotation applied to [`Tag`](com/oracle/truffle/api/instrumentation/Tag.md) subclasses to specify the tag identifier. The tag identifier can be used to [`find`](com/oracle/truffle/api/instrumentation/Tag.md#findProvidedTag%28com.oracle.truffle.api.nodes.LanguageInfo,java.lang.String%29) and load tag classes used by tools. ## Elements ### value() `String value()`. Since 0.33. Returns the identifier value as string. Cite: `com/oracle/truffle/api/instrumentation/Tag.Identifier.html#value()` # ◇ ThreadsActivationListener [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 20.3. ```java public interface ThreadsActivationListener ``` Listener that allows to be notified when threads become active and deactivated. This operation may called more frequently than the thread initialization with [`ThreadsListener`](com/oracle/truffle/api/instrumentation/ThreadsListener.md), therefore the implementation of the threads activation listener needs to be designed for compilation. Care needs to be taken to not unnecessarily slow down thread activation. The event notification starts immediately after the listener is registered. It is therefore possible that [`onLeaveThread(TruffleContext)`](com/oracle/truffle/api/instrumentation/ThreadsActivationListener.md#onLeaveThread%28com.oracle.truffle.api.TruffleContext%29) is called without [`onEnterThread(TruffleContext)`](com/oracle/truffle/api/instrumentation/ThreadsActivationListener.md#onEnterThread%28com.oracle.truffle.api.TruffleContext%29) ever being invoked, if the listener is attached in parallel. When any of the listener methods are executed then the [`ThreadsActivationListener`](com/oracle/truffle/api/instrumentation/ThreadsActivationListener.md) is guaranteed to be a [`partial evaluation constant`](com/oracle/truffle/api/CompilerAsserts.md#partialEvaluationConstant%28java.lang.Object%29). The provided [`TruffleContext`](com/oracle/truffle/api/TruffleContext.md) may be a PE constant, but it is not guaranteed. Common use-cases for threads activation include capturing the time the context is active, changing thread priorities or measuring thread allocated bytes of a context. **See also** - [`to register a listener`](com/oracle/truffle/api/instrumentation/Instrumenter.md#attachThreadsActivationListener%28com.oracle.truffle.api.instrumentation.ThreadsActivationListener%29) ## Methods ### onEnterThread(TruffleContext) `void onEnterThread(TruffleContext context)`. Since 20.3. Notified when a context is entered on the [`current thread`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Thread.html#currentThread%28%29). Entering a thread indicates that the context is currently active. A context maybe entered multiple times per thread. This method is executed frequently and must be designed for compilation. If this method throws an `com.oracle.truffle.api.exception.AbstractTruffleException` the exception interop messages may be executed without a context being entered. Parameters: `context` `TruffleContext`: the context being entered on the current thread. Cite: `com/oracle/truffle/api/instrumentation/ThreadsActivationListener.html#onEnterThread(com.oracle.truffle.api.TruffleContext)` ### onLeaveThread(TruffleContext) `void onLeaveThread(TruffleContext context)`. Since 20.3. Notified when a context is entered on the [`current thread`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Thread.html#currentThread%28%29). Leaving a thread indicates that the context is no longer active on that thread. A context maybe left multiple times per thread. This method is executed frequently and must be designed for compilation. Parameters: `context` `TruffleContext`: the context being left on the current thread. Cite: `com/oracle/truffle/api/instrumentation/ThreadsActivationListener.html#onLeaveThread(com.oracle.truffle.api.TruffleContext)` # ◇ ThreadsListener [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.30. ```java public interface ThreadsListener ``` Listener to be notified about changes of threads in guest language application. Use [`Instrumenter.attachThreadsListener(com.oracle.truffle.api.instrumentation.ThreadsListener, boolean)`](com/oracle/truffle/api/instrumentation/Instrumenter.md#attachThreadsListener%28T,boolean%29) to register an implementation of this listener. Use [`EventBinding.dispose()`](com/oracle/truffle/api/instrumentation/EventBinding.md#dispose%28%29) to unregister. The listener gets called when a thread is initialized for use in a [`context`](com/oracle/truffle/api/TruffleContext.md) or thread-related resources are disposed in a context. The notification calls do not say anything about the actual life-time of the thread as such, which may live before the initialization and may continue to live after the disposal. **See also** - [`Instrumenter.attachThreadsListener(com.oracle.truffle.api.instrumentation.ThreadsListener, boolean)`](com/oracle/truffle/api/instrumentation/Instrumenter.md#attachThreadsListener%28T,boolean%29) ## Methods ### onThreadInitialized(TruffleContext, Thread) `void onThreadInitialized(TruffleContext context, Thread thread)`. Since 0.30. Notifies about initialization of a thread to be used for a guest language execution in a `TruffleContext`. If this method throws an `com.oracle.truffle.api.exception.AbstractTruffleException` the exception interop messages may be executed without a context being entered. Parameters: `context` `TruffleContext`: the context the thread is initialized in. `thread` `Thread`: the initialized thread. Cite: `com/oracle/truffle/api/instrumentation/ThreadsListener.html#onThreadInitialized(com.oracle.truffle.api.TruffleContext,java.lang.Thread)` ### onThreadDisposed(TruffleContext, Thread) `void onThreadDisposed(TruffleContext context, Thread thread)`. Since 0.30. Notifies about disposal of thread-related resources that were used for a guest language execution in a `TruffleContext`. Parameters: `context` `TruffleContext`: the context the thread is disposed from. `thread` `Thread`: the thread. Cite: `com/oracle/truffle/api/instrumentation/ThreadsListener.html#onThreadDisposed(com.oracle.truffle.api.TruffleContext,java.lang.Thread)` # ◆ TruffleInstrument [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.12. ```java public abstract class TruffleInstrument ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `TruffleInstrument` The service provider interface (SPI) for Truffle instruments: clients of Truffle instrumentation that may observe and inject behavior into interpreters written using the Truffle framework. Instrument implementation classes must use the [`Registration`](com/oracle/truffle/api/instrumentation/TruffleInstrument.Registration.md) annotation to provide required metadata and to enable automatic discovery of the implementation. An instrument is [`created`](com/oracle/truffle/api/instrumentation/TruffleInstrument.md#onCreate%28com.oracle.truffle.api.instrumentation.TruffleInstrument.Env%29) if at least one instrument [`option`](com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.md#getOptions%28%29) was specified or if a [`service`](com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.md#registerService%28java.lang.Object%29) was looked up. The [`Instrumenter`](com/oracle/truffle/api/instrumentation/Instrumenter.md) available in the provided [environment](com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.md) allows the instrument instance to bind listeners for [execution](com/oracle/truffle/api/instrumentation/ExecutionEventListener.md) and [source](com/oracle/truffle/api/instrumentation/LoadSourceListener.md) events, as well as [node factories](com/oracle/truffle/api/instrumentation/ExecutionEventNodeFactory.md) for code injection at guest language code locations. An instrument is disposed when the associated polyglot [engine](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Engine.html) is disposed. All active bindings created by a disposed instrument become disposed automatically. The [`Instrumenter`](com/oracle/truffle/api/instrumentation/Instrumenter.md) instance available in the provided [environment](com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.md) may not be used after disposal. #### Example for a simple expression coverage instrument: ```java @Registration(id = CoverageExample.ID, services = Object.class) public final class CoverageExample extends TruffleInstrument { public static final String ID = "test-coverage"; private final Set coverage = new HashSet<>(); @Override protected void onCreate(final Env env) { SourceSectionFilter.Builder builder = SourceSectionFilter.newBuilder(); SourceSectionFilter filter = builder.tagIs(ExpressionTag.class).build(); Instrumenter instrumenter = env.getInstrumenter(); instrumenter.attachExecutionEventFactory(filter, new CoverageExampleEventFactory(env)); } private class CoverageExampleEventFactory implements ExecutionEventNodeFactory { private final Env env; CoverageExampleEventFactory(final Env env) { this.env = env; } public ExecutionEventNode create(final EventContext ec) { final PrintStream out = new PrintStream(env.out()); return new ExecutionEventNode() { @CompilationFinal private boolean visited; @Override public void onReturnValue(VirtualFrame vFrame, Object result) { if (!visited) { CompilerDirectives.transferToInterpreterAndInvalidate(); visited = true; SourceSection src = ec.getInstrumentedSourceSection(); out.print(src.getCharIndex() + " "); coverage.add(src); } } }; } } } ``` ## Nested types - [`TruffleInstrument.ContextLocalFactory`](com/oracle/truffle/api/instrumentation/TruffleInstrument.ContextLocalFactory.md) (interface): Context local factory for Truffle instruments. - [`TruffleInstrument.ContextLocalProvider`](com/oracle/truffle/api/instrumentation/TruffleInstrument.ContextLocalProvider.md) (class): Provider for creating context local and context thread local references. - [`TruffleInstrument.ContextThreadLocalFactory`](com/oracle/truffle/api/instrumentation/TruffleInstrument.ContextThreadLocalFactory.md) (interface): Context local factory for Truffle instruments. - [`TruffleInstrument.Env`](com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.md) (class): Access to instrumentation services as well as input, output, and error streams. - [`TruffleInstrument.Registration`](com/oracle/truffle/api/instrumentation/TruffleInstrument.Registration.md) (annotation interface): Annotation that registers an instrument implementations for automatic discovery. ## Fields ### locals `protected final TruffleInstrument.ContextLocalProvider locals`. Since 23.1. Provider for creating context local and context thread local references. See also: `TruffleInstrument.ContextLocalProvider.createContextLocal(TruffleInstrument.ContextLocalFactory)`, `TruffleInstrument.ContextLocalProvider.createContextThreadLocal(TruffleInstrument.ContextThreadLocalFactory)`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.html#locals` ## Constructors ### TruffleInstrument() `protected TruffleInstrument()`. Since 0.12. Constructor for subclasses. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.html#()` ## Methods ### onCreate(TruffleInstrument.Env) `protected abstract void onCreate(TruffleInstrument.Env env)`. Since 0.12. Invoked once on each newly allocated `TruffleInstrument` instance. The method may `register` additional `services` - e.g. objects to be exposed via [`lookup query`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Instrument.html#lookup%28java.lang.Class%29). For example to expose a debugger one could define an abstract debugger controller: and declare it as a `service` associated with the instrument, implement it, instantiate and `register` in own's instrument `onCreate` method: If this method throws an `com.oracle.truffle.api.exception.AbstractTruffleException` the exception interop messages are executed without a context being entered. Parameters: `env` `TruffleInstrument.Env`: environment information for the instrument. See also: `Env.getInstrumenter()`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.html#onCreate(com.oracle.truffle.api.instrumentation.TruffleInstrument.Env)` ```java public abstract class DebuggerController { DebuggerController() { } public abstract void installBreakpoint(int i, Callback callback); public abstract void stepInto(Callback callback); public abstract void stepOut(Callback callback); public abstract void stepOver(Callback callback); public interface Callback { void halted(DebuggerController debugger, EventContext haltedAt); } } ``` ```java @Registration(id = DebuggerExample.ID, services = DebuggerController.class) public final class DebuggerExample extends TruffleInstrument { private Controller controller; @Override protected void onCreate(Env env) { assert this.controller == null; this.controller = new Controller(env.getInstrumenter()); env.registerService(controller); } private static final class Controller extends DebuggerController { private final Instrumenter instrumenter; private EventBinding stepping; private Callback currentStatementCallback; Controller(Instrumenter instrumenter) { this.instrumenter = instrumenter; } ``` ### onPreinitialize(TruffleInstrument.Env) `protected boolean onPreinitialize(TruffleInstrument.Env env)`. Since 25.5. Invoked once on an initialized instrument when its engine is preinitialized. This method is called after all contexts have been prepared and without an entered context. Services of other instruments may be looked up; instruments initialized by such lookups receive this callback as well. When an explicitly preinitialized engine is consumed, the instrument's options must match, including which options were explicitly set. There is no consumption-time patch callback. By default, instruments do not support preinitialization. Parameters: `env` `TruffleInstrument.Env`: environment information for the instrument. Returns `boolean`: `true` if the instrument state can be retained in the preinitialized engine, or `false` to fail engine preinitialization. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.html#onPreinitialize(com.oracle.truffle.api.instrumentation.TruffleInstrument.Env)` ### onFinalize(TruffleInstrument.Env) `protected void onFinalize(TruffleInstrument.Env env)`. Since 19.0. Invoked once on an instance just before all instruments and languages are going to be disposed, possibly because the underlying [engine](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Engine.html) is going to be closed. This method is called before `onDispose(Env)` and the instrument must remain usable after finalization. The instrument can prepare for disposal while still having other instruments not disposed yet. In the event of VM shutdown, `onDispose(Env)` for active instruments on unclosed [`engines`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Engine.html) is not called, and so in case the instrument is supposed to do some specific action before its disposal, e.g. print some kind of summary, it should be done in this method. Parameters: `env` `TruffleInstrument.Env`: environment information for the instrument. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.html#onFinalize(com.oracle.truffle.api.instrumentation.TruffleInstrument.Env)` ### onDispose(TruffleInstrument.Env) `protected void onDispose(TruffleInstrument.Env env)`. Since 0.12. Invoked once on an instance when it becomes disabled, possibly because the underlying [engine](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Engine.html) has been closed. A disposed instance is no longer usable. If the instrument is re-enabled, the engine will create a new instance. In the event of VM shutdown, this method is not called for active instruments on unclosed [`engines`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Engine.html). The unclosed engines are not closed automatically on VM shutdown, they just die with the VM. Parameters: `env` `TruffleInstrument.Env`: environment information for the instrument. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.html#onDispose(com.oracle.truffle.api.instrumentation.TruffleInstrument.Env)` ### getOptionDescriptors() `protected OptionDescriptors getOptionDescriptors()`. Since 0.27. Returns a set of option descriptors that are supported by this instrument. Option values are accessible using the `environment` when the instrument is `created`. By default no options are available for an instrument. Options returned by this method must specify the `instrument id` as [`name`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/options/OptionDescriptor.html#getName%28%29) prefix for each option. For example if the id of the instrument is "debugger" then a valid option name would be "debugger.Enabled". The instrument will automatically be `created` if one of the specified options was provided by the engine. To construct option descriptors from a list then [`OptionDescriptors.create(List)`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/options/OptionDescriptors.html#create%28java.util.List%29) can be used. By default option descriptors may only be specified per engine or bound engine, but option values may also be specified per context. In this case the context specific options can be specified with `getContextOptionDescriptors()` and the values can be accessed with `Env.getOptions(TruffleContext)`. See also: `For an example of declaring the option descriptor using an annotation.`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.html#getOptionDescriptors()` ### getContextOptionDescriptors() `protected OptionDescriptors getContextOptionDescriptors()`. Since 20.3. Returns a set of option descriptors for instrument options that can be specified per context. This can be specified in addition to options specified on the engine level, instruments may specify options for each context. Option descriptors specified per context must not overlap with option descriptors specified per instrument instance. Example usage: See also: `to lookup the option values for a context.`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.html#getContextOptionDescriptors()` ```java @Option.Group(MyInstrument.ID) final class MyContext { @Option(category = OptionCategory.EXPERT, help = "Description...") static final OptionKey MyContextOption = new OptionKey<>(Boolean.FALSE); } @Registration(...) class MyInstrument extends TruffleInstrument { static final OptionDescriptors CONTEXT_OPTIONS = new MyContextOptionDescriptors(); //... protected OptionDescriptors getContextOptionDescriptors() { return CONTEXT_OPTIONS; } } ``` ### getSourceOptionDescriptors() `protected OptionDescriptors getSourceOptionDescriptors()`. Since 25.0. Returns a set of source option descriptors that are supported by this language. Option values are accessible using the `environment`. Languages must always return the same option descriptors independent of the language instance or side-effects. See also: `For an example of declaring the option descriptor using an annotation.`, `for another example`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.html#getSourceOptionDescriptors()` ### createContextLocal(TruffleInstrument.ContextLocalFactory) `@Deprecated protected final ContextLocal createContextLocal(TruffleInstrument.ContextLocalFactory factory)`. Since 20.3. Deprecated. in 23.1, use `TruffleInstrument.ContextLocalProvider.createContextLocal(TruffleInstrument.ContextLocalFactory)` instead. Creates a new context local reference for this Truffle instrument. Starting with JDK 21, using this method leads to a this-escape warning. Use `TruffleInstrument.ContextLocalProvider.createContextLocal(TruffleInstrument.ContextLocalFactory)` instead. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.html#createContextLocal(com.oracle.truffle.api.instrumentation.TruffleInstrument.ContextLocalFactory)` ### createContextThreadLocal(TruffleInstrument.ContextThreadLocalFactory) `@Deprecated protected final ContextThreadLocal createContextThreadLocal(TruffleInstrument.ContextThreadLocalFactory factory)`. Since 20.3. Deprecated. in 23.1, use `TruffleInstrument.ContextLocalProvider.createContextThreadLocal(TruffleInstrument.ContextThreadLocalFactory)` instead. Creates a new context thread local reference for this Truffle instrument. Starting with JDK 21, using this method leads to a this-escape warning. Use `TruffleInstrument.ContextLocalProvider.createContextThreadLocal(TruffleInstrument.ContextThreadLocalFactory)` instead. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.html#createContextThreadLocal(com.oracle.truffle.api.instrumentation.TruffleInstrument.ContextThreadLocalFactory)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ TruffleInstrument.ContextLocalFactory [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 20.3. Nested in [`TruffleInstrument`](com/oracle/truffle/api/instrumentation/TruffleInstrument.md). ```java @FunctionalInterface protected interface TruffleInstrument.ContextLocalFactory ``` Context local factory for Truffle instruments. Creates a new value per context. ## Methods ### create(TruffleContext) `T create(TruffleContext context)`. Since 20.3. Returns a new value for a context local of an instrument. The returned value must not be `null` and must return a stable and exact type per registered instrument. A thread local must always return the same [`class`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), even for multiple instances of the same `TruffleInstrument`. If this method throws an `com.oracle.truffle.api.exception.AbstractTruffleException` the exception interop messages may be executed without a context being entered. See also: `TruffleInstrument.ContextLocalProvider.createContextLocal(TruffleInstrument.ContextLocalFactory)`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.ContextLocalFactory.html#create(com.oracle.truffle.api.TruffleContext)` # ◆ TruffleInstrument.ContextLocalProvider [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 23.1. Nested in [`TruffleInstrument`](com/oracle/truffle/api/instrumentation/TruffleInstrument.md). ```java protected static final class TruffleInstrument.ContextLocalProvider ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `ContextLocalProvider` Provider for creating context local and context thread local references. **See also** - [`TruffleInstrument.locals`](com/oracle/truffle/api/instrumentation/TruffleInstrument.md#locals) - [`TruffleInstrument.ContextLocalProvider.createContextLocal(TruffleInstrument.ContextLocalFactory)`](com/oracle/truffle/api/instrumentation/TruffleInstrument.ContextLocalProvider.md#createContextLocal%28com.oracle.truffle.api.instrumentation.TruffleInstrument.ContextLocalFactory%29) - [`TruffleInstrument.ContextLocalProvider.createContextThreadLocal(TruffleInstrument.ContextThreadLocalFactory)`](com/oracle/truffle/api/instrumentation/TruffleInstrument.ContextLocalProvider.md#createContextThreadLocal%28com.oracle.truffle.api.instrumentation.TruffleInstrument.ContextThreadLocalFactory%29) ## Methods ### createContextLocal(TruffleInstrument.ContextLocalFactory) `public ContextLocal createContextLocal(TruffleInstrument.ContextLocalFactory factory)`. Since 23.1. Creates a new context local reference for this instrument. Context locals for instruments allow to store additional top-level values for each context similar to language contexts. This enables instruments to use context local values just as languages using their language context. Context local factories are guaranteed to be invoked after the instrument is `created`. Context local references must be created during the invocation in the `TruffleInstrument` constructor. Calling this method at a later point in time will throw an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html). For each registered `TruffleInstrument` subclass it is required to always produce the same number of context local references. The values produced by the factory must not be `null` and use a stable exact value type for each instance of a registered instrument class. If the return value of the factory is not stable or `null` then an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) is thrown. These restrictions allow the Truffle runtime to read the value more efficiently. Usage example: Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.ContextLocalProvider.html#createContextLocal(com.oracle.truffle.api.instrumentation.TruffleInstrument.ContextLocalFactory)` ```java @TruffleInstrument.Registration(id = "example", name = "Example Instrument") public static class ExampleInstrument extends TruffleInstrument { final ContextLocal local = locals.createContextLocal(ExampleLocal::new); @Override protected void onCreate(Env env) { ExecutionEventListener listener = new ExecutionEventListener() { public void onEnter(EventContext context, VirtualFrame frame) { ExampleLocal value = local.get(); // use context local value; } public void onReturnValue(EventContext context, VirtualFrame frame, Object result) { } public void onReturnExceptional(EventContext context, VirtualFrame frame, Throwable exception) { } }; env.getInstrumenter().attachExecutionEventListener( SourceSectionFilter.ANY, listener); } static class ExampleLocal { final TruffleContext context; ExampleLocal(TruffleContext context) { this.context = context; } } } ``` ### createContextThreadLocal(TruffleInstrument.ContextThreadLocalFactory) `public ContextThreadLocal createContextThreadLocal(TruffleInstrument.ContextThreadLocalFactory factory)`. Since 23.1. Creates a new context thread local reference for this Truffle language. Context thread locals for languages allow to store additional top-level values for each context and thread. The factory may be invoked on any thread other than the thread of the context thread local value. Context thread local factories are guaranteed to be invoked after the instrument is `created`. Context thread local references must be created during the invocation in the `TruffleLanguage` constructor. Calling this method at a later point in time will throw an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html). For each registered `TruffleLanguage` subclass it is required to always produce the same number of context thread local references. The values produces by the factory must not be `null` and use a stable exact value type for each instance of a registered language class. If the return value of the factory is not stable or `null` then an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) is thrown. These restrictions allow the Truffle runtime to read the value more efficiently. Context thread locals should not contain a strong reference to the provided thread. Use a weak reference instance for that purpose. Usage example: Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.ContextLocalProvider.html#createContextThreadLocal(com.oracle.truffle.api.instrumentation.TruffleInstrument.ContextThreadLocalFactory)` ```java @TruffleInstrument.Registration(id = "example", name = "Example Instrument") public static class ExampleInstrument extends TruffleInstrument { final ContextThreadLocal local = locals.createContextThreadLocal(ExampleLocal::new); @Override protected void onCreate(Env env) { ExecutionEventListener listener = new ExecutionEventListener() { public void onEnter(EventContext context, VirtualFrame frame) { ExampleLocal value = local.get(); // use thread local value; assert value.thread.get() == Thread.currentThread(); } public void onReturnValue(EventContext context, VirtualFrame frame, Object result) { } public void onReturnExceptional(EventContext context, VirtualFrame frame, Throwable exception) { } }; env.getInstrumenter().attachExecutionEventListener( SourceSectionFilter.ANY, listener); } static class ExampleLocal { final TruffleContext context; final WeakReference thread; ExampleLocal(TruffleContext context, Thread thread) { this.context = context; this.thread = new WeakReference<>(thread); } } } ``` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ TruffleInstrument.ContextThreadLocalFactory [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 20.3. Nested in [`TruffleInstrument`](com/oracle/truffle/api/instrumentation/TruffleInstrument.md). ```java @FunctionalInterface protected interface TruffleInstrument.ContextThreadLocalFactory ``` Context local factory for Truffle instruments. Creates a new value per context and thread. ## Methods ### create(TruffleContext, Thread) `T create(TruffleContext context, Thread thread)`. Since 20.3. Returns a new value for a context thread local for a context and thread. The returned value must not be `null` and must return a stable and exact type per registered instrument. A thread local must always return the same [`class`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), even for multiple instances of the same `TruffleInstrument`. If this method throws an `com.oracle.truffle.api.exception.AbstractTruffleException` the exception interop messages may be executed without a context being entered. See also: `TruffleInstrument.ContextLocalProvider.createContextThreadLocal(TruffleInstrument.ContextThreadLocalFactory)`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.ContextThreadLocalFactory.html#create(com.oracle.truffle.api.TruffleContext,java.lang.Thread)` # ◆ TruffleInstrument.Env [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.12. Nested in [`TruffleInstrument`](com/oracle/truffle/api/instrumentation/TruffleInstrument.md). ```java public static final class TruffleInstrument.Env ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Env` Access to instrumentation services as well as input, output, and error streams. ## Methods ### getInstrumenter() `public Instrumenter getInstrumenter()`. Since 0.12. Returns the instrumenter which lets you instrument guest language ASTs. See also: `Instrumenter`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#getInstrumenter()` ### in() `public InputStream in()`. Since 0.12. Input associated with [`org.graalvm.polyglot.Engine`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Engine.html) this `instrument` is being executed in. Returns `InputStream`: reader, never `null`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#in()` ### out() `public OutputStream out()`. Since 0.12. Standard output writer for [`org.graalvm.polyglot.Engine`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Engine.html) this `instrument` is being executed in. Returns `OutputStream`: writer, never `null`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#out()` ### err() `public OutputStream err()`. Since 0.12. Standard error writer for [`org.graalvm.polyglot.Engine`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Engine.html) this `instrument` is being executed in. Returns `OutputStream`: writer, never `null`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#err()` ### startServer(URI, MessageEndpoint) `public MessageEndpoint startServer(URI uri, MessageEndpoint server) throws IOException, MessageTransport.VetoException`. Since 19.0. Start a server at the provided URI via the [`MessageTransport`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/MessageTransport.html) service. Before an instrument creates a server endpoint for a message protocol, it needs to check the result of this method. When a virtual message transport is available, it blocks until a client connects and [`MessageEndpoint`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/MessageEndpoint.html) representing the peer endpoint is returned. Those endpoints need to be used instead of a direct creation of a server socket. If no virtual message transport is available at that URI, `null` is returned and the instrument needs to set up the server itself. When [`org.graalvm.polyglot.io.MessageTransport.VetoException`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/MessageTransport.VetoException.html) is thrown, the server creation needs to be abandoned. This method can be called concurrently from multiple threads. However, the [`MessageEndpoint`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/MessageEndpoint.html) ought to be called on one thread at a time, unless you're sure that the particular implementation can handle concurrent calls. The same holds true for the returned endpoint, it's called synchronously. Parameters: `uri` `URI`: the URI of the server endpoint. `server` `MessageEndpoint`: the handler of messages at the server side. Returns `MessageEndpoint`: an implementation of [`MessageEndpoint`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/MessageEndpoint.html) call back representing the client side, or `null` when no virtual transport is available. Throws: `MessageTransport.VetoException`: if creation of a server at that URI is not allowed. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#startServer(java.net.URI,org.graalvm.polyglot.io.MessageEndpoint)` ### registerService(Object) `public void registerService(Object service)`. Since 0.12. Registers additional service. This method can be called multiple time, but only during `initialization of the instrument`. These services are made available to users via [`org.graalvm.polyglot.Instrument.lookup`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Instrument.html#lookup%28java.lang.Class%29) query method. This method can only be called from `onCreate(com.oracle.truffle.api.instrumentation.TruffleInstrument.Env)` method - then the services are collected and cannot be changed anymore. Parameters: `service` `Object`: a service to be returned from associated [`org.graalvm.polyglot.Instrument.lookup`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Instrument.html#lookup%28java.lang.Class%29). Throws: `IllegalStateException` (unchecked): if the method is called later than from `onCreate(com.oracle.truffle.api.instrumentation.TruffleInstrument.Env)` method. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#registerService(java.lang.Object)` ### lookup(LanguageInfo, Class) `public S lookup(LanguageInfo language, Class type)`. Since 0.26. Queries a `language implementation` for a special service. The services can be provided by the language by directly implementing them when subclassing `TruffleLanguage`. The truffle language needs to be entered on the current Thread otherwise an [`AssertionError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AssertionError.html) is thrown. Type parameters: ``: the requested type. Parameters: `language` `LanguageInfo`: identification of the language to query. `type` `Class`: the class of the requested type. Returns `S`: the registered service or `null` if none is found. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#lookup(com.oracle.truffle.api.nodes.LanguageInfo,java.lang.Class)` ### lookup(InstrumentInfo, Class) `public S lookup(InstrumentInfo instrument, Class type)`. Since 0.26. Returns an additional service provided by this instrument, specified by type. If an instrument is not enabled, it will be enabled automatically by requesting a supported service. If the instrument does not provide a service for a given type it will not be enabled automatically. An [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown if a service is looked up from the current instrument. Type parameters: ``: the requested type. Parameters: `instrument` `InstrumentInfo`: identification of the instrument to query. `type` `Class`: the class of the requested type. Returns `S`: the registered service or `null` if none is found. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#lookup(com.oracle.truffle.api.InstrumentInfo,java.lang.Class)` ### getLanguages() `public Map getLanguages()`. Since 0.26. Returns a map `language id` to `language info` of all languages that are installed in the environment. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#getLanguages()` ### getHostLanguage() `public LanguageInfo getHostLanguage()`. Since 25.1. Retrieves the host language used in this environment. The returned language can be used to obtain the host language top scope object using `getScope(LanguageInfo)` method. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#getHostLanguage()` ### getInstruments() `public Map getInstruments()`. Since 0.26. Returns a map `instrument id` to `instrument info` of all instruments that are installed in the environment. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#getInstruments()` ### getOptions() `public OptionValues getOptions()`. Since 0.27. Returns the context independent option values for the options described in `TruffleInstrument.getOptionDescriptors()`. The returned options are never `null`. See also: `to return the context specific options for this instrument.`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#getOptions()` ### getOptions(TruffleContext) `public OptionValues getOptions(TruffleContext context)`. Since 20.3. Returns the context specific option values for the options described in `TruffleInstrument.getContextOptionDescriptors()` and `TruffleInstrument.getOptionDescriptors()`. Instrument context options can be different for each TruffleContext, whereas regular options cannot. See also: `to get the context independent options set for this instrument`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#getOptions(com.oracle.truffle.api.TruffleContext)` ### getOptions(Source) `public OptionValues getOptions(Source source)`. Since 25.0. Returns the parsed option values of the given source for the current instrument. Options can be specified by implementing `TruffleInstrument.getSourceOptionDescriptors()`. Note that options may not be validated beforehand, which can result in an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) if validation fails. If the source was parsed previously, all options are guaranteed to have been validated. Otherwise, this method validates only the options of the current instrument. Parameters: `source` `Source`: the source whose option values are to be retrieved. Returns `OptionValues`: the parsed [`OptionValues`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/options/OptionValues.html) for the specified source. Throws: `IllegalArgumentException` (unchecked): if option validation fails. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#getOptions(com.oracle.truffle.api.source.Source)` ### parse(Source, String...) `public CallTarget parse(Source source, String... argumentNames) throws IOException`. Since 0.12. Evaluates source of (potentially different) language using the current context.The names of arguments are parameters for the resulting {#link CallTarget} that allow the `source` to reference the actual parameters passed to `CallTarget.call(java.lang.Object...)`. Parameters: `source` `Source`: the source to evaluate. `argumentNames` `String...`: the names of `CallTarget.call(java.lang.Object...)` arguments that can be referenced from the source. Returns `CallTarget`: the call target representing the parsed result. Throws: `IOException`: if the parsing or evaluation fails for some reason. `SecurityException` (unchecked). Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#parse(com.oracle.truffle.api.source.Source,java.lang.String...)` ### parseInline(Source, Node, MaterializedFrame) `public ExecutableNode parseInline(Source source, Node node, MaterializedFrame frame)`. Since 0.31. Parses source snippet of the node's language at the provided node location. The result is an AST fragment represented by `ExecutableNode` that accepts frames valid at the provided node location, or `null` when inline parsing is not supported by the language. Parameters: `source` `Source`: a source snippet to parse at the provided node location. `node` `Node`: a context location where the source is parsed at, must not be `null`. `frame` `MaterializedFrame`: a frame location where the source is parsed at, can be `null`. Returns `ExecutableNode`: the executable fragment representing the parsed result, or `null`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#parseInline(com.oracle.truffle.api.source.Source,com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.frame.MaterializedFrame)` ### getTruffleFile(TruffleContext, String) `public TruffleFile getTruffleFile(TruffleContext context, String path)`. Since 23.0. Returns a `TruffleFile` for given path and `context`. Parameters: `context` `TruffleContext`: the `TruffleContext`, or `null` to use a current entered context. `path` `String`: the absolute or relative path to create `TruffleFile` for. Returns `TruffleFile`: `TruffleFile`. Throws: `UnsupportedOperationException` (unchecked): when the [`FileSystem`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/FileSystem.html) supports only [`URI`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/URI.html). `IllegalArgumentException` (unchecked): if the `path` string cannot be converted to a [`Path`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/Path.html). Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#getTruffleFile(com.oracle.truffle.api.TruffleContext,java.lang.String)` ### getTruffleFile(TruffleContext, URI) `public TruffleFile getTruffleFile(TruffleContext context, URI uri)`. Since 23.0. Returns a `TruffleFile` for given [`URI`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/URI.html) and `context`. Parameters: `context` `TruffleContext`: the `TruffleContext`, or `null` to use a current entered context. `uri` `URI`: the [`URI`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/URI.html) to create `TruffleFile` for. Returns `TruffleFile`: `TruffleFile`. Throws: `UnsupportedOperationException` (unchecked): when [`URI`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/URI.html) scheme is not supported. `IllegalArgumentException` (unchecked): if preconditions on the `uri` do not hold. `FileSystemNotFoundException` (unchecked): is the file system, identified by the `uri`, does not exist and cannot be created automatically. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#getTruffleFile(com.oracle.truffle.api.TruffleContext,java.net.URI)` ### getEnteredContext() `public TruffleContext getEnteredContext()`. Since 20.3. Returns the entered `TruffleContext` or `null` when no context is entered. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#getEnteredContext()` ### isEngineRoot(RootNode) `public boolean isEngineRoot(RootNode root)`. Since 0.17. Returns `true` if the given root node is considered an engine evaluation root for the current execution context. Multiple such root nodes can appear on stack frames returned by `TruffleRuntime.iterateFrames(com.oracle.truffle.api.frame.FrameInstanceVisitor)`. A debugger implementation might use this information to hide stack frames of other engines. Parameters: `root` `RootNode`: the root node to check. Returns `boolean`: `true` if engine root else `false`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#isEngineRoot(com.oracle.truffle.api.nodes.RootNode)` ### setAsynchronousStackDepth(int) `public void setAsynchronousStackDepth(int depth)`. Since 20.1.0. Request for languages to provide stack frames of scheduled asynchronous execution. Languages might not provide asynchronous stack frames by default for performance reasons. At most `depth` asynchronous stack frames are asked for. When multiple instruments call this method, the languages get a maximum depth of these calls and may therefore provide longer asynchronous stacks than requested. Also, languages may provide asynchronous stacks if it's of no performance penalty, or if requested by other options. Asynchronous stacks can then be accessed via `TruffleStackTrace.getAsynchronousStackTrace(CallTarget, Frame)`. Parameters: `depth` `int`: the requested stack depth, 0 means no asynchronous stack frames are required. See also: `TruffleStackTrace.getAsynchronousStackTrace(CallTarget, Frame)`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#setAsynchronousStackDepth(int)` ### getLanguageInfo(Class) `public LanguageInfo getLanguageInfo(Class> languageClass)`. Since 20.1. Returns the `language info` for a given language class if available. Language classes are typically obtained by invoking the `InteropLibrary.getLanguage(Object)` message. Throws an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) if the provided language is not registered. Note that languages may be returned that are not contained in `getLanguages()`. For example, values originating from the embedder like Java classes or [`polyglot proxies`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/proxy/Proxy.html). Parameters: `languageClass` `Class>`: the language class to convert. Returns `LanguageInfo`: the associated language info. Throws: `IllegalArgumentException` (unchecked): if the language class is not valid. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#getLanguageInfo(java.lang.Class)` ### getLanguageView(LanguageInfo, Object) `public Object getLanguageView(LanguageInfo language, Object value)`. Since 20.1. Wraps the provided value to provide language specific information for primitive and foreign values. A typical implementation of a given language for this method does the following: Return the current language id as their associated `language`.; Provide a language specific `display string` for primitive and foreign values.; Return a language specific `metaobject` primitive or foreign values.; Add members to the object that would implicitly be available for all objects. For example, any JavaScript object is expected to have a prototype member. Foreign objects, even if they do not have such a member, are interpreted as if they have. Parameters: `language` `LanguageInfo`: the language to provide the view for. `value` `Object`: the value to language specific information for. See also: `TruffleLanguage.getLanguageView(Object, Object)`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#getLanguageView(com.oracle.truffle.api.nodes.LanguageInfo,java.lang.Object)` ### getPolyglotBindings() `public Object getPolyglotBindings()`. Since 20.1. Returns the polyglot scope - symbols explicitly exported by languages. The polyglot bindings of the current entered context are returned. Returns `Object`: an interop object having the symbol names as properties. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#getPolyglotBindings()` ### getScope(LanguageInfo) `public Object getScope(LanguageInfo language)`. Since 20.3. Provides top scope object of the language, if any. Uses the current context to find the language scope associated with. The returned object is an `interop scope object`, or `null`. Parameters: `language` `LanguageInfo`: a language. Returns `Object`: the top scope, or `null` if the language does not support such concept. See also: `TruffleLanguage.getScope(Object)`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#getScope(com.oracle.truffle.api.nodes.LanguageInfo)` ### getInternalResource(Class) `public TruffleFile getInternalResource(Class resource) throws IOException`. Since 23.1. Returns the `TruffleFile` representing the target directory of an internal resource. The internal resource is guaranteed to be fully `InternalResource.unpackFiles(InternalResource.Env, Path)` unpacked} before this method returns. When this method is called for the first time and the resource is not cached than the resource will be unpacked. Unpacking an internal resource can be an expensive operation, but the implementation makes sure that unpacked internal resources are cached. The returned `TruffleFile` will only grant read-only access to the target directory, but access is provided even if IO access is disabled. On a HotSpot VM the internal resource is typically cached in the user directory, so unpacking would be repeated once per operating system user. When the language was compiled using native-image internal resources are unpacked at native-image compile time and stored relative to the native-image. The caller thread must be entered in a context. Parameters: `resource` `Class`: the resource class to load. Throws: `IllegalArgumentException` (unchecked): if `resource` is not associated with this instrument. `IOException`: in case of IO error. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#getInternalResource(java.lang.Class)` ### getInternalResource(String) `public TruffleFile getInternalResource(String resourceId) throws IOException`. Since 23.1. Returns the `TruffleFile` representing the target directory of an internal resource. Unlike the `getInternalResource(Class)`, this method can be used for optional resources whose classes may not exist at runtime. In this case the optional resource must be unpacked at build time, see [`Engine.copyResources(Path, String...)`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Engine.html#copyResources%28java.nio.file.Path,java.lang.String...%29). If the resource with the specified `resourceId` is not associated to this instrument, the function returns `null`. Parameters: `resourceId` `String`: unique id of the resource to be loaded. Returns `TruffleFile`: internal resource directory or `null` if resource with the `resourceId` is not associated with this instrument. Throws: `IOException`: in case of IO error. See also: `getInternalResource(Class)`, [`Engine.copyResources(Path, String...)`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Engine.html#copyResources%28java.nio.file.Path,java.lang.String...%29). Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#getInternalResource(java.lang.String)` ### getLogger(String) `public TruffleLogger getLogger(String loggerName)`. Since 19.0. Find or create an engine bound logger for an instrument. When a logging is required from a thread which entered a context the context's logging handler and options are used. Otherwise the engine's logging handler and options are used. If a logger with given name already exists it's returned, otherwise a new logger is created. Unlike loggers created by `TruffleLogger.getLogger` loggers created by this method are bound to engine, there may be more logger instances having the same name but each bound to different engine instance. Instruments should never store the returned logger into a static fields. A new logger must be always created in `onCreate` method. Parameters: `loggerName` `String`: the name of a `TruffleLogger`, if a `loggerName` is null or empty a root logger for language or instrument is returned. Returns `TruffleLogger`: a `TruffleLogger`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#getLogger(java.lang.String)` ### getLogger(Class) `public TruffleLogger getLogger(Class forClass)`. Since 19.0. Find or create an engine bound logger for an instrument. The engine bound loggers can be used by threads executing without any current context. When a logging is required from a thread which entered a context the context's logging handler and options are used. Otherwise the engine's logging handler and options are used. If a logger for the class already exists it's returned, otherwise a new logger is created. Unlike loggers created by `TruffleLogger.getLogger` loggers created by this method are bound to engine, there may be more logger instances having the same name but each bound to different engine instance. Instruments should never store the returned logger into a static fields. A new logger must be always created in `onCreate` method. Parameters: `forClass` `Class`: the [`Class`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Class.html) to create a logger for. Returns `TruffleLogger`: a `TruffleLogger`. Throws: `NullPointerException` (unchecked): if `forClass` is null. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#getLogger(java.lang.Class)` ### isSameFrame(RootNode, Frame, Frame) `public boolean isSameFrame(RootNode root, Frame frame1, Frame frame2)`. Since 24.0. Tests if two frames are the same. This method is mainly used by instruments in case of `yield` of the execution and later resume. Frame comparison is used to match the particular yielded and resumed execution. The frames must correspond to the root. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#isSameFrame(com.oracle.truffle.api.nodes.RootNode,com.oracle.truffle.api.frame.Frame,com.oracle.truffle.api.frame.Frame)` ### calculateContextHeapSize(TruffleContext, long, AtomicBoolean) `public long calculateContextHeapSize(TruffleContext truffleContext, long stopAtBytes, AtomicBoolean cancelled)`. Since 21.1. Returns heap memory size retained by a polyglot context. Parameters: `truffleContext` `TruffleContext`: specifies the polyglot context for which retained size is calculated. `stopAtBytes` `long`: when the calculated size exceeds stopAtBytes, calculation is stopped and only size calculated up to that point is returned, i.e., if the retained size is greater than stopAtBytes, a value greater than stopAtBytes will be returned, not the total retained size which might be much greater. `cancelled` `AtomicBoolean`: when cancelled returns true, calculation is cancelled and [`java.util.concurrent.CancellationException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/CancellationException.html) is thrown. The message of the exception specifies the number of bytes calculated up to that point. Returns `long`: calculated heap memory size retained by the specified polyglot context, or a value greater than stopAtBytes if the calculated size is greater than stopAtBytes. Throws: `UnsupportedOperationException` (unchecked): in case heap size calculation is not supported on current runtime. `CancellationException` (unchecked): in case the heap size calculation is cancelled based on the cancelled parameter. The message of the exception specifies the number of bytes calculated up to that point. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#calculateContextHeapSize(com.oracle.truffle.api.TruffleContext,long,java.util.concurrent.atomic.AtomicBoolean)` ### submitThreadLocal(TruffleContext, Thread[], ThreadLocalAction) `public Future submitThreadLocal(TruffleContext context, Thread[] threads, ThreadLocalAction action)`. Since 21.1. Submits a thread local action to be performed at the next guest language safepoint on a provided set of threads, once for each thread. If the threads array is `null` then the thread local action will be performed on all alive threads. The submitted actions are processed in the same order as they are submitted in. The action can be synchronous or asynchronous, side-effecting or non-sideeffecting. Please see `ThreadLocalAction` for details. It is ensured that a thread local action will get processed as long as the thread stays active for this context. If a thread becomes inactive before the action can get processed then the action will not be performed for this thread. If a thread becomes active while the action is being processed then the action will be performed for that thread as long as the thread filter includes the thread or `null` was passed. Already started synchronous actions will block on activation of a new thread. If the synchronous action was not yet started on any thread, then the synchronous action will also be performed for the newly activated thread. The method returns a [`Future`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/Future.html) instance that allows to wait for the thread local action to complete or to cancel a currently performed event. Example Usage: By default thread-local actions are executed once per configured thread and do not repeat themselves. If a ThreadLocalAction is configured to be `recurring` then the action will automatically be rescheduled in the same configuration until it is [`cancelled`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/Future.html#cancel%28boolean%29). For recurring actions, an invocation of [`Future.get()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/Future.html#get%28%29) will only wait for the first action to be performed. [`Future.isDone()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/Future.html#isDone%28%29) will return `true` only if the action was canceled. Canceling a recurring action will result in the current event being canceled and no further events being submitted. Using recurring events should be preferred over submitting the event again for the current thread while performing the thread-local action as recurring events are also resubmitted in case all threads leave and later reenter. If the thread local action future needs to be waited on and this might be prone to deadlocks the `blocking API` can be used to allow other thread local actions to be processed while the current thread is waiting. The returned [`Future.get()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/Future.html#get%28%29) method can be used as `Interruptible`. If the supplied context is already closed, the method returns a completed [`Future`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/Future.html). Parameters: `context` `TruffleContext`: the context in which the action should be performed. Non `null` . `threads` `Thread[]`: the threads to execute the action on. `null` for all threads. `action` `ThreadLocalAction`: the action to perform on that thread. See also: `ThreadLocalAction`, `TruffleSafepoint`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#submitThreadLocal(com.oracle.truffle.api.TruffleContext,java.lang.Thread[],com.oracle.truffle.api.ThreadLocalAction)` ```java Env env; // supplied by TruffleInstrument TruffleContext context; // supplied by ContextsListener env.submitThreadLocal(context, null, new ThreadLocalAction(true, true) { @Override protected void perform(Access access) { // perform action } }); ``` ### createSystemThread(Runnable) `public Thread createSystemThread(Runnable runnable)`. Since 22.3. Creates a new thread designed to process instrument tasks in the background. See `createSystemThread(Runnable, ThreadGroup)` for a detailed description of the parameters. See also: `createSystemThread(Runnable, ThreadGroup)`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#createSystemThread(java.lang.Runnable)` ### createSystemThread(Runnable, ThreadGroup) `public Thread createSystemThread(Runnable runnable, ThreadGroup threadGroup)`. Since 22.3. Creates a new thread designed to process instrument tasks in the background. The created thread cannot enter the context, if it tries an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) is thrown. Creating or terminating a system thread does not notify languages or `ThreadsListener`s. Creating a system thread does not cause a transition to multi-threaded access. It is recommended to set an [`uncaught exception handler`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Thread.html#setUncaughtExceptionHandler%28java.lang.Thread.UncaughtExceptionHandler%29) for the created thread. For example the thread can throw an uncaught exception if the engine is closed before the thread is started. The instrument that created and started the thread is responsible to stop and join it during the `onDispose`, otherwise an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) is thrown. It's not safe to use the [`ExecutorService.awaitTermination(long, java.util.concurrent.TimeUnit)`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/ExecutorService.html#awaitTermination%28long,java.util.concurrent.TimeUnit%29) to detect Thread termination as the system thread may be cancelled before executing the executor worker. A typical implementation looks like: Parameters: `runnable` `Runnable`: the runnable to run on this thread. `threadGroup` `ThreadGroup`: the thread group, passed on to the underlying [`Thread`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Thread.html). Throws: `IllegalStateException` (unchecked): if the engine is already closed. See also: `createSystemThread(Runnable)`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#createSystemThread(java.lang.Runnable,java.lang.ThreadGroup)` ```java class SystemThreadInstrument extends TruffleInstrument { private volatile Thread systemThread; private volatile boolean cancelled; private final BlockingQueue tasks = new LinkedBlockingQueue<>(); @Override protected void onCreate(Env env) { // Create and start a Thread for the asynchronous task. // Remember the Thread reference to stop and join it in // the finalizeContext systemThread = env.createSystemThread(() -> { while (!cancelled) { try { Runnable task = tasks.poll(Integer.MAX_VALUE, SECONDS); if (task != null) { task.run(); } } catch (InterruptedException ie) { // pass to cancelled check } } }); systemThread.start(); } @Override protected void onDispose(Env env) { // Stop and join system thread. cancelled = true; systemThread.interrupt(); boolean interrupted = false; boolean terminated = false; while (!terminated) { try { systemThread.join(); terminated = true; } catch (InterruptedException ie) { interrupted = true; } } if (interrupted) { Thread.currentThread().interrupt(); } } } ``` ### getSandboxPolicy() `public SandboxPolicy getSandboxPolicy()`. Since 23.0. Returns the engine's [`SandboxPolicy`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/SandboxPolicy.html). An instrument can use the returned sandbox policy to make instrument-specific verifications that the sandbox requirements are met. These verifications should be made as early as possible in the `TruffleInstrument.onCreate(Env)` method. See also: [`SandboxPolicy`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/SandboxPolicy.html), `TruffleInstrument.onCreate(Env)`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Env.html#getSandboxPolicy()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # @ TruffleInstrument.Registration [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation](com/oracle/truffle/api/instrumentation/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.instrumentation`](com/oracle/truffle/api/instrumentation/index.md). Since 0.12. Nested in [`TruffleInstrument`](com/oracle/truffle/api/instrumentation/TruffleInstrument.md). ```java @Retention(RUNTIME) @Target({TYPE}) public @interface TruffleInstrument.Registration ``` Annotation that registers an [`instrument`](com/oracle/truffle/api/instrumentation/TruffleInstrument.md) implementations for automatic discovery. ## Elements ### id() `String id() default ""`. Since 0.12. A custom machine identifier for this instrument. If not defined then the fully qualified class name is used. Default: `""`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Registration.html#id()` ### name() `String name() default ""`. Since 0.12. The name of the instrument in an arbitrary format for humans. Default: `""`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Registration.html#name()` ### version() `String version() default "inherit"`. Since 0.12. The version for instrument in an arbitrary format. It inherits from [`org.graalvm.polyglot.Engine.getVersion()`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Engine.html#getVersion%28%29) by default. Default: `"inherit"`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Registration.html#version()` ### internal() `boolean internal() default false`. Since 0.27. Specifies whether the instrument is accessible using the polyglot API. Internal instruments are only accessible from other instruments or guest languages. Default: `false`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Registration.html#internal()` ### services() `Class[] services() default {}`. Since 0.25. Declarative list of classes this instrument is known to provide. The instrument is supposed to override its `onCreate` method and instantiate and `register` all here in defined services. Instruments automatically get created when their registered [`service is requested`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Instrument.html#lookup%28java.lang.Class%29). Returns `Class[]`: list of service types that this instrument can provide. Default: `{}`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Registration.html#services()` ### website() `String website() default ""`. Since 22.1.0. A link to a website with more information about the instrument. Will be shown in the help text of GraalVM launchers. The link can contain the following substitutions: **`${graalvm-version}`** the current GraalVM version. Optionally, a format string can be provided for the version using `${graalvm-version:format}`. See [`Version.format`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/home/Version.html#format%28java.lang.String%29).; **`${graalvm-website-version}`** the current GraalVM version in a format suitable for links to the GraalVM reference manual. The exact format may change without notice. Default: `""`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Registration.html#website()` ### sandbox() `SandboxPolicy sandbox() default TRUSTED`. Since 23.0. Specifies the most strict sandbox policy in which the instrument can be used. The instrument can be used in an engine with the specified sandbox policy or a weaker one. For example, if an instrument specifies `ISOLATED` policy, it can be used in an engine configured with sandbox policy `TRUSTED`, `CONSTRAINED` or `ISOLATED`. But it cannot be used in an engine configured with the `UNTRUSTED` sandbox policy. Default: `TRUSTED`. See also: [`SandboxPolicy`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/SandboxPolicy.html). Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Registration.html#sandbox()` ### internalResources() `Class[] internalResources() default {}`. Since 23.1. Declarative list of `InternalResource` classes that is associated with this instrument. Use the `internalResources` attribute solely for registering required internal resources. Optional internal resources should provide the associated instrument identifier using the `Id.componentId()` method. To unpack all resources of an instrument embedders may use [`Engine.copyResources(Path, String...)`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Engine.html#copyResources%28java.nio.file.Path,java.lang.String...%29). Default: `{}`. See also: `InternalResource`, `Id`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Registration.html#internalResources()` ### optionalResources() `String[] optionalResources() default {}`. Since 25.0. A declarative list of optional `InternalResource` identifiers associated with this instrument. It is recommended to register all optional resource identifiers here. Specifying the resource identifier allows the instrument use the resource even if its implementation was omitted at runtime. To use the resource when its implementation was omitted the `polyglot.engine.resourcePath.instrumentId` system property must be specified and point to a path with the resources. This allows to omit the resource implementation class in standalone distributions. Default: `{}`. See also: `InternalResource`, `Id`. Cite: `com/oracle/truffle/api/instrumentation/TruffleInstrument.Registration.html#optionalResources()` # ▣ com.oracle.truffle.api.instrumentation.provider [truffle-api](index.md) · Every page: [llms.txt](llms.txt) Package in truffle-api. Since 23.1. This package contains a provider to instantiate a Truffle instrument. The Truffle instrument provider is not intended to be implemented directly by a language developer, rather the implementation is generated by the Truffle DSL. ## Classes - [`TruffleInstrumentProvider`](com/oracle/truffle/api/instrumentation/provider/TruffleInstrumentProvider.md): Used to register a TruffleInstrument using a ServiceLoader. # ◆ TruffleInstrumentProvider [truffle-api](index.md) › [com.oracle.truffle.api.instrumentation.provider](com/oracle/truffle/api/instrumentation/provider/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.instrumentation.provider`](com/oracle/truffle/api/instrumentation/provider/index.md). Since 23.1. ```java public abstract class TruffleInstrumentProvider ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `TruffleInstrumentProvider` Used to register a [`TruffleInstrument`](com/oracle/truffle/api/instrumentation/TruffleInstrument.md) using a [`ServiceLoader`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/ServiceLoader.html). This interface is not intended to be implemented directly by an instrument developer, rather the implementation is generated by the Truffle DSL. The generated implementation has to inherit the [`Registration`](com/oracle/truffle/api/instrumentation/TruffleInstrument.Registration.md) annotations from the [`TruffleInstrument`](com/oracle/truffle/api/instrumentation/TruffleInstrument.md). ## Constructors ### TruffleInstrumentProvider() `protected TruffleInstrumentProvider()`. Since 23.1. Constructor to be called by subclasses. Cite: `com/oracle/truffle/api/instrumentation/provider/TruffleInstrumentProvider.html#()` ## Methods ### getInstrumentClassName() `protected abstract String getInstrumentClassName()`. Since 23.1. Returns the name of a class implementing the `TruffleInstrument`. Cite: `com/oracle/truffle/api/instrumentation/provider/TruffleInstrumentProvider.html#getInstrumentClassName()` ### create() `protected abstract Object create()`. Since 23.1. Creates a new instance of a `TruffleInstrument`. Cite: `com/oracle/truffle/api/instrumentation/provider/TruffleInstrumentProvider.html#create()` ### getServicesClassNames() `protected abstract Collection getServicesClassNames()`. Since 23.1. Returns the class names of provided services. Cite: `com/oracle/truffle/api/instrumentation/provider/TruffleInstrumentProvider.html#getServicesClassNames()` ### getInternalResourceIds() `protected List getInternalResourceIds()`. Since 23.1. Returns ids of provided internal resources. Cite: `com/oracle/truffle/api/instrumentation/provider/TruffleInstrumentProvider.html#getInternalResourceIds()` ### createInternalResource(String) `protected Object createInternalResource(String resourceId)`. Since 23.1. Creates an instrument `InternalResource` identified by the `resourceId`. Throws: `IllegalArgumentException` (unchecked): if `resourceId` is not supported by this instrument. Cite: `com/oracle/truffle/api/instrumentation/provider/TruffleInstrumentProvider.html#createInternalResource(java.lang.String)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ▣ com.oracle.truffle.api.interop [truffle-api](index.md) · Every page: [llms.txt](llms.txt) Package in truffle-api. Since 0.8 or older. This package contains classes that specify the contract for inter-operability between Truffle guest languages and tools. **See also** - [`com.oracle.truffle.api.interop.InteropLibrary`](com/oracle/truffle/api/interop/InteropLibrary.md) ## Interfaces - [`TruffleObject`](com/oracle/truffle/api/interop/TruffleObject.md): Interface for any entity of a Truffle guest language implementations that can be shared across other language implementations. ## Classes - [`InteropLibrary`](com/oracle/truffle/api/interop/InteropLibrary.md): Represents the library that specifies the interoperability message protocol between Truffle languages, tools and embedders. - [`NodeLibrary`](com/oracle/truffle/api/interop/NodeLibrary.md): Node Library provides access to guest language information associated with a particular Node location. ## Enums - [`ExceptionType`](com/oracle/truffle/api/interop/ExceptionType.md): Represents a type of a Truffle exception. ## Exceptions - [`ArityException`](com/oracle/truffle/api/interop/ArityException.md): An exception thrown if a executable or instantiable object was provided with the wrong number of arguments. - [`HeapIsolationException`](com/oracle/truffle/api/interop/HeapIsolationException.md): Exception thrown when a TruffleObject cannot unbox a host object because the object resides in a foreign heap. - [`InteropException`](com/oracle/truffle/api/interop/InteropException.md): Common super class for exceptions that can occur when sending interop messages. - [`InvalidArrayIndexException`](com/oracle/truffle/api/interop/InvalidArrayIndexException.md): An exception thrown if an array does not contain a element with an index. - [`InvalidBufferOffsetException`](com/oracle/truffle/api/interop/InvalidBufferOffsetException.md): An exception thrown if a buffer access if out of bounds. - [`StopIterationException`](com/oracle/truffle/api/interop/StopIterationException.md): An exception thrown if an iterator is finished. - [`UnknownIdentifierException`](com/oracle/truffle/api/interop/UnknownIdentifierException.md): An exception thrown if an object does not contain a member with such an identifier. - [`UnknownKeyException`](com/oracle/truffle/api/interop/UnknownKeyException.md): An exception thrown if an object does not contain a hash entry with such a key. - [`UnsupportedMessageException`](com/oracle/truffle/api/interop/UnsupportedMessageException.md): An exception thrown if a TruffleObject does not support a interop message. - [`UnsupportedTypeException`](com/oracle/truffle/api/interop/UnsupportedTypeException.md): An exception thrown if a TruffleObject does not support the type of one or more arguments. # ⚡︎ ArityException [truffle-api](index.md) › [com.oracle.truffle.api.interop](com/oracle/truffle/api/interop/index.md) · Every page: [llms.txt](llms.txt) Exception in [`com.oracle.truffle.api.interop`](com/oracle/truffle/api/interop/index.md). Since 0.11. ```java public final class ArityException extends InteropException ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) > [`Exception`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Exception.html) > [`InteropException`](com/oracle/truffle/api/interop/InteropException.md) > `ArityException` An exception thrown if a executable or instantiable object was provided with the wrong number of arguments. ## Methods ### getMessage() `public String getMessage()`. Since 19.0. Overrides `getMessage()`. Cite: `com/oracle/truffle/api/interop/ArityException.html#getMessage()` ### getExpectedMinArity() `public int getExpectedMinArity()`. Since 21.0. Returns the minimum number of arguments that are expected. The returned minimum arity might be less conservative than the actual specification of the executable or instantiable invoked. Cite: `com/oracle/truffle/api/interop/ArityException.html#getExpectedMinArity()` ### getExpectedMaxArity() `public int getExpectedMaxArity()`. Since 21.0. Returns the maximum number of arguments that are expected. Returns a negative number if infinite arguments can be provided. Cite: `com/oracle/truffle/api/interop/ArityException.html#getExpectedMaxArity()` ### getActualArity() `public int getActualArity()`. Since 0.11. Returns the actual number of arguments provided by the foreign access. If a negative value is returned then the actual arity is unknown. Returns `int`: the number of provided arguments. Cite: `com/oracle/truffle/api/interop/ArityException.html#getActualArity()` ### create(int, int, int) `public static ArityException create(int expectedMinArity, int expectedMaxArity, int actualArity)`. Since 21.2. Creates an `ArityException` to indicate that the wrong number of arguments were provided. Throws an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) if the arguments are invalid and assertions (-ea) are enabled. This method is designed to be used in `compiled` code paths. Parameters: `expectedMinArity` `int`: (inclusive) the minimum number of arguments expected by the executable. Must be greater or equal to zero. `expectedMaxArity` `int`: (inclusive) the maximum number of arguments expected by the executable. If the maximum is negative then an infinite number of arguments is expected. If the number is positive then the maximum must be greater or equal to `expectedMinArity`. `actualArity` `int`: the number of provided by the executable. The actual arity must not be within range of the expected min and max arity. Cite: `com/oracle/truffle/api/interop/ArityException.html#create(int,int,int)` ### create(int, int, …) `public static ArityException create(int expectedMinArity, int expectedMaxArity, int actualArity, Throwable cause)`. Since 21.2. Creates an `ArityException` to indicate that the wrong number of arguments were provided. Throws an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) if the arguments are invalid and assertions (-ea) are enabled. In addition a cause may be provided. The cause should only be set if the guest language code caused this problem. An example for this is a language specific proxy mechanism that invokes guest language code to describe an object. If the guest language code fails to execute and this interop exception is a valid interpretation of the error, then the error should be provided as cause. The cause can then be used by the source language as new exception cause if the `InteropException` is translated to a source language error. If the `InteropException` is discarded, then the cause will most likely get discarded by the source language as well. Note that the cause must be of type `com.oracle.truffle.api.exception.AbstractTruffleException` otherwise an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. This method is designed to be used in `compiled` code paths. Parameters: `expectedMinArity` `int`: (inclusive) the minimum number of arguments expected by the executable. Must be greater or equal to zero. `expectedMaxArity` `int`: (inclusive) the maximum number of arguments expected by the executable. If the maximum is negative then an infinite number of arguments is expected. If the number is positive then the maximum must be greater or equal to `expectedMinArity`. `actualArity` `int`: the number of provided by the executable. The actual arity must not be within range of the expected min and max arity. `cause` `Throwable`: the guest language exception that caused the error. Cite: `com/oracle/truffle/api/interop/ArityException.html#create(int,int,int,java.lang.Throwable)` ## Inherited members - From class [`InteropException`](com/oracle/truffle/api/interop/InteropException.md): [`fillInStackTrace`](com/oracle/truffle/api/interop/InteropException.md#fillInStackTrace%28%29), [`getCause`](com/oracle/truffle/api/interop/InteropException.md#getCause%28%29) - From class [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html): [`addSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#addSuppressed%28java.lang.Throwable%29), [`getLocalizedMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getLocalizedMessage%28%29), [`getStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getStackTrace%28%29), [`getSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getSuppressed%28%29), [`initCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#initCause%28java.lang.Throwable%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintStream%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintWriter%29), [`setStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#setStackTrace%28java.lang.StackTraceElement[]%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ≡ ExceptionType [truffle-api](index.md) › [com.oracle.truffle.api.interop](com/oracle/truffle/api/interop/index.md) · Every page: [llms.txt](llms.txt) Enum class in [`com.oracle.truffle.api.interop`](com/oracle/truffle/api/interop/index.md). Since 20.3. ```java public enum ExceptionType ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html) > `ExceptionType` Represents a type of a Truffle exception. **See also** - [`InteropLibrary.isException(Object)`](com/oracle/truffle/api/interop/InteropLibrary.md#isException%28java.lang.Object%29) - [`InteropLibrary.getExceptionType(Object)`](com/oracle/truffle/api/interop/InteropLibrary.md#getExceptionType%28java.lang.Object%29) ## Enum constants ### EXIT `EXIT`. Since 20.3. Indicates that the application was soft-exited within the guest language program. To obtain the exit status use `getExceptionExitStatus`. See [Context Exit](https://github.com/oracle/graal/blob/master/truffle/docs/Exit.md) for further information. If a language uses hard exits, it should not use soft exits, i.e. throw exceptions of this type on its own. If a language that does not use soft exits sees an exception of this type, it should re-throw it like other foreign exceptions, triggering finally blocks. See also: `InteropLibrary.getExceptionExitStatus(Object)`. Cite: `com/oracle/truffle/api/interop/ExceptionType.html#EXIT` ### INTERRUPT `INTERRUPT`. Since 20.3. Indicates that the application thread was interrupted by an [`InterruptedException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/InterruptedException.html). Cite: `com/oracle/truffle/api/interop/ExceptionType.html#INTERRUPT` ### RUNTIME_ERROR `RUNTIME_ERROR`. Since 20.3. Indicates a guest language error. Cite: `com/oracle/truffle/api/interop/ExceptionType.html#RUNTIME_ERROR` ### PARSE_ERROR `PARSE_ERROR`. Since 20.3. Indicates a parser or syntax error. Syntax errors typically occur while `parsing` of guest language source code. Use `isExceptionIncompleteSource` to find out if the parse error happened due to incomplete source. See also: `InteropLibrary.isExceptionIncompleteSource(Object)`. Cite: `com/oracle/truffle/api/interop/ExceptionType.html#PARSE_ERROR` ## Methods ### values() `public static ExceptionType[] values()`. Returns the enum constants in declaration order. Returns `ExceptionType[]`: Returns the enum constants in declaration order. Cite: `com/oracle/truffle/api/interop/ExceptionType.html#values()` ### valueOf(String) `public static ExceptionType valueOf(String name)`. Returns the enum constant with the given name. Parameters: `name` `String`: The exact name of the enum constant. Returns `ExceptionType`: Returns the enum constant with the given name. Cite: `com/oracle/truffle/api/interop/ExceptionType.html#valueOf(java.lang.String)` ## Inherited members - From class [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#clone%28%29), [`compareTo`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#compareTo%28E%29), [`describeConstable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#describeConstable%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#finalize%28%29), [`getDeclaringClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#getDeclaringClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#hashCode%28%29), [`name`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#name%28%29), [`ordinal`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#ordinal%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#toString%28%29), [`valueOf`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#valueOf%28java.lang.Class,java.lang.String%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ⚡︎ HeapIsolationException [truffle-api](index.md) › [com.oracle.truffle.api.interop](com/oracle/truffle/api/interop/index.md) · Every page: [llms.txt](llms.txt) Exception in [`com.oracle.truffle.api.interop`](com/oracle/truffle/api/interop/index.md). Since 25.1. ```java public final class HeapIsolationException extends InteropException ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) > [`Exception`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Exception.html) > [`InteropException`](com/oracle/truffle/api/interop/InteropException.md) > `HeapIsolationException` Exception thrown when a [`TruffleObject`](com/oracle/truffle/api/interop/TruffleObject.md) cannot unbox a host object because the object resides in a foreign heap. ## Methods ### getMessage() `public String getMessage()`. Since 25.1. Overrides `getMessage()`. Cite: `com/oracle/truffle/api/interop/HeapIsolationException.html#getMessage()` ### create() `public static HeapIsolationException create()`. Since 25.1. Creates a new `HeapIsolationException` indicating that a host object cannot be unboxed because it was allocated in a foreign heap. For example, when `InteropLibrary.asHostObject(Object)` is invoked from within a polyglot isolate. This factory method is intended for use in `compiled code paths`. Cite: `com/oracle/truffle/api/interop/HeapIsolationException.html#create()` ### create(Throwable) `public static HeapIsolationException create(Throwable cause)`. Since 25.1. Creates a new `HeapIsolationException` indicating that a host object cannot be unboxed because it was allocated in a foreign heap. For example, when `InteropLibrary.asHostObject(Object)` is invoked from within a polyglot isolate. In addition, a cause may be provided. The cause should only be set if the guest language code caused this problem. An example for this is a language specific proxy mechanism that invokes guest language code to describe an object. If the guest language code fails to execute and this interop exception is a valid interpretation of the error, then the error should be provided as cause. The cause can then be used by the source language as new exception cause if the `InteropException` is translated to a source language error. If the `InteropException` is discarded, then the cause will most likely get discarded by the source language as well. Note that the cause must be of type `com.oracle.truffle.api.exception.AbstractTruffleException` otherwise an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. This factory method is intended for use in `compiled code paths`. Cite: `com/oracle/truffle/api/interop/HeapIsolationException.html#create(java.lang.Throwable)` ## Inherited members - From class [`InteropException`](com/oracle/truffle/api/interop/InteropException.md): [`fillInStackTrace`](com/oracle/truffle/api/interop/InteropException.md#fillInStackTrace%28%29), [`getCause`](com/oracle/truffle/api/interop/InteropException.md#getCause%28%29) - From class [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html): [`addSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#addSuppressed%28java.lang.Throwable%29), [`getLocalizedMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getLocalizedMessage%28%29), [`getStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getStackTrace%28%29), [`getSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getSuppressed%28%29), [`initCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#initCause%28java.lang.Throwable%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintStream%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintWriter%29), [`setStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#setStackTrace%28java.lang.StackTraceElement[]%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ⚡︎ InteropException [truffle-api](index.md) › [com.oracle.truffle.api.interop](com/oracle/truffle/api/interop/index.md) · Every page: [llms.txt](llms.txt) Abstract exception in [`com.oracle.truffle.api.interop`](com/oracle/truffle/api/interop/index.md). Since 0.11. ```java public abstract class InteropException extends Exception ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) > [`Exception`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Exception.html) > `InteropException` Common super class for exceptions that can occur when sending [`interop messages`](com/oracle/truffle/api/interop/InteropLibrary.md). This super class is used to catch any kind of these exceptions. **See also** - [`InteropLibrary`](com/oracle/truffle/api/interop/InteropLibrary.md) ## Methods ### getCause() `public final Throwable getCause()`. Since 20.2. Returns the cause of an interop exception. Overrides `getCause()`. Cite: `com/oracle/truffle/api/interop/InteropException.html#getCause()` ### fillInStackTrace() `public final Throwable fillInStackTrace()`. Since 20.2. No stack trace for interop exceptions. Overrides `fillInStackTrace()`. Cite: `com/oracle/truffle/api/interop/InteropException.html#fillInStackTrace()` ## Inherited members - From class [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html): [`addSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#addSuppressed%28java.lang.Throwable%29), [`getLocalizedMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getLocalizedMessage%28%29), [`getMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getMessage%28%29), [`getStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getStackTrace%28%29), [`getSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getSuppressed%28%29), [`initCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#initCause%28java.lang.Throwable%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintStream%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintWriter%29), [`setStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#setStackTrace%28java.lang.StackTraceElement[]%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ InteropLibrary [truffle-api](index.md) › [com.oracle.truffle.api.interop](com/oracle/truffle/api/interop/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.interop`](com/oracle/truffle/api/interop/index.md). Since 19.0. ```java public abstract class InteropLibrary extends Library ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > [`Library`](com/oracle/truffle/api/library/Library.md) > `InteropLibrary` Represents the library that specifies the interoperability message protocol between Truffle languages, tools and embedders. Every method represents one message specified by the protocol. In the following text we will abbreviate interoperability with interop. The interop API differentiates between the source and the target language. The source language is the language that implements/exports the message implementations. The implementations map types of the source language to the interop protocol as it is specified by the protocol. For example, language values that represent arrays or array like structures should implement the messages for [`array based access`](com/oracle/truffle/api/interop/InteropLibrary.md#hasArrayElements%28java.lang.Object%29). This allows the target language to call the protocol without knowledge of the concrete source language. The target language embeds the interop protocol semantics as part of their existing language semantics. For example, language operations that access array elements in the target language should call [`array access`](com/oracle/truffle/api/interop/InteropLibrary.md#hasArrayElements%28java.lang.Object%29) messages for interop values. The interop protocol only allows *interop values* to be used as receivers, return values or parameters of messages. Allowed Java types of interop values are: - [`TruffleObject`](com/oracle/truffle/api/interop/TruffleObject.md): Any object that implements the [`TruffleObject`](com/oracle/truffle/api/interop/TruffleObject.md) interface is interpreted according to the interop messages it [`exports`](com/oracle/truffle/api/library/ExportLibrary.md). Truffle objects are expected but not required to export interop library messages. - [`String`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html) and [`Character`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Character.html) are interpreted as [`string`](com/oracle/truffle/api/interop/InteropLibrary.md#isString%28java.lang.Object%29) value. - [`Boolean`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Boolean.html) is interpreted as [`boolean`](com/oracle/truffle/api/interop/InteropLibrary.md#isBoolean%28java.lang.Object%29) value. - [`Byte`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Byte.html), [`Short`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Short.html), [`Integer`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Integer.html), [`Long`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Long.html), [`Float`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Float.html) and [`Double`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Double.html) are interpreted as [`number`](com/oracle/truffle/api/interop/InteropLibrary.md#isNumber%28java.lang.Object%29) values. Note that `null` is *never* a valid interop value. Instead, use a [`TruffleObject`](com/oracle/truffle/api/interop/TruffleObject.md) which implements [`isNull(Object)`](com/oracle/truffle/api/interop/InteropLibrary.md#isNull%28java.lang.Object%29) message. The following type combinations are mutually exclusive and cannot return `true` for the type check message of the same receiver value: - [`Null`](com/oracle/truffle/api/interop/InteropLibrary.md#isNull%28java.lang.Object%29) - [`Boolean`](com/oracle/truffle/api/interop/InteropLibrary.md#isBoolean%28java.lang.Object%29) - [`String`](com/oracle/truffle/api/interop/InteropLibrary.md#isString%28java.lang.Object%29) - [`Number`](com/oracle/truffle/api/interop/InteropLibrary.md#isNumber%28java.lang.Object%29) - [`Date`](com/oracle/truffle/api/interop/InteropLibrary.md#isDate%28java.lang.Object%29), [`Time`](com/oracle/truffle/api/interop/InteropLibrary.md#isTime%28java.lang.Object%29) or [`TimeZone`](com/oracle/truffle/api/interop/InteropLibrary.md#isTimeZone%28java.lang.Object%29) - [`Duration`](com/oracle/truffle/api/interop/InteropLibrary.md#isDuration%28java.lang.Object%29) - [`Exception`](com/oracle/truffle/api/interop/InteropLibrary.md#isException%28java.lang.Object%29) - [`Meta-Object`](com/oracle/truffle/api/interop/InteropLibrary.md#isMetaObject%28java.lang.Object%29) - [`Iterator`](com/oracle/truffle/api/interop/InteropLibrary.md#isIterator%28java.lang.Object%29) All receiver values may have none, one or multiple of the following traits: - [`executable`](com/oracle/truffle/api/interop/InteropLibrary.md#isExecutable%28java.lang.Object%29) - [`instantiable`](com/oracle/truffle/api/interop/InteropLibrary.md#isInstantiable%28java.lang.Object%29) - [`pointer`](com/oracle/truffle/api/interop/InteropLibrary.md#isPointer%28java.lang.Object%29) - [`members`](com/oracle/truffle/api/interop/InteropLibrary.md#hasMembers%28java.lang.Object%29) - [`static scope`](com/oracle/truffle/api/interop/InteropLibrary.md#hasStaticScope%28java.lang.Object%29) - [`hash entries`](com/oracle/truffle/api/interop/InteropLibrary.md#hasHashEntries%28java.lang.Object%29) - [`array elements`](com/oracle/truffle/api/interop/InteropLibrary.md#hasArrayElements%28java.lang.Object%29) - [`buffer elements`](com/oracle/truffle/api/interop/InteropLibrary.md#hasBufferElements%28java.lang.Object%29) - [`language`](com/oracle/truffle/api/interop/InteropLibrary.md#hasLanguage%28java.lang.Object%29) - [`associated metaobject`](com/oracle/truffle/api/interop/InteropLibrary.md#hasMetaObject%28java.lang.Object%29) - [`metaobject parents as array elements`](com/oracle/truffle/api/interop/InteropLibrary.md#hasMetaParents%28java.lang.Object%29) - [`declaring meta object`](com/oracle/truffle/api/interop/InteropLibrary.md#hasDeclaringMetaObject%28java.lang.Object%29) - [`source location`](com/oracle/truffle/api/interop/InteropLibrary.md#hasSourceLocation%28java.lang.Object%29) - [`identity`](com/oracle/truffle/api/interop/InteropLibrary.md#hasIdentity%28java.lang.Object%29) - [`scope parent`](com/oracle/truffle/api/interop/InteropLibrary.md#hasScopeParent%28java.lang.Object%29) - [`executable name`](com/oracle/truffle/api/interop/InteropLibrary.md#hasExecutableName%28java.lang.Object%29) - [`exception message`](com/oracle/truffle/api/interop/InteropLibrary.md#hasExceptionMessage%28java.lang.Object%29) - [`exception cause`](com/oracle/truffle/api/interop/InteropLibrary.md#hasExceptionCause%28java.lang.Object%29) - [`exception stack trace`](com/oracle/truffle/api/interop/InteropLibrary.md#hasExceptionStackTrace%28java.lang.Object%29) - [`iterator`](com/oracle/truffle/api/interop/InteropLibrary.md#hasIterator%28java.lang.Object%29) - [`bytecode index`](com/oracle/truffle/api/interop/InteropLibrary.md#hasBytecodeIndex%28java.lang.Object%29) ### Naive and aware dates and times If a date or time value has a [`timezone`](com/oracle/truffle/api/interop/InteropLibrary.md#isTimeZone%28java.lang.Object%29) then it is called *aware* , otherwise *naive* An aware time and date has sufficient knowledge of applicable algorithmic and political time adjustments, such as time zone and daylight saving time information, to locate itself relative to other aware objects. An aware object is used to represent a specific moment in time that is not open to interpretation. A naive time and date does not contain enough information to unambiguously locate itself relative to other date/time objects. Whether a naive object represents Coordinated Universal Time (UTC), local time, or time in some other timezone is purely up to the program, just like it is up to the program whether a particular number represents metres, miles, or mass. Naive objects are easy to understand and to work with, at the cost of ignoring some aspects of reality. Interop messages throw [`checked exceptions`](com/oracle/truffle/api/interop/InteropException.md) to indicate error states. The target language is supposed to always catch those exceptions and translate them into guest language errors of the target language. Interop message contracts are verified only if assertions (-ea) are enabled. **See also** - [`Reference documentation of Truffle Libraries.`](com/oracle/truffle/api/library/index.md) ## Constructors ### InteropLibrary() `protected InteropLibrary()`. Since 19.0. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#()` ## Methods ### isNull(Object) `public boolean isNull(Object receiver)`. Since 19.0. Returns `true` if the receiver represents a `null` like value, else `false`. Most object oriented languages have one or many values representing null values. Invoking this message does not cause any observable side-effects. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isNull(java.lang.Object)` ### isBoolean(Object) `public boolean isBoolean(Object receiver)`. Since 19.0. Returns `true` if the receiver represents a `boolean` like value, else `false`. Invoking this message does not cause any observable side-effects. See also: `asBoolean(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isBoolean(java.lang.Object)` ### asBoolean(Object) `public boolean asBoolean(Object receiver) throws UnsupportedMessageException`. Since 19.0. Returns the Java boolean value if the receiver represents a `boolean` like value. Throws: `UnsupportedMessageException`: if and only if `isBoolean(Object)` returns `false` for the same receiver. See also: `isBoolean(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#asBoolean(java.lang.Object)` ### isExecutable(Object) `public boolean isExecutable(Object receiver)`. Since 19.0. Returns `true` if the receiver represents an `executable` value, else `false`. Functions, methods or closures are common examples of executable values. Invoking this message does not cause any observable side-effects. Note that receiver values which are `executable` might also be `instantiable`. See also: `execute(Object, Object...)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isExecutable(java.lang.Object)` ### execute(Object, Object...) `public Object execute(Object receiver, Object... arguments) throws UnsupportedTypeException, ArityException, UnsupportedMessageException`. Since 19.0. Executes an executable value with the given arguments. Throws: `UnsupportedTypeException`: if one of the arguments is not compatible to the executable signature. The exception is thrown on best effort basis, dynamic languages may throw their own exceptions if the arguments are wrong. `ArityException`: if the number of expected arguments does not match the number of actual arguments. `UnsupportedMessageException`: if and only if `isExecutable(Object)` returns `false` for the same receiver. See also: `isExecutable(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#execute(java.lang.Object,java.lang.Object...)` ### hasExecutableName(Object) `public boolean hasExecutableName(Object receiver)`. Since 20.3. Returns `true` if the receiver has an executable name. Invoking this message does not cause any observable side-effects. Returns `false` by default. See also: `getExecutableName(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#hasExecutableName(java.lang.Object)` ### getExecutableName(Object) `public Object getExecutableName(Object receiver) throws UnsupportedMessageException`. Since 20.3. Returns executable name of the receiver. Throws `UnsupportedMessageException` when the receiver is has no `executable name`. The return value is an interop value that is guaranteed to return `true` for `isString(Object)`. This method must not cause any observable side-effects. See also: `hasExecutableName(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getExecutableName(java.lang.Object)` ### hasDeclaringMetaObject(Object) `public boolean hasDeclaringMetaObject(Object receiver)`. Since 20.3. Returns `true` if the receiver has a declaring meta object. The declaring meta object is the meta object of the executable or meta object that declares the receiver value. Invoking this message does not cause any observable side-effects. Returns `false` by default. See also: `getDeclaringMetaObject(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#hasDeclaringMetaObject(java.lang.Object)` ### getDeclaringMetaObject(Object) `public Object getDeclaringMetaObject(Object receiver) throws UnsupportedMessageException`. Since 20.3. Returns declaring meta object. The declaring meta object is the meta object of declaring executable or meta object. Throws `UnsupportedMessageException` when the receiver is has no `declaring meta object`. The return value is an interop value that is guaranteed to return `true` for `isMetaObject(Object)`. See also: `hasDeclaringMetaObject(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getDeclaringMetaObject(java.lang.Object)` ### isInstantiable(Object) `public boolean isInstantiable(Object receiver)`. Since 19.0. Returns `true` if the receiver represents an `instantiable` value, else `false`. Contructors or `metaobjects` are typical examples of instantiable values. Invoking this message does not cause any observable side-effects. Note that receiver values which are `executable` might also be `instantiable`. See also: `instantiate(Object, Object...)`, `isMetaObject(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isInstantiable(java.lang.Object)` ### instantiate(Object, Object...) `public Object instantiate(Object receiver, Object... arguments) throws UnsupportedTypeException, ArityException, UnsupportedMessageException`. Since 19.0. Instantiates the receiver value with the given arguments. The returned object must be initialized correctly according to the language specification (e.g. by calling the constructor or initialization routine). Throws: `UnsupportedTypeException`: if one of the arguments is not compatible to the executable signature. `ArityException`: if the number of expected arguments does not match the number of actual arguments. `UnsupportedMessageException`: if and only if `isInstantiable(Object)` returns `false` for the same receiver. See also: `isExecutable(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#instantiate(java.lang.Object,java.lang.Object...)` ### isString(Object) `public boolean isString(Object receiver)`. Since 19.0. Returns `true` if the receiver represents a `string` value, else `false`. Invoking this message does not cause any observable side-effects. See also: `asString(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isString(java.lang.Object)` ### asString(Object) `public String asString(Object receiver) throws UnsupportedMessageException`. Since 19.0. Returns the Java string value if the receiver represents a `string` like value. Throws: `UnsupportedMessageException`: if and only if `isString(Object)` returns `false` for the same receiver. See also: `isString(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#asString(java.lang.Object)` ### asTruffleString(Object) `public TruffleString asTruffleString(Object receiver) throws UnsupportedMessageException`. Since 21.3. Returns the `TruffleString` value if the receiver represents a `string` like value. Throws: `UnsupportedMessageException`: if and only if `isString(Object)` returns `false` for the same receiver. See also: `isString(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#asTruffleString(java.lang.Object)` ### isNumber(Object) `public boolean isNumber(Object receiver)`. Since 19.0. Returns `true` if the receiver represents a `number` value, else `false`. Invoking this message does not cause any observable side-effects. See also: `fitsInByte(Object)`, `fitsInShort(Object)`, `fitsInInt(Object)`, `fitsInLong(Object)`, `fitsInBigInteger(Object)`, `fitsInFloat(Object)`, `fitsInDouble(Object)`, `asByte(Object)`, `asShort(Object)`, `asInt(Object)`, `asLong(Object)`, `asBigInteger(Object)`, `asFloat(Object)`, `asDouble(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isNumber(java.lang.Object)` ### fitsInByte(Object) `public boolean fitsInByte(Object receiver)`. Since 19.0. Returns `true` if the receiver represents a `number` and its value fits in a Java byte primitive without loss of precision, else `false`. Invoking this message does not cause any observable side-effects. See also: `isNumber(Object)`, `asByte(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#fitsInByte(java.lang.Object)` ### fitsInShort(Object) `public boolean fitsInShort(Object receiver)`. Since 19.0. Returns `true` if the receiver represents a `number` and its value fits in a Java short primitive without loss of precision, else `false`. Invoking this message does not cause any observable side-effects. See also: `isNumber(Object)`, `asShort(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#fitsInShort(java.lang.Object)` ### fitsInInt(Object) `public boolean fitsInInt(Object receiver)`. Since 19.0. Returns `true` if the receiver represents a `number` and its value fits in a Java int primitive without loss of precision, else `false`. Invoking this message does not cause any observable side-effects. See also: `isNumber(Object)`, `asInt(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#fitsInInt(java.lang.Object)` ### fitsInLong(Object) `public boolean fitsInLong(Object receiver)`. Since 19.0. Returns `true` if the receiver represents a `number` and its value fits in a Java long primitive without loss of precision, else `false`. Invoking this message does not cause any observable side-effects. See also: `isNumber(Object)`, `asLong(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#fitsInLong(java.lang.Object)` ### fitsInBigInteger(Object) `public boolean fitsInBigInteger(Object receiver)`. Since 23.0. Returns `true` if the receiver represents a `number` and its value fits in a Java BigInteger without loss of precision, else `false`. Invoking this message does not cause any observable side-effects. See also: `isNumber(Object)`, `asBigInteger(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#fitsInBigInteger(java.lang.Object)` ### fitsInFloat(Object) `public boolean fitsInFloat(Object receiver)`. Since 19.0. Returns `true` if the receiver represents a `number` and its value fits in a Java float primitive without loss of precision, else `false`. Invoking this message does not cause any observable side-effects. See also: `isNumber(Object)`, `asFloat(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#fitsInFloat(java.lang.Object)` ### fitsInDouble(Object) `public boolean fitsInDouble(Object receiver)`. Since 19.0. Returns `true` if the receiver represents a `number` and its value fits in a Java double primitive without loss of precision, else `false`. Invoking this message does not cause any observable side-effects. See also: `isNumber(Object)`, `asDouble(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#fitsInDouble(java.lang.Object)` ### asByte(Object) `public byte asByte(Object receiver) throws UnsupportedMessageException`. Since 19.0. Returns the receiver value as Java byte primitive if the number fits without loss of precision. Invoking this message does not cause any observable side-effects. Throws: `UnsupportedMessageException`: if and only if the receiver is not a `isNumber(Object)` or it does not fit without loss of precision. See also: `isNumber(Object)`, `fitsInByte(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#asByte(java.lang.Object)` ### asShort(Object) `public short asShort(Object receiver) throws UnsupportedMessageException`. Since 19.0. Returns the receiver value as Java short primitive if the number fits without loss of precision. Invoking this message does not cause any observable side-effects. Throws: `UnsupportedMessageException`: if and only if the receiver is not a `isNumber(Object)` or it does not fit without loss of precision. See also: `isNumber(Object)`, `fitsInShort(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#asShort(java.lang.Object)` ### asInt(Object) `public int asInt(Object receiver) throws UnsupportedMessageException`. Since 19.0. Returns the receiver value as Java int primitive if the number fits without loss of precision. Invoking this message does not cause any observable side-effects. Throws: `UnsupportedMessageException`: if and only if the receiver is not a `isNumber(Object)` or it does not fit without loss of precision. See also: `isNumber(Object)`, `fitsInInt(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#asInt(java.lang.Object)` ### asLong(Object) `public long asLong(Object receiver) throws UnsupportedMessageException`. Since 19.0. Returns the receiver value as Java long primitive if the number fits without loss of precision. Invoking this message does not cause any observable side-effects. Throws: `UnsupportedMessageException`: if and only if the receiver is not a `isNumber(Object)` or it does not fit without loss of precision. See also: `isNumber(Object)`, `fitsInLong(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#asLong(java.lang.Object)` ### asBigInteger(Object) `public BigInteger asBigInteger(Object receiver) throws UnsupportedMessageException`. Since 23.0. Returns the receiver value as Java BigInteger if the number fits without loss of precision. Invoking this message does not cause any observable side-effects. Throws: `UnsupportedMessageException`: if and only if the receiver is not a `isNumber(Object)` or it does not fit without loss of precision. See also: `isNumber(Object)`, `fitsInBigInteger(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#asBigInteger(java.lang.Object)` ### asFloat(Object) `public float asFloat(Object receiver) throws UnsupportedMessageException`. Since 19.0. Returns the receiver value as Java float primitive if the number fits without loss of precision. Invoking this message does not cause any observable side-effects. Throws: `UnsupportedMessageException`: if and only if the receiver is not a `isNumber(Object)` or it does not fit without loss of precision. See also: `isNumber(Object)`, `fitsInFloat(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#asFloat(java.lang.Object)` ### asDouble(Object) `public double asDouble(Object receiver) throws UnsupportedMessageException`. Since 19.0. Returns the receiver value as Java double primitive if the number fits without loss of precision. Invoking this message does not cause any observable side-effects. Throws: `UnsupportedMessageException`: if and only if the receiver is not a `isNumber(Object)` or it does not fit without loss of precision. See also: `isNumber(Object)`, `fitsInDouble(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#asDouble(java.lang.Object)` ### hasMembers(Object) `public boolean hasMembers(Object receiver)`. Since 19.0. Returns `true` if the receiver may have members. Therefore, at least one of `readMember(Object, String)`, `writeMember(Object, String, Object)`, `removeMember(Object, String)`, `invokeMember(Object, String, Object...)` must not throw `UnsupportedMessageException`. Members are structural elements of a class. For example, a method or field is a member of a class. Invoking this message does not cause any observable side-effects. Returns `false` by default. See also: `getMembers(Object, boolean)`, `isMemberReadable(Object, String)`, `isMemberModifiable(Object, String)`, `isMemberInvocable(Object, String)`, `isMemberInsertable(Object, String)`, `isMemberRemovable(Object, String)`, `readMember(Object, String)`, `writeMember(Object, String, Object)`, `removeMember(Object, String)`, `invokeMember(Object, String, Object...)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#hasMembers(java.lang.Object)` ### hasBytecodeIndex(Object) `public boolean hasBytecodeIndex(Object receiver)`. Since 25.1. Determines whether the given receiver provides a bytecode index. For example, a stack frame object may provide a bytecode index. Calling this message does not produce any observable side effects. The default implementation returns `false`. See also: `getBytecodeIndex(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#hasBytecodeIndex(java.lang.Object)` ### getBytecodeIndex(Object) `public int getBytecodeIndex(Object receiver) throws UnsupportedMessageException`. Since 25.1. Returns bytecode index of the receiver. Throws `UnsupportedMessageException` when the receiver does not provide a `bytecode index` or has no bytecode index. See also: `hasBytecodeIndex(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getBytecodeIndex(java.lang.Object)` ### isInternal(Object) `public boolean isInternal(Object receiver)`. Since 25.1. Determines whether the given receiver represents an internal object. For example, a stack frame object may be marked as internal so that it can be excluded from a stack trace shown to the user. Calling this message does not produce any observable side effects. The default implementation returns `false`. See also: `getLanguageId(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isInternal(java.lang.Object)` ### getMembers(Object, boolean) `public Object getMembers(Object receiver, boolean includeInternal) throws UnsupportedMessageException`. Since 19.0. Returns an array of member name strings. The returned value must return `true` for `hasArrayElements(Object)` and every array element must be of type `string`. The member elements may also provide additional information like `source location` in case of `scope` variables, etc. The order of member names needs to be: deterministic, assuming the program execution is deterministic,; in the declaration order, when applicable,; multiple invocations of this method must return the same members in the same order as long as no side-effecting operations were performed. If the includeInternal argument is `true` then internal member names are returned as well. Internal members are implementation specific and should not be exposed to guest language application. An example of internal members are internal slots in ECMAScript. Throws: `UnsupportedMessageException`: if and only if the receiver does not have any `members`. See also: `hasMembers(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getMembers(java.lang.Object,boolean)` ### getMembers(Object) `public final Object getMembers(Object receiver) throws UnsupportedMessageException`. Since 19.0. Short-cut for `getMembers(receiver, false)`. Invoking this message does not cause any observable side-effects. Throws: `UnsupportedMessageException`: if and only if the receiver has no `members`. See also: `getMembers(Object, boolean)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getMembers(java.lang.Object)` ### isMemberReadable(Object, String) `public boolean isMemberReadable(Object receiver, String member)`. Since 19.0. Returns `true` if a given member is `readable`. This method may only return `true` if `hasMembers(Object)` returns `true` as well and `isMemberInsertable(Object, String)` returns `false`. Invoking this message does not cause any observable side-effects. Returns `false` by default. See also: `readMember(Object, String)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isMemberReadable(java.lang.Object,java.lang.String)` ### readMember(Object, String) `public Object readMember(Object receiver, String member) throws UnsupportedMessageException, UnknownIdentifierException`. Since 19.0. Reads the value of a given member. In case of a method-like member, we recommend that languages return a bound method (or an artificial receiver-method binding) to improve cross-language portability. In this case, the member should be `readable` and `invocable` and the result of reading the member should be `executable` and bound to the receiver. This message must have not observable side-effects unless `hasMemberReadSideEffects(Object, String)` returns `true`. Throws: `UnsupportedMessageException`: if when the receiver does not support reading at all. An empty receiver with no readable members supports the read operation (even though there is nothing to read), therefore it throws `UnknownIdentifierException` for all arguments instead. `UnknownIdentifierException`: if the given member cannot be read, e.g. because it is not (or no longer) `readable` such as when the member with the given name does not exist or has been removed. See also: `hasMemberReadSideEffects(Object, String)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#readMember(java.lang.Object,java.lang.String)` ### isMemberModifiable(Object, String) `public boolean isMemberModifiable(Object receiver, String member)`. Since 19.0. Returns `true` if a given member is existing and `writable`. This method may only return `true` if `hasMembers(Object)` returns `true` as well and `isMemberInsertable(Object, String)` returns `false`. Invoking this message does not cause any observable side-effects. Returns `false` by default. See also: `writeMember(Object, String, Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isMemberModifiable(java.lang.Object,java.lang.String)` ### isMemberInsertable(Object, String) `public boolean isMemberInsertable(Object receiver, String member)`. Since 19.0. Returns `true` if a given member is not existing and `writable`. This method may only return `true` if `hasMembers(Object)` returns `true` as well and `isMemberExisting(Object, String)` returns `false`. Invoking this message does not cause any observable side-effects. Returns `false` by default. See also: `writeMember(Object, String, Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isMemberInsertable(java.lang.Object,java.lang.String)` ### writeMember(Object, String, Object) `public void writeMember(Object receiver, String member, Object value) throws UnsupportedMessageException, UnknownIdentifierException, UnsupportedTypeException`. Since 19.0. Writes the value of a given member. Writing a member is allowed if is existing and `modifiable`, or not existing and `insertable`. This method must have no observable side-effects other than the changed member unless `side-effects` are allowed. Throws: `UnsupportedMessageException`: when the receiver does not support writing at all, e.g. when it is immutable. `UnknownIdentifierException`: if the given member is not `modifiable` nor `insertable`. `UnsupportedTypeException`: if the provided value type is not allowed to be written. See also: `hasMemberWriteSideEffects(Object, String)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#writeMember(java.lang.Object,java.lang.String,java.lang.Object)` ### isMemberRemovable(Object, String) `public boolean isMemberRemovable(Object receiver, String member)`. Since 19.0. Returns `true` if a given member is existing and removable. This method may only return `true` if `hasMembers(Object)` returns `true` as well and `isMemberInsertable(Object, String)` returns `false`. Invoking this message does not cause any observable side-effects. Returns `false` by default. See also: `removeMember(Object, String)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isMemberRemovable(java.lang.Object,java.lang.String)` ### removeMember(Object, String) `public void removeMember(Object receiver, String member) throws UnsupportedMessageException, UnknownIdentifierException`. Since 19.0. Removes a member from the receiver object. Removing member is allowed if is `removable`. This method does not have not observable side-effects other than the removed member. Throws: `UnsupportedMessageException`: when the receiver does not support removing at all, e.g. when it is immutable. `UnknownIdentifierException`: if the given member is not `isMemberRemovable(Object, String)` removable}, e.g. the receiver does not have a member with the given name. See also: `isMemberRemovable(Object, String)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#removeMember(java.lang.Object,java.lang.String)` ### isMemberInvocable(Object, String) `public boolean isMemberInvocable(Object receiver, String member)`. Since 19.0. Returns `true` if a given member is invocable. This method may only return `true` if `hasMembers(Object)` returns `true` as well and `isMemberInsertable(Object, String)` returns `false`. Invoking this message does not cause any observable side-effects. Returns `false` by default. See also: `invokeMember(Object, String, Object...)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isMemberInvocable(java.lang.Object,java.lang.String)` ### invokeMember(Object, String, Object...) `public Object invokeMember(Object receiver, String member, Object... arguments) throws UnsupportedMessageException, ArityException, UnknownIdentifierException, UnsupportedTypeException`. Since 19.0. Invokes a member for a given receiver and arguments. Throws: `UnknownIdentifierException`: if the given member does not exist or is not `invocable`. `UnsupportedTypeException`: if one of the arguments is not compatible to the executable signature. The exception is thrown on best effort basis, dynamic languages may throw their own exceptions if the arguments are wrong. `ArityException`: if the number of expected arguments does not match the number of actual arguments. `UnsupportedMessageException`: when the receiver does not support invoking at all, e.g. when storing executable members is not allowed. See also: `isMemberInvocable(Object, String)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#invokeMember(java.lang.Object,java.lang.String,java.lang.Object...)` ### isMemberInternal(Object, String) `public boolean isMemberInternal(Object receiver, String member)`. Since 19.0. Returns true if a member is internal. Internal members are not enumerated by `getMembers(Object, boolean)` by default. Internal members are only relevant to guest language implementations and tools, but not to guest applications or embedders. An example of internal members are internal slots in ECMAScript. Invoking this message does not cause any observable side-effects. Returns `false` by default. See also: `getMembers(Object, boolean)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isMemberInternal(java.lang.Object,java.lang.String)` ### isMemberWritable(Object, String) `public final boolean isMemberWritable(Object receiver, String member)`. Since 19.0. Returns true if the member is `modifiable` or `insertable`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isMemberWritable(java.lang.Object,java.lang.String)` ### isMemberExisting(Object, String) `public final boolean isMemberExisting(Object receiver, String member)`. Since 19.0. Returns true if the member is existing. A member is existing if it is `modifiable`, `readable`, `removable` or `invocable`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isMemberExisting(java.lang.Object,java.lang.String)` ### hasMemberReadSideEffects(Object, String) `public boolean hasMemberReadSideEffects(Object receiver, String member)`. Since 19.0. Returns `true` if reading a member may cause a side-effect. Invoking this message does not cause any observable side-effects. A member read does not cause any side-effects by default. For instance in JavaScript a property read may have side-effects if the property has a getter function. See also: `readMember(Object, String)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#hasMemberReadSideEffects(java.lang.Object,java.lang.String)` ### hasMemberWriteSideEffects(Object, String) `public boolean hasMemberWriteSideEffects(Object receiver, String member)`. Since 19.0. Returns `true` if writing a member may cause a side-effect, besides the write operation of the member. Invoking this message does not cause any observable side-effects. A member write does not cause any side-effects by default. For instance in JavaScript a property write may have side-effects if the property has a setter function. See also: `writeMember(Object, String, Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#hasMemberWriteSideEffects(java.lang.Object,java.lang.String)` ### hasStaticScope(Object) `public boolean hasStaticScope(Object receiver)`. Since 25.1. Returns `true` if the given receiver is a meta object that provides a static scope. A static scope represents the static or class-level members associated with the receiver's type, such as static fields or methods. Invoking this message must not cause any observable side effects. Only `meta objects` are permitted to expose a static scope, for all non-meta objects this method must return `false`. By default, this method returns `false`. See also: `getStaticScope(Object)`, `isMetaObject(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#hasStaticScope(java.lang.Object)` ### getStaticScope(Object) `public Object getStaticScope(Object receiver) throws UnsupportedMessageException`. Since 25.1. Returns the static scope associated with the given receiver. The receiver must be a meta object. A static scope is an object that exposes static members, members whose values or behaviors are independent of any particular instance of the receiver. The static scope typically serves as an artificial or meta-level object that provides access to instance-independent members declared by the meta object. The returned object can be used as the receiver for interop messages such as `readMember`, `writeMember`, and `invokeMember` when accessing static members. The returned static scope is always expected to be a `scope` and provide `members`, representing the receiver's static context. **Examples:** In Java, the static scope exposes static fields and methods of a class.; In Python, the static scope exposes class-level attributes and methods, effectively corresponding to the members provided by the Python metaobject. Throws: `UnsupportedMessageException`: if and only if the receiver does not have a static scope. See also: `hasStaticScope(Object)`, `isMetaObject(Object)`, `isScope(Object)`, `hasMembers(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getStaticScope(java.lang.Object)` ### hasHashEntries(Object) `public boolean hasHashEntries(Object receiver)`. Since 21.1. Returns `true` if the receiver may have hash entries. Therefore, at least one of `readHashValue(Object, Object)`, `writeHashEntry(Object, Object, Object)`, `removeHashEntry(Object, Object)` must not throw `UnsupportedMessageException`. For example, the contents of a map data structure could be interpreted as hash elements. Invoking this message does not cause any observable side-effects. Returns `false` by default. See also: `getHashEntriesIterator(Object)`, `getHashSize(Object)`, `isHashEntryReadable(Object, Object)`, `isHashEntryWritable(Object, Object)`, `isHashEntryInsertable(Object, Object)`, `isHashEntryRemovable(Object, Object)`, `readHashValue(Object, Object)`, `readHashValueOrDefault(Object, Object, Object)`, `writeHashEntry(Object, Object, Object)`, `removeHashEntry(Object, Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#hasHashEntries(java.lang.Object)` ### getHashSize(Object) `public long getHashSize(Object receiver) throws UnsupportedMessageException`. Since 21.1. Returns the number of receiver entries. Throws: `UnsupportedMessageException`: if and only if `hasHashEntries(Object)` returns `false`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getHashSize(java.lang.Object)` ### isHashEntryReadable(Object, Object) `public boolean isHashEntryReadable(Object receiver, Object key)`. Since 21.1. Returns `true` if mapping for the specified key exists and is `readable`. This method may only return `true` if `hasHashEntries(Object)` returns `true` as well and `isHashEntryInsertable(Object, Object)` returns `false`. Invoking this message does not cause any observable side-effects. Returns `false` by default. See also: `readHashValue(Object, Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isHashEntryReadable(java.lang.Object,java.lang.Object)` ### readHashValue(Object, Object) `public Object readHashValue(Object receiver, Object key) throws UnsupportedMessageException, UnknownKeyException`. Since 21.1. Reads the value for the specified key. Throws: `UnsupportedMessageException`: if the receiver does not support reading at all. An empty receiver with no readable hash entries supports the read operation (even though there is nothing to read), therefore it throws `UnknownKeyException` for all arguments instead. `UnknownKeyException`: if mapping for the specified key is not `readable`, e.g. when the hash does not contain specified key. See also: `isHashEntryReadable(Object, Object)`, `readHashValueOrDefault(Object, Object, Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#readHashValue(java.lang.Object,java.lang.Object)` ### readHashValueOrDefault(Object, Object, Object) `public Object readHashValueOrDefault(Object receiver, Object key, Object defaultValue) throws UnsupportedMessageException`. Since 21.1. Reads the value for the specified key or returns the `defaultValue` when the mapping for the specified key does not exist or is not readable. Throws: `UnsupportedMessageException`: if the receiver does not support reading at all. An empty receiver with no readable hash entries supports the read operation (even though there is nothing to read), therefore it returns the `defaultValue` for all arguments instead. See also: `isHashEntryReadable(Object, Object)`, `readHashValue(Object, Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#readHashValueOrDefault(java.lang.Object,java.lang.Object,java.lang.Object)` ### isHashEntryModifiable(Object, Object) `public boolean isHashEntryModifiable(Object receiver, Object key)`. Since 21.1. Returns `true` if mapping for the specified key exists and is `writable`. This method may only return `true` if `hasHashEntries(Object)` returns `true` as well and `isHashEntryInsertable(Object, Object)` returns `false`. Invoking this message does not cause any observable side-effects. Returns `false` by default. See also: `writeHashEntry(Object, Object, Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isHashEntryModifiable(java.lang.Object,java.lang.Object)` ### isHashEntryInsertable(Object, Object) `public boolean isHashEntryInsertable(Object receiver, Object key)`. Since 21.1. Returns `true` if mapping for the specified key does not exist and is `writable`. This method may only return `true` if `hasHashEntries(Object)` returns `true` as well and `isHashEntryExisting(Object, Object)` returns `false`. Invoking this message does not cause any observable side-effects. Returns `false` by default. See also: `writeHashEntry(Object, Object, Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isHashEntryInsertable(java.lang.Object,java.lang.Object)` ### isHashEntryWritable(Object, Object) `public boolean isHashEntryWritable(Object receiver, Object key)`. Since 21.1. Returns `true` if mapping for the specified key is `modifiable` or `insertable`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isHashEntryWritable(java.lang.Object,java.lang.Object)` ### writeHashEntry(Object, Object, Object) `public void writeHashEntry(Object receiver, Object key, Object value) throws UnsupportedMessageException, UnknownKeyException, UnsupportedTypeException`. Since 21.1. Associates the specified value with the specified key in the receiver. Writing the entry is allowed if is existing and `modifiable`, or not existing and `insertable`. Throws: `UnsupportedMessageException`: when the receiver does not support writing at all, e.g. when it is immutable. `UnknownKeyException`: if mapping for the specified key is not `modifiable` nor `insertable`. `UnsupportedTypeException`: if the provided key type or value type is not allowed to be written. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#writeHashEntry(java.lang.Object,java.lang.Object,java.lang.Object)` ### isHashEntryRemovable(Object, Object) `public boolean isHashEntryRemovable(Object receiver, Object key)`. Since 21.1. Returns `true` if mapping for the specified key exists and is removable. This method may only return `true` if `hasHashEntries(Object)` returns `true` as well and `isHashEntryInsertable(Object, Object)` returns `false`. Invoking this message does not cause any observable side-effects. Returns `false` by default. See also: `removeHashEntry(Object, Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isHashEntryRemovable(java.lang.Object,java.lang.Object)` ### removeHashEntry(Object, Object) `public void removeHashEntry(Object receiver, Object key) throws UnsupportedMessageException, UnknownKeyException`. Since 21.1. Removes the mapping for a given key from the receiver. Mapping removing is allowed if it is `removable`. Throws: `UnsupportedMessageException`: when the receiver does not support removing at all, e.g. when it is immutable. `UnknownKeyException`: if the given mapping is not `removable`, e.g. the receiver does not have a mapping for given key. See also: `isHashEntryRemovable(Object, Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#removeHashEntry(java.lang.Object,java.lang.Object)` ### isHashEntryExisting(Object, Object) `public boolean isHashEntryExisting(Object receiver, Object key)`. Since 21.1. Returns `true` if mapping for a given key is existing. The mapping is existing if it is `modifiable`, `readable` or `removable`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isHashEntryExisting(java.lang.Object,java.lang.Object)` ### getHashEntriesIterator(Object) `public Object getHashEntriesIterator(Object receiver) throws UnsupportedMessageException`. Since 21.1. Returns the hash entries iterator for the receiver. The return value is always an `iterator` of `array` elements. The first array element is a key, the second array element is an associated value. Array returned by the iterator may be modifiable but detached from the hash, updating the array elements may not update the hash. So even if array elements are `modifiable` always use `writeHashEntry(Object, Object, Object)` to update the hash mapping. Throws: `UnsupportedMessageException`: if and only if `hasHashEntries(Object)` returns `false` for the same receiver. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getHashEntriesIterator(java.lang.Object)` ### getHashKeysIterator(Object) `public Object getHashKeysIterator(Object receiver) throws UnsupportedMessageException`. Since 21.1. Returns the hash keys iterator for the receiver. The return value is always an `iterator`. Throws: `UnsupportedMessageException`: if and only if `hasHashEntries(Object)` returns `false` for the same receiver. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getHashKeysIterator(java.lang.Object)` ### getHashValuesIterator(Object) `public Object getHashValuesIterator(Object receiver) throws UnsupportedMessageException`. Since 21.1. Returns the hash values iterator for the receiver. The return value is always an `iterator`. Throws: `UnsupportedMessageException`: if and only if `hasHashEntries(Object)` returns `false` for the same receiver. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getHashValuesIterator(java.lang.Object)` ### hasArrayElements(Object) `public boolean hasArrayElements(Object receiver)`. Since 19.0. Returns `true` if the receiver may have array elements. Therefore, At least one of `readArrayElement(Object, long)`, `writeArrayElement(Object, long, Object)`, `removeArrayElement(Object, long)` must not throw {#link `UnsupportedMessageException`. For example, the contents of an array or list datastructure could be interpreted as array elements. Invoking this message does not cause any observable side-effects. Returns `false` by default. See also: `getArraySize(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#hasArrayElements(java.lang.Object)` ### readArrayElement(Object, long) `public Object readArrayElement(Object receiver, long index) throws UnsupportedMessageException, InvalidArrayIndexException`. Since 19.0. Reads the value of an array element by index. This method must have not observable side-effect. Throws: `UnsupportedMessageException`: when the receiver does not support reading at all. An empty receiver with no readable array elements supports the read operation (even though there is nothing to read), therefore it throws `UnknownIdentifierException` for all arguments instead. `InvalidArrayIndexException`: if the given index is not `readable`, e.g. when the index is invalid or the index is out of bounds. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#readArrayElement(java.lang.Object,long)` ### getArraySize(Object) `public long getArraySize(Object receiver) throws UnsupportedMessageException`. Since 19.0. Returns the array size of the receiver. Throws: `UnsupportedMessageException`: if and only if `hasArrayElements(Object)` returns `false`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getArraySize(java.lang.Object)` ### isArrayElementReadable(Object, long) `public boolean isArrayElementReadable(Object receiver, long index)`. Since 19.0. Returns `true` if a given array element is `readable`. This method may only return `true` if `hasArrayElements(Object)` returns `true` as well. Invoking this message does not cause any observable side-effects. Returns `false` by default. See also: `readArrayElement(Object, long)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isArrayElementReadable(java.lang.Object,long)` ### writeArrayElement(Object, long, Object) `public void writeArrayElement(Object receiver, long index, Object value) throws UnsupportedMessageException, UnsupportedTypeException, InvalidArrayIndexException`. Since 19.0. Writes the value of an array element by index. Writing an array element is allowed if is existing and `modifiable`, or not existing and `insertable`. This method must have not observable side-effects other than the changed array element. Throws: `UnsupportedMessageException`: when the receiver does not support writing at all, e.g. when it is immutable. `InvalidArrayIndexException`: if the given index is not `insertable` nor `modifiable`, e.g. when the index is invalid or the index is out of bounds and the array does not support growing. `UnsupportedTypeException`: if the provided value type is not allowed to be written. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#writeArrayElement(java.lang.Object,long,java.lang.Object)` ### removeArrayElement(Object, long) `public void removeArrayElement(Object receiver, long index) throws UnsupportedMessageException, InvalidArrayIndexException`. Since 19.0. Remove an array element from the receiver object. Removing member is allowed if the array element is `removable`. This method may only return `true` if `hasArrayElements(Object)` returns `true` as well and `isArrayElementInsertable(Object, long)` returns `false`. This method does not have observable side-effects other than the removed array element and shift of remaining elements. If shifting is not supported then the array might allow only removal of last element. Throws: `UnsupportedMessageException`: when the receiver does not support removing at all, e.g. when it is immutable. `InvalidArrayIndexException`: if the given index is not `removable`, e.g. when the index is invalid, the index is out of bounds, or the array does not support shifting of remaining elements. See also: `isArrayElementRemovable(Object, long)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#removeArrayElement(java.lang.Object,long)` ### isArrayElementModifiable(Object, long) `public boolean isArrayElementModifiable(Object receiver, long index)`. Since 19.0. Returns `true` if a given array element index is existing and `writable`. This method may only return `true` if `hasArrayElements(Object)` returns `true` as well and `isArrayElementInsertable(Object, long)` returns `false`. Invoking this message does not cause any observable side-effects. Returns `false` by default. See also: `writeArrayElement(Object, long, Object)`, `isArrayElementInsertable(Object, long)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isArrayElementModifiable(java.lang.Object,long)` ### isArrayElementInsertable(Object, long) `public boolean isArrayElementInsertable(Object receiver, long index)`. Since 19.0. Returns `true` if a given array element index is not existing and `insertable`. This method may only return `true` if `hasArrayElements(Object)` returns `true` as well and `isArrayElementExisting(Object, long)`} returns `false`. Invoking this message does not cause any observable side-effects. Returns `false` by default. See also: `writeArrayElement(Object, long, Object)`, `isArrayElementModifiable(Object, long)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isArrayElementInsertable(java.lang.Object,long)` ### isArrayElementRemovable(Object, long) `public boolean isArrayElementRemovable(Object receiver, long index)`. Since 19.0. Returns `true` if a given array element index is existing and `removable`. This method may only return `true` if `hasArrayElements(Object)` returns `true` as well and `isArrayElementInsertable(Object, long)`} returns `false`. Invoking this message does not cause any observable side-effects. Returns `false` by default. See also: `removeArrayElement(Object, long)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isArrayElementRemovable(java.lang.Object,long)` ### isArrayElementWritable(Object, long) `public final boolean isArrayElementWritable(Object receiver, long index)`. Since 19.0. Returns true if the array element is `modifiable` or `insertable`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isArrayElementWritable(java.lang.Object,long)` ### isArrayElementExisting(Object, long) `public final boolean isArrayElementExisting(Object receiver, long index)`. Since 19.0. Returns true if the array element is existing. An array element is existing if it is, `modifiable`, `readable` or `removable`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isArrayElementExisting(java.lang.Object,long)` ### hasBufferElements(Object) `public boolean hasBufferElements(Object receiver)`. Since 21.1. Returns `true` if the receiver may have buffer elements. If this message returns `true`, then `getBufferSize(Object)`, `readBufferByte(Object, long)`, `readBufferShort(Object, ByteOrder, long)`, `readBufferInt(Object, ByteOrder, long)`, `readBufferLong(Object, ByteOrder, long)`, `readBufferFloat(Object, ByteOrder, long)` and `readBufferDouble(Object, ByteOrder, long)` must not throw `UnsupportedMessageException`. Invoking this message does not cause any observable side-effects. By default, it returns `false`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#hasBufferElements(java.lang.Object)` ### isBufferWritable(Object) `public boolean isBufferWritable(Object receiver) throws UnsupportedMessageException`. Since 21.1. Returns `true` if the receiver is a modifiable buffer. If this message returns `true`, then `getBufferSize(Object)`, `writeBufferByte(Object, long, byte)`, `writeBufferShort(Object, ByteOrder, long, short)`, `writeBufferInt(Object, ByteOrder, long, int)`, `writeBufferLong(Object, ByteOrder, long, long)`, `writeBufferFloat(Object, ByteOrder, long, float)` and `writeBufferDouble(Object, ByteOrder, long, double)` must not throw `UnsupportedMessageException`. Invoking this message does not cause any observable side-effects. By default, it returns `false` if `hasBufferElements(Object)` return `true`, and throws `UnsupportedMessageException` otherwise. Throws: `UnsupportedMessageException`: if and only if `hasBufferElements(Object)` returns `false`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isBufferWritable(java.lang.Object)` ### getBufferSize(Object) `public long getBufferSize(Object receiver) throws UnsupportedMessageException`. Since 21.1. Returns the buffer size of the receiver, in bytes. Invoking this message does not cause any observable side-effects. Throws: `UnsupportedMessageException`: if and only if `hasBufferElements(Object)` returns `false`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getBufferSize(java.lang.Object)` ### readBufferByte(Object, long) `public byte readBufferByte(Object receiver, long byteOffset) throws UnsupportedMessageException, InvalidBufferOffsetException`. Since 21.1. Reads the byte from the receiver object at the given byte offset from the start of the buffer. The access is *not* guaranteed to be atomic. Therefore, this message is *not* thread-safe. Invoking this message does not cause any observable side-effects. Returns `byte`: the byte at the given index. Throws: `InvalidBufferOffsetException`: if and only if `byteOffset < 0 || byteOffset >= ``getBufferSize(Object)`. `UnsupportedMessageException`: if and only if `hasBufferElements(Object)` returns `false`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#readBufferByte(java.lang.Object,long)` ### readBuffer(Object, long, …) `public void readBuffer(Object receiver, long byteOffset, byte[] destination, int destinationOffset, int length) throws UnsupportedMessageException, InvalidBufferOffsetException`. Since 24.0. Reads bytes from the receiver object into the specified byte array. The access is *not* guaranteed to be atomic. Therefore, this message is *not* thread-safe. Invoking this message does not cause any observable side-effects. Parameters: `byteOffset` `long`: offset in the buffer to start reading from. `destination` `byte[]`: byte array to write the read bytes into. `destinationOffset` `int`: offset in the destination array to start writing from. `length` `int`: number of bytes to read. Throws: `InvalidBufferOffsetException`: if and only if `byteOffset < 0 || length < 0 || byteOffset + length > ``getBufferSize(Object)`. `UnsupportedMessageException`: if and only if `hasBufferElements(Object)` returns `false`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#readBuffer(java.lang.Object,long,byte[],int,int)` ### writeBufferByte(Object, long, byte) `public void writeBufferByte(Object receiver, long byteOffset, byte value) throws UnsupportedMessageException, InvalidBufferOffsetException`. Since 21.1. Writes the given byte from the receiver object at the given byte offset from the start of the buffer. The access is *not* guaranteed to be atomic. Therefore, this message is *not* thread-safe. Throws: `InvalidBufferOffsetException`: if and only if `byteOffset < 0 || byteOffset >= ``getBufferSize(Object)`. `UnsupportedMessageException`: if and only if either `hasBufferElements(Object)` or `isBufferWritable` returns `false`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#writeBufferByte(java.lang.Object,long,byte)` ### readBufferShort(Object, ByteOrder, long) `public short readBufferShort(Object receiver, ByteOrder order, long byteOffset) throws UnsupportedMessageException, InvalidBufferOffsetException`. Since 21.1. Reads the short from the receiver object in the given byte order at the given byte offset from the start of the buffer. Unaligned accesses are supported. The access is *not* guaranteed to be atomic. Therefore, this message is *not* thread-safe. Invoking this message does not cause any observable side-effects. Returns `short`: the short at the given byte offset from the start of the buffer. Throws: `InvalidBufferOffsetException`: if and only if `byteOffset ``<`` 0 || byteOffset ``>``= ``getBufferSize(Object)`` - 1`. `UnsupportedMessageException`: if and only if `hasBufferElements(Object)` returns `false`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#readBufferShort(java.lang.Object,java.nio.ByteOrder,long)` ### writeBufferShort(Object, ByteOrder, …) `public void writeBufferShort(Object receiver, ByteOrder order, long byteOffset, short value) throws UnsupportedMessageException, InvalidBufferOffsetException`. Since 21.1. Writes the given short from the receiver object in the given byte order at the given byte offset from the start of the buffer. Unaligned accesses are supported. The access is *not* guaranteed to be atomic. Therefore, this message is *not* thread-safe. Throws: `InvalidBufferOffsetException`: if and only if `byteOffset ``<`` 0 || byteOffset ``>``= ``getBufferSize(Object)`` - 1`. `UnsupportedMessageException`: if and only if either `hasBufferElements(Object)` or `isBufferWritable` returns `false`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#writeBufferShort(java.lang.Object,java.nio.ByteOrder,long,short)` ### readBufferInt(Object, ByteOrder, long) `public int readBufferInt(Object receiver, ByteOrder order, long byteOffset) throws UnsupportedMessageException, InvalidBufferOffsetException`. Since 21.1. Reads the int from the receiver object in the given byte order at the given byte offset from the start of the buffer. Unaligned accesses are supported. The access is *not* guaranteed to be atomic. Therefore, this message is *not* thread-safe. Invoking this message does not cause any observable side-effects. Returns `int`: the int at the given byte offset from the start of the buffer. Throws: `InvalidBufferOffsetException`: if and only if `byteOffset ``<`` 0 || byteOffset ``>``= ``getBufferSize(Object)`` - 3`. `UnsupportedMessageException`: if and only if `hasBufferElements(Object)` returns `false`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#readBufferInt(java.lang.Object,java.nio.ByteOrder,long)` ### writeBufferInt(Object, ByteOrder, …) `public void writeBufferInt(Object receiver, ByteOrder order, long byteOffset, int value) throws UnsupportedMessageException, InvalidBufferOffsetException`. Since 21.1. Writes the given int from the receiver object in the given byte order at the given byte offset from the start of the buffer. Unaligned accesses are supported. The access is *not* guaranteed to be atomic. Therefore, this message is *not* thread-safe. Throws: `InvalidBufferOffsetException`: if and only if `byteOffset ``<`` 0 || byteOffset ``>``= ``getBufferSize(Object)`` - 3`. `UnsupportedMessageException`: if and only if either `hasBufferElements(Object)` or `isBufferWritable` returns `false`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#writeBufferInt(java.lang.Object,java.nio.ByteOrder,long,int)` ### readBufferLong(Object, ByteOrder, long) `public long readBufferLong(Object receiver, ByteOrder order, long byteOffset) throws UnsupportedMessageException, InvalidBufferOffsetException`. Since 21.1. Reads the long from the receiver object in the given byte order at the given byte offset from the start of the buffer. Unaligned accesses are supported. The access is *not* guaranteed to be atomic. Therefore, this message is *not* thread-safe. Invoking this message does not cause any observable side-effects. Returns `long`: the int at the given byte offset from the start of the buffer. Throws: `InvalidBufferOffsetException`: if and only if `byteOffset ``<`` 0 || byteOffset ``>``= ``getBufferSize(Object)`` - 7`. `UnsupportedMessageException`: if and only if `hasBufferElements(Object)` returns `false`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#readBufferLong(java.lang.Object,java.nio.ByteOrder,long)` ### writeBufferLong(Object, ByteOrder, …) `public void writeBufferLong(Object receiver, ByteOrder order, long byteOffset, long value) throws UnsupportedMessageException, InvalidBufferOffsetException`. Since 21.1. Writes the given long from the receiver object in the given byte order at the given byte offset from the start of the buffer. Unaligned accesses are supported. The access is *not* guaranteed to be atomic. Therefore, this message is *not* thread-safe. Throws: `InvalidBufferOffsetException`: if and only if `byteOffset ``<`` 0 || byteOffset ``>``= ``getBufferSize(Object)`` - 7`. `UnsupportedMessageException`: if and only if either `hasBufferElements(Object)` or `isBufferWritable` returns `false`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#writeBufferLong(java.lang.Object,java.nio.ByteOrder,long,long)` ### readBufferFloat(Object, ByteOrder, long) `public float readBufferFloat(Object receiver, ByteOrder order, long byteOffset) throws UnsupportedMessageException, InvalidBufferOffsetException`. Since 21.1. Reads the float from the receiver object in the given byte order at the given byte offset from the start of the buffer. Unaligned accesses are supported. The access is *not* guaranteed to be atomic. Therefore, this message is *not* thread-safe. Invoking this message does not cause any observable side-effects. Returns `float`: the float at the given byte offset from the start of the buffer. Throws: `InvalidBufferOffsetException`: if and only if `byteOffset ``<`` 0 || byteOffset ``>``= ``getBufferSize(Object)`` - 3`. `UnsupportedMessageException`: if and only if `hasBufferElements(Object)` returns `false`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#readBufferFloat(java.lang.Object,java.nio.ByteOrder,long)` ### writeBufferFloat(Object, ByteOrder, …) `public void writeBufferFloat(Object receiver, ByteOrder order, long byteOffset, float value) throws UnsupportedMessageException, InvalidBufferOffsetException`. Since 21.1. Writes the given float from the receiver object in the given byte order at the given byte offset from the start of the buffer. Unaligned accesses are supported. The access is *not* guaranteed to be atomic. Therefore, this message is *not* thread-safe. Throws: `InvalidBufferOffsetException`: if and only if `byteOffset ``<`` 0 || byteOffset ``>``= ``getBufferSize(Object)`` - 3`. `UnsupportedMessageException`: if and only if either `hasBufferElements(Object)` or `isBufferWritable` returns `false`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#writeBufferFloat(java.lang.Object,java.nio.ByteOrder,long,float)` ### readBufferDouble(Object, ByteOrder, long) `public double readBufferDouble(Object receiver, ByteOrder order, long byteOffset) throws UnsupportedMessageException, InvalidBufferOffsetException`. Since 21.1. Reads the double from the receiver object in the given byte order at the given byte offset from the start of the buffer. Unaligned accesses are supported. The access is *not* guaranteed to be atomic. Therefore, this message is *not* thread-safe. Invoking this message does not cause any observable side-effects. Returns `double`: the double at the given byte offset from the start of the buffer. Throws: `InvalidBufferOffsetException`: if and only if `byteOffset ``<`` 0 || byteOffset ``>``= ``getBufferSize(Object)`` - 7`. `UnsupportedMessageException`: if and only if `hasBufferElements(Object)` returns `false`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#readBufferDouble(java.lang.Object,java.nio.ByteOrder,long)` ### writeBufferDouble(Object, ByteOrder, …) `public void writeBufferDouble(Object receiver, ByteOrder order, long byteOffset, double value) throws UnsupportedMessageException, InvalidBufferOffsetException`. Since 21.1. Writes the given double from the receiver object in the given byte order at the given byte offset from the start of the buffer. Unaligned accesses are supported. The access is *not* guaranteed to be atomic. Therefore, this message is *not* thread-safe. Throws: `InvalidBufferOffsetException`: if and only if `byteOffset ``<`` 0 || byteOffset ``>``= ``getBufferSize(Object)`` - 7`. `UnsupportedMessageException`: if and only if either `hasBufferElements(Object)` or `isBufferWritable` returns `false`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#writeBufferDouble(java.lang.Object,java.nio.ByteOrder,long,double)` ### isPointer(Object) `public boolean isPointer(Object receiver)`. Since 19.0. Returns `true` if the receiver value represents a native pointer. Native pointers are represented as 64 bit pointers. Invoking this message does not cause any observable side-effects. Returns `false` by default. It is expected that objects should only return `true` if the native pointer value corresponding to this object already exists, and obtaining it is a cheap operation. If an object can be transformed to a pointer representation, but this hasn't happened yet, the object is expected to return `false` with `isPointer(Object)`, and wait for the `toNative(Object)` message to trigger the transformation. See also: `asPointer(Object)`, `toNative(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isPointer(java.lang.Object)` ### asPointer(Object) `public long asPointer(Object receiver) throws UnsupportedMessageException`. Since 19.0. Returns the pointer value as long value if the receiver represents a pointer like value. Throws: `UnsupportedMessageException`: if and only if `isPointer(Object)` returns `false` for the same receiver. See also: `isPointer(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#asPointer(java.lang.Object)` ### toNative(Object) `public void toNative(Object receiver)`. Since 19.0. Attempts to transform a `receiver` to a value that represents a raw native pointer. After a successful transformation, the provided receiver returns true for `isPointer(Object)` and can be unwrapped using the `asPointer(Object)` message. If transformation cannot be done `isPointer(Object)` will keep returning false. See also: `isPointer(Object)`, `asPointer(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#toNative(java.lang.Object)` ### asInstant(Object) `public Instant asInstant(Object receiver) throws UnsupportedMessageException`. Since 20.0.0 beta 2. Returns the receiver as instant if this object represents an `instant`. If a value is an instant then it is also a `date`, `time` and `timezone`. Using this method may be more efficient than reconstructing the timestamp from the date, time and timezone data. Implementers should implement this method if they can provide a more efficient conversion to Instant than reconstructing it from date, time and timezone date. Implementers must ensure that the following Java code snippet always holds: Throws: `UnsupportedMessageException`: if and only if `isInstant(Object)` returns `false`. See also: `isDate(Object)`, `isTime(Object)`, `isTimeZone(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#asInstant(java.lang.Object)` ```java ZoneId zone = getTimeZone(receiver); LocalDate date = getDate(receiver); LocalTime time = getTime(receiver); assert ZonedDateTime.of(date, time, zone).toInstant().equals(getInstant(receiver)); ``` ### isInstant(Object) `public final boolean isInstant(Object receiver)`. Since 20.0.0 beta 2. Returns `true` if the receiver represents an instant. If a value is an instant then it is also a `date`, `time` and `timezone`. This method is short-hand for: See also: `isDate(Object)`, `isTime(Object)`, `isInstant(Object)`, `asInstant(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isInstant(java.lang.Object)` ```java isDate(v) && isTime(v) && isTimeZone(v) ``` ### isTimeZone(Object) `public boolean isTimeZone(Object receiver)`. Since 20.0.0 beta 2. Returns `true` if this object represents a timezone, else `false`. The interpretation of timezone objects may vary: If `isDate(Object)` and `isTime(Object)` return `true`, then the returned date or time information is aware of this timezone.; If `isDate(Object)` and `isTime(Object)` returns `false`, then it represents just timezone information. Objects with only date information must not have timezone information attached and objects with only time information must have either none, or [`fixed zone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/time/zone/ZoneRules.html#isFixedOffset%28%29) only. If this rule is violated then an [`AssertionError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AssertionError.html) is thrown if assertions are enabled. If this method is implemented then also `asTimeZone(Object)` must be implemented. See also: `asTimeZone(Object)`, `asInstant(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isTimeZone(java.lang.Object)` ### asTimeZone(Object) `public ZoneId asTimeZone(Object receiver) throws UnsupportedMessageException`. Since 20.0.0 beta 2. Returns the receiver as timestamp if this object represents a `timezone`. Throws: `UnsupportedMessageException`: if and only if `isTimeZone(Object)` returns `false` . See also: `isTimeZone(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#asTimeZone(java.lang.Object)` ### isDate(Object) `public boolean isDate(Object receiver)`. Since 20.0.0 beta 2. Returns `true` if this object represents a date, else `false`. If the receiver is also a `timezone` then the date is aware, otherwise it is naive. See also: `asDate(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isDate(java.lang.Object)` ### asDate(Object) `public LocalDate asDate(Object receiver) throws UnsupportedMessageException`. Since 20.0.0 beta 2. Returns the receiver as date if this object represents a `date`. The returned date is either aware if the receiver has a `timezone` otherwise it is naive. Throws: `UnsupportedMessageException`: if and only if `isDate(Object)` returns `false`. See also: `isDate(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#asDate(java.lang.Object)` ### isTime(Object) `public boolean isTime(Object receiver)`. Since 20.0.0 beta 2. Returns `true` if this object represents a time, else `false`. If the receiver is also a `timezone` then the time is aware, otherwise it is naive. See also: `asTime(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isTime(java.lang.Object)` ### asTime(Object) `public LocalTime asTime(Object receiver) throws UnsupportedMessageException`. Since 20.0.0 beta 2. Returns the receiver as time if this object represents a `time`. The returned time is either aware if the receiver has a `timezone` otherwise it is naive. Throws: `UnsupportedMessageException`: if and only if `isTime(Object)` returns `false`. See also: `isTime(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#asTime(java.lang.Object)` ### isDuration(Object) `public boolean isDuration(Object receiver)`. Since 20.0.0 beta 2. Returns `true` if this object represents a duration, else `false`. See also: [`Duration`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/time/Duration.html), `asDuration(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isDuration(java.lang.Object)` ### asDuration(Object) `public Duration asDuration(Object receiver) throws UnsupportedMessageException`. Since 20.0.0 beta 2. Returns the receiver as duration if this object represents a `duration`. Throws: `UnsupportedMessageException`: if and only if `isDuration(Object)` returns `false` . See also: `isDuration(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#asDuration(java.lang.Object)` ### isException(Object) `public boolean isException(Object receiver)`. Since 19.3. Returns `true` if the receiver value represents a throwable exception/error. Invoking this message does not cause any observable side-effects. Returns `false` by default. Objects must only return `true` if they support `throwException` as well. If this method is implemented then also `throwException(Object)` must be implemented. Note that a receiver that is also a host object may have `asHostObject(Object)` return an object that is *not* a [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html). This is the case when a guest exception wraps an arbitrary host object (or delegates to another object for that matter), so `isHostObject(Object)` returns true and `asHostObject(Object)` returns the underlying host object, whereas `throwException(Object)` throws the guest exception. The following simplified `TryCatchNode` shows how the exceptions should be handled by languages. See also: `throwException(Object)`, `com.oracle.truffle.api.exception.AbstractTruffleException`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isException(java.lang.Object)` ```java static final class TryCatchNode extends StatementNode { @Node.Child private BlockNode block; @Node.Child private BlockNode catchBlock; @Node.Child private BlockNode finallyBlock; private final BranchProfile exceptionProfile; TryCatchNode(BlockNode block, BlockNode catchBlock, BlockNode finallyBlock) { this.block = block; this.catchBlock = catchBlock; this.finallyBlock = finallyBlock; this.exceptionProfile = BranchProfile.create(); } @Override void executeVoid(VirtualFrame frame) { RuntimeException rethrowException = null; try { block.executeVoid(frame); } catch (AbstractTruffleException ex) { exceptionProfile.enter(); try { if (catchBlock != null) { catchBlock.executeVoid(frame); // do not rethrow if handled rethrowException = null; } else { // rethrow if not handled rethrowException = ex; } } catch (AbstractTruffleException e) { rethrowException = e; } } catch (ControlFlowException cfe) { // run finally blocks for control flow rethrowException = cfe; } // Java finally blocks that execute nodes are not allowed for // compilation as code in finally blocks is duplicated // by the Java bytecode compiler. This can lead to // exponential code growth in worst cases. if (finallyBlock != null) { finallyBlock.executeVoid(frame); } if (rethrowException != null) { throw rethrowException; } } } ``` ### throwException(Object) `public RuntimeException throwException(Object receiver) throws UnsupportedMessageException`. Since 19.3. Throws the receiver object as an exception of the source language, as if it was thrown by the source language itself. Allows rethrowing exceptions caught by another language. If this method is implemented then also `isException(Object)` must be implemented. Any interop value can be an exception value and export `throwException(Object)`. The exception thrown by this message must extend `com.oracle.truffle.api.exception.AbstractTruffleException`. In future versions this contract will be enforced using an assertion. For a sample `TryCatchNode` implementation see `isException`. Throws: `UnsupportedMessageException`: if and only if `isException(Object)` returns `false` for the same receiver. See also: `isException(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#throwException(java.lang.Object)` ### getExceptionType(Object) `public ExceptionType getExceptionType(Object receiver) throws UnsupportedMessageException`. Since 20.3. Returns `exception type` of the receiver. Throws `UnsupportedMessageException` when the receiver is not an `exception`. For a sample `TryCatchNode` implementation see `isException`. See also: `isException(Object)`, `ExceptionType`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getExceptionType(java.lang.Object)` ### isExceptionIncompleteSource(Object) `public boolean isExceptionIncompleteSource(Object receiver) throws UnsupportedMessageException`. Since 20.3. Returns `true` if receiver value represents an incomplete source exception. Throws `UnsupportedMessageException` when the receiver is not an `exception` or the exception is not a `ExceptionType.PARSE_ERROR`. See also: `isException(Object)`, `getExceptionType(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isExceptionIncompleteSource(java.lang.Object)` ### getExceptionExitStatus(Object) `public int getExceptionExitStatus(Object receiver) throws UnsupportedMessageException`. Since 20.3. Returns exception exit status of the receiver. Throws `UnsupportedMessageException` when the receiver is not an `exception` of the `exit type`. See [Context Exit](https://github.com/oracle/graal/blob/master/truffle/docs/Exit.md) for further information. A return value zero indicates that the execution of the application was successful, a non-zero value that it failed. The individual interpretation of non-zero values depends on the application. See also: `isException(Object)`, `getExceptionType(Object)`, `ExceptionType`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getExceptionExitStatus(java.lang.Object)` ### hasExceptionCause(Object) `public boolean hasExceptionCause(Object receiver)`. Since 20.3. Returns `true` if the receiver is an exception with an attached internal cause. Invoking this message does not cause any observable side-effects. Returns `false` by default. See also: `isException(Object)`, `getExceptionCause(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#hasExceptionCause(java.lang.Object)` ### getExceptionCause(Object) `public Object getExceptionCause(Object receiver) throws UnsupportedMessageException`. Since 20.3. Returns the internal cause of the receiver. Throws `UnsupportedMessageException` when the receiver is not an `exception` or if the exception does not support an exception cause. The returned value of this message is guaranteed to represent either an `exception` or an `null` object. An null object is returned if the exception supports a cause but the cause itself is `null`. See also: `isException(Object)`, `hasExceptionCause(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getExceptionCause(java.lang.Object)` ### hasExceptionMessage(Object) `public boolean hasExceptionMessage(Object receiver)`. Since 20.3. Returns `true` if the receiver is an exception that has an exception message. Invoking this message does not cause any observable side-effects. Returns `false` by default. See also: `isException(Object)`, `getExceptionMessage(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#hasExceptionMessage(java.lang.Object)` ### getExceptionMessage(Object) `public Object getExceptionMessage(Object receiver) throws UnsupportedMessageException`. Since 20.3. Returns exception message of the receiver. Throws `UnsupportedMessageException` when the receiver is not an `exception` or has no exception message. The return value of this message is guaranteed to return `true` for `isString(Object)`. See also: `isException(Object)`, `hasExceptionMessage(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getExceptionMessage(java.lang.Object)` ### hasExceptionStackTrace(Object) `public boolean hasExceptionStackTrace(Object receiver)`. Since 20.3. Returns `true` if the receiver is an exception and has a stack trace. Invoking this message does not cause any observable side-effects. Returns `false` by default. See also: `isException(Object)`, `getExceptionStackTrace(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#hasExceptionStackTrace(java.lang.Object)` ### getExceptionStackTrace(Object) `public Object getExceptionStackTrace(Object receiver) throws UnsupportedMessageException`. Since 20.3. Returns the exception stack trace of the receiver that is of type exception. Returns an `array` of objects with potentially `executable name`, `declaring meta object` and `source location` of the caller. Throws `UnsupportedMessageException` when the receiver is not an `exception` or has no stack trace. Invoking this message or accessing the stack trace elements array must not cause any observable side-effects. The default implementation of `getExceptionStackTrace(Object)` calls `TruffleStackTrace.getStackTrace(Throwable)` on the underlying exception object and `TruffleStackTraceElement.getGuestObject()` to access an interop capable object of the underlying stack trace element. See also: `isException(Object)`, `hasExceptionStackTrace(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getExceptionStackTrace(java.lang.Object)` ### hasIterator(Object) `public boolean hasIterator(Object receiver)`. Since 21.1. Returns `true` if the receiver provides an iterator. For example, an array or a list provide an iterator over their content. Invoking this message does not cause any observable side-effects. By default returns `true` for receivers that have `array elements`. See also: `getIterator(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#hasIterator(java.lang.Object)` ### getIterator(Object) `public Object getIterator(Object receiver) throws UnsupportedMessageException`. Since 21.1. Returns the iterator for the receiver. The return value is always an `iterator`. Invoking this message does not cause any observable side-effects. Throws: `UnsupportedMessageException`: if and only if `hasIterator(Object)` returns `false` for the same receiver. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getIterator(java.lang.Object)` ### isIterator(Object) `public boolean isIterator(Object receiver)`. Since 21.1. Returns `true` if the receiver represents an iterator. Invoking this message does not cause any observable side-effects. Returns `false` by default. See also: `hasIterator(Object)`, `getIterator(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isIterator(java.lang.Object)` ### hasIteratorNextElement(Object) `public boolean hasIteratorNextElement(Object receiver) throws UnsupportedMessageException`. Since 21.1. Returns `true` if the receiver is an iterator which has more elements, else `false`. Multiple calls to the `hasIteratorNextElement(Object)` might lead to different results if the underlying data structure is modified. The following example shows how the `hasIteratorNextElement` message can be emulated in languages where iterators only have a next method and throw an exception if there are no further elements. Throws: `UnsupportedMessageException`: if and only if `isIterator(Object)` returns `false` for the same receiver. See also: `isIterator(Object)`, `getIteratorNextElement(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#hasIteratorNextElement(java.lang.Object)` ```java @ExportLibrary(InteropLibrary.class) abstract class InteropIterator implements TruffleObject { @SuppressWarnings("serial") public static final class Stop extends AbstractTruffleException { } private static final Object STOP = new Object(); private Object next; protected InteropIterator() { } protected abstract Object next() throws Stop; @ExportMessage @SuppressWarnings("static-method") boolean isIterator() { return true; } @ExportMessage boolean hasIteratorNextElement() { fetchNext(); return next != STOP; } @ExportMessage Object getIteratorNextElement() throws StopIterationException { fetchNext(); Object res = next; if (res == STOP) { throw StopIterationException.create(); } else { next = null; } return res; } private void fetchNext() { if (next == null) { try { next = next(); } catch (Stop stop) { next = STOP; } } } } ``` ### getIteratorNextElement(Object) `public Object getIteratorNextElement(Object receiver) throws UnsupportedMessageException, StopIterationException`. Since 21.1. Returns the next element in the iteration. When the underlying data structure is modified the `getIteratorNextElement(Object)` may throw the `StopIterationException` despite the `hasIteratorNextElement(Object)` returned `true`. Throws: `UnsupportedMessageException`: if `isIterator(Object)` returns `false` for the same receiver or when the underlying iterator element exists but is not readable. `StopIterationException`: if the iteration has no more elements. Even if the `StopIterationException` was thrown it might not be thrown again by a next `getIteratorNextElement(Object)` invocation on the same receiver due to a modification of an underlying iterable. See also: `isIterator(Object)`, `hasIteratorNextElement(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getIteratorNextElement(java.lang.Object)` ### hasSourceLocation(Object) `public boolean hasSourceLocation(Object receiver)`. Since 20.1. Returns `true` if the receiver value has a declared source location attached, else `false`. Returning a source location for a value is optional and typically impacts the capabilities of tools like debuggers to jump to the declaration of a value. Examples for values that may provide a source location: `Metaobjects` like classes or types.; First class `executables`, like functions, closures or promises.; Allocation sites for instances. Note that in most languages it is very expensive to track the allocation site of an instance and it is therefore not recommended to support this feature by default, but ideally behind an optional language option. This method must not cause any observable side-effects. If this method is implemented then also `getSourceLocation(Object)` must be implemented. See also: `getSourceLocation(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#hasSourceLocation(java.lang.Object)` ### getSourceLocation(Object) `public SourceSection getSourceLocation(Object receiver) throws UnsupportedMessageException`. Since 20.1. Returns the declared source location of the receiver value. Throws an `UnsupportedMessageException` if the value does not have a declared source location. See `hasSourceLocation(Object)` for further details on potential interpretations. Throws `UnsupportedMessageException` by default. This method must not cause any observable side-effects. If this method is implemented then also `hasSourceLocation(Object)` must be implemented. Throws: `UnsupportedMessageException`: if and only if `hasSourceLocation(Object)` returns `false` for the same receiver. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getSourceLocation(java.lang.Object)` ### hasLanguage(Object) `@Deprecated(since = "25.1") public boolean hasLanguage(Object receiver)`. Since 20.1. Deprecated since 25.1. Use `hasLanguageId(Object)`. Returns `true` if the receiver originates from a language, else `false` . Primitive values or other shared interop value representations that are not associated with a language may return `false`. Values that originate from a language should return `true`. Returns `false` by default. The associated language allows tools to identify the original language of a value. If an instrument requests a `language view` then values that are already associated with a language will just return the same value. Otherwise `TruffleLanguage.getLanguageView(Object, Object)` will be invoked on the language. The returned language may be also exposed to embedders in the future. This method must not cause any observable side-effects. If this method is implemented then also `getLanguage(Object)` and `toDisplayString(Object, boolean)` must be implemented. See also: `getLanguage(Object)`, `toDisplayString(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#hasLanguage(java.lang.Object)` ### getLanguage(Object) `@Deprecated(since = "25.1") public Class> getLanguage(Object receiver) throws UnsupportedMessageException`. Since 20.1. Deprecated since 25.1. Use `getLanguageId(Object)`. Returns the original language of the receiver value. The returned language class must be non-null and represent a valid `registered` language class. For more details see `hasLanguage(Object)`. This method must not cause any observable side-effects. If this method is implemented then also `hasLanguage(Object)` must be implemented. Throws: `UnsupportedMessageException`: if and only if `hasLanguage(Object)` returns `false` for the same receiver. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getLanguage(java.lang.Object)` ### hasLanguageId(Object) `public boolean hasLanguageId(Object receiver)`. Since 25.1. Returns `true` if the receiver originates from a language, else `false`. Primitive values or other shared interop value representations that are not associated with a language may return `false`. Values that originate from a language should return {code true}. Returns `false` by default. The associated language allows tools to identify the original language of a value. If an instrument requests a `language view` then values that are already associated with a language will just return the same value. Otherwise `TruffleLanguage.getLanguageView(Object, Object)` will be invoked on the language. The returned language id may be also exposed to embedders in polyglot stack frame. This method must not cause any observable side-effects. If this method is implemented then also `getLanguageId(Object)` and `toDisplayString(Object, boolean)` must be implemented. See also: `getLanguageId(Object)`, `toDisplayString(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#hasLanguageId(java.lang.Object)` ### hasLanguageLegacy(Object) `protected final boolean hasLanguageLegacy(Object receiver)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#hasLanguageLegacy(java.lang.Object)` ### getLanguageId(Object) `public String getLanguageId(Object receiver) throws UnsupportedMessageException`. Since 25.1. Returns the language id of the receiver value. The returned language id must be non-null and represent a valid id of a `registered` language. For more details see `hasLanguageId(Object)`. This method must not cause any observable side-effects. If this method is implemented then also `hasLanguageId(Object)` must be implemented. Throws: `UnsupportedMessageException`: if and only if `hasLanguageId(Object)` returns `false` for the same receiver. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getLanguageId(java.lang.Object)` ### getLanguageLegacy(Object) `protected final Class> getLanguageLegacy(Object receiver) throws UnsupportedMessageException`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getLanguageLegacy(java.lang.Object)` ### hasMetaObject(Object) `public boolean hasMetaObject(Object receiver)`. Since 20.1. Returns `true` if the receiver value has a metaobject associated. The metaobject represents a description of the object, reveals its kind and its features. Some information that a metaobject might define includes the base object's type, interface, class, methods, attributes, etc. Should return `false` when no metaobject is known for this type. Returns `false` by default. An example, for Java objects the returned metaobject is the [`class`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29) instance. In JavaScript this could be the function or class that is associated with the object. Metaobjects for primitive values or values of other languages may be provided using `language views`. While an object is associated with a metaobject in one language, the metaobject might be a different when viewed from another language. This method must not cause any observable side-effects. If this method is implemented then also `getMetaObject(Object)` must be implemented. See also: `getMetaObject(Object)`, `isMetaObject(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#hasMetaObject(java.lang.Object)` ### getMetaObject(Object) `public Object getMetaObject(Object receiver) throws UnsupportedMessageException`. Since 20.1. Returns the metaobject that is associated with this value. The metaobject represents a description of the object, reveals its kind and its features. Some information that a metaobject might define includes the base object's type, interface, class, methods, attributes, etc. When no metaobject is known for this type. Throws `UnsupportedMessageException` by default. The returned object must return `true` for `isMetaObject(Object)` and provide implementations for `getMetaSimpleName(Object)`, `getMetaQualifiedName(Object)`, and `isMetaInstance(Object, Object)`. For all values with metaobjects it must at hold that `isMetaInstance(getMetaObject(value), value) == true`. This method must not cause any observable side-effects. If this method is implemented then also `hasMetaObject(Object)` must be implemented. Throws: `UnsupportedMessageException`: if and only if `hasMetaObject(Object)` returns `false` for the same receiver. See also: `hasMetaObject(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getMetaObject(java.lang.Object)` ### toDisplayString(Object, boolean) `public Object toDisplayString(Object receiver, boolean allowSideEffects)`. Since 20.1. Converts the receiver to a human readable `string`. Each language may have special formating conventions - even primitive values may not follow the traditional Java rules. The format of the returned string is intended to be interpreted by humans not machines and should therefore not be relied upon by machines. By default the receiver class name and its [`identity hash code`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/System.html#identityHashCode%28java.lang.Object%29) is used as string representation. String representations for primitive values or values of other languages may be provided using `language views`. It is common that languages provide different string representations for primitive and foreign values. To convert the result value to a Java string use `InteropLibrary.asString(Object)`. Parameters: `allowSideEffects` `boolean`: whether side-effects are allowed in the production of the string. See also: `TruffleLanguage.getLanguageView(Object, Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#toDisplayString(java.lang.Object,boolean)` ### toDisplayString(Object) `public final Object toDisplayString(Object receiver)`. Since 20.1. Converts the receiver to a human readable `string` of the language. Short-cut for `toDisplayString(Object, true)`. See also: `toDisplayString(Object, boolean)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#toDisplayString(java.lang.Object)` ### isMetaObject(Object) `public boolean isMetaObject(Object receiver)`. Since 20.1. Returns `true` if the receiver value represents a metaobject. Metaobjects may be values that naturally occur in a language or they may be returned by `getMetaObject(Object)`. A metaobject represents a description of the object, reveals its kind and its features. If a receiver is a metaobject it is often also `instantiable`, but this is not a requirement. **Sample interpretations:** In Java an instance of the type [`Class`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Class.html) is a metaobject. In JavaScript any function instance is a metaobject. For example, the metaobject of a JavaScript class is the associated constructor function. This method must not cause any observable side-effects. If this method is implemented then also `getMetaQualifiedName(Object)`, `getMetaSimpleName(Object)` and `isMetaInstance(Object, Object)` must be implemented as well. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isMetaObject(java.lang.Object)` ### getMetaQualifiedName(Object) `public Object getMetaQualifiedName(Object metaObject) throws UnsupportedMessageException`. Since 20.1. Returns the qualified name of a metaobject as `string`. **Sample interpretations:** The qualified name of a Java class includes the package name and its class name. JavaScript does not have the notion of qualified name and therefore returns the `simple name` instead. This method must not cause any observable side-effects. If this method is implemented then also `isMetaObject(Object)` must be implemented as well. Throws: `UnsupportedMessageException`: if and only if `isMetaObject(Object)` returns `false` for the same receiver. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getMetaQualifiedName(java.lang.Object)` ### getMetaSimpleName(Object) `public Object getMetaSimpleName(Object metaObject) throws UnsupportedMessageException`. Since 20.1. Returns the simple name of a metaobject as `string`. **Sample interpretations:** The simple name of a Java class is the class name. This method must not cause any observable side-effects. If this method is implemented then also `isMetaObject(Object)` must be implemented as well. Throws: `UnsupportedMessageException`: if and only if `isMetaObject(Object)` returns `false` for the same receiver. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getMetaSimpleName(java.lang.Object)` ### isMetaInstance(Object, Object) `public boolean isMetaInstance(Object receiver, Object instance) throws UnsupportedMessageException`. Since 20.1. Returns `true` if the given instance is of the provided receiver metaobject, else `false`. **Sample interpretations:** A Java object is an instance of its returned [`class`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29). This method must not cause any observable side-effects. If this method is implemented then also `isMetaObject(Object)` must be implemented as well. Parameters: `instance` `Object`: the instance object to check. Throws: `UnsupportedMessageException`: if and only if `isMetaObject(Object)` returns `false` for the same receiver. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isMetaInstance(java.lang.Object,java.lang.Object)` ### hasMetaParents(Object) `public boolean hasMetaParents(Object receiver)`. Since 22.2. Returns `true` if the receiver value `is a metaobject` which has parents (super types). This method must not cause any observable side-effects. If this method is implemented then also `getMetaParents(Object)` must be implemented. Parameters: `receiver` `Object`: a metaobject. See also: `getMetaParents(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#hasMetaParents(java.lang.Object)` ### getMetaParents(Object) `public Object getMetaParents(Object receiver) throws UnsupportedMessageException`. Since 22.2. Returns an array like `hasArrayElements(Object)` of metaobjects that are direct parents (super types) of this metaobject. The returned object is an `array` of objects that return `true` from `isMetaObject(Object)`. Parameters: `receiver` `Object`: a metaobject. Throws: `UnsupportedMessageException`: if and only if `hasMetaParents(Object)` returns `false` for the same receiver. See also: `hasMetaParents(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getMetaParents(java.lang.Object)` ### isIdenticalOrUndefined(Object, Object) `protected TriState isIdenticalOrUndefined(Object receiver, Object other)`. Since 20.2. Returns `TRUE` if the receiver is or `FALSE` if the receiver is not identical to the `other` value. Returns `UNDEFINED` if the operation is not specified. **Sample interpretations:** A Java object might be of the identical instance as another Java object. Typically compared using the `==` operator. Any implementation, with the exception of an implementation that returns `UNDEFINED` unconditionally, must guarantee the following properties: It is *reflexive*: for any value `x`, `lib.isIdenticalOrUndefined(x, x)` always returns `TRUE`. This is necessary to ensure that the `hasIdentity(Object)` contract has reliable results.; It is *symmetric*: for any values `x` and `y`, `lib.isIdenticalOrUndefined(x, y)` returns `TRUE` if and only if `lib.isIdenticalOrUndefined(y, x)` returns `TRUE`.; It is *transitive*: for any values `x`, `y`, and `z`, if `lib.isIdenticalOrUndefined(x, y)` returns `TRUE` and `lib.isIdenticalOrUndefined(y, z)` returns `TRUE`, then `lib.isIdentical(x, z, zLib)` returns `TRUE`.; It is *consistent*: for any values `x` and `y`, multiple invocations of `lib.isIdenticalOrUndefined(x, y)` consistently returns the same value. Note that the target language identical semantics typically does not map directly to interop identical implementation. Instead target language identity is specified by the language operation, may take multiple other rules into account and may only fallback to interop identical for values without dedicated interop type. For example, in many languages primitives like numbers or strings may be identical, in the target language sense, still identity can only be exposed for objects and non-primitive values. Primitive values like [`Integer`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Integer.html) can never be interop identical to other boxed language integers as this would violate the symmetric property. Example receiver class MyObject which uses an explicit identity field to compute whether two values are identical. This method must not cause any observable side-effects. If this method is implemented then also `identityHashCode(Object)` must be implemented. Parameters: `other` `Object`: the other value to compare to. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isIdenticalOrUndefined(java.lang.Object,java.lang.Object)` ```java static class MyObject { final Object identity; MyObject(Object identity) { this.identity = identity; } @ExportMessage static final class IsIdenticalOrUndefined { @Specialization static TriState doMyObject(MyObject receiver, MyObject other) { return receiver.identity == other.identity ? TriState.TRUE : TriState.FALSE; } @Fallback static TriState doOther(MyObject receiver, Object other) { return TriState.UNDEFINED; } } // ... } ``` ### isIdentical(Object, Object, InteropLibrary) `public boolean isIdentical(Object receiver, Object other, InteropLibrary otherInterop)`. Since 20.2. Returns `true` if two values represent the identical value, else `false`. Two values are identical if and only if they have specified identity semantics in the target language and refer to the identical instance. By default, an interop value does not support identical comparisons, and will return `false` for any invocation of this method. Use `hasIdentity(Object)` to find out whether a receiver supports identity comparisons. This method has the following properties: It is **not** *reflexive*: for any value `x`, `lib.isIdentical(x, x, lib)` may return `false` if the object does not support identity, else `true`. This method is reflexive if `x` supports identity. A value supports identity if `lib.isIdentical(x, x, lib)` returns `true`. The method `hasIdentity(Object)` may be used to document this intent explicitly.; It is *symmetric*: for any values `x` and `y`, `lib.isIdentical(x, y, yLib)` returns `true` if and only if `lib.isIdentical(y, x, xLib)` returns `true`.; It is *transitive*: for any values `x`, `y`, and `z`, if `lib.isIdentical(x, y, yLib)` returns `true` and `lib.isIdentical(y, z, zLib)` returns `true`, then `lib.isIdentical(x, z, zLib)` returns `true`.; It is *consistent*: for any values `x` and `y`, multiple invocations of `lib.isIdentical(x, y, yLib)` consistently returns `true` or consistently return `false`. Note that the target language identical semantics typically does not map directly to interop identical implementation. Instead target language identity is specified by the language operation, may take multiple other rules into account and may only fallback to interop identical for values without dedicated interop type. For example, in many languages primitives like numbers or strings may be identical, in the target language sense, still identity can only be exposed for objects and non-primitive values. Primitive values like [`Integer`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Integer.html) can never be interop identical to other boxed language integers as this would violate the symmetric property. This method performs double dispatch by forwarding calls to `isIdenticalOrUndefined(Object, Object)` with receiver and other value first and then with reversed parameters if the result was `undefined`. This allows the receiver and the other value to negotiate identity semantics. This method is supposed to be exported only if the receiver represents a wrapper that forwards messages. In such a case the isIdentical message should be forwarded to the delegate value. Otherwise, the `isIdenticalOrUndefined(Object, Object)` should be exported instead. This method must not cause any observable side-effects. Cached usage example: Uncached usage example: For a full example please refer to the SLEqualNode of the SimpleLanguage example implementation. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isIdentical(java.lang.Object,java.lang.Object,com.oracle.truffle.api.interop.InteropLibrary)` ```java abstract class IsIdenticalUsage extends Node { abstract boolean execute(Object left, Object right); @Specialization(limit = "3") public boolean isIdentical(Object left, Object right, @CachedLibrary("left") InteropLibrary leftInterop, @CachedLibrary("right") InteropLibrary rightInterop) { return leftInterop.isIdentical(left, right, rightInterop); } } ``` ```java @TruffleBoundary public static boolean isIdentical(Object left, Object right) { return InteropLibrary.getUncached(left).isIdentical(left, right, InteropLibrary.getUncached(right)); } ``` ### hasIdentity(Object) `public final boolean hasIdentity(Object receiver)`. Since 20.2. Returns `true` if and only if the receiver specifies identity, else `false`. This method is a short-cut for `this.isIdentical(receiver, receiver, this) != TriState.UNDEFINED`. This message cannot be exported. To add identity support to the receiver export `isIdenticalOrUndefined(Object, Object)` instead. See also: `isIdenticalOrUndefined(Object, Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#hasIdentity(java.lang.Object)` ### identityHashCode(Object) `public int identityHashCode(Object receiver) throws UnsupportedMessageException`. Since 20.2. Returns an identity hash code for the receiver if it has `identity`. If the receiver has no identity then an `UnsupportedMessageException` is thrown. The identity hash code may be used by languages to store foreign values with identity in an identity hash map. Whenever it is invoked on the same object more than once during an execution of a guest context, the identityHashCode method must consistently return the same integer. This integer need not remain consistent from one execution context of a guest application to another execution context of the same application.; If two objects are the same according to the `isIdentical(Object, Object, InteropLibrary)` message, then calling the identityHashCode method on each of the two objects must produce the same integer result.; As much as is reasonably practical, the identityHashCode message does return distinct integers for objects that are not the same. This method must not cause any observable side-effects. If this method is implemented then also `isIdenticalOrUndefined(Object, Object)` must be implemented. Throws: `UnsupportedMessageException`: if and only if `hasIdentity(Object)` returns `false` for the same receiver. See also: `isIdenticalOrUndefined(Object, Object)`, `isIdentical(Object, Object, InteropLibrary)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#identityHashCode(java.lang.Object)` ### isScope(Object) `public boolean isScope(Object receiver)`. Since 20.3. Returns `true` if the value represents a scope object, else `false`. The scope object contains variables as `members`. The scope may return a `source location` that indicates the range of the scope in the source code. The scope may have `parent scopes`. The `members` of a scope represent all visible flattened variables, including all parent scopes, if any. The variables of the current scope must be listed first in `getMembers(Object)`. Variables of the `parent scope` must be listed afterwards, even if they contain duplicates. This allows to resolve which variables are redeclared in sub scopes. Every `member` may not be just a String literal, but a `string object` that provides also a `source location` of its declaration. When different variables of the same name are in different scopes, they will be represented by different member elements providing the same `name`. This method must not cause any observable side-effects. If this method is implemented then also `hasMembers(Object)` must be implemented and `hasSourceLocation(Object)` is recommended. See also: `getMembers(Object)`, `hasScopeParent(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isScope(java.lang.Object)` ### hasScopeParent(Object) `public boolean hasScopeParent(Object receiver)`. Since 20.3. Returns `true` if this scope has an enclosing parent scope, else `false`. This method must not cause any observable side-effects. If this method is implemented then also `isScope(Object)` and `getScopeParent(Object)` must be implemented. See also: `isScope(Object)`, `getScopeParent(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#hasScopeParent(java.lang.Object)` ### getScopeParent(Object) `public Object getScopeParent(Object receiver) throws UnsupportedMessageException`. Since 20.3. Returns the parent scope object if it `has the parent`. The returned object must be a `scope` and must provide a reduced list of `member` variables, omitting all variables that are local to the current scope. This method must not cause any observable side-effects. If this method is implemented then also `isScope(Object)` and `getScopeParent(Object)` must be implemented. Throws: `UnsupportedMessageException`: if and only if `hasScopeParent(Object)` returns `false` for the same receiver. See also: `isScope(Object)`, `hasScopeParent(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getScopeParent(java.lang.Object)` ### isHostObject(Object) `public boolean isHostObject(Object receiver)`. Since 25.1. Returns `true` if the argument is wrapped Java host language object. This method must not cause any observable side-effects. If this method is implemented then also `asHostObject(Object)` must be implemented. See also: `asHostObject(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isHostObject(java.lang.Object)` ### asHostObject(Object) `public Object asHostObject(Object receiver) throws UnsupportedMessageException, HeapIsolationException`. Since 25.1. Returns the Java host object representation of the given Truffle guest object. Implementations of this method must not produce any observable side effects. If this method is implemented, `isHostObject(Object)` must also be implemented and return `true` for the same receiver. Throws: `UnsupportedMessageException`: if `isHostObject(Object)` returns `false` for the given receiver. `HeapIsolationException`: if the guest object represents a host object located in a foreign heap, for example in a polyglot isolate. See also: `isHostObject(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#asHostObject(java.lang.Object)` ### getFactory() `public static LibraryFactory getFactory()`. Since 19.0. Returns the library factory for the interop library. Short-cut for `ResolvedLibrary.resolve(InteropLibrary.class)`. See also: `LibraryFactory.resolve(Class)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getFactory()` ### getUncached() `public static InteropLibrary getUncached()`. Since 20.2. Returns the uncached automatically dispatched version of the interop library. This is a short-cut for calling `InteropLibrary.getFactory().getUncached()`. See also: `LibraryFactory.getUncached()`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getUncached()` ### getUncached(Object) `public static InteropLibrary getUncached(Object v)`. Since 20.2. Returns the uncached manually dispatched version of the interop library. This is a short-cut for calling `InteropLibrary.getFactory().getUncached(v)`. See also: `LibraryFactory.getUncached(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#getUncached(java.lang.Object)` ### assertAdopted() `protected final boolean assertAdopted()`. Since 19.0. Utility for libraries to require adoption before cached versions of nodes can be executed. Only fails if assertions (-ea) are enabled. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#assertAdopted()` ### isValidValue(Object) `public static boolean isValidValue(Object receiver)`. Since 21.3. Utility to check whether a value is a valid interop value. Interop values are all values that can flow through the language implementation freely and are intended to be used as receivers for the `InteropLibrary`. This method will be extended with more checked types as interop is extended with further allowed values. It is not recommended to make assumptions about the types of interop values. It is recommended to use instance methods in `InteropLibrary` to check for interop types instead. However, it can be useful to make such assumptions for performance reasons. To verify that these assumptions continue to hold this method can be used. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isValidValue(java.lang.Object)` ### isValidProtocolValue(Object) `public static boolean isValidProtocolValue(Object value)`. Since 21.3. Utility to check whether a value is a valid interop protocol value. An interop protocol value is either an `interop value` or a value that might be returned or passed as parameter by any of the methods in `InteropLibrary`. This can be useful to validate all values received or returned by a wrapper that uses `ReflectionLibrary` to delegate all interop protocol parameters and return values. This method will be extended with more checked types as interop is extended with further allowed values. See also: `isValidValue(Object)`. Cite: `com/oracle/truffle/api/interop/InteropLibrary.html#isValidProtocolValue(java.lang.Object)` ## Inherited members - From class [`Library`](com/oracle/truffle/api/library/Library.md): [`accepts`](com/oracle/truffle/api/library/Library.md#accepts%28java.lang.Object%29) - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ⚡︎ InvalidArrayIndexException [truffle-api](index.md) › [com.oracle.truffle.api.interop](com/oracle/truffle/api/interop/index.md) · Every page: [llms.txt](llms.txt) Exception in [`com.oracle.truffle.api.interop`](com/oracle/truffle/api/interop/index.md). Since 19.0. ```java public final class InvalidArrayIndexException extends InteropException ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) > [`Exception`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Exception.html) > [`InteropException`](com/oracle/truffle/api/interop/InteropException.md) > `InvalidArrayIndexException` An exception thrown if an array does not contain a element with an index. Interop exceptions are supposed to be caught and converted into a guest language error by the caller. **See also** - [`getInvalidIndex()`](com/oracle/truffle/api/interop/InvalidArrayIndexException.md#getInvalidIndex%28%29) - [`InteropLibrary`](com/oracle/truffle/api/interop/InteropLibrary.md) ## Methods ### getMessage() `public String getMessage()`. Since 19.0. Overrides `getMessage()`. Cite: `com/oracle/truffle/api/interop/InvalidArrayIndexException.html#getMessage()` ### getInvalidIndex() `public long getInvalidIndex()`. Since 19.0. Returns the invalid index that was used. Cite: `com/oracle/truffle/api/interop/InvalidArrayIndexException.html#getInvalidIndex()` ### create(long) `public static InvalidArrayIndexException create(long invalidIndex)`. Since 19.0. Creates an `InvalidArrayIndexException` to indicate that an array index is invalid. This method is designed to be used in `compiled` code paths. Parameters: `invalidIndex` `long`: the index that could not be accessed. Cite: `com/oracle/truffle/api/interop/InvalidArrayIndexException.html#create(long)` ### create(long, Throwable) `public static InvalidArrayIndexException create(long invalidIndex, Throwable cause)`. Since 20.2. Creates an `InvalidArrayIndexException` to indicate that an array index is invalid. In addition a cause may be provided. The cause should only be set if the guest language code caused this problem. An example for this is a language specific proxy mechanism that invokes guest language code to describe an object. If the guest language code fails to execute and this interop exception is a valid interpretation of the error, then the error should be provided as cause. The cause can then be used by the source language as new exception cause if the `InteropException` is translated to a source language error. If the `InteropException` is discarded, then the cause will most likely get discarded by the source language as well. Note that the cause must be of type `com.oracle.truffle.api.exception.AbstractTruffleException` otherwise an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. This method is designed to be used in `compiled` code paths. Parameters: `invalidIndex` `long`: the index that could not be accessed. `cause` `Throwable`: the guest language exception that caused the error. Cite: `com/oracle/truffle/api/interop/InvalidArrayIndexException.html#create(long,java.lang.Throwable)` ## Inherited members - From class [`InteropException`](com/oracle/truffle/api/interop/InteropException.md): [`fillInStackTrace`](com/oracle/truffle/api/interop/InteropException.md#fillInStackTrace%28%29), [`getCause`](com/oracle/truffle/api/interop/InteropException.md#getCause%28%29) - From class [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html): [`addSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#addSuppressed%28java.lang.Throwable%29), [`getLocalizedMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getLocalizedMessage%28%29), [`getStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getStackTrace%28%29), [`getSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getSuppressed%28%29), [`initCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#initCause%28java.lang.Throwable%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintStream%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintWriter%29), [`setStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#setStackTrace%28java.lang.StackTraceElement[]%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ⚡︎ InvalidBufferOffsetException [truffle-api](index.md) › [com.oracle.truffle.api.interop](com/oracle/truffle/api/interop/index.md) · Every page: [llms.txt](llms.txt) Exception in [`com.oracle.truffle.api.interop`](com/oracle/truffle/api/interop/index.md). Since 21.1. ```java public final class InvalidBufferOffsetException extends InteropException ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) > [`Exception`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Exception.html) > [`InteropException`](com/oracle/truffle/api/interop/InteropException.md) > `InvalidBufferOffsetException` An exception thrown if a buffer access if out of bounds. Interop exceptions are supposed to be caught and converted into a guest language error by the caller. **See also** - [`getByteOffset()`](com/oracle/truffle/api/interop/InvalidBufferOffsetException.md#getByteOffset%28%29) - [`getLength()`](com/oracle/truffle/api/interop/InvalidBufferOffsetException.md#getLength%28%29) - [`InteropLibrary`](com/oracle/truffle/api/interop/InteropLibrary.md) ## Methods ### getByteOffset() `public long getByteOffset()`. Since 21.1. Returns the start byte offset of the invalid access from the start of the buffer. Cite: `com/oracle/truffle/api/interop/InvalidBufferOffsetException.html#getByteOffset()` ### getLength() `public long getLength()`. Since 21.1. Returns the length of the accessed memory region in bytes starting from `the start byte offset`. Cite: `com/oracle/truffle/api/interop/InvalidBufferOffsetException.html#getLength()` ### getMessage() `public String getMessage()`. Since 21.1. Overrides `getMessage()`. Cite: `com/oracle/truffle/api/interop/InvalidBufferOffsetException.html#getMessage()` ### create(long, long) `public static InvalidBufferOffsetException create(long byteOffset, long length)`. Since 21.1. Creates an `InvalidBufferOffsetException` to indicate that a buffer access is invalid. This method is designed to be used in `compiled` code paths. Parameters: `byteOffset` `long`: the start byteOffset of the invalid access. `length` `long`: the length of the accessed memory region in bytes starting from `byteOffset`. Cite: `com/oracle/truffle/api/interop/InvalidBufferOffsetException.html#create(long,long)` ### create(long, long, Throwable) `public static InvalidBufferOffsetException create(long byteOffset, long length, Throwable cause)`. Since 21.1. Creates an `InvalidBufferOffsetException` to indicate that a buffer access is invalid. In addition a cause may be provided. The cause should only be set if the guest language code caused this problem. An example for this is a language specific proxy mechanism that invokes guest language code to describe an object. If the guest language code fails to execute and this interop exception is a valid interpretation of the error, then the error should be provided as cause. The cause can then be used by the source language as new exception cause if the `InteropException` is translated to a source language error. If the `InteropException` is discarded, then the cause will most likely get discarded by the source language as well. Note that the cause must be of type `com.oracle.truffle.api.exception.AbstractTruffleException` otherwise an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. This method is designed to be used in `compiled` code paths. Parameters: `byteOffset` `long`: the start byteOffset of the invalid access. `length` `long`: the length of the accessed memory region in bytes starting from `byteOffset`. `cause` `Throwable`: the guest language exception that caused the error. Cite: `com/oracle/truffle/api/interop/InvalidBufferOffsetException.html#create(long,long,java.lang.Throwable)` ## Inherited members - From class [`InteropException`](com/oracle/truffle/api/interop/InteropException.md): [`fillInStackTrace`](com/oracle/truffle/api/interop/InteropException.md#fillInStackTrace%28%29), [`getCause`](com/oracle/truffle/api/interop/InteropException.md#getCause%28%29) - From class [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html): [`addSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#addSuppressed%28java.lang.Throwable%29), [`getLocalizedMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getLocalizedMessage%28%29), [`getStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getStackTrace%28%29), [`getSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getSuppressed%28%29), [`initCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#initCause%28java.lang.Throwable%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintStream%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintWriter%29), [`setStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#setStackTrace%28java.lang.StackTraceElement[]%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ NodeLibrary [truffle-api](index.md) › [com.oracle.truffle.api.interop](com/oracle/truffle/api/interop/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.interop`](com/oracle/truffle/api/interop/index.md). Since 20.3. ```java public abstract class NodeLibrary extends Library ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > [`Library`](com/oracle/truffle/api/library/Library.md) > `NodeLibrary` Node Library provides access to guest language information associated with a particular [`Node`](com/oracle/truffle/api/nodes/Node.md) location. The receiver of this library must be an [`instrumentable`](com/oracle/truffle/api/instrumentation/InstrumentableNode.md#isInstrumentable%28%29) [`Node`](com/oracle/truffle/api/nodes/Node.md) that has a [`root node`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29). ## Constructors ### NodeLibrary() `protected NodeLibrary()`. Since 20.3. Cite: `com/oracle/truffle/api/interop/NodeLibrary.html#()` ## Methods ### hasScope(Object, Frame) `public boolean hasScope(Object node, Frame frame)`. Since 20.3. Returns `true`, if the node is in a scope containing local variables, else `false`. This method must not cause any observable side-effects. If this method is implemented then also `getScope(Object, Frame, boolean)` must be implemented. Parameters: `node` `Object`: a Node, never `null`. `frame` `Frame`: a `Frame`, can be `null` in case of lexical access. See also: `getScope(Object, Frame, boolean)`. Cite: `com/oracle/truffle/api/interop/NodeLibrary.html#hasScope(java.lang.Object,com.oracle.truffle.api.frame.Frame)` ### getScope(Object, Frame, boolean) `public Object getScope(Object node, Frame frame, boolean nodeEnter) throws UnsupportedMessageException`. Since 20.3. Get an object representing a local scope containing variables visible at the node location. The returned object must respond `true` to `InteropLibrary.isScope(Object)`. The scope object exposes all locally visible variables as flattened `members`, including all parent scopes (for example block, closure, lexical or dynamic scopes). Local scopes are associated with a `Frame`. See `InteropLibrary.isScope(Object)` for details. This method must not cause any observable side-effects. If this method is implemented then also `hasScope(Object, Frame)` must be implemented. A returned scope is only valid while the regular guest language execution on this thread is suspended. If the guest execution is continued e.g. if a new instrumentation event occurs, the scope is invalid and should be discarded. Parameters: `node` `Object`: a Node, never `null`. `frame` `Frame`: a `Frame`, can be `null` in case of lexical access. `nodeEnter` `boolean`: when `true`, the location that determines scope variables is at the enter to the node execution, else `false`. Use `true` when called e.g. by instruments from `com.oracle.truffle.api.instrumentation.ExecutionEventNode.onEnter(VirtualFrame)` and `false` when called e.g. from `com.oracle.truffle.api.instrumentation.ExecutionEventNode.onReturnValue(VirtualFrame, Object)`. This argument helps to determine visible variables in case that some variables are added during the node execution. Returns `Object`: An interop object with `InteropLibrary.isScope(Object)` being true. Throws: `UnsupportedMessageException`: if and only if `hasScope(Object, Frame)` returns `false` for the same node and frame. Cite: `com/oracle/truffle/api/interop/NodeLibrary.html#getScope(java.lang.Object,com.oracle.truffle.api.frame.Frame,boolean)` ### hasReceiverMember(Object, Frame) `public boolean hasReceiverMember(Object node, Frame frame)`. Since 20.3. Returns `true`, if there is a named receiver object, else `false`. This method must not cause any observable side-effects. If this method is implemented then also `getReceiverMember(Object, Frame)` must be implemented. Parameters: `node` `Object`: a Node, never `null`. `frame` `Frame`: a `Frame`, can be `null` in case of lexical access. See also: `getReceiverMember(Object, Frame)`. Cite: `com/oracle/truffle/api/interop/NodeLibrary.html#hasReceiverMember(java.lang.Object,com.oracle.truffle.api.frame.Frame)` ### getReceiverMember(Object, Frame) `public Object getReceiverMember(Object node, Frame frame) throws UnsupportedMessageException`. Since 20.3. Returns an object that represents the receiver name when available. The returned value is guaranteed to return true for `InteropLibrary.isString(Object)`. Examples for receiver names are `this` in Java or self in Ruby or Python. The value of the receiver object can be retrieved from the `scope` by converting the member to a string using `InteropLibrary.isString(Object)`. The return value of this method is an Object intentionally to allow the member to have additional interop traits. This method must not cause any observable side-effects. If this method is implemented then also `hasReceiverMember(Object, Frame)` must be implemented. Parameters: `node` `Object`: a Node, never `null`. `frame` `Frame`: a `Frame`, can be `null` in case of lexical access. Returns `Object`: an `interop string object`. Throws: `UnsupportedMessageException`: if and only if `hasReceiverMember(Object, Frame)` returns `false` for the same node and frame. See also: `hasReceiverMember(Object, Frame)`, `getScope(Object, Frame, boolean)`. Cite: `com/oracle/truffle/api/interop/NodeLibrary.html#getReceiverMember(java.lang.Object,com.oracle.truffle.api.frame.Frame)` ### hasRootInstance(Object, Frame) `public boolean hasRootInstance(Object node, Frame frame)`. Since 20.3. Returns `true`, if a current instance of the guest language representation of the root node (e.g. the enclosing guest language function) is available, else `false`. Guest languages will likely require a context lookup to resolve the root instance object. This method must not cause any observable side-effects. If this method is implemented then also `getRootInstance(Object, Frame)` must be implemented. Parameters: `node` `Object`: a Node, never `null`. `frame` `Frame`: a `Frame`, can be `null` in case of lexical access, in which case the instance would likely not be available. See also: `getRootInstance(Object, Frame)`. Cite: `com/oracle/truffle/api/interop/NodeLibrary.html#hasRootInstance(java.lang.Object,com.oracle.truffle.api.frame.Frame)` ### getRootInstance(Object, Frame) `public Object getRootInstance(Object node, Frame frame) throws UnsupportedMessageException`. Since 20.3. Returns the current instance of guest language representation of the root node (e.g. the enclosing guest language function), when available. This method must not cause any observable side-effects. If this method is implemented then also `hasRootInstance(Object, Frame)` must be implemented. Parameters: `node` `Object`: a Node, never `null`. `frame` `Frame`: a `Frame`, can be `null` in case of lexical access, in which case the instance would likely not be available. Returns `Object`: the root instance value which must be an `interop` and `executable` value. Throws: `UnsupportedMessageException`: if and only if `hasRootInstance(Object, Frame)` returns `false` for the same node and frame. See also: `hasRootInstance(Object, Frame)`. Cite: `com/oracle/truffle/api/interop/NodeLibrary.html#getRootInstance(java.lang.Object,com.oracle.truffle.api.frame.Frame)` ### getView(Object, Frame, Object) `public Object getView(Object node, Frame frame, Object value)`. Since 20.3. Wraps the value to filter or add scoping specific information for values associated with the current language and location in the code. Allows the language to augment the perspective tools have on values depending on location and frame. This may be useful to apply local specific visibility rules. By default this method does return the passed value, not applying any scope information to the value. If a language does not implement any scoping and/or has not concept of visibility then this method typically can stay without an implementation. A typical implementation of this method may do the following: Apply visibility and scoping rules to the value hiding or removing members from the object.; Add or remove implicit members that are only available within this source location. This method is only invoked with values that are associated with the current `language`. For values without language the `language view` is requested first before the scoped view is requested. If this method needs an implementation then `TruffleLanguage.getLanguageView(Object, Object)` should be implemented as well. Scoped views may be implemented in a very similar way to `language views`. Please refer to the examples from this method. Parameters: `node` `Object`: the current source location. Guaranteed to be a node from a `RootNode` associated with this language. Never `null`. `frame` `Frame`: the current active frame. Guaranteed to be a frame from a `RootNode` associated with this language. Never `null`. `value` `Object`: the value to provide scope information for. Never `null`. Always associated with this language. See also: `TruffleLanguage.getLanguageView(Object, Object)`. Cite: `com/oracle/truffle/api/interop/NodeLibrary.html#getView(java.lang.Object,com.oracle.truffle.api.frame.Frame,java.lang.Object)` ### getFactory() `public static LibraryFactory getFactory()`. Since 20.3. Returns the library factory for the node library. Short-cut for `ResolvedLibrary.resolve(NodeLibrary.class)`. See also: `LibraryFactory.resolve(Class)`. Cite: `com/oracle/truffle/api/interop/NodeLibrary.html#getFactory()` ### getUncached() `public static NodeLibrary getUncached()`. Since 20.3. Returns the uncached automatically dispatched version of the node library. This is a short-cut for calling `NodeLibrary.getFactory().getUncached()`. See also: `LibraryFactory.getUncached()`. Cite: `com/oracle/truffle/api/interop/NodeLibrary.html#getUncached()` ### getUncached(Object) `public static NodeLibrary getUncached(Object node)`. Since 20.3. Returns the uncached manually dispatched version of the node library. This is a short-cut for calling `NodeLibrary.getFactory().getUncached(v)`. See also: `LibraryFactory.getUncached(Object)`. Cite: `com/oracle/truffle/api/interop/NodeLibrary.html#getUncached(java.lang.Object)` ## Inherited members - From class [`Library`](com/oracle/truffle/api/library/Library.md): [`accepts`](com/oracle/truffle/api/library/Library.md#accepts%28java.lang.Object%29) - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ⚡︎ StopIterationException [truffle-api](index.md) › [com.oracle.truffle.api.interop](com/oracle/truffle/api/interop/index.md) · Every page: [llms.txt](llms.txt) Exception in [`com.oracle.truffle.api.interop`](com/oracle/truffle/api/interop/index.md). Since 21.1. ```java public final class StopIterationException extends InteropException ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) > [`Exception`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Exception.html) > [`InteropException`](com/oracle/truffle/api/interop/InteropException.md) > `StopIterationException` An exception thrown if an iterator is finished. This exception is thrown by the [`getIteratorNextElement`](com/oracle/truffle/api/interop/InteropLibrary.md#getIteratorNextElement%28java.lang.Object%29) when the iterator has no more elements to return. Interop exceptions are supposed to be caught and converted into a guest language error by the caller. **See also** - [`InteropLibrary`](com/oracle/truffle/api/interop/InteropLibrary.md) ## Methods ### getMessage() `public String getMessage()`. Since 21.1. Overrides `getMessage()`. Cite: `com/oracle/truffle/api/interop/StopIterationException.html#getMessage()` ### create() `public static StopIterationException create()`. Since 21.1. Creates an `StopIterationException` to indicate that iteration was stopped. This method is designed to be used in `compiled` code paths. Cite: `com/oracle/truffle/api/interop/StopIterationException.html#create()` ### create(Throwable) `public static StopIterationException create(Throwable cause)`. Since 21.1. Creates an `StopIterationException` to indicate that iteration was stopped. In addition a cause may be provided. The cause should only be set if the guest language code caused this problem. An example for this is a language specific proxy mechanism that invokes guest language code to describe an object. If the guest language code fails to execute and this interop exception is a valid interpretation of the error, then the error should be provided as cause. The cause can then be used by the source language as new exception cause if the `InteropException` is translated to a source language error. If the `InteropException` is discarded, then the cause will most likely get discarded by the source language as well. Note that the cause must be of type `com.oracle.truffle.api.exception.AbstractTruffleException` otherwise an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. This method is designed to be used in `compiled` code paths. Parameters: `cause` `Throwable`: the guest language exception that caused the error. Cite: `com/oracle/truffle/api/interop/StopIterationException.html#create(java.lang.Throwable)` ## Inherited members - From class [`InteropException`](com/oracle/truffle/api/interop/InteropException.md): [`fillInStackTrace`](com/oracle/truffle/api/interop/InteropException.md#fillInStackTrace%28%29), [`getCause`](com/oracle/truffle/api/interop/InteropException.md#getCause%28%29) - From class [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html): [`addSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#addSuppressed%28java.lang.Throwable%29), [`getLocalizedMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getLocalizedMessage%28%29), [`getStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getStackTrace%28%29), [`getSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getSuppressed%28%29), [`initCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#initCause%28java.lang.Throwable%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintStream%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintWriter%29), [`setStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#setStackTrace%28java.lang.StackTraceElement[]%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ TruffleObject [truffle-api](index.md) › [com.oracle.truffle.api.interop](com/oracle/truffle/api/interop/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.interop`](com/oracle/truffle/api/interop/index.md). Since 0.8 or earlier. ```java public interface TruffleObject ``` Interface for any entity of a Truffle guest language implementations that can be shared across other language implementations. **See also** - [`to access truffle objects.`](com/oracle/truffle/api/interop/InteropLibrary.md) # ⚡︎ UnknownIdentifierException [truffle-api](index.md) › [com.oracle.truffle.api.interop](com/oracle/truffle/api/interop/index.md) · Every page: [llms.txt](llms.txt) Exception in [`com.oracle.truffle.api.interop`](com/oracle/truffle/api/interop/index.md). Since 0.11. ```java public final class UnknownIdentifierException extends InteropException ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) > [`Exception`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Exception.html) > [`InteropException`](com/oracle/truffle/api/interop/InteropException.md) > `UnknownIdentifierException` An exception thrown if an object does not contain a member with such an identifier. Interop exceptions are supposed to be caught and converted into a guest language error by the caller. **See also** - [`getUnknownIdentifier()`](com/oracle/truffle/api/interop/UnknownIdentifierException.md#getUnknownIdentifier%28%29) - [`InteropLibrary`](com/oracle/truffle/api/interop/InteropLibrary.md) ## Methods ### getMessage() `public String getMessage()`. Since 19.0. Overrides `getMessage()`. Cite: `com/oracle/truffle/api/interop/UnknownIdentifierException.html#getMessage()` ### getUnknownIdentifier() `public String getUnknownIdentifier()`. Since 0.11. Returns the identifier that could not be accessed. Returns `String`: the unaccessible identifier. Cite: `com/oracle/truffle/api/interop/UnknownIdentifierException.html#getUnknownIdentifier()` ### create(String) `public static UnknownIdentifierException create(String unknownIdentifier)`. Since 19.0. Creates an `UnknownIdentifierException` to indicate that an identifier is missing. This method is designed to be used in `compiled` code paths. Parameters: `unknownIdentifier` `String`: the identifier that could not be accessed. Cite: `com/oracle/truffle/api/interop/UnknownIdentifierException.html#create(java.lang.String)` ### create(String, Throwable) `public static UnknownIdentifierException create(String unknownIdentifier, Throwable cause)`. Since 20.2. Creates an `UnknownIdentifierException` to indicate that an identifier is missing. In addition a cause may be provided. The cause should only be set if the guest language code caused this problem. An example for this is a language specific proxy mechanism that invokes guest language code to describe an object. If the guest language code fails to execute and this interop exception is a valid interpretation of the error, then the error should be provided as cause. The cause can then be used by the source language as new exception cause if the `InteropException` is translated to a source language error. If the `InteropException` is discarded, then the cause will most likely get discarded by the source language as well. Note that the cause must be of type `com.oracle.truffle.api.exception.AbstractTruffleException` otherwise an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. This method is designed to be used in `compiled` code paths. Parameters: `unknownIdentifier` `String`: the identifier that could not be accessed. `cause` `Throwable`: the guest language exception that caused the error. Cite: `com/oracle/truffle/api/interop/UnknownIdentifierException.html#create(java.lang.String,java.lang.Throwable)` ## Inherited members - From class [`InteropException`](com/oracle/truffle/api/interop/InteropException.md): [`fillInStackTrace`](com/oracle/truffle/api/interop/InteropException.md#fillInStackTrace%28%29), [`getCause`](com/oracle/truffle/api/interop/InteropException.md#getCause%28%29) - From class [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html): [`addSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#addSuppressed%28java.lang.Throwable%29), [`getLocalizedMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getLocalizedMessage%28%29), [`getStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getStackTrace%28%29), [`getSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getSuppressed%28%29), [`initCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#initCause%28java.lang.Throwable%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintStream%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintWriter%29), [`setStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#setStackTrace%28java.lang.StackTraceElement[]%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ⚡︎ UnknownKeyException [truffle-api](index.md) › [com.oracle.truffle.api.interop](com/oracle/truffle/api/interop/index.md) · Every page: [llms.txt](llms.txt) Exception in [`com.oracle.truffle.api.interop`](com/oracle/truffle/api/interop/index.md). Since 21.1.0. ```java public final class UnknownKeyException extends InteropException ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) > [`Exception`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Exception.html) > [`InteropException`](com/oracle/truffle/api/interop/InteropException.md) > `UnknownKeyException` An exception thrown if an object does not contain a hash entry with such a key. Interop exceptions are supposed to be caught and converted into a guest language error by the caller. **See also** - [`getUnknownKey()`](com/oracle/truffle/api/interop/UnknownKeyException.md#getUnknownKey%28%29) - [`InteropLibrary`](com/oracle/truffle/api/interop/InteropLibrary.md) ## Methods ### getMessage() `public String getMessage()`. Since 21.1.0. Overrides `getMessage()`. Cite: `com/oracle/truffle/api/interop/UnknownKeyException.html#getMessage()` ### getUnknownKey() `public Object getUnknownKey()`. Since 21.1.0. Returns the hash key that could not be accessed. Cite: `com/oracle/truffle/api/interop/UnknownKeyException.html#getUnknownKey()` ### create(Object) `public static UnknownKeyException create(Object unknownKey)`. Since 21.1.0. Creates an `UnknownKeyException` to indicate that a key is missing in the hash object. This method is designed to be used in `compiled` code paths. Parameters: `unknownKey` `Object`: the key that could not be accessed. Cite: `com/oracle/truffle/api/interop/UnknownKeyException.html#create(java.lang.Object)` ### create(Object, Throwable) `public static UnknownKeyException create(Object unknownKey, Throwable cause)`. Since 21.1.0. Creates an `UnknownKeyException` to indicate that a key is missing in the hash object. In addition a cause may be provided. The cause should only be set if the guest language code caused this problem. An example for this is a language specific proxy mechanism that invokes guest language code to describe an object. If the guest language code fails to execute and this interop exception is a valid interpretation of the error, then the error should be provided as cause. The cause can then be used by the source language as new exception cause if the `InteropException` is translated to a source language error. If the `InteropException` is discarded, then the cause will most likely get discarded by the source language as well. Note that the cause must be of type `com.oracle.truffle.api.exception.AbstractTruffleException` otherwise an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. This method is designed to be used in `compiled` code paths. Parameters: `unknownKey` `Object`: the key that could not be accessed. `cause` `Throwable`: the guest language exception that caused the error. Cite: `com/oracle/truffle/api/interop/UnknownKeyException.html#create(java.lang.Object,java.lang.Throwable)` ## Inherited members - From class [`InteropException`](com/oracle/truffle/api/interop/InteropException.md): [`fillInStackTrace`](com/oracle/truffle/api/interop/InteropException.md#fillInStackTrace%28%29), [`getCause`](com/oracle/truffle/api/interop/InteropException.md#getCause%28%29) - From class [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html): [`addSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#addSuppressed%28java.lang.Throwable%29), [`getLocalizedMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getLocalizedMessage%28%29), [`getStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getStackTrace%28%29), [`getSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getSuppressed%28%29), [`initCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#initCause%28java.lang.Throwable%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintStream%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintWriter%29), [`setStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#setStackTrace%28java.lang.StackTraceElement[]%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ⚡︎ UnsupportedMessageException [truffle-api](index.md) › [com.oracle.truffle.api.interop](com/oracle/truffle/api/interop/index.md) · Every page: [llms.txt](llms.txt) Exception in [`com.oracle.truffle.api.interop`](com/oracle/truffle/api/interop/index.md). Since 0.11. ```java public final class UnsupportedMessageException extends InteropException ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) > [`Exception`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Exception.html) > [`InteropException`](com/oracle/truffle/api/interop/InteropException.md) > `UnsupportedMessageException` An exception thrown if a [`TruffleObject`](com/oracle/truffle/api/interop/TruffleObject.md) does not support a interop message. If this exception is thrown then the receiver does not support the message at all and it is not supported for any arguments given to the message. ## Methods ### getMessage() `public String getMessage()`. Since 19.0. Overrides `getMessage()`. Cite: `com/oracle/truffle/api/interop/UnsupportedMessageException.html#getMessage()` ### create() `public static UnsupportedMessageException create()`. Since 19.0. Creates an `UnsupportedMessageException` to indicate that an `interop` message is not supported. This method is designed to be used in `compiled` code paths. Cite: `com/oracle/truffle/api/interop/UnsupportedMessageException.html#create()` ### create(Throwable) `public static UnsupportedMessageException create(Throwable cause)`. Since 20.2. Creates an `UnsupportedMessageException` to indicate that an `interop` message is not supported. In addition a cause may be provided. The cause should only be set if the guest language code caused this problem. An example for this is a language specific proxy mechanism that invokes guest language code to describe an object. If the guest language code fails to execute and this interop exception is a valid interpretation of the error, then the error should be provided as cause. The cause can then be used by the source language as new exception cause if the `InteropException` is translated to a source language error. If the `InteropException` is discarded, then the cause will most likely get discarded by the source language as well. Note that the cause must be of type `com.oracle.truffle.api.exception.AbstractTruffleException` otherwise an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. This method is designed to be used in `compiled` code paths. Parameters: `cause` `Throwable`: the guest language exception that caused the error. Cite: `com/oracle/truffle/api/interop/UnsupportedMessageException.html#create(java.lang.Throwable)` ## Inherited members - From class [`InteropException`](com/oracle/truffle/api/interop/InteropException.md): [`fillInStackTrace`](com/oracle/truffle/api/interop/InteropException.md#fillInStackTrace%28%29), [`getCause`](com/oracle/truffle/api/interop/InteropException.md#getCause%28%29) - From class [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html): [`addSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#addSuppressed%28java.lang.Throwable%29), [`getLocalizedMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getLocalizedMessage%28%29), [`getStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getStackTrace%28%29), [`getSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getSuppressed%28%29), [`initCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#initCause%28java.lang.Throwable%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintStream%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintWriter%29), [`setStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#setStackTrace%28java.lang.StackTraceElement[]%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ⚡︎ UnsupportedTypeException [truffle-api](index.md) › [com.oracle.truffle.api.interop](com/oracle/truffle/api/interop/index.md) · Every page: [llms.txt](llms.txt) Exception in [`com.oracle.truffle.api.interop`](com/oracle/truffle/api/interop/index.md). Since 0.11. ```java public final class UnsupportedTypeException extends InteropException ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) > [`Exception`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Exception.html) > [`InteropException`](com/oracle/truffle/api/interop/InteropException.md) > `UnsupportedTypeException` An exception thrown if a [`TruffleObject`](com/oracle/truffle/api/interop/TruffleObject.md) does not support the type of one or more arguments. ## Methods ### getSuppliedValues() `public Object[] getSuppliedValues()`. Since 0.11. Returns the arguments of the foreign object access that were not supported by the `TruffleObject`. Returns `Object[]`: the unsupported arguments. Cite: `com/oracle/truffle/api/interop/UnsupportedTypeException.html#getSuppliedValues()` ### create(Object[]) `public static UnsupportedTypeException create(Object[] suppliedValues)`. Since 19.0. Creates an `UnsupportedTypeException` to indicate that an argument type is not supported. Cite: `com/oracle/truffle/api/interop/UnsupportedTypeException.html#create(java.lang.Object[])` ### create(Object[], String) `public static UnsupportedTypeException create(Object[] suppliedValues, String hint)`. Since 19.0. Creates an `UnsupportedTypeException` to indicate that an argument type is not supported. Cite: `com/oracle/truffle/api/interop/UnsupportedTypeException.html#create(java.lang.Object[],java.lang.String)` ### create(Object[], String, Throwable) `public static UnsupportedTypeException create(Object[] suppliedValues, String hint, Throwable cause)`. Since 20.2. Creates an `UnsupportedTypeException` to indicate that an argument type is not supported. In addition a cause may be provided. The cause should only be set if the guest language code caused this problem. An example for this is a language specific proxy mechanism that invokes guest language code to describe an object. If the guest language code fails to execute and this interop exception is a valid interpretation of the error, then the error should be provided as cause. The cause can then be used by the source language as new exception cause if the `InteropException` is translated to a source language error. If the `InteropException` is discarded, then the cause will most likely get discarded by the source language as well. Note that the cause must be of type `com.oracle.truffle.api.exception.AbstractTruffleException` otherwise an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. This method is designed to be used in `compiled` code paths. Parameters: `cause` `Throwable`: the guest language exception that caused the error. Cite: `com/oracle/truffle/api/interop/UnsupportedTypeException.html#create(java.lang.Object[],java.lang.String,java.lang.Throwable)` ## Inherited members - From class [`InteropException`](com/oracle/truffle/api/interop/InteropException.md): [`fillInStackTrace`](com/oracle/truffle/api/interop/InteropException.md#fillInStackTrace%28%29), [`getCause`](com/oracle/truffle/api/interop/InteropException.md#getCause%28%29) - From class [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html): [`addSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#addSuppressed%28java.lang.Throwable%29), [`getLocalizedMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getLocalizedMessage%28%29), [`getMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getMessage%28%29), [`getStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getStackTrace%28%29), [`getSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getSuppressed%28%29), [`initCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#initCause%28java.lang.Throwable%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintStream%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintWriter%29), [`setStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#setStackTrace%28java.lang.StackTraceElement[]%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ▣ com.oracle.truffle.api.io [truffle-api](index.md) · Every page: [llms.txt](llms.txt) Package in truffle-api. Since 19.1.0. This package contains I/O related classes used by [`com.oracle.truffle.api.TruffleLanguage`](com/oracle/truffle/api/TruffleLanguage.md) implementations. ## Classes - [`TruffleProcessBuilder`](com/oracle/truffle/api/io/TruffleProcessBuilder.md): A builder used to create an external subprocess. # ◆ TruffleProcessBuilder [truffle-api](index.md) › [com.oracle.truffle.api.io](com/oracle/truffle/api/io/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.io`](com/oracle/truffle/api/io/index.md). Since 19.1.0. ```java public final class TruffleProcessBuilder ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `TruffleProcessBuilder` A builder used to create an external subprocess. The `TruffleProcessBuilder` instance allows to set subprocess attributes. The [`start()`](com/oracle/truffle/api/io/TruffleProcessBuilder.md#start%28%29) method creates a new [`Process`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Process.html) instance with those attributes. The [`start()`](com/oracle/truffle/api/io/TruffleProcessBuilder.md#start%28%29) method can be invoked repeatedly from the same instance to create new subprocesses with the same attributes. ## Methods ### command(List) `public TruffleProcessBuilder command(List command)`. Since 19.1.0. Sets the executable and arguments. Parameters: `command` `List`: the list containing the executable and its arguments. Returns `TruffleProcessBuilder`: this `builder`. Cite: `com/oracle/truffle/api/io/TruffleProcessBuilder.html#command(java.util.List)` ### command(String...) `public TruffleProcessBuilder command(String... command)`. Since 19.1.0. Sets the executable and arguments. Parameters: `command` `String...`: the string array containing the executable and its arguments. Returns `TruffleProcessBuilder`: this `builder`. Cite: `com/oracle/truffle/api/io/TruffleProcessBuilder.html#command(java.lang.String...)` ### directory(TruffleFile) `public TruffleProcessBuilder directory(TruffleFile currentWorkingDirectory)`. Since 19.1.0. Sets this process current working directory. The `currentWorkingDirectory` may be `null`, in this case the subprocess current working directory is set to `file system current working directory`. Parameters: `currentWorkingDirectory` `TruffleFile`: the new current working directory. Returns `TruffleProcessBuilder`: this `builder`. Cite: `com/oracle/truffle/api/io/TruffleProcessBuilder.html#directory(com.oracle.truffle.api.TruffleFile)` ### redirectErrorStream(boolean) `public TruffleProcessBuilder redirectErrorStream(boolean enabled)`. Since 19.1.0. If `true` the standard error output is merged into standard output. Parameters: `enabled` `boolean`: enables merging of standard error output into standard output. Returns `TruffleProcessBuilder`: this `builder`. Cite: `com/oracle/truffle/api/io/TruffleProcessBuilder.html#redirectErrorStream(boolean)` ### redirectInput(ProcessHandler.Redirect) `public TruffleProcessBuilder redirectInput(ProcessHandler.Redirect source)`. Since 19.1.0. Sets the standard input source. Process started by the `start()` method obtain its standard input from this source. If the source is [`PIPE`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/ProcessHandler.Redirect.html#PIPE), the default value, then the standard input of a subprocess can be written to using the output stream returned by [`Process.getOutputStream()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Process.html#getOutputStream%28%29). If the source is set to [`INHERIT`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/ProcessHandler.Redirect.html#INHERIT), then the [`Process.getOutputStream()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Process.html#getOutputStream%28%29) returns a closed output stream. Parameters: `source` `ProcessHandler.Redirect`: the new standard input source. Returns `TruffleProcessBuilder`: this `builder`. Cite: `com/oracle/truffle/api/io/TruffleProcessBuilder.html#redirectInput(org.graalvm.polyglot.io.ProcessHandler.Redirect)` ### redirectOutput(ProcessHandler.Redirect) `public TruffleProcessBuilder redirectOutput(ProcessHandler.Redirect destination)`. Since 19.1.0. Sets the standard output destination. Process started by the `start()` method send its standard output to this destination. If the destination is [`PIPE`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/ProcessHandler.Redirect.html#PIPE), the default value, then the standard output of a subprocess can be read using the input stream returned by [`Process.getInputStream()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Process.html#getInputStream%28%29). If the destination is set to is set to [`INHERIT`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/ProcessHandler.Redirect.html#INHERIT), then [`Process.getInputStream()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Process.html#getInputStream%28%29) returns a closed input stream. Parameters: `destination` `ProcessHandler.Redirect`: the new standard output destination. Returns `TruffleProcessBuilder`: this `builder`. Cite: `com/oracle/truffle/api/io/TruffleProcessBuilder.html#redirectOutput(org.graalvm.polyglot.io.ProcessHandler.Redirect)` ### redirectError(ProcessHandler.Redirect) `public TruffleProcessBuilder redirectError(ProcessHandler.Redirect destination)`. Since 19.1.0. Sets the standard error output destination. Process started by the `start()` method send its error output to this destination. If the destination is [`PIPE`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/ProcessHandler.Redirect.html#PIPE), the default value, then the standard error of a subprocess can be read using the input stream returned by [`Process.getErrorStream()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Process.html#getErrorStream%28%29). If the destination is set to is set to [`INHERIT`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/ProcessHandler.Redirect.html#INHERIT), then [`Process.getErrorStream()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Process.html#getErrorStream%28%29) returns a closed input stream. Parameters: `destination` `ProcessHandler.Redirect`: the new error output destination. Returns `TruffleProcessBuilder`: this `builder`. Cite: `com/oracle/truffle/api/io/TruffleProcessBuilder.html#redirectError(org.graalvm.polyglot.io.ProcessHandler.Redirect)` ### inheritIO(boolean) `public TruffleProcessBuilder inheritIO(boolean enabled)`. Since 19.1.0. If `true` the subprocess standard input, output and error output are the same as those of the current Java process. Parameters: `enabled` `boolean`: enables standard I/O inheritance. Returns `TruffleProcessBuilder`: this `builder`. Cite: `com/oracle/truffle/api/io/TruffleProcessBuilder.html#inheritIO(boolean)` ### clearEnvironment(boolean) `public TruffleProcessBuilder clearEnvironment(boolean clear)`. Since 19.1.0. If `true` the environment variables are not inherited by the subprocess. Parameters: `clear` `boolean`: disables inheritance of environment variables. Returns `TruffleProcessBuilder`: this `builder`. Cite: `com/oracle/truffle/api/io/TruffleProcessBuilder.html#clearEnvironment(boolean)` ### environment(String, String) `public TruffleProcessBuilder environment(String name, String value)`. Since 19.1.0. Sets the subprocess environment variable. Parameters: `name` `String`: the variable name. `value` `String`: the value. Returns `TruffleProcessBuilder`: this `builder`. Cite: `com/oracle/truffle/api/io/TruffleProcessBuilder.html#environment(java.lang.String,java.lang.String)` ### environment(Map) `public TruffleProcessBuilder environment(Map environment)`. Since 19.1.0. Shortcut for setting multiple `environment variables` using a map. All values of the provided map must be non-null. Parameters: `environment` `Map`: environment variables. Returns `TruffleProcessBuilder`: this `builder`. See also: `To set a single environment variable.`. Cite: `com/oracle/truffle/api/io/TruffleProcessBuilder.html#environment(java.util.Map)` ### createRedirectToStream(OutputStream) `public ProcessHandler.Redirect createRedirectToStream(OutputStream stream)`. Since 19.2.0. Creates a redirect to write into the given [`OutputStream`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/OutputStream.html). It is guaranteed that the process output (error output) is copied into the given stream before the call to [`Process.waitFor()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Process.html#waitFor%28%29) method ends. The stream is not closed when the process terminates. Parameters: `stream` `OutputStream`: the [`OutputStream`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/OutputStream.html) to write into. Throws: `NullPointerException` (unchecked): if the given stream is `null`. Cite: `com/oracle/truffle/api/io/TruffleProcessBuilder.html#createRedirectToStream(java.io.OutputStream)` ### start() `public Process start() throws IOException`. Since 19.1.0. Starts a new subprocess using the attributes of this builder. The new process invokes the command with arguments given by `command(java.lang.String...)`, in a working directory given by `directory(com.oracle.truffle.api.TruffleFile)`, with a process environment inherited from [`Context`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html) and possibly extended by `environment(java.lang.String, java.lang.String)`. Returns `Process`: a new [`Process`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Process.html) instance. Throws: `NullPointerException` (unchecked): if an element of the command list is null. `IndexOutOfBoundsException` (unchecked): if the command is an empty list. `SecurityException` (unchecked): when process creation is forbidden by [`ProcessHandler`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/ProcessHandler.html). `IOException`: if the process fails to execute. Cite: `com/oracle/truffle/api/io/TruffleProcessBuilder.html#start()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ▣ com.oracle.truffle.api.library [truffle-api](index.md) · Every page: [llms.txt](llms.txt) Package in truffle-api. Since 19.0. Truffle Libraries allow language implementations to use polymorphic dispatch for receiver types with support for implementation specific caching/profiling and customization of the dispatch. Libraries enable modularity and encapsulation for representation types in language implementations. Before reading the javadoc make sure you have read the [tutorial](https://github.com/oracle/graal/blob/master/truffle/docs/TruffleLibraries.md). Start learning Truffle Libraries by reading the following articles: - [`Libraries`](com/oracle/truffle/api/library/GenerateLibrary.md) specify the set of available messages i.e. the protocol. - [`Exports`](com/oracle/truffle/api/library/ExportLibrary.md) implement a library for a receiver type. - Automatic dispatching using [@CachedLibrary](com/oracle/truffle/api/library/CachedLibrary.md) allows to call library messages with concrete receiver and parameters from nodes using the [`specialization`](com/oracle/truffle/api/dsl/Specialization.md) DSL. - Manual dispatching using the [LibraryFactory](com/oracle/truffle/api/library/LibraryFactory.md) allows to perform slow-path calls and custom inline cache implementations. Advanced Features: - The [`com.oracle.truffle.api.library.ReflectionLibrary`](com/oracle/truffle/api/library/ReflectionLibrary.md) allows to reflectively export and call messages without binary dependency to a library. It also allows to implement library agnostic proxies. - The [`com.oracle.truffle.api.library.DynamicDispatchLibrary`](com/oracle/truffle/api/library/DynamicDispatchLibrary.md) allows to implement receivers that dynamically dispatch to exported message implementations. **See also** - [`To specify libraries`](com/oracle/truffle/api/library/GenerateLibrary.md) - [`To export libraries`](com/oracle/truffle/api/library/ExportLibrary.md) - [`To dispatch libraries from nodes`](com/oracle/truffle/api/library/CachedLibrary.md) - [`To manually dispatch messages`](com/oracle/truffle/api/library/LibraryFactory.md) ## Classes - [`DynamicDispatchLibrary`](com/oracle/truffle/api/library/DynamicDispatchLibrary.md): A library that allows to dynamically dispatch to export library classes. - [`Library`](com/oracle/truffle/api/library/Library.md): Base class for all Truffle library specifications. - [`LibraryExport`](com/oracle/truffle/api/library/LibraryExport.md): Base class for generated export classes. - [`LibraryFactory`](com/oracle/truffle/api/library/LibraryFactory.md): Library factories allow to create instances of libraries used to call library messages. - [`Message`](com/oracle/truffle/api/library/Message.md): Represents a description of library message. - [`ReflectionLibrary`](com/oracle/truffle/api/library/ReflectionLibrary.md): The reflection library allows to send to and proxy messages of receivers. ## Annotations - [`CachedLibrary`](com/oracle/truffle/api/library/CachedLibrary.md): The cached library annotation allows to use Truffle Libraries conveniently in specializations or exported messages. - [`ExportLibrary`](com/oracle/truffle/api/library/ExportLibrary.md): Allows to export messages of Truffle libraries. - [`ExportMessage`](com/oracle/truffle/api/library/ExportMessage.md): Exports the annotated method or class as library message. - [`GenerateLibrary`](com/oracle/truffle/api/library/GenerateLibrary.md): Libraries are specified with public and abstract Java classes that extend the Library class and are annotated by @GenerateLibrary. # @ CachedLibrary [truffle-api](index.md) › [com.oracle.truffle.api.library](com/oracle/truffle/api/library/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.library`](com/oracle/truffle/api/library/index.md). Since 19.0. ```java @Retention(CLASS) @Target({PARAMETER}) public @interface CachedLibrary ``` The cached library annotation allows to use [`Truffle Libraries`](com/oracle/truffle/api/library/index.md) conveniently in [`specializations`](com/oracle/truffle/api/dsl/Specialization.md) or [`exported messages`](com/oracle/truffle/api/library/ExportMessage.md). It is designed as the primary way of using libraries. The [`CachedLibrary`](com/oracle/truffle/api/library/CachedLibrary.md) annotation may be used for any parameters of methods annotated with [@Specialization](com/oracle/truffle/api/dsl/Specialization.md) or [@ExportMessage](com/oracle/truffle/api/library/ExportMessage.md). ### Using Specialized Libraries A cached library can be specialized for a value that is referred to with the [`value expression`](com/oracle/truffle/api/library/CachedLibrary.md#value%28%29) attribute. A specialized library implicitly prepends a guard for the [`acceptance`](com/oracle/truffle/api/library/Library.md#accepts%28java.lang.Object%29) of a library with the provided value expression. Adding the acceptance guard leads to multiple specialization instances as it binds to the cached library value. The [`specialization`](com/oracle/truffle/api/dsl/Specialization.md#limit%28%29) or [`export`](com/oracle/truffle/api/library/ExportMessage.md#limit%28%29) limit attribute must therefore be specified. If this limit overflows then the operation will rewrite itself to an [`uncached`](com/oracle/truffle/api/library/LibraryFactory.md#getUncached%28java.lang.Object%29) version of the library. Multiple specialized libraries may be used per export or specialization. The acceptance guards for these libraries will be added in the order of their declaration. #### Usage: ```java @NodeChild @NodeChild abstract static class ArrayReadNode extends ExpressionNode { @Specialization(guards = "arrays.isArray(array)", limit = "2") int doDefault(Object array, int index, @CachedLibrary("array") ArrayLibrary arrays) { return arrays.read(array, index); } } ``` It is recommended to use the plural of the specialized parameter name as naming convention for the library parameter name, e.g. a library for an `array` value is called `arrays`. If multiple libraries are specialized for the same specialized expression it is recommended to prepend the library name e.g. `interopArrays`. ### Using Dispatched Libraries If no specialized value expression can be specified, i.e. if the value is computed as part of the operation, then a dispatched version of a library can be used by omitting the [`value`](com/oracle/truffle/api/library/CachedLibrary.md#value%28%29) attribute and specifying the [`limit()`](com/oracle/truffle/api/library/CachedLibrary.md#limit%28%29) attribute instead. A dispatched library builds the specialized value inline cache internally for each invocation of a message instead of once per outer specialization or export. An instance of a dispatched library therefore [`accepts`](com/oracle/truffle/api/library/Library.md#accepts%28java.lang.Object%29) any value as receiver. It is recommended to use the same generic library instance for few message invocations of similar values only, could lead to duplication of inline cache dispatches in the compiled code. The limit of a dispatched library may be set to 0 to directly switch to an uncached version of a library. #### Usage: The following example combines the use of specialized and dispatched libraries. In this example the array is read twice. For the first *outer* read the specializing expression can be used. For the second read the specializing expression cannot be used as it depends on the result of the outer read. We therefore use a dispatched library for the inner array. ```java @NodeChild @NodeChild @NodeChild abstract static class TwoDimReadNode extends ExpressionNode { @Specialization(guards = "outerArrays.isArray(array)", limit = "2") int doDefault(Object array, int outerIndex, int innerIndex, @CachedLibrary("array") ArrayLibrary outerArrays, @CachedLibrary(limit = "2") ArrayLibrary innerArrays) { return innerArrays.read(outerArrays.read(outerIndex), innerIndex); } } ``` **See also** - [`for manually instantiating libraries`](com/oracle/truffle/api/library/LibraryFactory.md) - [`Truffle Library reference documentation`](com/oracle/truffle/api/library/index.md) ## Elements ### value() `String value() default ""`. Since 19.0. Sets the specialized value expression when using specialized libraries. The same syntax applies as for `Cached` value expressions. Default: `""`. See also: `for usage examples.`. Cite: `com/oracle/truffle/api/library/CachedLibrary.html#value()` ### limit() `String limit() default ""`. Since 19.0. Sets the limit expression when using dispatched libraries. The limit expression sets the number of internally dispatched specialized libraries until an `uncached` version of the library will be used. Default: `""`. See also: `for usage examples.`. Cite: `com/oracle/truffle/api/library/CachedLibrary.html#limit()` # ◆ DynamicDispatchLibrary [truffle-api](index.md) › [com.oracle.truffle.api.library](com/oracle/truffle/api/library/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.library`](com/oracle/truffle/api/library/index.md). Since 19.0. ```java public abstract class DynamicDispatchLibrary extends Library ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > [`Library`](com/oracle/truffle/api/library/Library.md) > `DynamicDispatchLibrary` A library that allows to dynamically dispatch to export library classes. Sometimes the target exports for a receiver type cannot be statically determined by the receiver class with the [`ExportLibrary`](com/oracle/truffle/api/library/ExportLibrary.md) annotation. To allow such types to dynamically dispatch to exports the dynamic dispatch library can be exported instead. By exporting dynamic dispatch the export target can be chosen dynamically. The dynamic dispatch library requires to implement the dispatch method. The dispatch method returns the target exports class that this receiver should dispatch to. If it returns `null` then the type will dispatch to the library default exports. The implementation of the dispatch must be stable for a single receiver value. For example it is not allowed to change the dispatch target for a receiver instance. If the dispatch target was changed while the receiver was used by a library then an [`AssertionError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AssertionError.html) will be thrown. #### Full usage example ```java @ExportLibrary(DynamicDispatchLibrary.class) static final class DispatchObject { final Object data; final Class dispatchTarget; DispatchObject(Object data, Class<> dispatchTarget) { this.data = data; this.dispatchTarget = dispatchTarget; } @ExportMessage Class dispatch() { return dispatchTarget; } } @GenerateLibrary public abstract static class ArrayLibrary extends Library { public boolean isArray(Object receiver) { return false; } public abstract int read(Object receiver, int index); } @ExportLibrary(value = ArrayLibrary.class, receiverType = DispatchObject.class) static final class DispatchedBufferArray { @ExportMessage static boolean isArray(DispatchObject o) { return true; } @ExportMessage static int read(DispatchObject o, int index) { return ((int[]) o.data)[index]; } } public static void main(String[] args) { ArrayLibrary arrays = LibraryFactory.resolve(ArrayLibrary.class).getUncached(); assert 42 == arrays.read(new DispatchObject(new int[]{42}, DispatchedBufferArray.class), 0); } ``` ## Constructors ### DynamicDispatchLibrary() `protected DynamicDispatchLibrary()`. Since 19.0. Constructor for generated subclasses. Subclasses of this class are generated, do not extend this class directly. Cite: `com/oracle/truffle/api/library/DynamicDispatchLibrary.html#()` ## Methods ### dispatch(Object) `public Class dispatch(Object receiver)`. Since 19.0. Returns a class that `exports` at least one library with an explicit receiver. Returns `null` to indicate that the default dispatch of the library should be used. Cite: `com/oracle/truffle/api/library/DynamicDispatchLibrary.html#dispatch(java.lang.Object)` ### cast(Object) `public abstract Object cast(Object receiver)`. Since 19.0. Cast the object receiver type to the dispatched type. This is not supposed to be implemented by dynamic dispatch implementer but is automatically implemented when implementing dynamic dispatch. Cite: `com/oracle/truffle/api/library/DynamicDispatchLibrary.html#cast(java.lang.Object)` ### getFactory() `public static LibraryFactory getFactory()`. Since 19.0. Returns the library factory for `DynamicDispatchLibrary`. Cite: `com/oracle/truffle/api/library/DynamicDispatchLibrary.html#getFactory()` ## Inherited members - From class [`Library`](com/oracle/truffle/api/library/Library.md): [`accepts`](com/oracle/truffle/api/library/Library.md#accepts%28java.lang.Object%29) - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # @ ExportLibrary [truffle-api](index.md) › [com.oracle.truffle.api.library](com/oracle/truffle/api/library/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.library`](com/oracle/truffle/api/library/index.md). Since 19.0. ```java @Retention(RUNTIME) @Target({TYPE}) @Repeatable(com.oracle.truffle.api.library.ExportLibrary.Repeat.class) public @interface ExportLibrary ``` Allows to export messages of Truffle libraries. The exported library [`value`](com/oracle/truffle/api/library/ExportLibrary.md#value%28%29) specifies the library class that is exported. If there are abstract methods specified by a library then those messages need to be implemented. A receiver may export multiple libraries at the same time, by specifying multiple export annotations. Subclasses of the receiver type inherit all exported messages and may also be exported again. In this case the subclass overrides the base class export. ### Method Exports Messages are exported by specifying methods annotated by [@ExportMessage](com/oracle/truffle/api/library/ExportMessage.md) that match the name and signature of a library message. By default the message name is inferred by the method name and the library is automatically detected if it can be unambiguously identified by its simple name. If the receiver type is implicit then the receiver type parameter can be omitted. Exported messages allow the use of [Cached](com/oracle/truffle/api/dsl/Cached.md) and [CachedLibrary](com/oracle/truffle/api/library/CachedLibrary.md) parameters at the end of the method. This allows the use of nodes in implementations. #### Usage example Example usage with implicit receiver type: ```java @ExportLibrary(ArrayLibrary.class) static final class BufferArray { private int length; private int[] buffer; BufferArray(int length) { this.length = length; this.buffer = new int[length]; } @ExportMessage boolean isArray() { return true; } @ExportMessage int read(int index) { return buffer[index]; } } ``` ### Class exports If a message export requires more than one [`specialization`](com/oracle/truffle/api/dsl/Specialization.md) then the export must be specified as class. In this case the simple name of the message is resolved by using the class name and turning the first character lower-case. So for an exported class named `Read` the message `read` would be used. It is not allowed to use a method export and a class export for the same message at the same time. Multiple [`ExportMessage`](com/oracle/truffle/api/library/ExportMessage.md) annotations may be used for the same method or class to export them for multiple messages. In this case the [`message name`](com/oracle/truffle/api/library/ExportMessage.md#name%28%29) needs to be specified explicitly and the target signatures need to match for all exported messages. #### Usage example ```java @ExportLibrary(value = ArrayLibrary.class) static final class SequenceArray { final int start; final int stride; final int length; SequenceArray(int start, int stride, int length) { this.start = start; this.stride = stride; this.length = length; } @ExportMessage boolean isArray() { return true; } @ExportMessage static class Read { @Specialization(guards = {"seq.stride == cachedStride", "seq.start == cachedStart"}, limit = "1") static int doSequenceCached(SequenceArray seq, int index, @Cached("seq.start") int cachedStart, @Cached("seq.stride") int cachedStride) { return cachedStart + cachedStride * index; } @Specialization(replaces = "doSequenceCached") static int doSequence(SequenceArray seq, int index) { return doSequenceCached(seq, index, seq.start, seq.stride); } } } ``` ### Explicit Receiver Types For [`default exports`](com/oracle/truffle/api/library/GenerateLibrary.DefaultExport.md) or types that support [`dynamic dispatch`](com/oracle/truffle/api/library/DynamicDispatchLibrary.md) the export may declare an [`explicit receiver type`](com/oracle/truffle/api/library/ExportLibrary.md#receiverType%28%29). **See also** - [`GenerateLibrary`](com/oracle/truffle/api/library/GenerateLibrary.md) - [`CachedLibrary`](com/oracle/truffle/api/library/CachedLibrary.md) ## Nested types - [`ExportLibrary.Repeat`](com/oracle/truffle/api/library/ExportLibrary.Repeat.md) (annotation interface): Repeat annotation for ExportLibrary. ## Elements ### value() `Class value()`. Since 19.0. The library class that specifies the messages that are exported. Cite: `com/oracle/truffle/api/library/ExportLibrary.html#value()` ### receiverType() `Class receiverType() default java.lang.Void.class`. Since 19.0. The explicit receiver type to use if specified. This is useful to specifying the receiver type for `default exports` or types that are `dynamically dispatched`. If specified, all exported methods need to be declared statically with the receiver type argument as first parameter. Usage example. Default: `java.lang.Void.class`. Cite: `com/oracle/truffle/api/library/ExportLibrary.html#receiverType()` ```java @ExportLibrary(value = ArrayLibrary.class, receiverType = Integer.class) static final class ScalarIntegerArray { @ExportMessage static boolean isArray(Integer receiver) { return true; } @ExportMessage int read(Integer receiver, int index) { if (index == 0) { return receiver; } else { throw new ArrayIndexOutOfBoundsException(index); } } } ``` ### delegateTo() `String delegateTo() default ""`. Since 20.0. Automatically forwards all messages of the library which are not exported to the value of a delegate field. This can be used to conveniently build wrapper types that do not delegate all but only some of the messages. To forward messages from unknown libraries, this can be combined with `reflection proxies`. The specified field name must link to a field in the specified `receiver type`, or in the annotated type if no receiver type is specified. The field must have the modifier `final`. The specified field must be visible to the generated code and therefore not private. The referenced field must not be static. Usage example In the following wrapper all messages of ArrayLibrary will be forwarded to the value of the delegate field. In the following wrapper the toDisplayString will be re-exported and not delegated to the delegate field. All other messages of the ArrayLibrary are implicitly delegated to the value of the delegate field. In the following wrapper the toDisplayString will be exported but forwards to the delegate manually adding brackets around the delegate value. In the following wrapper the toDisplayString message is re-exported. Other messages of the ArrayLibrary are delegated as well as all messages of any other library that supports reflection. Default: `""`. Cite: `com/oracle/truffle/api/library/ExportLibrary.html#delegateTo()` ```java @GenerateLibrary public abstract class ArrayLibrary extends Library { public String toDisplayString(Object receiver) { return receiver.toString(); } public String otherMessage(Object receiver) { return "otherResult"; } } ``` ```java @ExportLibrary(value = ArrayLibrary.class, delegateTo = "delegate") final class ArrayDelegateWrapper { final Object delegate; ArrayDelegateWrapper(Object delegate) { this.delegate = delegate; } } ``` ```java @ExportLibrary(value = ArrayLibrary.class, delegateTo = "delegate") final class ArrayOverrideWrapper { final Object delegate; ArrayOverrideWrapper(Object delegate) { this.delegate = delegate; } @ExportMessage final String toDisplayString() { return "Wrapped"; } } ``` ```java @ExportLibrary(value = ArrayLibrary.class, delegateTo = "delegate") final class ArrayManualDelegateWrapper { final Object delegate; ArrayManualDelegateWrapper(Object delegate) { this.delegate = delegate; } @ExportMessage final String toDisplayString( @CachedLibrary("this.delegate") ArrayLibrary arrayLibrary) { return "Wrapped[" + arrayLibrary.toDisplayString(delegate) + "]"; } } ``` ```java @ExportLibrary(value = ArrayLibrary.class, delegateTo = "delegate") @ExportLibrary(value = ReflectionLibrary.class, delegateTo = "delegate") final class ArrayFullWrapper { final Object delegate; ArrayFullWrapper(Object delegate) { this.delegate = delegate; } @ExportMessage final String toDisplayString() { return "Wrapped"; } } ``` ### priority() `int priority() default 0`. Since 20.1. Specifies the priority for service provider lookup based default exports. Needs to be specified for exports with explicit receiver type, that are not declared as default exports. Positive values indicate a priority higher than library builtin `default exports`, negative values lower than default exports. A priority equal to 0 is invalid. Default: `0`. Cite: `com/oracle/truffle/api/library/ExportLibrary.html#priority()` ### transitionLimit() `String transitionLimit() default ""`. Since 20.1. By default export libraries don't allow changes in the behavior of accepts for a receiver instance. If this assumption is violated then an [`AssertionError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AssertionError.html) is thrown. If the transition limit is set then the accepts condition is allowed to transition from `true` to `false` for a library created for a receiver instance. The limit expression specifies how many fallback library instances should be created until the library is dispatching to uncached cases of the library. By default accepts transitions are not allowed. Note this option is only relevant if you use a custom accepts implementation in the export. If the receiver transitions in parallel then there are no guarantees provided. The library caller is responsible to provide proper synchronization. This feature is useful to implement runtime value representations that dynamically transition from one state to the next. With arrays, a common example is the access strategy that changes from sparse or dense arrays. Another use-case is the Truffle object model, where the shape should be used in the accepts condition, to common out the shape check, but at the same time the shape should be able to transition due to a property write. The transition limit expression is allowed to access visible static fields or methods of the enclosing class. If the limit needs to be looked up from an option it is recommended to extract the option lookup in a static Java method. **Performance note:** If any number of transitions is enabled, the accepts guard of this library effectively needs to be repeated on every message invocation of this export. It is therefore recommended to not set this property for performance reasons, if possible. It is also recommended to double check that the duplicated accepts guard for every message is eliminated in the compiler graphs after Partial evaluation. Default: `""`. See also: `Library.accepts(Object)`. Cite: `com/oracle/truffle/api/library/ExportLibrary.html#transitionLimit()` ### useForAOT() `boolean useForAOT() default false`. Since 21.2. Enables `AOT preparation` for this export. An exported library must use the `GenerateAOT` annotation on the library class to allow exports to enable AOT. Multiple AOT exports may be specified for each library. The library may be used for implicit and explicit receivers, dynamic dispatch and default exports. Merged libraries are currently not supported for AOT enabled exports. A `priority` must be set in order to resolve a deterministic order for AOT initialized exports. All exported libraries with AOT enabled are loaded and initialized eagerly when a library that supports AOT is used for the first time. In order for this to work the exported library automatically generates subclass of `EagerExportProvider`, that must be registered in the module descriptor as a provided service. When the language is compiled using native-image then this is not necessary as native-image compilation discovers all AOT exports for a library during native image generation. Default: `false`. Cite: `com/oracle/truffle/api/library/ExportLibrary.html#useForAOT()` ### useForAOTPriority() `int useForAOTPriority() default 0`. Since 21.2. Specifies the priority for the export when used for AOT preparation. A higher priority indicates that this export should be ordered earlier in the code rather than later. For example if a library has two exports and one has a higher priority then the export with the higher priority with be inserted first in the inline cache. Consequently, the library export accepts method will be invoked earlier for a higher priority. Default: `0`. Cite: `com/oracle/truffle/api/library/ExportLibrary.html#useForAOTPriority()` # @ ExportLibrary.Repeat [truffle-api](index.md) › [com.oracle.truffle.api.library](com/oracle/truffle/api/library/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.library`](com/oracle/truffle/api/library/index.md). Since 19.0. Nested in [`ExportLibrary`](com/oracle/truffle/api/library/ExportLibrary.md). ```java @Retention(RUNTIME) @Target({TYPE}) public @interface ExportLibrary.Repeat ``` Repeat annotation for [`ExportLibrary`](com/oracle/truffle/api/library/ExportLibrary.md). ## Elements ### value() `ExportLibrary[] value()`. Since 19.0. Repeat value for `ExportLibrary`. Cite: `com/oracle/truffle/api/library/ExportLibrary.Repeat.html#value()` # @ ExportMessage [truffle-api](index.md) › [com.oracle.truffle.api.library](com/oracle/truffle/api/library/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.library`](com/oracle/truffle/api/library/index.md). Since 19.0. ```java @Retention(RUNTIME) @Target({METHOD, TYPE}) @Repeatable(com.oracle.truffle.api.library.ExportMessage.Repeat.class) public @interface ExportMessage ``` Exports the annotated method or class as library message. The annotation can only be applied to method or classes with an enclosing class annotated by [`ExportLibrary`](com/oracle/truffle/api/library/ExportLibrary.md). Exported messages are inherited to subclasses of the enclosing class. If they are redeclared in the sub-class then the semantics of the overridden message is replaced by the semantics of the sub-class. A class and a method cannot be exported at the same time for a single message and enclosing class. **See also** - [`For usage examples.`](com/oracle/truffle/api/library/ExportLibrary.md) ## Nested types - [`ExportMessage.Ignore`](com/oracle/truffle/api/library/ExportMessage.Ignore.md) (annotation interface): Explicitly ignores warning messages originating from the ExportLibrary annotation. - [`ExportMessage.Repeat`](com/oracle/truffle/api/library/ExportMessage.Repeat.md) (annotation interface): No description. ## Elements ### name() `String name() default ""`. Since 19.0. Returns the message simple name to export. If not specified, the exported message name is inherited from the enclosing method name or class. In case of an exported class the first letter is automatically translated to lower-case. The name attribute should be specified if the exported message does not match the exported method or class name or if multiple messages need to be exported for a method or class. Default: `""`. Cite: `com/oracle/truffle/api/library/ExportMessage.html#name()` ### library() `Class library() default com.oracle.truffle.api.library.Library.class`. Since 19.0. Returns the library to export by this method or class. Automatically selected if the name of the message is unique. Needs to be specified if the name is not unique when implementing multiple libraries. Default: `com.oracle.truffle.api.library.Library.class`. Cite: `com/oracle/truffle/api/library/ExportMessage.html#library()` ### limit() `String limit() default ""`. Since 19.0. Specifies the limit of an exported message. The limit specifies the number of specialized instances of `cached library` should be used until the library rewrites itself to an uncached case. Default: `""`. See also: `Specialization.limit()`, `CachedLibrary`. Cite: `com/oracle/truffle/api/library/ExportMessage.html#limit()` # @ ExportMessage.Ignore [truffle-api](index.md) › [com.oracle.truffle.api.library](com/oracle/truffle/api/library/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.library`](com/oracle/truffle/api/library/index.md). Since 19.0. Nested in [`ExportMessage`](com/oracle/truffle/api/library/ExportMessage.md). ```java @Retention(RUNTIME) @Target({METHOD, TYPE}) public @interface ExportMessage.Ignore ``` Explicitly ignores warning messages originating from the [`ExportLibrary`](com/oracle/truffle/api/library/ExportLibrary.md) annotation. # @ ExportMessage.Repeat [truffle-api](index.md) › [com.oracle.truffle.api.library](com/oracle/truffle/api/library/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.library`](com/oracle/truffle/api/library/index.md). Since 19.0. Nested in [`ExportMessage`](com/oracle/truffle/api/library/ExportMessage.md). ```java @Retention(RUNTIME) @Target({METHOD, TYPE}) public @interface ExportMessage.Repeat ``` ## Elements ### value() `ExportMessage[] value()`. Since 19.0. Cite: `com/oracle/truffle/api/library/ExportMessage.Repeat.html#value()` # @ GenerateLibrary [truffle-api](index.md) › [com.oracle.truffle.api.library](com/oracle/truffle/api/library/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.library`](com/oracle/truffle/api/library/index.md). Since 19.0. ```java @Retention(RUNTIME) @Target({TYPE}) public @interface GenerateLibrary ``` Libraries are specified with `public` and `abstract` Java classes that extend the [Library](com/oracle/truffle/api/library/Library.md) class and are annotated by `@GenerateLibrary`. A library consists of a set of messages, that are specified using public Java methods. The methods may be abstract or use default implementations. The first parameter of every library message is the receiver parameter, which must be a non-primitive type and consistent across all messages of a library. There are no restrictions on the return type or argument types of a message. Every method that specifies a message must have a name that is unique per library. Final or private methods will always be ignored by the generator. Parameter type overloading is currently not supported for messages, therefore every public method must have a unique name per library. Generic type arguments local to messages are generally supported, but generic type arguments on the library type are not yet supported. ### Basic Usage The following example specifies a basic library for arrays: ```java @GenerateLibrary public abstract class ArrayLibrary extends Library { public boolean isArray(Object receiver) { return false; } public abstract int read(Object receiver, int index); } ``` Messages that are not implemented and have no default implementation throw an [`AbstractMethodError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AbstractMethodError.html). The [`Abstract`](com/oracle/truffle/api/library/GenerateLibrary.Abstract.md) annotation can be used, to provide a default implementation for receiver types but at the same time make the message abstract. A library class may also specify [`default exports`](com/oracle/truffle/api/library/GenerateLibrary.DefaultExport.md) that can be used to dispatch to receiver types that don't export the library. Since the receiver type for default exports can be specified explicitly, it can be used to provide a default implementation for receiver types of third parties or the JDK. For example the Truffle interop library has default exports for most [`Number`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Number.html) types, [`String`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html) and [`Boolean`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Boolean.html) type. In order to enable AOT generation for a library annotate the class with [`GenerateAOT`](com/oracle/truffle/api/dsl/GenerateAOT.md) and enable exports to be used for AOT by setting [`ExportLibrary.useForAOT()`](com/oracle/truffle/api/library/ExportLibrary.md#useForAOT%28%29) to `true`. ### Deprecating Messages If a library message gets deprecated using the [`Deprecated`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Deprecated.html) annotation then all exports will get a deprecation warning. This can be useful to evolve libraries over time in a compatible way. Sometimes it is needed to remove or modify types of parameters as part of evolution. In this case it is possible to declare multiple overloads of the same library message where all but one method are annotated with [`Deprecated`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Deprecated.html). The non-deprecated method must use more generic or the same parameter types. For example, this allows to evolve message with parameter [`String`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html) to evolve into [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html). It is also possible to add or remove parameter types in the non-deprecated method. These restrictions are necessary in order to ensure that exports of that message never export the new overload after recompilation unless the parameter types were updated. **See also** - [`to specify default exports.`](com/oracle/truffle/api/library/GenerateLibrary.DefaultExport.md) - [`to make messages abstract if they have a default implemetnation`](com/oracle/truffle/api/library/GenerateLibrary.Abstract.md) ## Nested types - [`GenerateLibrary.Abstract`](com/oracle/truffle/api/library/GenerateLibrary.Abstract.md) (annotation interface): Makes a library message abstract, but allows to keep a default implementation. - [`GenerateLibrary.DefaultExport`](com/oracle/truffle/api/library/GenerateLibrary.DefaultExport.md) (annotation interface): Specifies library implementations provided by default as a fallback. ## Elements ### assertions() `Class assertions() default com.oracle.truffle.api.library.Library.class`. Since 19.0. Specifies an assertion wrapper class that can be used to verify pre and post conditions of a library. Assertion wrappers are only inserted when assertions (-ea) are enabled. It is required that assertion wrappers don't introduce additional side-effects and call the delegate methods exactly once. If assertions are disabled no library wrapper will be inserted therefore not performing any checks when library messages are invoked. **Example Usage:**. Default: `com.oracle.truffle.api.library.Library.class`. Cite: `com/oracle/truffle/api/library/GenerateLibrary.html#assertions()` ```java @GenerateLibrary(assertions = ArrayAssertions.class) public abstract class ArrayLibrary extends Library { public boolean isArray(Object receiver) { return false; } public int read(Object receiver, int index) { throw new UnsupportedOperationException(); } static class ArrayAssertions extends ArrayLibrary { @Child private ArrayLibrary delegate; ArrayAssertions(ArrayLibrary delegate) { this.delegate = delegate; } @Override public boolean isArray(Object receiver) { return delegate.isArray(receiver); } @Override public int read(Object receiver, int index) { int result = super.read(receiver, index); assert delegate.isArray(receiver) : "if a read was successful the receiver must be an array"; return result; } @Override public boolean accepts(Object receiver) { return delegate.accepts(receiver); } } } ``` ### receiverType() `Class receiverType() default java.lang.Object.class`. Since 19.0. Restricts the receiver type for exports that implement this library. This allows to have different receiver type in message methods, but require export receiver types to implement or extend a declared class. Default exports are not affected by this restriction and can therefore export the library for any receiver type the message methods first parameter is compatible with. Default: `java.lang.Object.class`. Cite: `com/oracle/truffle/api/library/GenerateLibrary.html#receiverType()` ### defaultExportLookupEnabled() `boolean defaultExportLookupEnabled() default false`. Since 20.1. Allows the library to lookup additional default exports using a service provider interface. `Exports` for this library with explicit receiver type will automatically be interpreted as additional default exports. External default exports may specify with the `priority` whether they are looked up before or after existing default exports specified for the library. Default exports always have a lower priority than explicit exports on the receiver type or exports that use dynamic dispatch. Default: `false`. See also: `ExportLibrary.priority()`. Cite: `com/oracle/truffle/api/library/GenerateLibrary.html#defaultExportLookupEnabled()` ### dynamicDispatchEnabled() `boolean dynamicDispatchEnabled() default true`. Since 20.1. Allows the use of `DynamicDispatchLibrary` with this library. By default, dynamic dispatch is enabled. If this flag is set to `false` then the `dispatch` method will not be used for this library. Only default exports and exports declared with the receiver type will be used instead for this library. Default: `true`. Cite: `com/oracle/truffle/api/library/GenerateLibrary.html#dynamicDispatchEnabled()` ### pushEncapsulatingNode() `boolean pushEncapsulatingNode() default true`. Since 20.3. Enables push and pop of the encapsulating node when a library transitions from cached to uncached. The current encapsulating node is needed for correct stack trace location when library exports perform guest language calls. If a library is known to never need correct stack trace information, e.g. if all exports are known to not perform guest language calls, then pushing and popping of encapsulating nodes can be disabled. By default pushing and popping of encapsulating nodes is enabled. Default: `true`. See also: `EncapsulatingNodeReference`. Cite: `com/oracle/truffle/api/library/GenerateLibrary.html#pushEncapsulatingNode()` # @ GenerateLibrary.Abstract [truffle-api](index.md) › [com.oracle.truffle.api.library](com/oracle/truffle/api/library/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.library`](com/oracle/truffle/api/library/index.md). Since 19.0. Nested in [`GenerateLibrary`](com/oracle/truffle/api/library/GenerateLibrary.md). ```java @Retention(CLASS) @Target({METHOD}) public @interface GenerateLibrary.Abstract ``` Makes a library message abstract, but allows to keep a default implementation. By default, abstract messages throw an [`AbstractMethodError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AbstractMethodError.html) if they are not exported for a given receiver type. To customize this behavior the library message can specify a method body and annotate it with [`Abstract`](com/oracle/truffle/api/library/GenerateLibrary.Abstract.md) to keep requiring an implementation from exports. **For example:** ```java @GenerateLibrary public abstract class ArrayLibrary extends Library { @Abstract(ifExported = "read") public boolean isArray(Object receiver) { return false; } @Abstract(ifExported = "isArray") public int read(Object receiver, int index) { throw new UnsupportedOperationException(); } } ``` In this example a receiver that does not export the `ArrayLibrary` will return `false` for `isArray` and throw an [UnsupportedOperationException](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/UnsupportedOperationException.html) for `read` calls. A message may be made conditionally abstract by specifying the [`Abstract.ifExported()`](com/oracle/truffle/api/library/GenerateLibrary.Abstract.md#ifExported%28%29) attribute. **See also** - [`ifExported()`](com/oracle/truffle/api/library/GenerateLibrary.Abstract.md#ifExported%28%29) ## Elements ### ifExported() `String[] ifExported() default {}`. Since 19.0. Specifies a message to be abstract only if another message is implemented. Multiple other messages can be specified. If the list is empty, the message is always abstract unless `Abstract.ifExportedAsWarning()` is not empty. If the list is not empty it takes precedence over `Abstract.ifExportedAsWarning()`. **For example:** In this example the isArray message only needs to be exported if the read message is exported and vice-versa. Default: `{}`. Cite: `com/oracle/truffle/api/library/GenerateLibrary.Abstract.html#ifExported()` ```java @GenerateLibrary public abstract class ArrayLibrary extends Library { @Abstract(ifExported = "read") public boolean isArray(Object receiver) { return false; } @Abstract(ifExported = "isArray") public int read(Object receiver, int index) { throw new UnsupportedOperationException(); } } ``` ### ifExportedAsWarning() `String[] ifExportedAsWarning() default {}`. Since 23.0. Specifies a message to be abstract only if another message is implemented. Multiple other messages can be specified. The message is not actually made abstract unless it is in the `Abstract.ifExported()` list. Only a warning is produced that prompts the user to implement the message **For example:** In this example, if the isNumber message is exported and the getNumber message is not, the user gets a warning. Default: `{}`. Cite: `com/oracle/truffle/api/library/GenerateLibrary.Abstract.html#ifExportedAsWarning()` ```java @GenerateLibrary public abstract class MaybeNumberLibrary extends Library { public boolean isNumber(Object receiver) { return false; } @Abstract(ifExportedAsWarning = "isNumber") public Number getNumber(Object receiver) { throw new UnsupportedOperationException(); } } ``` ### replacementOf() `String replacementOf() default ""`. Since 25.1. A tool to deprecate and replace messages during library evolution. The primary use case is to facilitate transitions from one message to another by designating a new message as a replacement for an older, deprecated message. When this annotation is present, and the deprecated message is not explicitly implemented, a default implementation is generated that delegates from the deprecated message to its designated replacement. The message specification may optionally include argument types in parentheses. When delegation cannot be handled automatically, a custom implementation can be provided using `replacementMethod()`. The migration behavior between deprecated and replacement messages depends on whether the exporter (the library implementer) and the client (the library user) have migrated to the new API. The following combinations are supported: **Both exporter and client use the deprecated API:** The original deprecated message is used exactly as before deprecation. No delegation or generated replacement is involved.; **Exporter uses the deprecated API, client uses the new API:** The default implementation of the new message is used. It delegates to the exporter's implementation of the deprecated message.; **Exporter uses the new API, client uses the deprecated API:** The annotation processor generates an implementation of the deprecated message that delegates to the exporter's new message. When the default delegation is insufficient, the `replacementMethod()` can be used to provide a custom conversion or adapter.; **Both exporter and client use the new API:** The generated deprecated message is no longer needed and can be safely removed once all usages have migrated. **Example:** In this example, the `read(Object, long)` message replaces `read(Object, int)`. If only the new message is implemented, the following delegation is generated automatically: Legacy clients can continue calling the deprecated message, while exporters need only implement the new message signature. Default: `""`. See also: `replacementMethod()`. Cite: `com/oracle/truffle/api/library/GenerateLibrary.Abstract.html#replacementOf()` ```java @GenerateLibrary public abstract class ArrayLibrary extends Library { @Abstract(ifExported = "isArray") @Deprecated public int read(Object receiver, int index) { throw new UnsupportedOperationException(); } @Abstract(ifExported = "isArray", replacementOf = "read(Object, int)") public int read(Object receiver, long index) { throw new UnsupportedOperationException(); } } ``` ```java public int read(Object receiver, int index) { return read(receiver, (long) index); } ``` ### replacementMethod() `String replacementMethod() default ""`. Since 25.1. Specifies a custom replacement method to handle delegation for a message declared with `replacementOf()`. This attribute provides a way to manually implement delegation logic when automatic delegation from the deprecated message to its replacement cannot be generated correctly. Typical reasons include differences in argument semantics, necessary type conversions, or behavioral changes that cannot be inferred automatically. This element is only valid when `replacementOf()` is also set. Using it without `replacementOf` will result in a compilation error. The specified method must have a compatible signature and be accessible from the annotated message. **Example:** In this example, the deprecated `read(Object, int)` message cannot be automatically delegated to `read(Object, long)` because the index must be treated as unsigned. The custom `readLegacy` method therefore provides the correct conversion logic. Default: `""`. See also: `replacementOf()`. Cite: `com/oracle/truffle/api/library/GenerateLibrary.Abstract.html#replacementMethod()` ```java @Abstract(ifExported = "isArray", replacementOf = "read(Object, int)", replacementMethod = "readLegacy") public int read(Object receiver, long unsignedIndex) { throw new UnsupportedOperationException(); } protected final int readLegacy(Object receiver, int index) { long unsignedIndex = Integer.toUnsignedLong(index); return read(receiver, unsignedIndex); } ``` # @ GenerateLibrary.DefaultExport [truffle-api](index.md) › [com.oracle.truffle.api.library](com/oracle/truffle/api/library/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.library`](com/oracle/truffle/api/library/index.md). Since 19.0. Nested in [`GenerateLibrary`](com/oracle/truffle/api/library/GenerateLibrary.md). ```java @Retention(CLASS) @Target({TYPE}) @Repeatable(com.oracle.truffle.api.library.GenerateLibrary.DefaultExport.Repeat.class) public @interface GenerateLibrary.DefaultExport ``` Specifies [`library`](com/oracle/truffle/api/library/GenerateLibrary.md) implementations provided by default as a fallback. May only be used on classes annotated with Library. ## Nested types - [`GenerateLibrary.DefaultExport.Repeat`](com/oracle/truffle/api/library/GenerateLibrary.DefaultExport.Repeat.md) (annotation interface): No description. ## Elements ### value() `Class value()`. Since 19.0. Cite: `com/oracle/truffle/api/library/GenerateLibrary.DefaultExport.html#value()` # @ GenerateLibrary.DefaultExport.Repeat [truffle-api](index.md) › [com.oracle.truffle.api.library](com/oracle/truffle/api/library/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.library`](com/oracle/truffle/api/library/index.md). Since 19.0. Nested in [`GenerateLibrary.DefaultExport`](com/oracle/truffle/api/library/GenerateLibrary.DefaultExport.md). ```java @Retention(CLASS) @Target({TYPE}) public @interface GenerateLibrary.DefaultExport.Repeat ``` ## Elements ### value() `GenerateLibrary.DefaultExport[] value()`. Since 19.0. Cite: `com/oracle/truffle/api/library/GenerateLibrary.DefaultExport.Repeat.html#value()` # ◆ Library [truffle-api](index.md) › [com.oracle.truffle.api.library](com/oracle/truffle/api/library/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.library`](com/oracle/truffle/api/library/index.md). Since 19.0. ```java public abstract class Library extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `Library` Base class for all Truffle library specifications. Required base class for classes annotated with [`GenerateLibrary`](com/oracle/truffle/api/library/GenerateLibrary.md). Implementations for the abstract methods specified in this classes are not supposed to be implemented manually. **See also** - [`GenerateLibrary`](com/oracle/truffle/api/library/GenerateLibrary.md) ## Constructors ### Library() `protected Library()`. Since 19.0. Default constructor for sub-classes. Libraries always have a no-arg protected constructor. Cite: `com/oracle/truffle/api/library/Library.html#()` ## Methods ### accepts(Object) `public abstract boolean accepts(Object receiver)`. Since 19.0. Returns `true` if this library instance supports sending messages with the given receiver. If accepts returns `false` and a library message is sent anyway then an [`AssertionError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AssertionError.html) is thrown if assertions are enabled (-ea). Otherwise a [`NullPointerException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) or [`ClassCastException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ClassCastException.html) may be thrown by the method. A library that was created using a receiver value i.e. a `LibraryFactory.create(Object)` only guarantees to accept the value it was constructed with. For other values, the method may return `false`. Such libraries need to check for acceptance before calling a library method with a receiver. If receiver values are not accepted then a new library needs to be created or fetched. Dispatched versions of libraries always return `true` for any value as they take care of dispatching to any receiver type. It is not necessary to call accepts manually for most use cases. Instead the `CachedLibrary` should be used instead. For slow-paths the `internally dispatched` versions of the uncached library should be used. The accepts message may be exported by receiver types. When exported it can only be further restricted in addition to the default accepts implementation. See also: `for ways how to dispatch libraries.`. Cite: `com/oracle/truffle/api/library/Library.html#accepts(java.lang.Object)` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ LibraryExport [truffle-api](index.md) › [com.oracle.truffle.api.library](com/oracle/truffle/api/library/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.library`](com/oracle/truffle/api/library/index.md). Since 19.0. ```java public abstract class LibraryExport ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `LibraryExport` Base class for generated export classes. This class is not intended to be sub-classed or used manually. **See also** - [`to implement / export library message.`](com/oracle/truffle/api/library/ExportLibrary.md) ## Nested types - [`LibraryExport.DelegateExport`](com/oracle/truffle/api/library/LibraryExport.DelegateExport.md) (interface): Internal interface for generated code only. ## Constructors ### LibraryExport(Class, Class, boolean) `protected LibraryExport(Class library, Class receiverClass, boolean defaultExport)`. Since 19.0. Constructor for generated code. Do not call manually. Cite: `com/oracle/truffle/api/library/LibraryExport.html#(java.lang.Class,java.lang.Class,boolean)` ### LibraryExport(Class, Class, …) `protected LibraryExport(Class library, Class receiverClass, boolean defaultExport, boolean aot, int aotPriority)`. Since 21.2. Constructor for generated code. Do not call manually. Cite: `com/oracle/truffle/api/library/LibraryExport.html#(java.lang.Class,java.lang.Class,boolean,boolean,int)` ## Methods ### createUncached(Object) `protected abstract T createUncached(Object receiver)`. Since 19.0. Implemented generated by `ExportLibrary`. Do not implement manually. Cite: `com/oracle/truffle/api/library/LibraryExport.html#createUncached(java.lang.Object)` ### createCached(Object) `protected abstract T createCached(Object receiver)`. Since 19.0. Implemented generated by `ExportLibrary`. Do not implement manually. Cite: `com/oracle/truffle/api/library/LibraryExport.html#createCached(java.lang.Object)` ### assertAdopted(Node) `protected static boolean assertAdopted(Node node)`. Since 23.1. Internal method for generated code only. Cite: `com/oracle/truffle/api/library/LibraryExport.html#assertAdopted(com.oracle.truffle.api.nodes.Node)` ### createDelegate(LibraryFactory, T) `protected static T createDelegate(LibraryFactory factory, T delegate)`. Since 20.0. Internal method for generated code only. Cite: `com/oracle/truffle/api/library/LibraryExport.html#createDelegate(com.oracle.truffle.api.library.LibraryFactory,T)` ### createMessageBitSet(LibraryFactory, String...) `protected static FinalBitSet createMessageBitSet(LibraryFactory factory, String... messageNames)`. Since 20.0. Internal method for generated code only. Cite: `com/oracle/truffle/api/library/LibraryExport.html#createMessageBitSet(com.oracle.truffle.api.library.LibraryFactory,java.lang.String...)` ### toString() `public final String toString()`. Since 19.0. Overrides `toString()`. Cite: `com/oracle/truffle/api/library/LibraryExport.html#toString()` ### register(Class, LibraryExport...) `public static void register(Class receiverClass, LibraryExport... libs)`. Since 19.0. Called only by code generated by `ExportLibrary`. Do not call manually. Multiple calls with the same receiver class will lead to an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html). Cite: `com/oracle/truffle/api/library/LibraryExport.html#register(java.lang.Class,com.oracle.truffle.api.library.LibraryExport...)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ LibraryExport.DelegateExport [truffle-api](index.md) › [com.oracle.truffle.api.library](com/oracle/truffle/api/library/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.library`](com/oracle/truffle/api/library/index.md). Since 20.0. Nested in [`LibraryExport`](com/oracle/truffle/api/library/LibraryExport.md). ```java protected interface LibraryExport.DelegateExport ``` Internal interface for generated code only. ## Methods ### readDelegateExport(Object) `Object readDelegateExport(Object receiver)`. Since 20.0. Internal method for generated code only. Cite: `com/oracle/truffle/api/library/LibraryExport.DelegateExport.html#readDelegateExport(java.lang.Object)` ### getDelegateExportMessages() `FinalBitSet getDelegateExportMessages()`. Since 20.0. Internal method for generated code only. Cite: `com/oracle/truffle/api/library/LibraryExport.DelegateExport.html#getDelegateExportMessages()` ### getDelegateExportLibrary(Object) `Library getDelegateExportLibrary(Object delegate)`. Since 20.0. Internal method for generated code only. Cite: `com/oracle/truffle/api/library/LibraryExport.DelegateExport.html#getDelegateExportLibrary(java.lang.Object)` # ◆ LibraryFactory [truffle-api](index.md) › [com.oracle.truffle.api.library](com/oracle/truffle/api/library/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.library`](com/oracle/truffle/api/library/index.md). Since 19.0. ```java public abstract class LibraryFactory ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `LibraryFactory` Library factories allow to create instances of libraries used to call library messages. A library factory for a library class can be looked up using the static method [`resolve(Class)`](com/oracle/truffle/api/library/LibraryFactory.md#resolve%28java.lang.Class%29). Library instances are either *automatically dispatched* or *manually dispatched*. Automatically dispatched libraries always return `true` for [`Library.accepts(Object)`](com/oracle/truffle/api/library/Library.md#accepts%28java.lang.Object%29) therefore they can be used with changing receiver values. Manually dispatched libraries are created once for a receiver and are only valid as long as [`accepts`](com/oracle/truffle/api/library/Library.md#accepts%28java.lang.Object%29) returns `true`. Once accepts was checked for an individual value, it is guaranteed that the accepts continues to return true. It is therefore not necessary to call accepts again for multiple message invocations. To create automatically dispatched versions of libraries use either [`createDispatched(int)`](com/oracle/truffle/api/library/LibraryFactory.md#createDispatched%28int%29) or [`getUncached()`](com/oracle/truffle/api/library/LibraryFactory.md#getUncached%28%29). For calling manually dispatched libraries it is recommended to use [`CachedLibrary`](com/oracle/truffle/api/library/CachedLibrary.md) instead using the factory manually. Library instances are either *cached* or *uncached*. Cached instances are library instances designed to be used in ASTs. Cached instances are typically [`adoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29) and store additional profiling information for the cached export. This allows to generate call-site specific profiling information for libray calls. Before a cached instance can be used it must be [`adopted`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29) by a parent node. Uncached versions are designed to be used from slow-path runtime methods or whenever call-site specific profiling is not desired. All uncached versions of a library are annotated with [@TruffleBoundary](com/oracle/truffle/api/CompilerDirectives.TruffleBoundary.md). Uncached instances always return `false` for [`Node.isAdoptable()`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29). This class is intended to be sub-classed by generated code only. Do not sub-class [`LibraryFactory`](com/oracle/truffle/api/library/LibraryFactory.md) manually. **See also** - [`Library`](com/oracle/truffle/api/library/Library.md) - [`LibraryExport`](com/oracle/truffle/api/library/LibraryExport.md) - [`CachedLibrary`](com/oracle/truffle/api/library/CachedLibrary.md) - [`Message`](com/oracle/truffle/api/library/Message.md) ## Constructors ### LibraryFactory(Class, List) `@Deprecated protected LibraryFactory(Class libraryClass, List messages)`. Since 19.0. Deprecated. new versions of the library generator won't use this constructor anymore. Constructor for generated subclasses. Do not sub-class `LibraryFactory` manually. Cite: `com/oracle/truffle/api/library/LibraryFactory.html#(java.lang.Class,java.util.List)` ### LibraryFactory(Class, List, boolean) `protected LibraryFactory(Class libraryClass, List messages, boolean dynamicDispatchEnabled)`. Since 25.1. Constructor for generated subclasses. Do not sub-class `LibraryFactory` manually. Cite: `com/oracle/truffle/api/library/LibraryFactory.html#(java.lang.Class,java.util.List,boolean)` ## Methods ### createDispatched(int) `public final T createDispatched(int limit)`. Since 19.0. Creates a new cached and automatically dispatched library given a limit. The limit specifies the number of cached instances that will be automatically dispatched until the dispatched library rewrites itself to an uncached version of the library. If the limit is zero then the library will use an uncached version from the start. Negative values will throw an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html). It is discouraged to use [`Integer.MAX_VALUE`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Integer.html#MAX_VALUE) as parameter to this method. Reasonable values for the limit range from zero to ten. If possible it is recommended to not use this method manually but to use `CachedLibrary` instead. Whenever the limit is reached for a node and the uncached version is in use, the current enclosing node will be available to the uncached library export of the library using `EncapsulatingNodeReference`. See also: `EncapsulatingNodeReference`, `CachedLibrary`. Cite: `com/oracle/truffle/api/library/LibraryFactory.html#createDispatched(int)` ### create(Object) `public final T create(Object receiver)`. Since 19.0. Creates a new manually dispatched cached library for a given receiver. The receiver must not be `null`. The returned library must be adopted before used. For calling manually dispatched libraries it is recommended to use `CachedLibrary` instead using the factory manually. See also: `CachedLibrary`. Cite: `com/oracle/truffle/api/library/LibraryFactory.html#create(java.lang.Object)` ### createAOT(LibraryExport) `protected final T createAOT(LibraryExport lib)`. Since 21.2. Creates an AOT version for a library export. Intended to be used by generated code, do not use manually. Cite: `com/oracle/truffle/api/library/LibraryFactory.html#createAOT(com.oracle.truffle.api.library.LibraryExport)` ### getUncached() `public final T getUncached()`. Since 19.0. Returns an uncached automatically dispatched version of the library. This is version of a library is used for slow-path calls. Cite: `com/oracle/truffle/api/library/LibraryFactory.html#getUncached()` ### getUncached(Object) `public final T getUncached(Object receiver)`. Since 19.0. Returns an uncached manually dispatched library for a given receiver. The receiver must not be `null`. See also: `CachedLibrary`. Cite: `com/oracle/truffle/api/library/LibraryFactory.html#getUncached(java.lang.Object)` ### getMessages() `public final List getMessages()`. Since 22.0. Returns an unmodifiable list of messages that this library provides. The returned list is ordered by `message ids`. Cite: `com/oracle/truffle/api/library/LibraryFactory.html#getMessages()` ### assertAdopted(Node) `protected static boolean assertAdopted(Node node)`. Since 23.1. Internal method for generated code only. Cite: `com/oracle/truffle/api/library/LibraryFactory.html#assertAdopted(com.oracle.truffle.api.nodes.Node)` ### createDispatchImpl(int) `protected abstract T createDispatchImpl(int limit)`. Since 19.0. Creates a cached automatically dispatched version of this library. An implementation for this method is generated, do not implement or call manually. Cite: `com/oracle/truffle/api/library/LibraryFactory.html#createDispatchImpl(int)` ### getAOTExports() `protected final List> getAOTExports()`. Since 21.2. Returns a list of ordered exports to be used for AOT preparation if supported. Intended to be used by generated code only, do not use manually. Cite: `com/oracle/truffle/api/library/LibraryFactory.html#getAOTExports()` ### createUncachedDispatch() `protected abstract T createUncachedDispatch()`. Since 19.0. Creates a uncached automatically dispatched version of this library. An implementation for this method is generated, do not implement or call manually. Cite: `com/oracle/truffle/api/library/LibraryFactory.html#createUncachedDispatch()` ### createProxy(ReflectionLibrary) `protected abstract T createProxy(ReflectionLibrary lib)`. Since 19.0. Creates a proxy version of this library. A proxy version is responsible for dispatching to reflective implementations of messages. An implementation for this method is generated, do not implement manually. Cite: `com/oracle/truffle/api/library/LibraryFactory.html#createProxy(com.oracle.truffle.api.library.ReflectionLibrary)` ### createDelegate(T) `protected T createDelegate(T original)`. Since 20.0. Creates a delegate version of a library. May be used for cached or uncached versions of a library. Intended to be used by generated code only, do not use manually. Cite: `com/oracle/truffle/api/library/LibraryFactory.html#createDelegate(T)` ### createAssertions(T) `protected T createAssertions(T delegate)`. Since 19.0. Creates an assertion version of this library. An implementation for this method is generated, do not implement manually. Cite: `com/oracle/truffle/api/library/LibraryFactory.html#createAssertions(T)` ### getDefaultClass(Object) `protected abstract Class getDefaultClass(Object receiver)`. Since 19.0. Returns default exported used for a given receiver. An implementation for this method is generated, do not implement manually. Cite: `com/oracle/truffle/api/library/LibraryFactory.html#getDefaultClass(java.lang.Object)` ### getLookup() `protected MethodHandles.Lookup getLookup()`. Since 24.0. Returns a method handle lookup used to initialize the library class. Cite: `com/oracle/truffle/api/library/LibraryFactory.html#getLookup()` ### genericDispatch(Library, Object, …) `protected abstract Object genericDispatch(Library library, Object receiver, Message message, Object[] arguments, int parameterOffset) throws Exception`. Since 19.0. Performs a generic dispatch for this library. An implementation for this method is generated, do not implement manually. Cite: `com/oracle/truffle/api/library/LibraryFactory.html#genericDispatch(com.oracle.truffle.api.library.Library,java.lang.Object,com.oracle.truffle.api.library.Message,java.lang.Object[],int)` ### createMessageBitSet(Message...) `protected FinalBitSet createMessageBitSet(Message... enabledMessages)`. Since 20.0. Creates a final bitset of the given messages. Uses an internal index for the messages. An implementation for this method is generated, do not implement manually. Cite: `com/oracle/truffle/api/library/LibraryFactory.html#createMessageBitSet(com.oracle.truffle.api.library.Message...)` ### isDelegated(Library, int) `protected static boolean isDelegated(Library lib, int index)`. Since 20.0. Returns `true` if a message is delegated, otherwise `false`. Intended to be used by generated code only, do not use manually. Cite: `com/oracle/truffle/api/library/LibraryFactory.html#isDelegated(com.oracle.truffle.api.library.Library,int)` ### readDelegate(Library, Object) `protected static Object readDelegate(Library lib, Object receiver)`. Since 20.0. Reads the delegate for a receiver. Intended to be used by generated code only, do not use manually. Cite: `com/oracle/truffle/api/library/LibraryFactory.html#readDelegate(com.oracle.truffle.api.library.Library,java.lang.Object)` ### getDelegateLibrary(T, Object) `protected static T getDelegateLibrary(T lib, Object delegate)`. Since 20.0. Returns the delegated library to use when messages are delegated. Intended to be used by generated code only, do not use manually. Cite: `com/oracle/truffle/api/library/LibraryFactory.html#getDelegateLibrary(T,java.lang.Object)` ### resolve(Class) `public static LibraryFactory resolve(Class library)`. Since 19.0. Looks up the resolved library instance for a library class. If a library class was not yet loaded it will be initialized automatically. If the passed library class is not a valid library then a [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. See also: `Library`. Cite: `com/oracle/truffle/api/library/LibraryFactory.html#resolve(java.lang.Class)` ### register(Class, LibraryFactory) `protected static void register(Class libraryClass, LibraryFactory library)`. Since 19.0. Cite: `com/oracle/truffle/api/library/LibraryFactory.html#register(java.lang.Class,com.oracle.truffle.api.library.LibraryFactory)` ### toString() `public String toString()`. Since 19.0. Overrides `toString()`. Cite: `com/oracle/truffle/api/library/LibraryFactory.html#toString()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ Message [truffle-api](index.md) › [com.oracle.truffle.api.library](com/oracle/truffle/api/library/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.library`](com/oracle/truffle/api/library/index.md). Since 19.0. ```java public abstract class Message ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Message` Represents a description of library message. A message description refers to one public method in a [`library`](com/oracle/truffle/api/library/Library.md) subclass. Messages may be resolved dynamically by calling [`resolveExact(Class, String, Class[])`](com/oracle/truffle/api/library/Message.md#resolveExact%28java.lang.Class,java.lang.String,java.lang.Class...%29) with a known library class, message name and parameter types. Message instances provide meta-data about the simple and qualified name of the message, return type, receiver type, parameter types and library name. Message instances are used to invoke library messages or implement library messages reflectively using the [`reflection library`](com/oracle/truffle/api/library/ReflectionLibrary.md). Message instances are globally unique and can safely be compared by identity. In other words, if the same message is [`resolveExact(Class, String, Class[])`](com/oracle/truffle/api/library/Message.md#resolveExact%28java.lang.Class,java.lang.String,java.lang.Class...%29) resolved} twice the same instance will be returned. Since they are shared message instances must not be used as locks to avoid deadlocks. Note: This class is intended to be sub-classed by generated code only and must \*not\* be sub-classed by user-code. **See also** - [`ReflectionLibrary`](com/oracle/truffle/api/library/ReflectionLibrary.md) - [`Library`](com/oracle/truffle/api/library/Library.md) ## Constructors ### Message(Class, String, …) `protected Message(Class libraryClass, String messageName, int id, Class returnType, Class... parameterTypes)`. Since 22.0. Cite: `com/oracle/truffle/api/library/Message.html#(java.lang.Class,java.lang.String,int,java.lang.Class,java.lang.Class...)` ### Message(Class, String, …) `protected Message(Class libraryClass, String messageName, int id, boolean deprecated, Class returnType, Class... parameterTypes)`. Since 23.0. Cite: `com/oracle/truffle/api/library/Message.html#(java.lang.Class,java.lang.String,int,boolean,java.lang.Class,java.lang.Class...)` ## Methods ### getId() `public final int getId()`. Since 22.0. Returns a unique message id within a library. Returns `int`: a non-negative message id or `-1` if the message is not assigned a unique id. Cite: `com/oracle/truffle/api/library/Message.html#getId()` ### getQualifiedName() `public final String getQualifiedName()`. Since 19.0. Returns a qualified and unique name of this message. The qualified name is specified as `getLibraryName() + "." + getSimpleName()`. The returned name is [`interned`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html#intern%28%29) can safely be compared by identity. The returned name is never `null`. See also: `getSimpleName()`, `getLibraryName()`. Cite: `com/oracle/truffle/api/library/Message.html#getQualifiedName()` ### getSimpleName() `public final String getSimpleName()`. Since 19.0. Returns the simple name of this message. The simple name is unique per library and equals the method name of the method in the library specification class. The returned name is [`interned`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html#intern%28%29) can safely be compared by identity. The returned name is never `null`. Cite: `com/oracle/truffle/api/library/Message.html#getSimpleName()` ### getLibraryName() `public final String getLibraryName()`. Since 19.0. Returns the name of the library of this message. The name of the library is specified as the [`name`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Class.html#getName%28%29) of the `library class`. The returned name is never `null`. Cite: `com/oracle/truffle/api/library/Message.html#getLibraryName()` ### getReturnType() `public final Class getReturnType()`. Since 19.0. Returns the return type of the message. The return type can be useful for `reflective` invocations of the message. Cite: `com/oracle/truffle/api/library/Message.html#getReturnType()` ### getReceiverType() `public final Class getReceiverType()`. Since 19.0. Returns the receiver type of the message. The receiver type is always the same as the first `parameter type`. In many cases the receiver type of a message is [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html). However, it possible for libraries to restrict the receiver type to sub-types. The receiver type may be useful for `reflective` invocations of the message. Cite: `com/oracle/truffle/api/library/Message.html#getReceiverType()` ### getParameterTypes() `public final List> getParameterTypes()`. Since 19.0. Returns all parameter types including the receiver type of the message. The returned immutable parameter types list corresponds to the [`Method.getParameterTypes()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/reflect/Method.html#getParameterTypes%28%29) parameter types of the declared library method. The parameter types may be useful for `reflective` invocations of the message. Cite: `com/oracle/truffle/api/library/Message.html#getParameterTypes()` ### getParameterType(int) `public final Class getParameterType(int index)`. Since 21.3. Just like `getParameterTypes()` but returns the parameter of a given index in a partial evaluation safe way. Cite: `com/oracle/truffle/api/library/Message.html#getParameterType(int)` ### getParameterCount() `public final int getParameterCount()`. Since 19.0. Returns the number of parameters including the receiver type. Cite: `com/oracle/truffle/api/library/Message.html#getParameterCount()` ### isDeprecated() `public final boolean isDeprecated()`. Since 23.0. Returns true if this message is deprecated. Cite: `com/oracle/truffle/api/library/Message.html#isDeprecated()` ### getLibraryClass() `public final Class getLibraryClass()`. Since 19.0. Returns the library class of this message. The library class may be used to `resolve` other messages of the same library. Cite: `com/oracle/truffle/api/library/Message.html#getLibraryClass()` ### getFactory() `public final LibraryFactory getFactory()`. Since 19.0. Cite: `com/oracle/truffle/api/library/Message.html#getFactory()` ### clone() `protected final Object clone() throws CloneNotSupportedException`. Since 19.0. Overrides `clone()`. Cite: `com/oracle/truffle/api/library/Message.html#clone()` ### toString() `public final String toString()`. Since 19.0. Overrides `toString()`. Cite: `com/oracle/truffle/api/library/Message.html#toString()` ### resolve(Class, String) `@Deprecated(since = "25.1") public static Message resolve(Class libraryClass, String messageName)`. Since 19.0. Deprecated since 25.1. since 25.1, use `resolveExact(Class, String, Class...)` instead. Since library messages can now be deprecated and replaced, they need to be resolved with argument types. Cite: `com/oracle/truffle/api/library/Message.html#resolve(java.lang.Class,java.lang.String)` ### resolve(Class, String, boolean) `@Deprecated(since = "25.1") public static Message resolve(Class libraryClass, String messageName, boolean fail)`. Since 19.0. Deprecated since 25.1. since 25.1, use `resolveExact(Class, String, boolean, Class...)` instead. Since library messages can now be deprecated and replaced, they need to be resolved with argument types. Cite: `com/oracle/truffle/api/library/Message.html#resolve(java.lang.Class,java.lang.String,boolean)` ### resolveExact(Class, String, Class...) `public static Message resolveExact(Class libraryClass, String messageName, Class... argumentTypes)`. Since 25.1. Resolves a message globally for a given library class, message name and argument types. The message name corresponds to the method name of the library message. The returned message always returns the same instance for a combination of library class, message and argument types. The provided library class and message name must not be `null`. If the library or message is invalid or not found an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. Parameters: `libraryClass` `Class`: the class of the library this message is contained in. `messageName` `String`: the simple name of this message. Cite: `com/oracle/truffle/api/library/Message.html#resolveExact(java.lang.Class,java.lang.String,java.lang.Class...)` ### resolveExact(Class, String, …) `public static Message resolveExact(Class libraryClass, String messageName, boolean fail, Class... argumentTypes)`. Since 25.1. Resolves a message globally for a given library class and message name. The message name corresponds to the method name of the library message. The returned message always returns the same instance for a combination of library class, message and argument types. The provided library class and message name must not be `null`. Parameters: `libraryClass` `Class`: the class of the library this message is contained in. `messageName` `String`: the simple name of this message. `fail` `boolean`: whether to fail with an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) or return `null` if the message was not found. `argumentTypes` `Class...`: the parameter types of the message. Cite: `com/oracle/truffle/api/library/Message.html#resolveExact(java.lang.Class,java.lang.String,boolean,java.lang.Class...)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ ReflectionLibrary [truffle-api](index.md) › [com.oracle.truffle.api.library](com/oracle/truffle/api/library/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.library`](com/oracle/truffle/api/library/index.md). Since 19.0. ```java public abstract class ReflectionLibrary extends Library ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > [`Library`](com/oracle/truffle/api/library/Library.md) > `ReflectionLibrary` The reflection library allows to send to and proxy messages of receivers. The reflection library may be used for any receiver object. If a sent message is not implemented by the target receiver then the default library export will be used, otherwise it is forwarded to the resolved exported message. If the reflection library is exported by a receiver directly then the reflection behavior can be customized. This allows, for example, to proxy all messages to a delegate instance. ### Sending Messages Messages can be sent to receivers by first [`Message.resolveExact(Class, String, Class[])`](com/oracle/truffle/api/library/Message.md#resolveExact%28java.lang.Class,java.lang.String,java.lang.Class...%29) resolving} a target message. Then the message can be sent to a receiver that may implement that message. The message name and class may be resolved dynamically. #### Usage example ```java String messageName = "isArray"; Message message = Message.resolveExact(ArrayLibrary.class, messageName); Object receiver = 42; try { ReflectionLibrary.getFactory().getUncached().send(receiver, message); } catch (Exception e) { // handle error } ``` ### Proxies It is possible to proxy library messages to a delegate object. To achieve that the reflection library can be exported by a receiver type. #### Usage example ```java @ExportLibrary(ReflectionLibrary.class) static class AgnosticWrapper { final Object delegate; AgnosticWrapper(Object delegate) { this.delegate = delegate; } @ExportMessage final Object send(Message message, Object[] args, @CachedLibrary("this.delegate") ReflectionLibrary reflection) throws Exception { // do before Object result = reflection.send(delegate, message, args); // do after return result; } } ``` ## Constructors ### ReflectionLibrary() `protected ReflectionLibrary()`. Since 19.0. Constructor for generated subclasses. Subclasses of this class are generated, do not extend this class directly. Cite: `com/oracle/truffle/api/library/ReflectionLibrary.html#()` ## Methods ### send(Object, Message, Object...) `public Object send(Object receiver, Message message, Object... args) throws Exception`. Since 19.0. Sends a given message to the target receiver with the provided arguments. The provided receiver and message must not be null. If the argument types don't match the expected message signature then an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) will be thrown. Cite: `com/oracle/truffle/api/library/ReflectionLibrary.html#send(java.lang.Object,com.oracle.truffle.api.library.Message,java.lang.Object...)` ### getFactory() `public static LibraryFactory getFactory()`. Since 19.0. Returns the library factory for `ReflectionLibrary`. Cite: `com/oracle/truffle/api/library/ReflectionLibrary.html#getFactory()` ### getUncached() `public static ReflectionLibrary getUncached()`. Since 21.3. Returns the uncached automatically dispatched version of the reflection library. This is a short-cut for calling `ReflectionLibrary.getFactory().getUncached()`. See also: `LibraryFactory.getUncached()`. Cite: `com/oracle/truffle/api/library/ReflectionLibrary.html#getUncached()` ### getUncached(Object) `public static ReflectionLibrary getUncached(Object v)`. Since 21.3. Returns the uncached manually dispatched version of the reflection library. This is a short-cut for calling `ReflectionLibrary.getFactory().getUncached(v)`. See also: `LibraryFactory.getUncached(Object)`. Cite: `com/oracle/truffle/api/library/ReflectionLibrary.html#getUncached(java.lang.Object)` ## Inherited members - From class [`Library`](com/oracle/truffle/api/library/Library.md): [`accepts`](com/oracle/truffle/api/library/Library.md#accepts%28java.lang.Object%29) - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ▣ com.oracle.truffle.api.library.provider [truffle-api](index.md) · Every page: [llms.txt](llms.txt) Package in truffle-api. Since 23.1. This package contains service provider interfaces used by Truffle libraries. The provider interfaces are not intended to be implemented manually but automatically generated by the annotation processor when needed. ## Interfaces - [`DefaultExportProvider`](com/oracle/truffle/api/library/provider/DefaultExportProvider.md): Service provider interface implemented by external default exports of a library. - [`EagerExportProvider`](com/oracle/truffle/api/library/provider/EagerExportProvider.md): Service provider interface implemented by library exports if they needed to be loaded eagerly with a library. # ◇ DefaultExportProvider [truffle-api](index.md) › [com.oracle.truffle.api.library.provider](com/oracle/truffle/api/library/provider/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.library.provider`](com/oracle/truffle/api/library/provider/index.md). Since 23.1. ```java public interface DefaultExportProvider ``` Service provider interface implemented by external default exports of a library. This class is not intended to be implemented manually but automatically generated by the annotation processor when needed. ## Methods ### getLibraryClassName() `String getLibraryClassName()`. Since 23.1. Returns the [`class name`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Class.html#getName%28%29) of the library to be used. Uses a string to avoid triggering class loading for all libraries. Cite: `com/oracle/truffle/api/library/provider/DefaultExportProvider.html#getLibraryClassName()` ### getDefaultExport() `Class getDefaultExport()`. Since 23.1. Returns the default export class to be used for this provider. Cite: `com/oracle/truffle/api/library/provider/DefaultExportProvider.html#getDefaultExport()` ### getReceiverClass() `Class getReceiverClass()`. Since 23.1. Returns the receiver class of the default export. Cite: `com/oracle/truffle/api/library/provider/DefaultExportProvider.html#getReceiverClass()` ### getPriority() `int getPriority()`. Since 23.1. Returns the priority used when multiple default exports would be applicable. Cite: `com/oracle/truffle/api/library/provider/DefaultExportProvider.html#getPriority()` # ◇ EagerExportProvider [truffle-api](index.md) › [com.oracle.truffle.api.library.provider](com/oracle/truffle/api/library/provider/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.library.provider`](com/oracle/truffle/api/library/provider/index.md). Since 23.1. ```java public interface EagerExportProvider ``` Service provider interface implemented by library exports if they needed to be loaded eagerly with a library. For example, this is used for exports that are marked to be [used for AOT](https://www.graalvm.org/truffle/javadoc/com/oracle/truffle/api/library/ExportLibrary.html#useForAOTPriority--). On SVM we can rely that the closed world analysis registers all exports at image generation time, so there is no need to use these service providers. Service provider interface implementations and uses are intended to be automatically generated by the Truffle DSL annotation processor. Do not declare custom eager export providers or call [`ensureRegistered()`](com/oracle/truffle/api/library/provider/EagerExportProvider.md#ensureRegistered%28%29). ## Methods ### ensureRegistered() `void ensureRegistered()`. Since 23.1. Ensures that the export is registered and usable. This method has no effect if already registered. Cite: `com/oracle/truffle/api/library/provider/EagerExportProvider.html#ensureRegistered()` ### getLibraryClassName() `String getLibraryClassName()`. Since 23.1. Returns the [`class name`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Class.html#getName%28%29) of the library to be used. Uses a string to avoid triggering class loading for all libraries. Cite: `com/oracle/truffle/api/library/provider/EagerExportProvider.html#getLibraryClassName()` # ▣ com.oracle.truffle.api.memory [truffle-api](index.md) · Every page: [llms.txt](llms.txt) Package in truffle-api. Since 20.3. This package contains memory related classes used by [`com.oracle.truffle.api.TruffleLanguage`](com/oracle/truffle/api/TruffleLanguage.md) implementations. ## Classes - [`ByteArraySupport`](com/oracle/truffle/api/memory/ByteArraySupport.md): Utility methods to write to and read from arrays of bytes. # ◆ ByteArraySupport [truffle-api](index.md) › [com.oracle.truffle.api.memory](com/oracle/truffle/api/memory/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.memory`](com/oracle/truffle/api/memory/index.md). Since 20.3. ```java public abstract class ByteArraySupport ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `ByteArraySupport` Utility methods to write to and read from arrays of bytes. Singletons of this class are obtained from [`littleEndian()`](com/oracle/truffle/api/memory/ByteArraySupport.md#littleEndian%28%29) or [`bigEndian()`](com/oracle/truffle/api/memory/ByteArraySupport.md#bigEndian%28%29) respectively to access byte arrays in little-endian or big-endian order. ## Thread safety The methods of this class are *not* safe for use by multiple concurrent threads, unless otherwise stated. If a byte array is to be used by more than one thread then access to the byte array should be controlled by appropriate synchronization. ## Alignment Unaligned accesses are allowed, but will not constant-fold during partial evaluation. If constant folding is desired, consider using the unaligned methods (e.g., [`getIntUnaligned`](com/oracle/truffle/api/memory/ByteArraySupport.md#getIntUnaligned%28byte[],int%29)) to read immutable data from unaligned offsets. ## Methods ### littleEndian() `public static ByteArraySupport littleEndian()`. Since 20.3. Enables accessing multibyte Java primitives from byte arrays in little-endian order. Example usage: Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#littleEndian()` ```java byte[] buffer = new byte[]{0, 0, 0, 0}; ByteArraySupport.littleEndian().putShort(buffer, 2, (short) 1); // buffer[2] == (byte) 1 // buffer[3] == (byte) 0 ByteArraySupport.littleEndian().putShort(buffer, 3, (short) 1); // throws IndexOutOfBoundsException exception ``` ### bigEndian() `public static ByteArraySupport bigEndian()`. Since 20.3. Enables accessing multibyte Java primitives from byte arrays in big-endian order. Example usage: Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#bigEndian()` ```java byte[] buffer = new byte[]{0, 0, 0, 0}; ByteArraySupport.bigEndian().putShort(buffer, 0, (short) 1); // buffer[0] == (byte) 0 // buffer[1] == (byte) 1 ``` ### inBounds(byte[], int, int) `public final boolean inBounds(byte[] buffer, int startByteOffset, int length)`. Since 20.3. Checks if an access is in bounds of the given buffer. If out-of-bounds accesses are expected to happen frequently, it is faster (~1.2x in interpreter mode) to use this method to check for them than catching [`IndexOutOfBoundsException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IndexOutOfBoundsException.html)s. Parameters: `buffer` `byte[]`: the byte array. `startByteOffset` `int`: the start byte offset of the access. `length` `int`: the number of bytes accessed. Returns `boolean`: True if the access is in bounds, false otherwise. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#inBounds(byte[],int,int)` ### inBounds(byte[], long, long) `public final boolean inBounds(byte[] buffer, long startByteOffset, long length)`. Since 22.2. Checks if an access is in bounds of the given buffer. If out-of-bounds accesses are expected to happen frequently, it is faster (~1.2x in interpreter mode) to use this method to check for them than catching [`IndexOutOfBoundsException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IndexOutOfBoundsException.html)s. Parameters: `buffer` `byte[]`: the byte array. `startByteOffset` `long`: the start byte offset of the access. `length` `long`: the number of bytes accessed. Returns `boolean`: True if the access is in bounds, false otherwise. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#inBounds(byte[],long,long)` ### getByte(byte[], int) `public abstract byte getByte(byte[] buffer, int byteOffset) throws IndexOutOfBoundsException`. Since 20.3. Reads the byte at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `int`: the byte offset at which the byte will be read. Returns `byte`: the byte at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getByte(byte[],int)` ### getByte(byte[], long) `public abstract byte getByte(byte[] buffer, long byteOffset) throws IndexOutOfBoundsException`. Since 22.2. Reads the byte at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset at which the byte will be read. Returns `byte`: the byte at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getByte(byte[],long)` ### putByte(byte[], int, byte) `public abstract void putByte(byte[] buffer, int byteOffset, byte value) throws IndexOutOfBoundsException`. Since 20.3. Writes the given byte at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to write in. `byteOffset` `int`: the byte offset at which the byte will be written. `value` `byte`: the byte value to be written. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#putByte(byte[],int,byte)` ### putByte(byte[], long, byte) `public abstract void putByte(byte[] buffer, long byteOffset, byte value) throws IndexOutOfBoundsException`. Since 22.2. Writes the given byte at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to write in. `byteOffset` `long`: the byte offset at which the byte will be written. `value` `byte`: the byte value to be written. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#putByte(byte[],long,byte)` ### getShort(byte[], int) `public abstract short getShort(byte[] buffer, int byteOffset) throws IndexOutOfBoundsException`. Since 20.3. Reads the short at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `int`: the byte offset from which the short will be read. Returns `short`: the short at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 1`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getShort(byte[],int)` ### getShort(byte[], long) `public abstract short getShort(byte[] buffer, long byteOffset) throws IndexOutOfBoundsException`. Since 22.2. Reads the short at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset from which the short will be read. Returns `short`: the short at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 1`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getShort(byte[],long)` ### putShort(byte[], int, short) `public abstract void putShort(byte[] buffer, int byteOffset, short value) throws IndexOutOfBoundsException`. Since 20.3. Writes the given short at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to write in. `byteOffset` `int`: the byte offset from which the short will be written. `value` `short`: the short value to be written. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 1`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#putShort(byte[],int,short)` ### putShort(byte[], long, short) `public abstract void putShort(byte[] buffer, long byteOffset, short value) throws IndexOutOfBoundsException`. Since 22.2. Writes the given short at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to write in. `byteOffset` `long`: the byte offset from which the short will be written. `value` `short`: the short value to be written. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 1`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#putShort(byte[],long,short)` ### getInt(byte[], int) `public abstract int getInt(byte[] buffer, int byteOffset) throws IndexOutOfBoundsException`. Since 20.3. Reads the int at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `int`: the byte offset from which the int will be read. Returns `int`: the int at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 3`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getInt(byte[],int)` ### getInt(byte[], long) `public abstract int getInt(byte[] buffer, long byteOffset) throws IndexOutOfBoundsException`. Since 20.3. Reads the int at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset from which the int will be read. Returns `int`: the int at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 3`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getInt(byte[],long)` ### putInt(byte[], int, int) `public abstract void putInt(byte[] buffer, int byteOffset, int value) throws IndexOutOfBoundsException`. Since 20.3. Writes the given int at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to write in. `byteOffset` `int`: the byte offset from which the int will be written. `value` `int`: the int value to be written. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 3`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#putInt(byte[],int,int)` ### putInt(byte[], long, int) `public abstract void putInt(byte[] buffer, long byteOffset, int value) throws IndexOutOfBoundsException`. Since 22.2. Writes the given int at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to write in. `byteOffset` `long`: the byte offset from which the int will be written. `value` `int`: the int value to be written. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 3`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#putInt(byte[],long,int)` ### getLong(byte[], int) `public abstract long getLong(byte[] buffer, int byteOffset) throws IndexOutOfBoundsException`. Since 20.3. Reads the long at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `int`: the byte offset from which the int will be read. Returns `long`: the int at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 7`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getLong(byte[],int)` ### getLong(byte[], long) `public abstract long getLong(byte[] buffer, long byteOffset) throws IndexOutOfBoundsException`. Since 22.2. Reads the long at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset from which the int will be read. Returns `long`: the int at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 7`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getLong(byte[],long)` ### putLong(byte[], int, long) `public abstract void putLong(byte[] buffer, int byteOffset, long value) throws IndexOutOfBoundsException`. Since 20.3. Writes the given long at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to write in. `byteOffset` `int`: the byte offset from which the int will be written. `value` `long`: the int value to be written. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 7`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#putLong(byte[],int,long)` ### putLong(byte[], long, long) `public abstract void putLong(byte[] buffer, long byteOffset, long value) throws IndexOutOfBoundsException`. Since 22.2. Writes the given long at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to write in. `byteOffset` `long`: the byte offset from which the int will be written. `value` `long`: the int value to be written. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 7`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#putLong(byte[],long,long)` ### getFloat(byte[], int) `public abstract float getFloat(byte[] buffer, int byteOffset) throws IndexOutOfBoundsException`. Since 20.3. Reads the float at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `int`: the byte offset from which the float will be read. Returns `float`: the float at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 3`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getFloat(byte[],int)` ### getFloat(byte[], long) `public abstract float getFloat(byte[] buffer, long byteOffset) throws IndexOutOfBoundsException`. Since 22.2. Reads the float at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset from which the float will be read. Returns `float`: the float at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 3`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getFloat(byte[],long)` ### putFloat(byte[], int, float) `public abstract void putFloat(byte[] buffer, int byteOffset, float value) throws IndexOutOfBoundsException`. Since 20.3. Writes the given float at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to write in. `byteOffset` `int`: the byte offset from which the float will be written. `value` `float`: the float value to be written. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 3`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#putFloat(byte[],int,float)` ### putFloat(byte[], long, float) `public abstract void putFloat(byte[] buffer, long byteOffset, float value) throws IndexOutOfBoundsException`. Since 22.2. Writes the given float at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to write in. `byteOffset` `long`: the byte offset from which the float will be written. `value` `float`: the float value to be written. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 3`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#putFloat(byte[],long,float)` ### getDouble(byte[], int) `public abstract double getDouble(byte[] buffer, int byteOffset) throws IndexOutOfBoundsException`. Since 20.3. Reads the double at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `int`: the byte offset from which the double will be read. Returns `double`: the double at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 7`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getDouble(byte[],int)` ### getDouble(byte[], long) `public abstract double getDouble(byte[] buffer, long byteOffset) throws IndexOutOfBoundsException`. Since 22.2. Reads the double at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset from which the double will be read. Returns `double`: the double at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 7`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getDouble(byte[],long)` ### putDouble(byte[], int, double) `public abstract void putDouble(byte[] buffer, int byteOffset, double value) throws IndexOutOfBoundsException`. Since 20.3. Writes the given double at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to write in. `byteOffset` `int`: the byte offset from which the double will be written. `value` `double`: the double value to be written. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 7`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#putDouble(byte[],int,double)` ### putDouble(byte[], long, double) `public abstract void putDouble(byte[] buffer, long byteOffset, double value) throws IndexOutOfBoundsException`. Since 22.2. Writes the given double at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to write in. `byteOffset` `long`: the byte offset from which the double will be written. `value` `double`: the double value to be written. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 7`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#putDouble(byte[],long,double)` ### getShortUnaligned(byte[], int) `public abstract short getShortUnaligned(byte[] buffer, int byteOffset) throws IndexOutOfBoundsException`. Since 24.2. Reads the short at the given byte offset from the start of the buffer. Unlike `getShort(byte[], int)`, the byte offset does not need to be short-aligned. The platform may not support atomic unaligned reads, so this method should not be used with shared mutable data. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `int`: the byte offset from which the short will be read. Returns `short`: the short at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 1`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getShortUnaligned(byte[],int)` ### getShortUnaligned(byte[], long) `public abstract short getShortUnaligned(byte[] buffer, long byteOffset) throws IndexOutOfBoundsException`. Since 24.2. Reads the short at the given byte offset from the start of the buffer. Unlike `getShort(byte[], long)`, the byte offset does not need to be short-aligned. The platform may not support atomic unaligned reads, so this method should not be used with shared mutable data. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset from which the short will be read. Returns `short`: the short at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 1`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getShortUnaligned(byte[],long)` ### getIntUnaligned(byte[], int) `public abstract int getIntUnaligned(byte[] buffer, int byteOffset) throws IndexOutOfBoundsException`. Since 24.2. Reads the int at the given byte offset from the start of the buffer. Unlike `getInt(byte[], int)`, the byte offset does not need to be int-aligned. The platform may not support atomic unaligned reads, so this method should not be used with shared mutable data. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `int`: the byte offset from which the int will be read. Returns `int`: the int at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 3`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getIntUnaligned(byte[],int)` ### getIntUnaligned(byte[], long) `public abstract int getIntUnaligned(byte[] buffer, long byteOffset) throws IndexOutOfBoundsException`. Since 24.2. Reads the int at the given byte offset from the start of the buffer. Unlike `getInt(byte[], long)`, the byte offset does not need to be int-aligned. The platform may not support atomic unaligned reads, so this method should not be used with shared mutable data. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset from which the int will be read. Returns `int`: the int at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 3`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getIntUnaligned(byte[],long)` ### getLongUnaligned(byte[], int) `public abstract long getLongUnaligned(byte[] buffer, int byteOffset) throws IndexOutOfBoundsException`. Since 24.2. Reads the long at the given byte offset from the start of the buffer. Unlike `getLong(byte[], int)`, the byte offset does not need to be long-aligned. The platform may not support atomic unaligned reads, so this method should not be used with shared mutable data. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `int`: the byte offset from which the long will be read. Returns `long`: the long at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 7`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getLongUnaligned(byte[],int)` ### getLongUnaligned(byte[], long) `public abstract long getLongUnaligned(byte[] buffer, long byteOffset) throws IndexOutOfBoundsException`. Since 24.2. Reads the long at the given byte offset from the start of the buffer. Unlike `getLong(byte[], long)`, the byte offset does not need to be long-aligned. The platform may not support atomic unaligned reads, so this method should not be used with shared mutable data. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset from which the long will be read. Returns `long`: the long at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 7`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getLongUnaligned(byte[],long)` ### getByteVolatile(byte[], long) `public abstract byte getByteVolatile(byte[] buffer, long byteOffset) throws IndexOutOfBoundsException`. Since 23.1. Volatile version of `getByte(byte[], long)`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getByteVolatile(byte[],long)` ### putByteVolatile(byte[], long, byte) `public abstract void putByteVolatile(byte[] buffer, long byteOffset, byte value) throws IndexOutOfBoundsException`. Since 23.1. Volatile version of `putByte(byte[], long, byte)`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#putByteVolatile(byte[],long,byte)` ### getShortVolatile(byte[], long) `public abstract short getShortVolatile(byte[] buffer, long byteOffset) throws IndexOutOfBoundsException`. Since 23.1. Volatile version of `getShort(byte[], long)`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getShortVolatile(byte[],long)` ### putShortVolatile(byte[], long, short) `public abstract void putShortVolatile(byte[] buffer, long byteOffset, short value) throws IndexOutOfBoundsException`. Since 23.1. Volatile version of `putShort(byte[], long, short)`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#putShortVolatile(byte[],long,short)` ### getIntVolatile(byte[], long) `public abstract int getIntVolatile(byte[] buffer, long byteOffset) throws IndexOutOfBoundsException`. Since 23.1. Volatile version of `getInt(byte[], long)`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getIntVolatile(byte[],long)` ### putIntVolatile(byte[], long, int) `public abstract void putIntVolatile(byte[] buffer, long byteOffset, int value) throws IndexOutOfBoundsException`. Since 23.1. Volatile version of `putInt(byte[], long, int)`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#putIntVolatile(byte[],long,int)` ### getLongVolatile(byte[], long) `public abstract long getLongVolatile(byte[] buffer, long byteOffset) throws IndexOutOfBoundsException`. Since 23.1. Volatile version of `getLong(byte[], long)`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getLongVolatile(byte[],long)` ### putLongVolatile(byte[], long, long) `public abstract void putLongVolatile(byte[] buffer, long byteOffset, long value) throws IndexOutOfBoundsException`. Since 23.1. Volatile version of `putLong(byte[], long, long)`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#putLongVolatile(byte[],long,long)` ### getAndAddByte(byte[], long, byte) `public abstract byte getAndAddByte(byte[] buffer, long byteOffset, byte delta) throws IndexOutOfBoundsException`. Since 23.1. Atomically adds the given byte to the current byte at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset at which the byte will be read and written to. `delta` `byte`: the byte value to add. Returns `byte`: the previous byte at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getAndAddByte(byte[],long,byte)` ### getAndAddShort(byte[], long, short) `public abstract short getAndAddShort(byte[] buffer, long byteOffset, short delta) throws IndexOutOfBoundsException`. Since 23.1. Atomically adds the given short to the current short at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset at which the short will be read and written to. `delta` `short`: the short value to add. Returns `short`: the previous short at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 1`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getAndAddShort(byte[],long,short)` ### getAndAddInt(byte[], long, int) `public abstract int getAndAddInt(byte[] buffer, long byteOffset, int delta) throws IndexOutOfBoundsException`. Since 23.1. Atomically adds the given int to the current int at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset at which the int will be read and written to. `delta` `int`: the int value to add. Returns `int`: the previous int at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 3`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getAndAddInt(byte[],long,int)` ### getAndAddLong(byte[], long, long) `public abstract long getAndAddLong(byte[] buffer, long byteOffset, long delta) throws IndexOutOfBoundsException`. Since 23.1. Atomically adds the given long to the current long at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset at which the long will be read and written to. `delta` `long`: the long value to add. Returns `long`: the previous long at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 7`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getAndAddLong(byte[],long,long)` ### getAndBitwiseAndByte(byte[], long, byte) `public abstract byte getAndBitwiseAndByte(byte[] buffer, long byteOffset, byte mask) throws IndexOutOfBoundsException`. Since 23.1. Atomically bitwise-ANDs the given byte to the current byte at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset at which the byte will be read and written to. `mask` `byte`: the byte value to bitwise-AND. Returns `byte`: the previous byte at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getAndBitwiseAndByte(byte[],long,byte)` ### getAndBitwiseAndShort(byte[], long, short) `public abstract short getAndBitwiseAndShort(byte[] buffer, long byteOffset, short mask) throws IndexOutOfBoundsException`. Since 23.1. Atomically bitwise-ANDs the given short to the current short at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset at which the short will be read and written to. `mask` `short`: the short value to bitwise-AND. Returns `short`: the previous short at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 1`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getAndBitwiseAndShort(byte[],long,short)` ### getAndBitwiseAndInt(byte[], long, int) `public abstract int getAndBitwiseAndInt(byte[] buffer, long byteOffset, int mask) throws IndexOutOfBoundsException`. Since 23.1. Atomically bitwise-ANDs the given int to the current int at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset at which the int will be read and written to. `mask` `int`: the int value to bitwise-AND. Returns `int`: the previous int at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 3`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getAndBitwiseAndInt(byte[],long,int)` ### getAndBitwiseAndLong(byte[], long, long) `public abstract long getAndBitwiseAndLong(byte[] buffer, long byteOffset, long mask) throws IndexOutOfBoundsException`. Since 23.1. Atomically bitwise-ANDs the given long to the current long at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset at which the long will be read and written to. `mask` `long`: the long value to bitwise-AND. Returns `long`: the previous long at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 7`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getAndBitwiseAndLong(byte[],long,long)` ### getAndBitwiseOrByte(byte[], long, byte) `public abstract byte getAndBitwiseOrByte(byte[] buffer, long byteOffset, byte mask) throws IndexOutOfBoundsException`. Since 23.1. Atomically bitwise-ORs the given byte to the current byte at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset at which the byte will be read and written to. `mask` `byte`: the byte value to bitwise-OR. Returns `byte`: the previous byte at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getAndBitwiseOrByte(byte[],long,byte)` ### getAndBitwiseOrShort(byte[], long, short) `public abstract short getAndBitwiseOrShort(byte[] buffer, long byteOffset, short mask) throws IndexOutOfBoundsException`. Since 23.1. Atomically bitwise-ORs the given short to the current short at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset at which the short will be read and written to. `mask` `short`: the short value to bitwise-OR. Returns `short`: the previous short at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 1`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getAndBitwiseOrShort(byte[],long,short)` ### getAndBitwiseOrInt(byte[], long, int) `public abstract int getAndBitwiseOrInt(byte[] buffer, long byteOffset, int mask) throws IndexOutOfBoundsException`. Since 23.1. Atomically bitwise-ORs the given int to the current int at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset at which the int will be read and written to. `mask` `int`: the int value to bitwise-OR. Returns `int`: the previous int at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 3`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getAndBitwiseOrInt(byte[],long,int)` ### getAndBitwiseOrLong(byte[], long, long) `public abstract long getAndBitwiseOrLong(byte[] buffer, long byteOffset, long mask) throws IndexOutOfBoundsException`. Since 23.1. Atomically bitwise-ORs the given long to the current long at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset at which the long will be read and written to. `mask` `long`: the long value to bitwise-OR. Returns `long`: the previous long at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 7`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getAndBitwiseOrLong(byte[],long,long)` ### getAndBitwiseXorByte(byte[], long, byte) `public abstract byte getAndBitwiseXorByte(byte[] buffer, long byteOffset, byte mask) throws IndexOutOfBoundsException`. Since 23.1. Atomically bitwise-XORs the given byte to the current byte at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset at which the byte will be read and written to. `mask` `byte`: the byte value to bitwise-XOR. Returns `byte`: the previous byte at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getAndBitwiseXorByte(byte[],long,byte)` ### getAndBitwiseXorShort(byte[], long, short) `public abstract short getAndBitwiseXorShort(byte[] buffer, long byteOffset, short mask) throws IndexOutOfBoundsException`. Since 23.1. Atomically bitwise-XORs the given short to the current short at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset at which the short will be read and written to. `mask` `short`: the short value to bitwise-XOR. Returns `short`: the previous short at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 1`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getAndBitwiseXorShort(byte[],long,short)` ### getAndBitwiseXorInt(byte[], long, int) `public abstract int getAndBitwiseXorInt(byte[] buffer, long byteOffset, int mask) throws IndexOutOfBoundsException`. Since 23.1. Atomically bitwise-XORs the given int to the current int at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset at which the int will be read and written to. `mask` `int`: the int value to bitwise-XOR. Returns `int`: the previous int at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 3`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getAndBitwiseXorInt(byte[],long,int)` ### getAndBitwiseXorLong(byte[], long, long) `public abstract long getAndBitwiseXorLong(byte[] buffer, long byteOffset, long mask) throws IndexOutOfBoundsException`. Since 23.1. Atomically bitwise-XORs the given long to the current long at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset at which the long will be read and written to. `mask` `long`: the long value to bitwise-XOR. Returns `long`: the previous long at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 7`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getAndBitwiseXorLong(byte[],long,long)` ### getAndSetByte(byte[], long, byte) `public abstract byte getAndSetByte(byte[] buffer, long byteOffset, byte newValue) throws IndexOutOfBoundsException`. Since 23.1. Atomically exchanges the given byte with the current byte at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset at which the byte will be read and written to. `newValue` `byte`: the new byte value. Returns `byte`: the previous byte at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getAndSetByte(byte[],long,byte)` ### getAndSetShort(byte[], long, short) `public abstract short getAndSetShort(byte[] buffer, long byteOffset, short newValue) throws IndexOutOfBoundsException`. Since 23.1. Atomically exchanges the given short with the current short at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset at which the short will be read and written to. `newValue` `short`: the new short value. Returns `short`: the previous short at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 1`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getAndSetShort(byte[],long,short)` ### getAndSetInt(byte[], long, int) `public abstract int getAndSetInt(byte[] buffer, long byteOffset, int newValue) throws IndexOutOfBoundsException`. Since 23.1. Atomically exchanges the given int with the current int at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset at which the int will be read and written to. `newValue` `int`: the new int value. Returns `int`: the previous int at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 3`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getAndSetInt(byte[],long,int)` ### getAndSetLong(byte[], long, long) `public abstract long getAndSetLong(byte[] buffer, long byteOffset, long newValue) throws IndexOutOfBoundsException`. Since 23.1. Atomically exchanges the given long with the current long at the given byte offset from the start of the buffer. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset at which the long will be read and written to. `newValue` `long`: the new long value. Returns `long`: the previous long at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 7`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#getAndSetLong(byte[],long,long)` ### compareAndExchangeByte(byte[], long, …) `public abstract byte compareAndExchangeByte(byte[] buffer, long byteOffset, byte expected, byte x) throws IndexOutOfBoundsException`. Since 23.1. Atomically exchanges the given byte with the current byte at the given byte offset from the start of the buffer, if and only if the current byte equals the expected byte. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset at which the byte will be read and written to. `expected` `byte`: the expected byte value. `x` `byte`: the replacement byte value. Returns `byte`: the previous byte at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#compareAndExchangeByte(byte[],long,byte,byte)` ### compareAndExchangeShort(byte[], long, …) `public abstract short compareAndExchangeShort(byte[] buffer, long byteOffset, short expected, short x) throws IndexOutOfBoundsException`. Since 23.1. Atomically exchanges the given short with the current short at the given byte offset from the start of the buffer, if and only if the current short equals the expected short. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset at which the short will be read and written to. `expected` `short`: the expected short value. `x` `short`: the replacement short value. Returns `short`: the previous short at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 1`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#compareAndExchangeShort(byte[],long,short,short)` ### compareAndExchangeInt(byte[], long, …) `public abstract int compareAndExchangeInt(byte[] buffer, long byteOffset, int expected, int x) throws IndexOutOfBoundsException`. Since 23.1. Atomically exchanges the given int with the current int at the given byte offset from the start of the buffer, if and only if the current int equals the expected int. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset at which the int will be read and written to. `expected` `int`: the expected int value. `x` `int`: the replacement int value. Returns `int`: the previous int at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 3`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#compareAndExchangeInt(byte[],long,int,int)` ### compareAndExchangeLong(byte[], long, …) `public abstract long compareAndExchangeLong(byte[] buffer, long byteOffset, long expected, long x) throws IndexOutOfBoundsException`. Since 23.1. Atomically exchanges the given long with the current long at the given byte offset from the start of the buffer, if and only if the current long equals the expected long. Parameters: `buffer` `byte[]`: the byte array to read from. `byteOffset` `long`: the byte offset at which the long will be read and written to. `expected` `long`: the expected long value. `x` `long`: the replacement long value. Returns `long`: the previous long at the given byte offset from the start of the buffer. Throws: `IndexOutOfBoundsException`: if and only if `byteOffset < 0 || byteOffset >= buffer.length - 7`. Cite: `com/oracle/truffle/api/memory/ByteArraySupport.html#compareAndExchangeLong(byte[],long,long,long)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ▣ com.oracle.truffle.api.nodes [truffle-api](index.md) · Every page: [llms.txt](llms.txt) Package in truffle-api. Since 0.8 or older. Abstract syntax tree [`nodes`](com/oracle/truffle/api/nodes/Node.md) are the basic building block for your [`com.oracle.truffle.api.TruffleLanguage`](com/oracle/truffle/api/TruffleLanguage.md). ## Interfaces - [`BytecodeOSRNode`](com/oracle/truffle/api/nodes/BytecodeOSRNode.md): Interface for Truffle bytecode nodes which can be on-stack replaced (OSR). - [`NodeInterface`](com/oracle/truffle/api/nodes/NodeInterface.md): Common base interface for all Truffle nodes. - [`NodeVisitor`](com/oracle/truffle/api/nodes/NodeVisitor.md): Visitor for trees of nodes. - [`RepeatingNode`](com/oracle/truffle/api/nodes/RepeatingNode.md): A node that is repeatedly invoked as part of a Truffle loop control structure. - [`UnadoptableNode`](com/oracle/truffle/api/nodes/UnadoptableNode.md): Marks a node unadoptable, this means that the parent pointer will never be written by the Truffle framework. ## Classes - [`BlockNode`](com/oracle/truffle/api/nodes/BlockNode.md): Represents a standard node for guest language blocks. - [`DirectCallNode`](com/oracle/truffle/api/nodes/DirectCallNode.md): Represents a direct call to a CallTarget. - [`EncapsulatingNodeReference`](com/oracle/truffle/api/nodes/EncapsulatingNodeReference.md): Thread local reference class to remember the current encapsulating node of an interpreter on the stack. - [`ExecutableNode`](com/oracle/truffle/api/nodes/ExecutableNode.md): Represents an executable node in a Truffle AST. - [`ExecutionSignature`](com/oracle/truffle/api/nodes/ExecutionSignature.md): Represents an execution signature of a RootNode. - [`IndirectCallNode`](com/oracle/truffle/api/nodes/IndirectCallNode.md): Represents an indirect call to a CallTarget. - [`LanguageInfo`](com/oracle/truffle/api/nodes/LanguageInfo.md): Represents public information about a language. - [`LoopNode`](com/oracle/truffle/api/nodes/LoopNode.md): A loop node calls repeating nodes as long as it returns true. - [`Node`](com/oracle/truffle/api/nodes/Node.md): Abstract base class for all nodes in the Truffle Abstract Syntax Tree (AST). - [`NodeClass`](com/oracle/truffle/api/nodes/NodeClass.md): Information about a Node class. - [`NodeCloneable`](com/oracle/truffle/api/nodes/NodeCloneable.md): Declarative base class for node fields that are to be cloned together with the containing node. - [`NodeUtil`](com/oracle/truffle/api/nodes/NodeUtil.md): Utility class that manages the special access methods for node instances. - [`RootNode`](com/oracle/truffle/api/nodes/RootNode.md): Represents the root node in a Truffle AST. ## Enums - [`NodeCost`](com/oracle/truffle/api/nodes/NodeCost.md): Represents a rough estimate for the cost of a Node. ## Exceptions - [`ControlFlowException`](com/oracle/truffle/api/nodes/ControlFlowException.md): An exception thrown to model control flow in a Truffle interpreter. - [`InvalidAssumptionException`](com/oracle/truffle/api/nodes/InvalidAssumptionException.md): An exception that should be thrown if an assumption is checked and the check fails. - [`SlowPathException`](com/oracle/truffle/api/nodes/SlowPathException.md): An exception thrown to enter a slow path. - [`UnexpectedResultException`](com/oracle/truffle/api/nodes/UnexpectedResultException.md): An exception that should be thrown if the return value cannot be represented as a value of the return type. ## Annotations - [`DenyReplace`](com/oracle/truffle/api/nodes/DenyReplace.md): If a Node subtype is annotated with this annotation then replacement is denied. - [`ExplodeLoop`](com/oracle/truffle/api/nodes/ExplodeLoop.md): Specifies that loops originating from within this method should be fully unrolled. - [`NodeInfo`](com/oracle/truffle/api/nodes/NodeInfo.md): Annotation for providing additional information on nodes. # ◆ BlockNode [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 19.3. ```java public abstract class BlockNode extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `BlockNode` Represents a standard node for guest language blocks. Using standard blocks in a guest language is not strictly necessary, but recommended as it allows the optimizing runtime to split compilation of very big methods into multiple compilation units. Block nodes may be executed with a customizable argument to resume the execution at a particular location. Elements are executed using the [`ElementExecutor`](com/oracle/truffle/api/nodes/BlockNode.ElementExecutor.md) provided when [`creating`](com/oracle/truffle/api/nodes/BlockNode.md#create%28T[],com.oracle.truffle.api.nodes.BlockNode.ElementExecutor%29) the block node. When a block is executed then all elements are executed using [`executeVoid`](com/oracle/truffle/api/nodes/BlockNode.ElementExecutor.md#executeVoid%28com.oracle.truffle.api.frame.VirtualFrame,T,int,int%29) except the last element which will be executed using the typed execute method also used to execute the block node. This allows to implement boxing elimination of the return value of blocks in the interpreter. For example, if [`executeInt`](com/oracle/truffle/api/nodes/BlockNode.md#executeInt%28com.oracle.truffle.api.frame.VirtualFrame,int%29) is invoked on the block , then all elements except the last one is executed using [`executeVoid`](com/oracle/truffle/api/nodes/BlockNode.ElementExecutor.md#executeVoid%28com.oracle.truffle.api.frame.VirtualFrame,T,int,int%29), but the last one with [`executeInt`](com/oracle/truffle/api/nodes/BlockNode.ElementExecutor.md#executeInt%28com.oracle.truffle.api.frame.VirtualFrame,T,int,int%29). The optimizing runtime may decide to group elements of a block into multiple block compilation units. This may happen if the block is too big to be compiled with a single compilation unit. If the compilation final state of an element is changed, or a node is replaced only the compilation unit of the current block is invalidated and not all compilations units of a block. Therefore, no compilation final assumptions must be taken between elements of a block. ### Simple Usage: The following example shows how a language with untyped execute methods, but with blocks that return values would use the block node. ```java // language base node abstract class LanguageNode extends Node { public abstract Object execute(VirtualFrame frame); } final class LanguageBlockNode extends LanguageNode implements ElementExecutor { @Child private BlockNode block; LanguageBlockNode(LanguageNode[] elements) { this.block = BlockNode.create(elements, this); } @Override public void executeVoid(VirtualFrame frame, LanguageNode node, int index, int arg) { node.execute(frame); } @Override public Object executeGeneric(VirtualFrame frame, LanguageNode node, int index, int arg) { return node.execute(frame); } @Override public Object execute(VirtualFrame frame) { return block.executeGeneric(frame, 0); } } ``` ### Resumable Usage: The following example shows how the block node can be used to implement resumable blocks, e.g. for generator implementations: ```java final class YieldException extends ControlFlowException { final Object result; YieldException(Object result) { this.result = result; } } final class ResumableBlockNode extends LanguageNode implements ElementExecutor { @CompilationFinal private Integer indexSlot; @Child private BlockNode block; ResumableBlockNode(LanguageNode[] elements) { this.block = BlockNode.create(elements, this); } @Override public Object execute(VirtualFrame frame) { frame.setAuxiliarySlot(getIndexSlot(), 0); return block.executeGeneric(frame, 0); } // Called if the resumable block needs to be // resumed later on after a yield. public void resume(VirtualFrame frame) { getIndexSlot(); int startIndex = frame.getInt(getIndexSlot()); block.executeGeneric(frame, startIndex); } @Override public void executeVoid(VirtualFrame frame, LanguageNode node, int elementIndex, int startIndex) { executeGeneric(frame, node, elementIndex, startIndex); } @Override public Object executeGeneric(VirtualFrame frame, LanguageNode node, int elementIndex, int startIndex) { if (elementIndex >= startIndex) { try { return node.execute(frame); } catch (YieldException e) { // store index to be able to resume later frame.setInt(getIndexSlot(), elementIndex); return e.result; } } else { CompilerDirectives.transferToInterpreterAndInvalidate(); throw new AssertionError("Invalid start index"); } } private int getIndexSlot() { Integer slot = this.indexSlot; if (slot == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); FrameDescriptor fd = getRootNode().getFrameDescriptor(); this.indexSlot = slot = fd.findOrAddAuxiliarySlot(this); } return slot; } } ``` **Type parameters** - ``: the type of the block element node ## Nested types - [`BlockNode.ElementExecutor`](com/oracle/truffle/api/nodes/BlockNode.ElementExecutor.md) (interface): Represents a contract how block element nodes can be executed. ## Fields ### NO_ARGUMENT `public static final int NO_ARGUMENT`. Since 19.3. Use when no argument is needed for the block node. Constant value: `0`. Cite: `com/oracle/truffle/api/nodes/BlockNode.html#NO_ARGUMENT` ## Constructors ### BlockNode(T[]) `protected BlockNode(T[] elements)`. Since 19.3. Internal constructor for implementations. Do not use. Cite: `com/oracle/truffle/api/nodes/BlockNode.html#(T[])` ## Methods ### executeVoid(VirtualFrame, int) `public abstract void executeVoid(VirtualFrame frame, int argument)`. Since 19.3. Executes the block and returns no value. The block implementation calls `ElementExecutor.executeVoid(VirtualFrame, Node, int, int)` for all elements of the block. Parameters: `frame` `VirtualFrame`: the frame to execute the block in. `argument` `int`: a custom argument that is forwarded to the executor as is. If no argument is needed then `BlockNode.NO_ARGUMENT` should be used. Cite: `com/oracle/truffle/api/nodes/BlockNode.html#executeVoid(com.oracle.truffle.api.frame.VirtualFrame,int)` ### executeGeneric(VirtualFrame, int) `public abstract Object executeGeneric(VirtualFrame frame, int argument)`. Since 19.3. Executes the block and returns a generic value. The block implementation calls `ElementExecutor.executeVoid(VirtualFrame, Node, int, int)` for all elements of the block except the last element. The last element is executed using `ElementExecutor.executeGeneric(VirtualFrame, Node, int, int)`. Parameters: `frame` `VirtualFrame`: the frame to execute the block in. `argument` `int`: a custom value that is forwarded to the executor as is. If no argument is needed then `BlockNode.NO_ARGUMENT` should be used. Cite: `com/oracle/truffle/api/nodes/BlockNode.html#executeGeneric(com.oracle.truffle.api.frame.VirtualFrame,int)` ### executeByte(VirtualFrame, int) `public abstract byte executeByte(VirtualFrame frame, int argument) throws UnexpectedResultException`. Since 19.3. Executes the block and returns a byte value. The block implementation calls `ElementExecutor.executeVoid(VirtualFrame, Node, int, int)` for all elements of the block except the last element. The last element is executed using `ElementExecutor.executeByte(VirtualFrame, Node, int, int)`. Parameters: `frame` `VirtualFrame`: the frame to execute the block in. `argument` `int`: a custom value that is forwarded to the executor as is. If no argument is needed then `BlockNode.NO_ARGUMENT` should be used. Cite: `com/oracle/truffle/api/nodes/BlockNode.html#executeByte(com.oracle.truffle.api.frame.VirtualFrame,int)` ### executeShort(VirtualFrame, int) `public abstract short executeShort(VirtualFrame frame, int argument) throws UnexpectedResultException`. Since 19.3. Executes the block and returns a short value. The block implementation calls `ElementExecutor.executeVoid(VirtualFrame, Node, int, int)` for all elements of the block except the last element. The last element is executed using `ElementExecutor.executeShort(VirtualFrame, Node, int, int)`. Parameters: `frame` `VirtualFrame`: the frame to execute the block in. `argument` `int`: a custom value that is forwarded to the executor as is. If no argument is needed then `BlockNode.NO_ARGUMENT` should be used. Cite: `com/oracle/truffle/api/nodes/BlockNode.html#executeShort(com.oracle.truffle.api.frame.VirtualFrame,int)` ### executeInt(VirtualFrame, int) `public abstract int executeInt(VirtualFrame frame, int argument) throws UnexpectedResultException`. Since 19.3. Executes the block and returns an int value. The block implementation calls `ElementExecutor.executeVoid(VirtualFrame, Node, int, int)` for all elements of the block except the last element. The last element is executed using `ElementExecutor.executeInt(VirtualFrame, Node, int, int)`. Parameters: `frame` `VirtualFrame`: the frame to execute the block in. `argument` `int`: a custom value that is forwarded to the executor as is. If no argument is needed then `BlockNode.NO_ARGUMENT` should be used. Cite: `com/oracle/truffle/api/nodes/BlockNode.html#executeInt(com.oracle.truffle.api.frame.VirtualFrame,int)` ### executeChar(VirtualFrame, int) `public abstract char executeChar(VirtualFrame frame, int argument) throws UnexpectedResultException`. Since 19.3. Executes the block and returns a char value. The block implementation calls `ElementExecutor.executeVoid(VirtualFrame, Node, int, int)` for all elements of the block except the last element. The last element is executed using `ElementExecutor.executeChar(VirtualFrame, Node, int, int)`. Parameters: `frame` `VirtualFrame`: the frame to execute the block in. `argument` `int`: a custom value that is forwarded to the executor as is. If no argument is needed then `BlockNode.NO_ARGUMENT` should be used. Cite: `com/oracle/truffle/api/nodes/BlockNode.html#executeChar(com.oracle.truffle.api.frame.VirtualFrame,int)` ### executeFloat(VirtualFrame, int) `public abstract float executeFloat(VirtualFrame frame, int argument) throws UnexpectedResultException`. Since 19.3. Executes the block and returns a float value. The block implementation calls `ElementExecutor.executeVoid(VirtualFrame, Node, int, int)` for all elements of the block except the last element. The last element is executed using `ElementExecutor.executeFloat(VirtualFrame, Node, int, int)`. Parameters: `frame` `VirtualFrame`: the frame to execute the block in. `argument` `int`: a custom value that is forwarded to the executor as is. If no argument is needed then `BlockNode.NO_ARGUMENT` should be used. Cite: `com/oracle/truffle/api/nodes/BlockNode.html#executeFloat(com.oracle.truffle.api.frame.VirtualFrame,int)` ### executeDouble(VirtualFrame, int) `public abstract double executeDouble(VirtualFrame frame, int argument) throws UnexpectedResultException`. Since 19.3. Executes the block and returns a double value. The block implementation calls `ElementExecutor.executeVoid(VirtualFrame, Node, int, int)` for all elements of the block except the last element. The last element is executed using `ElementExecutor.executeDouble(VirtualFrame, Node, int, int)`. Parameters: `frame` `VirtualFrame`: the frame to execute the block in. `argument` `int`: a custom value that is forwarded to the executor as is. If no argument is needed then `BlockNode.NO_ARGUMENT` should be used. Cite: `com/oracle/truffle/api/nodes/BlockNode.html#executeDouble(com.oracle.truffle.api.frame.VirtualFrame,int)` ### executeLong(VirtualFrame, int) `public abstract long executeLong(VirtualFrame frame, int argument) throws UnexpectedResultException`. Since 19.3. Executes the block and returns a long value. The block implementation calls `ElementExecutor.executeVoid(VirtualFrame, Node, int, int)` for all elements of the block except the last element. The last element is executed using `ElementExecutor.executeLong(VirtualFrame, Node, int, int)`. Parameters: `frame` `VirtualFrame`: the frame to execute the block in. `argument` `int`: a custom value that is forwarded to the executor as is. If no argument is needed then `BlockNode.NO_ARGUMENT` should be used. Cite: `com/oracle/truffle/api/nodes/BlockNode.html#executeLong(com.oracle.truffle.api.frame.VirtualFrame,int)` ### executeBoolean(VirtualFrame, int) `public abstract boolean executeBoolean(VirtualFrame frame, int argument) throws UnexpectedResultException`. Since 19.3. Executes the block and returns a boolean value. The block implementation calls `ElementExecutor.executeVoid(VirtualFrame, Node, int, int)` for all elements of the block except the last element. The last element is executed using `ElementExecutor.executeBoolean(VirtualFrame, Node, int, int)`. Parameters: `frame` `VirtualFrame`: the frame to execute the block in. `argument` `int`: a custom value that is forwarded to the executor as is. If no argument is needed then `BlockNode.NO_ARGUMENT` should be used. Cite: `com/oracle/truffle/api/nodes/BlockNode.html#executeBoolean(com.oracle.truffle.api.frame.VirtualFrame,int)` ### getElements() `public final T[] getElements()`. Since 19.3. Returns the elements of the block node. Elements of block nodes are provided using `create(Node[], ElementExecutor)`. Cite: `com/oracle/truffle/api/nodes/BlockNode.html#getElements()` ### create(T[], BlockNode.ElementExecutor) `public static BlockNode create(T[] elements, BlockNode.ElementExecutor executor)`. Since 19.3. Creates a new block node. The elements array of the block node must not be empty or an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown. Elements of a block must at least extend `Node`. An executor must be provided that allows the block node implementation to execute the block elements. The executor must not be `null`. Cite: `com/oracle/truffle/api/nodes/BlockNode.html#create(T[],com.oracle.truffle.api.nodes.BlockNode.ElementExecutor)` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ BlockNode.ElementExecutor [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 19.3. Nested in [`BlockNode`](com/oracle/truffle/api/nodes/BlockNode.md). ```java public interface BlockNode.ElementExecutor ``` Represents a contract how block element nodes can be executed. Designed for the block node only. **See also** - [`BlockNode`](com/oracle/truffle/api/nodes/BlockNode.md) ## Methods ### executeVoid(VirtualFrame, T, …) `void executeVoid(VirtualFrame frame, T node, int index, int argument)`. Since 19.3. Executes the block node element without expecting any return value. Cite: `com/oracle/truffle/api/nodes/BlockNode.ElementExecutor.html#executeVoid(com.oracle.truffle.api.frame.VirtualFrame,T,int,int)` ### executeGeneric(VirtualFrame, T, …) `default Object executeGeneric(VirtualFrame frame, T node, int index, int argument)`. Since 19.3. Executes the block node element and expects a generic value. This method is used for the last element of the block, to provide a value to the block execute method. Forwards to `executeVoid(VirtualFrame, Node, int, int)` by default. Cite: `com/oracle/truffle/api/nodes/BlockNode.ElementExecutor.html#executeGeneric(com.oracle.truffle.api.frame.VirtualFrame,T,int,int)` ### executeBoolean(VirtualFrame, T, …) `default boolean executeBoolean(VirtualFrame frame, T node, int index, int argument) throws UnexpectedResultException`. Since 19.3. Executes the block node element and expects a boolean value. This method is used for the last element of the block, to provide a value to the block execute method. Forwards to `executeGeneric(VirtualFrame, Node, int, int)` by default and throws an `UnexpectedResultException` if the value is not a boolean. Cite: `com/oracle/truffle/api/nodes/BlockNode.ElementExecutor.html#executeBoolean(com.oracle.truffle.api.frame.VirtualFrame,T,int,int)` ### executeByte(VirtualFrame, T, …) `default byte executeByte(VirtualFrame frame, T node, int index, int argument) throws UnexpectedResultException`. Since 19.3. Executes the block node element and expects a byte value. This method is used for the last element of the block, to provide a value to the block execute method. Forwards to `executeGeneric(VirtualFrame, Node, int, int)` by default and throws an `UnexpectedResultException` if the value is not a byte. Cite: `com/oracle/truffle/api/nodes/BlockNode.ElementExecutor.html#executeByte(com.oracle.truffle.api.frame.VirtualFrame,T,int,int)` ### executeShort(VirtualFrame, T, …) `default short executeShort(VirtualFrame frame, T node, int index, int argument) throws UnexpectedResultException`. Since 19.3. Executes the block node element and expects a short value. This method is used for the last element of the block, to provide a value to the block execute method. Forwards to `executeGeneric(VirtualFrame, Node, int, int)` by default and throws an `UnexpectedResultException` if the value is not a short. Cite: `com/oracle/truffle/api/nodes/BlockNode.ElementExecutor.html#executeShort(com.oracle.truffle.api.frame.VirtualFrame,T,int,int)` ### executeChar(VirtualFrame, T, …) `default char executeChar(VirtualFrame frame, T node, int index, int argument) throws UnexpectedResultException`. Since 19.3. Executes the block node element and expects a char value. This method is used for the last element of the block, to provide a value to the block execute method. Forwards to `executeGeneric(VirtualFrame, Node, int, int)` by default and throws an `UnexpectedResultException` if the value is not a char. Cite: `com/oracle/truffle/api/nodes/BlockNode.ElementExecutor.html#executeChar(com.oracle.truffle.api.frame.VirtualFrame,T,int,int)` ### executeInt(VirtualFrame, T, …) `default int executeInt(VirtualFrame frame, T node, int index, int argument) throws UnexpectedResultException`. Since 19.3. Executes the block node element and expects an int value. This method is used for the last element of the block, to provide a value to the block execute method. Forwards to `executeGeneric(VirtualFrame, Node, int, int)` by default and throws an `UnexpectedResultException` if the value is not an int. Cite: `com/oracle/truffle/api/nodes/BlockNode.ElementExecutor.html#executeInt(com.oracle.truffle.api.frame.VirtualFrame,T,int,int)` ### executeLong(VirtualFrame, T, …) `default long executeLong(VirtualFrame frame, T node, int index, int argument) throws UnexpectedResultException`. Since 19.3. Executes the block node element and expects a long value. This method is used for the last element of the block, to provide a value to the block execute method. Forwards to `executeGeneric(VirtualFrame, Node, int, int)` by default and throws an `UnexpectedResultException` if the value is not a long. Cite: `com/oracle/truffle/api/nodes/BlockNode.ElementExecutor.html#executeLong(com.oracle.truffle.api.frame.VirtualFrame,T,int,int)` ### executeFloat(VirtualFrame, T, …) `default float executeFloat(VirtualFrame frame, T node, int index, int argument) throws UnexpectedResultException`. Since 19.3. Executes the block node element and expects a float value. This method is used for the last element of the block, to provide a value to the block execute method. Forwards to `executeGeneric(VirtualFrame, Node, int, int)` by default and throws an `UnexpectedResultException` if the value is not a float. Cite: `com/oracle/truffle/api/nodes/BlockNode.ElementExecutor.html#executeFloat(com.oracle.truffle.api.frame.VirtualFrame,T,int,int)` ### executeDouble(VirtualFrame, T, …) `default double executeDouble(VirtualFrame frame, T node, int index, int argument) throws UnexpectedResultException`. Since 19.3. Executes the block node element and expects a double value. This method is used for the last element of the block, to provide a value to the block execute method. Forwards to `executeGeneric(VirtualFrame, Node, int, int)` by default and throws an `UnexpectedResultException` if the value is not a double. Cite: `com/oracle/truffle/api/nodes/BlockNode.ElementExecutor.html#executeDouble(com.oracle.truffle.api.frame.VirtualFrame,T,int,int)` # ◇ BytecodeOSRNode [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 21.3. ```java public interface BytecodeOSRNode extends NodeInterface ``` Extends: [`NodeInterface`](com/oracle/truffle/api/nodes/NodeInterface.md) Interface for Truffle bytecode nodes which can be on-stack replaced (OSR). There are a few restrictions Bytecode OSR nodes must satisfy in order for OSR to work correctly: 1. The node must extend [`Node`](com/oracle/truffle/api/nodes/Node.md) or a subclass of [`Node`](com/oracle/truffle/api/nodes/Node.md). 2. The node must provide storage for the OSR metadata maintained by the runtime using an instance field. The field must be [`@CompilationFinal`](com/oracle/truffle/api/CompilerDirectives.CompilationFinal.md), and the [`BytecodeOSRNode.getOSRMetadata`](com/oracle/truffle/api/nodes/BytecodeOSRNode.md#getOSRMetadata%28%29) and [`BytecodeOSRNode.setOSRMetadata`](com/oracle/truffle/api/nodes/BytecodeOSRNode.md#setOSRMetadata%28java.lang.Object%29) methods must proxy accesses to it. 3. The node should call [`BytecodeOSRNode.pollOSRBackEdge`](com/oracle/truffle/api/nodes/BytecodeOSRNode.md#pollOSRBackEdge%28com.oracle.truffle.api.nodes.BytecodeOSRNode%29) and [`BytecodeOSRNode.tryOSR`](com/oracle/truffle/api/nodes/BytecodeOSRNode.md#tryOSR%28com.oracle.truffle.api.nodes.BytecodeOSRNode,int,java.lang.Object,java.lang.Runnable,com.oracle.truffle.api.frame.VirtualFrame%29) as described by their documentation. 4. The node should implement either [`executeOSR(VirtualFrame, int, Object)`](com/oracle/truffle/api/nodes/BytecodeOSRNode.md#executeOSR%28com.oracle.truffle.api.frame.VirtualFrame,int,java.lang.Object%29) or [`executeOSR(VirtualFrame, long, Object)`](com/oracle/truffle/api/nodes/BytecodeOSRNode.md#executeOSR%28com.oracle.truffle.api.frame.VirtualFrame,long,java.lang.Object%29) (see note below). For performance reasons, the parent frame may be copied into a new frame used for OSR. If this happens, [`BytecodeOSRNode.copyIntoOSRFrame(VirtualFrame, VirtualFrame, int, Object)`](com/oracle/truffle/api/nodes/BytecodeOSRNode.md#copyIntoOSRFrame%28com.oracle.truffle.api.frame.VirtualFrame,com.oracle.truffle.api.frame.VirtualFrame,int,java.lang.Object%29) is used to perform the copy, and [`BytecodeOSRNode.restoreParentFrame`](com/oracle/truffle/api/nodes/BytecodeOSRNode.md#restoreParentFrame%28com.oracle.truffle.api.frame.VirtualFrame,com.oracle.truffle.api.frame.VirtualFrame%29) is used to copy the OSR frame contents back into the parent frame after OSR. A node may override these methods; by default, they perform slot-wise copies. A node may also wish to override [`BytecodeOSRNode.prepareOSR`](com/oracle/truffle/api/nodes/BytecodeOSRNode.md#prepareOSR%28int%29) to perform initialization. This method will be called before compilation, and can be useful to avoid deoptimizing inside compiled code. Starting in 24.2, Bytecode OSR supports `long` values for `target` dispatch locations. An interpreter can use `long` targets by invoking [`tryOSR(BytecodeOSRNode, long, Object, Runnable, VirtualFrame)`](com/oracle/truffle/api/nodes/BytecodeOSRNode.md#tryOSR%28com.oracle.truffle.api.nodes.BytecodeOSRNode,long,java.lang.Object,java.lang.Runnable,com.oracle.truffle.api.frame.VirtualFrame%29) (instead of [`tryOSR(BytecodeOSRNode, int, Object, Runnable, VirtualFrame)`](com/oracle/truffle/api/nodes/BytecodeOSRNode.md#tryOSR%28com.oracle.truffle.api.nodes.BytecodeOSRNode,int,java.lang.Object,java.lang.Runnable,com.oracle.truffle.api.frame.VirtualFrame%29)). Refer to the documentation for the `long` overload for more details. ## Methods ### executeOSR(VirtualFrame, int, Object) `default Object executeOSR(VirtualFrame osrFrame, int target, Object interpreterState)`. Since 21.3. Entrypoint to invoke this node through OSR. Implementers must override this method (or its `long overload`). The implementation should execute bytecode starting from the given `target` location (e.g., bytecode index). The `osrFrame` may be the parent frame, but for performance reasons could also be a new frame. In case a new frame is created, the frame's `arguments` will be provided by `storeParentFrameInArguments`. Typically, a bytecode node's `execute(VirtualFrame)` method already contains a dispatch loop. This loop can be extracted into a separate method which can also be used by this method. For example: Parameters: `osrFrame` `VirtualFrame`: the frame to use for OSR. `target` `int`: the target location to execute from (e.g., bytecode index). `interpreterState` `Object`: other interpreter state used to resume execution. See `tryOSR(BytecodeOSRNode, int, Object, Runnable, VirtualFrame)` for more details. Returns `Object`: the result of execution. See also: `executeOSR(VirtualFrame, long, Object)`. Cite: `com/oracle/truffle/api/nodes/BytecodeOSRNode.html#executeOSR(com.oracle.truffle.api.frame.VirtualFrame,int,java.lang.Object)` ```java Object execute(VirtualFrame frame) { return dispatchFromBCI(frame, 0); } Object executeOSR(VirtualFrame osrFrame, int target, Object interpreterState) { return dispatchFromBCI(osrFrame, target); } Object dispatchFromBCI(VirtualFrame frame, int bci) { // main dispatch loop while(true) { switch(instructions[bci]) { ... } } } ``` ### executeOSR(VirtualFrame, long, Object) `default Object executeOSR(VirtualFrame osrFrame, long target, Object interpreterState)`. Since 24.2. Overload of `executeOSR(VirtualFrame, int, Object)` with a `long` target. An interpreter that uses `long` targets must override this method. See also: `tryOSR(BytecodeOSRNode, long, Object, Runnable, VirtualFrame)`. Cite: `com/oracle/truffle/api/nodes/BytecodeOSRNode.html#executeOSR(com.oracle.truffle.api.frame.VirtualFrame,long,java.lang.Object)` ### getOSRMetadata() `Object getOSRMetadata()`. Since 21.3. Gets the OSR metadata for this instance. The metadata must be stored on a `@CompilationFinal` instance field. Refer to the documentation for this interface for a more complete description. Returns `Object`: the OSR metadata. Cite: `com/oracle/truffle/api/nodes/BytecodeOSRNode.html#getOSRMetadata()` ### setOSRMetadata(Object) `void setOSRMetadata(Object osrMetadata)`. Since 21.3. Sets the OSR metadata for this instance. The metadata must be stored on a `@CompilationFinal` instance field. Refer to the documentation for this interface for a more complete description. Parameters: `osrMetadata` `Object`: the OSR metadata. Cite: `com/oracle/truffle/api/nodes/BytecodeOSRNode.html#setOSRMetadata(java.lang.Object)` ### copyIntoOSRFrame(VirtualFrame, VirtualFrame, …) `default void copyIntoOSRFrame(VirtualFrame osrFrame, VirtualFrame parentFrame, int target, Object targetMetadata)`. Since 22.2. Copies the contents of the `parentFrame` into the `osrFrame` used to execute OSR. By default, performs a slot-wise copy of the frame. NOTE: This method is only used if the Truffle runtime decides to copy the frame. OSR may also reuse the parent frame directly. Parameters: `osrFrame` `VirtualFrame`: the frame to use for OSR. `parentFrame` `VirtualFrame`: the frame used before performing OSR. `target` `int`: the target location OSR will execute from (e.g., bytecode index). `targetMetadata` `Object`: Additional metadata associated with this `target` for the default frame transfer behavior. See also: `copyIntoOSRFrame(VirtualFrame, VirtualFrame, long, Object)`. Cite: `com/oracle/truffle/api/nodes/BytecodeOSRNode.html#copyIntoOSRFrame(com.oracle.truffle.api.frame.VirtualFrame,com.oracle.truffle.api.frame.VirtualFrame,int,java.lang.Object)` ### copyIntoOSRFrame(VirtualFrame, VirtualFrame, …) `default void copyIntoOSRFrame(VirtualFrame osrFrame, VirtualFrame parentFrame, long target, Object targetMetadata)`. Since 24.2. Overload of `copyIntoOSRFrame(VirtualFrame, VirtualFrame, int, Object)` with a `long` target. An interpreter that uses `long` targets must override this method. See also: `tryOSR(BytecodeOSRNode, long, Object, Runnable, VirtualFrame)`. Cite: `com/oracle/truffle/api/nodes/BytecodeOSRNode.html#copyIntoOSRFrame(com.oracle.truffle.api.frame.VirtualFrame,com.oracle.truffle.api.frame.VirtualFrame,long,java.lang.Object)` ### transferOSRFrame(VirtualFrame, VirtualFrame, …) `default void transferOSRFrame(VirtualFrame osrFrame, VirtualFrame parentFrame, long target, Object targetMetadata)`. Since 24.2. Helper method that can be called by implementations of `copyIntoOSRFrame(VirtualFrame, VirtualFrame, long, Object)`. Should not be overridden. See also: `tryOSR(BytecodeOSRNode, long, Object, Runnable, VirtualFrame)`. Cite: `com/oracle/truffle/api/nodes/BytecodeOSRNode.html#transferOSRFrame(com.oracle.truffle.api.frame.VirtualFrame,com.oracle.truffle.api.frame.VirtualFrame,long,java.lang.Object)` ### restoreParentFrame(VirtualFrame, VirtualFrame) `default void restoreParentFrame(VirtualFrame osrFrame, VirtualFrame parentFrame)`. Since 21.3. Restores the contents of the `osrFrame` back into the `parentFrame` after OSR. By default, performs a slot-wise copy of the frame. Though a bytecode interpreter might not explicitly use `parentFrame` after OSR, it is necessary to restore the state into `parentFrame` if it may be accessed through instrumentation. NOTE: This method is only used if the Truffle runtime decided to copy the frame using `BytecodeOSRNode.copyIntoOSRFrame(VirtualFrame, VirtualFrame, int, Object)`. Parameters: `osrFrame` `VirtualFrame`: the frame which was used for OSR. `parentFrame` `VirtualFrame`: the frame which will be used by the parent after returning from OSR. Cite: `com/oracle/truffle/api/nodes/BytecodeOSRNode.html#restoreParentFrame(com.oracle.truffle.api.frame.VirtualFrame,com.oracle.truffle.api.frame.VirtualFrame)` ### prepareOSR(int) `default void prepareOSR(int target)`. Since 21.3. Initialization hook which will be invoked before OSR compilation. This hook can be used to perform any necessary initialization before compilation happens. For example, consider a field which must be initialized in the interpreter: If the field is accessed from compiled OSR code, it may trigger a deoptimization in order to initialize the field. Using `BytecodeOSRNode.prepareOSR` to initialize the field can prevent this. Parameters: `target` `int`: the target location OSR will execute from (e.g., bytecode index). See also: `prepareOSR(long)`. Cite: `com/oracle/truffle/api/nodes/BytecodeOSRNode.html#prepareOSR(int)` ```java @CompilationFinal Object field; Object getField() { if (field == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); field = new Object(); } return field; } ``` ### prepareOSR(long) `default void prepareOSR(long target)`. Since 24.2. Overload of `prepareOSR(int)` with a `long` target. An interpreter that uses `long` targets must override this method. See also: `tryOSR(BytecodeOSRNode, long, Object, Runnable, VirtualFrame)`. Cite: `com/oracle/truffle/api/nodes/BytecodeOSRNode.html#prepareOSR(long)` ### pollOSRBackEdge(BytecodeOSRNode) `@Deprecated(since = "25.0") static boolean pollOSRBackEdge(BytecodeOSRNode osrNode)`. Since 21.3. Deprecated since 25.0. use `pollOSRBackEdge(BytecodeOSRNode, int)` instead. It is recommended to batch up polls in the interpreter implementation. Important note: `pollOSRBackEdge(BytecodeOSRNode)` did implicitly `poll` Truffle safepoints. The new method is no longer doing that. Make sure your bytecode interpreter contains a call to `TruffleSafepoint.poll(Node)` on loop back-edges when migrating. Reports a back edge, returning whether to try performing OSR. An interpreter must ensure this method returns `true` immediately before calling `BytecodeOSRNode.tryOSR`. For example: Parameters: `osrNode` `BytecodeOSRNode`: the node to report a back-edge for. Returns `boolean`: whether to try OSR. Cite: `com/oracle/truffle/api/nodes/BytecodeOSRNode.html#pollOSRBackEdge(com.oracle.truffle.api.nodes.BytecodeOSRNode)` ```java if (BytecodeOSRNode.pollOSRBackEdge(this)) { Object osrResult = BytecodeOSRNode.tryOSR(...); ... } ``` ### pollOSRBackEdge(BytecodeOSRNode, int) `static boolean pollOSRBackEdge(BytecodeOSRNode osrNode, int loopCountIncrement)`. Since 25.0. Reports a back edge, returning whether to try performing OSR. An interpreter must ensure this method returns `true` immediately before calling `BytecodeOSRNode.tryOSR`. For example: Parameters: `osrNode` `BytecodeOSRNode`: the node to report a back-edge for. `loopCountIncrement` `int`: the number iterations incremented. Value must be \> 0. Returns `boolean`: whether to try OSR. Cite: `com/oracle/truffle/api/nodes/BytecodeOSRNode.html#pollOSRBackEdge(com.oracle.truffle.api.nodes.BytecodeOSRNode,int)` ```java if (BytecodeOSRNode.pollOSRBackEdge(this, 1)) { Object osrResult = BytecodeOSRNode.tryOSR(...); ... } ``` ### tryOSR(BytecodeOSRNode, int, …) `static Object tryOSR(BytecodeOSRNode osrNode, int target, Object interpreterState, Runnable beforeTransfer, VirtualFrame parentFrame)`. Since 21.3. Tries to perform OSR. This method must only be called immediately after a `true` result from `BytecodeOSRNode.pollOSRBackEdge`. Depending on the Truffle runtime, this method can trigger OSR compilation and then (typically in a subsequent call) transfer to OSR code. If OSR occurs, this method returns the result of OSR execution. The caller of this method can forward the result back to its caller rather than continuing execution from the `target`. For example: The optional `interpreterState` parameter will be forwarded to `BytecodeOSRNode.executeOSR` when OSR is performed. It should consist of additional interpreter state (e.g., data pointers) needed to resume execution from `target`. The state should be fixed (i.e., final) for the given `target`. For example: The optional `beforeTransfer` callback will be called before transferring control to the OSR target. Since this method may or may not perform a transfer, it is a way to ensure certain actions (e.g., instrumentation events) occur before transferring to OSR code. For example: Parameters: `osrNode` `BytecodeOSRNode`: the node to try OSR for. `target` `int`: the target location OSR will execute from (e.g., bytecode index). `interpreterState` `Object`: other interpreter state used to resume execution. `beforeTransfer` `Runnable`: a callback invoked before OSR. Can be `null`. `parentFrame` `VirtualFrame`: frame at the current point of execution. Returns `Object`: the result if OSR was performed, or `null` otherwise. See also: `tryOSR(BytecodeOSRNode, long, Object, Runnable, VirtualFrame)`. Cite: `com/oracle/truffle/api/nodes/BytecodeOSRNode.html#tryOSR(com.oracle.truffle.api.nodes.BytecodeOSRNode,int,java.lang.Object,java.lang.Runnable,com.oracle.truffle.api.frame.VirtualFrame)` ```java if (BytecodeOSRNode.pollOSRBackEdge(this)) { Object osrResult = BytecodeOSRNode.tryOSR(...); if (osrResult != null) return osrResult; } ``` ```java // class definition class InterpreterState { final int dataPtr; InterpreterState(int dataPtr) { ... } } // call site Object osrResult = BytecodeOSRNode.tryOSR(this, target, new InterpreterState(dataPtr), ...); // executeOSR Object executeOSR(VirtualFrame osrFrame, int target, Object interpreterState) { InterpreterState state = (InterpreterState) interpreterState; return dispatchFromBCI(osrFrame, target, interpreterState.dataPtr); } ``` ```java // call site Object osrResult = BytecodeNode.tryOSR(this, target, ..., () -> { instrument.notify(current, target); }); ``` ### tryOSR(BytecodeOSRNode, long, …) `static Object tryOSR(BytecodeOSRNode osrNode, long target, Object interpreterState, Runnable beforeTransfer, VirtualFrame parentFrame)`. Since 24.2. Overload of `tryOSR(BytecodeOSRNode, int, Object, Runnable, VirtualFrame)` with a `long` target. An interpreter that uses `long` targets should call this method. If an interpreter uses a `long` representation, it **must** override the hooks that define `long` overloads, namely `executeOSR(VirtualFrame, long, Object)`, `copyIntoOSRFrame(VirtualFrame, VirtualFrame, long, Object)`, and `prepareOSR(long)`. Overriding is necessary because the default `long` overloads call their `int` overloads for backwards compatibility, and these calls will fail for `long`-sized targets. See also: `tryOSR(BytecodeOSRNode, int, Object, Runnable, VirtualFrame)`, `executeOSR(VirtualFrame, long, Object)`, `copyIntoOSRFrame(VirtualFrame, VirtualFrame, long, Object)`, `prepareOSR(long)`. Cite: `com/oracle/truffle/api/nodes/BytecodeOSRNode.html#tryOSR(com.oracle.truffle.api.nodes.BytecodeOSRNode,long,java.lang.Object,java.lang.Runnable,com.oracle.truffle.api.frame.VirtualFrame)` ### storeParentFrameInArguments(VirtualFrame) `default Object[] storeParentFrameInArguments(VirtualFrame parentFrame)`. Since 22.2. Produce the arguments that will be used to perform the call to the new OSR root. It will become the arguments array of the frame passed into `executeOSR` in case a new frame is generated for the call for performance reasons. The contents are up to language, Truffle only requires that a subsequent call to `restoreParentFrame` with the arguments array will return the same object as was passed into the `parentFrame` argument. By default, this method creates a new one-element array, which discards the original frame arguments. Override this method to be able to preserve a subset of the original frame arguments. It is permitted to modify arguments array of `parentFrame` and return it. This is called only in the interpreter, therefore the frame is not virtual and it is safe to store it into the arguments array. Parameters: `parentFrame` `VirtualFrame`: the frame object to be stored in the resulting arguments array. Returns `Object[]`: arguments array containing `parentFrame`. Cite: `com/oracle/truffle/api/nodes/BytecodeOSRNode.html#storeParentFrameInArguments(com.oracle.truffle.api.frame.VirtualFrame)` ### restoreParentFrameFromArguments(Object[]) `default Frame restoreParentFrameFromArguments(Object[] arguments)`. Since 22.2. Return the parent frame that was stored in an arguments array by a previous call to `storeParentFrameInArguments`. Parameters: `arguments` `Object[]`: frame arguments originally produced by `storeParentFrameInArguments`. Returns `Frame`: stored parent frame. Cite: `com/oracle/truffle/api/nodes/BytecodeOSRNode.html#restoreParentFrameFromArguments(java.lang.Object[])` # ⚡︎ ControlFlowException [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Exception in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 0.8 or earlier. ```java public class ControlFlowException extends RuntimeException ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) > [`Exception`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Exception.html) > [`RuntimeException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/RuntimeException.html) > `ControlFlowException` An exception thrown to model control flow in a Truffle interpreter. The Truffle optimizer has special knowledge of this exception class for performance optimizations. ## Constructors ### ControlFlowException() `public ControlFlowException()`. Since 0.8 or earlier. Creates an exception thrown to model control flow. Cite: `com/oracle/truffle/api/nodes/ControlFlowException.html#()` ## Methods ### fillInStackTrace() `public final Throwable fillInStackTrace()`. Since 0.8 or earlier. For performance reasons, this exception does not record any stack trace information. Overrides `fillInStackTrace()`. Cite: `com/oracle/truffle/api/nodes/ControlFlowException.html#fillInStackTrace()` ## Inherited members - From class [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html): [`addSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#addSuppressed%28java.lang.Throwable%29), [`getCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getCause%28%29), [`getLocalizedMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getLocalizedMessage%28%29), [`getMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getMessage%28%29), [`getStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getStackTrace%28%29), [`getSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getSuppressed%28%29), [`initCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#initCause%28java.lang.Throwable%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintStream%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintWriter%29), [`setStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#setStackTrace%28java.lang.StackTraceElement[]%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # @ DenyReplace [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 22.2. ```java @Retention(RUNTIME) @Target({TYPE}) public @interface DenyReplace ``` If a [`Node`](com/oracle/truffle/api/nodes/Node.md) subtype is annotated with this annotation then [`replacement`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29) is denied. When replacement is denied an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) will be thrown on replace. Only final subtypes of type [`Node`](com/oracle/truffle/api/nodes/Node.md) may be annotated. [`DenyReplace`](com/oracle/truffle/api/nodes/DenyReplace.md) is recommended for uncached or not adoptable nodes that should never be replaceable. Truffle DSL automatically applies this annotation to all uncached versions of specialized nodes and libraries. # ◆ DirectCallNode [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 0.8 or earlier. ```java public abstract class DirectCallNode extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `DirectCallNode` Represents a direct call to a [`CallTarget`](com/oracle/truffle/api/CallTarget.md). Direct calls are calls for which the [`CallTarget`](com/oracle/truffle/api/CallTarget.md) remains the same for each consecutive call. This part of the Truffle API enables the runtime system to perform additional optimizations on direct calls. Optimizations that can be applied to a [`DirectCallNode`](com/oracle/truffle/api/nodes/DirectCallNode.md) are inlining and call site sensitive AST duplication. Inlining inlines this call site into the call graph of the parent [`CallTarget`](com/oracle/truffle/api/CallTarget.md). Call site sensitive AST duplication duplicates the [`CallTarget`](com/oracle/truffle/api/CallTarget.md) in an uninitialized state to collect call site sensitive profiling information. Please note: This class is not intended to be subclassed by guest language implementations. **See also** - [`for calls with a non-constant target`](com/oracle/truffle/api/nodes/IndirectCallNode.md) - [`TruffleRuntime.createDirectCallNode(CallTarget)`](com/oracle/truffle/api/TruffleRuntime.md#createDirectCallNode%28com.oracle.truffle.api.CallTarget%29) - [`forceInlining()`](com/oracle/truffle/api/nodes/DirectCallNode.md#forceInlining%28%29) - [`cloneCallTarget()`](com/oracle/truffle/api/nodes/DirectCallNode.md#cloneCallTarget%28%29) ## Fields ### callTarget `protected final CallTarget callTarget`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/DirectCallNode.html#callTarget` ## Constructors ### DirectCallNode(CallTarget) `protected DirectCallNode(CallTarget callTarget)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/DirectCallNode.html#(com.oracle.truffle.api.CallTarget)` ## Methods ### call(Object...) `public abstract Object call(Object... arguments)`. Since 0.23. Calls the inner `CallTarget` returned by `getCurrentCallTarget()`. Parameters: `arguments` `Object...`: the arguments that should be passed to the callee. Returns `Object`: the return result of the call. Cite: `com/oracle/truffle/api/nodes/DirectCallNode.html#call(java.lang.Object...)` ### call(int, Object[]) `public abstract Object call(int bytecodeIndex, Object[] arguments)`. Since 25.6. Calls the inner `CallTarget` returned by `getCurrentCallTarget()` with an explicit bytecode index. This call node identifies the location of the call. Callers that do not have an explicit bytecode index should pass `-1`. Parameters: `bytecodeIndex` `int`: the bytecode index associated with this call, or `-1` if no explicit bytecode index is available. `arguments` `Object[]`: the arguments that should be passed to the callee. Returns `Object`: the return result of the call. Cite: `com/oracle/truffle/api/nodes/DirectCallNode.html#call(int,java.lang.Object[])` ### call(Class, int, Object[]) `public abstract Object call(Class rootType, int bytecodeIndex, Object[] arguments)`. Since 25.6. Calls the current root node with an explicit root type, bytecode index, and arguments. A concrete `rootType` allows the host compiler to optimize the call boundary further, including inlining into `RootNode.execute`. Pass a compile-time-constant class literal assignable from the current root node. This call node identifies the location of the call. Callers that do not have an explicit bytecode index should pass `-1`. Parameters: `rootType` `Class`: the expected type of the current root node. `bytecodeIndex` `int`: the bytecode index associated with this call, or `-1` if no explicit bytecode index is available. `arguments` `Object[]`: the arguments that should be passed to the callee. Returns `Object`: the return result of the call. Cite: `com/oracle/truffle/api/nodes/DirectCallNode.html#call(java.lang.Class,int,java.lang.Object[])` ### getCallTarget() `public CallTarget getCallTarget()`. Since 0.8 or earlier. Returns the originally supplied `CallTarget` when this call node was created. Please note that the returned `CallTarget` is not necessarily the `CallTarget` that is called. For that use `getCurrentCallTarget()` instead. Returns `CallTarget`: the `CallTarget` provided. Cite: `com/oracle/truffle/api/nodes/DirectCallNode.html#getCallTarget()` ### isInlinable() `public abstract boolean isInlinable()`. Since 0.8 or earlier. Returns `true` if the underlying runtime system supports inlining for the `CallTarget` in this `DirectCallNode`. Returns `boolean`: true if inlining is supported. Cite: `com/oracle/truffle/api/nodes/DirectCallNode.html#isInlinable()` ### isInliningForced() `public abstract boolean isInliningForced()`. Since 0.8 or earlier. Returns `true` if the `CallTarget` is forced to be inlined. A `DirectCallNode` can either be inlined manually by invoking `forceInlining()` or by the runtime system which may at any point decide to inline. Returns `boolean`: true if this method was inlined else false. Cite: `com/oracle/truffle/api/nodes/DirectCallNode.html#isInliningForced()` ### forceInlining() `public abstract void forceInlining()`. Since 0.8 or earlier. Enforces the runtime system to inline the `CallTarget` at this call site. If the runtime system does not support inlining or it is already inlined this method has no effect. The runtime system may decide to not inline calls which were forced to inline. Cite: `com/oracle/truffle/api/nodes/DirectCallNode.html#forceInlining()` ### isCallTargetCloningAllowed() `public abstract boolean isCallTargetCloningAllowed()`. Since 0.8 or earlier. Returns `true` if the runtime system supports cloning and the `RootNode` returns `true` in `RootNode.isCloningAllowed()`. Returns `boolean`: `true` if the target is allowed to be cloned. Cite: `com/oracle/truffle/api/nodes/DirectCallNode.html#isCallTargetCloningAllowed()` ### cloneCallTarget() `public abstract boolean cloneCallTarget()`. Since 0.8 or earlier. Clones the `CallTarget` instance returned by `getCallTarget()` in an uninitialized state for this `DirectCallNode`. This can be sensible to gather call site sensitive profiling information for this `DirectCallNode`. If `isCallTargetCloningAllowed()` returns `false` this method has no effect and returns `false`. Cite: `com/oracle/truffle/api/nodes/DirectCallNode.html#cloneCallTarget()` ### isCallTargetCloned() `public final boolean isCallTargetCloned()`. Since 0.8 or earlier. Returns `true` if the target of the `DirectCallNode` was cloned by the runtime system or by the guest language implementation. Returns `boolean`: if the target was split. Cite: `com/oracle/truffle/api/nodes/DirectCallNode.html#isCallTargetCloned()` ### getClonedCallTarget() `public abstract CallTarget getClonedCallTarget()`. Since 0.8 or earlier. Returns the split `CallTarget` if this call site's `CallTarget` is cloned. Returns `CallTarget`: the split `CallTarget`. Cite: `com/oracle/truffle/api/nodes/DirectCallNode.html#getClonedCallTarget()` ### getCurrentCallTarget() `public CallTarget getCurrentCallTarget()`. Since 0.8 or earlier. Returns the used call target when `call(java.lang.Object[])` is invoked. If the `CallTarget` was split this method returns the `CallTarget` returned by `getClonedCallTarget()`. Returns `CallTarget`: the used `CallTarget` when node is called. Cite: `com/oracle/truffle/api/nodes/DirectCallNode.html#getCurrentCallTarget()` ### getCurrentRootNode() `public final RootNode getCurrentRootNode()`. Since 0.8 or earlier. Returns the `RootNode` associated with `CallTarget` returned by `getCurrentCallTarget()`. If the stored `CallTarget` does not contain a `RootNode` this method returns `null`. Returns `RootNode`: the root node of the used call target. See also: `getCurrentCallTarget()`. Cite: `com/oracle/truffle/api/nodes/DirectCallNode.html#getCurrentRootNode()` ### toString() `public String toString()`. Since 0.8 or earlier. Converts this node to a textual representation useful for debugging. Overrides `toString()`. Cite: `com/oracle/truffle/api/nodes/DirectCallNode.html#toString()` ### create(CallTarget) `public static DirectCallNode create(CallTarget target)`. Since 0.8 or earlier. Creates cached direct call node using bytecode index `-1`. Cite: `com/oracle/truffle/api/nodes/DirectCallNode.html#create(com.oracle.truffle.api.CallTarget)` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ EncapsulatingNodeReference [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 20.2. ```java public final class EncapsulatingNodeReference ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `EncapsulatingNodeReference` Thread local reference class to remember the current encapsulating node of an interpreter on the stack. The current encapsulating node is used whenever the code transitions from cached to uncached cases. This typically happens when the maximum limit for an inline cache was reached and the uncached version of a node will be used behind a [`TruffleBoundary`](com/oracle/truffle/api/CompilerDirectives.TruffleBoundary.md). To correctly produce exception stack traces it is necessary to remember the node that transitioned to the uncached case. Uncached calls to [`CallTarget`](com/oracle/truffle/api/CallTarget.md) will automatically use the value of the encapsulating node. Truffle DSL produces such transitions automatically if Truffle libraries are used and they transition to uncached. Usage example for pushing and restoring the current node to the stack. ```java EncapsulatingNodeReference encapsulating = EncapsulatingNodeReference.getCurrent(); Node encapsulatingNode = encapsulating.set(currentNode); try { // follow uncached path } finally { encapsulating.set(encapsulatingNode); } ``` The current encapsulating node can also be useful when constructing guest exceptions in slow-paths and the location of the error needs to be found out reliably. Usage example: ```java final class LanguageException extends AbstractTruffleException { private LanguageException(Node locationNode) { super(locationNode); } static LanguageException create(Node locationNode) { CompilerAsserts.partialEvaluationConstant(locationNode); if (locationNode == null || !locationNode.isAdoptable()) { return new LanguageException(EncapsulatingNodeReference.getCurrent().get()); } else { return new LanguageException(locationNode); } } // ... } ``` Note that [`Node.isAdoptable()`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29) is a way to find out whether a node was used in an uncached scenario or not. ## Methods ### set(Node) `public Node set(Node node)`. Since 20.2. Sets the current encapsulating node for the current thread and returns its previous value. The passed node may be `null`. The set node must be `adoptable` and be adopted by a `RootNode` otherwise an [`AssertionError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AssertionError.html) is thrown. This method must only be used from the thread it was `requested` for. This method is safe to be called from compiled code paths. Cite: `com/oracle/truffle/api/nodes/EncapsulatingNodeReference.html#set(com.oracle.truffle.api.nodes.Node)` ### get() `public Node get()`. Since 20.2. Returns the current encapsulating node for the current thread. Returned node may be `null`. If the returned node is non-null then it is guaranteed to be `adoptable` and adopted by a `RootNode`. This method must only be used from the thread it was `requested` for. This method is safe to be called from compiled code paths. Cite: `com/oracle/truffle/api/nodes/EncapsulatingNodeReference.html#get()` ### getCurrent() `public static EncapsulatingNodeReference getCurrent()`. Since 20.2. Returns the encapsulating node reference of the [`current`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Thread.html#currentThread%28%29) thread. The returned value is never `null`. This method is safe to be called from compiled code paths. Cite: `com/oracle/truffle/api/nodes/EncapsulatingNodeReference.html#getCurrent()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ ExecutableNode [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 0.31. ```java public abstract class ExecutableNode extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `ExecutableNode` Represents an executable node in a Truffle AST. The executable node represents an AST fragment that can be [`executed`](com/oracle/truffle/api/nodes/ExecutableNode.md#execute%28com.oracle.truffle.api.frame.VirtualFrame%29) using a [`frame`](com/oracle/truffle/api/frame/VirtualFrame.md) instance created by the framework. **See also** - [`TruffleLanguage.parse(com.oracle.truffle.api.TruffleLanguage.InlineParsingRequest)`](com/oracle/truffle/api/TruffleLanguage.md#parse%28com.oracle.truffle.api.TruffleLanguage.InlineParsingRequest%29) ## Constructors ### ExecutableNode(TruffleLanguage) `protected ExecutableNode(TruffleLanguage language)`. Since 0.31. Creates new executable node with a given language instance. The language instance is obtainable while `TruffleLanguage.parse(InlineParsingRequest)` is executed. Parameters: `language` `TruffleLanguage`: the language this executable node is associated with. Cite: `com/oracle/truffle/api/nodes/ExecutableNode.html#(com.oracle.truffle.api.TruffleLanguage)` ## Methods ### execute(VirtualFrame) `public abstract Object execute(VirtualFrame frame)`. Since 0.31. Execute this fragment at the place where it was parsed. Parameters: `frame` `VirtualFrame`: the actual frame valid at the parsed location. Returns `Object`: the result of the execution, must be an interop type (i.e. either implementing TruffleObject or be a primitive value), or `null`. Cite: `com/oracle/truffle/api/nodes/ExecutableNode.html#execute(com.oracle.truffle.api.frame.VirtualFrame)` ### getLanguageInfo() `public final LanguageInfo getLanguageInfo()`. Since 0.31. Returns public information about the language. The language can be assumed equal if the instances of the language info instance are the same. To access internal details of the language within the language implementation use a `LanguageReference`. Cite: `com/oracle/truffle/api/nodes/ExecutableNode.html#getLanguageInfo()` ### getLanguage(Class) `public final C getLanguage(Class languageClass)`. Since 0.31. Returns the language instance associated with this executable node. The language instance is intended for internal use in languages and is only accessible if the concrete type of the language is known. Public information about the language can be accessed using `getLanguageInfo()`. The language is `null` if the executable node is not associated with a language. This method is guaranteed to return a `PE constant` if the root node is also a PE constant. See also: `getLanguageInfo()`. Cite: `com/oracle/truffle/api/nodes/ExecutableNode.html#getLanguage(java.lang.Class)` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ ExecutionSignature [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 20.3. ```java public final class ExecutionSignature ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `ExecutionSignature` Represents an execution signature of a [`RootNode`](com/oracle/truffle/api/nodes/RootNode.md). This is used to represent AOT signatures. **See also** - [`RootNode.prepareForAOT()`](com/oracle/truffle/api/nodes/RootNode.md#prepareForAOT%28%29) ## Fields ### GENERIC `public static final ExecutionSignature GENERIC`. Since 20.3. Returns a generic return profile where return and argument types are unknown. Cite: `com/oracle/truffle/api/nodes/ExecutionSignature.html#GENERIC` ## Methods ### getArgumentTypes() `public Class[] getArgumentTypes()`. Since 20.3. Returns the argument types of the execution signature. The returned types may be `null` to indicate that nothing is known about argument types. If the argument returns a non-null value then the length of the array will be used for the number of expected arguments. Each value of the return array specifies the expected argument type of the execution. If an argument type is `null` then this indicates that the argument type is unknown. Cite: `com/oracle/truffle/api/nodes/ExecutionSignature.html#getArgumentTypes()` ### getReturnType() `public Class getReturnType()`. Since 20.3. Returns the return type of the execution signature. The return type may be `null` to indicate that the type is unknown. Cite: `com/oracle/truffle/api/nodes/ExecutionSignature.html#getReturnType()` ### create(Class, Class[]) `public static ExecutionSignature create(Class returnType, Class[] argumentTypes)`. Since 20.3. Creates a new execution signature of a `RootNode`. The return type or the argument types may be null to indicate that they are unknown. Individual argument type array values may also be null to indicate they are unknown. Cite: `com/oracle/truffle/api/nodes/ExecutionSignature.html#create(java.lang.Class,java.lang.Class[])` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # @ ExplodeLoop [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 0.8 or earlier. ```java @Retention(RUNTIME) @Target({METHOD}) public @interface ExplodeLoop ``` Specifies that loops originating from within this method should be fully unrolled. This is only compatible with loops that have a partial-evaluation-constant number of iterations - loops without a constant number of iterations will cause the compiler to bailout due to the graph exceeding maximum size. The annotation does not apply to loops from within other methods that are inlined into this method. ## Nested types - [`ExplodeLoop.LoopExplosionKind`](com/oracle/truffle/api/nodes/ExplodeLoop.LoopExplosionKind.md) (enum class): Controls the behavior of the ExplodeLoop annotation. ## Elements ### kind() `ExplodeLoop.LoopExplosionKind kind() default FULL_UNROLL_UNTIL_RETURN`. Since 0.15. The loop explosion kind. Default: `FULL_UNROLL_UNTIL_RETURN`. Cite: `com/oracle/truffle/api/nodes/ExplodeLoop.html#kind()` # ≡ ExplodeLoop.LoopExplosionKind [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Enum class in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 0.15. Nested in [`ExplodeLoop`](com/oracle/truffle/api/nodes/ExplodeLoop.md). ```java public enum ExplodeLoop.LoopExplosionKind ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html) > `LoopExplosionKind` Controls the behavior of the [`ExplodeLoop`](com/oracle/truffle/api/nodes/ExplodeLoop.md) annotation. ## Terminology In the explanations below, the term *loop end* refers to control flow reaching the end of the loop body such as `continue` or a statement at the end of the loop body. The term *loop exit* refers to control flow exiting the loop, such as `return` or `break`. Example: ```java int loopEndExits() { int state = -1; for (int i = 0; i < 4; i++) { if (condition(i)) { continue; // loop end } else if (condition1(i)) { // loop exit (break) state = 2; break; } else if (condition2(i)) { // loop exit (return) state = 3; return state; } else { state = i; // loop end } } // loop exit (after last iteration) return state; } ``` There are 4 loop explosion kinds (plus `MERGE_EXPLODE`, which is meant for bytecode interpreters), configurable by 2 parameters: UNROLL vs EXPLODE and UNTIL\_RETURN vs not. ## UNROLL vs EXPLODE The first parameter specifies whether the partial evaluator should duplicate loop ends. UNROLL merges after each loop end and EXPLODE keeps exploding nested iterations like a tree. ```java @ExplodeLoop void unrollVsExplodeLoop() { int state = 1; for (int i = 0; i < 2; i++) { if (c(i, state)) { state = 2; } else { state = 3; } } } ``` gets unrolled with `FULL_UNROLL` to: ```java void unrollVsExplodeLoopUnrolled() { int state = 1; if (c(0, 1)) { state = 2; } else { state = 3; } if (c(1, state)) { state = 2; } else { state = 3; } } ``` and exploded with `FULL_EXPLODE` to: ```java void unrollVsExplodeLoopExploded() { int state = 1; if (c(0, 1)) { if (c(1, 2)) { state = 2; } else { state = 3; } } else { if (c(1, 3)) { state = 2; } else { state = 3; } } } ``` ## UNTIL\_RETURN The second parameter specifies whether the partial evaluator should duplicate loop exits. UNTIL\_RETURN duplicates them, otherwise control flow is merged. ```java @ExplodeLoop int untilReturnLoop() { for (int i = 0; i < 2; i++) { if (condition(i)) { // exit1 return f(i); } } // exit2 return fallback(); } ``` is expanded with `FULL_UNROLL_UNTIL_RETURN` to: ```java int untilReturn() { if (condition(0)) { return f(0); } if (condition(1)) { return f(1); } return fallback(); } ``` while `FULL_UNROLL` merges loop exits: ```java int notUntilReturn() { int i; for (;;) { if (condition(0)) { i = 0; break; } if (condition(1)) { i = 1; break; } return fallback(); } return f(i); } ``` ### break Note that `break` statements inside the loop will duplicate code after the loop since they add new loop exits: ```java @ExplodeLoop int breaksLoop() { int state = -1; for (int i = 0; i < 2; i++) { if (condition1(i)) { return f(i); } else if (condition2(i)) { state = i; break; } } return fallback(state); } ``` is expanded with `FULL_UNROLL_UNTIL_RETURN` to: ```java int breaksLoopUnrollUntilReturn() { if (condition1(0)) { return f(0); } else if (condition2(0)) { return fallback(0); } if (condition1(1)) { return f(1); } else if (condition2(1)) { return fallback(1); } return fallback(-1); } ``` ## Enum constants ### FULL_UNROLL `FULL_UNROLL`. Since 0.15. Fully unroll all loops. The loops must have a known finite number of iterations. If a loop has multiple loop ends, they are merged so that the subsequent loop iteration is processed only once. For example, a loop with 4 iterations and 2 loop ends leads to 1+1+1+1 = 4 copies of the loop body. Cite: `com/oracle/truffle/api/nodes/ExplodeLoop.LoopExplosionKind.html#FULL_UNROLL` ### FULL_UNROLL_UNTIL_RETURN `FULL_UNROLL_UNTIL_RETURN`. Since 20.0. Like `FULL_UNROLL`, but in addition loop unrolling duplicates loop exits in every iteration instead of merging them. Code after a loop exit is duplicated for every loop exit and every loop iteration. For example, a loop with 4 iterations and 2 loop exits (exit1 and exit2, where exit1 is an early return inside a loop, such as `untilReturnLoop()`) leads to 4 copies of the loop body and 4 copies of exit1 and 1 copy of exit2. After each exit all code until a return is duplicated per iteration. Beware of break statements inside loops since they cause additional loop exits leading to code duplication along exit2. Cite: `com/oracle/truffle/api/nodes/ExplodeLoop.LoopExplosionKind.html#FULL_UNROLL_UNTIL_RETURN` ### FULL_EXPLODE `FULL_EXPLODE`. Since 0.15. Fully explode all loops. The loops must have a known finite number of iterations. If a loop has multiple loop ends, they are not merged so that subsequent loop iterations are processed multiple times. For example, a loop with 4 iterations and 2 loop ends leads to 1+2+4+8 = 15 copies of the loop body. Cite: `com/oracle/truffle/api/nodes/ExplodeLoop.LoopExplosionKind.html#FULL_EXPLODE` ### FULL_EXPLODE_UNTIL_RETURN `FULL_EXPLODE_UNTIL_RETURN`. Since 0.15. Like `FULL_EXPLODE`, but in addition explosion does not stop at loop exits. Code after the loop is duplicated for every loop exit of every loop iteration. For example, a loop with 4 iterations and 2 loop exits leads to 4 \* 2 = 8 copies of the code after the loop. Cite: `com/oracle/truffle/api/nodes/ExplodeLoop.LoopExplosionKind.html#FULL_EXPLODE_UNTIL_RETURN` ### MERGE_EXPLODE `MERGE_EXPLODE`. Since 0.15. like `FULL_EXPLODE`, but copies of the loop body that have the exact same state (all local variables have the same value) are merged. This reduces the number of copies necessary, but can introduce loops again. This kind is useful for bytecode interpreter loops. Cite: `com/oracle/truffle/api/nodes/ExplodeLoop.LoopExplosionKind.html#MERGE_EXPLODE` ## Methods ### values() `public static ExplodeLoop.LoopExplosionKind[] values()`. Returns the enum constants in declaration order. Returns `ExplodeLoop.LoopExplosionKind[]`: Returns the enum constants in declaration order. Cite: `com/oracle/truffle/api/nodes/ExplodeLoop.LoopExplosionKind.html#values()` ### valueOf(String) `public static ExplodeLoop.LoopExplosionKind valueOf(String name)`. Returns the enum constant with the given name. Parameters: `name` `String`: The exact name of the enum constant. Returns `ExplodeLoop.LoopExplosionKind`: Returns the enum constant with the given name. Cite: `com/oracle/truffle/api/nodes/ExplodeLoop.LoopExplosionKind.html#valueOf(java.lang.String)` ## Inherited members - From class [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#clone%28%29), [`compareTo`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#compareTo%28E%29), [`describeConstable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#describeConstable%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#finalize%28%29), [`getDeclaringClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#getDeclaringClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#hashCode%28%29), [`name`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#name%28%29), [`ordinal`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#ordinal%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#toString%28%29), [`valueOf`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#valueOf%28java.lang.Class,java.lang.String%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ IndirectCallNode [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 0.8 or earlier. ```java public abstract class IndirectCallNode extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `IndirectCallNode` Represents an indirect call to a [`CallTarget`](com/oracle/truffle/api/CallTarget.md). Indirect calls are calls for which the [`CallTarget`](com/oracle/truffle/api/CallTarget.md) may change dynamically for each consecutive call. This part of the Truffle API enables the runtime system to perform additional optimizations on indirect calls. Please note: This class is not intended to be sub classed by guest language implementations. See [`DirectCallNode`](com/oracle/truffle/api/nodes/DirectCallNode.md) for faster calls with a constantly known [`CallTarget`](com/oracle/truffle/api/CallTarget.md). ## Constructors ### IndirectCallNode() `protected IndirectCallNode()`. Since 0.8 or earlier. Constructor for implementation subclasses. Cite: `com/oracle/truffle/api/nodes/IndirectCallNode.html#()` ## Methods ### call(CallTarget, Object...) `public abstract Object call(CallTarget target, Object... arguments)`. Since 0.23. Performs an indirect call to the given `CallTarget` target with the provided arguments. Parameters: `target` `CallTarget`: the `CallTarget` to call. `arguments` `Object...`: the arguments to provide. Returns `Object`: the return value of the call. Cite: `com/oracle/truffle/api/nodes/IndirectCallNode.html#call(com.oracle.truffle.api.CallTarget,java.lang.Object...)` ### call(CallTarget, int, Object[]) `public abstract Object call(CallTarget target, int bytecodeIndex, Object[] arguments)`. Since 25.6. Performs an indirect call to the given `CallTarget` target with an explicit bytecode index and the provided arguments. Callers that do not have an explicit bytecode index should pass `-1`. Parameters: `target` `CallTarget`: the `CallTarget` to call. `bytecodeIndex` `int`: the bytecode index associated with this call, or `-1` if no explicit bytecode index is available. `arguments` `Object[]`: the arguments to provide. Returns `Object`: the return value of the call. Cite: `com/oracle/truffle/api/nodes/IndirectCallNode.html#call(com.oracle.truffle.api.CallTarget,int,java.lang.Object[])` ### call(RootNode, int, Object[]) `public Object call(RootNode root, int bytecodeIndex, Object[] arguments)`. Since 25.6. Calls the given root node with an explicit bytecode index and arguments. A concrete root-node type allows the host compiler to optimize the call boundary further, including inlining into `RootNode.execute`. Cast `root` to its concrete type before calling this method, even if the root instance changes between calls. This call node identifies the location of the call. Callers that do not have an explicit bytecode index should pass `-1`. The root node's call target must already be initialized using `RootNode.initializeCallTarget()` or `RootNode.getCallTarget()`. Parameters: `root` `RootNode`: the root node to call. `bytecodeIndex` `int`: the bytecode index associated with this call, or `-1` if no explicit bytecode index is available. `arguments` `Object[]`: the arguments to provide. Returns `Object`: the return value of the call. Throws: `NullPointerException` (unchecked): if `root` is `null`. `IllegalStateException` (unchecked): if the root node's call target has not been initialized. Cite: `com/oracle/truffle/api/nodes/IndirectCallNode.html#call(com.oracle.truffle.api.nodes.RootNode,int,java.lang.Object[])` ### create() `public static IndirectCallNode create()`. Since 0.8 or earlier. Creates a cached indirect call node. Returns `IndirectCallNode`: a new call node. Cite: `com/oracle/truffle/api/nodes/IndirectCallNode.html#create()` ### getUncached() `public static IndirectCallNode getUncached()`. Since 19.0. Returns an uncached version of an indirect call node. Uncached versions of an indirect call node use the `current encapsulating node` as source location. Cite: `com/oracle/truffle/api/nodes/IndirectCallNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ⚡︎ InvalidAssumptionException [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Exception in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 0.8 or earlier. ```java public final class InvalidAssumptionException extends SlowPathException ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) > [`Exception`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Exception.html) > [`SlowPathException`](com/oracle/truffle/api/nodes/SlowPathException.md) > `InvalidAssumptionException` An exception that should be thrown if an assumption is checked and the check fails. The Truffle optimizer has special knowledge of this exception class and will never compile a catch block that catches this exception type. ## Constructors ### InvalidAssumptionException() `public InvalidAssumptionException()`. Since 0.8 or earlier. Default constructor. Cite: `com/oracle/truffle/api/nodes/InvalidAssumptionException.html#()` ## Inherited members - From class [`SlowPathException`](com/oracle/truffle/api/nodes/SlowPathException.md): [`fillInStackTrace`](com/oracle/truffle/api/nodes/SlowPathException.md#fillInStackTrace%28%29) - From class [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html): [`addSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#addSuppressed%28java.lang.Throwable%29), [`getCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getCause%28%29), [`getLocalizedMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getLocalizedMessage%28%29), [`getMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getMessage%28%29), [`getStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getStackTrace%28%29), [`getSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getSuppressed%28%29), [`initCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#initCause%28java.lang.Throwable%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintStream%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintWriter%29), [`setStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#setStackTrace%28java.lang.StackTraceElement[]%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ LanguageInfo [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 0.25. ```java public final class LanguageInfo ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `LanguageInfo` Represents public information about a language. ## Methods ### getId() `public String getId()`. Since 0.27. Returns the unique id of the language. This id is equivalent to the id returned by `Registration.id()`. Cite: `com/oracle/truffle/api/nodes/LanguageInfo.html#getId()` ### getName() `public String getName()`. Since 0.25. Returns the unique name of the language. This name is equivalent to the name returned by `Registration.name()`. Cite: `com/oracle/truffle/api/nodes/LanguageInfo.html#getName()` ### getVersion() `public String getVersion()`. Since 0.25. Returns the version of the language. This version is equivalent to the name returned by `Registration.version()`. Cite: `com/oracle/truffle/api/nodes/LanguageInfo.html#getVersion()` ### getDefaultMimeType() `public String getDefaultMimeType()`. Since 19.0. Returns the default MIME type of a language or `null` if no default mime-type is set. The default MIME type specifies whether a source is loaded as character or binary based source by default. If no default MIME type is set all sources evaluated with that language will be interpreted as `character based` sources. This set is equivalent to the set provided by `Registration.defaultMimeType()`. Cite: `com/oracle/truffle/api/nodes/LanguageInfo.html#getDefaultMimeType()` ### getMimeTypes() `public Set getMimeTypes()`. Since 0.25. Returns the MIME types supported by this language. This set is equivalent to the set provided by `Registration.characterMimeTypes()` and `Registration.byteMimeTypes()`. Cite: `com/oracle/truffle/api/nodes/LanguageInfo.html#getMimeTypes()` ### isInternal() `public boolean isInternal()`. Since 0.31. Returns `boolean`: `true` if the language is `internal`, `false` otherwise. Cite: `com/oracle/truffle/api/nodes/LanguageInfo.html#isInternal()` ### isInteractive() `public boolean isInteractive()`. Since 19.0. Returns `boolean`: `true` if the language is `interactive`, `false` otherwise. Cite: `com/oracle/truffle/api/nodes/LanguageInfo.html#isInteractive()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ LoopNode [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 0.8 or earlier. ```java public abstract class LoopNode extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `LoopNode` A loop node calls [`repeating nodes`](com/oracle/truffle/api/nodes/RepeatingNode.md#executeRepeating%28com.oracle.truffle.api.frame.VirtualFrame%29) as long as it returns `true`. Using the loop node in a guest language implementation allows the Truffle runtime to optimize loops in a better way. For example a Truffle runtime implementation might decide to optimize loop already during its first execution (also called on stack replacement OSR). Loop nodes are intended to be implemented by Truffle runtime implementations and not by guest language implementations. Note: The loop condition is automatically profiled by the loop node, so the [`repeating node`](com/oracle/truffle/api/nodes/RepeatingNode.md) should not use a loop condition profile. Full usage example for guest language while node: ```java public class WhileNode extends GuestLanguageNode { @Node.Child private LoopNode loop; public WhileNode(GuestLanguageNode conditionNode, GuestLanguageNode bodyNode) { loop = Truffle.getRuntime().createLoopNode(new WhileRepeatingNode(conditionNode, bodyNode)); } @Override public Object execute(VirtualFrame frame) { loop.executeLoop(frame); return null; } private static class WhileRepeatingNode extends Node implements RepeatingNode { @Node.Child private GuestLanguageNode conditionNode; @Node.Child private GuestLanguageNode bodyNode; public WhileRepeatingNode(GuestLanguageNode conditionNode, GuestLanguageNode bodyNode) { this.conditionNode = conditionNode; this.bodyNode = bodyNode; } public boolean executeRepeating(VirtualFrame frame) { if ((boolean) conditionNode.execute(frame)) { try { bodyNode.execute(frame); } catch (ContinueException ex) { // the body might throw a continue control-flow exception // continue loop invocation } catch (BreakException ex) { // the body might throw a break control-flow exception // break loop invocation by returning false return false; } return true; } else { return false; } } } } // substitute with a guest language node type public abstract class GuestLanguageNode extends Node { public abstract Object execute(VirtualFrame frame); } // thrown by guest language continue statements public final class ContinueException extends ControlFlowException {} // thrown by guest language break statements public final class BreakException extends ControlFlowException {} ``` **See also** - [`RepeatingNode`](com/oracle/truffle/api/nodes/RepeatingNode.md) - [`TruffleRuntime.createLoopNode(RepeatingNode)`](com/oracle/truffle/api/TruffleRuntime.md#createLoopNode%28com.oracle.truffle.api.nodes.RepeatingNode%29) ## Constructors ### LoopNode() `protected LoopNode()`. Since 0.8 or earlier. Constructor for subclasses. Cite: `com/oracle/truffle/api/nodes/LoopNode.html#()` ## Methods ### execute(VirtualFrame) `public Object execute(VirtualFrame frame)`. Since 19.3. Invokes one loop invocation by repeatedly calling `execute)` on the repeating node the loop was initialized with. Any exceptions that occur in the execution of the repeating node will just be forwarded to this method and will cancel the current loop invocation. Parameters: `frame` `VirtualFrame`: the current execution frame or null if the repeating node does not require a frame. Returns `Object`: a value `v` returned by `execute` satisfying `shouldContinue(v)`` == false`, which can be used in a language-specific way (for example, to encode structured jumps). Cite: `com/oracle/truffle/api/nodes/LoopNode.html#execute(com.oracle.truffle.api.frame.VirtualFrame)` ### getRepeatingNode() `public abstract RepeatingNode getRepeatingNode()`. Since 0.8 or earlier. Returns the repeating node the loop node was created with. Cite: `com/oracle/truffle/api/nodes/LoopNode.html#getRepeatingNode()` ### reportLoopCount(Node, int) `public static void reportLoopCount(Node source, int iterations)`. Since 0.12. Reports the execution count of a loop for which no `LoopNode` was used. The optimization heuristics can use the loop count from non Truffle loops to guide compilation and inlining better. Do not use `LoopNode` and `reportLoopCount(Node, int)` at the same time for one loop. If the number of iterations needs to be counted and can overflow, only count if `CompilerDirectives.hasNextTier()` is `true` (reporting will have no effect in the last tier) and consider reporting [`Integer.MAX_VALUE`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Integer.html#MAX_VALUE) in case of overflows. If the number is often zero and `reportLoopCount(Node, int)` is called frequently (e.g. in a loop), consider adding a check to avoid the overhead of redundant calls with an `iterations` argument of zero in the interpreter. Example usage for a custom loop iterating over an array: ` `` public int executeCustomLoopSum(int[] data) { int sum = 0; for (int i = 0; i ``<`` data.length; i++) { sum += data[i]; } LoopNode.reportLoopCount(this, data.length); return sum; } `` ` Example usage for a custom loop with an unknown number of iterations and a potential `int` overflow: ` `` public Object executeCustomLoopWithUnknownIterations(int[] data) { Object result; int counter = 0; while(true) { if (isResultAvailable()) { result = getResult(); break; } // do some work to calculate result if (CompilerDirectives.hasNextTier()) { counter++; } } if (counter != 0) { LoopNode.reportLoopCount(this, counter > 0 ? counter : Integer.MAX_VALUE); } return result; } `` `. Parameters: `source` `Node`: the Node which invoked the loop. `iterations` `int`: the number iterations to report to the runtime system, must be \>= 0. Cite: `com/oracle/truffle/api/nodes/LoopNode.html#reportLoopCount(com.oracle.truffle.api.nodes.Node,int)` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ Node [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 0.8 or earlier. ```java public abstract class Node implements NodeInterface, Cloneable ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Node` Implements: [`NodeInterface`](com/oracle/truffle/api/nodes/NodeInterface.md), [`Cloneable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Cloneable.html) Abstract base class for all nodes in the Truffle Abstract Syntax Tree (AST). The `Node` class serves as the foundational class for all nodes within the Truffle framework. It provides the core functionality required to build interpreters for guest languages by allowing language implementers to define custom nodes representing language constructs. Key responsibilities and features of the `Node` class include: - Managing the parent-child relationships between nodes, ensuring the integrity of the AST. - Providing mechanisms for adopting and replacing child nodes within the AST, facilitating dynamic language features and optimizations. - Handling source code associations, allowing nodes to represent specific segments of the guest language source code via [`getSourceSection()`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29). - Supporting node cloning and deep copying, enabling the creation of modified copies of node trees. - Facilitating node visitation patterns through the [`accept(NodeVisitor)`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29) method and providing iteration over child nodes via [`getChildren()`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29). - Ensuring thread safety and synchronization for modifications to the AST with atomic operations and locks via [`atomic(Runnable)`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29) and [`getLock()`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29). - Integrating with Truffle's instrumentation and debugging facilities, allowing for runtime observation and modification of AST nodes. - Reporting polymorphic specializations through [`reportPolymorphicSpecialize()`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), aiding in the optimization processes of the Truffle framework. Language implementers typically create subclasses of `Node` to represent specific language constructs and operations. Subclasses can use the [`Child`](com/oracle/truffle/api/nodes/Node.Child.md) and [`Children`](com/oracle/truffle/api/nodes/Node.Children.md) annotations to declare child nodes, which the Truffle framework manages automatically. The `Node` class also provides important methods such as [`replace(Node)`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29) for replacing nodes in the AST, [`getParent()`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29) and [`getRootNode()`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29) for navigating the tree, and [`getDescription()`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29) for obtaining a user-readable description of the node. **See also** - [`RootNode`](com/oracle/truffle/api/nodes/RootNode.md) - [`NodeVisitor`](com/oracle/truffle/api/nodes/NodeVisitor.md) - [`NodeInterface`](com/oracle/truffle/api/nodes/NodeInterface.md) ## Nested types - [`Node.Child`](com/oracle/truffle/api/nodes/Node.Child.md) (annotation interface): Marks fields that represent child nodes of this node. - [`Node.Children`](com/oracle/truffle/api/nodes/Node.Children.md) (annotation interface): Marks array fields that are children of this node. ## Constructors ### Node() `protected Node()`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/Node.html#()` ## Methods ### getCost() `@Deprecated public NodeCost getCost()`. Since 0.8 or earlier. Deprecated. in 24.1 without replacement. Returns a rough estimate for the cost of this `Node`. This estimate can be used by runtime systems or guest languages to implement heuristics based on Truffle ASTs. This method is intended to be overridden by subclasses. The default implementation returns the value of `NodeInfo.cost()` of the `NodeInfo` annotation declared at the subclass. If no `NodeInfo` annotation is declared the method returns `NodeCost.MONOMORPHIC` as a default value. Cite: `com/oracle/truffle/api/nodes/Node.html#getCost()` ### getSourceSection() `public SourceSection getSourceSection()`. Since 0.8 or earlier. Retrieves the segment of guest language source code that is represented by this Node. The default implementation of this method returns `null`. If your node represents a segment of the source code, override this method and return a eagerly or lazily computed source section value. This method is not designed to be invoked on compiled code paths. May be called on any thread and without a language context being active. Simple example implementation using a simple implementation using a field: Recommended implementation computing the source section lazily from primitive fields: Returns `SourceSection`: the source code represented by this Node. Cite: `com/oracle/truffle/api/nodes/Node.html#getSourceSection()` ```java abstract class SimpleNode extends Node { private SourceSection sourceSection; void setSourceSection(SourceSection sourceSection) { this.sourceSection = sourceSection; } @Override public SourceSection getSourceSection() { return sourceSection; } } ``` ```java abstract class RecommendedNode extends Node { private static final int NO_SOURCE = -1; private int sourceCharIndex = NO_SOURCE; private int sourceLength; public abstract Object execute(VirtualFrame frame); // invoked by the parser to set the source void setSourceSection(int charIndex, int length) { assert sourceCharIndex == NO_SOURCE : "source should only be set once"; this.sourceCharIndex = charIndex; this.sourceLength = length; } @Override public final SourceSection getSourceSection() { if (sourceCharIndex == NO_SOURCE) { // AST node without source return null; } RootNode rootNode = getRootNode(); if (rootNode == null) { // not yet adopted yet return null; } Source source = rootNode.getSourceSection().getSource(); return source.createSection(sourceCharIndex, sourceLength); } } ``` ### getEncapsulatingSourceSection() `public SourceSection getEncapsulatingSourceSection()`. Since 0.8 or earlier. Retrieves the segment of guest language source code that is represented by this Node, if present; otherwise retrieves the segment represented by the nearest AST ancestor that has this information. Can be called on any thread and without a language context. Returns `SourceSection`: an approximation of the source code represented by this Node. Cite: `com/oracle/truffle/api/nodes/Node.html#getEncapsulatingSourceSection()` ### isAdoptable() `public boolean isAdoptable()`. Since 19.0. Returns `true` if this node can be adopted by a parent. This method is intended to be overriden by subclasses. If nodes need to be statically shared that they must not be adoptable, because otherwise the parent reference might cause a memory leak. If a node is not adoptable then then it is guaranteed that the `parent` pointer remains `null` at all times, even if the node is tried to be adopted by a parent. If the result of this method is statically known then it is recommended to make the node implement `UnadoptableNode` instead. Implementations of `isAdoptable()` are required to fold to a constant result when compiled with a constant receiver. Cite: `com/oracle/truffle/api/nodes/Node.html#isAdoptable()` ### insert(T[]) `public final T[] insert(T[] newChildren)`. Since 0.8 or earlier. Inserts new node children into an AST that was already `adopted` by a `parent`. The new children need to be assigned to its `children` field after insert was called. Parameters: `newChildren` `T[]`: the array of new children whose parent should be updated. Returns `T[]`: the array of new children. Cite: `com/oracle/truffle/api/nodes/Node.html#insert(T[])` ### insert(T) `public final T insert(T newChild)`. Since 0.8 or earlier. Inserts an new node into an AST that was already `adopted` by a `parent`. The new child needs to be assigned to its `child` field after insert was called. Parameters: `newChild` `T`: the new child whose parent should be updated. Returns `T`: the new child. Cite: `com/oracle/truffle/api/nodes/Node.html#insert(T)` ### notifyInserted(Node) `protected final void notifyInserted(Node node)`. Since 0.27. Notifies the framework about the insertion of one or more nodes during execution. Otherwise, the framework assumes that `instrumentable` nodes remain unchanged after their root node is first `executed`. Insertions don't need to be notified if it is known that none of the inserted nodes are `instrumentable`. The provided `Node` and its children must be `adopted` in the AST before invoking this method. The caller must ensure that this method is invoked only once for a given node and its children. Parameters: `node` `Node`: the node tree that got inserted. Cite: `com/oracle/truffle/api/nodes/Node.html#notifyInserted(com.oracle.truffle.api.nodes.Node)` ```java class MyRootNode extends RootNode { protected MyRootNode(MyLanguage language) { super(language); } @Child InstrumentableLanguageNode child; @Override public Object execute(VirtualFrame frame) { if (child == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); child = insert(new InstrumentableLanguageNode()); notifyInserted(child); } return child.execute(frame); } } ``` ### adoptChildren() `public final void adoptChildren()`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/Node.html#adoptChildren()` ### getDebugProperties() `public Map getDebugProperties()`. Since 0.8 or earlier. Returns properties of this node interesting for debugging and can be overwritten by subclasses to add their own custom properties. This method may be called on a compiler thread without an entered guest context. Implementations must not execute guest code or rely on a guest context being entered. Debug property values should be strings, boxed primitive values, classes, or enums. Other values may be represented using an opaque identity string; their [`Object.toString()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29) method is not invoked implicitly. Returns `Map`: the properties as a key/value hash map. Cite: `com/oracle/truffle/api/nodes/Node.html#getDebugProperties()` ### getParent() `public final Node getParent()`. Since 0.8 or earlier. The current parent node of this node. Returns `Node`: the parent node. Cite: `com/oracle/truffle/api/nodes/Node.html#getParent()` ### replace(T, CharSequence) `public final T replace(T newNode, CharSequence reason)`. Since 0.8 or earlier. Replaces this node with another node. If there is a source section (see `getSourceSection()`) associated with this node, it is transferred to the new node. Parameters: `newNode` `T`: the new node that is the replacement. `reason` `CharSequence`: a description of the reason for the replacement. Returns `T`: the new node. Cite: `com/oracle/truffle/api/nodes/Node.html#replace(T,java.lang.CharSequence)` ### replace(T) `public final T replace(T newNode)`. Since 0.8 or earlier. Replaces this node with another node. If there is a source section (see `getSourceSection()`) associated with this node, it is transferred to the new node. Parameters: `newNode` `T`: the new node that is the replacement. Returns `T`: the new node. Cite: `com/oracle/truffle/api/nodes/Node.html#replace(T)` ### isSafelyReplaceableBy(Node) `public final boolean isSafelyReplaceableBy(Node newNode)`. Since 0.8 or earlier. Checks if this node can be replaced by another node: tree structure & type. Cite: `com/oracle/truffle/api/nodes/Node.html#isSafelyReplaceableBy(com.oracle.truffle.api.nodes.Node)` ### reportReplace(Node, Node, CharSequence) `protected final void reportReplace(Node oldNode, Node newNode, CharSequence reason)`. Since 24.2. Reports that `oldNode` was replaced with `newNode`, notifying any `replace observers` and invalidating any compiled call targets. This method does not actually replace the nodes. Use `Node.replace(Node, CharSequence)` to replace nodes. Cite: `com/oracle/truffle/api/nodes/Node.html#reportReplace(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence)` ### onReplace(Node, CharSequence) `protected void onReplace(Node newNode, CharSequence reason)`. Since 0.8 or earlier. Intended to be implemented by subclasses of `Node` to receive a notification when the node is rewritten. This method is invoked before the actual replace has happened. Parameters: `newNode` `Node`: the replacement node. `reason` `CharSequence`: the reason the replace supplied. Cite: `com/oracle/truffle/api/nodes/Node.html#onReplace(com.oracle.truffle.api.nodes.Node,java.lang.CharSequence)` ### accept(NodeVisitor) `public final void accept(NodeVisitor nodeVisitor)`. Since 0.8 or earlier. Invokes the `NodeVisitor.visit(Node)` method for this node and recursively also for all child nodes. Parameters: `nodeVisitor` `NodeVisitor`: the visitor. Cite: `com/oracle/truffle/api/nodes/Node.html#accept(com.oracle.truffle.api.nodes.NodeVisitor)` ### getChildren() `public final Iterable getChildren()`. Since 0.8 or earlier. Iterator over the children of this node. Returns `Iterable`: the iterator. Cite: `com/oracle/truffle/api/nodes/Node.html#getChildren()` ### copy() `public Node copy()`. Since 0.8 or earlier. Creates a shallow copy of this node. Returns `Node`: the new copy. Cite: `com/oracle/truffle/api/nodes/Node.html#copy()` ### deepCopy() `public Node deepCopy()`. Since 0.8 or earlier. Creates a deep copy of this node. Returns `Node`: the new deep copy. Cite: `com/oracle/truffle/api/nodes/Node.html#deepCopy()` ### getRootNode() `public final RootNode getRootNode()`. Since 0.8 or earlier. Get the root node of the tree a node belongs to. Returns `RootNode`: the `RootNode` or `null` if there is none. Cite: `com/oracle/truffle/api/nodes/Node.html#getRootNode()` ### reportPolymorphicSpecialize() `public final void reportPolymorphicSpecialize()`. Since 0.33. Notifies the runtime that this node specialized to a polymorphic state. This includes specializations that increase "level" of polymorphism (e.g. Adding another element to an existing inline cache). The runtime can use this information to, if `allowed`, create a deep copy of the `RootNode` hosting this node and gather context sensitive profiling feedback. Cite: `com/oracle/truffle/api/nodes/Node.html#reportPolymorphicSpecialize()` ### toString() `public String toString()`. Since 0.8 or earlier. Converts this node to a textual representation useful for debugging. Overrides `toString()`. Cite: `com/oracle/truffle/api/nodes/Node.html#toString()` ### atomic(Runnable) `public final void atomic(Runnable closure)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/Node.html#atomic(java.lang.Runnable)` ### atomic(Callable) `public final T atomic(Callable closure)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/Node.html#atomic(java.util.concurrent.Callable)` ### getLock() `protected final Lock getLock()`. Since 0.19. Returns a lock object that can be used to synchronize modifications to the AST. Don't lock if you call into foreign code with potential recursions to avoid deadlocks. Use responsibly. Cite: `com/oracle/truffle/api/nodes/Node.html#getLock()` ### getDescription() `public String getDescription()`. Since 0.8 or earlier. Returns a user-readable description of the purpose of the Node, or "" if no description is available. Can be called on any thread and without a language context. Cite: `com/oracle/truffle/api/nodes/Node.html#getDescription()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # @ Node.Child [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 0.8 or earlier. Nested in [`Node`](com/oracle/truffle/api/nodes/Node.md). ```java @Retention(RUNTIME) @Target({FIELD}) public @interface Node.Child ``` Marks fields that represent child nodes of this node. This annotation implies the semantics of [`CompilationFinal`](com/oracle/truffle/api/CompilerDirectives.CompilationFinal.md). # @ Node.Children [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 0.8 or earlier. Nested in [`Node`](com/oracle/truffle/api/nodes/Node.md). ```java @Retention(RUNTIME) @Target({FIELD}) public @interface Node.Children ``` Marks array fields that are children of this node. This annotation implies the semantics of @[`CompilationFinal`](com/oracle/truffle/api/CompilerDirectives.CompilationFinal.md)(dimensions = 1). # ◆ NodeClass [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 0.8 or earlier. ```java public abstract class NodeClass ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `NodeClass` Information about a [`Node`](com/oracle/truffle/api/nodes/Node.md) class. A single instance of this class is allocated for every subclass of [`Node`](com/oracle/truffle/api/nodes/Node.md) that is used. ## Constructors ### NodeClass(Class) `public NodeClass(Class clazz)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/NodeClass.html#(java.lang.Class)` ## Methods ### get(Class) `public static NodeClass get(Class clazz)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/NodeClass.html#get(java.lang.Class)` ### get(Node) `public static NodeClass get(Node node)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/NodeClass.html#get(com.oracle.truffle.api.nodes.Node)` ### makeIterator(Node) `public Iterator makeIterator(Node node)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/NodeClass.html#makeIterator(com.oracle.truffle.api.nodes.Node)` ### isReplaceAllowed() `protected abstract boolean isReplaceAllowed()`. Since 22.2. Returns `true` if `DenyReplace` was not set for this node. Cite: `com/oracle/truffle/api/nodes/NodeClass.html#isReplaceAllowed()` ### getType() `public abstract Class getType()`. Since 0.8 or earlier. The [`Class`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Class.html) this `NodeClass` has been `created for`. Returns `Class`: the clazz of node this `NodeClass` describes. Cite: `com/oracle/truffle/api/nodes/NodeClass.html#getType()` ### getNodeFieldArray() `protected abstract Object[] getNodeFieldArray()`. Since 20.2. Cite: `com/oracle/truffle/api/nodes/NodeClass.html#getNodeFieldArray()` ### putFieldObject(Object, Node, Object) `protected abstract void putFieldObject(Object field, Node receiver, Object value)`. Since 0.14. Cite: `com/oracle/truffle/api/nodes/NodeClass.html#putFieldObject(java.lang.Object,com.oracle.truffle.api.nodes.Node,java.lang.Object)` ### getFieldObject(Object, Node) `protected abstract Object getFieldObject(Object field, Node receiver)`. Since 0.14. Cite: `com/oracle/truffle/api/nodes/NodeClass.html#getFieldObject(java.lang.Object,com.oracle.truffle.api.nodes.Node)` ### getFieldValue(Object, Node) `protected abstract Object getFieldValue(Object field, Node receiver)`. Since 0.14. Cite: `com/oracle/truffle/api/nodes/NodeClass.html#getFieldValue(java.lang.Object,com.oracle.truffle.api.nodes.Node)` ### getFieldType(Object) `protected abstract Class getFieldType(Object field)`. Since 0.14. Cite: `com/oracle/truffle/api/nodes/NodeClass.html#getFieldType(java.lang.Object)` ### getFieldName(Object) `protected abstract String getFieldName(Object field)`. Since 0.14. Cite: `com/oracle/truffle/api/nodes/NodeClass.html#getFieldName(java.lang.Object)` ### isChildField(Object) `protected abstract boolean isChildField(Object field)`. Since 0.14. Cite: `com/oracle/truffle/api/nodes/NodeClass.html#isChildField(java.lang.Object)` ### isChildrenField(Object) `protected abstract boolean isChildrenField(Object field)`. Since 0.14. Cite: `com/oracle/truffle/api/nodes/NodeClass.html#isChildrenField(java.lang.Object)` ### isCloneableField(Object) `protected abstract boolean isCloneableField(Object field)`. Since 0.14. Cite: `com/oracle/truffle/api/nodes/NodeClass.html#isCloneableField(java.lang.Object)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ NodeCloneable [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 0.8 or earlier. ```java public abstract class NodeCloneable implements Cloneable ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `NodeCloneable` Implements: [`Cloneable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Cloneable.html) Declarative base class for node fields that are to be cloned together with the containing node. ## Constructors ### NodeCloneable() `protected NodeCloneable()`. Since 0.8 or earlier. Constructor for subclasses. Cite: `com/oracle/truffle/api/nodes/NodeCloneable.html#()` ## Methods ### clone() `protected Object clone()`. Since 0.8 or earlier. Overrides `clone()`. Cite: `com/oracle/truffle/api/nodes/NodeCloneable.html#clone()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ≡ NodeCost [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Enum class in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 0.8 or earlier. ```java @Deprecated public enum NodeCost ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html) > `NodeCost` > **⊘ Deprecated.** > > in 24.1 without replacement Represents a rough estimate for the cost of a [`Node`](com/oracle/truffle/api/nodes/Node.md). This estimate can be used by runtime systems or guest languages to implement heuristics based on Truffle ASTs. **See also** - [`Node.getCost()`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29) ## Enum constants ### NONE `NONE`. Since 0.8 or earlier. This node has literally no costs and should be ignored for heuristics. This is particularly useful for wrapper and profiling nodes which should not influence the heuristics. Cite: `com/oracle/truffle/api/nodes/NodeCost.html#NONE` ### UNINITIALIZED `UNINITIALIZED`. Since 0.8 or earlier. This node has a `CompilerDirectives.transferToInterpreter()` or `CompilerDirectives.transferToInterpreterAndInvalidate()` as its first unconditional statement. Cite: `com/oracle/truffle/api/nodes/NodeCost.html#UNINITIALIZED` ### MONOMORPHIC `MONOMORPHIC`. Since 0.8 or earlier. This node represents a specialized monomorphic version of an operation. Cite: `com/oracle/truffle/api/nodes/NodeCost.html#MONOMORPHIC` ### POLYMORPHIC `POLYMORPHIC`. Since 0.8 or earlier. This node represents a polymorphic version of an operation. For multiple chained polymorphic nodes the first may return `MONOMORPHIC` and all additional nodes should return `POLYMORPHIC`. Cite: `com/oracle/truffle/api/nodes/NodeCost.html#POLYMORPHIC` ### MEGAMORPHIC `MEGAMORPHIC`. Since 0.8 or earlier. This node represents a megamorphic version of an operation. This value should only be used if the operation implementation supports monomorphism and polymorphism otherwise `MONOMORPHIC` should be used instead. Cite: `com/oracle/truffle/api/nodes/NodeCost.html#MEGAMORPHIC` ## Methods ### values() `public static NodeCost[] values()`. Returns the enum constants in declaration order. Returns `NodeCost[]`: Returns the enum constants in declaration order. Cite: `com/oracle/truffle/api/nodes/NodeCost.html#values()` ### valueOf(String) `public static NodeCost valueOf(String name)`. Returns the enum constant with the given name. Parameters: `name` `String`: The exact name of the enum constant. Returns `NodeCost`: Returns the enum constant with the given name. Cite: `com/oracle/truffle/api/nodes/NodeCost.html#valueOf(java.lang.String)` ### isTrivial() `public boolean isTrivial()`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/NodeCost.html#isTrivial()` ### fromCount(int) `public static NodeCost fromCount(int nodeCount)`. Since 19.0. Finds the node cost for an associated node count. Returns `NodeCost.UNINITIALIZED` for 0, `NodeCost.MONOMORPHIC` for 1 and `NodeCost.POLYMORPHIC` for any other value. Cite: `com/oracle/truffle/api/nodes/NodeCost.html#fromCount(int)` ## Inherited members - From class [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#clone%28%29), [`compareTo`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#compareTo%28E%29), [`describeConstable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#describeConstable%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#finalize%28%29), [`getDeclaringClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#getDeclaringClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#hashCode%28%29), [`name`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#name%28%29), [`ordinal`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#ordinal%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#toString%28%29), [`valueOf`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#valueOf%28java.lang.Class,java.lang.String%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # @ NodeInfo [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 0.8 or earlier. ```java @Retention(RUNTIME) @Target({TYPE}) @Inherited public @interface NodeInfo ``` Annotation for providing additional information on nodes. ## Elements ### shortName() `String shortName() default ""`. Since 0.8 or earlier. Short name representing the node that can be used for debugging. Returns `String`: the short name. Default: `""`. Cite: `com/oracle/truffle/api/nodes/NodeInfo.html#shortName()` ### cost() `@Deprecated NodeCost cost() default MONOMORPHIC`. Since 0.8 or earlier. Deprecated. in 24.1 without replacement. Provides a rough estimate for the cost of the annotated `Node`. This estimate can be used by runtime systems or guest languages to implement heuristics based on Truffle ASTs. Default: `MONOMORPHIC`. See also: `Node.getCost()`, `NodeCost`. Cite: `com/oracle/truffle/api/nodes/NodeInfo.html#cost()` ### description() `String description() default ""`. Since 0.8 or earlier. A human readable explanation of the purpose of the annotated `Node`. Can be used e.g. for debugging or visualization purposes. Returns `String`: the description. Default: `""`. Cite: `com/oracle/truffle/api/nodes/NodeInfo.html#description()` ### language() `String language() default ""`. Since 0.8 or earlier. A description, providing a user-readable explanation of the source language of the annotated `Node`. Can be used e.g. for debugging or visualization purposes. Typically this information is set only in an abstract base node for the language implementation. Returns `String`: the description. Default: `""`. Cite: `com/oracle/truffle/api/nodes/NodeInfo.html#language()` # ◇ NodeInterface [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 0.8 or earlier. ```java public interface NodeInterface ``` Common base interface for all Truffle nodes. **See also** - [`Node`](com/oracle/truffle/api/nodes/Node.md) # ◆ NodeUtil [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 0.8 or earlier. ```java public final class NodeUtil ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `NodeUtil` Utility class that manages the special access methods for node instances. ## Nested types - [`NodeUtil.NodeCountFilter`](com/oracle/truffle/api/nodes/NodeUtil.NodeCountFilter.md) (interface): No description. ## Methods ### cloneNode(T) `public static T cloneNode(T orig)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#cloneNode(T)` ### assertAdopted(Node) `public static boolean assertAdopted(Node node)`. Since 23.1. Asserts that a node is adopted by a `RootNode` and prints a formatted error message with the error path if it is not adopted. Provided node must be not `null`. Throws an [`AssertionError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AssertionError.html) if it fails and always returns `true` otherwise for convenient usage with the `assert` statement. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#assertAdopted(com.oracle.truffle.api.nodes.Node)` ### findNodeChildren(Node) `public static List findNodeChildren(Node node)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#findNodeChildren(com.oracle.truffle.api.nodes.Node)` ### nonAtomicReplace(Node, T, CharSequence) `public static T nonAtomicReplace(Node oldNode, T newNode, CharSequence reason)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#nonAtomicReplace(com.oracle.truffle.api.nodes.Node,T,java.lang.CharSequence)` ### replaceChild(Node, Node, Node) `public static boolean replaceChild(Node parent, Node oldChild, Node newChild)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#replaceChild(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node)` ### findChildFieldName(Node, Node) `public static String findChildFieldName(Node parent, Node child)`. Since 22.2. Finds the field in a parent node and returns its name. Utility for debugging and tracing purposes. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#findChildFieldName(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node)` ### collectFieldNames(Class) `public static List collectFieldNames(Class clazz)`. Since 22.2. Finds and retrieves all field names of a node class. This is a utility intended for debugging and tracing purposes. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#collectFieldNames(java.lang.Class)` ### collectNodeChildren(Node) `public static Map collectNodeChildren(Node node)`. Since 22.2. Finds and retrieves all `Child` and `Children` annotated field names and values. This is a utility intended for debugging and tracing purposes. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#collectNodeChildren(com.oracle.truffle.api.nodes.Node)` ### collectNodeProperties(Node) `public static Map collectNodeProperties(Node node)`. Since 22.2. Finds and retrieves all properties of a node. Properties of a node are all fields not annotated with `Child` or `Children`. This is a utility intended for debugging and tracing purposes. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#collectNodeProperties(com.oracle.truffle.api.nodes.Node)` ### isReplacementSafe(Node, Node, Node) `public static boolean isReplacementSafe(Node parent, Node oldChild, Node newChild)`. Since 0.8 or earlier. Determines whether a proposed child replacement would be safe: structurally and type. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#isReplacementSafe(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node)` ### forEachChild(Node, NodeVisitor) `public static boolean forEachChild(Node parent, NodeVisitor visitor)`. Since 0.8 or earlier. Executes a closure for every non-null child of the parent node. Returns `boolean`: `true` if all children were visited, `false` otherwise. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#forEachChild(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.NodeVisitor)` ### concat(T[], T[]) `public static T[] concat(T[] first, T[] second)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#concat(T[],T[])` ### getNthParent(Node, int) `public static Node getNthParent(Node node, int n)`. Since 0.8 or earlier. Get the nth parent of a node, where the 0th parent is the node itself. Returns null if there are less than n ancestors. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#getNthParent(com.oracle.truffle.api.nodes.Node,int)` ### findAnnotation(Class, Class) `public static T findAnnotation(Class clazz, Class annotationClass)`. Since 0.8 or earlier. Find annotation in class/interface hierarchy. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#findAnnotation(java.lang.Class,java.lang.Class)` ### findParent(Node, Class) `public static T findParent(Node start, Class clazz)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#findParent(com.oracle.truffle.api.nodes.Node,java.lang.Class)` ### findAllParents(Node, Class) `public static List findAllParents(Node start, Class clazz)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#findAllParents(com.oracle.truffle.api.nodes.Node,java.lang.Class)` ### collectNodes(Node, Node) `public static List collectNodes(Node parent, Node child)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#collectNodes(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node)` ### findFirstNodeInstance(Node, Class) `public static T findFirstNodeInstance(Node root, Class clazz)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#findFirstNodeInstance(com.oracle.truffle.api.nodes.Node,java.lang.Class)` ### findAllNodeInstances(Node, Class) `public static List findAllNodeInstances(Node root, Class clazz)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#findAllNodeInstances(com.oracle.truffle.api.nodes.Node,java.lang.Class)` ### countNodes(Node) `public static int countNodes(Node root)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#countNodes(com.oracle.truffle.api.nodes.Node)` ### countNodes(Node, NodeUtil.NodeCountFilter) `public static int countNodes(Node root, NodeUtil.NodeCountFilter filter)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#countNodes(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.NodeUtil.NodeCountFilter)` ### printCompactTreeToString(Node) `public static String printCompactTreeToString(Node node)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#printCompactTreeToString(com.oracle.truffle.api.nodes.Node)` ### printCompactTree(OutputStream, Node) `public static void printCompactTree(OutputStream out, Node node)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#printCompactTree(java.io.OutputStream,com.oracle.truffle.api.nodes.Node)` ### printSourceAttributionTree(Node) `public static String printSourceAttributionTree(Node node)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#printSourceAttributionTree(com.oracle.truffle.api.nodes.Node)` ### printSourceAttributionTree(OutputStream, Node) `public static void printSourceAttributionTree(OutputStream out, Node node)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#printSourceAttributionTree(java.io.OutputStream,com.oracle.truffle.api.nodes.Node)` ### printSourceAttributionTree(PrintWriter, Node) `public static void printSourceAttributionTree(PrintWriter out, Node node)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#printSourceAttributionTree(java.io.PrintWriter,com.oracle.truffle.api.nodes.Node)` ### printSyntaxTags(Object) `public static String printSyntaxTags(Object node)`. Since 0.8 or earlier. Originally returned the *tags* if any, associated with a node; now unsupported. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#printSyntaxTags(java.lang.Object)` ### printTree(OutputStream, Node) `public static void printTree(OutputStream out, Node node)`. Since 0.8 or earlier. Prints a human readable form of a `Node` AST to the given [`PrintStream`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/PrintStream.html). This print method does not check for cycles in the node structure. Parameters: `out` `OutputStream`: the stream to print to. `node` `Node`: the root node to write. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#printTree(java.io.OutputStream,com.oracle.truffle.api.nodes.Node)` ### printTree(PrintWriter, Node) `public static void printTree(PrintWriter p, Node node)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#printTree(java.io.PrintWriter,com.oracle.truffle.api.nodes.Node)` ### printTreeToString(Node) `public static String printTreeToString(Node node)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#printTreeToString(com.oracle.truffle.api.nodes.Node)` ### verify(Node) `public static boolean verify(Node root)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#verify(com.oracle.truffle.api.nodes.Node)` ### assertRecursion(Node, int) `public static boolean assertRecursion(Node node, int maxRecursion)`. Since 21.2. Fails with an assertion if the exact [`node type`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29) is used as a parent. Returns `true` if the node is `null`. Cite: `com/oracle/truffle/api/nodes/NodeUtil.html#assertRecursion(com.oracle.truffle.api.nodes.Node,int)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ NodeUtil.NodeCountFilter [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 0.8 or earlier. Nested in [`NodeUtil`](com/oracle/truffle/api/nodes/NodeUtil.md). ```java public interface NodeUtil.NodeCountFilter ``` ## Fields ### NO_FILTER `NodeUtil.NodeCountFilter NO_FILTER`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/NodeUtil.NodeCountFilter.html#NO_FILTER` ## Methods ### isCounted(Node) `boolean isCounted(Node node)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/NodeUtil.NodeCountFilter.html#isCounted(com.oracle.truffle.api.nodes.Node)` # ◇ NodeVisitor [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 0.8 or earlier. ```java public interface NodeVisitor ``` Visitor for trees of nodes. ## Methods ### visit(Node) `boolean visit(Node node)`. Since 0.8 or earlier. This visitor method is called for every node in the tree. Its return value determines if the visitation continues i.e. As long as the return value is `true` the visitation continues. Parameters: `node` `Node`: the node that is currently visited. Returns `boolean`: `true` if the visitation should continue, `false` otherwise. Cite: `com/oracle/truffle/api/nodes/NodeVisitor.html#visit(com.oracle.truffle.api.nodes.Node)` # ◇ RepeatingNode [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 0.8 or earlier. ```java public interface RepeatingNode extends NodeInterface ``` Extends: [`NodeInterface`](com/oracle/truffle/api/nodes/NodeInterface.md) A node that is repeatedly invoked as part of a Truffle loop control structure. Repeating nodes must extend [`Node`](com/oracle/truffle/api/nodes/Node.md) or a subclass of [`Node`](com/oracle/truffle/api/nodes/Node.md). Repeating nodes are intended to be implemented by guest language implementations. For a full usage example please see [`LoopNode`](com/oracle/truffle/api/nodes/LoopNode.md). Note: The result of [`shouldContinue`](com/oracle/truffle/api/nodes/RepeatingNode.md#shouldContinue%28java.lang.Object%29)`( `[`executeRepeatingWithValue`](com/oracle/truffle/api/nodes/RepeatingNode.md#executeRepeatingWithValue%28com.oracle.truffle.api.frame.VirtualFrame%29)`())` is automatically profiled by the loop node, so the [`repeating node`](com/oracle/truffle/api/nodes/RepeatingNode.md) should not use a loop condition profile. **See also** - [`LoopNode`](com/oracle/truffle/api/nodes/LoopNode.md) - [`TruffleRuntime.createLoopNode(RepeatingNode)`](com/oracle/truffle/api/TruffleRuntime.md#createLoopNode%28com.oracle.truffle.api.nodes.RepeatingNode%29) ## Fields ### CONTINUE_LOOP_STATUS `Object CONTINUE_LOOP_STATUS`. Since 19.3. A value indicating that the loop should be repeated. Cite: `com/oracle/truffle/api/nodes/RepeatingNode.html#CONTINUE_LOOP_STATUS` ### BREAK_LOOP_STATUS `Object BREAK_LOOP_STATUS`. Since 19.3. A value indicating that the loop should not be repeated. Any other value different than `CONTINUE_LOOP_STATUS` can also be used to indicate that the loop should not be repeated. Cite: `com/oracle/truffle/api/nodes/RepeatingNode.html#BREAK_LOOP_STATUS` ## Methods ### executeRepeating(VirtualFrame) `boolean executeRepeating(VirtualFrame frame)`. Since 0.8 or earlier. Repeatedly invoked by a `loop node` implementation until the method returns `false` or throws an exception. Parameters: `frame` `VirtualFrame`: the current execution frame passed through the interpreter. Returns `boolean`: `true` if the method should be executed again to complete the loop and `false` if it must not. Cite: `com/oracle/truffle/api/nodes/RepeatingNode.html#executeRepeating(com.oracle.truffle.api.frame.VirtualFrame)` ### executeRepeatingWithValue(VirtualFrame) `default Object executeRepeatingWithValue(VirtualFrame frame)`. Since 19.3. Repeatedly invoked by a `loop node` implementation, but allows returning a language-specific loop exit status. Only languages that need to return custom loop statuses should override this method. Parameters: `frame` `VirtualFrame`: the current execution frame passed through the interpreter. Returns `Object`: a value `v` satisfying `shouldContinue(v)`` == true` if the method should be executed again to complete the loop and any other value if it must not. Cite: `com/oracle/truffle/api/nodes/RepeatingNode.html#executeRepeatingWithValue(com.oracle.truffle.api.frame.VirtualFrame)` ### initialLoopStatus() `default Object initialLoopStatus()`. Since 20.3. Returns a placeholder loop status used internally before the first iteration. Returns `Object`: a value satisfying `shouldContinue``(``initialLoopStatus``(v)) == true`. Cite: `com/oracle/truffle/api/nodes/RepeatingNode.html#initialLoopStatus()` ### shouldContinue(Object) `default boolean shouldContinue(Object returnValue)`. Since 20.3. Predicate called on values returned by `executeRepeatingWithValue()`. Parameters: `returnValue` `Object`: a value returned by `executeRepeatingWithValue()`. Returns `boolean`: true if the loop should continue executing or false otherwise. Cite: `com/oracle/truffle/api/nodes/RepeatingNode.html#shouldContinue(java.lang.Object)` # ◆ RootNode [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 0.8 or earlier. ```java public abstract class RootNode extends ExecutableNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > [`ExecutableNode`](com/oracle/truffle/api/nodes/ExecutableNode.md) > `RootNode` Represents the root node in a Truffle AST. The root node is a [`node`](com/oracle/truffle/api/nodes/Node.md) that allows to be [`executed`](com/oracle/truffle/api/nodes/RootNode.md#execute%28com.oracle.truffle.api.frame.VirtualFrame%29) using a [`frame`](com/oracle/truffle/api/frame/VirtualFrame.md) instance created by the framework. Please note that the [`RootNode`](com/oracle/truffle/api/nodes/RootNode.md) should not be executed directly but using [`CallTarget.call(Object...)`](com/oracle/truffle/api/CallTarget.md#call%28java.lang.Object...%29). The structure of the frame is provided by the [`frame descriptor`](com/oracle/truffle/api/frame/FrameDescriptor.md) passed in the constructor. A root node has always a `null` [`parent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29) and cannot be [`replaced`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29). #### Construction The root node can be constructed with a [`language implementation`](com/oracle/truffle/api/TruffleLanguage.md) if it is available. The language implementation instance is obtainable while [`TruffleLanguage.createContext(Env)`](com/oracle/truffle/api/TruffleLanguage.md#createContext%28com.oracle.truffle.api.TruffleLanguage.Env%29) or [`TruffleLanguage.parse(ParsingRequest)`](com/oracle/truffle/api/TruffleLanguage.md#parse%28com.oracle.truffle.api.TruffleLanguage.ParsingRequest%29) is executed. If no language environment is available, then `null` can be passed. Please note that root nodes with `null` language are considered not instrumentable and don't have access to its public [`language information`](com/oracle/truffle/api/nodes/ExecutableNode.md#getLanguageInfo%28%29). #### Execution In order to execute a root node, its call target is lazily created and can be accessed via [`RootNode.getCallTarget()`](com/oracle/truffle/api/nodes/RootNode.md#getCallTarget%28%29). This allows the runtime system to optimize the execution of the AST. The [`CallTarget`](com/oracle/truffle/api/CallTarget.md) can either be [`called`](com/oracle/truffle/api/CallTarget.md#call%28java.lang.Object...%29) directly from runtime code or [`direct`](com/oracle/truffle/api/nodes/DirectCallNode.md) and [`indirect`](com/oracle/truffle/api/nodes/IndirectCallNode.md) call nodes can be created, inserted in a child field and [`called`](com/oracle/truffle/api/nodes/DirectCallNode.md#call%28java.lang.Object...%29). The use of direct call nodes allows the framework to automatically inline and further optimize call sites based on heuristics. After several calls to a call target or call node, the root node might get compiled using partial evaluation. The details of the compilation heuristic are unspecified, therefore the Truffle runtime system might decide to not compile at all. #### Cardinalities *One* root node instance refers to other classes using the following cardinalities: - *one* [`language`](com/oracle/truffle/api/TruffleLanguage.md) - *one* [`call target`](com/oracle/truffle/api/CallTarget.md) - *many* [`created`](com/oracle/truffle/api/TruffleLanguage.md#createContext%28com.oracle.truffle.api.TruffleLanguage.Env%29) language contexts #### Instrumentation A root node can be [instrumented](com/oracle/truffle/api/instrumentation/index.md) if the following conditions apply: - A non-null [`language`](com/oracle/truffle/api/TruffleLanguage.md) is passed in the root node constructor. - [`isInstrumentable()`](com/oracle/truffle/api/nodes/RootNode.md#isInstrumentable%28%29) is overridden and returns `true`. - [`getSourceSection()`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29) is overridden and returns a non-null value. - The AST contains at least one node that implements [`com.oracle.truffle.api.instrumentation.InstrumentableNode`](com/oracle/truffle/api/instrumentation/InstrumentableNode.md). - It is recommended that children of instrumentable root nodes are tagged with `StandardTags`. **Note:** It is recommended to override [`getSourceSection()`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29) and provide a source section if available. This allows for better testing/tracing/tooling. If no concrete source section is available please consider using [`Source.createUnavailableSection()`](com/oracle/truffle/api/source/Source.md#createUnavailableSection%28%29). ## Constructors ### RootNode(TruffleLanguage) `protected RootNode(TruffleLanguage language)`. Since 0.25. Creates new root node with a given language instance. The language instance is obtainable while `TruffleLanguage.createContext(Env)` or `TruffleLanguage.parse(ParsingRequest)` is executed. If no language environment is available, then `null` can be passed. Please note that root nodes with `null` language are considered not instrumentable and don't have access to its public `language information`. Parameters: `language` `TruffleLanguage`: the language this root node is associated with. Cite: `com/oracle/truffle/api/nodes/RootNode.html#(com.oracle.truffle.api.TruffleLanguage)` ### RootNode(TruffleLanguage, FrameDescriptor) `protected RootNode(TruffleLanguage language, FrameDescriptor frameDescriptor)`. Since 0.25. Creates new root node given an language environment and frame descriptor. The language instance is obtainable while `TruffleLanguage.createContext(Env)` or `TruffleLanguage.parse(ParsingRequest)` is executed. If no language environment is available, then `null` can be passed. Please note that root nodes with `null` language are considered not instrumentable and don't have access to its public `language information`. Parameters: `language` `TruffleLanguage`: the language this root node is associated with. Cite: `com/oracle/truffle/api/nodes/RootNode.html#(com.oracle.truffle.api.TruffleLanguage,com.oracle.truffle.api.frame.FrameDescriptor)` ## Methods ### copy() `public Node copy()`. Since 0.8 or earlier. Creates a shallow copy of this node. Returns `Node`: the new copy. Overrides `copy()`. Cite: `com/oracle/truffle/api/nodes/RootNode.html#copy()` ### getQualifiedName() `public String getQualifiedName()`. Since 20.0. Returns a qualified name of the AST that in the best case uniquely identifiers the method. If the qualified name is not specified by the root, then the `name` is used by default. A root node that represents a Java method could consist of the package name, the class name and the method name. E.g. `mypackage.MyClass.myMethod`. Cite: `com/oracle/truffle/api/nodes/RootNode.html#getQualifiedName()` ### getName() `public String getName()`. Since 0.15. Returns a simple name of the AST (expected to be a method or procedure name in most languages) that identifies the AST for the benefit of guest language programmers using tools; it might appear, for example in the context of a stack dump or trace and is not expected to be called often. Can be called on any thread and without a language context. The name of a root node that represents a Java method could consist of the method name. E.g. `myMethod` In some languages AST "compilation units" may have no intrinsic names. When no information is available, language implementations might simply use the first few characters of the code, followed by "`...`". Language implementations should assign a more helpful name whenever it becomes possible, for example when a functional value is assigned. This means that the name might not be stable over time. Language execution semantics should not depend on either this name or the way that it is formatted. The name should be presented in the way expected to be most useful for programmers. Returns `String`: a name that helps guest language programmers identify code corresponding to the AST, possibly `null` if the language implementation is unable to provide any useful information. Cite: `com/oracle/truffle/api/nodes/RootNode.html#getName()` ### isInternal() `public boolean isInternal()`. Since 0.27. Returns `true` if this root node should be considered internal and not be shown to a guest language programmer. This method has effect on tools and guest language stack traces. By default a `RootNode` is internal if no language was passed in the constructor or if the `root source section` is set and points to an internal source. This method is intended to be overwritten by guest languages, when the node's source is internal, the implementation should respect that. Can be called on any thread and without a language context. This method may be invoked on compiled code paths. It is recommended to implement this method such that it returns a compilation final constant. Cite: `com/oracle/truffle/api/nodes/RootNode.html#isInternal()` ### countsTowardsStackTraceLimit() `protected boolean countsTowardsStackTraceLimit()`. Since 21.2.0. Returns `true` if this root node should count towards `com.oracle.truffle.api.exception.AbstractTruffleException.getStackTraceElementLimit`. By default, returns the negation of `isInternal()`. This method may be invoked on compiled code paths. It is recommended to implement this method or #isInternal() such that it returns a partial evaluation constant. Cite: `com/oracle/truffle/api/nodes/RootNode.html#countsTowardsStackTraceLimit()` ### findBytecodeIndex(Node, Frame) `protected int findBytecodeIndex(Node node, Frame frame)`. Since 24.1. Returns the current byte code index of the root node using a given node location and a frame. Depending on the strategy (see below) either the node or the frame may be used to find the bytecode index. This method is called by Truffle to determine the bytecode index when constructing `TruffleStackTraceElement` objects. There are two common strategies to implement this method: If the bytecode index is stored in the frame, then `isCaptureFramesForTrace(boolean)` should be overridden and return `true`. Next use the frame argument and read the bytecode index from the frame. Note that the provided frame may be `null` even if `isCaptureFramesForTrace(boolean)` returns `true`.; If the bytecode index is stored in the call node, then `parent` nodes should be walked to find the node containing the bytecode index. This method should return a negative bytecode index if it is unavailable or invalid. A language implementation may assign additional semantics for individual negative byte code indices, other languages will interpret any negative index as if the index is unavailable. Parameters: `node` `Node`: the top-most node of the activation or `null`. `frame` `Frame`: the current frame of the activation or `null`. See also: `to access byte code indices`. Cite: `com/oracle/truffle/api/nodes/RootNode.html#findBytecodeIndex(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.frame.Frame)` ### isCaptureFramesForTrace(Node) `@Deprecated protected boolean isCaptureFramesForTrace(Node compiledFrame)`. Since 24.1. Deprecated. in 24.1, implement and use `isCaptureFramesForTrace(boolean)` instead. Cite: `com/oracle/truffle/api/nodes/RootNode.html#isCaptureFramesForTrace(com.oracle.truffle.api.nodes.Node)` ### isCaptureFramesForTrace(boolean) `protected boolean isCaptureFramesForTrace(boolean compiledFrame)`. Since 24.1. Returns `true` if an AbstractTruffleException leaving this node should capture `Frame` objects in its stack trace in addition to the default information. This is `false` by default to avoid the attached overhead. The captured frames are then accessible through `TruffleStackTraceElement.getFrame()`. Using the compiledFrame argument can be useful to capture the frame only for interpreted frames. This way it is possible to store the `bytecode index` in the frame only in the interpreter, but never in compiled code. This is more efficient, because capturing the frame is a fast operation in the interpreter, but a slow operation for compiled frames. Parameters: `compiledFrame` `boolean`: whether the frame would be from a compiled execution. Cite: `com/oracle/truffle/api/nodes/RootNode.html#isCaptureFramesForTrace(boolean)` ### isCaptureFramesForTrace() `@Deprecated public boolean isCaptureFramesForTrace()`. Since 0.31. Deprecated. in 24.1, implement and use `isCaptureFramesForTrace(boolean)` instead. Cite: `com/oracle/truffle/api/nodes/RootNode.html#isCaptureFramesForTrace()` ### isCloningAllowed() `public boolean isCloningAllowed()`. Since 0.8 or earlier. Returns `true` if this `RootNode` is allowed to be cloned. The runtime system might decide to create deep copies of the `RootNode` in order to gather context sensitive profiling feedback. The default implementation returns `false`. Guest language specific implementations may want to return `true` here to indicate that gathering call site specific profiling information might make sense for this `RootNode` . Returns `boolean`: `true` if cloning is allowed else `false`. Cite: `com/oracle/truffle/api/nodes/RootNode.html#isCloningAllowed()` ### isCloneUninitializedSupported() `protected boolean isCloneUninitializedSupported()`. Since 0.24. Returns `true` if `cloneUninitialized()` can be used to create uninitialized copies of an already initialized / executed root node. By default, or if this method returns `false`, an optimizing Truffle runtime might need to copy the AST before it is executed for the first time to ensure it is able to create new uninitialized copies when needed. By returning `true` and therefore supporting uninitialized copies an optimizing runtime does not need to keep a reference to an uninitialized copy on its own and might therefore be able to save memory. The returned boolean needs to be immutable for a `RootNode` instance. Returns `boolean`: `true` if calls to `uninitialized copies` are supported. See also: `cloneUninitialized()`. Cite: `com/oracle/truffle/api/nodes/RootNode.html#isCloneUninitializedSupported()` ### cloneUninitialized() `protected RootNode cloneUninitialized()`. Since 0.24. Creates an uninitialized copy of an already initialized/executed root node if it is `supported`. Throws an [`UnsupportedOperationException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/UnsupportedOperationException.html) exception by default. By default, or if `isCloneUninitializedSupported()` returns `false`, an optimizing Truffle runtime might need to copy the root node before it is executed for the first time to ensure it is able to create new uninitialized copies when needed. By supporting uninitialized copies an optimizing runtime does not need to keep a reference to an uninitialized copy on its own and might therefore be able to save memory. Two common strategies to implement `cloneUninitialized()` are: **Reparsing:** Support it by keeping a reference to the original source code including the lexical scope and create the uninitialized copy of the root node by reparsing the source.; **Resetting:** Support it by traversing the `Node` tree and derive an uninitialized copy from each initialized node. Returns `RootNode`: an uninitialized copy of this root node if supported. Throws: `UnsupportedOperationException` (unchecked): if not supported. See also: `isCloneUninitializedSupported()`. Cite: `com/oracle/truffle/api/nodes/RootNode.html#cloneUninitialized()` ### execute(VirtualFrame) `public abstract Object execute(VirtualFrame frame)`. Since 0.8 or earlier. Executes this function using the specified frame and returns the result value. Parameters: `frame` `VirtualFrame`: the frame of the currently executing guest language method. Returns `Object`: the value of the execution. Overrides `execute()`. Cite: `com/oracle/truffle/api/nodes/RootNode.html#execute(com.oracle.truffle.api.frame.VirtualFrame)` ### getCallTarget() `public final RootCallTarget getCallTarget()`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/RootNode.html#getCallTarget()` ### initializeCallTarget() `public final void initializeCallTarget()`. Since 25.6. Initializes this root node's call target without executing the root node. This method has the same initialization effects as `getCallTarget()`, including invoking `prepareForCall()` when the call target is first created. Repeated calls reuse the existing call target. Call this method after configuring the root node and before using it in the application through `call(Node, int, Object[])` or `IndirectCallNode.call(RootNode, int, Object[])`. These root-based call methods require an initialized call target and do not initialize it implicitly. Cite: `com/oracle/truffle/api/nodes/RootNode.html#initializeCallTarget()` ### getFrameDescriptor() `public final FrameDescriptor getFrameDescriptor()`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/nodes/RootNode.html#getFrameDescriptor()` ### isInstrumentable() `protected boolean isInstrumentable()`. Since 0.8 or earlier. Does this contain AST content that it is possible to instrument. Can be called on any thread and without a language context. Cite: `com/oracle/truffle/api/nodes/RootNode.html#isInstrumentable()` ### prepareForCall() `protected void prepareForCall()`. Since 25.0. Prepares this `RootNode` to be called with a `CallTarget`. This method will be called exactly once when a call target is first created by `getCallTarget()` or `initializeCallTarget()`. This method can be used to lazily initialize parts of a root node, or to validate that a root node can be used as a call target. Cite: `com/oracle/truffle/api/nodes/RootNode.html#prepareForCall()` ### prepareForCompilation(boolean, int, boolean) `protected boolean prepareForCompilation(boolean rootCompilation, int compilationTier, boolean lastTier)`. Since 24.2. Prepares this `RootNode` for compilation. This method is guaranteed to be called at least once before any code paths are executed as compiled code (see `CompilerDirectives.inCompiledCode()`) for a given compilation tier. It may be called multiple times per compilation and can be invoked concurrently by multiple compiler threads without synchronization; therefore, it must be thread-safe. By default, this method returns `true` to indicate sufficient profiling for compilation, but implementations can return `false` if not. Returning `false` for root compilations will defer the compilation to allow for additional profiling, whereas otherwise returning `false` during inlining will disable inlining for this call site. Any exception thrown will fail the compilation for this `RootNode` permanently. Compilations are initiated by the runtime for optimization through partial evaluation and compilation. The timing and threading of compilations are runtime-specific and should not be relied upon. This method is not called for Truffle runtimes that do not support compilation, such as the fallback runtime. Compilations may be initiated for the following reasons: The `CallTarget` for this `RootNode` has been invoked frequently enough to trigger compilation.; A `LoopNode` or `BytecodeOSRNode` has executed frequently enough to trigger OSR compilation.; The compiler is exploring inlining during compilation, preparing to inline a `DirectCallNode` or an indirect call with a partially evaluated constant `CallTarget`. Work performed in this method counts towards compilation time, not interpretation time. Implementing this method can help offload expensive computations to compiler threads. Cache any preparation work to avoid repeating it for every compilation and inlining. To prevent deadlocks when using synchronization, adhere to the following guidelines: Do not execute guest code or invoke `CallTarget.call(Object...)` within this method.; Avoid acquiring locks shared with execution threads, especially across call boundaries or loop back-edges when OSR compilation is enabled.; Use [`AtomicReferenceFieldUpdater`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.html) CAS-locking for caching non-expensive preparation work to minimize contention.; Ensure all synchronization primitives are released upon method exit; use finally blocks for safety. During the execution of this method, if this root node is associated with a `language`, that language is entered, but no language context is entered. In that case, `LanguageReference` can be used, but `ContextThreadLocal`, `ContextLocal`, and `ContextReference` cannot be used. Parameters: `rootCompilation` `boolean`: `true` if this is a root compilation; `false` if inlining this root. `compilationTier` `int`: the current compilation tier, as per `FrameInstance.getCompilationTier()`. `lastTier` `boolean`: `true` if this is the last compilation tier for which this `RootNode` is prepared; `false` otherwise. Useful for performing preparation only at the highest tier. Returns `boolean`: `true` if the method is sufficiently profiled; `false` otherwise. Cite: `com/oracle/truffle/api/nodes/RootNode.html#prepareForCompilation(boolean,int,boolean)` ### visitCloneableNodes(NodeVisitor) `protected void visitCloneableNodes(NodeVisitor visitor)`. Since 25.6. Visits nodes that may be cloned with this root node. The default implementation visits this root and its ordinary children. Overrides must invoke the superclass implementation before visiting additional node trees stored outside of ordinary child fields. Additional node trees must be visited at most once and must not be reachable through ordinary child fields. Parameters: `visitor` `NodeVisitor`: the visitor invoked for each node. Cite: `com/oracle/truffle/api/nodes/RootNode.html#visitCloneableNodes(com.oracle.truffle.api.nodes.NodeVisitor)` ### isTrivial() `protected boolean isTrivial()`. Since 20.3.0. Is this root node to be considered trivial by the runtime. A trivial root node is defined as a root node that: Never increases code size when inlined, i.e. is always less complex then the call.; Never performs guest language calls.; Never contains loops.; Is small (for a language-specific definition of small). An good example of trivial root nodes would be getters and setters in java. Returns `boolean`: `true `if this root node should be considered trivial by the runtime. `false` otherwise. Cite: `com/oracle/truffle/api/nodes/RootNode.html#isTrivial()` ### prepareForInstrumentation(Set) `protected void prepareForInstrumentation(Set> tags)`. Since 24.2. Prepares a root node for use with the Truffle instrumentation framework. This is similar to materialization of syntax nodes in an InstrumentableNode, but this method should be preferred if the root node is updated as a whole and the individual materialization of nodes is not needed. Another advantage of this method is that it is always invoked before `getSourceSection()` by the instrumentation framework. This allows to perform the materialization of sources and tags in one operation. This method is invoked repeatedly and should not perform any operation if a set of tags was already prepared before. In other words, this method should stabilize and eventually not perform any operation if the same tags were observed before. Cite: `com/oracle/truffle/api/nodes/RootNode.html#prepareForInstrumentation(java.util.Set)` ### findInstrumentableCallNode(Node, Frame, int) `protected Node findInstrumentableCallNode(Node callNode, Frame frame, int bytecodeIndex)`. Since 24.2. Returns an instrumentable call node from a node and frame. By default, returns the given `callNode`. If the returned node is not instrumentable, the `parent` chain of the node may be traversed until an instrumentable node is found (thus, the returned node should be adopted). This method should be implemented if the instrumentable call node is not reachable through the `parent` chain of a `call node`. For example, in bytecode interpreters instrumentable nodes may be stored in a side data structure and the instrumentable node must be looked up using the bytecode index. This method is intended to be overridden to implement specify such behavior. A `frame` parameter is only provided if `isCaptureFramesForTrace(boolean)` returns `true`. If the frame is not captured then the frame parameter is `null`. The `bytecodeIndex` parameter takes on the value produced by calling `findBytecodeIndex(Node, Frame)` (`-1` unless overridden). Parameters: `callNode` `Node`: the top-most node of the activation or `null`. `frame` `Frame`: the current frame of the activation or `null`. `bytecodeIndex` `int`: the current bytecode index of the activation or a negative number. Cite: `com/oracle/truffle/api/nodes/RootNode.html#findInstrumentableCallNode(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.frame.Frame,int)` ### findAsynchronousFrames(Frame) `protected List findAsynchronousFrames(Frame frame)`. Since 20.1.0. Provide a list of stack frames that led to a schedule of asynchronous execution of this root node on the provided frame. The asynchronous frames are expected to be found here when `TruffleLanguage.getAsynchronousStackDepth()` is positive. The language is free to provide asynchronous frames or longer list of frames when it's of no performance penalty, or if requested by other options. This method is invoked on slow-paths only and with a context entered. Parameters: `frame` `Frame`: A frame, never `null`. Returns `List`: a list of `TruffleStackTraceElement`, or `null` when no asynchronous stack is available. See also: `TruffleLanguage.getAsynchronousStackDepth()`. Cite: `com/oracle/truffle/api/nodes/RootNode.html#findAsynchronousFrames(com.oracle.truffle.api.frame.Frame)` ### translateStackTraceElement(TruffleStackTraceElement) `protected Object translateStackTraceElement(TruffleStackTraceElement element)`. Since 20.3. Translates the `TruffleStackTraceElement` into an interop object supporting the `hasExecutableName` and potentially `hasDeclaringMetaObject` and `hasSourceLocation` messages. An executable name must be provided, whereas the declaring meta object and source location is optional. Guest languages may typically return their function objects that typically already implement the required contracts. The intention of this method is to provide a guest language object for other languages that they can inspect using interop. An implementation of this method is expected to not fail with a guest error. Implementations are allowed to do `context reference lookups` in the implementation of the method. This may be useful to access the function objects needed to resolve the stack trace element. See also: `to access the guest object of a stack trace element.`. Cite: `com/oracle/truffle/api/nodes/RootNode.html#translateStackTraceElement(com.oracle.truffle.api.TruffleStackTraceElement)` ### prepareForAOT() `protected ExecutionSignature prepareForAOT()`. Since 20.3. Allows languages to perform actions before a root node is attempted to be compiled without prior call to `execute(VirtualFrame)`. By default this method returns `null` to indicate that AOT compilation is not supported. Any non-null value indicates that compilation without execution is supported for this root node. This method is guaranteed to not be invoked prior to any calls to `execute`. Common tasks that need to be performed by this method: Initialize local variable types in the `FrameDescriptor` of the root node. Without that any access to the frame will invalidate the code on first execute.; Initialize specializing nodes with profiles that do not invalidate on first execution. For initialization of Truffle DSL nodes see `com.oracle.truffle.api.dsl.AOTSupport`.; Compute the expected execution signature of a root node and return it. If possible an `execution signature` should be returned for better call efficiency. If the argument and return profile is not available or cannot be derived the `ExecutionSignature.GENERIC` can be used to indicate that any value needs to be expected for as argument from or as return value of the method. To indicate that a type is unknown a `null` return or argument type should be used. The type `Object` type should not be used in that case. This method is invoked when no context is currently `entered` therefore no guest application code must be executed. The execution might happen on any thread, even threads unknown to the guest language implementation. It is allowed to create new `call targets` during preparation of the root node or perform modifications to the `language` of this root node. See also: `prepareForCompilation(boolean, int, boolean)`. Cite: `com/oracle/truffle/api/nodes/RootNode.html#prepareForAOT()` ### createConstantNode(Object) `public static RootNode createConstantNode(Object constant)`. Since 0.8 or earlier. Helper method to create a root node that always returns the same value. Certain operations (especially `inter-operability` API) require return of stable `root nodes`. To simplify creation of such nodes, here is a factory method that can create `RootNode` that returns always the same value. Parameters: `constant` `Object`: the constant to return. Returns `RootNode`: root node returning the constant. Cite: `com/oracle/truffle/api/nodes/RootNode.html#createConstantNode(java.lang.Object)` ### getParentFrameDescriptor() `protected FrameDescriptor getParentFrameDescriptor()`. Since 22.3.0. If this root node has a lexical scope parent, this method returns its frame descriptor. As an example, consider the following pseudocode: This info is used by the runtime to optimize compilation order by giving more priority to lexical parents which are likely to inline the child thus resulting in better performance sooner rather than waiting for the lexical parent to get hot on its own. Returns `FrameDescriptor`: The frame descriptor of the lexical parent scope if it exists. `null` otherwise. Cite: `com/oracle/truffle/api/nodes/RootNode.html#getParentFrameDescriptor()` ```java def m { # For the "m" root node: # getFrameDescriptor returns FrameDescriptor(m) # getParentFrameDescriptor returns null var_method = 0 a = () -> { # For the "a lambda" root node: # getFrameDescriptor returns FrameDescriptor(a) # getParentFrameDescriptor returns FrameDescriptor(m) var_lambda1 = 1 b = () -> { # For the "b lambda" root node: # getFrameDescriptor returns FrameDescriptor(b) # getParentFrameDescriptor returns FrameDescriptor(a) var_method + var_lambda1 } b.call } a.call } ``` ### isSameFrame(Frame, Frame) `protected boolean isSameFrame(Frame frame1, Frame frame2)`. Since 24.0. Tests if two frames are the same. This method is mainly used by instruments in case of `yield` of the execution and later resume. Frame comparison is used to match the particular yielded and resumed execution. The default implementation compares the frames identity. Cite: `com/oracle/truffle/api/nodes/RootNode.html#isSameFrame(com.oracle.truffle.api.frame.Frame,com.oracle.truffle.api.frame.Frame)` ### computeSize() `protected int computeSize()`. Since 23.0. Computes a size estimate of this root node. This is intended to be overwritten if the size of the root node cannot be estimated from the natural AST size. For example, in case the root node is represented by a bytecode interpreter. If `-1` is returned, the regular AST size estimate is going to be used. By default this method returns `-1`. The size estimate is guaranteed to be invoked only once when the `CallTarget` is created by `getCallTarget()` or `initializeCallTarget()`. This method will never be invoked after the root node was already executed. Cite: `com/oracle/truffle/api/nodes/RootNode.html#computeSize()` ### call(Node, int, Object[]) `public final Object call(Node location, int bytecodeIndex, Object[] arguments)`. Since 25.6. Calls this root node with an explicit call location, bytecode index, and arguments. Unlike a generic `CallTarget` call, a call specialized to a concrete `RootNode` class exposes its `execute` implementation to the host compiler. This may allow the host compiler to inline further across the call boundary, including into `execute`. Callers that do not have an explicit bytecode index should pass `-1`. The call target must already be initialized using `initializeCallTarget()` or `getCallTarget()`. This method does not initialize the call target. Parameters: `location` `Node`: a `Node` that identifies the location of this call. The location may be `null` if no location is available. `bytecodeIndex` `int`: the bytecode index associated with this call, or `-1` if no explicit bytecode index is available. `arguments` `Object[]`: the arguments passed to the call, as an object array. Returns `Object`: the result of the call. Throws: `IllegalStateException` (unchecked): if the call target has not been initialized. See also: `CallTarget.call(Node, int, Object[])`. Cite: `com/oracle/truffle/api/nodes/RootNode.html#call(com.oracle.truffle.api.nodes.Node,int,java.lang.Object[])` ## Inherited members - From class [`ExecutableNode`](com/oracle/truffle/api/nodes/ExecutableNode.md): [`getLanguage`](com/oracle/truffle/api/nodes/ExecutableNode.md#getLanguage%28java.lang.Class%29), [`getLanguageInfo`](com/oracle/truffle/api/nodes/ExecutableNode.md#getLanguageInfo%28%29) - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ⚡︎ SlowPathException [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Exception in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 0.8 or earlier. ```java public class SlowPathException extends Exception ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) > [`Exception`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Exception.html) > `SlowPathException` An exception thrown to enter a slow path. The Truffle optimizer has special knowledge of this exception class and will never compile a catch block that catches this exception type. ## Constructors ### SlowPathException() `public SlowPathException()`. Since 0.8 or earlier. Creates an exception thrown to enter a slow path. Cite: `com/oracle/truffle/api/nodes/SlowPathException.html#()` ### SlowPathException(String, Throwable) `public SlowPathException(String message, Throwable cause)`. Since 0.8 or earlier. Creates an exception thrown to enter a slow path. Cite: `com/oracle/truffle/api/nodes/SlowPathException.html#(java.lang.String,java.lang.Throwable)` ### SlowPathException(String) `public SlowPathException(String message)`. Since 0.8 or earlier. Creates an exception thrown to enter a slow path. Cite: `com/oracle/truffle/api/nodes/SlowPathException.html#(java.lang.String)` ### SlowPathException(Throwable) `public SlowPathException(Throwable cause)`. Since 0.8 or earlier. Creates an exception thrown to enter a slow path. Cite: `com/oracle/truffle/api/nodes/SlowPathException.html#(java.lang.Throwable)` ## Methods ### fillInStackTrace() `@Deprecated(since = "19.0") public final Throwable fillInStackTrace()`. Since 0.8 or earlier. Deprecated since 19.0. the method will become final in future releases. For performance reasons, this exception does not record any stack trace information. Overrides `fillInStackTrace()`. Cite: `com/oracle/truffle/api/nodes/SlowPathException.html#fillInStackTrace()` ## Inherited members - From class [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html): [`addSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#addSuppressed%28java.lang.Throwable%29), [`getCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getCause%28%29), [`getLocalizedMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getLocalizedMessage%28%29), [`getMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getMessage%28%29), [`getStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getStackTrace%28%29), [`getSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getSuppressed%28%29), [`initCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#initCause%28java.lang.Throwable%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintStream%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintWriter%29), [`setStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#setStackTrace%28java.lang.StackTraceElement[]%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ UnadoptableNode [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 24.1. ```java public interface UnadoptableNode ``` Marks a node unadoptable, this means that the parent pointer will never be written by the Truffle framework. If nodes need to be statically shared then they must not be adoptable, because otherwise the parent reference might cause a memory leak. If a node is not adoptable then then it is guaranteed that the [`parent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29) pointer remains `null` at all times, even if the node is tried to be adopted by a parent. Node that unadoptable nodes should usually also be annotated with [`DenyReplace`](com/oracle/truffle/api/nodes/DenyReplace.md). **See also** - [`Node.isAdoptable()`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29) - [`DenyReplace`](com/oracle/truffle/api/nodes/DenyReplace.md) # ⚡︎ UnexpectedResultException [truffle-api](index.md) › [com.oracle.truffle.api.nodes](com/oracle/truffle/api/nodes/index.md) · Every page: [llms.txt](llms.txt) Exception in [`com.oracle.truffle.api.nodes`](com/oracle/truffle/api/nodes/index.md). Since 0.8 or earlier. ```java public final class UnexpectedResultException extends SlowPathException ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) > [`Exception`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Exception.html) > [`SlowPathException`](com/oracle/truffle/api/nodes/SlowPathException.md) > `UnexpectedResultException` An exception that should be thrown if the return value cannot be represented as a value of the return type. The Truffle optimizer has special knowledge of this exception class and will never compile a catch block that catches this exception type. ## Constructors ### UnexpectedResultException(Object) `public UnexpectedResultException(Object result)`. Since 0.8 or earlier. Creates the exception with the alternative result that cannot be represented as a value of the return type. Parameters: `result` `Object`: the alternative result. Cite: `com/oracle/truffle/api/nodes/UnexpectedResultException.html#(java.lang.Object)` ## Methods ### getResult() `public Object getResult()`. Since 0.8 or earlier. Returns `Object`: the unexpected result. Cite: `com/oracle/truffle/api/nodes/UnexpectedResultException.html#getResult()` ## Inherited members - From class [`SlowPathException`](com/oracle/truffle/api/nodes/SlowPathException.md): [`fillInStackTrace`](com/oracle/truffle/api/nodes/SlowPathException.md#fillInStackTrace%28%29) - From class [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html): [`addSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#addSuppressed%28java.lang.Throwable%29), [`getCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getCause%28%29), [`getLocalizedMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getLocalizedMessage%28%29), [`getMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getMessage%28%29), [`getStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getStackTrace%28%29), [`getSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getSuppressed%28%29), [`initCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#initCause%28java.lang.Throwable%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintStream%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintWriter%29), [`setStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#setStackTrace%28java.lang.StackTraceElement[]%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ▣ com.oracle.truffle.api.object [truffle-api](index.md) · Every page: [llms.txt](llms.txt) Package in truffle-api. Since 0.8 or older. Dynamic object storage model. ## Interfaces - [`DoubleLocation`](com/oracle/truffle/api/object/DoubleLocation.md): Double-typed storage location. - [`IntLocation`](com/oracle/truffle/api/object/IntLocation.md): Int-typed storage location. ## Classes - [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md): Represents a dynamic object, members of which can be dynamically added and removed at run time. - [`DynamicObjectFactory`](com/oracle/truffle/api/object/DynamicObjectFactory.md): No description. - [`DynamicObjectLibrary`](com/oracle/truffle/api/object/DynamicObjectLibrary.md): DynamicObject access library. - [`HiddenKey`](com/oracle/truffle/api/object/HiddenKey.md): A unique key to be used for private object fields; excluded from enumeration and compared by object identity. - [`Location`](com/oracle/truffle/api/object/Location.md): Property location. - [`Property`](com/oracle/truffle/api/object/Property.md): Property objects represent the mapping between property identifiers (keys) and storage locations. - [`PropertyGetter`](com/oracle/truffle/api/object/PropertyGetter.md): A lightweight property getter that allows getting the value of a DynamicObject property without any lookup or cache dispatch. - [`Shape`](com/oracle/truffle/api/object/Shape.md): A Shape is an immutable descriptor of the current object "shape" of a DynamicObject, i.e., object layout, metadata (type, flags), and a mapping of properties to storage locations. ## Exceptions - [`FinalLocationException`](com/oracle/truffle/api/object/FinalLocationException.md): This exception is thrown on an attempt to assign a value to a final location. - [`IncompatibleLocationException`](com/oracle/truffle/api/object/IncompatibleLocationException.md): This exception is thrown on an attempt to assign an incompatible value to a location. # ◇ DoubleLocation [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 0.8 or earlier. ```java @Deprecated(since = "22.2") public interface DoubleLocation ``` > **⊘ Deprecated since 22.2.** Double-typed storage location. **See also** - [`Location`](com/oracle/truffle/api/object/Location.md) - [`DynamicObjectLibrary.getDoubleOrDefault`](com/oracle/truffle/api/object/DynamicObjectLibrary.md#getDoubleOrDefault%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object%29) - [`DynamicObjectLibrary.putDouble`](com/oracle/truffle/api/object/DynamicObjectLibrary.md#putDouble%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object,double%29) ## Methods ### getDouble(DynamicObject, boolean) `@Deprecated(since = "22.2") double getDouble(DynamicObject store, boolean condition)`. Since 0.8 or earlier. Deprecated since 22.2. See also: `Location.get(DynamicObject, boolean)`. Cite: `com/oracle/truffle/api/object/DoubleLocation.html#getDouble(com.oracle.truffle.api.object.DynamicObject,boolean)` ### setDouble(DynamicObject, double, Shape) `@Deprecated(since = "22.2") void setDouble(DynamicObject store, double value, Shape shape) throws FinalLocationException`. Since 0.8 or earlier. Deprecated since 22.2. See also: `Location.set(DynamicObject, Object, Shape)`. Cite: `com/oracle/truffle/api/object/DoubleLocation.html#setDouble(com.oracle.truffle.api.object.DynamicObject,double,com.oracle.truffle.api.object.Shape)` # ◆ DynamicObject [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 0.8 or earlier. ```java public abstract class DynamicObject implements TruffleObject ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `DynamicObject` Implements: [`TruffleObject`](com/oracle/truffle/api/interop/TruffleObject.md) Represents a dynamic object, members of which can be dynamically added and removed at run time. To use it, extend [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md) and use nodes nested under DynamicObject such as [`DynamicObject.GetNode`](com/oracle/truffle/api/object/DynamicObject.GetNode.md) for object accesses. When [constructing](com/oracle/truffle/api/object/DynamicObject.md#%3Cinit%3E%28com.oracle.truffle.api.object.Shape%29) a [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md), it has to be initialized with an empty initial shape. Initial shapes are created using [`Shape.newBuilder()`](com/oracle/truffle/api/object/Shape.md#newBuilder%28%29) and should ideally be shared per [`TruffleLanguage`](com/oracle/truffle/api/TruffleLanguage.md) instance to allow shape caches to be shared across contexts. Subclasses can provide in-object dynamic field slots using the [`DynamicField`](com/oracle/truffle/api/object/DynamicObject.DynamicField.md) annotation and [`Shape.Builder.layout`](com/oracle/truffle/api/object/Shape.Builder.md#layout%28java.lang.Class,java.lang.invoke.MethodHandles.Lookup%29). Example: ```java public class MyObject extends DynamicObject implements TruffleObject { MyObject(Shape shape) { super(shape); } static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup(); } public abstract class MyTruffleLanguage extends TruffleLanguage { final Shape initialShape = Shape.newBuilder().build(); public MyObject newObject() { return new MyObject(initialShape); } } ``` ## Using DynamicObject nodes DynamicObject nodes is the central interface for accessing and mutating properties and other state (flags, dynamic type) of [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md)s. All nodes provide cached and uncached variants. Note: Property keys are always compared using object identity (`==`), never with ` equals`, for efficiency reasons. If the node is not used with a fixed key, and some keys might be `equals` but not have the same identity (`==`), you must either intern the keys first, or cache the key by equality using an inline cache and use the cached key with the DynamicObject node to ensure equal keys with different identity will use the same cache entry and not overflow the cache: ```java abstract static class GetStringKeyNode extends Node { abstract Object execute(DynamicObject receiver, Object key); @Specialization(guards = "equalNode.execute(key, cachedKey, UTF_16)", limit = "3") static Object doCached(MyDynamicObjectSubclass receiver, TruffleString key, @Cached("key") TruffleString cachedKey, @Cached TruffleString.EqualNode equalNode, @Cached DynamicObject.GetNode getNode) { return getNode.execute(receiver, cachedKey, NULL_VALUE); } } ``` ### Usage examples: #### Simple use of [`GetNode`](com/oracle/truffle/api/object/DynamicObject.GetNode.md) with a pre-interned symbol key. ```java abstract static class GetSimpleNode extends Node { abstract Object execute(DynamicObject receiver, Object key); @Specialization static Object doCached(MyDynamicObjectSubclass receiver, Symbol key, @Cached DynamicObject.GetNode getNode) { return getNode.execute(receiver, key, NULL_VALUE); } } ``` #### Implementing InteropLibrary messages using DynamicObject access nodes: ```java @ExportLibrary(InteropLibrary.class) static class MyDynamicObjectSubclass extends DynamicObject { MyDynamicObjectSubclass(Shape shape) { super(shape); } @ExportMessage Object readMember(String member, @Cached DynamicObject.GetNode getNode) throws UnknownIdentifierException { Object result = getNode.execute(this, member, null); if (result == null) { throw UnknownIdentifierException.create(member); } return result; } ``` Member name equality check omitted for brevity. #### Adding extra dynamic fields to a DynamicObject subclass: ```java public class MyObjectWithFields extends DynamicObject implements TruffleObject { @DynamicField private Object extra1; @DynamicField private Object extra2; @DynamicField private long extraLong1; @DynamicField private long extraLong2; MyObjectWithFields(Shape shape) { super(shape); } static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup(); } Shape initialShape = Shape.newBuilder().layout(MyObject.class, MyObject.LOOKUP).build(); MyObject obj = new MyObject(initialShape); ``` **See also** - [`DynamicObject.DynamicObject(Shape)`](com/oracle/truffle/api/object/DynamicObject.md#%3Cinit%3E%28com.oracle.truffle.api.object.Shape%29) - [`Shape`](com/oracle/truffle/api/object/Shape.md) - [`Shape.newBuilder()`](com/oracle/truffle/api/object/Shape.md#newBuilder%28%29) - [`DynamicObject.GetNode`](com/oracle/truffle/api/object/DynamicObject.GetNode.md) - [`DynamicObject.ContainsKeyNode`](com/oracle/truffle/api/object/DynamicObject.ContainsKeyNode.md) - [`DynamicObject.PutNode`](com/oracle/truffle/api/object/DynamicObject.PutNode.md) - [`DynamicObject.GetPropertyNode`](com/oracle/truffle/api/object/DynamicObject.GetPropertyNode.md) - [`DynamicObject.GetPropertyFlagsNode`](com/oracle/truffle/api/object/DynamicObject.GetPropertyFlagsNode.md) - [`DynamicObject.SetPropertyFlagsNode`](com/oracle/truffle/api/object/DynamicObject.SetPropertyFlagsNode.md) - [`DynamicObject.CopyPropertiesNode`](com/oracle/truffle/api/object/DynamicObject.CopyPropertiesNode.md) - [`DynamicObject.GetKeyArrayNode`](com/oracle/truffle/api/object/DynamicObject.GetKeyArrayNode.md) - [`DynamicObject.GetPropertyArrayNode`](com/oracle/truffle/api/object/DynamicObject.GetPropertyArrayNode.md) - [`DynamicObject.RemoveKeyNode`](com/oracle/truffle/api/object/DynamicObject.RemoveKeyNode.md) - [`DynamicObject.PutConstantNode`](com/oracle/truffle/api/object/DynamicObject.PutConstantNode.md) - [`DynamicObject.GetDynamicTypeNode`](com/oracle/truffle/api/object/DynamicObject.GetDynamicTypeNode.md) - [`DynamicObject.SetDynamicTypeNode`](com/oracle/truffle/api/object/DynamicObject.SetDynamicTypeNode.md) - [`DynamicObject.GetShapeFlagsNode`](com/oracle/truffle/api/object/DynamicObject.GetShapeFlagsNode.md) - [`DynamicObject.SetShapeFlagsNode`](com/oracle/truffle/api/object/DynamicObject.SetShapeFlagsNode.md) - [`DynamicObject.UpdateShapeNode`](com/oracle/truffle/api/object/DynamicObject.UpdateShapeNode.md) - [`DynamicObject.ResetShapeNode`](com/oracle/truffle/api/object/DynamicObject.ResetShapeNode.md) - [`DynamicObject.IsSharedNode`](com/oracle/truffle/api/object/DynamicObject.IsSharedNode.md) - [`DynamicObject.MarkSharedNode`](com/oracle/truffle/api/object/DynamicObject.MarkSharedNode.md) ## Nested types - [`DynamicObject.ContainsKeyNode`](com/oracle/truffle/api/object/DynamicObject.ContainsKeyNode.md) (abstract class): Checks if this object contains a property with the given key. - [`DynamicObject.CopyPropertiesNode`](com/oracle/truffle/api/object/DynamicObject.CopyPropertiesNode.md) (abstract class): Copies all properties of a DynamicObject to another, preserving property flags. - [`DynamicObject.DynamicField`](com/oracle/truffle/api/object/DynamicObject.DynamicField.md) (annotation interface): Using this annotation, subclasses can define additional dynamic fields to be used by the object layout. - [`DynamicObject.GetDynamicTypeNode`](com/oracle/truffle/api/object/DynamicObject.GetDynamicTypeNode.md) (abstract class): Gets the language-specific dynamic type identifier currently associated with this object. - [`DynamicObject.GetKeyArrayNode`](com/oracle/truffle/api/object/DynamicObject.GetKeyArrayNode.md) (abstract class): Gets a snapshot of the object's property keys, in insertion order. - [`DynamicObject.GetNode`](com/oracle/truffle/api/object/DynamicObject.GetNode.md) (abstract class): Gets the value of a property or returns a default value if no such property exists. - [`DynamicObject.GetPropertyArrayNode`](com/oracle/truffle/api/object/DynamicObject.GetPropertyArrayNode.md) (abstract class): Gets a snapshot of the object's properties, in insertion order. - [`DynamicObject.GetPropertyFlagsNode`](com/oracle/truffle/api/object/DynamicObject.GetPropertyFlagsNode.md) (abstract class): Gets the property flags associated with the requested property key. - [`DynamicObject.GetPropertyNode`](com/oracle/truffle/api/object/DynamicObject.GetPropertyNode.md) (abstract class): Gets a property descriptor for the requested property key or null if no such property exists. - [`DynamicObject.GetShapeFlagsNode`](com/oracle/truffle/api/object/DynamicObject.GetShapeFlagsNode.md) (abstract class): Gets the language-specific object shape flags. - [`DynamicObject.IsSharedNode`](com/oracle/truffle/api/object/DynamicObject.IsSharedNode.md) (abstract class): Checks whether this object is marked as shared. - [`DynamicObject.MarkSharedNode`](com/oracle/truffle/api/object/DynamicObject.MarkSharedNode.md) (abstract class): Marks this object as shared. - [`DynamicObject.PutAllNode`](com/oracle/truffle/api/object/DynamicObject.PutAllNode.md) (abstract class): Adds or sets multiple properties in bulk. - [`DynamicObject.PutConstantNode`](com/oracle/truffle/api/object/DynamicObject.PutConstantNode.md) (abstract class): Sets the value of an existing property or adds a new property if no such property exists. - [`DynamicObject.PutNode`](com/oracle/truffle/api/object/DynamicObject.PutNode.md) (abstract class): Sets the value of an existing property or adds a new property if no such property exists. - [`DynamicObject.RemoveKeyNode`](com/oracle/truffle/api/object/DynamicObject.RemoveKeyNode.md) (abstract class): Removes the property with the given key from the object. - [`DynamicObject.ResetShapeNode`](com/oracle/truffle/api/object/DynamicObject.ResetShapeNode.md) (abstract class): Empties and resets the object to the given root shape. - [`DynamicObject.SetAllPropertyFlagsNode`](com/oracle/truffle/api/object/DynamicObject.SetAllPropertyFlagsNode.md) (abstract class): Sets or updates the flags of multiple existing properties. - [`DynamicObject.SetDynamicTypeNode`](com/oracle/truffle/api/object/DynamicObject.SetDynamicTypeNode.md) (abstract class): Sets the language-specific dynamic type identifier. - [`DynamicObject.SetPropertyFlagsNode`](com/oracle/truffle/api/object/DynamicObject.SetPropertyFlagsNode.md) (abstract class): Sets or updates property flags associated with the requested property key. - [`DynamicObject.SetShapeFlagsNode`](com/oracle/truffle/api/object/DynamicObject.SetShapeFlagsNode.md) (abstract class): Sets or updates language-specific object shape flags. - [`DynamicObject.UpdateShapeNode`](com/oracle/truffle/api/object/DynamicObject.UpdateShapeNode.md) (abstract class): Ensures the object's shape is up-to-date. ## Constructors ### DynamicObject(Shape) `protected DynamicObject(Shape shape)`. Since 19.0. Constructor for `DynamicObject` subclasses. Initializes the object with the provided shape. The shape must have been constructed with a layout class assignable from this class (i.e., the concrete subclass, a superclass thereof, including `DynamicObject`) and must not have any instance properties (but may have constant properties). Examples: Parameters: `shape` `Shape`: the initial shape of this object. Throws: `IllegalArgumentException` (unchecked): if called with an illegal (incompatible) shape. Cite: `com/oracle/truffle/api/object/DynamicObject.html#(com.oracle.truffle.api.object.Shape)` ```java Shape shape = Shape.newBuilder().build(); DynamicObject myObject = new MyObject(shape); ``` ```java Shape shape = Shape.newBuilder().layout(MyObject.class, MethodHandles.lookup()).build(); DynamicObject myObject = new MyObject(shape); ``` ## Methods ### getShape() `public final Shape getShape()`. Since 0.8 or earlier. Get the object's current shape. See also: `Shape`. Cite: `com/oracle/truffle/api/object/DynamicObject.html#getShape()` ### clone() `protected Object clone() throws CloneNotSupportedException`. Since 20.2.0. The `clone()` method is not supported by `DynamicObject` at this point in time, so it always throws [`CloneNotSupportedException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/CloneNotSupportedException.html), even if the [`Cloneable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Cloneable.html) interface is implemented in a subclass. Subclasses may however override this method and create a copy of this object by constructing a new object and copying any properties over manually. Overrides `clone()`. Cite: `com/oracle/truffle/api/object/DynamicObject.html#clone()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DynamicObject.ContainsKeyNode [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 25.1. Nested in [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md). ```java public abstract static class DynamicObject.ContainsKeyNode extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `ContainsKeyNode` Checks if this object contains a property with the given key. **See also** - [`execute(DynamicObject, Object)`](com/oracle/truffle/api/object/DynamicObject.ContainsKeyNode.md#execute%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object%29) ## Methods ### execute(DynamicObject, Object) `public abstract boolean execute(DynamicObject receiver, Object key)`. Returns `true` if this object contains a property with the given key. Usage example: Member name equality check omitted for brevity. Parameters: `key` `Object`: the property key, compared by identity (`==`), not equality (`equals`). See `DynamicObject` for more information. Returns `boolean`: `true` if the object contains a property with this key, else `false`. Cite: `com/oracle/truffle/api/object/DynamicObject.ContainsKeyNode.html#execute(com.oracle.truffle.api.object.DynamicObject,java.lang.Object)` ```java @ExportMessage(name = "isMemberReadable") @ExportMessage(name = "isMemberRemovable") boolean isMemberReadable(String member, @Cached @Shared DynamicObject.ContainsKeyNode containsKeyNode) { return containsKeyNode.execute(this, member); } ``` ### create() `public static DynamicObject.ContainsKeyNode create()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.ContainsKeyNode.html#create()` ### getUncached() `public static DynamicObject.ContainsKeyNode getUncached()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.ContainsKeyNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DynamicObject.CopyPropertiesNode [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 25.1. Nested in [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md). ```java public abstract static class DynamicObject.CopyPropertiesNode extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `CopyPropertiesNode` Copies all properties of a DynamicObject to another, preserving property flags. Does not copy hidden properties. **See also** - [`execute(DynamicObject, DynamicObject)`](com/oracle/truffle/api/object/DynamicObject.CopyPropertiesNode.md#execute%28com.oracle.truffle.api.object.DynamicObject,com.oracle.truffle.api.object.DynamicObject%29) ## Methods ### execute(DynamicObject, DynamicObject) `public abstract void execute(DynamicObject from, DynamicObject to)`. Since 25.1. Copies all properties of a DynamicObject to another, preserving property flags. Does not copy hidden properties. Cite: `com/oracle/truffle/api/object/DynamicObject.CopyPropertiesNode.html#execute(com.oracle.truffle.api.object.DynamicObject,com.oracle.truffle.api.object.DynamicObject)` ### create() `public static DynamicObject.CopyPropertiesNode create()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.CopyPropertiesNode.html#create()` ### getUncached() `public static DynamicObject.CopyPropertiesNode getUncached()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.CopyPropertiesNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # @ DynamicObject.DynamicField [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Annotation interface in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 20.2.0. Nested in [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md). ```java @Retention(RUNTIME) @Target({FIELD}) protected @interface DynamicObject.DynamicField ``` Using this annotation, subclasses can define additional dynamic fields to be used by the object layout. Annotated field must be of type `Object` or `long`, must not be final, and must not have any direct usages. **See also** - [`Shape.Builder.layout(Class, Lookup)`](com/oracle/truffle/api/object/Shape.Builder.md#layout%28java.lang.Class,java.lang.invoke.MethodHandles.Lookup%29) # ◆ DynamicObject.GetDynamicTypeNode [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 25.1. Nested in [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md). ```java public abstract static class DynamicObject.GetDynamicTypeNode extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `GetDynamicTypeNode` Gets the language-specific dynamic type identifier currently associated with this object. **See also** - [`execute(DynamicObject)`](com/oracle/truffle/api/object/DynamicObject.GetDynamicTypeNode.md#execute%28com.oracle.truffle.api.object.DynamicObject%29) ## Methods ### execute(DynamicObject) `public abstract Object execute(DynamicObject receiver)`. Gets the dynamic type identifier currently associated with this object. What this type represents is completely up to the language. For example, it could be a guest-language class. Returns `Object`: the object type. See also: `DynamicObject.SetDynamicTypeNode`. Cite: `com/oracle/truffle/api/object/DynamicObject.GetDynamicTypeNode.html#execute(com.oracle.truffle.api.object.DynamicObject)` ### create() `public static DynamicObject.GetDynamicTypeNode create()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.GetDynamicTypeNode.html#create()` ### getUncached() `public static DynamicObject.GetDynamicTypeNode getUncached()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.GetDynamicTypeNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DynamicObject.GetKeyArrayNode [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 25.1. Nested in [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md). ```java public abstract static class DynamicObject.GetKeyArrayNode extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `GetKeyArrayNode` Gets a snapshot of the object's property keys, in insertion order. **See also** - [`execute(DynamicObject)`](com/oracle/truffle/api/object/DynamicObject.GetKeyArrayNode.md#execute%28com.oracle.truffle.api.object.DynamicObject%29) ## Methods ### execute(DynamicObject) `public abstract Object[] execute(DynamicObject receiver)`. Gets a snapshot of the object's property keys, in insertion order. The returned array may have been cached and must not be mutated. Properties with a `HiddenKey` are not included. Usage example: The example below shows how the returned keys array could be translated to an interop array for use with InteropLibrary. Returns `Object[]`: a read-only array of the object's property keys. Do not modify. Cite: `com/oracle/truffle/api/object/DynamicObject.GetKeyArrayNode.html#execute(com.oracle.truffle.api.object.DynamicObject)` ```java @ExportMessage Object getMembers(boolean includeInternal, @Cached DynamicObject.GetKeyArrayNode getKeyArrayNode) { return new Keys(getKeyArrayNode.execute(this)); } @ExportLibrary(InteropLibrary.class) static final class Keys implements TruffleObject { @CompilationFinal(dimensions = 1) final Object[] keys; Keys(Object[] keys) { this.keys = keys; } @ExportMessage boolean hasArrayElements() { return true; } @ExportMessage Object readArrayElement(long index) throws InvalidArrayIndexException { if (!isArrayElementReadable(index)) { throw InvalidArrayIndexException.create(index); } return keys[(int) index]; } @ExportMessage long getArraySize() { return keys.length; } @ExportMessage boolean isArrayElementReadable(long index) { return index >= 0 && index < keys.length; } } ``` ### create() `public static DynamicObject.GetKeyArrayNode create()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.GetKeyArrayNode.html#create()` ### getUncached() `public static DynamicObject.GetKeyArrayNode getUncached()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.GetKeyArrayNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DynamicObject.GetNode [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 25.1. Nested in [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md). ```java public abstract static class DynamicObject.GetNode extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `GetNode` Gets the value of a property or returns a default value if no such property exists. Specialized return type variants are available for when a primitive result is expected. **See also** - [`execute(DynamicObject, Object, Object)`](com/oracle/truffle/api/object/DynamicObject.GetNode.md#execute%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object%29) - [`executeInt(DynamicObject, Object, Object)`](com/oracle/truffle/api/object/DynamicObject.GetNode.md#executeInt%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object%29) - [`executeLong(DynamicObject, Object, Object)`](com/oracle/truffle/api/object/DynamicObject.GetNode.md#executeLong%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object%29) - [`executeDouble(DynamicObject, Object, Object)`](com/oracle/truffle/api/object/DynamicObject.GetNode.md#executeDouble%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object%29) ## Methods ### execute(DynamicObject, Object, Object) `public abstract Object execute(DynamicObject receiver, Object key, Object defaultValue)`. Since 25.1. Gets the value of an existing property or returns the provided default value if no such property exists. Usage examples: Simple use of `GetNode` with a pre-interned symbol key. Simple use of `GetNode` with a string key cached by equality. Parameters: `key` `Object`: the property key, compared by identity (`==`), not equality (`equals`). See `DynamicObject` for more information. `defaultValue` `Object`: value to be returned if the property does not exist. Returns `Object`: the property's value if it exists, else `defaultValue`. Cite: `com/oracle/truffle/api/object/DynamicObject.GetNode.html#execute(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object)` ```java abstract static class GetSimpleNode extends Node { abstract Object execute(DynamicObject receiver, Object key); @Specialization static Object doCached(MyDynamicObjectSubclass receiver, Symbol key, @Cached DynamicObject.GetNode getNode) { return getNode.execute(receiver, key, NULL_VALUE); } } ``` ```java abstract static class GetStringKeyNode extends Node { abstract Object execute(DynamicObject receiver, Object key); @Specialization(guards = "equalNode.execute(key, cachedKey, UTF_16)", limit = "3") static Object doCached(MyDynamicObjectSubclass receiver, TruffleString key, @Cached("key") TruffleString cachedKey, @Cached TruffleString.EqualNode equalNode, @Cached DynamicObject.GetNode getNode) { return getNode.execute(receiver, cachedKey, NULL_VALUE); } } ``` ### executeInt(DynamicObject, Object, Object) `public abstract int executeInt(DynamicObject receiver, Object key, Object defaultValue) throws UnexpectedResultException`. Since 25.1. Gets the value of an existing property or returns the provided default value if no such property exists. Parameters: `key` `Object`: the property key, compared by identity (`==`), not equality (`equals`). See `DynamicObject` for more information. `defaultValue` `Object`: the value to be returned if the property does not exist. Returns `int`: the property's value if it exists, else `defaultValue`. Throws: `UnexpectedResultException`: if the value (or default value if the property is missing) is not an `int`. See also: `execute(DynamicObject, Object, Object)`. Cite: `com/oracle/truffle/api/object/DynamicObject.GetNode.html#executeInt(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object)` ### executeLong(DynamicObject, Object, Object) `public abstract long executeLong(DynamicObject receiver, Object key, Object defaultValue) throws UnexpectedResultException`. Since 25.1. Gets the value of an existing property or returns the provided default value if no such property exists. Parameters: `key` `Object`: the property key, compared by identity (`==`), not equality (`equals`). See `DynamicObject` for more information. `defaultValue` `Object`: the value to be returned if the property does not exist. Returns `long`: the property's value if it exists, else `defaultValue`. Throws: `UnexpectedResultException`: if the value (or default value if the property is missing) is not an `long`. See also: `execute(DynamicObject, Object, Object)`. Cite: `com/oracle/truffle/api/object/DynamicObject.GetNode.html#executeLong(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object)` ### executeDouble(DynamicObject, Object, Object) `public abstract double executeDouble(DynamicObject receiver, Object key, Object defaultValue) throws UnexpectedResultException`. Since 25.1. Gets the value of an existing property or returns the provided default value if no such property exists. Parameters: `key` `Object`: the property key, compared by identity (`==`), not equality (`equals`). See `DynamicObject` for more information. `defaultValue` `Object`: the value to be returned if the property does not exist. Returns `double`: the property's value if it exists, else `defaultValue`. Throws: `UnexpectedResultException`: if the value (or default value if the property is missing) is not an `double`. See also: `execute(DynamicObject, Object, Object)`. Cite: `com/oracle/truffle/api/object/DynamicObject.GetNode.html#executeDouble(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object)` ### create() `public static DynamicObject.GetNode create()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.GetNode.html#create()` ### getUncached() `public static DynamicObject.GetNode getUncached()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.GetNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DynamicObject.GetPropertyArrayNode [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 25.1. Nested in [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md). ```java public abstract static class DynamicObject.GetPropertyArrayNode extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `GetPropertyArrayNode` Gets a snapshot of the object's [properties](com/oracle/truffle/api/object/Property.md), in insertion order. **See also** - [`execute(DynamicObject)`](com/oracle/truffle/api/object/DynamicObject.GetPropertyArrayNode.md#execute%28com.oracle.truffle.api.object.DynamicObject%29) ## Methods ### execute(DynamicObject) `public abstract Property[] execute(DynamicObject receiver)`. Gets an array snapshot of the object's properties, in insertion order. The returned array may have been cached and must not be mutated. Properties with a `HiddenKey` are not included. Similar to `GetKeyArrayNode` but allows the properties' flags to be queried simultaneously which may be relevant for quick filtering. Returns `Property[]`: a read-only array of the object's properties. Do not modify. See also: `GetKeyArrayNode`. Cite: `com/oracle/truffle/api/object/DynamicObject.GetPropertyArrayNode.html#execute(com.oracle.truffle.api.object.DynamicObject)` ### create() `public static DynamicObject.GetPropertyArrayNode create()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.GetPropertyArrayNode.html#create()` ### getUncached() `public static DynamicObject.GetPropertyArrayNode getUncached()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.GetPropertyArrayNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DynamicObject.GetPropertyFlagsNode [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 25.1. Nested in [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md). ```java public abstract static class DynamicObject.GetPropertyFlagsNode extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `GetPropertyFlagsNode` Gets the property flags associated with the requested property key. **See also** - [`execute(DynamicObject, Object, int)`](com/oracle/truffle/api/object/DynamicObject.GetPropertyFlagsNode.md#execute%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object,int%29) ## Methods ### execute(DynamicObject, Object, int) `public abstract int execute(DynamicObject receiver, Object key, int defaultValue)`. Gets the property flags associated with the requested property key. Returns the `defaultValue` if the object contains no such property. If the property exists but no flags were explicitly set, returns the default of 0. Convenience method equivalent to: Usage example: Implementing read-only property check in writeMember: Member name equality check omitted for brevity. Parameters: `key` `Object`: the property key, compared by identity (`==`), not equality (`equals`). See `DynamicObject` for more information. `defaultValue` `int`: value to return if no such property exists. Returns `int`: the property flags if the property exists, else `defaultValue`. See also: `GetPropertyNode`. Cite: `com/oracle/truffle/api/object/DynamicObject.GetPropertyFlagsNode.html#execute(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,int)` ```java abstract static class GetPropertyEquivalentNode extends Node { abstract void execute(DynamicObject receiver, Object key); @Specialization int doGeneric(MyDynamicObjectSubclass receiver, Symbol key, int defaultValue, @Cached DynamicObject.GetPropertyNode getPropertyNode) { Property property = getPropertyNode.execute(receiver, key); return property != null ? property.getFlags() : defaultValue; } } ``` ```java static final int READ_ONLY = 1; static final int MISSING = -1; static final int FROZEN = 1; @ExportMessage void writeMember(String member, Object value, @Cached @Shared DynamicObject.GetShapeFlagsNode getShapeFlagsNode, @Cached @Shared DynamicObject.GetPropertyFlagsNode getPropertyFlagsNode, @Cached DynamicObject.PutNode putNode) throws UnknownIdentifierException, UnsupportedMessageException { if ((getShapeFlagsNode.execute(this) & FROZEN) == FROZEN) { throw UnsupportedMessageException.create(); } int flags = getPropertyFlagsNode.execute(this, member, MISSING); if (flags == MISSING) { throw UnknownIdentifierException.create(member); } else if ((flags & READ_ONLY) == READ_ONLY) { throw UnsupportedMessageException.create(); } putNode.execute(this, member, value); } @ExportMessage boolean isMemberModifiable(String member, @Cached @Shared DynamicObject.GetShapeFlagsNode getShapeFlagsNode, @Cached @Shared DynamicObject.GetPropertyFlagsNode getPropertyFlagsNode) { if ((getShapeFlagsNode.execute(this) & FROZEN) == FROZEN) { return false; } int flags = getPropertyFlagsNode.execute(this, member, MISSING); return flags != MISSING && (flags & READ_ONLY) == 0; } @ExportMessage boolean isMemberInsertable(String member, @Cached @Shared DynamicObject.GetShapeFlagsNode getShapeFlagsNode, @Cached @Shared DynamicObject.GetPropertyFlagsNode getPropertyFlagsNode) { if ((getShapeFlagsNode.execute(this) & FROZEN) == FROZEN) { return false; } return getPropertyFlagsNode.execute(this, member, MISSING) == MISSING; } ``` ### create() `public static DynamicObject.GetPropertyFlagsNode create()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.GetPropertyFlagsNode.html#create()` ### getUncached() `public static DynamicObject.GetPropertyFlagsNode getUncached()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.GetPropertyFlagsNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DynamicObject.GetPropertyNode [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 25.1. Nested in [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md). ```java public abstract static class DynamicObject.GetPropertyNode extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `GetPropertyNode` Gets a [property descriptor](com/oracle/truffle/api/object/Property.md) for the requested property key or `null` if no such property exists. **See also** - [`execute(DynamicObject, Object)`](com/oracle/truffle/api/object/DynamicObject.GetPropertyNode.md#execute%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object%29) ## Methods ### execute(DynamicObject, Object) `public abstract Property execute(DynamicObject receiver, Object key)`. Gets a property descriptor for the requested property key. Returns `null` if the object contains no such property. Returns `Property`: `Property` if the property exists, else `null`. Cite: `com/oracle/truffle/api/object/DynamicObject.GetPropertyNode.html#execute(com.oracle.truffle.api.object.DynamicObject,java.lang.Object)` ### create() `public static DynamicObject.GetPropertyNode create()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.GetPropertyNode.html#create()` ### getUncached() `public static DynamicObject.GetPropertyNode getUncached()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.GetPropertyNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DynamicObject.GetShapeFlagsNode [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 25.1. Nested in [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md). ```java public abstract static class DynamicObject.GetShapeFlagsNode extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `GetShapeFlagsNode` Gets the language-specific object shape flags. **See also** - [`execute(DynamicObject)`](com/oracle/truffle/api/object/DynamicObject.GetShapeFlagsNode.md#execute%28com.oracle.truffle.api.object.DynamicObject%29) ## Methods ### execute(DynamicObject) `public abstract int execute(DynamicObject receiver)`. Gets the language-specific object shape flags previously set using `SetShapeFlagsNode` or `Shape.Builder.shapeFlags(int)`. If no shape flags were explicitly set, the default of 0 is returned. These flags may be used to tag objects that possess characteristics that need to be queried efficiently on fast and slow paths. For example, they can be used to mark objects as frozen. Usage example: Implementing frozen object check in writeMember: Member name equality check omitted for brevity. Returns `int`: shape flags. See also: `SetShapeFlagsNode`, `Shape.Builder.shapeFlags(int)`, `Shape.getFlags()`. Cite: `com/oracle/truffle/api/object/DynamicObject.GetShapeFlagsNode.html#execute(com.oracle.truffle.api.object.DynamicObject)` ```java static final int READ_ONLY = 1; static final int MISSING = -1; static final int FROZEN = 1; @ExportMessage void writeMember(String member, Object value, @Cached @Shared DynamicObject.GetShapeFlagsNode getShapeFlagsNode, @Cached @Shared DynamicObject.GetPropertyFlagsNode getPropertyFlagsNode, @Cached DynamicObject.PutNode putNode) throws UnknownIdentifierException, UnsupportedMessageException { if ((getShapeFlagsNode.execute(this) & FROZEN) == FROZEN) { throw UnsupportedMessageException.create(); } int flags = getPropertyFlagsNode.execute(this, member, MISSING); if (flags == MISSING) { throw UnknownIdentifierException.create(member); } else if ((flags & READ_ONLY) == READ_ONLY) { throw UnsupportedMessageException.create(); } putNode.execute(this, member, value); } @ExportMessage boolean isMemberModifiable(String member, @Cached @Shared DynamicObject.GetShapeFlagsNode getShapeFlagsNode, @Cached @Shared DynamicObject.GetPropertyFlagsNode getPropertyFlagsNode) { if ((getShapeFlagsNode.execute(this) & FROZEN) == FROZEN) { return false; } int flags = getPropertyFlagsNode.execute(this, member, MISSING); return flags != MISSING && (flags & READ_ONLY) == 0; } @ExportMessage boolean isMemberInsertable(String member, @Cached @Shared DynamicObject.GetShapeFlagsNode getShapeFlagsNode, @Cached @Shared DynamicObject.GetPropertyFlagsNode getPropertyFlagsNode) { if ((getShapeFlagsNode.execute(this) & FROZEN) == FROZEN) { return false; } return getPropertyFlagsNode.execute(this, member, MISSING) == MISSING; } ``` ### create() `public static DynamicObject.GetShapeFlagsNode create()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.GetShapeFlagsNode.html#create()` ### getUncached() `public static DynamicObject.GetShapeFlagsNode getUncached()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.GetShapeFlagsNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DynamicObject.IsSharedNode [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 25.1. Nested in [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md). ```java public abstract static class DynamicObject.IsSharedNode extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `IsSharedNode` Checks whether this object is marked as shared. **See also** - [`execute(DynamicObject)`](com/oracle/truffle/api/object/DynamicObject.IsSharedNode.md#execute%28com.oracle.truffle.api.object.DynamicObject%29) ## Methods ### execute(DynamicObject) `public abstract boolean execute(DynamicObject receiver)`. Checks whether this object is marked as shared. Returns `boolean`: `true` if the object is shared. See also: `MarkSharedNode`, `Shape.isShared()`. Cite: `com/oracle/truffle/api/object/DynamicObject.IsSharedNode.html#execute(com.oracle.truffle.api.object.DynamicObject)` ### create() `public static DynamicObject.IsSharedNode create()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.IsSharedNode.html#create()` ### getUncached() `public static DynamicObject.IsSharedNode getUncached()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.IsSharedNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DynamicObject.MarkSharedNode [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 25.1. Nested in [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md). ```java public abstract static class DynamicObject.MarkSharedNode extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `MarkSharedNode` Marks this object as shared. **See also** - [`execute(DynamicObject)`](com/oracle/truffle/api/object/DynamicObject.MarkSharedNode.md#execute%28com.oracle.truffle.api.object.DynamicObject%29) ## Methods ### execute(DynamicObject) `public abstract boolean execute(DynamicObject receiver)`. Marks this object as shared. Makes the object use a shared variant of the `Shape`, to allow safe usage of this object between threads. Objects with a shared `Shape` will not reuse storage locations for other fields. In combination with careful synchronization on writes, this can prevent reading out-of-thin-air values. Throws: `UnsupportedOperationException` (unchecked): if the object is already `shared`. See also: `IsSharedNode`. Cite: `com/oracle/truffle/api/object/DynamicObject.MarkSharedNode.html#execute(com.oracle.truffle.api.object.DynamicObject)` ### create() `public static DynamicObject.MarkSharedNode create()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.MarkSharedNode.html#create()` ### getUncached() `public static DynamicObject.MarkSharedNode getUncached()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.MarkSharedNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DynamicObject.PutAllNode [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 25.1. Nested in [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md). ```java public abstract static class DynamicObject.PutAllNode extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `PutAllNode` Adds or sets multiple properties in bulk. Behaves like [`PutNode`](com/oracle/truffle/api/object/DynamicObject.PutNode.md), but is usually more efficient for cases like object initialization where more than a few properties are added at once. Cached nodes may retain the supplied keys array. Its elements must not be modified after being passed to a cached node, including between executions. Use a new array for different keys. Values and property flags arrays are not retained and may be modified between executions. No input array may be modified during execution. **See also** - [`execute(DynamicObject, Object[], Object[])`](com/oracle/truffle/api/object/DynamicObject.PutAllNode.md#execute%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object[],java.lang.Object[]%29) - [`executeIfAbsent(DynamicObject, Object[], Object[])`](com/oracle/truffle/api/object/DynamicObject.PutAllNode.md#executeIfAbsent%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object[],java.lang.Object[]%29) - [`executeIfPresent(DynamicObject, Object[], Object[])`](com/oracle/truffle/api/object/DynamicObject.PutAllNode.md#executeIfPresent%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object[],java.lang.Object[]%29) - [`executeWithFlags(DynamicObject, Object[], Object[], int[])`](com/oracle/truffle/api/object/DynamicObject.PutAllNode.md#executeWithFlags%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object[],java.lang.Object[],int[]%29) - [`executeWithFlagsIfAbsent(DynamicObject, Object[], Object[], int[])`](com/oracle/truffle/api/object/DynamicObject.PutAllNode.md#executeWithFlagsIfAbsent%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object[],java.lang.Object[],int[]%29) - [`executeWithFlagsIfPresent(DynamicObject, Object[], Object[], int[])`](com/oracle/truffle/api/object/DynamicObject.PutAllNode.md#executeWithFlagsIfPresent%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object[],java.lang.Object[],int[]%29) - [`PutNode`](com/oracle/truffle/api/object/DynamicObject.PutNode.md) ## Constructors ### PutAllNode() `public PutAllNode()`. Declared by the compiler. Creates a new PutAllNode instance. Cite: `com/oracle/truffle/api/object/DynamicObject.PutAllNode.html#()` ## Methods ### execute(DynamicObject, Object[], Object[]) `public final void execute(DynamicObject receiver, Object[] keys, Object[] values)`. Since 25.1. Adds multiple properties or sets the values of multiple existing properties at once. Newly added properties will have flags 0; flags of existing properties will not be changed. Use `executeWithFlags` to set property flags as well. Cached property keys are compared by identity (`==`), not equality (`equals`). Usage example: Simple use of `PutAllNode` to allocate and fill an object with properties. Parameters: `keys` `Object[]`: the property keys, compared by identity (`==`), not equality (`equals`). See `DynamicObject` for more information. `values` `Object[]`: the values to be set; needs to be the same length as `keys`. See also: `executeIfPresent(DynamicObject, Object[], Object[])`, `executeWithFlags(DynamicObject, Object[], Object[], int[])`. Cite: `com/oracle/truffle/api/object/DynamicObject.PutAllNode.html#execute(com.oracle.truffle.api.object.DynamicObject,java.lang.Object[],java.lang.Object[])` ```java abstract static class ObjectInitializerNode extends Node { @CompilationFinal private Shape initialShape; @CompilationFinal(dimensions = 1) private Object[] keys; @Children private ExprNode[] valueNodes; abstract void execute(); @ExplodeLoop @Specialization void doDefault(@Cached DynamicObject.PutAllNode putAllNode) { var receiver = new MyDynamicObjectSubclass(initialShape); var values = new Object[keys.length]; for (int i = 0; i < keys.length; i++) { values[i] = valueNodes[i].execute(); } putAllNode.execute(receiver, keys, values); } } ``` ### executeIfPresent(DynamicObject, Object[], Object[]) `public final void executeIfPresent(DynamicObject receiver, Object[] keys, Object[] values)`. Since 25.1. Like `execute(DynamicObject, Object[], Object[])` but only sets properties that are already present. See also: `execute(DynamicObject, Object[], Object[])`. Cite: `com/oracle/truffle/api/object/DynamicObject.PutAllNode.html#executeIfPresent(com.oracle.truffle.api.object.DynamicObject,java.lang.Object[],java.lang.Object[])` ### executeIfAbsent(DynamicObject, Object[], Object[]) `public final void executeIfAbsent(DynamicObject receiver, Object[] keys, Object[] values)`. Since 25.1. Like `execute(DynamicObject, Object[], Object[])` but only adds properties that are absent. See also: `execute(DynamicObject, Object[], Object[])`. Cite: `com/oracle/truffle/api/object/DynamicObject.PutAllNode.html#executeIfAbsent(com.oracle.truffle.api.object.DynamicObject,java.lang.Object[],java.lang.Object[])` ### executeWithFlags(DynamicObject, Object[], …) `public final void executeWithFlags(DynamicObject receiver, Object[] keys, Object[] values, int[] propertyFlags)`. Since 25.1. Like `execute(DynamicObject, Object[], Object[])` but additionally sets property flags. If a property already exists, its flags will be updated before the value is set. Parameters: `keys` `Object[]`: the property keys, compared by identity (`==`), not equality (`equals`). See `DynamicObject` for more information. `values` `Object[]`: the values to be set; needs to be the same length as `keys`. `propertyFlags` `int[]`: the property flags to be set; needs to be the same length as keys. Cite: `com/oracle/truffle/api/object/DynamicObject.PutAllNode.html#executeWithFlags(com.oracle.truffle.api.object.DynamicObject,java.lang.Object[],java.lang.Object[],int[])` ### executeWithFlagsIfPresent(DynamicObject, Object[], …) `public final void executeWithFlagsIfPresent(DynamicObject receiver, Object[] keys, Object[] values, int[] propertyFlags)`. Since 25.1. Like `executeIfPresent(DynamicObject, Object[], Object[])` but also sets property flags when a property is present. See also: `executeWithFlags(DynamicObject, Object[], Object[], int[])`, `executeIfPresent(DynamicObject, Object[], Object[])`. Cite: `com/oracle/truffle/api/object/DynamicObject.PutAllNode.html#executeWithFlagsIfPresent(com.oracle.truffle.api.object.DynamicObject,java.lang.Object[],java.lang.Object[],int[])` ### executeWithFlagsIfAbsent(DynamicObject, Object[], …) `public final void executeWithFlagsIfAbsent(DynamicObject receiver, Object[] keys, Object[] values, int[] propertyFlags)`. Since 25.1. Like `executeIfAbsent(DynamicObject, Object[], Object[])` but also sets property flags when adding a property. See also: `executeWithFlags(DynamicObject, Object[], Object[], int[])`, `executeIfAbsent(DynamicObject, Object[], Object[])`. Cite: `com/oracle/truffle/api/object/DynamicObject.PutAllNode.html#executeWithFlagsIfAbsent(com.oracle.truffle.api.object.DynamicObject,java.lang.Object[],java.lang.Object[],int[])` ### getUncached() `public static DynamicObject.PutAllNode getUncached()`. Cite: `com/oracle/truffle/api/object/DynamicObject.PutAllNode.html#getUncached()` ### create() `public static DynamicObject.PutAllNode create()`. Cite: `com/oracle/truffle/api/object/DynamicObject.PutAllNode.html#create()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DynamicObject.PutConstantNode [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 25.1. Nested in [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md). ```java public abstract static class DynamicObject.PutConstantNode extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `PutConstantNode` Sets the value of an existing property or adds a new property if no such property exists. Additional variants allow setting property flags, only setting the property if it's either absent or present, and setting constant properties stored in the shape. **See also** - [`execute(DynamicObject, Object, Object)`](com/oracle/truffle/api/object/DynamicObject.PutConstantNode.md#execute%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object%29) - [`executeIfAbsent(DynamicObject, Object, Object)`](com/oracle/truffle/api/object/DynamicObject.PutConstantNode.md#executeIfAbsent%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object%29) - [`executeIfPresent(DynamicObject, Object, Object)`](com/oracle/truffle/api/object/DynamicObject.PutConstantNode.md#executeIfPresent%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object%29) - [`executeWithFlags(DynamicObject, Object, Object, int)`](com/oracle/truffle/api/object/DynamicObject.PutConstantNode.md#executeWithFlags%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object,int%29) - [`executeWithFlagsIfAbsent(DynamicObject, Object, Object, int)`](com/oracle/truffle/api/object/DynamicObject.PutConstantNode.md#executeWithFlagsIfAbsent%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object,int%29) - [`executeWithFlagsIfPresent(DynamicObject, Object, Object, int)`](com/oracle/truffle/api/object/DynamicObject.PutConstantNode.md#executeWithFlagsIfPresent%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object,int%29) - [`PutNode`](com/oracle/truffle/api/object/DynamicObject.PutNode.md) ## Methods ### execute(DynamicObject, Object, Object) `public final void execute(DynamicObject receiver, Object key, Object value)`. Same as `executeWithFlags`, except the property is added with 0 flags, and if the property already exists, its flags will *not* be updated. Cite: `com/oracle/truffle/api/object/DynamicObject.PutConstantNode.html#execute(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object)` ### executeIfPresent(DynamicObject, Object, Object) `public final boolean executeIfPresent(DynamicObject receiver, Object key, Object value)`. Like `execute(DynamicObject, Object, Object)` but only if the property is present. Cite: `com/oracle/truffle/api/object/DynamicObject.PutConstantNode.html#executeIfPresent(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object)` ### executeIfAbsent(DynamicObject, Object, Object) `public final boolean executeIfAbsent(DynamicObject receiver, Object key, Object value)`. Like `execute(DynamicObject, Object, Object)` but only if the property is absent. Cite: `com/oracle/truffle/api/object/DynamicObject.PutConstantNode.html#executeIfAbsent(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object)` ### executeWithFlags(DynamicObject, Object, …) `public final void executeWithFlags(DynamicObject receiver, Object key, Object value, int propertyFlags)`. Adds a property with a constant value or replaces an existing one. If the property already exists, its flags will be updated. The constant value is stored in the shape rather than the object instance and a new shape will be allocated if it does not already exist. A typical use case for this method is setting the initial default value of a declared, but yet uninitialized, property. This defers storage allocation and type speculation until the first actual value is set. Warning: this method will lead to a shape transition every time a new value is set and should be used sparingly (with at most one constant value per property) since it could cause an excessive amount of shapes to be created. Note: the value is strongly referenced from the shape property map. It should ideally be a value type or light-weight object without any references to guest language objects in order to prevent potential memory leaks from holding onto the Shape in inline caches. The Shape transition itself is weak, so the previous shapes will not hold strongly on the value. Usage example: Parameters: `key` `Object`: property identifier. `value` `Object`: the constant value to be set. `propertyFlags` `int`: property flags or 0. See also: `(DynamicObject, Object, Object)`. Cite: `com/oracle/truffle/api/object/DynamicObject.PutConstantNode.html#executeWithFlags(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object,int)` ```java abstract static class DeclarePropertyNode extends Node { abstract void execute(DynamicObject receiver, Object key); @Specialization static void doCached(MyDynamicObjectSubclass receiver, Symbol key, @Cached DynamicObject.PutConstantNode putConstantNode) { // declare property putConstantNode.execute(receiver, key, NULL_VALUE); } } ``` ```java abstract static class InitializePropertyNode extends Node { abstract void execute(DynamicObject receiver, Object key, Object value); @Specialization static void doCached(MyDynamicObjectSubclass receiver, Symbol key, Object value, @Cached DynamicObject.PutNode putNode) { // initialize property putNode.execute(receiver, key, value); } } ``` ### executeWithFlagsIfPresent(DynamicObject, Object, …) `public final boolean executeWithFlagsIfPresent(DynamicObject receiver, Object key, Object value, int propertyFlags)`. Like `executeWithFlags(DynamicObject, Object, Object, int)` but only if the property is present. Cite: `com/oracle/truffle/api/object/DynamicObject.PutConstantNode.html#executeWithFlagsIfPresent(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object,int)` ### executeWithFlagsIfAbsent(DynamicObject, Object, …) `public final boolean executeWithFlagsIfAbsent(DynamicObject receiver, Object key, Object value, int propertyFlags)`. Like `executeWithFlags(DynamicObject, Object, Object, int)` but only if the property is absent. Cite: `com/oracle/truffle/api/object/DynamicObject.PutConstantNode.html#executeWithFlagsIfAbsent(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object,int)` ### create() `public static DynamicObject.PutConstantNode create()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.PutConstantNode.html#create()` ### getUncached() `public static DynamicObject.PutConstantNode getUncached()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.PutConstantNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DynamicObject.PutNode [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 25.1. Nested in [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md). ```java public abstract static class DynamicObject.PutNode extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `PutNode` Sets the value of an existing property or adds a new property if no such property exists. Additional variants allow setting property flags, only setting the property if it's either absent or present, and setting constant properties stored in the shape. **See also** - [`execute(DynamicObject, Object, Object)`](com/oracle/truffle/api/object/DynamicObject.PutNode.md#execute%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object%29) - [`executeIfAbsent(DynamicObject, Object, Object)`](com/oracle/truffle/api/object/DynamicObject.PutNode.md#executeIfAbsent%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object%29) - [`executeIfPresent(DynamicObject, Object, Object)`](com/oracle/truffle/api/object/DynamicObject.PutNode.md#executeIfPresent%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object%29) - [`executeWithFlags(DynamicObject, Object, Object, int)`](com/oracle/truffle/api/object/DynamicObject.PutNode.md#executeWithFlags%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object,int%29) - [`executeWithFlagsIfAbsent(DynamicObject, Object, Object, int)`](com/oracle/truffle/api/object/DynamicObject.PutNode.md#executeWithFlagsIfAbsent%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object,int%29) - [`executeWithFlagsIfPresent(DynamicObject, Object, Object, int)`](com/oracle/truffle/api/object/DynamicObject.PutNode.md#executeWithFlagsIfPresent%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object,int%29) - [`PutConstantNode`](com/oracle/truffle/api/object/DynamicObject.PutConstantNode.md) ## Methods ### execute(DynamicObject, Object, Object) `public final void execute(DynamicObject receiver, Object key, Object value)`. Sets the value of an existing property or adds a new property if no such property exists. A newly added property will have flags 0; flags of existing properties will not be changed. Use `executeWithFlags` to set property flags as well. Usage examples: Simple use of `PutNode` with a pre-interned symbol key. Simple use of `PutNode` with a string key cached by equality. Parameters: `key` `Object`: the property key, compared by identity (`==`), not equality (`equals`). See `DynamicObject` for more information. `value` `Object`: the value to be set. See also: `(DynamicObject, Object, Object)`, `(DynamicObject, Object, Object, int)`. Cite: `com/oracle/truffle/api/object/DynamicObject.PutNode.html#execute(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object)` ```java abstract static class SetSimpleNode extends Node { abstract Object execute(DynamicObject receiver, Object key, Object value); @Specialization static Object doCached(MyDynamicObjectSubclass receiver, Symbol key, Object value, @Cached DynamicObject.PutNode putNode) { putNode.execute(receiver, key, value); return value; } } ``` ```java abstract static class SetStringKeyNode extends Node { abstract Object execute(DynamicObject receiver, Object key, Object value); @Specialization(guards = "equalNode.execute(key, cachedKey, UTF_16)", limit = "3") static Object doCached(MyDynamicObjectSubclass receiver, TruffleString key, Object value, @Cached("key") TruffleString cachedKey, @Cached TruffleString.EqualNode equalNode, @Cached DynamicObject.PutNode putNode) { putNode.execute(receiver, cachedKey, value); return value; } } ``` ### executeIfPresent(DynamicObject, Object, Object) `public final boolean executeIfPresent(DynamicObject receiver, Object key, Object value)`. Sets the value of the property if present, otherwise returns `false`. Parameters: `key` `Object`: property identifier. `value` `Object`: value to be set. Returns `boolean`: `true` if the property was present and the value set, otherwise `false`. See also: `execute(DynamicObject, Object, Object)`. Cite: `com/oracle/truffle/api/object/DynamicObject.PutNode.html#executeIfPresent(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object)` ### executeIfAbsent(DynamicObject, Object, Object) `public final boolean executeIfAbsent(DynamicObject receiver, Object key, Object value)`. Sets the value of the property if absent, otherwise returns `false`. Parameters: `key` `Object`: property identifier. `value` `Object`: value to be set. Returns `boolean`: `true` if the property was absent and the value set, otherwise `false`. See also: `execute(DynamicObject, Object, Object)`. Cite: `com/oracle/truffle/api/object/DynamicObject.PutNode.html#executeIfAbsent(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object)` ### executeWithFlags(DynamicObject, Object, …) `public final void executeWithFlags(DynamicObject receiver, Object key, Object value, int propertyFlags)`. Like `execute(DynamicObject, Object, Object)`, but additionally assigns flags to the property. If the property already exists, its flags will be updated before the value is set. Parameters: `key` `Object`: property identifier. `value` `Object`: value to be set. `propertyFlags` `int`: flags to be set. See also: `execute(DynamicObject, Object, Object)`. Cite: `com/oracle/truffle/api/object/DynamicObject.PutNode.html#executeWithFlags(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object,int)` ### executeWithFlagsIfPresent(DynamicObject, Object, …) `public final boolean executeWithFlagsIfPresent(DynamicObject receiver, Object key, Object value, int propertyFlags)`. Like `executeIfPresent(DynamicObject, Object, Object)` but also sets property flags. Cite: `com/oracle/truffle/api/object/DynamicObject.PutNode.html#executeWithFlagsIfPresent(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object,int)` ### executeWithFlagsIfAbsent(DynamicObject, Object, …) `public final boolean executeWithFlagsIfAbsent(DynamicObject receiver, Object key, Object value, int propertyFlags)`. Like `executeIfAbsent(DynamicObject, Object, Object)` but also sets property flags. Cite: `com/oracle/truffle/api/object/DynamicObject.PutNode.html#executeWithFlagsIfAbsent(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object,int)` ### create() `public static DynamicObject.PutNode create()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.PutNode.html#create()` ### getUncached() `public static DynamicObject.PutNode getUncached()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.PutNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DynamicObject.RemoveKeyNode [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 25.1. Nested in [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md). ```java public abstract static class DynamicObject.RemoveKeyNode extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `RemoveKeyNode` Removes the property with the given key from the object. **See also** - [`execute(DynamicObject, Object)`](com/oracle/truffle/api/object/DynamicObject.RemoveKeyNode.md#execute%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object%29) ## Methods ### execute(DynamicObject, Object) `public abstract boolean execute(DynamicObject receiver, Object key)`. Removes the property with the given key from the object. Usage example: Member name equality check omitted for brevity. Parameters: `key` `Object`: the property key, compared by identity (`==`), not equality (`equals`). See `DynamicObject` for more information. Returns `boolean`: `true` if the property was removed or `false` if property was not found. Cite: `com/oracle/truffle/api/object/DynamicObject.RemoveKeyNode.html#execute(com.oracle.truffle.api.object.DynamicObject,java.lang.Object)` ```java @ExportMessage void removeMember(String member, @Cached @Shared DynamicObject.GetShapeFlagsNode getShapeFlagsNode, @Cached DynamicObject.RemoveKeyNode removeKeyNode) throws UnknownIdentifierException, UnsupportedMessageException { if ((getShapeFlagsNode.execute(this) & FROZEN) == FROZEN) { throw UnsupportedMessageException.create(); } if (!removeKeyNode.execute(this, member)) { throw UnknownIdentifierException.create(member); } } ``` ### create() `public static DynamicObject.RemoveKeyNode create()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.RemoveKeyNode.html#create()` ### getUncached() `public static DynamicObject.RemoveKeyNode getUncached()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.RemoveKeyNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DynamicObject.ResetShapeNode [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 25.1. Nested in [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md). ```java public abstract static class DynamicObject.ResetShapeNode extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `ResetShapeNode` Empties and resets the object to the given root shape. **See also** - [`execute(DynamicObject, Shape)`](com/oracle/truffle/api/object/DynamicObject.ResetShapeNode.md#execute%28com.oracle.truffle.api.object.DynamicObject,com.oracle.truffle.api.object.Shape%29) ## Methods ### execute(DynamicObject, Shape) `public abstract boolean execute(DynamicObject receiver, Shape newShape)`. Empties and resets the object to the given root shape, which must not contain any instance properties (but may contain properties with a constant value). Parameters: `newShape` `Shape`: the desired shape. Returns `boolean`: `true` if the object's shape was changed. Throws: `IllegalArgumentException` (unchecked): if the shape contains instance properties. Cite: `com/oracle/truffle/api/object/DynamicObject.ResetShapeNode.html#execute(com.oracle.truffle.api.object.DynamicObject,com.oracle.truffle.api.object.Shape)` ### create() `public static DynamicObject.ResetShapeNode create()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.ResetShapeNode.html#create()` ### getUncached() `public static DynamicObject.ResetShapeNode getUncached()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.ResetShapeNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DynamicObject.SetAllPropertyFlagsNode [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 25.5. Nested in [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md). ```java public abstract static class DynamicObject.SetAllPropertyFlagsNode extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `SetAllPropertyFlagsNode` Sets or updates the flags of multiple existing properties. Missing keys are ignored; no properties are created and no property values are assigned. "All" refers to the supplied keys, not all properties of the receiver. ```java static final class SetAllPropertyFlagsNode extends Node { @Child private DynamicObject.SetAllPropertyFlagsNode setFlags = DynamicObject.SetAllPropertyFlagsNode.create(); void execute(DynamicObject receiver, Object[] keys, int[] flags) { setFlags.execute(receiver, keys, flags); } } ``` Keys follow the identity-based caching contract of [`SetPropertyFlagsNode`](com/oracle/truffle/api/object/DynamicObject.SetPropertyFlagsNode.md). Duplicate keys are processed in input order, as separate calls to that node would be. Cached nodes may retain the supplied keys and per-key flags arrays. These arrays must not be modified after being passed to a cached node, including between executions. Use new arrays for different keys or flags. No input array may be modified during execution. ## Methods ### execute(DynamicObject, Object[], int) `public final void execute(DynamicObject receiver, Object[] keys, int flags)`. Since 25.5. Sets the flags of every supplied, existing key to `flags`. Cite: `com/oracle/truffle/api/object/DynamicObject.SetAllPropertyFlagsNode.html#execute(com.oracle.truffle.api.object.DynamicObject,java.lang.Object[],int)` ### execute(DynamicObject, Object[], int[]) `public final void execute(DynamicObject receiver, Object[] keys, int[] flags)`. Since 25.5. Sets each supplied, existing key's flags to the corresponding array element. Throws: `IllegalArgumentException` (unchecked): if the keys and flags array lengths differ. Cite: `com/oracle/truffle/api/object/DynamicObject.SetAllPropertyFlagsNode.html#execute(com.oracle.truffle.api.object.DynamicObject,java.lang.Object[],int[])` ### executeAdd(DynamicObject, Object[], int) `public final void executeAdd(DynamicObject receiver, Object[] keys, int addedFlags)`. Since 25.5. Adds the given flags to each supplied, existing property. Cite: `com/oracle/truffle/api/object/DynamicObject.SetAllPropertyFlagsNode.html#executeAdd(com.oracle.truffle.api.object.DynamicObject,java.lang.Object[],int)` ### executeRemove(DynamicObject, Object[], int) `public final void executeRemove(DynamicObject receiver, Object[] keys, int removedFlags)`. Since 25.5. Removes the given flags from each supplied, existing property. Cite: `com/oracle/truffle/api/object/DynamicObject.SetAllPropertyFlagsNode.html#executeRemove(com.oracle.truffle.api.object.DynamicObject,java.lang.Object[],int)` ### executeRemoveAndAdd(DynamicObject, Object[], …) `public final void executeRemoveAndAdd(DynamicObject receiver, Object[] keys, int removedFlags, int addedFlags)`. Since 25.5. Removes, then adds flags to each supplied, existing property. Addition wins when masks overlap. Cite: `com/oracle/truffle/api/object/DynamicObject.SetAllPropertyFlagsNode.html#executeRemoveAndAdd(com.oracle.truffle.api.object.DynamicObject,java.lang.Object[],int,int)` ### create() `public static DynamicObject.SetAllPropertyFlagsNode create()`. Since 25.5. Cite: `com/oracle/truffle/api/object/DynamicObject.SetAllPropertyFlagsNode.html#create()` ### getUncached() `public static DynamicObject.SetAllPropertyFlagsNode getUncached()`. Since 25.5. Cite: `com/oracle/truffle/api/object/DynamicObject.SetAllPropertyFlagsNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DynamicObject.SetDynamicTypeNode [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 25.1. Nested in [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md). ```java public abstract static class DynamicObject.SetDynamicTypeNode extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `SetDynamicTypeNode` Sets the language-specific dynamic type identifier. **See also** - [`execute(DynamicObject, Object)`](com/oracle/truffle/api/object/DynamicObject.SetDynamicTypeNode.md#execute%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object%29) ## Methods ### execute(DynamicObject, Object) `public abstract boolean execute(DynamicObject receiver, Object type)`. Sets the object's dynamic type identifier. What this type represents is completely up to the language. For example, it could be a guest-language class. The type object is strongly referenced from the shape. It should ideally be a singleton or light-weight object without any references to guest language objects in order to keep the memory footprint low and prevent potential memory leaks from holding onto the Shape in inline caches. The Shape transition itself is weak, so the previous shapes will not hold strongly on the type object. Type objects are always compared by object identity, never `equals`. Parameters: `type` `Object`: a non-null type identifier defined by the guest language. Returns `boolean`: `true` if the type (and the object's shape) changed. See also: `DynamicObject.GetDynamicTypeNode`. Cite: `com/oracle/truffle/api/object/DynamicObject.SetDynamicTypeNode.html#execute(com.oracle.truffle.api.object.DynamicObject,java.lang.Object)` ### create() `public static DynamicObject.SetDynamicTypeNode create()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.SetDynamicTypeNode.html#create()` ### getUncached() `public static DynamicObject.SetDynamicTypeNode getUncached()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.SetDynamicTypeNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DynamicObject.SetPropertyFlagsNode [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 25.1. Nested in [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md). ```java public abstract static class DynamicObject.SetPropertyFlagsNode extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `SetPropertyFlagsNode` Sets or updates property flags associated with the requested property key. **See also** - [`execute(DynamicObject, Object, int)`](com/oracle/truffle/api/object/DynamicObject.SetPropertyFlagsNode.md#execute%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object,int%29) - [`executeAdd(DynamicObject, Object, int)`](com/oracle/truffle/api/object/DynamicObject.SetPropertyFlagsNode.md#executeAdd%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object,int%29) - [`executeRemove(DynamicObject, Object, int)`](com/oracle/truffle/api/object/DynamicObject.SetPropertyFlagsNode.md#executeRemove%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object,int%29) - [`executeRemoveAndAdd(DynamicObject, Object, int, int)`](com/oracle/truffle/api/object/DynamicObject.SetPropertyFlagsNode.md#executeRemoveAndAdd%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object,int,int%29) ## Methods ### execute(DynamicObject, Object, int) `public final boolean execute(DynamicObject receiver, Object key, int propertyFlags)`. Since 25.1. Sets the property flags associated with the requested property. Parameters: `key` `Object`: the property key, compared by identity (`==`), not equality (`equals`). See `DynamicObject` for more information. Returns `boolean`: `true` if the property was found and its flags were changed, else `false`. Cite: `com/oracle/truffle/api/object/DynamicObject.SetPropertyFlagsNode.html#execute(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,int)` ### executeAdd(DynamicObject, Object, int) `public final boolean executeAdd(DynamicObject receiver, Object key, int addedFlags)`. Since 25.1. Adds property flags associated with the requested property. See also: `execute(DynamicObject, Object, int)`. Cite: `com/oracle/truffle/api/object/DynamicObject.SetPropertyFlagsNode.html#executeAdd(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,int)` ### executeRemove(DynamicObject, Object, int) `public final boolean executeRemove(DynamicObject receiver, Object key, int removedFlags)`. Since 25.1. Removes (clears) property flags associated with the requested property. See also: `execute(DynamicObject, Object, int)`. Cite: `com/oracle/truffle/api/object/DynamicObject.SetPropertyFlagsNode.html#executeRemove(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,int)` ### executeRemoveAndAdd(DynamicObject, Object, …) `public final boolean executeRemoveAndAdd(DynamicObject receiver, Object key, int removedFlags, int addedFlags)`. Since 25.1. Removes, then adds property flags associated with the requested property. See also: `execute(DynamicObject, Object, int)`. Cite: `com/oracle/truffle/api/object/DynamicObject.SetPropertyFlagsNode.html#executeRemoveAndAdd(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,int,int)` ### create() `public static DynamicObject.SetPropertyFlagsNode create()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.SetPropertyFlagsNode.html#create()` ### getUncached() `public static DynamicObject.SetPropertyFlagsNode getUncached()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.SetPropertyFlagsNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DynamicObject.SetShapeFlagsNode [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 25.1. Nested in [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md). ```java public abstract static class DynamicObject.SetShapeFlagsNode extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `SetShapeFlagsNode` Sets or updates language-specific object shape flags. **See also** - [`execute(DynamicObject, int)`](com/oracle/truffle/api/object/DynamicObject.SetShapeFlagsNode.md#execute%28com.oracle.truffle.api.object.DynamicObject,int%29) - [`executeAdd(DynamicObject, int)`](com/oracle/truffle/api/object/DynamicObject.SetShapeFlagsNode.md#executeAdd%28com.oracle.truffle.api.object.DynamicObject,int%29) - [`executeRemove(DynamicObject, int)`](com/oracle/truffle/api/object/DynamicObject.SetShapeFlagsNode.md#executeRemove%28com.oracle.truffle.api.object.DynamicObject,int%29) - [`executeRemoveAndAdd(DynamicObject, int, int)`](com/oracle/truffle/api/object/DynamicObject.SetShapeFlagsNode.md#executeRemoveAndAdd%28com.oracle.truffle.api.object.DynamicObject,int,int%29) ## Methods ### execute(DynamicObject, int) `public final boolean execute(DynamicObject receiver, int newFlags)`. Since 25.1. Sets language-specific object shape flags, changing the object's shape if need be. These flags may be used to tag objects that possess characteristics that need to be queried efficiently on fast and slow paths. For example, they can be used to mark objects as frozen. Only the lowest 16 bits (i.e. values in the range 0 to 65535) are allowed, the remaining bits are currently reserved. Usage example: Implementing a freeze object operation: Note that `executeAdd(DynamicObject, int)` is more efficient and convenient for that particular pattern. Parameters: `newFlags` `int`: the flags to set; must be in the range from 0 to 65535 (inclusive). Returns `boolean`: `true` if the object's shape changed, `false` if no change was made. Throws: `IllegalArgumentException` (unchecked): if the flags are not in the allowed range. See also: `GetShapeFlagsNode`, `executeAdd(DynamicObject, int)`, `Shape.Builder.shapeFlags(int)`. Cite: `com/oracle/truffle/api/object/DynamicObject.SetShapeFlagsNode.html#execute(com.oracle.truffle.api.object.DynamicObject,int)` ```java abstract static class FreezeObjectNode extends Node { static final int FROZEN = 1; abstract void execute(DynamicObject receiver); @Specialization static void freeze(DynamicObject receiver, @Cached DynamicObject.GetShapeFlagsNode getShapeFlagsNode, @Cached DynamicObject.SetShapeFlagsNode setShapeFlagsNode) { int oldFlags = getShapeFlagsNode.execute(receiver); int newFlags = oldFlags | FROZEN; if (newFlags != oldFlags) { setShapeFlagsNode.execute(receiver, newFlags); } } } ``` ### executeAdd(DynamicObject, int) `public final boolean executeAdd(DynamicObject receiver, int addedFlags)`. Since 25.1. Adds language-specific object shape flags, changing the object's shape if need be. Usage example: Implementing a freeze object operation: See also: `execute(DynamicObject, int)`. Cite: `com/oracle/truffle/api/object/DynamicObject.SetShapeFlagsNode.html#executeAdd(com.oracle.truffle.api.object.DynamicObject,int)` ```java abstract static class FreezeNode extends Node { static final int FROZEN = 1; abstract void execute(DynamicObject receiver); @Specialization static void freeze(DynamicObject receiver, @Cached DynamicObject.SetShapeFlagsNode setShapeFlagsNode) { setShapeFlagsNode.executeAdd(receiver, FROZEN); } } ``` ### executeRemove(DynamicObject, int) `public final boolean executeRemove(DynamicObject receiver, int removedFlags)`. Since 25.1. Removes language-specific object shape flags, changing the object's shape if need be. See also: `execute(DynamicObject, int)`. Cite: `com/oracle/truffle/api/object/DynamicObject.SetShapeFlagsNode.html#executeRemove(com.oracle.truffle.api.object.DynamicObject,int)` ### executeRemoveAndAdd(DynamicObject, int, int) `public final boolean executeRemoveAndAdd(DynamicObject receiver, int removedFlags, int addedFlags)`. Since 25.1. Removes, then adds language-specific object shape flags, changing the object's shape if need be. See also: `execute(DynamicObject, int)`. Cite: `com/oracle/truffle/api/object/DynamicObject.SetShapeFlagsNode.html#executeRemoveAndAdd(com.oracle.truffle.api.object.DynamicObject,int,int)` ### create() `public static DynamicObject.SetShapeFlagsNode create()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.SetShapeFlagsNode.html#create()` ### getUncached() `public static DynamicObject.SetShapeFlagsNode getUncached()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.SetShapeFlagsNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DynamicObject.UpdateShapeNode [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 25.1. Nested in [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md). ```java public abstract static class DynamicObject.UpdateShapeNode extends Node ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `UpdateShapeNode` Ensures the object's shape is up-to-date. **See also** - [`execute(DynamicObject)`](com/oracle/truffle/api/object/DynamicObject.UpdateShapeNode.md#execute%28com.oracle.truffle.api.object.DynamicObject%29) ## Methods ### execute(DynamicObject) `public abstract boolean execute(DynamicObject receiver)`. Ensures the object's shape is up-to-date. If the object's shape has been marked as `invalid`, this method will attempt to bring the object into a valid shape again. If the object's shape is already `valid`, this method will have no effect. This method does not need to be called normally; all the messages in this library will work on invalid shapes as well, but it can be useful in some cases to avoid such shapes being cached which can cause unnecessary cache polymorphism and invalidations. Returns `boolean`: `true` if the object's shape was changed, otherwise `false`. Cite: `com/oracle/truffle/api/object/DynamicObject.UpdateShapeNode.html#execute(com.oracle.truffle.api.object.DynamicObject)` ### create() `public static DynamicObject.UpdateShapeNode create()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.UpdateShapeNode.html#create()` ### getUncached() `public static DynamicObject.UpdateShapeNode getUncached()`. Since 25.1. Cite: `com/oracle/truffle/api/object/DynamicObject.UpdateShapeNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DynamicObjectFactory [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). ```java public final class DynamicObjectFactory ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `DynamicObjectFactory` ## Constructors ### DynamicObjectFactory() `public DynamicObjectFactory()`. Declared by the compiler. Creates a new DynamicObjectFactory instance. Cite: `com/oracle/truffle/api/object/DynamicObjectFactory.html#()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DynamicObjectLibrary [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 20.2.0. ```java @Deprecated(since = "25.1") public abstract class DynamicObjectLibrary extends Library ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > [`Library`](com/oracle/truffle/api/library/Library.md) > `DynamicObjectLibrary` > **⊘ Deprecated since 25.1.** > > DynamicObjectLibrary has been replaced by more lightweight DynamicObject nodes. Consult the javadoc of the individual messages for the corresponding API replacement, or see [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md) for a list of new node-based APIs. [`DynamicObjectLibrary`](com/oracle/truffle/api/object/DynamicObjectLibrary.md) will be removed in a future release. [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md) access library. This is the central interface for accessing and mutating properties and other state (flags, dynamic type) of [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md)s. It is recommended that you use the [`CachedLibrary`](com/oracle/truffle/api/library/CachedLibrary.md) annotation in Truffle DSL nodes. You can also use the library either [without caching](com/oracle/truffle/api/object/DynamicObjectLibrary.md#getUncached%28%29) or create a [manually](com/oracle/truffle/api/library/LibraryFactory.md#create%28java.lang.Object%29) or [automatically](com/oracle/truffle/api/library/LibraryFactory.md#createDispatched%28int%29) dispatched cached library. Cached libraries must be adopted before use. The cached library instances dispatch by object [shape](com/oracle/truffle/api/object/Shape.md) and, if applicable, automatically by property key. Property keys are compared using object identity (`==`) first and then [`Object.equals(Object)`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29). It is therefore recommended to use the same string/key instances for each access of the property in order to avoid pulling in `equals`. Keys must not be `null`. Note: cached library nodes may not profile the class of the object parameter; it is therefore the caller's responsibility to do any desired profiling and ensure accurate type information. ### Usage examples: ```java @Specialization(limit = "3") static Object read(DynamicObject receiver, Object key, @CachedLibrary("receiver") DynamicObjectLibrary objLib) { return objLib.getOrDefault(receiver, key, NULL_VALUE); } ``` ```java @ExportMessage Object readMember(String name, @CachedLibrary("this") DynamicObjectLibrary objLib) throws UnknownIdentifierException { Object result = objLib.getOrDefault(this, name, null); if (result == null) { throw UnknownIdentifierException.create(name); } return result; } ``` **See also** - [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md) ## Methods ### getFactory() `public static LibraryFactory getFactory()`. Since 20.2.0. Returns the library factory for `DynamicObjectLibrary`. Cite: `com/oracle/truffle/api/object/DynamicObjectLibrary.html#getFactory()` ### getUncached() `public static DynamicObjectLibrary getUncached()`. Since 20.2.0. Gets the shared `DynamicObjectLibrary` instance for uncached accesses. Equivalent to `DynamicObjectLibrary.getFactory().getUncached()`. Returns `DynamicObjectLibrary`: an uncached automatically dispatched version of the library. Cite: `com/oracle/truffle/api/object/DynamicObjectLibrary.html#getUncached()` ### getShape(DynamicObject) `public abstract Shape getShape(DynamicObject object)`. Since 20.2.0. Gets the `shape` of the object. Returns the cached shape if the library is a cached library instance. Returns `Shape`: the object's current `Shape`. See also: `DynamicObject.getShape()`. Cite: `com/oracle/truffle/api/object/DynamicObjectLibrary.html#getShape(com.oracle.truffle.api.object.DynamicObject)` ### getOrDefault(DynamicObject, Object, Object) `public abstract Object getOrDefault(DynamicObject object, Object key, Object defaultValue)`. Since 20.2.0. Gets the value of an existing property or returns the provided default value if no such property exists. Usage example: Parameters: `key` `Object`: the property key. `defaultValue` `Object`: value to be returned if the property does not exist. Returns `Object`: the property's value if it exists, else `defaultValue`. See also: `DynamicObject.GetNode.execute(DynamicObject, Object, Object)`. Cite: `com/oracle/truffle/api/object/DynamicObjectLibrary.html#getOrDefault(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object)` ```java @Specialization(limit = "3") static Object read(DynamicObject receiver, Object key, @CachedLibrary("receiver") DynamicObjectLibrary objLib) { return objLib.getOrDefault(receiver, key, NULL_VALUE); } ``` ### getIntOrDefault(DynamicObject, Object, Object) `public int getIntOrDefault(DynamicObject object, Object key, Object defaultValue) throws UnexpectedResultException`. Since 20.2.0. Gets the value of an existing property or returns the provided default value if no such property exists. Parameters: `key` `Object`: the property key. `defaultValue` `Object`: the value to be returned if the property does not exist. Returns `int`: the property's value if it exists, else `defaultValue`. Throws: `UnexpectedResultException`: if the (default) value is not an `int`. See also: `getOrDefault(DynamicObject, Object, Object)`, `DynamicObject.GetNode.executeInt(DynamicObject, Object, Object)`. Cite: `com/oracle/truffle/api/object/DynamicObjectLibrary.html#getIntOrDefault(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object)` ### getDoubleOrDefault(DynamicObject, Object, Object) `public double getDoubleOrDefault(DynamicObject object, Object key, Object defaultValue) throws UnexpectedResultException`. Since 20.2.0. Gets the value of an existing property or returns the provided default value if no such property exists. Parameters: `key` `Object`: the property key. `defaultValue` `Object`: the value to be returned if the property does not exist. Returns `double`: the property's value if it exists, else `defaultValue`. Throws: `UnexpectedResultException`: if the (default) value is not a `double`. See also: `getOrDefault(DynamicObject, Object, Object)`, `DynamicObject.GetNode.executeDouble(DynamicObject, Object, Object)`. Cite: `com/oracle/truffle/api/object/DynamicObjectLibrary.html#getDoubleOrDefault(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object)` ### getLongOrDefault(DynamicObject, Object, Object) `public long getLongOrDefault(DynamicObject object, Object key, Object defaultValue) throws UnexpectedResultException`. Since 20.2.0. Gets the value of an existing property or returns the provided default value if no such property exists. Parameters: `key` `Object`: the property key. `defaultValue` `Object`: the value to be returned if the property does not exist. Returns `long`: the property's value if it exists, else `defaultValue`. Throws: `UnexpectedResultException`: if the (default) value is not a `long`. See also: `getOrDefault(DynamicObject, Object, Object)`, `DynamicObject.GetNode.executeLong(DynamicObject, Object, Object)`. Cite: `com/oracle/truffle/api/object/DynamicObjectLibrary.html#getLongOrDefault(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object)` ### put(DynamicObject, Object, Object) `public abstract void put(DynamicObject object, Object key, Object value)`. Since 20.2.0. Sets the value of an existing property or adds a new property if no such property exists. A newly added property will have flags 0; flags of existing properties will not be changed. Use `putWithFlags` to set property flags as well. Usage example: Parameters: `key` `Object`: the property key. `value` `Object`: the value to be set. See also: `putInt(DynamicObject, Object, int)`, `putDouble(DynamicObject, Object, double)`, `putLong(DynamicObject, Object, long)`, `putIfPresent(DynamicObject, Object, Object)`, `putWithFlags(DynamicObject, Object, Object, int)`, `DynamicObject.PutNode.execute(DynamicObject, Object, Object)`. Cite: `com/oracle/truffle/api/object/DynamicObjectLibrary.html#put(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object)` ```java @ExportMessage Object writeMember(String member, Object value, @CachedLibrary("this") DynamicObjectLibrary objLib) { objLib.put(this, member, value); } ``` ### putInt(DynamicObject, Object, int) `public void putInt(DynamicObject object, Object key, int value)`. Since 20.2.0. Int-typed variant of `put`. See also: `put(DynamicObject, Object, Object)`, `DynamicObject.PutNode.execute(DynamicObject, Object, Object)`. Cite: `com/oracle/truffle/api/object/DynamicObjectLibrary.html#putInt(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,int)` ### putDouble(DynamicObject, Object, double) `public void putDouble(DynamicObject object, Object key, double value)`. Since 20.2.0. Double-typed variant of `put`. See also: `put(DynamicObject, Object, Object)`, `DynamicObject.PutNode.execute(DynamicObject, Object, Object)`. Cite: `com/oracle/truffle/api/object/DynamicObjectLibrary.html#putDouble(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,double)` ### putLong(DynamicObject, Object, long) `public void putLong(DynamicObject object, Object key, long value)`. Since 20.2.0. Long-typed variant of `put`. See also: `put(DynamicObject, Object, Object)`, `DynamicObject.PutNode.execute(DynamicObject, Object, Object)`. Cite: `com/oracle/truffle/api/object/DynamicObjectLibrary.html#putLong(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,long)` ### putIfPresent(DynamicObject, Object, Object) `public abstract boolean putIfPresent(DynamicObject object, Object key, Object value)`. Since 20.2.0. Sets the value of the property if present, otherwise returns `false`. Parameters: `key` `Object`: property identifier. `value` `Object`: value to be set. Returns `boolean`: `true` if the property was present and the value set, otherwise `false`. See also: `put(DynamicObject, Object, Object)`, `DynamicObject.PutNode.executeIfPresent(DynamicObject, Object, Object)`. Cite: `com/oracle/truffle/api/object/DynamicObjectLibrary.html#putIfPresent(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object)` ### putWithFlags(DynamicObject, Object, …) `public abstract void putWithFlags(DynamicObject object, Object key, Object value, int flags)`. Since 20.2.0. Like `put`, but additionally assigns flags to the property. If the property already exists, its flags will be updated before the value is set. Parameters: `key` `Object`: property identifier. `value` `Object`: value to be set. `flags` `int`: flags to be set. See also: `put(DynamicObject, Object, Object)`, `setPropertyFlags(DynamicObject, Object, int)`, `DynamicObject.PutNode.executeWithFlags(DynamicObject, Object, Object, int)`. Cite: `com/oracle/truffle/api/object/DynamicObjectLibrary.html#putWithFlags(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object,int)` ### putConstant(DynamicObject, Object, …) `public abstract void putConstant(DynamicObject object, Object key, Object value, int flags)`. Since 20.2.0. Adds a property with a constant value or replaces an existing one. If the property already exists, its flags will be updated. The constant value is stored in the shape rather than the object instance and a new shape will be allocated if it does not already exist. A typical use case for this method is setting the initial default value of a declared, but yet uninitialized, property. This defers storage allocation and type speculation until the first actual value is set. Warning: this method will lead to a shape transition every time a new value is set and should be used sparingly (with at most one constant value per property) since it could cause an excessive amount of shapes to be created. Note: the value is strongly referenced from the shape property map. It should ideally be a value type or light-weight object without any references to guest language objects in order to prevent potential memory leaks from holding onto the Shape in inline caches. The Shape transition itself is weak, so the previous shapes will not hold strongly on the value. Usage example: Parameters: `key` `Object`: property identifier. `value` `Object`: the constant value to be set. `flags` `int`: property flags or 0. See also: `put(DynamicObject, Object, Object)`, `DynamicObject.PutConstantNode.execute(DynamicObject, Object, Object)`. Cite: `com/oracle/truffle/api/object/DynamicObjectLibrary.html#putConstant(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object,int)` ```java // declare property objLib.putConstant(receiver, key, NULL_VALUE, 0); // initialize property objLib.put(receiver, key, value); ``` ### removeKey(DynamicObject, Object) `public abstract boolean removeKey(DynamicObject object, Object key)`. Since 20.2.0. Removes the property with the given key from the object. Parameters: `key` `Object`: the property key. Returns `boolean`: `true` if the property was removed or `false` if property was not found. See also: `DynamicObject.RemoveKeyNode`. Cite: `com/oracle/truffle/api/object/DynamicObjectLibrary.html#removeKey(com.oracle.truffle.api.object.DynamicObject,java.lang.Object)` ### setDynamicType(DynamicObject, Object) `public abstract boolean setDynamicType(DynamicObject object, Object type)`. Since 20.2.0. Sets the object's dynamic type identifier. What this type represents is completely up to the language. For example, it could be a guest-language class. The type object is strongly referenced from the shape. It should ideally be a singleton or light-weight object without any references to guest language objects in order to keep the memory footprint low and prevent potential memory leaks from holding onto the Shape in inline caches. The Shape transition itself is weak, so the previous shapes will not hold strongly on the type object. Type objects are always compared by object identity, never `equals`. Parameters: `type` `Object`: a non-null type identifier defined by the guest language. Returns `boolean`: `true` if the type (and the object's shape) changed. See also: `getDynamicType(DynamicObject)`, `DynamicObject.SetDynamicTypeNode`. Cite: `com/oracle/truffle/api/object/DynamicObjectLibrary.html#setDynamicType(com.oracle.truffle.api.object.DynamicObject,java.lang.Object)` ### getDynamicType(DynamicObject) `public abstract Object getDynamicType(DynamicObject object)`. Since 20.2.0. Gets the dynamic type identifier currently associated with this object. What this type represents is completely up to the language. For example, it could be a guest-language class. Returns `Object`: the object type. See also: `setDynamicType(DynamicObject, Object)`, `Shape.getDynamicType()`, `DynamicObject.GetDynamicTypeNode`. Cite: `com/oracle/truffle/api/object/DynamicObjectLibrary.html#getDynamicType(com.oracle.truffle.api.object.DynamicObject)` ### containsKey(DynamicObject, Object) `public abstract boolean containsKey(DynamicObject object, Object key)`. Since 20.2.0. Returns `true` if this object contains a property with the given key. Usage example: Parameters: `key` `Object`: the property key. Returns `boolean`: `true` if the object contains a property with this key, else `false`. See also: `DynamicObject.ContainsKeyNode`. Cite: `com/oracle/truffle/api/object/DynamicObjectLibrary.html#containsKey(com.oracle.truffle.api.object.DynamicObject,java.lang.Object)` ```java @ExportMessage boolean isMemberReadable(String name, @CachedLibrary("this") DynamicObjectLibrary objLib) { return objLib.containsKey(this, name); } ``` ### getShapeFlags(DynamicObject) `public abstract int getShapeFlags(DynamicObject object)`. Since 20.2.0. Gets the language-specific object shape flags previously set using `DynamicObjectLibrary.setShapeFlags(DynamicObject, int)` or `Shape.Builder.shapeFlags(int)`. If no shape flags were explicitly set, the default of 0 is returned. These flags may be used to tag objects that possess characteristics that need to be queried efficiently on fast and slow paths. For example, they can be used to mark objects as frozen. Usage example: Returns `int`: shape flags. See also: `setShapeFlags(DynamicObject, int)`, `Shape.Builder.shapeFlags(int)`, `Shape.getFlags()`, `DynamicObject.GetShapeFlagsNode`. Cite: `com/oracle/truffle/api/object/DynamicObjectLibrary.html#getShapeFlags(com.oracle.truffle.api.object.DynamicObject)` ```java @ExportMessage Object writeMember(String member, Object value, @CachedLibrary("this") DynamicObjectLibrary objLib) throws UnsupportedMessageException { if ((objLib.getShapeFlags(receiver) & FROZEN) != 0) { throw UnsupportedMessageException.create(); } objLib.put(this, member, value); } ``` ### setShapeFlags(DynamicObject, int) `public abstract boolean setShapeFlags(DynamicObject object, int flags)`. Since 20.2.0. Sets language-specific object shape flags, changing the object's shape if need be. These flags may be used to tag objects that possess characteristics that need to be queried efficiently on fast and slow paths. For example, they can be used to mark objects as frozen. Only the lowest 16 bits (i.e. values in the range 0 to 65535) are allowed, the remaining bits are currently reserved. Usage example: Parameters: `flags` `int`: the flags to set; must be in the range from 0 to 255 (inclusive). Returns `boolean`: `true` if the object's shape changed, `false` if no change was made. Throws: `IllegalArgumentException` (unchecked): if the flags are not in the allowed range. See also: `getShapeFlags(DynamicObject)`, `Shape.Builder.shapeFlags(int)`, `DynamicObject.SetShapeFlagsNode`. Cite: `com/oracle/truffle/api/object/DynamicObjectLibrary.html#setShapeFlags(com.oracle.truffle.api.object.DynamicObject,int)` ```java @Specialization(limit = "3") static void preventExtensions(DynamicObject receiver, @CachedLibrary("receiver") DynamicObjectLibrary objLib) { objLib.setShapeFlags(receiver, objLib.getShapeFlags(receiver) | FROZEN); } ``` ### getProperty(DynamicObject, Object) `public abstract Property getProperty(DynamicObject object, Object key)`. Since 20.2.0. Gets a property descriptor for the requested property key. Returns `null` if the object contains no such property. Returns `Property`: `Property` if the property exists, else `null`. See also: `DynamicObject.GetPropertyNode`. Cite: `com/oracle/truffle/api/object/DynamicObjectLibrary.html#getProperty(com.oracle.truffle.api.object.DynamicObject,java.lang.Object)` ### getPropertyFlagsOrDefault(DynamicObject, Object, int) `public final int getPropertyFlagsOrDefault(DynamicObject object, Object key, int defaultValue)`. Since 20.2.0. Gets the property flags associated with the requested property key. Returns the `defaultValue` if the object contains no such property. If the property exists but no flags were explicitly set, returns the default of 0. Convenience method equivalent to: Parameters: `key` `Object`: the property key. `defaultValue` `int`: value to return if no such property exists. Returns `int`: the property flags if the property exists, else `defaultValue`. See also: `getProperty(DynamicObject, Object)`, `DynamicObject.GetPropertyFlagsNode`. Cite: `com/oracle/truffle/api/object/DynamicObjectLibrary.html#getPropertyFlagsOrDefault(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,int)` ```java Property property = getProperty(object, key); return property != null ? property.getFlags() : defaultValue; ``` ### setPropertyFlags(DynamicObject, Object, int) `public abstract boolean setPropertyFlags(DynamicObject object, Object key, int propertyFlags)`. Since 20.2.0. Sets the property flags associated with the requested property. Parameters: `key` `Object`: the property key. Returns `boolean`: `true` if the property was found and its flags were changed, else `false`. See also: `DynamicObject.SetPropertyFlagsNode`. Cite: `com/oracle/truffle/api/object/DynamicObjectLibrary.html#setPropertyFlags(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,int)` ### markShared(DynamicObject) `public abstract void markShared(DynamicObject object)`. Since 20.2.0. Marks this object as shared. Makes the object use a shared variant of the `Shape`, to allow safe usage of this object between threads. Objects with a shared `Shape` will not reuse storage locations for other fields. In combination with careful synchronization on writes, this can prevent reading out-of-thin-air values. Throws: `UnsupportedOperationException` (unchecked): if the object is already shared. See also: `isShared(DynamicObject)`, `DynamicObject.MarkSharedNode`. Cite: `com/oracle/truffle/api/object/DynamicObjectLibrary.html#markShared(com.oracle.truffle.api.object.DynamicObject)` ### isShared(DynamicObject) `public abstract boolean isShared(DynamicObject object)`. Since 20.2.0. Checks whether this object is marked as shared. Returns `boolean`: `true` if the object is shared. See also: `markShared(DynamicObject)`, `Shape.isShared()`, `DynamicObject.IsSharedNode`. Cite: `com/oracle/truffle/api/object/DynamicObjectLibrary.html#isShared(com.oracle.truffle.api.object.DynamicObject)` ### updateShape(DynamicObject) `public abstract boolean updateShape(DynamicObject object)`. Since 20.2.0. Ensures the object's shape is up-to-date. If the object's shape has been marked as invalid, this method will attempt to bring the object into a valid shape again. If the object's shape is already valid, this method will have no effect. This method does not need to be called normally; all the messages in this library will work on invalid shapes as well, but it can be useful in some cases to avoid such shapes being cached which can cause unnecessary cache polymorphism and invalidations. Returns `boolean`: `true` if the object's shape was changed, otherwise `false`. See also: `DynamicObject.UpdateShapeNode`. Cite: `com/oracle/truffle/api/object/DynamicObjectLibrary.html#updateShape(com.oracle.truffle.api.object.DynamicObject)` ### resetShape(DynamicObject, Shape) `public abstract boolean resetShape(DynamicObject object, Shape otherShape)`. Since 20.2.0. Empties and resets the object to the given root shape, which must not contain any instance properties (but may contain properties with a constant value). Parameters: `otherShape` `Shape`: the desired shape. Returns `boolean`: `true` if the object's shape was changed. Throws: `IllegalArgumentException` (unchecked): if the shape contains instance properties. See also: `DynamicObject.ResetShapeNode`. Cite: `com/oracle/truffle/api/object/DynamicObjectLibrary.html#resetShape(com.oracle.truffle.api.object.DynamicObject,com.oracle.truffle.api.object.Shape)` ### getKeyArray(DynamicObject) `public abstract Object[] getKeyArray(DynamicObject object)`. Since 20.2.0. Gets a snapshot of the object's property keys, in insertion order. The returned array may have been cached and must not be mutated. Properties with a `HiddenKey` are not included. Usage example: The example below shows how the returned keys array could be translated to an interop array for use with InteropLibrary. Returns `Object[]`: a read-only array of the object's property keys. See also: `DynamicObject.GetKeyArrayNode`. Cite: `com/oracle/truffle/api/object/DynamicObjectLibrary.html#getKeyArray(com.oracle.truffle.api.object.DynamicObject)` ```java @ExportMessage Object getMembers( @CachedLibrary("this") DynamicObjectLibrary objLib) { return new Keys(objLib.getKeyArray(this)); } @ExportLibrary(InteropLibrary.class) static final class Keys implements TruffleObject { @CompilationFinal(dimensions = 1) final Object[] keys; Keys(Object[] keys) { this.keys = keys; } @ExportMessage boolean hasArrayElements() { return true; } @ExportMessage Object readArrayElement(long index) throws InvalidArrayIndexException { if (!isArrayElementReadable(index)) { throw InvalidArrayIndexException.create(index); } return keys[(int) index]; } @ExportMessage long getArraySize() { return keys.length; } @ExportMessage boolean isArrayElementReadable(long index) { return index >= 0 && index < keys.length; } } ``` ### getPropertyArray(DynamicObject) `public abstract Property[] getPropertyArray(DynamicObject object)`. Since 20.2.0. Gets an array snapshot of the object's properties, in insertion order. The returned array may have been cached and must not be mutated. Properties with a `HiddenKey` are not included. Similar to `getKeyArray` but allows the properties' flags to be queried simultaneously which may be relevant for quick filtering. Returns `Property[]`: a read-only array of the object's properties. See also: `getKeyArray(DynamicObject)`, `DynamicObject.GetPropertyArrayNode`. Cite: `com/oracle/truffle/api/object/DynamicObjectLibrary.html#getPropertyArray(com.oracle.truffle.api.object.DynamicObject)` ## Inherited members - From class [`Library`](com/oracle/truffle/api/library/Library.md): [`accepts`](com/oracle/truffle/api/library/Library.md#accepts%28java.lang.Object%29) - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ⚡︎ FinalLocationException [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Exception in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 0.8 or earlier. ```java @Deprecated(since = "22.2") public final class FinalLocationException extends SlowPathException ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) > [`Exception`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Exception.html) > [`SlowPathException`](com/oracle/truffle/api/nodes/SlowPathException.md) > `FinalLocationException` > **⊘ Deprecated since 22.2.** This exception is thrown on an attempt to assign a value to a final location. ## Inherited members - From class [`SlowPathException`](com/oracle/truffle/api/nodes/SlowPathException.md): [`fillInStackTrace`](com/oracle/truffle/api/nodes/SlowPathException.md#fillInStackTrace%28%29) - From class [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html): [`addSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#addSuppressed%28java.lang.Throwable%29), [`getCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getCause%28%29), [`getLocalizedMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getLocalizedMessage%28%29), [`getMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getMessage%28%29), [`getStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getStackTrace%28%29), [`getSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getSuppressed%28%29), [`initCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#initCause%28java.lang.Throwable%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintStream%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintWriter%29), [`setStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#setStackTrace%28java.lang.StackTraceElement[]%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ HiddenKey [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 0.8 or earlier. ```java public final class HiddenKey implements TruffleObject ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `HiddenKey` Implements: [`TruffleObject`](com/oracle/truffle/api/interop/TruffleObject.md) A unique key to be used for private object fields; excluded from enumeration and compared by object identity. ## Constructors ### HiddenKey(String) `public HiddenKey(String name)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/object/HiddenKey.html#(java.lang.String)` ## Methods ### getName() `public String getName()`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/object/HiddenKey.html#getName()` ### toString() `public String toString()`. Since 0.8 or earlier. Overrides `toString()`. Cite: `com/oracle/truffle/api/object/HiddenKey.html#toString()` ### equals(Object) `public boolean equals(Object obj)`. Since 0.27. Overrides `equals(java.lang.Object)`. Cite: `com/oracle/truffle/api/object/HiddenKey.html#equals(java.lang.Object)` ### hashCode() `public int hashCode()`. Since 0.27. Overrides `hashCode()`. Cite: `com/oracle/truffle/api/object/HiddenKey.html#hashCode()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ⚡︎ IncompatibleLocationException [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Exception in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 0.8 or earlier. ```java @Deprecated(since = "22.2") public final class IncompatibleLocationException extends SlowPathException ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) > [`Exception`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Exception.html) > [`SlowPathException`](com/oracle/truffle/api/nodes/SlowPathException.md) > `IncompatibleLocationException` > **⊘ Deprecated since 22.2.** This exception is thrown on an attempt to assign an incompatible value to a location. ## Inherited members - From class [`SlowPathException`](com/oracle/truffle/api/nodes/SlowPathException.md): [`fillInStackTrace`](com/oracle/truffle/api/nodes/SlowPathException.md#fillInStackTrace%28%29) - From class [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html): [`addSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#addSuppressed%28java.lang.Throwable%29), [`getCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getCause%28%29), [`getLocalizedMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getLocalizedMessage%28%29), [`getMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getMessage%28%29), [`getStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getStackTrace%28%29), [`getSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getSuppressed%28%29), [`initCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#initCause%28java.lang.Throwable%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintStream%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintWriter%29), [`setStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#setStackTrace%28java.lang.StackTraceElement[]%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ IntLocation [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 0.8 or earlier. ```java @Deprecated(since = "22.2") public interface IntLocation ``` > **⊘ Deprecated since 22.2.** Int-typed storage location. **See also** - [`Location`](com/oracle/truffle/api/object/Location.md) - [`DynamicObjectLibrary.getIntOrDefault`](com/oracle/truffle/api/object/DynamicObjectLibrary.md#getIntOrDefault%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object,java.lang.Object%29) - [`DynamicObjectLibrary.putInt`](com/oracle/truffle/api/object/DynamicObjectLibrary.md#putInt%28com.oracle.truffle.api.object.DynamicObject,java.lang.Object,int%29) ## Methods ### getInt(DynamicObject, boolean) `@Deprecated(since = "22.2") int getInt(DynamicObject store, boolean condition)`. Since 0.8 or earlier. Deprecated since 22.2. See also: `Location.get(DynamicObject, boolean)`. Cite: `com/oracle/truffle/api/object/IntLocation.html#getInt(com.oracle.truffle.api.object.DynamicObject,boolean)` ### setInt(DynamicObject, int, Shape) `@Deprecated(since = "22.2") void setInt(DynamicObject store, int value, Shape shape) throws FinalLocationException`. Since 0.8 or earlier. Deprecated since 22.2. See also: `Location.set(DynamicObject, Object, Shape)`. Cite: `com/oracle/truffle/api/object/IntLocation.html#setInt(com.oracle.truffle.api.object.DynamicObject,int,com.oracle.truffle.api.object.Shape)` # ◆ Location [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Sealed abstract class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 0.8 or earlier. ```java public abstract sealed class Location permits ExtLocations.InstanceLocation, ExtLocations.ValueLocation ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Location` Permitted subtypes: `ExtLocations.InstanceLocation`, `ExtLocations.ValueLocation` Property location. Planned to be deprecated. **See also** - [`Shape`](com/oracle/truffle/api/object/Shape.md) - [`Property`](com/oracle/truffle/api/object/Property.md) - [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md) ## Methods ### get(DynamicObject, Shape) `@Deprecated(since = "22.2") public final Object get(DynamicObject store, Shape shape)`. Since 0.8 or earlier. Deprecated since 22.2. Get object value as object at this location in store. Parameters: `shape` `Shape`: the current shape of the object, which must contain this location. Cite: `com/oracle/truffle/api/object/Location.html#get(com.oracle.truffle.api.object.DynamicObject,com.oracle.truffle.api.object.Shape)` ### get(DynamicObject, boolean) `@Deprecated(since = "22.2") public Object get(DynamicObject store, boolean condition)`. Since 0.8 or earlier. Deprecated since 22.2. Get object value as object at this location in store. For internal use only and subject to change, use `get(DynamicObject, Shape)` instead. Parameters: `store` `DynamicObject`: storage object. `condition` `boolean`: the result of a shape check or `false`. See also: `get(DynamicObject, Shape)`. Cite: `com/oracle/truffle/api/object/Location.html#get(com.oracle.truffle.api.object.DynamicObject,boolean)` ### get(DynamicObject) `@Deprecated(since = "22.2") public final Object get(DynamicObject store)`. Since 0.8 or earlier. Deprecated since 22.2. Get object value as object at this location in store. Cite: `com/oracle/truffle/api/object/Location.html#get(com.oracle.truffle.api.object.DynamicObject)` ### getInt(DynamicObject, boolean) `protected int getInt(DynamicObject store, boolean guard) throws UnexpectedResultException`. Since 22.2. Gets this location's value as int. Parameters: `store` `DynamicObject`: storage object. `guard` `boolean`: the result of a shape check or `false`. Throws: `UnexpectedResultException`: if the location does not contain an int value. Cite: `com/oracle/truffle/api/object/Location.html#getInt(com.oracle.truffle.api.object.DynamicObject,boolean)` ### getLong(DynamicObject, boolean) `protected long getLong(DynamicObject store, boolean guard) throws UnexpectedResultException`. Since 22.2. Gets this location's value as long. Parameters: `store` `DynamicObject`: storage object. `guard` `boolean`: the result of a shape check or `false`. Throws: `UnexpectedResultException`: if the location does not contain a long value. Cite: `com/oracle/truffle/api/object/Location.html#getLong(com.oracle.truffle.api.object.DynamicObject,boolean)` ### getDouble(DynamicObject, boolean) `protected double getDouble(DynamicObject store, boolean guard) throws UnexpectedResultException`. Since 22.2. Gets this location's value as double. Parameters: `store` `DynamicObject`: storage object. `guard` `boolean`: the result of a shape check or `false`. Throws: `UnexpectedResultException`: if the location does not contain a double value. Cite: `com/oracle/truffle/api/object/Location.html#getDouble(com.oracle.truffle.api.object.DynamicObject,boolean)` ### set(DynamicObject, Object, Shape) `@Deprecated(since = "22.2") public void set(DynamicObject store, Object value, Shape shape) throws IncompatibleLocationException, FinalLocationException`. Since 0.8 or earlier. Deprecated since 22.2. Set object value at this location in store. Parameters: `store` `DynamicObject`: storage object. `value` `Object`: the value to set. `shape` `Shape`: the current shape of the storage object. Throws: `IncompatibleLocationException`: for storage type invalidations. `FinalLocationException`: for effectively final fields. Cite: `com/oracle/truffle/api/object/Location.html#set(com.oracle.truffle.api.object.DynamicObject,java.lang.Object,com.oracle.truffle.api.object.Shape)` ### canStore(Object) `public boolean canStore(Object value)`. Since 0.8 or earlier. Returns `true` if the location is compatible with the type of the value. Parameters: `value` `Object`: the value in question. Cite: `com/oracle/truffle/api/object/Location.html#canStore(java.lang.Object)` ### isFinal() `@Deprecated(since = "25.1") public boolean isFinal()`. Since 0.8 or earlier. Deprecated since 25.1. Use `isAssumedFinal()` instead or replace by `false`. Returns `true` if this is a final location, i.e. readonly once set. See also: `isAssumedFinal()`. Cite: `com/oracle/truffle/api/object/Location.html#isFinal()` ### isConstant() `public boolean isConstant()`. Since 0.8 or earlier. Returns `true` if this is a constant value location. Cite: `com/oracle/truffle/api/object/Location.html#isConstant()` ### hashCode() `public int hashCode()`. Since 0.8 or earlier. Must be overridden in subclasses. Overrides `hashCode()`. Cite: `com/oracle/truffle/api/object/Location.html#hashCode()` ### equals(Object) `public boolean equals(Object obj)`. Since 0.8 or earlier. Must be overridden in subclasses. Overrides `equals(java.lang.Object)`. Cite: `com/oracle/truffle/api/object/Location.html#equals(java.lang.Object)` ### toString() `public String toString()`. Since 0.8 or earlier. Overrides `toString()`. Cite: `com/oracle/truffle/api/object/Location.html#toString()` ### isValue() `public boolean isValue()`. Since 0.18. Returns `true` if this is a value location. See also: `isConstant()`. Cite: `com/oracle/truffle/api/object/Location.html#isValue()` ### isAssumedFinal() `public boolean isAssumedFinal()`. Since 0.18. Returns `true` if this location is assumed to be final. See also: `getFinalAssumption()`. Cite: `com/oracle/truffle/api/object/Location.html#isAssumedFinal()` ### getFinalAssumption() `public Assumption getFinalAssumption()`. Since 0.18. Returns the assumption that this location is final. See also: `isAssumedFinal()`. Cite: `com/oracle/truffle/api/object/Location.html#getFinalAssumption()` ### isPrimitive() `public boolean isPrimitive()`. Since 22.2. Returns `true` if this location can only store primitive types and cannot contain any object references. Cite: `com/oracle/truffle/api/object/Location.html#isPrimitive()` ### getConstantValue() `public Object getConstantValue()`. Since 22.2. If this is a constant location, returns the constant value bound to this location. Otherwise, returns null. Cite: `com/oracle/truffle/api/object/Location.html#getConstantValue()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ Property [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 0.8 or earlier. ```java public final class Property ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Property` Property objects represent the mapping between property identifiers (keys) and storage locations. Optionally, properties may have metadata attached to them. ## Methods ### getKey() `public Object getKey()`. Since 0.8 or earlier. Get property identifier. Cite: `com/oracle/truffle/api/object/Property.html#getKey()` ### getFlags() `public int getFlags()`. Since 0.8 or earlier. Get property flags, which are free for language-specific use. Cite: `com/oracle/truffle/api/object/Property.html#getFlags()` ### getLocation() `public Location getLocation()`. Since 0.8 or earlier. Get the property location. Planned to be deprecated. Cite: `com/oracle/truffle/api/object/Property.html#getLocation()` ### isHidden() `public boolean isHidden()`. Since 0.8 or earlier. Is this property hidden from iteration. See also: `HiddenKey`. Cite: `com/oracle/truffle/api/object/Property.html#isHidden()` ### equals(Object) `public boolean equals(Object obj)`. Since 0.8 or earlier. Overrides `equals(java.lang.Object)`. Cite: `com/oracle/truffle/api/object/Property.html#equals(java.lang.Object)` ### hashCode() `public int hashCode()`. Since 0.8 or earlier. Overrides `hashCode()`. Cite: `com/oracle/truffle/api/object/Property.html#hashCode()` ### toString() `public String toString()`. Since 0.8 or earlier. Overrides `toString()`. Cite: `com/oracle/truffle/api/object/Property.html#toString()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ PropertyGetter [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 22.2. ```java public final class PropertyGetter ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `PropertyGetter` A lightweight property getter that allows getting the value of a [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md) [property](com/oracle/truffle/api/object/Property.md) without any lookup or cache dispatch. Only objects of a specific [`Shape`](com/oracle/truffle/api/object/Shape.md) are [accepted](com/oracle/truffle/api/object/PropertyGetter.md#accepts%28com.oracle.truffle.api.object.DynamicObject%29). Therefore, it should only be used where the object is already known to have the supported shape. **See also** - [`Shape.makePropertyGetter(Object)`](com/oracle/truffle/api/object/Shape.md#makePropertyGetter%28java.lang.Object%29) - [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md) ## Methods ### accepts(DynamicObject) `public boolean accepts(DynamicObject receiver)`. Since 22.2. Returns `true` if this `PropertyGetter` can be used with the given receiver object to get the property's value. Parameters: `receiver` `DynamicObject`: the receiver object. Returns `boolean`: `true` if the shape of the receiver object is supported by this `PropertyGetter`. See also: `get(DynamicObject)`. Cite: `com/oracle/truffle/api/object/PropertyGetter.html#accepts(com.oracle.truffle.api.object.DynamicObject)` ### get(DynamicObject) `public Object get(DynamicObject receiver)`. Since 22.2. Gets the property's value from the given receiver object if the object has the supported `Shape`, i.e. the shape this property getter was created with. Otherwise, throws an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html). Parameters: `receiver` `DynamicObject`: the receiver object. Returns `Object`: the property's value. Throws: `IllegalArgumentException` (unchecked): if the object does not have the expected shape. Cite: `com/oracle/truffle/api/object/PropertyGetter.html#get(com.oracle.truffle.api.object.DynamicObject)` ### getInt(DynamicObject) `public int getInt(DynamicObject receiver) throws UnexpectedResultException`. Since 22.2. Gets the property's value from the given receiver object if the object has the supported `Shape`. Expects an `int` value or throws an `UnexpectedResultException` if the value is of a different type. If the object's shape is not supported, throws an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html). Parameters: `receiver` `DynamicObject`: the receiver object. Returns `int`: the property's value. Throws: `IllegalArgumentException` (unchecked): if the object does not have the expected shape. `UnexpectedResultException`: if the location does not contain an int value. See also: `get(DynamicObject)`. Cite: `com/oracle/truffle/api/object/PropertyGetter.html#getInt(com.oracle.truffle.api.object.DynamicObject)` ### getLong(DynamicObject) `public long getLong(DynamicObject receiver) throws UnexpectedResultException`. Since 22.2. Gets the property's value from the given receiver object if the object has the supported `Shape`. Expects a `long` value or throws an `UnexpectedResultException` if the value is of a different type. If the object's shape is not supported, throws an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html). Parameters: `receiver` `DynamicObject`: the receiver object. Returns `long`: the property's value. Throws: `IllegalArgumentException` (unchecked): if the object does not have the expected shape. `UnexpectedResultException`: if the location does not contain a long value. See also: `get(DynamicObject)`. Cite: `com/oracle/truffle/api/object/PropertyGetter.html#getLong(com.oracle.truffle.api.object.DynamicObject)` ### getDouble(DynamicObject) `public double getDouble(DynamicObject receiver) throws UnexpectedResultException`. Since 22.2. Gets the property's value from the given receiver object if the object has the supported `Shape`. Expects a `double` value or throws an `UnexpectedResultException` if the value is of a different type. If the object's shape is not supported, throws an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html). Parameters: `receiver` `DynamicObject`: the receiver object. Returns `double`: the property's value. Throws: `IllegalArgumentException` (unchecked): if the object does not have the expected shape. `UnexpectedResultException`: if the location does not contain a double value. See also: `get(DynamicObject)`. Cite: `com/oracle/truffle/api/object/PropertyGetter.html#getDouble(com.oracle.truffle.api.object.DynamicObject)` ### getKey() `public Object getKey()`. Since 22.2. Returns the key of the property represented by this getter. See also: `Property.getKey()`. Cite: `com/oracle/truffle/api/object/PropertyGetter.html#getKey()` ### getFlags() `public int getFlags()`. Since 22.2. Returns the flags associated with the property represented by this getter. See also: `Property.getFlags()`. Cite: `com/oracle/truffle/api/object/PropertyGetter.html#getFlags()` ### getShape() `public Shape getShape()`. Since 25.5. Returns the shape this property getter was created with. Only objects of this exact shape are accepted by this property getter. This allows the property getter's shape to be used in a specialization without occupying another cached field, for example, to perform its own shape-based guards: Returns `Shape`: the accepted shape. See also: `accepts(DynamicObject)`, `Shape.makePropertyGetter(Object)`. Cite: `com/oracle/truffle/api/object/PropertyGetter.html#getShape()` ```java @Specialization(guards = {"getter != null", "getter.accepts(receiver)", "!hasDict(getter.getShape())"}, limit = "3") static Object doGet(Object key, DynamicObject receiver, @Cached("receiver.getShape().makePropertyGetter(key)") PropertyGetter getter) { return getter.get(receiver); } ``` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ Shape [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 0.8 or earlier. ```java public final class Shape ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Shape` A Shape is an immutable descriptor of the current object "shape" of a DynamicObject, i.e., object layout, metadata ([type](com/oracle/truffle/api/object/Shape.md#getDynamicType%28%29), [flags](com/oracle/truffle/api/object/Shape.md#getFlags%28%29)), and a mapping of [properties](com/oracle/truffle/api/object/Property.md) to storage locations. This allows cached [`DynamicObjectLibrary`](com/oracle/truffle/api/object/DynamicObjectLibrary.md) to do a simple shape check to determine the contents of an object and do fast, constant-time property accesses. Shape changes, like adding or removing a property, yield a new Shape derived from the old one. Shapes are shared between objects that assume the same shape if they follow the same shape transitions, like adding the same properties in the same order, starting from a common root shape. Shape transitions are automatically, weakly cached. Dynamic objects start off with an initial shape that has no instance properties (but may have constant properties that are stored in the shape). Initial shapes are created via [`Shape.newBuilder()`](com/oracle/truffle/api/object/Shape.md#newBuilder%28%29). **See also** - [`DynamicObject`](com/oracle/truffle/api/object/DynamicObject.md) - [`Shape.newBuilder()`](com/oracle/truffle/api/object/Shape.md#newBuilder%28%29) - [`Property`](com/oracle/truffle/api/object/Property.md) ## Nested types - [`Shape.Builder`](com/oracle/truffle/api/object/Shape.Builder.md) (class): Builder class to construct initial Shape instances. - [`Shape.DerivedBuilder`](com/oracle/truffle/api/object/Shape.DerivedBuilder.md) (class): Builder class to construct derived Shape instances. ## Methods ### newBuilder() `public static Shape.Builder newBuilder()`. Since 20.2.0. Creates a new initial shape builder. The builder instance is not thread-safe and must not be used from multiple threads at the same time. Cite: `com/oracle/truffle/api/object/Shape.html#newBuilder()` ### newBuilder(Shape) `public static Shape.DerivedBuilder newBuilder(Shape baseShape)`. Since 20.2.0. Creates a new derived shape builder that allows changing a root shape's flags and dynamic type and adding constant properties. The builder instance is not thread-safe and must not be used from multiple threads at the same time. Parameters: `baseShape` `Shape`: the shape to be modified. See also: `Shape.newBuilder()`. Cite: `com/oracle/truffle/api/object/Shape.html#newBuilder(com.oracle.truffle.api.object.Shape)` ### getProperty(Object) `public Property getProperty(Object key)`. Since 0.8 or earlier. Get a property entry by key. Parameters: `key` `Object`: the identifier to look up. Returns `Property`: a Property object, or `null` if not found. Cite: `com/oracle/truffle/api/object/Shape.html#getProperty(java.lang.Object)` ### addProperty(Property) `protected Shape addProperty(Property property)`. Since 0.8 or earlier. Add a new property in the map, yielding a new or cached Shape object. Parameters: `property` `Property`: the property to add. Returns `Shape`: the new Shape. Cite: `com/oracle/truffle/api/object/Shape.html#addProperty(com.oracle.truffle.api.object.Property)` ### defineProperty(Object, Object, …) `protected Shape defineProperty(Object key, Object value, int propertyFlags, int putFlags)`. Since 24.1. Add or change property in the map, yielding a new or cached Shape object. Returns `Shape`: the shape after defining the property. Cite: `com/oracle/truffle/api/object/Shape.html#defineProperty(java.lang.Object,java.lang.Object,int,int)` ### getProperties() `public Iterable getProperties()`. Since 0.8 or earlier. An [`Iterable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Iterable.html) over the shape's properties in insertion order. Cite: `com/oracle/truffle/api/object/Shape.html#getProperties()` ### getPropertyList() `public List getPropertyList()`. Since 0.8 or earlier. Get a list of all properties that this Shape stores. Properties with a `HiddenKey` are not included. Returns `List`: list of properties. Cite: `com/oracle/truffle/api/object/Shape.html#getPropertyList()` ### getPropertyListInternal(boolean) `public List getPropertyListInternal(boolean ascending)`. Since 0.8 or earlier. Returns all (also hidden) property objects in this shape. Parameters: `ascending` `boolean`: desired order (`true` for insertion order, `false` for reverse insertion order). Cite: `com/oracle/truffle/api/object/Shape.html#getPropertyListInternal(boolean)` ### getKeyList() `public List getKeyList()`. Since 0.8 or earlier. Get a list of all property keys in insertion order. Properties with a `HiddenKey` are not included. Cite: `com/oracle/truffle/api/object/Shape.html#getKeyList()` ### getKeys() `public Iterable getKeys()`. Since 0.8 or earlier. Get all property keys in insertion order. Cite: `com/oracle/truffle/api/object/Shape.html#getKeys()` ### getValidAssumption() `public Assumption getValidAssumption()`. Since 0.8 or earlier. Get an assumption that the shape is valid. Cite: `com/oracle/truffle/api/object/Shape.html#getValidAssumption()` ### isValid() `public boolean isValid()`. Since 0.8 or earlier. Check whether this shape is valid. Cite: `com/oracle/truffle/api/object/Shape.html#isValid()` ### getLeafAssumption() `public Assumption getLeafAssumption()`. Since 0.8 or earlier. Get an assumption that the shape is a leaf. Cite: `com/oracle/truffle/api/object/Shape.html#getLeafAssumption()` ### isLeaf() `public boolean isLeaf()`. Since 0.8 or earlier. Check whether this shape is a leaf in the transition graph, i.e. transitionless. Cite: `com/oracle/truffle/api/object/Shape.html#isLeaf()` ### hasProperty(Object) `public boolean hasProperty(Object name)`. Since 0.8 or earlier. Check whether the shape has a property with the given key. Cite: `com/oracle/truffle/api/object/Shape.html#hasProperty(java.lang.Object)` ### removeProperty(Property) `protected Shape removeProperty(Property property)`. Since 0.8 or earlier. Remove the given property from the shape. Cite: `com/oracle/truffle/api/object/Shape.html#removeProperty(com.oracle.truffle.api.object.Property)` ### replaceProperty(Property, Property) `protected Shape replaceProperty(Property oldProperty, Property newProperty)`. Since 0.8 or earlier. Replace a property in the shape. Cite: `com/oracle/truffle/api/object/Shape.html#replaceProperty(com.oracle.truffle.api.object.Property,com.oracle.truffle.api.object.Property)` ### getLastProperty() `public Property getLastProperty()`. Since 0.8 or earlier. Gets the last property. Returns `Property`: the last property in the shape or `null` if empty. Cite: `com/oracle/truffle/api/object/Shape.html#getLastProperty()` ### getFirstProperty() `public Property getFirstProperty()`. Since 25.1. Gets the first property. Returns `Property`: the first property in the shape or `null` if empty. Cite: `com/oracle/truffle/api/object/Shape.html#getFirstProperty()` ### getFlags() `public int getFlags()`. Since 20.2.0. Returns the language-specific shape flags previously set using `DynamicObjectLibrary.setShapeFlags(DynamicObject, int)` or `Shape.Builder.shapeFlags(int)`. If no shape flags were explicitly set, the default of 0 is returned. These flags may be used to tag objects that possess characteristics that need to be queried efficiently on fast and slow paths. For example, they can be used to mark objects as frozen. See also: `DynamicObjectLibrary.getShapeFlags(DynamicObject)`, `DynamicObjectLibrary.setShapeFlags(DynamicObject, int)`, `Shape.Builder.shapeFlags(int)`. Cite: `com/oracle/truffle/api/object/Shape.html#getFlags()` ### setFlags(int) `protected Shape setFlags(int objectFlags)`. Since 20.2.0. Returns a copy of the shape, with the shape flags set to `newFlags`. Parameters: `objectFlags` `int`: the new shape flags; an int value in the range from 0 to 65535 (inclusive). Throws: `IllegalArgumentException` (unchecked): if the flags value is not in the supported range. See also: `Shape.Builder.shapeFlags(int)`. Cite: `com/oracle/truffle/api/object/Shape.html#setFlags(int)` ### getPropertyCount() `public int getPropertyCount()`. Since 0.8 or earlier. Returns the number of properties in this shape. Cite: `com/oracle/truffle/api/object/Shape.html#getPropertyCount()` ### getDynamicType() `public Object getDynamicType()`. Since 20.2.0. Get the shape's dynamic object type identifier. Cite: `com/oracle/truffle/api/object/Shape.html#getDynamicType()` ### setDynamicType(Object) `protected Shape setDynamicType(Object dynamicType)`. Since 20.2.0. Returns a copy of the shape, with the dynamic object type identifier set to `dynamicType`. Parameters: `dynamicType` `Object`: the new dynamic object type identifier. Throws: `NullPointerException` (unchecked): if the argument is null. See also: `Shape.Builder.dynamicType(Object)`. Cite: `com/oracle/truffle/api/object/Shape.html#setDynamicType(java.lang.Object)` ### getRoot() `public Shape getRoot()`. Since 0.8 or earlier. Get the root shape. Planned to be deprecated. Cite: `com/oracle/truffle/api/object/Shape.html#getRoot()` ### check(DynamicObject) `public boolean check(DynamicObject subject)`. Since 0.8 or earlier. Checks whether the given object's shape is identical to this shape. Cite: `com/oracle/truffle/api/object/Shape.html#check(com.oracle.truffle.api.object.DynamicObject)` ### getLayoutClass() `public Class getLayoutClass()`. Since 21.1. Get the shape's layout class. See also: `Shape.Builder.layout(Class, Lookup)`. Cite: `com/oracle/truffle/api/object/Shape.html#getLayoutClass()` ### getSharedData() `public Object getSharedData()`. Since 0.8 or earlier. Get the shape's shared data. See also: `Shape.Builder.sharedData(Object)`. Cite: `com/oracle/truffle/api/object/Shape.html#getSharedData()` ### tryMerge(Shape) `public Shape tryMerge(Shape other)`. Since 0.8 or earlier. Try to merge two related shapes to a more general shape that has the same properties and can store at least the values of both shapes. Returns `Shape`: this, other, or a new shape that is compatible with both shapes. Cite: `com/oracle/truffle/api/object/Shape.html#tryMerge(com.oracle.truffle.api.object.Shape)` ### isShared() `public boolean isShared()`. Since 0.18. Returns `true` if this shape is marked as shared. See also: `DynamicObjectLibrary.isShared(DynamicObject)`, `DynamicObjectLibrary.markShared(DynamicObject)`, `Shape.Builder.shared(boolean)`. Cite: `com/oracle/truffle/api/object/Shape.html#isShared()` ### makeSharedShape() `public Shape makeSharedShape()`. Since 0.18. Make a shared variant of this shape, to allow safe usage of this object between threads. Shared shapes will not reuse storage locations for other fields. In combination with careful synchronization on writes, this can prevent reading out-of-thin-air values. Note: Where possible, avoid using this method and use `DynamicObjectLibrary.markShared(DynamicObject)` instead. Returns `Shape`: a cached and shared variant of this shape. Throws: `UnsupportedOperationException` (unchecked): if this shape is already shared. See also: `isShared()`, `DynamicObjectLibrary.markShared(DynamicObject)`. Cite: `com/oracle/truffle/api/object/Shape.html#makeSharedShape()` ### hasInstanceProperties() `protected boolean hasInstanceProperties()`. Since 20.2.0. Returns `true` if this shape has instance properties (i.e., stored in the object). Cite: `com/oracle/truffle/api/object/Shape.html#hasInstanceProperties()` ### getPropertyAssumption(Object) `public Assumption getPropertyAssumption(Object key)`. Since 20.2.0. Gets a stable property assumption for the given property key. May be invalid. If a valid assumption is returned, it may be used to assume this particular property is still absent or present at the current storage location in objects of this shape. The assumption is invalidated if a shape change is triggered because of a property with the given key was added, removed, or changed, or a `resetShape`. Only applicable if property assumptions are enabled for this shape, otherwise always returns an invalid assumption. Parameters: `key` `Object`: the property key of interest. Returns `Assumption`: an assumption that the property is stable or an invalid assumption. See also: `Shape.Builder.propertyAssumptions(boolean)`. Cite: `com/oracle/truffle/api/object/Shape.html#getPropertyAssumption(java.lang.Object)` ### allPropertiesMatch(Predicate) `public boolean allPropertiesMatch(Predicate predicate)`. Since 20.2.0. Tests if all properties in the shape match the provided predicate. May not evaluate the predicate on all properties if a predicate did not match. If the shape does not contain any properties, returns `true` and does not evaluate the predicate. Returns `boolean`: `true` if the all properties match the predicate, else `false`. Cite: `com/oracle/truffle/api/object/Shape.html#allPropertiesMatch(java.util.function.Predicate)` ### makePropertyGetter(Object) `public PropertyGetter makePropertyGetter(Object key)`. Since 22.2. Makes a property getter for this shape and the given property key, if it exists. Otherwise, returns `null`. Note that the returned `PropertyGetter` only accepts objects of this particular `Shape`. Parameters: `key` `Object`: the identifier to look up. Returns `PropertyGetter`: a `PropertyGetter`, or `null` if the property was not found in this shape. Cite: `com/oracle/truffle/api/object/Shape.html#makePropertyGetter(java.lang.Object)` ### toString() `public String toString()`. Since 25.1. Returns a string representation of the object. Returns `String`: a string representation of the object. Overrides `toString()`. Cite: `com/oracle/truffle/api/object/Shape.html#toString()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ Shape.Builder [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 20.2.0. Nested in [`Shape`](com/oracle/truffle/api/object/Shape.md). ```java public static final class Shape.Builder extends Shape.AbstractBuilder ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Shape.AbstractBuilder` > `Builder` Builder class to construct initial [`Shape`](com/oracle/truffle/api/object/Shape.md) instances. The builder instance is not thread-safe and must not be used from multiple threads at the same time. **See also** - [`Shape.newBuilder()`](com/oracle/truffle/api/object/Shape.md#newBuilder%28%29) ## Methods ### layout(Class) `@Deprecated(since = "24.2") public Shape.Builder layout(Class layoutClass)`. Since 20.2.0. Deprecated since 24.2. Use `layout(Class, MethodHandles.Lookup)` instead. Sets custom object layout class (default: `DynamicObject` base class). Enables the use of dynamic object fields declared in subclasses using the `DynamicField` annotation. Examples: Parameters: `layoutClass` `Class`: custom object layout class. Cite: `com/oracle/truffle/api/object/Shape.Builder.html#layout(java.lang.Class)` ```java public class MyObject extends DynamicObject implements TruffleObject { @DynamicField private Object _obj1; @DynamicField private Object _obj2; @DynamicField private long _long1; @DynamicField private long _long2; public MyObject(Shape shape) { super(shape); } } Shape myObjShape = Shape.newBuilder().layout(MyObject.class).build(); MyObject obj = new MyObject(myObjShape); ``` ### layout(Class, MethodHandles.Lookup) `public Shape.Builder layout(Class layoutClass, MethodHandles.Lookup layoutClassLookup)`. Since 24.2.0. Sets a custom object layout class (default: `DynamicObject``.class`) and a corresponding [`MethodHandles.Lookup`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/invoke/MethodHandles.Lookup.html) created by the layout class, or a class in the same module, that has full privilege access in order to provide access to its fields. Enables the allocation of any additional `DynamicField`-annotated fields declared in the `DynamicObject` layout subclass as storage locations. By default, only extension array based storage locations in the `DynamicObject` base class are used. Also restricts the shape to a specific `DynamicObject` subclass and subclasses thereof, i.e. shapes created for a `DynamicObject` layout subclass, and any derived shapes, can only be used to instantiate, and be assigned to, instances of that class (regardless of whether the class actually contains any dynamic fields). Example: Parameters: `layoutClass` `Class`: a `DynamicObject` layout subclass or the default `DynamicObject``.class`. `layoutClassLookup` `MethodHandles.Lookup`: a [`Lookup`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/invoke/MethodHandles.Lookup.html) that has full privilege access, created using [`MethodHandles.lookup()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/invoke/MethodHandles.html#lookup%28%29), either by the layout class itself, or a class in the same module. If `layoutClass == DynamicObject.class`, and only then, this parameter is ignored and may be `null`. Throws: `IllegalArgumentException` (unchecked): if `layoutClass != DynamicObject.class` and the lookup does not have [`full privilege access`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/invoke/MethodHandles.Lookup.html#hasFullPrivilegeAccess%28%29) or is not from the layout class or a class within the same module as the layout class. `NullPointerException` (unchecked): if `layoutClass == null`, or `lookup == null` and `layoutClass != ``DynamicObject``.class`. Cite: `com/oracle/truffle/api/object/Shape.Builder.html#layout(java.lang.Class,java.lang.invoke.MethodHandles.Lookup)` ```java public class MyObject extends DynamicObject implements TruffleObject { @DynamicField private Object _obj1; @DynamicField private Object _obj2; @DynamicField private long _long1; @DynamicField private long _long2; public MyObject(Shape shape) { super(shape); } static MethodHandles.Lookup lookup() { return MethodHandles.lookup(); } } Shape myObjShape = Shape.newBuilder().layout(MyObject.class, MyObject.lookup()).build(); MyObject obj = new MyObject(myObjShape); ``` ### dynamicType(Object) `public Shape.Builder dynamicType(Object dynamicType)`. Since 20.2.0. Sets initial dynamic object type identifier. See `DynamicObjectLibrary.setDynamicType(DynamicObject, Object)` for more information. Parameters: `dynamicType` `Object`: a non-null object type identifier. Throws: `NullPointerException` (unchecked): if the type is `null`. Overrides `dynamicType(java.lang.Object)`. See also: `DynamicObjectLibrary.getDynamicType(DynamicObject)`, `DynamicObjectLibrary.setDynamicType(DynamicObject, Object)`. Cite: `com/oracle/truffle/api/object/Shape.Builder.html#dynamicType(java.lang.Object)` ### shapeFlags(int) `public Shape.Builder shapeFlags(int flags)`. Since 20.2.0. Sets initial shape flags (default: 0). Currently limited to 16 bits. See `DynamicObjectLibrary.setShapeFlags(DynamicObject, int)` for more information. Parameters: `flags` `int`: an int value in the range from 0 to 65535 (inclusive). Throws: `IllegalArgumentException` (unchecked): if the flags value is not in the supported range. Overrides `shapeFlags(int)`. See also: `DynamicObjectLibrary.getShapeFlags(DynamicObject)`, `DynamicObjectLibrary.setShapeFlags(DynamicObject, int)`. Cite: `com/oracle/truffle/api/object/Shape.Builder.html#shapeFlags(int)` ### shared(boolean) `public Shape.Builder shared(boolean isShared)`. Since 20.2.0. If `true`, makes the object shared (default: `false`). See also: `Shape.isShared()`, `DynamicObjectLibrary.isShared(DynamicObject)`, `DynamicObjectLibrary.markShared(DynamicObject)`. Cite: `com/oracle/truffle/api/object/Shape.Builder.html#shared(boolean)` ### propertyAssumptions(boolean) `public Shape.Builder propertyAssumptions(boolean enable)`. Since 20.2.0. If `true`, enables the use of property assumptions for this object shape and any derived shapes (default: `false`). Property assumptions allow speculating on select properties being absent or stable across shape changes. Use of property assumptions can be beneficial in single-context mode for long-lived objects with stable properties but recurrent shape changes due to properties being added (e.g. global objects of a context), in which case a shape cache would be unstable while the property assumption allows for a stable cache. See also: `Shape.getPropertyAssumption(Object)`. Cite: `com/oracle/truffle/api/object/Shape.Builder.html#propertyAssumptions(boolean)` ### sharedData(Object) `public Shape.Builder sharedData(Object sharedData)`. Since 20.2.0. Sets shared data to be associated with the root shape and any derived shapes (e.g. a `TruffleLanguage` instance). May be null (the default). See also: `Shape.getSharedData()`. Cite: `com/oracle/truffle/api/object/Shape.Builder.html#sharedData(java.lang.Object)` ### singleContextAssumption(Assumption) `public Shape.Builder singleContextAssumption(Assumption assumption)`. Since 20.2.0. Sets an assumption that allows specializations on constant object instances with this shape, as long as the assumption is valid. The assumption should be valid only if code is not shared across contexts and invalidated when this is no longer true. The assumption may be `null` in which case this feature is disabled (the default). See also: `propertyAssumptions(boolean)`. Cite: `com/oracle/truffle/api/object/Shape.Builder.html#singleContextAssumption(com.oracle.truffle.api.Assumption)` ### addConstantProperty(Object, Object, int) `public Shape.Builder addConstantProperty(Object key, Object value, int flags)`. Since 20.2.0. Adds a property with a constant value to the shape. The key must not be `null` and must not be equal to any previously added property's key. Parameters: `key` `Object`: the property's key. `value` `Object`: the property's value. `flags` `int`: the property's flags. Throws: `NullPointerException` (unchecked): if the key is `null`. `IllegalArgumentException` (unchecked): if a property with the key already exists. Overrides `addConstantProperty(java.lang.Object,java.lang.Object,int)`. See also: `DynamicObjectLibrary.putConstant(DynamicObject, Object, Object, int)`. Cite: `com/oracle/truffle/api/object/Shape.Builder.html#addConstantProperty(java.lang.Object,java.lang.Object,int)` ### allowImplicitCastIntToLong(boolean) `public Shape.Builder allowImplicitCastIntToLong(boolean allow)`. Since 20.2.0. Allows values to be implicitly cast from int to long in this shape and any derived shapes. Cite: `com/oracle/truffle/api/object/Shape.Builder.html#allowImplicitCastIntToLong(boolean)` ### allowImplicitCastIntToDouble(boolean) `public Shape.Builder allowImplicitCastIntToDouble(boolean allow)`. Since 20.2.0. Allows values to be implicitly cast from int to double in this shape and any derived shapes. Cite: `com/oracle/truffle/api/object/Shape.Builder.html#allowImplicitCastIntToDouble(boolean)` ### build() `public Shape build()`. Since 20.2.0. Builds a new shape using the configuration of this builder. Cite: `com/oracle/truffle/api/object/Shape.Builder.html#build()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ Shape.DerivedBuilder [truffle-api](index.md) › [com.oracle.truffle.api.object](com/oracle/truffle/api/object/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.object`](com/oracle/truffle/api/object/index.md). Since 20.2.0. Nested in [`Shape`](com/oracle/truffle/api/object/Shape.md). ```java public static final class Shape.DerivedBuilder extends Shape.AbstractBuilder ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Shape.AbstractBuilder` > `DerivedBuilder` Builder class to construct derived [`Shape`](com/oracle/truffle/api/object/Shape.md) instances. The builder instance is not thread-safe and must not be used from multiple threads at the same time. **See also** - [`Shape.newBuilder(Shape)`](com/oracle/truffle/api/object/Shape.md#newBuilder%28com.oracle.truffle.api.object.Shape%29) ## Methods ### dynamicType(Object) `public Shape.DerivedBuilder dynamicType(Object dynamicType)`. Since 20.2.0. Sets initial dynamic object type identifier. See `DynamicObjectLibrary.setDynamicType(DynamicObject, Object)` for more information. Parameters: `dynamicType` `Object`: a non-null object type identifier. Throws: `NullPointerException` (unchecked): if the type is `null`. Overrides `dynamicType(java.lang.Object)`. See also: `DynamicObjectLibrary.getDynamicType(DynamicObject)`, `DynamicObjectLibrary.setDynamicType(DynamicObject, Object)`. Cite: `com/oracle/truffle/api/object/Shape.DerivedBuilder.html#dynamicType(java.lang.Object)` ### shapeFlags(int) `public Shape.DerivedBuilder shapeFlags(int flags)`. Since 20.2.0. Sets initial shape flags (default: 0). Currently limited to 16 bits. See `DynamicObjectLibrary.setShapeFlags(DynamicObject, int)` for more information. Parameters: `flags` `int`: an int value in the range from 0 to 65535 (inclusive). Throws: `IllegalArgumentException` (unchecked): if the flags value is not in the supported range. Overrides `shapeFlags(int)`. See also: `DynamicObjectLibrary.getShapeFlags(DynamicObject)`, `DynamicObjectLibrary.setShapeFlags(DynamicObject, int)`. Cite: `com/oracle/truffle/api/object/Shape.DerivedBuilder.html#shapeFlags(int)` ### addConstantProperty(Object, Object, int) `public Shape.DerivedBuilder addConstantProperty(Object key, Object value, int flags)`. Since 20.2.0. Adds a property with a constant value to the shape. The key must not be `null` and must not be equal to any previously added property's key. Parameters: `key` `Object`: the property's key. `value` `Object`: the property's value. `flags` `int`: the property's flags. Throws: `NullPointerException` (unchecked): if the key is `null`. `IllegalArgumentException` (unchecked): if a property with the key already exists. Overrides `addConstantProperty(java.lang.Object,java.lang.Object,int)`. See also: `DynamicObjectLibrary.putConstant(DynamicObject, Object, Object, int)`. Cite: `com/oracle/truffle/api/object/Shape.DerivedBuilder.html#addConstantProperty(java.lang.Object,java.lang.Object,int)` ### build() `public Shape build()`. Since 20.2.0. Builds a derived shape from the base shape supplied to the constructor using the configuration of this builder. Returns `Shape`: a new or cached shape. Cite: `com/oracle/truffle/api/object/Shape.DerivedBuilder.html#build()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ▣ com.oracle.truffle.api.profiles [truffle-api](index.md) · Every page: [llms.txt](llms.txt) Package in truffle-api. Since 0.8 or older. A profile is a Truffle utility class that uses the [`Truffle compiler directives`](com/oracle/truffle/api/CompilerDirectives.md) to guard for and/or forward runtime information to the compiler. **See also** - [`com.oracle.truffle.api.profiles.Profile`](com/oracle/truffle/api/profiles/Profile.md) ## Classes - [`BranchProfile`](com/oracle/truffle/api/profiles/BranchProfile.md): BranchProfiles are profiles to speculate on branches that are unlikely to be visited. - [`ByteValueProfile`](com/oracle/truffle/api/profiles/ByteValueProfile.md): Specialized value profile to capture certain properties of byte runtime values. - [`ConditionProfile`](com/oracle/truffle/api/profiles/ConditionProfile.md): ConditionProfiles are useful to profile the outcome of conditions. - [`CountingConditionProfile`](com/oracle/truffle/api/profiles/CountingConditionProfile.md): CountingConditionProfiles are useful to profile the outcome of conditions. - [`DoubleValueProfile`](com/oracle/truffle/api/profiles/DoubleValueProfile.md): Specialized value profile to capture certain properties of double runtime values. - [`FloatValueProfile`](com/oracle/truffle/api/profiles/FloatValueProfile.md): Specialized value profile to capture certain properties of float runtime values. - [`InlinedBranchProfile`](com/oracle/truffle/api/profiles/InlinedBranchProfile.md): BranchProfiles are profiles to speculate on branches that are unlikely to be visited. - [`InlinedByteValueProfile`](com/oracle/truffle/api/profiles/InlinedByteValueProfile.md): Specialized value profile to capture certain properties of byte runtime values. - [`InlinedConditionProfile`](com/oracle/truffle/api/profiles/InlinedConditionProfile.md): ConditionProfiles are useful to profile the outcome of conditions. - [`InlinedCountingConditionProfile`](com/oracle/truffle/api/profiles/InlinedCountingConditionProfile.md): CountingConditionProfiles are useful to profile the outcome of conditions. - [`InlinedDoubleValueProfile`](com/oracle/truffle/api/profiles/InlinedDoubleValueProfile.md): Specialized value profile to capture certain properties of byte runtime values. - [`InlinedExactClassProfile`](com/oracle/truffle/api/profiles/InlinedExactClassProfile.md): Specialized value profile to capture the exact class of reference runtime values. - [`InlinedFloatValueProfile`](com/oracle/truffle/api/profiles/InlinedFloatValueProfile.md): Specialized value profile to capture certain properties of float runtime values. - [`InlinedIntValueProfile`](com/oracle/truffle/api/profiles/InlinedIntValueProfile.md): Specialized value profile to capture certain properties of int runtime values. - [`InlinedLongValueProfile`](com/oracle/truffle/api/profiles/InlinedLongValueProfile.md): Specialized value profile to capture certain properties of long runtime values. - [`InlinedLoopConditionProfile`](com/oracle/truffle/api/profiles/InlinedLoopConditionProfile.md): InlinedLoopConditionProfiles are designed to profile the outcome of loop conditions. - [`InlinedProfile`](com/oracle/truffle/api/profiles/InlinedProfile.md): A profile is a Truffle utility class that uses the Truffle compiler directives to guard for and/or forward runtime information to the compiler. - [`IntValueProfile`](com/oracle/truffle/api/profiles/IntValueProfile.md): Specialized value profile to capture certain properties of int runtime values. - [`LongValueProfile`](com/oracle/truffle/api/profiles/LongValueProfile.md): Specialized value profile to capture certain properties of long runtime values. - [`LoopConditionProfile`](com/oracle/truffle/api/profiles/LoopConditionProfile.md): LoopConditionProfiles are designed to profile the outcome of loop conditions. - [`PrimitiveValueProfile`](com/oracle/truffle/api/profiles/PrimitiveValueProfile.md): Represents a ValueProfile that speculates on the primitive equality or object identity of values. - [`Profile`](com/oracle/truffle/api/profiles/Profile.md): A profile is a Truffle utility class that uses the Truffle compiler directives to guard for and/or forward runtime information to the compiler. - [`ValueProfile`](com/oracle/truffle/api/profiles/ValueProfile.md): Specialized value profile to capture certain properties of Object runtime values. # ◆ BranchProfile [truffle-api](index.md) › [com.oracle.truffle.api.profiles](com/oracle/truffle/api/profiles/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.profiles`](com/oracle/truffle/api/profiles/index.md). Since 0.10. ```java public final class BranchProfile extends Profile ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`NodeCloneable`](com/oracle/truffle/api/nodes/NodeCloneable.md) > [`Profile`](com/oracle/truffle/api/profiles/Profile.md) > `BranchProfile` BranchProfiles are profiles to speculate on branches that are unlikely to be visited. If the [`enter()`](com/oracle/truffle/api/profiles/BranchProfile.md#enter%28%29) method is invoked first the optimized code is invalidated and the branch where [`enter()`](com/oracle/truffle/api/profiles/BranchProfile.md#enter%28%29) is invoked is enabled for compilation. Otherwise if the [`enter()`](com/oracle/truffle/api/profiles/BranchProfile.md#enter%28%29) method was never invoked the branch will not get compiled. ** Usage example:** ```java class BranchingNode extends Node { final BranchProfile errorProfile = BranchProfile.create(); int execute(int value) { if (value == Integer.MAX_VALUE) { errorProfile.enter(); throw new Error("Invalid input value"); } return value; } } ``` **See also** - [`BranchProfile.enter()`](com/oracle/truffle/api/profiles/BranchProfile.md#enter%28%29) ## Methods ### enter() `public void enter()`. Since 0.10. Call when an unlikely branch is entered. Cite: `com/oracle/truffle/api/profiles/BranchProfile.html#enter()` ### disable() `public void disable()`. Since 22.1. Disables this profile by setting it to its generic state. After disabling it is guaranteed to never `deoptimize` on any invocation of a profile method. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Overrides `disable()`. Cite: `com/oracle/truffle/api/profiles/BranchProfile.html#disable()` ### reset() `public void reset()`. Since 22.1. Resets this profile to its uninitialized state. Has no effect if this profile is already in its uninitialized state or a disabled version of this profile is used. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Overrides `reset()`. Cite: `com/oracle/truffle/api/profiles/BranchProfile.html#reset()` ### toString() `public String toString()`. Since 22.1. Overrides `toString()`. Cite: `com/oracle/truffle/api/profiles/BranchProfile.html#toString()` ### create() `public static BranchProfile create()`. Since 0.10. Call to create a new instance of a branch profile. Cite: `com/oracle/truffle/api/profiles/BranchProfile.html#create()` ### inline(InlineSupport.InlineTarget) `public static InlinedBranchProfile inline(InlineSupport.InlineTarget target)`. Since 23.0. Returns an inlined version of the profile. This version is automatically used by Truffle DSL node inlining. Cite: `com/oracle/truffle/api/profiles/BranchProfile.html#inline(com.oracle.truffle.api.dsl.InlineSupport.InlineTarget)` ### getUncached() `public static BranchProfile getUncached()`. Since 19.0. Returns the uncached version of the profile. The uncached version of a profile does nothing. Cite: `com/oracle/truffle/api/profiles/BranchProfile.html#getUncached()` ## Inherited members - From class [`NodeCloneable`](com/oracle/truffle/api/nodes/NodeCloneable.md): [`clone`](com/oracle/truffle/api/nodes/NodeCloneable.md#clone%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ ByteValueProfile [truffle-api](index.md) › [com.oracle.truffle.api.profiles](com/oracle/truffle/api/profiles/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.profiles`](com/oracle/truffle/api/profiles/index.md). Since 0.10. ```java public final class ByteValueProfile extends Profile ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`NodeCloneable`](com/oracle/truffle/api/nodes/NodeCloneable.md) > [`Profile`](com/oracle/truffle/api/profiles/Profile.md) > `ByteValueProfile` Specialized value profile to capture certain properties of `byte` runtime values. Value profiles require a runtime check in their initialized state to verify their profiled assumption. Value profiles are limited to capture monomorphic profiles only. This means that if two or more values are profiled within a single profile then the profile has no effect. If the value assumption is invalidated in compiled code then it is invalidated. ** Usage example:** ```java class ByteProfileNode extends Node { final ByteValueProfile profile = ByteValueProfile.create(); byte execute(byte input) { byte profiledValue = profile.profile(input); // compiler may know now more about profiledValue return profiledValue; } } ``` **See also** - [`createIdentityProfile()`](com/oracle/truffle/api/profiles/ByteValueProfile.md#createIdentityProfile%28%29) - [`ValueProfile`](com/oracle/truffle/api/profiles/ValueProfile.md) ## Methods ### profile(byte) `public byte profile(byte value)`. Since 0.10. Cite: `com/oracle/truffle/api/profiles/ByteValueProfile.html#profile(byte)` ### disable() `public void disable()`. Since 22.1. Disables this profile by setting it to its generic state. After disabling it is guaranteed to never `deoptimize` on any invocation of a profile method. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Overrides `disable()`. Cite: `com/oracle/truffle/api/profiles/ByteValueProfile.html#disable()` ### reset() `public void reset()`. Since 22.1. Resets this profile to its uninitialized state. Has no effect if this profile is already in its uninitialized state or a disabled version of this profile is used. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Overrides `reset()`. Cite: `com/oracle/truffle/api/profiles/ByteValueProfile.html#reset()` ### toString() `public String toString()`. Since 22.1. Overrides `toString()`. Cite: `com/oracle/truffle/api/profiles/ByteValueProfile.html#toString()` ### createIdentityProfile() `public static ByteValueProfile createIdentityProfile()`. Since 0.10. Returns a value profile that profiles the exact value of a `byte`. See also: `ByteValueProfile`. Cite: `com/oracle/truffle/api/profiles/ByteValueProfile.html#createIdentityProfile()` ### create() `public static ByteValueProfile create()`. Since 22.1. Returns a value profile that profiles the exact value of a `byte`. See also: `ByteValueProfile`. Cite: `com/oracle/truffle/api/profiles/ByteValueProfile.html#create()` ### getUncached() `public static ByteValueProfile getUncached()`. Since 19.0. Returns the uncached version of the profile. The uncached version of a profile does nothing. Cite: `com/oracle/truffle/api/profiles/ByteValueProfile.html#getUncached()` ### inline(InlineSupport.InlineTarget) `public static InlinedByteValueProfile inline(InlineSupport.InlineTarget target)`. Since 23.0. Returns an inlined version of the profile. This version is automatically used by Truffle DSL node inlining. Cite: `com/oracle/truffle/api/profiles/ByteValueProfile.html#inline(com.oracle.truffle.api.dsl.InlineSupport.InlineTarget)` ## Inherited members - From class [`NodeCloneable`](com/oracle/truffle/api/nodes/NodeCloneable.md): [`clone`](com/oracle/truffle/api/nodes/NodeCloneable.md#clone%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ ConditionProfile [truffle-api](index.md) › [com.oracle.truffle.api.profiles](com/oracle/truffle/api/profiles/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.profiles`](com/oracle/truffle/api/profiles/index.md). Since 0.10. ```java public class ConditionProfile extends Profile ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`NodeCloneable`](com/oracle/truffle/api/nodes/NodeCloneable.md) > [`Profile`](com/oracle/truffle/api/profiles/Profile.md) > `ConditionProfile` ConditionProfiles are useful to profile the outcome of conditions. A regular condition profile keeps track of a binary state, for each branch whether a branch was hit or not and communicates this to the compiler. If frequency information for each branch should be collected use [`CountingConditionProfile`](com/oracle/truffle/api/profiles/CountingConditionProfile.md) instead. ** Usage example:** ```java class AbsoluteNode extends Node { final ConditionProfile greaterZeroProfile = ConditionProfile.create(); void execute(int value) { if (greaterZeroProfile.profile(value >= 0)) { return value; } else { return -value; } } } ``` **See also** - [`create()`](com/oracle/truffle/api/profiles/ConditionProfile.md#create%28%29) - [`LoopConditionProfile`](com/oracle/truffle/api/profiles/LoopConditionProfile.md) - [`CountingConditionProfile`](com/oracle/truffle/api/profiles/CountingConditionProfile.md) ## Methods ### profile(boolean) `public boolean profile(boolean value)`. Since 0.10. Cite: `com/oracle/truffle/api/profiles/ConditionProfile.html#profile(boolean)` ### disable() `public void disable()`. Since 23.0. Disables this profile by setting it to its generic state. After disabling it is guaranteed to never `deoptimize` on any invocation of a profile method. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Overrides `disable()`. Cite: `com/oracle/truffle/api/profiles/ConditionProfile.html#disable()` ### reset() `public void reset()`. Since 23.0. Resets this profile to its uninitialized state. Has no effect if this profile is already in its uninitialized state or a disabled version of this profile is used. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Overrides `reset()`. Cite: `com/oracle/truffle/api/profiles/ConditionProfile.html#reset()` ### toString() `public String toString()`. Since 23.0. Overrides `toString()`. Cite: `com/oracle/truffle/api/profiles/ConditionProfile.html#toString()` ### create() `public static ConditionProfile create()`. Since 20.2. Returns a `ConditionProfile` that speculates on conditions to be never `true` or to be never `false`. Condition profiles are intended to be used as part of if conditions. Cite: `com/oracle/truffle/api/profiles/ConditionProfile.html#create()` ### getUncached() `public static ConditionProfile getUncached()`. Since 19.0. Returns the uncached version of the profile. The uncached version of a profile does nothing. Cite: `com/oracle/truffle/api/profiles/ConditionProfile.html#getUncached()` ### inline(InlineSupport.InlineTarget) `public static InlinedConditionProfile inline(InlineSupport.InlineTarget target)`. Since 23.0. Returns an inlined version of the profile. This version is automatically used by Truffle DSL node inlining. Cite: `com/oracle/truffle/api/profiles/ConditionProfile.html#inline(com.oracle.truffle.api.dsl.InlineSupport.InlineTarget)` ## Inherited members - From class [`NodeCloneable`](com/oracle/truffle/api/nodes/NodeCloneable.md): [`clone`](com/oracle/truffle/api/nodes/NodeCloneable.md#clone%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ CountingConditionProfile [truffle-api](index.md) › [com.oracle.truffle.api.profiles](com/oracle/truffle/api/profiles/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.profiles`](com/oracle/truffle/api/profiles/index.md). Since 23.0. ```java public final class CountingConditionProfile extends Profile ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`NodeCloneable`](com/oracle/truffle/api/nodes/NodeCloneable.md) > [`Profile`](com/oracle/truffle/api/profiles/Profile.md) > `CountingConditionProfile` CountingConditionProfiles are useful to profile the outcome of conditions. A counting condition profile holds a count for each branch whether a branch was hit or not and communicates this to the compiler as frequency information. If binary information only is desired for each branch should use [`ConditionProfile`](com/oracle/truffle/api/profiles/ConditionProfile.md) instead. ** Usage example:** ```java class AbsoluteNode extends Node { final CountingConditionProfile greaterZeroProfile = CountingConditionProfile.create(); void execute(int value) { if (greaterZeroProfile.profile(value >= 0)) { return value; } else { return -value; } } } ``` **See also** - [`create()`](com/oracle/truffle/api/profiles/CountingConditionProfile.md#create%28%29) - [`LoopConditionProfile`](com/oracle/truffle/api/profiles/LoopConditionProfile.md) - [`CountingConditionProfile`](com/oracle/truffle/api/profiles/CountingConditionProfile.md) ## Methods ### profile(boolean) `public boolean profile(boolean value)`. Since 22.1. Cite: `com/oracle/truffle/api/profiles/CountingConditionProfile.html#profile(boolean)` ### disable() `public void disable()`. Since 23.0. Disables this profile by setting it to its generic state. After disabling it is guaranteed to never `deoptimize` on any invocation of a profile method. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Overrides `disable()`. Cite: `com/oracle/truffle/api/profiles/CountingConditionProfile.html#disable()` ### reset() `public void reset()`. Since 23.0. Resets this profile to its uninitialized state. Has no effect if this profile is already in its uninitialized state or a disabled version of this profile is used. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Overrides `reset()`. Cite: `com/oracle/truffle/api/profiles/CountingConditionProfile.html#reset()` ### toString() `public String toString()`. Since 23.0. Overrides `toString()`. Cite: `com/oracle/truffle/api/profiles/CountingConditionProfile.html#toString()` ### getUncached() `public static CountingConditionProfile getUncached()`. Since 23.0. Returns the uncached version of the profile. The uncached version of a profile does nothing. Cite: `com/oracle/truffle/api/profiles/CountingConditionProfile.html#getUncached()` ### create() `public static CountingConditionProfile create()`. Since 23.0. Returns a `ConditionProfile` that speculates on conditions to be never `true` or to be never `false`. Additionally to a binary profile this method returns a condition profile that also counts the number of times the condition was true and false. This information is reported to the underlying optimization system using `CompilerDirectives.injectBranchProbability(double, boolean)`. Condition profiles are intended to be used as part of if conditions. See also: `ConditionProfile`. Cite: `com/oracle/truffle/api/profiles/CountingConditionProfile.html#create()` ### inline(InlineSupport.InlineTarget) `public static InlinedCountingConditionProfile inline(InlineSupport.InlineTarget target)`. Since 23.0. Returns an inlined version of the profile. This version is automatically used by Truffle DSL node inlining. Cite: `com/oracle/truffle/api/profiles/CountingConditionProfile.html#inline(com.oracle.truffle.api.dsl.InlineSupport.InlineTarget)` ## Inherited members - From class [`NodeCloneable`](com/oracle/truffle/api/nodes/NodeCloneable.md): [`clone`](com/oracle/truffle/api/nodes/NodeCloneable.md#clone%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ DoubleValueProfile [truffle-api](index.md) › [com.oracle.truffle.api.profiles](com/oracle/truffle/api/profiles/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.profiles`](com/oracle/truffle/api/profiles/index.md). Since 0.10. ```java public final class DoubleValueProfile extends Profile ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`NodeCloneable`](com/oracle/truffle/api/nodes/NodeCloneable.md) > [`Profile`](com/oracle/truffle/api/profiles/Profile.md) > `DoubleValueProfile` Specialized value profile to capture certain properties of `double` runtime values. Value profiles require a runtime check in their initialized state to verify their profiled assumption. Value profiles are limited to capture monomorphic profiles only. This means that if two or more values are profiled within a single profile then the profile has no effect. If the value assumption is invalidated in compiled code then it is invalidated. ** Usage example:** ```java class SampleNode extends Node { final DoubleValueProfile profile = DoubleValueProfile.createRawIdentityProfile(); double execute(double input) { double profiledValue = profile.profile(input); // compiler may know now more about profiledValue return profiledValue; } } ``` **See also** - [`createRawIdentityProfile()`](com/oracle/truffle/api/profiles/DoubleValueProfile.md#createRawIdentityProfile%28%29) - [`ValueProfile`](com/oracle/truffle/api/profiles/ValueProfile.md) ## Methods ### profile(double) `public double profile(double value)`. Since 0.10. Cite: `com/oracle/truffle/api/profiles/DoubleValueProfile.html#profile(double)` ### disable() `public void disable()`. Since 22.1. Disables this profile by setting it to its generic state. After disabling it is guaranteed to never `deoptimize` on any invocation of a profile method. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Overrides `disable()`. Cite: `com/oracle/truffle/api/profiles/DoubleValueProfile.html#disable()` ### reset() `public void reset()`. Since 22.1. Resets this profile to its uninitialized state. Has no effect if this profile is already in its uninitialized state or a disabled version of this profile is used. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Overrides `reset()`. Cite: `com/oracle/truffle/api/profiles/DoubleValueProfile.html#reset()` ### toString() `public String toString()`. Since 22.1. Overrides `toString()`. Cite: `com/oracle/truffle/api/profiles/DoubleValueProfile.html#toString()` ### createRawIdentityProfile() `public static DoubleValueProfile createRawIdentityProfile()`. Since 0.10. Returns a value profile that profiles the exact value of a `double` using [`Double.doubleToRawLongBits(double)`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Double.html#doubleToRawLongBits%28double%29). See also: `IntValueProfile`. Cite: `com/oracle/truffle/api/profiles/DoubleValueProfile.html#createRawIdentityProfile()` ### create() `public static DoubleValueProfile create()`. Since 22.1. Returns a value profile that profiles the exact value of a `double` using [`Double.doubleToRawLongBits(double)`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Double.html#doubleToRawLongBits%28double%29). See also: `IntValueProfile`. Cite: `com/oracle/truffle/api/profiles/DoubleValueProfile.html#create()` ### getUncached() `public static DoubleValueProfile getUncached()`. Since 19.0. Returns the uncached version of the profile. The uncached version of a profile does nothing. Cite: `com/oracle/truffle/api/profiles/DoubleValueProfile.html#getUncached()` ### inline(InlineSupport.InlineTarget) `public static InlinedDoubleValueProfile inline(InlineSupport.InlineTarget target)`. Since 23.0. Returns an inlined version of the profile. This version is automatically used by Truffle DSL node inlining. Cite: `com/oracle/truffle/api/profiles/DoubleValueProfile.html#inline(com.oracle.truffle.api.dsl.InlineSupport.InlineTarget)` ## Inherited members - From class [`NodeCloneable`](com/oracle/truffle/api/nodes/NodeCloneable.md): [`clone`](com/oracle/truffle/api/nodes/NodeCloneable.md#clone%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ FloatValueProfile [truffle-api](index.md) › [com.oracle.truffle.api.profiles](com/oracle/truffle/api/profiles/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.profiles`](com/oracle/truffle/api/profiles/index.md). Since 0.10. ```java public final class FloatValueProfile extends Profile ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`NodeCloneable`](com/oracle/truffle/api/nodes/NodeCloneable.md) > [`Profile`](com/oracle/truffle/api/profiles/Profile.md) > `FloatValueProfile` Specialized value profile to capture certain properties of `float` runtime values. Value profiles require a runtime check in their initialized state to verify their profiled assumption. Value profiles are limited to capture monomorphic profiles only. This means that if two or more values are profiled within a single profile then the profile has no effect. If the value assumption is invalidated in compiled code then it is invalidated. ** Usage example:** ```java class SampleNode extends Node { final FloatValueProfile profile = FloatValueProfile.createRawIdentityProfile(); float execute(float input) { float profiledValue = profile.profile(input); // compiler may know now more about profiledValue return profiledValue; } } ``` **See also** - [`createRawIdentityProfile()`](com/oracle/truffle/api/profiles/FloatValueProfile.md#createRawIdentityProfile%28%29) - [`ValueProfile`](com/oracle/truffle/api/profiles/ValueProfile.md) ## Methods ### profile(float) `public float profile(float value)`. Since 0.10. Cite: `com/oracle/truffle/api/profiles/FloatValueProfile.html#profile(float)` ### disable() `public void disable()`. Since 22.1. Disables this profile by setting it to its generic state. After disabling it is guaranteed to never `deoptimize` on any invocation of a profile method. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Overrides `disable()`. Cite: `com/oracle/truffle/api/profiles/FloatValueProfile.html#disable()` ### reset() `public void reset()`. Since 22.1. Resets this profile to its uninitialized state. Has no effect if this profile is already in its uninitialized state or a disabled version of this profile is used. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Overrides `reset()`. Cite: `com/oracle/truffle/api/profiles/FloatValueProfile.html#reset()` ### toString() `public String toString()`. Since 22.1. Overrides `toString()`. Cite: `com/oracle/truffle/api/profiles/FloatValueProfile.html#toString()` ### createRawIdentityProfile() `public static FloatValueProfile createRawIdentityProfile()`. Since 0.10. Returns a value profile that profiles the exact value of a `float` using [`Float.floatToRawIntBits(float)`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Float.html#floatToRawIntBits%28float%29). See also: `IntValueProfile`. Cite: `com/oracle/truffle/api/profiles/FloatValueProfile.html#createRawIdentityProfile()` ### create() `public static FloatValueProfile create()`. Since 22.1. Returns a value profile that profiles the exact value of a `float` using [`Float.floatToRawIntBits(float)`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Float.html#floatToRawIntBits%28float%29). See also: `IntValueProfile`. Cite: `com/oracle/truffle/api/profiles/FloatValueProfile.html#create()` ### getUncached() `public static FloatValueProfile getUncached()`. Since 19.0. Returns the uncached version of the profile. The uncached version of a profile does nothing. Cite: `com/oracle/truffle/api/profiles/FloatValueProfile.html#getUncached()` ### inline(InlineSupport.InlineTarget) `public static InlinedFloatValueProfile inline(InlineSupport.InlineTarget target)`. Since 23.0. Returns an inlined version of the profile. This version is automatically used by Truffle DSL node inlining. Cite: `com/oracle/truffle/api/profiles/FloatValueProfile.html#inline(com.oracle.truffle.api.dsl.InlineSupport.InlineTarget)` ## Inherited members - From class [`NodeCloneable`](com/oracle/truffle/api/nodes/NodeCloneable.md): [`clone`](com/oracle/truffle/api/nodes/NodeCloneable.md#clone%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ InlinedBranchProfile [truffle-api](index.md) › [com.oracle.truffle.api.profiles](com/oracle/truffle/api/profiles/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.profiles`](com/oracle/truffle/api/profiles/index.md). Since 23.0. ```java public final class InlinedBranchProfile extends InlinedProfile ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`InlinedProfile`](com/oracle/truffle/api/profiles/InlinedProfile.md) > `InlinedBranchProfile` BranchProfiles are profiles to speculate on branches that are unlikely to be visited. If the [`enter(Node)`](com/oracle/truffle/api/profiles/InlinedBranchProfile.md#enter%28com.oracle.truffle.api.nodes.Node%29) method is invoked first the optimized code is invalidated and the branch where [`enter(Node)`](com/oracle/truffle/api/profiles/InlinedBranchProfile.md#enter%28com.oracle.truffle.api.nodes.Node%29) is invoked is enabled for compilation. Otherwise if the [`enter(Node)`](com/oracle/truffle/api/profiles/InlinedBranchProfile.md#enter%28com.oracle.truffle.api.nodes.Node%29) method was never invoked the branch will not get compiled. ** Usage example:** ```java class ExampleNode extends Node { abstract int execute(int value); @Specialization int doDefault(int value, @Cached InlinedBranchProfile errorProfile) { if (value == Integer.MAX_VALUE) { errorProfile.enter(this); throw new Error("Invalid input value"); } return value; } } ``` **See also** - [`InlinedProfile`](com/oracle/truffle/api/profiles/InlinedProfile.md) ## Methods ### enter(Node) `public void enter(Node node)`. Since 23.0. Cite: `com/oracle/truffle/api/profiles/InlinedBranchProfile.html#enter(com.oracle.truffle.api.nodes.Node)` ### wasEntered(Node) `public boolean wasEntered(Node node)`. Since 23.0. Returns `true` if the `enter(Node)` method was ever called, otherwise `false`. For profiles with profiling disabled or `uncached` profiles this method always returns `true`. Cite: `com/oracle/truffle/api/profiles/InlinedBranchProfile.html#wasEntered(com.oracle.truffle.api.nodes.Node)` ### reset(Node) `public void reset(Node node)`. Since 23.0. Resets this profile to its uninitialized state. Has no effect if this profile is already in its uninitialized state or a disabled version of this profile is used. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Overrides `reset()`. Cite: `com/oracle/truffle/api/profiles/InlinedBranchProfile.html#reset(com.oracle.truffle.api.nodes.Node)` ### disable(Node) `public void disable(Node node)`. Since 23.0. Disables this profile by setting it to its generic state. After disabling it is guaranteed to never `deoptimize` on any invocation of a profile method. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Overrides `disable()`. Cite: `com/oracle/truffle/api/profiles/InlinedBranchProfile.html#disable(com.oracle.truffle.api.nodes.Node)` ### toString(Node) `public String toString(Node node)`. Since 23.0. Prints a string representation of this inlined profile given a target node. Overrides `toString()`. Cite: `com/oracle/truffle/api/profiles/InlinedBranchProfile.html#toString(com.oracle.truffle.api.nodes.Node)` ### inline(InlineSupport.InlineTarget) `public static InlinedBranchProfile inline(InlineSupport.InlineTarget target)`. Since 23.0. Returns an inlined version of the profile. This version is automatically used by Truffle DSL node inlining. Cite: `com/oracle/truffle/api/profiles/InlinedBranchProfile.html#inline(com.oracle.truffle.api.dsl.InlineSupport.InlineTarget)` ### getUncached() `public static InlinedBranchProfile getUncached()`. Since 23.0. Returns the uncached version of the profile. The uncached version of a profile does not perform any profiling. Cite: `com/oracle/truffle/api/profiles/InlinedBranchProfile.html#getUncached()` ## Inherited members - From class [`InlinedProfile`](com/oracle/truffle/api/profiles/InlinedProfile.md): [`toString`](com/oracle/truffle/api/profiles/InlinedProfile.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ InlinedByteValueProfile [truffle-api](index.md) › [com.oracle.truffle.api.profiles](com/oracle/truffle/api/profiles/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.profiles`](com/oracle/truffle/api/profiles/index.md). Since 23.0. ```java public final class InlinedByteValueProfile extends AbstractInlinedValueProfile ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`InlinedProfile`](com/oracle/truffle/api/profiles/InlinedProfile.md) > `AbstractInlinedValueProfile` > `InlinedByteValueProfile` Specialized value profile to capture certain properties of `byte` runtime values. Value profiles require a runtime check in their initialized state to verify their profiled assumption. Value profiles are limited to capture monomorphic profiles only. This means that if two or more values are profiled within a single profile then the profile has no effect. If the value assumption is invalidated in compiled code then it is invalidated. ** Usage example:** ```java abstract class ByteProfileNode extends Node { abstract byte execute(byte input); @Specialization byte doDefault(byte input, @Cached InlinedByteValueProfile profile) { byte profiledValue = profile.profile(this, input); // compiler may now see profiledValue as a partial evaluation constant return profiledValue; } } ``` ## Methods ### profile(Node, byte) `public byte profile(Node node, byte value)`. Since 23.0. Cite: `com/oracle/truffle/api/profiles/InlinedByteValueProfile.html#profile(com.oracle.truffle.api.nodes.Node,byte)` ### toString(Node) `public String toString(Node node)`. Since 23.0. Prints a string representation of this inlined profile given a target node. Overrides `toString()`. Cite: `com/oracle/truffle/api/profiles/InlinedByteValueProfile.html#toString(com.oracle.truffle.api.nodes.Node)` ### inline(InlineSupport.InlineTarget) `public static InlinedByteValueProfile inline(InlineSupport.InlineTarget target)`. Since 23.0. Returns an inlined version of the profile. This version is automatically used by Truffle DSL node inlining. Cite: `com/oracle/truffle/api/profiles/InlinedByteValueProfile.html#inline(com.oracle.truffle.api.dsl.InlineSupport.InlineTarget)` ### getUncached() `public static InlinedByteValueProfile getUncached()`. Since 23.0. Returns the uncached version of the profile. The uncached version of a profile does not perform any profiling. Cite: `com/oracle/truffle/api/profiles/InlinedByteValueProfile.html#getUncached()` ## Inherited members - From class `AbstractInlinedValueProfile`: `GENERIC`, `REQUIRED_STATE_BITS`, `SPECIALIZED`, `UNINITIALIZED`, `disable`, `reset`, `state` - From class [`InlinedProfile`](com/oracle/truffle/api/profiles/InlinedProfile.md): [`toString`](com/oracle/truffle/api/profiles/InlinedProfile.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ InlinedConditionProfile [truffle-api](index.md) › [com.oracle.truffle.api.profiles](com/oracle/truffle/api/profiles/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.profiles`](com/oracle/truffle/api/profiles/index.md). Since 23.0. ```java public final class InlinedConditionProfile extends InlinedProfile ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`InlinedProfile`](com/oracle/truffle/api/profiles/InlinedProfile.md) > `InlinedConditionProfile` ConditionProfiles are useful to profile the outcome of conditions. A regular condition profile keeps track of a binary state, for each branch whether a branch was hit or not and communicates this to the compiler. If frequency information for each branch should be collected use [`InlinedCountingConditionProfile`](com/oracle/truffle/api/profiles/InlinedCountingConditionProfile.md) instead. ** Usage example:** ```java abstract class AbsoluteNode extends Node { abstract void execute(int value); @Specialization int doDefault(int value, @Cached InlinedConditionProfile p) { if (p.profile(this, value >= 0)) { return value; } else { return -value; } } } ``` ## Methods ### profile(Node, boolean) `public boolean profile(Node node, boolean value)`. Since 23.0. Cite: `com/oracle/truffle/api/profiles/InlinedConditionProfile.html#profile(com.oracle.truffle.api.nodes.Node,boolean)` ### wasTrue(Node) `public boolean wasTrue(Node node)`. Since 23.0. Returns `true` if the `profile(Node, boolean)` method ever received a `true` value, otherwise `false`. For profiles with profiling disabled or `uncached` profiles this method always returns `true`. Cite: `com/oracle/truffle/api/profiles/InlinedConditionProfile.html#wasTrue(com.oracle.truffle.api.nodes.Node)` ### wasFalse(Node) `public boolean wasFalse(Node node)`. Since 23.0. Returns `true` if the `profile(Node, boolean)` method ever received a `false` value, otherwise `false`. For profiles with profiling disabled or `uncached` profiles this method always returns `true`. Cite: `com/oracle/truffle/api/profiles/InlinedConditionProfile.html#wasFalse(com.oracle.truffle.api.nodes.Node)` ### disable(Node) `public void disable(Node node)`. Since 23.0. Disables this profile by setting it to its generic state. After disabling it is guaranteed to never `deoptimize` on any invocation of a profile method. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Overrides `disable()`. Cite: `com/oracle/truffle/api/profiles/InlinedConditionProfile.html#disable(com.oracle.truffle.api.nodes.Node)` ### reset(Node) `public void reset(Node node)`. Since 23.0. Resets this profile to its uninitialized state. Has no effect if this profile is already in its uninitialized state or a disabled version of this profile is used. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Overrides `reset()`. Cite: `com/oracle/truffle/api/profiles/InlinedConditionProfile.html#reset(com.oracle.truffle.api.nodes.Node)` ### toString(Node) `public String toString(Node node)`. Since 23.0. Prints a string representation of this inlined profile given a target node. Overrides `toString()`. Cite: `com/oracle/truffle/api/profiles/InlinedConditionProfile.html#toString(com.oracle.truffle.api.nodes.Node)` ### inline(InlineSupport.InlineTarget) `public static InlinedConditionProfile inline(InlineSupport.InlineTarget target)`. Since 23.0. Returns an inlined version of the profile. This version is automatically used by Truffle DSL node inlining. Cite: `com/oracle/truffle/api/profiles/InlinedConditionProfile.html#inline(com.oracle.truffle.api.dsl.InlineSupport.InlineTarget)` ### getUncached() `public static InlinedConditionProfile getUncached()`. Since 23.0. Returns the uncached version of the profile. The uncached version of a profile does not perform any profiling. Cite: `com/oracle/truffle/api/profiles/InlinedConditionProfile.html#getUncached()` ## Inherited members - From class [`InlinedProfile`](com/oracle/truffle/api/profiles/InlinedProfile.md): [`toString`](com/oracle/truffle/api/profiles/InlinedProfile.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ InlinedCountingConditionProfile [truffle-api](index.md) › [com.oracle.truffle.api.profiles](com/oracle/truffle/api/profiles/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.profiles`](com/oracle/truffle/api/profiles/index.md). Since 23.0. ```java public final class InlinedCountingConditionProfile extends InlinedProfile ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`InlinedProfile`](com/oracle/truffle/api/profiles/InlinedProfile.md) > `InlinedCountingConditionProfile` CountingConditionProfiles are useful to profile the outcome of conditions. A counting condition profile holds a count for each branch whether a branch was hit or not and communicates this to the compiler as frequency information. If binary information only is desired for each branch should use [`InlinedConditionProfile`](com/oracle/truffle/api/profiles/InlinedConditionProfile.md) instead. ** Usage example:** ```java abstract class AbsoluteNode extends Node { abstract void execute(int value); @Specialization int doDefault(int value, @Cached InlinedCountingConditionProfile p) { if (p.profile(this, value >= 0)) { return value; } else { return -value; } } } ``` ## Methods ### profile(Node, boolean) `public boolean profile(Node node, boolean value)`. Since 23.0. Cite: `com/oracle/truffle/api/profiles/InlinedCountingConditionProfile.html#profile(com.oracle.truffle.api.nodes.Node,boolean)` ### wasTrue(Node) `public boolean wasTrue(Node node)`. Since 23.0. Returns `true` if the `profile(Node, boolean)` method ever received a `true` value, otherwise `false`. For profiles with profiling disabled or `uncached` profiles this method always returns `true`. Cite: `com/oracle/truffle/api/profiles/InlinedCountingConditionProfile.html#wasTrue(com.oracle.truffle.api.nodes.Node)` ### wasFalse(Node) `public boolean wasFalse(Node node)`. Since 23.0. Returns `true` if the `profile(Node, boolean)` method ever received a `false` value, otherwise `false`. For profiles with profiling disabled or `uncached` profiles this method always returns `true`. Cite: `com/oracle/truffle/api/profiles/InlinedCountingConditionProfile.html#wasFalse(com.oracle.truffle.api.nodes.Node)` ### disable(Node) `public void disable(Node node)`. Since 23.0. Disables this profile by setting it to its generic state. After disabling it is guaranteed to never `deoptimize` on any invocation of a profile method. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Overrides `disable()`. Cite: `com/oracle/truffle/api/profiles/InlinedCountingConditionProfile.html#disable(com.oracle.truffle.api.nodes.Node)` ### reset(Node) `public void reset(Node node)`. Since 23.0. Resets this profile to its uninitialized state. Has no effect if this profile is already in its uninitialized state or a disabled version of this profile is used. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Overrides `reset()`. Cite: `com/oracle/truffle/api/profiles/InlinedCountingConditionProfile.html#reset(com.oracle.truffle.api.nodes.Node)` ### toString(Node) `public String toString(Node node)`. Since 23.0. Prints a string representation of this inlined profile given a target node. Overrides `toString()`. Cite: `com/oracle/truffle/api/profiles/InlinedCountingConditionProfile.html#toString(com.oracle.truffle.api.nodes.Node)` ### inline(InlineSupport.InlineTarget) `public static InlinedCountingConditionProfile inline(InlineSupport.InlineTarget target)`. Since 23.0. Returns an inlined version of the profile. This version is automatically used by Truffle DSL node inlining. Cite: `com/oracle/truffle/api/profiles/InlinedCountingConditionProfile.html#inline(com.oracle.truffle.api.dsl.InlineSupport.InlineTarget)` ### getUncached() `public static InlinedCountingConditionProfile getUncached()`. Since 23.0. Returns the uncached version of the profile. The uncached version of a profile does not perform any profiling. Cite: `com/oracle/truffle/api/profiles/InlinedCountingConditionProfile.html#getUncached()` ## Inherited members - From class [`InlinedProfile`](com/oracle/truffle/api/profiles/InlinedProfile.md): [`toString`](com/oracle/truffle/api/profiles/InlinedProfile.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ InlinedDoubleValueProfile [truffle-api](index.md) › [com.oracle.truffle.api.profiles](com/oracle/truffle/api/profiles/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.profiles`](com/oracle/truffle/api/profiles/index.md). Since 23.0. ```java public final class InlinedDoubleValueProfile extends AbstractInlinedValueProfile ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`InlinedProfile`](com/oracle/truffle/api/profiles/InlinedProfile.md) > `AbstractInlinedValueProfile` > `InlinedDoubleValueProfile` Specialized value profile to capture certain properties of `byte` runtime values. Value profiles require a runtime check in their initialized state to verify their profiled assumption. Value profiles are limited to capture monomorphic profiles only. This means that if two or more values are profiled within a single profile then the profile has no effect. If the value assumption is invalidated in compiled code then it is invalidated. ** Usage example:** ```java abstract class DoubleProfileNode extends Node { abstract double execute(double input); @Specialization double doDefault(double input, @Cached InlinedDoubleValueProfile profile) { double profiledValue = profile.profile(this, input); // compiler may now see profiledValue as a partial evaluation constant return profiledValue; } } ``` ## Methods ### profile(Node, double) `public double profile(Node node, double value)`. Since 23.0. Cite: `com/oracle/truffle/api/profiles/InlinedDoubleValueProfile.html#profile(com.oracle.truffle.api.nodes.Node,double)` ### toString(Node) `public String toString(Node node)`. Since 23.0. Prints a string representation of this inlined profile given a target node. Overrides `toString()`. Cite: `com/oracle/truffle/api/profiles/InlinedDoubleValueProfile.html#toString(com.oracle.truffle.api.nodes.Node)` ### inline(InlineSupport.InlineTarget) `public static InlinedDoubleValueProfile inline(InlineSupport.InlineTarget target)`. Since 23.0. Returns an inlined version of the profile. This version is automatically used by Truffle DSL node inlining. Cite: `com/oracle/truffle/api/profiles/InlinedDoubleValueProfile.html#inline(com.oracle.truffle.api.dsl.InlineSupport.InlineTarget)` ### getUncached() `public static InlinedDoubleValueProfile getUncached()`. Since 23.0. Returns the uncached version of the profile. The uncached version of a profile does not perform any profiling. Cite: `com/oracle/truffle/api/profiles/InlinedDoubleValueProfile.html#getUncached()` ## Inherited members - From class `AbstractInlinedValueProfile`: `GENERIC`, `REQUIRED_STATE_BITS`, `SPECIALIZED`, `UNINITIALIZED`, `disable`, `reset`, `state` - From class [`InlinedProfile`](com/oracle/truffle/api/profiles/InlinedProfile.md): [`toString`](com/oracle/truffle/api/profiles/InlinedProfile.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ InlinedExactClassProfile [truffle-api](index.md) › [com.oracle.truffle.api.profiles](com/oracle/truffle/api/profiles/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.profiles`](com/oracle/truffle/api/profiles/index.md). Since 23.0. ```java public final class InlinedExactClassProfile extends AbstractInlinedValueProfile ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`InlinedProfile`](com/oracle/truffle/api/profiles/InlinedProfile.md) > `AbstractInlinedValueProfile` > `InlinedExactClassProfile` Specialized value profile to capture the exact class of `reference` runtime values. Value profiles require a runtime check in their initialized state to verify their profiled assumption. Value profiles are limited to capture monomorphic profiles only. This means that if two or more values are profiled within a single profile then the profile has no effect. If the value assumption is invalidated in compiled code then it is invalidated. ** Usage example:** ```java abstract class ReferenceProfileNode extends Node { abstract Object execute(Object input); @Specialization Object doDefault(Object input, @Cached InlinedExactClassProfile profile) { Object profiledValue = profile.profile(this, input); // compiler may now see the exact class as a partial evaluation constant return profiledValue; } } ``` ## Methods ### profile(Node, T) `public T profile(Node node, T value)`. Since 23.0. Cite: `com/oracle/truffle/api/profiles/InlinedExactClassProfile.html#profile(com.oracle.truffle.api.nodes.Node,T)` ### toString(Node) `public String toString(Node node)`. Since 23.0. Prints a string representation of this inlined profile given a target node. Overrides `toString()`. Cite: `com/oracle/truffle/api/profiles/InlinedExactClassProfile.html#toString(com.oracle.truffle.api.nodes.Node)` ### inline(InlineSupport.InlineTarget) `public static InlinedExactClassProfile inline(InlineSupport.InlineTarget target)`. Since 23.0. Returns an inlined version of the profile. This version is automatically used by Truffle DSL node inlining. Cite: `com/oracle/truffle/api/profiles/InlinedExactClassProfile.html#inline(com.oracle.truffle.api.dsl.InlineSupport.InlineTarget)` ### getUncached() `public static InlinedExactClassProfile getUncached()`. Since 23.0. Returns the uncached version of the profile. The uncached version of a profile does not perform any profiling. Cite: `com/oracle/truffle/api/profiles/InlinedExactClassProfile.html#getUncached()` ## Inherited members - From class `AbstractInlinedValueProfile`: `GENERIC`, `REQUIRED_STATE_BITS`, `SPECIALIZED`, `UNINITIALIZED`, `disable`, `reset`, `state` - From class [`InlinedProfile`](com/oracle/truffle/api/profiles/InlinedProfile.md): [`toString`](com/oracle/truffle/api/profiles/InlinedProfile.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ InlinedFloatValueProfile [truffle-api](index.md) › [com.oracle.truffle.api.profiles](com/oracle/truffle/api/profiles/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.profiles`](com/oracle/truffle/api/profiles/index.md). Since 23.0. ```java public final class InlinedFloatValueProfile extends AbstractInlinedValueProfile ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`InlinedProfile`](com/oracle/truffle/api/profiles/InlinedProfile.md) > `AbstractInlinedValueProfile` > `InlinedFloatValueProfile` Specialized value profile to capture certain properties of `float` runtime values. Value profiles require a runtime check in their initialized state to verify their profiled assumption. Value profiles are limited to capture monomorphic profiles only. This means that if two or more values are profiled within a single profile then the profile has no effect. If the value assumption is invalidated in compiled code then it is invalidated. ** Usage example:** ```java abstract class FloatProfileNode extends Node { abstract float execute(float input); @Specialization float doDefault(float input, @Cached InlinedFloatValueProfile profile) { float profiledValue = profile.profile(this, input); // compiler may now see profiledValue as a partial evaluation constant return profiledValue; } } ``` ## Methods ### profile(Node, float) `public float profile(Node node, float value)`. Since 23.0. Cite: `com/oracle/truffle/api/profiles/InlinedFloatValueProfile.html#profile(com.oracle.truffle.api.nodes.Node,float)` ### toString(Node) `public String toString(Node node)`. Since 23.0. Prints a string representation of this inlined profile given a target node. Overrides `toString()`. Cite: `com/oracle/truffle/api/profiles/InlinedFloatValueProfile.html#toString(com.oracle.truffle.api.nodes.Node)` ### inline(InlineSupport.InlineTarget) `public static InlinedFloatValueProfile inline(InlineSupport.InlineTarget target)`. Since 23.0. Returns an inlined version of the profile. This version is automatically used by Truffle DSL node inlining. Cite: `com/oracle/truffle/api/profiles/InlinedFloatValueProfile.html#inline(com.oracle.truffle.api.dsl.InlineSupport.InlineTarget)` ### getUncached() `public static InlinedFloatValueProfile getUncached()`. Since 23.0. Returns the uncached version of the profile. The uncached version of a profile does not perform any profiling. Cite: `com/oracle/truffle/api/profiles/InlinedFloatValueProfile.html#getUncached()` ## Inherited members - From class `AbstractInlinedValueProfile`: `GENERIC`, `REQUIRED_STATE_BITS`, `SPECIALIZED`, `UNINITIALIZED`, `disable`, `reset`, `state` - From class [`InlinedProfile`](com/oracle/truffle/api/profiles/InlinedProfile.md): [`toString`](com/oracle/truffle/api/profiles/InlinedProfile.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ InlinedIntValueProfile [truffle-api](index.md) › [com.oracle.truffle.api.profiles](com/oracle/truffle/api/profiles/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.profiles`](com/oracle/truffle/api/profiles/index.md). Since 23.0. ```java public final class InlinedIntValueProfile extends AbstractInlinedValueProfile ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`InlinedProfile`](com/oracle/truffle/api/profiles/InlinedProfile.md) > `AbstractInlinedValueProfile` > `InlinedIntValueProfile` Specialized value profile to capture certain properties of `int` runtime values. Value profiles require a runtime check in their initialized state to verify their profiled assumption. Value profiles are limited to capture monomorphic profiles only. This means that if two or more values are profiled within a single profile then the profile has no effect. If the value assumption is invalidated in compiled code then it is invalidated. ** Usage example:** ```java abstract class IntProfileNode extends Node { abstract int execute(int input); @Specialization int doDefault(int input, @Cached InlinedIntValueProfile profile) { int profiledValue = profile.profile(this, input); // compiler may now see profiledValue as a partial evaluation constant return profiledValue; } } ``` ## Methods ### profile(Node, int) `public int profile(Node node, int value)`. Since 23.0. Cite: `com/oracle/truffle/api/profiles/InlinedIntValueProfile.html#profile(com.oracle.truffle.api.nodes.Node,int)` ### toString(Node) `public String toString(Node node)`. Since 23.0. Prints a string representation of this inlined profile given a target node. Overrides `toString()`. Cite: `com/oracle/truffle/api/profiles/InlinedIntValueProfile.html#toString(com.oracle.truffle.api.nodes.Node)` ### inline(InlineSupport.InlineTarget) `public static InlinedIntValueProfile inline(InlineSupport.InlineTarget target)`. Since 23.0. Returns an inlined version of the profile. This version is automatically used by Truffle DSL node inlining. Cite: `com/oracle/truffle/api/profiles/InlinedIntValueProfile.html#inline(com.oracle.truffle.api.dsl.InlineSupport.InlineTarget)` ### getUncached() `public static InlinedIntValueProfile getUncached()`. Since 23.0. Returns the uncached version of the profile. The uncached version of a profile does not perform any profiling. Cite: `com/oracle/truffle/api/profiles/InlinedIntValueProfile.html#getUncached()` ## Inherited members - From class `AbstractInlinedValueProfile`: `GENERIC`, `REQUIRED_STATE_BITS`, `SPECIALIZED`, `UNINITIALIZED`, `disable`, `reset`, `state` - From class [`InlinedProfile`](com/oracle/truffle/api/profiles/InlinedProfile.md): [`toString`](com/oracle/truffle/api/profiles/InlinedProfile.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ InlinedLongValueProfile [truffle-api](index.md) › [com.oracle.truffle.api.profiles](com/oracle/truffle/api/profiles/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.profiles`](com/oracle/truffle/api/profiles/index.md). Since 23.0. ```java public final class InlinedLongValueProfile extends AbstractInlinedValueProfile ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`InlinedProfile`](com/oracle/truffle/api/profiles/InlinedProfile.md) > `AbstractInlinedValueProfile` > `InlinedLongValueProfile` Specialized value profile to capture certain properties of `long` runtime values. Value profiles require a runtime check in their initialized state to verify their profiled assumption. Value profiles are limited to capture monomorphic profiles only. This means that if two or more values are profiled within a single profile then the profile has no effect. If the value assumption is invalidated in compiled code then it is invalidated. ** Usage example:** ```java abstract class LongProfileNode extends Node { abstract long execute(long input); @Specialization long doDefault(byte input, @Cached InlinedLongValueProfile profile) { long profiledValue = profile.profile(this, input); // compiler may now see profiledValue as a partial evaluation constant return profiledValue; } } ``` ## Methods ### profile(Node, long) `public long profile(Node node, long value)`. Since 23.0. Cite: `com/oracle/truffle/api/profiles/InlinedLongValueProfile.html#profile(com.oracle.truffle.api.nodes.Node,long)` ### toString(Node) `public String toString(Node node)`. Since 23.0. Prints a string representation of this inlined profile given a target node. Overrides `toString()`. Cite: `com/oracle/truffle/api/profiles/InlinedLongValueProfile.html#toString(com.oracle.truffle.api.nodes.Node)` ### inline(InlineSupport.InlineTarget) `public static InlinedLongValueProfile inline(InlineSupport.InlineTarget target)`. Since 23.0. Returns an inlined version of the profile. This version is automatically used by Truffle DSL node inlining. Cite: `com/oracle/truffle/api/profiles/InlinedLongValueProfile.html#inline(com.oracle.truffle.api.dsl.InlineSupport.InlineTarget)` ### getUncached() `public static InlinedLongValueProfile getUncached()`. Since 23.0. Returns the uncached version of the profile. The uncached version of a profile does not perform any profiling. Cite: `com/oracle/truffle/api/profiles/InlinedLongValueProfile.html#getUncached()` ## Inherited members - From class `AbstractInlinedValueProfile`: `GENERIC`, `REQUIRED_STATE_BITS`, `SPECIALIZED`, `UNINITIALIZED`, `disable`, `reset`, `state` - From class [`InlinedProfile`](com/oracle/truffle/api/profiles/InlinedProfile.md): [`toString`](com/oracle/truffle/api/profiles/InlinedProfile.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ InlinedLoopConditionProfile [truffle-api](index.md) › [com.oracle.truffle.api.profiles](com/oracle/truffle/api/profiles/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.profiles`](com/oracle/truffle/api/profiles/index.md). Since 23.0. ```java public final class InlinedLoopConditionProfile extends InlinedProfile ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`InlinedProfile`](com/oracle/truffle/api/profiles/InlinedProfile.md) > `InlinedLoopConditionProfile` InlinedLoopConditionProfiles are designed to profile the outcome of loop conditions. Loop profiles can be used to profile unpredictable loops as well as predictable loops. This profile is intended to be used in combination with Truffle DSL. ** Uncounted loop usage example:** ```java class LoopNode extends Node { abstract void execute(); @Specialization void doDefault(@Cached InlinedLoopConditionProfile loopProfile) { // loop count cannot be predicted while (loopProfile.profile(this, Math.random() >= 0.9)) { // work } } } ``` ** Counted loop usage example:** ```java class CountedLoopNode extends Node { abstract void execute(int length); @Specialization void doDefault(int length, @Cached InlinedLoopConditionProfile loopProfile) { // loop count can be predicted loopProfile.profileCounted(this, length); for (int i = 0; loopProfile.inject(this, i < length); i++) { // work } } } ``` The advantage of using [`profileCounted(Node, long)`](com/oracle/truffle/api/profiles/InlinedLoopConditionProfile.md#profileCounted%28com.oracle.truffle.api.nodes.Node,long%29) to using [`profile(Node, boolean)`](com/oracle/truffle/api/profiles/InlinedLoopConditionProfile.md#profile%28com.oracle.truffle.api.nodes.Node,boolean%29) is that it incurs less overhead in the interpreter. Using [`InlinedLoopConditionProfile.inject(Node, boolean)`](com/oracle/truffle/api/profiles/InlinedLoopConditionProfile.md#inject%28com.oracle.truffle.api.nodes.Node,boolean%29) is a no-op in the interpreter while [`profile(Node, boolean)`](com/oracle/truffle/api/profiles/InlinedLoopConditionProfile.md#profile%28com.oracle.truffle.api.nodes.Node,boolean%29) needs to use a counter for each iteration. **See also** - [`InlinedConditionProfile`](com/oracle/truffle/api/profiles/InlinedConditionProfile.md) - [`InlinedCountingConditionProfile`](com/oracle/truffle/api/profiles/InlinedCountingConditionProfile.md) - [`LoopConditionProfile`](com/oracle/truffle/api/profiles/LoopConditionProfile.md) ## Methods ### profile(Node, boolean) `public boolean profile(Node node, boolean condition)`. Since 23.0. Cite: `com/oracle/truffle/api/profiles/InlinedLoopConditionProfile.html#profile(com.oracle.truffle.api.nodes.Node,boolean)` ### profileCounted(Node, long) `public void profileCounted(Node node, long length)`. Since 23.0. Provides an alternative way to profile counted loops with less interpreter footprint. Please see `InlinedLoopConditionProfile` for an usage example. See also: `inject(Node, boolean)`. Cite: `com/oracle/truffle/api/profiles/InlinedLoopConditionProfile.html#profileCounted(com.oracle.truffle.api.nodes.Node,long)` ### inject(Node, boolean) `public boolean inject(Node node, boolean condition)`. Since 23.0. Provides an alternative way to profile counted loops with less interpreter footprint. Please see `InlinedLoopConditionProfile` for an usage example. Cite: `com/oracle/truffle/api/profiles/InlinedLoopConditionProfile.html#inject(com.oracle.truffle.api.nodes.Node,boolean)` ### wasTrue(Node) `public boolean wasTrue(Node node)`. Since 23.0. Returns `true` if the `profile(Node, boolean)` method ever received a `true` value, otherwise `false`. For profiles with profiling disabled or `uncached` profiles this method always returns `true`. Cite: `com/oracle/truffle/api/profiles/InlinedLoopConditionProfile.html#wasTrue(com.oracle.truffle.api.nodes.Node)` ### wasFalse(Node) `public boolean wasFalse(Node node)`. Since 23.0. Returns `true` if the `profile(Node, boolean)` method ever received a `false` value, otherwise `false`. For profiles with profiling disabled or `uncached` profiles this method always returns `true`. Cite: `com/oracle/truffle/api/profiles/InlinedLoopConditionProfile.html#wasFalse(com.oracle.truffle.api.nodes.Node)` ### disable(Node) `public void disable(Node node)`. Since 23.0. Disables this profile by setting it to its generic state. After disabling it is guaranteed to never `deoptimize` on any invocation of a profile method. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Overrides `disable()`. Cite: `com/oracle/truffle/api/profiles/InlinedLoopConditionProfile.html#disable(com.oracle.truffle.api.nodes.Node)` ### reset(Node) `public void reset(Node node)`. Since 23.0. Resets this profile to its uninitialized state. Has no effect if this profile is already in its uninitialized state or a disabled version of this profile is used. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Overrides `reset()`. Cite: `com/oracle/truffle/api/profiles/InlinedLoopConditionProfile.html#reset(com.oracle.truffle.api.nodes.Node)` ### toString(Node) `public String toString(Node node)`. Since 23.0. Prints a string representation of this inlined profile given a target node. Overrides `toString()`. Cite: `com/oracle/truffle/api/profiles/InlinedLoopConditionProfile.html#toString(com.oracle.truffle.api.nodes.Node)` ### inline(InlineSupport.InlineTarget) `public static InlinedLoopConditionProfile inline(InlineSupport.InlineTarget target)`. Since 23.0. Returns an inlined version of the profile. This version is automatically used by Truffle DSL node inlining. Cite: `com/oracle/truffle/api/profiles/InlinedLoopConditionProfile.html#inline(com.oracle.truffle.api.dsl.InlineSupport.InlineTarget)` ### getUncached() `public static InlinedLoopConditionProfile getUncached()`. Since 23.0. Returns the uncached version of the profile. The uncached version of a profile does not perform any profiling. Cite: `com/oracle/truffle/api/profiles/InlinedLoopConditionProfile.html#getUncached()` ## Inherited members - From class [`InlinedProfile`](com/oracle/truffle/api/profiles/InlinedProfile.md): [`toString`](com/oracle/truffle/api/profiles/InlinedProfile.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ InlinedProfile [truffle-api](index.md) › [com.oracle.truffle.api.profiles](com/oracle/truffle/api/profiles/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.profiles`](com/oracle/truffle/api/profiles/index.md). Since 23.0. ```java public abstract class InlinedProfile ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `InlinedProfile` A profile is a Truffle utility class that uses the [`Truffle compiler directives`](com/oracle/truffle/api/CompilerDirectives.md) to guard for and/or forward runtime information to the compiler. Whenever Truffle DSL can be used [`inlined profiles`](com/oracle/truffle/api/profiles/InlinedProfile.md) subclasses should be used instead of regular [`profile`](com/oracle/truffle/api/profiles/Profile.md) subclasses. **Usage:** Inlined profiles are used using the [`Cached`](com/oracle/truffle/api/dsl/Cached.md) annotation in specialization methods. See the individual profile subclasses for further usage examples. Profiles are intended for local speculation only. For global speculations use [`assumptions`](com/oracle/truffle/api/Assumption.md) instead. **Compilation:** Some profiles like [`branch`](com/oracle/truffle/api/profiles/InlinedBranchProfile.md) profiles do not induce additional overhead in compiled code. Others like [`value`](com/oracle/truffle/api/profiles/InlinedByteValueProfile.md) profiles might require a runtime check to verify their local speculation. Even if profiles do not induce direct overhead in compiled code it still might get invalidated as a result of using profiles. Invalidating profiles will result in the invalidation of compiled code. It is therefore essential to place these profiles in way that is neither too aggressive nor too conservative, ideally based on measurements in real world applications. **Footprint:** Inlined versions of profiles have a significantly reduced memory footprint compared to their [`allocated`](com/oracle/truffle/api/profiles/Profile.md) counterparts, however they do rely on their usage being inlined to have the same performance characteristics. Whether profiling information can be forwarded to the compiler depends on the capabilities of the [`runtime system`](com/oracle/truffle/api/TruffleRuntime.md). If the runtime returns `true` in [`TruffleRuntime.isProfilingEnabled()`](com/oracle/truffle/api/TruffleRuntime.md#isProfilingEnabled%28%29) then runtime information will get collected. This comes at the cost of additional overhead and footprint in interpreted mode. Thats why the factory methods of profiles can return implementations where profiling is disabled. Using disabled profiles makes sense for runtimes that are unable to use the collected profiling information. Even runtime implementations that are able to use this information might decide to turn off profiling for benchmarking purposes. Inlined profile subclasses: - [`InlinedBranchProfile`](com/oracle/truffle/api/profiles/InlinedBranchProfile.md) to profile on unlikely branches like errors. - [`InlinedConditionProfile`](com/oracle/truffle/api/profiles/InlinedConditionProfile.md) to profile on conditionals or boolean values. - [`InlinedCountingConditionProfile`](com/oracle/truffle/api/profiles/InlinedCountingConditionProfile.md) to profile on conditionals or boolean values using counters. - [`InlinedLoopConditionProfile`](com/oracle/truffle/api/profiles/InlinedLoopConditionProfile.md) to profile on conditionals of loops with special support for counted loops. - [`InlinedByteValueProfile`](com/oracle/truffle/api/profiles/InlinedByteValueProfile.md) to profile on `byte` values. - [`InlinedIntValueProfile`](com/oracle/truffle/api/profiles/InlinedIntValueProfile.md) to profile on `int` values. - [`InlinedLongValueProfile`](com/oracle/truffle/api/profiles/InlinedLongValueProfile.md) to profile on `long` values. - [`InlinedFloatValueProfile`](com/oracle/truffle/api/profiles/InlinedFloatValueProfile.md) to profile on `float` values. - [`InlinedDoubleValueProfile`](com/oracle/truffle/api/profiles/InlinedDoubleValueProfile.md) to profile on `double` values. **See also** - [`InlinedProfile`](com/oracle/truffle/api/profiles/InlinedProfile.md) - [`Assumption`](com/oracle/truffle/api/Assumption.md) ## Methods ### disable(Node) `public abstract void disable(Node node)`. Since 23.0. Disables this profile by setting it to its generic state. After disabling it is guaranteed to never `deoptimize` on any invocation of a profile method. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Cite: `com/oracle/truffle/api/profiles/InlinedProfile.html#disable(com.oracle.truffle.api.nodes.Node)` ### reset(Node) `public abstract void reset(Node node)`. Since 23.0. Resets this profile to its uninitialized state. Has no effect if this profile is already in its uninitialized state or a disabled version of this profile is used. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Cite: `com/oracle/truffle/api/profiles/InlinedProfile.html#reset(com.oracle.truffle.api.nodes.Node)` ### toString(Node) `public abstract String toString(Node node)`. Since 23.0. Prints a string representation of this inlined profile given a target node. Cite: `com/oracle/truffle/api/profiles/InlinedProfile.html#toString(com.oracle.truffle.api.nodes.Node)` ### toString() `public final String toString()`. Since 23.0. Overrides `toString()`. Cite: `com/oracle/truffle/api/profiles/InlinedProfile.html#toString()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ IntValueProfile [truffle-api](index.md) › [com.oracle.truffle.api.profiles](com/oracle/truffle/api/profiles/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.profiles`](com/oracle/truffle/api/profiles/index.md). Since 0.10. ```java public final class IntValueProfile extends Profile ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`NodeCloneable`](com/oracle/truffle/api/nodes/NodeCloneable.md) > [`Profile`](com/oracle/truffle/api/profiles/Profile.md) > `IntValueProfile` Specialized value profile to capture certain properties of `int` runtime values. Value profiles require a runtime check in their initialized state to verify their profiled assumption. Value profiles are limited to capture monomorphic profiles only. This means that if two or more values are profiled within a single profile then the profile has no effect. If the value assumption is invalidated in compiled code then it is invalidated. ** Usage example:** ```java class SampleNode extends Node { final IntValueProfile profile = IntValueProfile.createIdentityProfile(); int execute(int input) { int profiledValue = profile.profile(input); // compiler may know now more about profiledValue return profiledValue; } } ``` **See also** - [`createIdentityProfile()`](com/oracle/truffle/api/profiles/IntValueProfile.md#createIdentityProfile%28%29) - [`ValueProfile`](com/oracle/truffle/api/profiles/ValueProfile.md) ## Methods ### profile(int) `public int profile(int value)`. Since 0.10. Cite: `com/oracle/truffle/api/profiles/IntValueProfile.html#profile(int)` ### disable() `public void disable()`. Since 22.1. Disables this profile by setting it to its generic state. After disabling it is guaranteed to never `deoptimize` on any invocation of a profile method. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Overrides `disable()`. Cite: `com/oracle/truffle/api/profiles/IntValueProfile.html#disable()` ### reset() `public void reset()`. Since 22.1. Resets this profile to its uninitialized state. Has no effect if this profile is already in its uninitialized state or a disabled version of this profile is used. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Overrides `reset()`. Cite: `com/oracle/truffle/api/profiles/IntValueProfile.html#reset()` ### toString() `public String toString()`. Since 22.1. Overrides `toString()`. Cite: `com/oracle/truffle/api/profiles/IntValueProfile.html#toString()` ### createIdentityProfile() `public static IntValueProfile createIdentityProfile()`. Since 0.10. Returns a value profile that profiles the exact value of an `int`. See also: `IntValueProfile`. Cite: `com/oracle/truffle/api/profiles/IntValueProfile.html#createIdentityProfile()` ### create() `public static IntValueProfile create()`. Since 22.1. Returns a value profile that profiles the exact value of an `int`. See also: `IntValueProfile`. Cite: `com/oracle/truffle/api/profiles/IntValueProfile.html#create()` ### getUncached() `public static IntValueProfile getUncached()`. Since 19.0. Returns the uncached version of the profile. The uncached version of a profile does nothing. Cite: `com/oracle/truffle/api/profiles/IntValueProfile.html#getUncached()` ### inline(InlineSupport.InlineTarget) `public static InlinedIntValueProfile inline(InlineSupport.InlineTarget target)`. Since 23.0. Returns an inlined version of the profile. This version is automatically used by Truffle DSL node inlining. Cite: `com/oracle/truffle/api/profiles/IntValueProfile.html#inline(com.oracle.truffle.api.dsl.InlineSupport.InlineTarget)` ## Inherited members - From class [`NodeCloneable`](com/oracle/truffle/api/nodes/NodeCloneable.md): [`clone`](com/oracle/truffle/api/nodes/NodeCloneable.md#clone%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ LongValueProfile [truffle-api](index.md) › [com.oracle.truffle.api.profiles](com/oracle/truffle/api/profiles/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.profiles`](com/oracle/truffle/api/profiles/index.md). Since 0.10. ```java public final class LongValueProfile extends Profile ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`NodeCloneable`](com/oracle/truffle/api/nodes/NodeCloneable.md) > [`Profile`](com/oracle/truffle/api/profiles/Profile.md) > `LongValueProfile` Specialized value profile to capture certain properties of `long` runtime values. Value profiles require a runtime check in their initialized state to verify their profiled assumption. Value profiles are limited to capture monomorphic profiles only. This means that if two or more values are profiled within a single profile then the profile has no effect. If the value assumption is invalidated in compiled code then it is invalidated. ** Usage example:** ```java class SampleNode extends Node { final LongValueProfile profile = LongValueProfile.createIdentityProfile(); long execute(long input) { long profiledValue = profile.profile(input); // compiler may know now more about profiledValue return profiledValue; } } ``` **See also** - [`createIdentityProfile()`](com/oracle/truffle/api/profiles/LongValueProfile.md#createIdentityProfile%28%29) - [`ValueProfile`](com/oracle/truffle/api/profiles/ValueProfile.md) ## Methods ### profile(long) `public long profile(long value)`. Since 0.10. Cite: `com/oracle/truffle/api/profiles/LongValueProfile.html#profile(long)` ### disable() `public void disable()`. Since 22.1. Disables this profile by setting it to its generic state. After disabling it is guaranteed to never `deoptimize` on any invocation of a profile method. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Overrides `disable()`. Cite: `com/oracle/truffle/api/profiles/LongValueProfile.html#disable()` ### reset() `public void reset()`. Since 22.1. Resets this profile to its uninitialized state. Has no effect if this profile is already in its uninitialized state or a disabled version of this profile is used. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Overrides `reset()`. Cite: `com/oracle/truffle/api/profiles/LongValueProfile.html#reset()` ### toString() `public String toString()`. Since 22.1. Overrides `toString()`. Cite: `com/oracle/truffle/api/profiles/LongValueProfile.html#toString()` ### createIdentityProfile() `public static LongValueProfile createIdentityProfile()`. Since 0.10. Returns a value profile that profiles the exact value of an `long`. See also: `LongValueProfile`. Cite: `com/oracle/truffle/api/profiles/LongValueProfile.html#createIdentityProfile()` ### create() `public static LongValueProfile create()`. Since 22.1. Returns a value profile that profiles the exact value of an `long`. See also: `LongValueProfile`. Cite: `com/oracle/truffle/api/profiles/LongValueProfile.html#create()` ### getUncached() `public static LongValueProfile getUncached()`. Since 19.0. Returns the uncached version of the profile. The uncached version of a profile does nothing. Cite: `com/oracle/truffle/api/profiles/LongValueProfile.html#getUncached()` ### inline(InlineSupport.InlineTarget) `public static InlinedLongValueProfile inline(InlineSupport.InlineTarget target)`. Since 23.0. Returns an inlined version of the profile. This version is automatically used by Truffle DSL node inlining. Cite: `com/oracle/truffle/api/profiles/LongValueProfile.html#inline(com.oracle.truffle.api.dsl.InlineSupport.InlineTarget)` ## Inherited members - From class [`NodeCloneable`](com/oracle/truffle/api/nodes/NodeCloneable.md): [`clone`](com/oracle/truffle/api/nodes/NodeCloneable.md#clone%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ LoopConditionProfile [truffle-api](index.md) › [com.oracle.truffle.api.profiles](com/oracle/truffle/api/profiles/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.profiles`](com/oracle/truffle/api/profiles/index.md). Since 0.10. ```java public final class LoopConditionProfile extends ConditionProfile ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`NodeCloneable`](com/oracle/truffle/api/nodes/NodeCloneable.md) > [`Profile`](com/oracle/truffle/api/profiles/Profile.md) > [`ConditionProfile`](com/oracle/truffle/api/profiles/ConditionProfile.md) > `LoopConditionProfile` LoopConditionProfiles are designed to profile the outcome of loop conditions. Loop profiles can be used to profile unpredictable loops as well as predictable loops. ** Arbitrary loop usage example:** ```java class LoopNode extends Node { final LoopConditionProfile loopProfile = LoopConditionProfile.create(); void execute() { // loop count cannot be predicted while (loopProfile.profile(Math.random() >= 0.9)) { // work } } } ``` ** Counted loop usage example:** ```java class CountedLoopNode extends Node { final LoopConditionProfile loopProfile = LoopConditionProfile.create(); void execute(int length) { // loop count can be predicted loopProfile.profileCounted(length); for (int i = 0; loopProfile.inject(i < length); i++) { // work } } } ``` The advantage of using [`profileCounted(long)`](com/oracle/truffle/api/profiles/LoopConditionProfile.md#profileCounted%28long%29) to using [`profile(boolean)`](com/oracle/truffle/api/profiles/LoopConditionProfile.md#profile%28boolean%29) is that it incurs less overhead in the interpreter. Using [`LoopConditionProfile.inject(boolean)`](com/oracle/truffle/api/profiles/LoopConditionProfile.md#inject%28boolean%29) is a no-op in the interpreter while [`profile(boolean)`](com/oracle/truffle/api/profiles/LoopConditionProfile.md#profile%28boolean%29) needs to use a counter for each iteration. **See also** - [`create()`](com/oracle/truffle/api/profiles/LoopConditionProfile.md#create%28%29) - [`LoopConditionProfile`](com/oracle/truffle/api/profiles/LoopConditionProfile.md) ## Methods ### profile(boolean) `public boolean profile(boolean condition)`. Since 0.10. Overrides `profile()`. Cite: `com/oracle/truffle/api/profiles/LoopConditionProfile.html#profile(boolean)` ### profileCounted(long) `public void profileCounted(long length)`. Since 0.10. Provides an alternative way to profile counted loops with less interpreter footprint. Please see `LoopConditionProfile` for an usage example. See also: `inject(boolean)`. Cite: `com/oracle/truffle/api/profiles/LoopConditionProfile.html#profileCounted(long)` ### inject(boolean) `public boolean inject(boolean condition)`. Since 0.10. Provides an alternative way to profile counted loops with less interpreter footprint. Please see `LoopConditionProfile` for an usage example. See also: `inject(boolean)`. Cite: `com/oracle/truffle/api/profiles/LoopConditionProfile.html#inject(boolean)` ### disable() `public void disable()`. Since 22.1. Disables this profile by setting it to its generic state. After disabling it is guaranteed to never `deoptimize` on any invocation of a profile method. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Overrides `disable()`. Cite: `com/oracle/truffle/api/profiles/LoopConditionProfile.html#disable()` ### reset() `public void reset()`. Since 22.1. Resets this profile to its uninitialized state. Has no effect if this profile is already in its uninitialized state or a disabled version of this profile is used. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Overrides `reset()`. Cite: `com/oracle/truffle/api/profiles/LoopConditionProfile.html#reset()` ### toString() `public String toString()`. Since 22.1. Overrides `toString()`. Cite: `com/oracle/truffle/api/profiles/LoopConditionProfile.html#toString()` ### create() `public static LoopConditionProfile create()`. Since 21.2. Returns a `LoopConditionProfile` that speculates on loop conditions to be never `true`. It also captures loop probabilities for the compiler. Loop condition profiles are intended to be used for loop conditions. Cite: `com/oracle/truffle/api/profiles/LoopConditionProfile.html#create()` ### getUncached() `public static LoopConditionProfile getUncached()`. Since 19.0. Returns the uncached version of the profile. The uncached version of a profile does nothing. Cite: `com/oracle/truffle/api/profiles/LoopConditionProfile.html#getUncached()` ## Inherited members - From class [`ConditionProfile`](com/oracle/truffle/api/profiles/ConditionProfile.md): [`create`](com/oracle/truffle/api/profiles/ConditionProfile.md#create%28%29), [`getUncached`](com/oracle/truffle/api/profiles/ConditionProfile.md#getUncached%28%29), [`inline`](com/oracle/truffle/api/profiles/ConditionProfile.md#inline%28com.oracle.truffle.api.dsl.InlineSupport.InlineTarget%29) - From class [`NodeCloneable`](com/oracle/truffle/api/nodes/NodeCloneable.md): [`clone`](com/oracle/truffle/api/nodes/NodeCloneable.md#clone%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ PrimitiveValueProfile [truffle-api](index.md) › [com.oracle.truffle.api.profiles](com/oracle/truffle/api/profiles/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.profiles`](com/oracle/truffle/api/profiles/index.md). Since 0.10. ```java public final class PrimitiveValueProfile extends ValueProfile ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`NodeCloneable`](com/oracle/truffle/api/nodes/NodeCloneable.md) > [`Profile`](com/oracle/truffle/api/profiles/Profile.md) > [`ValueProfile`](com/oracle/truffle/api/profiles/ValueProfile.md) > `PrimitiveValueProfile` Represents a [`ValueProfile`](com/oracle/truffle/api/profiles/ValueProfile.md) that speculates on the primitive equality or object identity of values. Note that for `float` and `double` values we compare primitive equality via [`Float.floatToRawIntBits`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Float.html#floatToRawIntBits%28float%29) and [`Double.doubleToRawLongBits`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Double.html#doubleToRawLongBits%28double%29), so that for example `-0.0` is not considered the same as `0.0`, even though primitive equality would normally say that it was. ## Methods ### profile(T) `public T profile(T v)`. Since 0.8 or earlier. Overrides `profile()`. Cite: `com/oracle/truffle/api/profiles/PrimitiveValueProfile.html#profile(T)` ### profile(byte) `public byte profile(byte value)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/profiles/PrimitiveValueProfile.html#profile(byte)` ### profile(short) `public short profile(short value)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/profiles/PrimitiveValueProfile.html#profile(short)` ### profile(int) `public int profile(int value)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/profiles/PrimitiveValueProfile.html#profile(int)` ### profile(long) `public long profile(long value)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/profiles/PrimitiveValueProfile.html#profile(long)` ### profile(float) `public float profile(float value)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/profiles/PrimitiveValueProfile.html#profile(float)` ### profile(double) `public double profile(double value)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/profiles/PrimitiveValueProfile.html#profile(double)` ### profile(boolean) `public boolean profile(boolean value)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/profiles/PrimitiveValueProfile.html#profile(boolean)` ### profile(char) `public char profile(char value)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/profiles/PrimitiveValueProfile.html#profile(char)` ### disable() `public void disable()`. Since 22.1. Disables this profile by setting it to its generic state. After disabling it is guaranteed to never `deoptimize` on any invocation of a profile method. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Overrides `disable()`. Cite: `com/oracle/truffle/api/profiles/PrimitiveValueProfile.html#disable()` ### reset() `public void reset()`. Since 22.1. Resets this profile to its uninitialized state. Has no effect if this profile is already in its uninitialized state or a disabled version of this profile is used. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Overrides `reset()`. Cite: `com/oracle/truffle/api/profiles/PrimitiveValueProfile.html#reset()` ### toString() `public String toString()`. Since 22.1. Overrides `toString()`. Cite: `com/oracle/truffle/api/profiles/PrimitiveValueProfile.html#toString()` ### createEqualityProfile() `public static PrimitiveValueProfile createEqualityProfile()`. Since 0.10. Returns a `PrimitiveValueProfile` that speculates on the primitive equality or object identity of a value. Cite: `com/oracle/truffle/api/profiles/PrimitiveValueProfile.html#createEqualityProfile()` ### create() `public static PrimitiveValueProfile create()`. Since 22.1. Returns a `PrimitiveValueProfile` that speculates on the primitive equality or object identity of a value. Cite: `com/oracle/truffle/api/profiles/PrimitiveValueProfile.html#create()` ### getUncached() `public static PrimitiveValueProfile getUncached()`. Since 19.0. Returns the uncached version of the profile. The uncached version of a profile does nothing. Cite: `com/oracle/truffle/api/profiles/PrimitiveValueProfile.html#getUncached()` ## Inherited members - From class [`ValueProfile`](com/oracle/truffle/api/profiles/ValueProfile.md): [`create`](com/oracle/truffle/api/profiles/ValueProfile.md#create%28%29), [`createClassProfile`](com/oracle/truffle/api/profiles/ValueProfile.md#createClassProfile%28%29), [`createIdentityProfile`](com/oracle/truffle/api/profiles/ValueProfile.md#createIdentityProfile%28%29), [`getUncached`](com/oracle/truffle/api/profiles/ValueProfile.md#getUncached%28%29), [`inline`](com/oracle/truffle/api/profiles/ValueProfile.md#inline%28com.oracle.truffle.api.dsl.InlineSupport.InlineTarget%29) - From class [`NodeCloneable`](com/oracle/truffle/api/nodes/NodeCloneable.md): [`clone`](com/oracle/truffle/api/nodes/NodeCloneable.md#clone%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ Profile [truffle-api](index.md) › [com.oracle.truffle.api.profiles](com/oracle/truffle/api/profiles/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.profiles`](com/oracle/truffle/api/profiles/index.md). Since 0.10. ```java public abstract class Profile extends NodeCloneable ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`NodeCloneable`](com/oracle/truffle/api/nodes/NodeCloneable.md) > `Profile` A profile is a Truffle utility class that uses the [`Truffle compiler directives`](com/oracle/truffle/api/CompilerDirectives.md) to guard for and/or forward runtime information to the compiler. Whenever Truffle DSL can be used [`inlined profiles`](com/oracle/truffle/api/profiles/InlinedProfile.md) subclasses should be used instead of regular [`profile`](com/oracle/truffle/api/profiles/Profile.md) subclasses. **Usage:** Profiles should be stored in `final` or [`compilation final`](com/oracle/truffle/api/CompilerDirectives.CompilationFinal.md) fields of node classes to ensure that they can get optimized properly. Profiles must not be shared between ASTs. Using the same profile multiple times in a single [`node`](com/oracle/truffle/api/nodes/Node.md) or in multiple [`nodes`](com/oracle/truffle/api/nodes/Node.md) which [`link`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29) to the same [`root`](com/oracle/truffle/api/nodes/RootNode.md) is allowed. **Never** store profiles inside runtime values that leave the scope of the originating AST. This limitation exists because the used mechanism to invalidate compiled code performs local invalidations only. For global speculations use [`assumptions`](com/oracle/truffle/api/Assumption.md) instead. **Compilation:** Some profiles like [`branch`](com/oracle/truffle/api/profiles/BranchProfile.md) profiles do not induce additional overhead in compiled code. Others like [`value`](com/oracle/truffle/api/profiles/ValueProfile.md) profiles might require a runtime check to verify their assumptions which are forwarded to the compiler. Even if profiles do not induce direct overhead in compiled code it still might get invalidated as a result of using profiles. Invalidating profiles will result in the invalidation of compiled code. It is therefore essential to place these profiles in way that is neither too aggressive nor too conservative. **Footprint:** Whether profiling information can be forwarded to the compiler depends on the capabilities of the [`runtime system`](com/oracle/truffle/api/TruffleRuntime.md). If the runtime returns `true` in [`TruffleRuntime.isProfilingEnabled()`](com/oracle/truffle/api/TruffleRuntime.md#isProfilingEnabled%28%29) then runtime information will get collected. This comes at the cost of additional overhead and footprint in interpreted mode. Thats why the factory methods of profiles can return implementations where profiling is disabled. Using disabled profiles makes sense for runtimes that are unable to use the collected profiling information. Even runtime implementations that are able to use this information might decide to turn off profiling for benchmarking purposes. Profile subclasses: - [`BranchProfile`](com/oracle/truffle/api/profiles/BranchProfile.md) to profile on unlikely branches like errors. - [`ConditionProfile`](com/oracle/truffle/api/profiles/ConditionProfile.md) to profile on conditionals or boolean values. - [`LoopConditionProfile`](com/oracle/truffle/api/profiles/LoopConditionProfile.md) to profile on conditionals of loops with special support for counted loops. - [`ValueProfile`](com/oracle/truffle/api/profiles/ValueProfile.md) to profile on properties like type and identity of values. - [`ByteValueProfile`](com/oracle/truffle/api/profiles/ByteValueProfile.md) to profile on `byte` values. - [`IntValueProfile`](com/oracle/truffle/api/profiles/IntValueProfile.md) to profile on `int` values. - [`LongValueProfile`](com/oracle/truffle/api/profiles/LongValueProfile.md) to profile on `long` values. - [`FloatValueProfile`](com/oracle/truffle/api/profiles/FloatValueProfile.md) to profile on `float` values. - [`DoubleValueProfile`](com/oracle/truffle/api/profiles/DoubleValueProfile.md) to profile on `double` values. - [`PrimitiveValueProfile`](com/oracle/truffle/api/profiles/PrimitiveValueProfile.md) to profile on objects by identity and on primitives by value. **See also** - [`InlinedProfile`](com/oracle/truffle/api/profiles/InlinedProfile.md) - [`Assumption`](com/oracle/truffle/api/Assumption.md) ## Methods ### disable() `public void disable()`. Since 21.1. Disables this profile by setting it to its generic state. After disabling it is guaranteed to never `deoptimize` on any invocation of a profile method. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Cite: `com/oracle/truffle/api/profiles/Profile.html#disable()` ### reset() `public void reset()`. Since 21.1. Resets this profile to its uninitialized state. Has no effect if this profile is already in its uninitialized state or a disabled version of this profile is used. This method must not be called on compiled code paths. Note that disabling the profile will not invalidate existing compiled code that uses this profile. Cite: `com/oracle/truffle/api/profiles/Profile.html#reset()` ## Inherited members - From class [`NodeCloneable`](com/oracle/truffle/api/nodes/NodeCloneable.md): [`clone`](com/oracle/truffle/api/nodes/NodeCloneable.md#clone%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ ValueProfile [truffle-api](index.md) › [com.oracle.truffle.api.profiles](com/oracle/truffle/api/profiles/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.profiles`](com/oracle/truffle/api/profiles/index.md). Since 0.10. ```java public abstract class ValueProfile extends Profile ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`NodeCloneable`](com/oracle/truffle/api/nodes/NodeCloneable.md) > [`Profile`](com/oracle/truffle/api/profiles/Profile.md) > `ValueProfile` Specialized value profile to capture certain properties of `Object` runtime values. Value profiles require a runtime check in their initialized state to verify their profiled assumption. Value profiles are limited to capture monomorphic profiles only. This means that if two or more identities or classes are profiles within a single profile then the profile has no effect and no overhead after compilation. There are specialized versions of this profile with less interpreter footprint for [`boolean`](com/oracle/truffle/api/profiles/ConditionProfile.md), [`byte`](com/oracle/truffle/api/profiles/ByteValueProfile.md), [`int`](com/oracle/truffle/api/profiles/IntValueProfile.md), [`long`](com/oracle/truffle/api/profiles/LongValueProfile.md), [`float`](com/oracle/truffle/api/profiles/FloatValueProfile.md) and [`double`](com/oracle/truffle/api/profiles/DoubleValueProfile.md) values. ** Usage example:** ```java class SampleNode extends Node { final ValueProfile profile = ValueProfile.create{Identity,Class}Profile(); Object execute(Object input) { Object profiledValue = profile.profile(input); // compiler may know now more about profiledValue return profieldValue; } } ``` **See also** - [`createIdentityProfile()`](com/oracle/truffle/api/profiles/ValueProfile.md#createIdentityProfile%28%29) - [`createClassProfile()`](com/oracle/truffle/api/profiles/ValueProfile.md#createClassProfile%28%29) ## Methods ### profile(T) `public abstract T profile(T value)`. Since 0.10. Cite: `com/oracle/truffle/api/profiles/ValueProfile.html#profile(T)` ### createClassProfile() `public static ValueProfile createClassProfile()`. Since 0.10. Returns a value profile that profiles the exact class of a value. It will check the class of the profiled value and provide additional information to the compiler if only non-null values of exactly one concrete Java class are passed as a parameter to the `ValueProfile.profile` method. This can be beneficial if subsequent code can take advantage of knowing the concrete class of the value. The profile will degrade to the generic case if a null value or if at least two instances of two different Java classes are registered. **Compilation notes:** Value profiles require a runtime check in their initialized state to verify their profiled class. If two classes have been seen on a single profile instance then this profile will transition to a generic state with no overhead. See also: `usage example`. Cite: `com/oracle/truffle/api/profiles/ValueProfile.html#createClassProfile()` ### create() `public static ValueProfile create()`. Since 23.0. Returns a value profile that profiles the exact class of a value. It will check the class of the profiled value and provide additional information to the compiler if only non-null values of exactly one concrete Java class are passed as a parameter to the `ValueProfile.profile` method. This can be beneficial if subsequent code can take advantage of knowing the concrete class of the value. The profile will degrade to the generic case if a null value or if at least two instances of two different Java classes are registered. **Compilation notes:** Value profiles require a runtime check in their initialized state to verify their profiled class. If two classes have been seen on a single profile instance then this profile will transition to a generic state with no overhead. See also: `usage example`. Cite: `com/oracle/truffle/api/profiles/ValueProfile.html#create()` ### createIdentityProfile() `public static ValueProfile createIdentityProfile()`. Since 0.10. Returns a value profile that profiles the object identity of a value. A single instance can only profile one particular instance. **Compilation notes:** Identity profiles require a runtime check to verify their profiled object identity. If two identities have been seen on a single profile instance then this profile will transition to a generic state with no overhead. Cite: `com/oracle/truffle/api/profiles/ValueProfile.html#createIdentityProfile()` ### getUncached() `public static ValueProfile getUncached()`. Since 19.0. Returns the uncached version of the profile. The uncached version of a profile does nothing. Cite: `com/oracle/truffle/api/profiles/ValueProfile.html#getUncached()` ### inline(InlineSupport.InlineTarget) `public static InlinedExactClassProfile inline(InlineSupport.InlineTarget target)`. Since 23.0. Returns an inlined version of the profile. This version is automatically used by Truffle DSL node inlining. Cite: `com/oracle/truffle/api/profiles/ValueProfile.html#inline(com.oracle.truffle.api.dsl.InlineSupport.InlineTarget)` ## Inherited members - From class [`Profile`](com/oracle/truffle/api/profiles/Profile.md): [`disable`](com/oracle/truffle/api/profiles/Profile.md#disable%28%29), [`reset`](com/oracle/truffle/api/profiles/Profile.md#reset%28%29) - From class [`NodeCloneable`](com/oracle/truffle/api/nodes/NodeCloneable.md): [`clone`](com/oracle/truffle/api/nodes/NodeCloneable.md#clone%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ▣ com.oracle.truffle.api.provider [truffle-api](index.md) · Every page: [llms.txt](llms.txt) Package in truffle-api. Since 23.1. This package contains a provider to instantiate a Truffle language. The Truffle language provider is not intended to be implemented directly by a language developer, rather the implementation is generated by the Truffle DSL. ## Classes - [`InternalResourceProvider`](com/oracle/truffle/api/provider/InternalResourceProvider.md): Used to register an optional InternalResource using a ServiceLoader. - [`TruffleLanguageProvider`](com/oracle/truffle/api/provider/TruffleLanguageProvider.md): Used to register a TruffleLanguage using a ServiceLoader. # ◆ InternalResourceProvider [truffle-api](index.md) › [com.oracle.truffle.api.provider](com/oracle/truffle/api/provider/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.provider`](com/oracle/truffle/api/provider/index.md). Since 23.1. ```java public abstract class InternalResourceProvider ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `InternalResourceProvider` Used to register an optional [`InternalResource`](com/oracle/truffle/api/InternalResource.md) using a [`ServiceLoader`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/ServiceLoader.html). This interface is not intended to be implemented directly by a language developer, rather the implementation is generated by the Truffle DSL. ## Constructors ### InternalResourceProvider() `public InternalResourceProvider()`. Declared by the compiler. Creates a new InternalResourceProvider instance. Cite: `com/oracle/truffle/api/provider/InternalResourceProvider.html#()` ## Methods ### getComponentId() `protected abstract String getComponentId()`. Since 23.1. Provides the identifier of the language or instrument to which the resource belongs. Cite: `com/oracle/truffle/api/provider/InternalResourceProvider.html#getComponentId()` ### getResourceId() `protected abstract String getResourceId()`. Since 23.1. An internal resource identifier. The value is derived from `Id.value()`. Cite: `com/oracle/truffle/api/provider/InternalResourceProvider.html#getResourceId()` ### createInternalResource() `protected abstract Object createInternalResource()`. Since 23.1. Creates an `InternalResource` instance. Cite: `com/oracle/truffle/api/provider/InternalResourceProvider.html#createInternalResource()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleLanguageProvider [truffle-api](index.md) › [com.oracle.truffle.api.provider](com/oracle/truffle/api/provider/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.provider`](com/oracle/truffle/api/provider/index.md). Since 23.1. ```java public abstract class TruffleLanguageProvider ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `TruffleLanguageProvider` Used to register a [`TruffleLanguage`](com/oracle/truffle/api/TruffleLanguage.md) using a [`ServiceLoader`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/ServiceLoader.html). This interface is not intended to be implemented directly by a language developer, rather the implementation is generated by the Truffle DSL. The generated implementation has to inherit the [`Registration`](com/oracle/truffle/api/TruffleLanguage.Registration.md) and `ProvidedTags` annotations from the [`TruffleLanguage`](com/oracle/truffle/api/TruffleLanguage.md). ## Constructors ### TruffleLanguageProvider() `protected TruffleLanguageProvider()`. Since 23.1. Constructor to be called by subclasses. Cite: `com/oracle/truffle/api/provider/TruffleLanguageProvider.html#()` ## Methods ### getLanguageClassName() `protected abstract String getLanguageClassName()`. Since 23.1. Returns the name of a class implementing the `TruffleLanguage`. Cite: `com/oracle/truffle/api/provider/TruffleLanguageProvider.html#getLanguageClassName()` ### create() `protected abstract Object create()`. Since 23.1. Creates a new instance of a `TruffleLanguage`. Cite: `com/oracle/truffle/api/provider/TruffleLanguageProvider.html#create()` ### getServicesClassNames() `protected abstract Collection getServicesClassNames()`. Since 23.1. Returns the class names of provided services. Cite: `com/oracle/truffle/api/provider/TruffleLanguageProvider.html#getServicesClassNames()` ### createFileTypeDetectors() `protected abstract List createFileTypeDetectors()`. Since 23.1. Creates file type detectors used by the `TruffleLanguage`. Cite: `com/oracle/truffle/api/provider/TruffleLanguageProvider.html#createFileTypeDetectors()` ### getInternalResourceIds() `protected List getInternalResourceIds()`. Since 23.1. Returns ids of provided internal resources. Cite: `com/oracle/truffle/api/provider/TruffleLanguageProvider.html#getInternalResourceIds()` ### createInternalResource(String) `protected Object createInternalResource(String resourceId)`. Since 23.1. Creates a language `InternalResource` identified by the `resourceId`. Throws: `IllegalArgumentException` (unchecked): if `resourceId` is not supported by this language. Cite: `com/oracle/truffle/api/provider/TruffleLanguageProvider.html#createInternalResource(java.lang.String)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ▣ com.oracle.truffle.api.source [truffle-api](index.md) · Every page: [llms.txt](llms.txt) Package in truffle-api. Since 0.8 or older. Represents a [`source file`](com/oracle/truffle/api/source/Source.md). ## Classes - [`Source`](com/oracle/truffle/api/source/Source.md): Representation of a source code unit and its contents that can be evaluated in a language. - [`SourceSection`](com/oracle/truffle/api/source/SourceSection.md): Description of contiguous section of text within a Source of program code.; supports multiple modes of access to the text and its location. # ◆ Source [truffle-api](index.md) › [com.oracle.truffle.api.source](com/oracle/truffle/api/source/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.source`](com/oracle/truffle/api/source/index.md). Since 0.8 or earlier. ```java public abstract class Source ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Source` Representation of a source code unit and its contents that can be evaluated in a language. Each source is associated with the ID of the language. ### From a file on disk Each file is represented as a canonical object, indexed by the absolute, canonical path name of the file. File content is *read eagerly* and may be optionally *cached*. Sample usage: ```java assert file.getName().endsWith(".java") : "Imagine 'c:\\sources\\Example.java' file"; String language = Source.findLanguage(file); Source source = Source.newBuilder(language, file).build(); assert file.getName().equals(source.getName()); assert file.getPath().equals(source.getPath()); assert file.toUri().equals(source.getURI()); ``` The starting point is [`Source.newBuilder(String, TruffleFile)`](com/oracle/truffle/api/source/Source.md#newBuilder%28java.lang.String,com.oracle.truffle.api.TruffleFile%29) method. ### Read from a URL One can read remote or in JAR resources using the [`Source.newBuilder(String, java.net.URL)`](com/oracle/truffle/api/source/Source.md#newBuilder%28java.lang.String,java.net.URL%29) factory: ```java URL resource = relativeClass.getResource("sample.js"); Source source = Source.newBuilder("js", resource) .build(); assert resource.toExternalForm().equals(source.getPath()); assert "sample.js".equals(source.getName()); assert resource.toURI().equals(source.getURI()); ``` Each URL source is represented as a canonical object, indexed by the URL. Contents are *read eagerly* once the [`SourceBuilder.build()`](com/oracle/truffle/api/source/Source.SourceBuilder.md#build%28%29) method is called. ### Source from a literal text An anonymous immutable code snippet can be created from a string via the [`Source.newBuilder(String, CharSequence, String)`](com/oracle/truffle/api/source/Source.md#newBuilder%28java.lang.String,java.lang.CharSequence,java.lang.String%29) factory method: ```java Source source = Source.newBuilder("js", "function() {\n" + " return 'Hi';\n" + "}\n", "hi.js").build(); assert "hi.js".equals(source.getName()); ``` ### Reading from a stream If one has a [`Reader`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/Reader.html) one can convert its content into a [`Source`](com/oracle/truffle/api/source/Source.md) via [`Source.newBuilder(String, java.io.Reader, String)`](com/oracle/truffle/api/source/Source.md#newBuilder%28java.lang.String,java.io.Reader,java.lang.String%29) method: ```java Reader stream = new InputStreamReader( relativeClass.getResourceAsStream("sample.js") ); Source source = Source.newBuilder("js", stream, "sample.js") .build(); assert "sample.js".equals(source.getName()); ``` the content is *read eagerly* once the [`SourceBuilder.build()`](com/oracle/truffle/api/source/Source.SourceBuilder.md#build%28%29) method is called. ### Reading from bytes Sources can be created from bytes. Please note that all character related methods will throw an [`UnsupportedOperationException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/UnsupportedOperationException.html) if that is the case. ```java byte[] bytes = new byte[] {/* Binary */}; Source source = Source.newBuilder("llvm", ByteSequence.create(bytes), "").build(); ``` ## Attributes The source object can be associated with various attributes like [`getName()`](com/oracle/truffle/api/source/Source.md#getName%28%29) , [`()`](com/oracle/truffle/api/source/Source.md#getURI%28%29), [`getMimeType()`](com/oracle/truffle/api/source/Source.md#getMimeType%28%29) and these are immutable. The system makes the best effort to derive values of these attributes from the location and/or content of the [`Source`](com/oracle/truffle/api/source/Source.md) object. However, to give the user that creates the source control over these attributes, the API offers an easy way to alter values of these attributes. ## Character and binary based Sources A source is [`byte`](com/oracle/truffle/api/source/Source.md#hasBytes%28%29) or [`character`](com/oracle/truffle/api/source/Source.md#hasCharacters%28%29) based, or none of those when [`no content`](com/oracle/truffle/api/source/Source.md#CONTENT_NONE) is specified. For literal sources it depends on whether the byte or character based factory method was used. When the source was loaded from a [`file`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/File.html) or [`url`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/URL.html) then the [`default MIME type`](com/oracle/truffle/api/nodes/LanguageInfo.md#getDefaultMimeType%28%29) of the provided language will be used to determine whether bytes or characters should be loaded. The behavior can be customized by specifying a [`MIME type`](com/oracle/truffle/api/source/Source.SourceBuilder.md#mimeType%28java.lang.String%29) or [`content`](com/oracle/truffle/api/source/Source.SourceBuilder.md#content%28org.graalvm.polyglot.io.ByteSequence%29) explicitly. If the specified or inferred MIME type starts with `'text/` or the MIME types is `null` then it will be interpreted as character based, otherwise byte based. ## Nested types - [`Source.LiteralBuilder`](com/oracle/truffle/api/source/Source.LiteralBuilder.md) (class): Allows one to specify additional attribute before creating new Source instance. - [`Source.SourceBuilder`](com/oracle/truffle/api/source/Source.SourceBuilder.md) (class): Allows one to specify additional attribute before creating new Source instance. ## Fields ### CONTENT_NONE `public static final CharSequence CONTENT_NONE`. Since 19.0. Constant to be used as an argument to `SourceBuilder.content(CharSequence)` to set no content to the Source built. The created sections will contain location information only and no characters. That's useful mainly when the source code is not available, but there are relative file paths, like in Java bytecode or LLVM bitcode. It's up to tools to resolve those relative paths and use the section location in resolved sources. Cite: `com/oracle/truffle/api/source/Source.html#CONTENT_NONE` ## Methods ### getLanguage() `public abstract String getLanguage()`. Since 0.28. Returns the language this source was created with. The string returned matches the `id` of the language. Returns `String`: the language of this source. Cite: `com/oracle/truffle/api/source/Source.html#getLanguage()` ### getName() `public abstract String getName()`. Since 0.8 or earlier. Returns the name of this resource holding a guest language program. An example would be the name of a guest language source code file. Name is supposed to be shorter than `getPath()`. Returns `String`: the name of the guest language program. Cite: `com/oracle/truffle/api/source/Source.html#getName()` ### getPath() `public abstract String getPath()`. Since 0.8 or earlier. The fully qualified name of the source. In case this source originates from a [`File`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/File.html) or `TruffleFile`, then the path is the normalized, [`canonical path`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/File.html#getCanonicalPath%28%29). If `canonicalizePath(false)` is used when building the source then `TruffleFile.getPath()` is used instead. If the source originates from an [`URL`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/URL.html), then it's the path component of the URL. Cite: `com/oracle/truffle/api/source/Source.html#getPath()` ### isInternal() `public abstract boolean isInternal()`. Since 0.15. Check whether this source has been marked as *internal*, meaning that it has been provided by the infrastructure, language implementation, or system library. *Internal* sources are presumed to be irrelevant to guest language programmers, as well as possibly confusing and revealing of language implementation details. On the other hand, tools should be free to make *internal* sources visible in (possibly privileged) modes that are useful for language implementors. One can specify whether a source is internal when `building it`. Returns `boolean`: whether this source is marked as *internal*. Cite: `com/oracle/truffle/api/source/Source.html#isInternal()` ### isCached() `public abstract boolean isCached()`. Since 19.0. Returns `true` if code caching is enabled for this source. If `true` then the source does not require parsing every time this source is evaluated. If `false` then the source requires parsing every time the source is evaluated but does not remember any state. Disabling caching may be useful if the source is known to only be evaluated once. Returns `boolean`: whether this source is allowed to be *cached*. Cite: `com/oracle/truffle/api/source/Source.html#isCached()` ### isInteractive() `public abstract boolean isInteractive()`. Since 0.21. Check whether this source has been marked as *interactive*. Interactive sources are provided by an entity which is able to interactively read output and provide an input during the source execution; that can be a user I/O through an interactive shell for instance. Depending on `language interactive` capability, when *interactive* sources are executed, the appropriate result can be passed directly to the environment `output stream` or `error stream` and `input stream` can be used to read user input during the execution, to clarify the execution behavior by asking questions for instance. Non-interactive languages are expected to ignore this property. One can specify whether a source is interactive when `building it`. Returns `boolean`: whether this source is marked as *interactive*. Cite: `com/oracle/truffle/api/source/Source.html#isInteractive()` ### equals(Object) `public final boolean equals(Object obj)`. Since 19.0. Overrides `equals(java.lang.Object)`. Cite: `com/oracle/truffle/api/source/Source.html#equals(java.lang.Object)` ### hashCode() `public final int hashCode()`. Since 19.0. Overrides `hashCode()`. Cite: `com/oracle/truffle/api/source/Source.html#hashCode()` ### subSource(int, int) `public Source subSource(int baseCharIndex, int length)`. Since 0.15. Creates a Source instance that represents the contents of a sub-range of an `this` `Source`. Parameters: `baseCharIndex` `int`: 0-based index of the first character of the sub-range. `length` `int`: the number of characters in the sub-range. Returns `Source`: a new instance representing a sub-range of another Source. Throws: `IllegalArgumentException` (unchecked): if the specified sub-range is not contained in the base. `UnsupportedOperationException` (unchecked): if this source cannot contain `characters`. Cite: `com/oracle/truffle/api/source/Source.html#subSource(int,int)` ### getCharacters() `public abstract CharSequence getCharacters()`. Since 0.28. Returns all characters of the source. Throws: `UnsupportedOperationException` (unchecked): if this source cannot contain `characters`. Cite: `com/oracle/truffle/api/source/Source.html#getCharacters()` ### getCharacters(int) `public final CharSequence getCharacters(int lineNumber)`. Since 0.28. Gets the text (not including a possible terminating newline) in a (1-based) numbered line. Causes the contents of this source to be loaded if they are loaded lazily. Throws: `UnsupportedOperationException` (unchecked): if this source cannot contain `characters`. Cite: `com/oracle/truffle/api/source/Source.html#getCharacters(int)` ### hasBytes() `public abstract boolean hasBytes()`. Since 19.0. Returns `true` if this source represents a byte based source, else `false`. A source is either a byte based, a character based, or with `no content`, but never both byte and character based at the same time. The method `getBytes()` is only supported if this method returns `true`. See also: `getBytes()`. Cite: `com/oracle/truffle/api/source/Source.html#hasBytes()` ### hasCharacters() `public abstract boolean hasCharacters()`. Since 19.0. Returns `true` if this source represents a character based source, else `false`. A source is either a byte based, a character based, or with `no content`, but never both byte and character based at the same time. The following methods are only supported if `hasCharacters()` is `true`: `getReader()`; `getCharacters()`; `getLineCount()`; `getLineNumber(int)`; `getColumnNumber(int)`; `getLineStartOffset(int)`; `getLineLength(int)`. Cite: `com/oracle/truffle/api/source/Source.html#hasCharacters()` ### getBytes() `public abstract ByteSequence getBytes()`. Since 19.0. Returns the bytes of the source if it is a `byte based source`. Throws: `UnsupportedOperationException` (unchecked): if this source cannot contain `bytes` . See also: `hasBytes()`. Cite: `com/oracle/truffle/api/source/Source.html#getBytes()` ### getURL() `public abstract URL getURL()`. Since 0.8 or earlier. The URL if the source is retrieved via URL. Returns `URL`: URL or `null`. Cite: `com/oracle/truffle/api/source/Source.html#getURL()` ### getURI() `public final URI getURI()`. Since 0.14. Get URI of the source. Every source has an associated [`URI`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/URI.html), which can be used as a persistent identification of the source. For example one can `register a breakpoint using a URI` to a source that isn't loaded yet and it will be activated when the source is evaluated. The [`URI`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/URI.html) returned by this method should be as unique as possible, yet it can happen that different `sources` return the same `getURI` - for example when content of a `file on a disk` changes and is re-loaded. Returns `URI`: a URI, it's never `null`. Cite: `com/oracle/truffle/api/source/Source.html#getURI()` ### getMimeType() `public abstract String getMimeType()`. Since 19.0. Returns the MIME type that is associated with this source. Sources have a `null` MIME type by default. If the MIME type is `null` then the [`default MIME type`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Language.html#getDefaultMimeType%28%29) of the language will be used to interpret the source. If set explicitly then the language needs to [`support`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Language.html#getMimeTypes%28%29) the MIME type in order to [`Context.eval(org.graalvm.polyglot.Source)`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Context.html#eval%28org.graalvm.polyglot.Source%29) evaluate} the source. If not `null` the MIME type is already verified containing no spaces and a '/' between group and sub-group. An example for a valid MIME type is: `text/javascript`. The MIME type can be guessed by the system based on `files` or `urls`. Returns `String`: MIME type of this source or `null`, if not explicitly set. See also: `LanguageInfo.getDefaultMimeType()`, `LanguageInfo.getMimeTypes()`, `Source.findMimeType(TruffleFile)`, `Source.findMimeType(URL)`. Cite: `com/oracle/truffle/api/source/Source.html#getMimeType()` ### getReader() `public final Reader getReader()`. Since 0.8 or earlier. Access to the source contents. Cite: `com/oracle/truffle/api/source/Source.html#getReader()` ### getLength() `public final int getLength()`. Since 0.8. Gets the number of characters or bytes of the source. Throws: `UnsupportedOperationException` (unchecked): if this source does not contain `characters`, nor `bytes`. Cite: `com/oracle/truffle/api/source/Source.html#getLength()` ### getLineCount() `public final int getLineCount()`. Since 0.8 or earlier. The number of text lines in the source, including empty lines; characters at the end of the source without a terminating newline count as a line. Causes the contents of this source to be loaded if they are loaded lazily. Throws: `UnsupportedOperationException` (unchecked): if this source cannot contain `characters`. Cite: `com/oracle/truffle/api/source/Source.html#getLineCount()` ### getLineNumber(int) `public final int getLineNumber(int offset) throws IllegalArgumentException`. Since 0.8 or earlier. Given a 0-based character offset, return the 1-based number of the line that includes the position. Causes the contents of this source to be loaded if they are loaded lazily. Throws: `UnsupportedOperationException` (unchecked): if this source cannot contain `characters`. `IllegalArgumentException`: if the offset is outside the text contents. Cite: `com/oracle/truffle/api/source/Source.html#getLineNumber(int)` ### getColumnNumber(int) `public final int getColumnNumber(int offset) throws IllegalArgumentException`. Since 0.8 or earlier. Given a 0-based character offset, return the 1-based number of the column at the position. Causes the contents of this source to be loaded if they are loaded lazily. Throws: `UnsupportedOperationException` (unchecked): if this source cannot contain `characters`. `IllegalArgumentException`: if the offset is outside the text contents. Cite: `com/oracle/truffle/api/source/Source.html#getColumnNumber(int)` ### getLineStartOffset(int) `public final int getLineStartOffset(int lineNumber) throws IllegalArgumentException`. Since 0.8 or earlier. Given a 1-based line number, return the 0-based offset of the first character in the line. Throws: `UnsupportedOperationException` (unchecked): if this source cannot contain `characters`. `IllegalArgumentException`: if there is no such line in the text. Cite: `com/oracle/truffle/api/source/Source.html#getLineStartOffset(int)` ### getLineLength(int) `public final int getLineLength(int lineNumber) throws IllegalArgumentException`. Since 0.8 or earlier. The number of characters (not counting a possible terminating newline) in a (1-based) numbered line. Causes the contents of this source to be loaded if they are loaded lazily. Throws: `UnsupportedOperationException` (unchecked): if this source cannot contain `characters`. `IllegalArgumentException`: if there is no such line in the text. Cite: `com/oracle/truffle/api/source/Source.html#getLineLength(int)` ### getOptions(TruffleLanguage) `public final OptionValues getOptions(TruffleLanguage language)`. Since 25.0. Returns the parsed option values of the given source for the given language. Options can be specified by implementing `TruffleLanguage.getSourceOptionDescriptors()`. When accessing source options during parsing, use `ParsingRequest.getOptionValues()` instead of this method, to avoid parsing the options twice. Note that options may not be validated beforehand, which can result in an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) if validation fails. If the source was parsed previously, all options are guaranteed to have been validated. Otherwise, this method validates only the options of the current language. Parameters: `language` `TruffleLanguage`: the language accessible via `LanguageReference`. Returns `OptionValues`: the parsed [`OptionValues`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/options/OptionValues.html) for the specified source. Throws: `IllegalArgumentException` (unchecked): if option validation fails. See also: `to access options from an instrument`. Cite: `com/oracle/truffle/api/source/Source.html#getOptions(com.oracle.truffle.api.TruffleLanguage)` ### createUnavailableSection() `public final SourceSection createUnavailableSection()`. Since 0.18. Returns an unavailable source section indicating that the source location is not available. Unavailable source sections have the same characteristics as empty source sections with character index `0`, but returns `false` for `SourceSection.isAvailable()`. Unavailable source sections may be created for character and byte based sources. See also: `SourceSection.isAvailable()`. Cite: `com/oracle/truffle/api/source/Source.html#createUnavailableSection()` ### createSection(int, int, …) `public final SourceSection createSection(int startLine, int startColumn, int endLine, int endColumn)`. Since 19.0. Create representation of a contiguous region in the source that does not have the character content available. Parameters: `startLine` `int`: 1-based line number of the first character in the section. `startColumn` `int`: 1-based column number of the first character in the section, or `-1` when the column is not defined. `endLine` `int`: 1-based line number of the last character in the section. `endColumn` `int`: 1-based column number of the last character in the section, or `-1` when the column is not defined. Throws: `UnsupportedOperationException` (unchecked): if this source has `bytes`. Cite: `com/oracle/truffle/api/source/Source.html#createSection(int,int,int,int)` ### createSection(int) `public final SourceSection createSection(int lineNumber)`. Since 0.17. Creates a representation of a line of text in the source identified only by line number, from which the character information will be computed. Please note that calling this method does cause the `code` of this source to be loaded, if there is any. If no `code` is `available`, a SourceSection without `character content` is created with the `start line` and the same `end line` defined only. Parameters: `lineNumber` `int`: 1-based line number of the first character in the section. Returns `SourceSection`: newly created object representing the specified line. Throws: `UnsupportedOperationException` (unchecked): if this source contains `bytes`. `IllegalArgumentException` (unchecked): if the given lineNumber does not exist the source. Cite: `com/oracle/truffle/api/source/Source.html#createSection(int)` ### createSection(int, int) `public final SourceSection createSection(int charIndex, int length)`. Since 0.17. Creates a representation of a contiguous region of text in the source. Please note that calling this method does only cause the `code` of this source to be loaded if assertions enabled. The bounds of the source section are only verified if assertions (-ea) are enabled in the host system. An [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) is thrown if the given indices are out of bounds of the source bounds. Parameters: `charIndex` `int`: 0-based position of the first character in the section. `length` `int`: the number of characters in the section. Returns `SourceSection`: newly created object representing the specified region. Throws: `UnsupportedOperationException` (unchecked): if this source cannot contain `characters`. `IllegalArgumentException` (unchecked): if charIndex \< 0 or length \< 0; in case assertions are enabled also if the given bounds are out of the source bounds. Cite: `com/oracle/truffle/api/source/Source.html#createSection(int,int)` ### createSection(int, int, int) `public final SourceSection createSection(int startLine, int startColumn, int length)`. Since 0.17. Creates a representation of a contiguous region of text in the source. When character content is available, computes the `charIndex` value by building a text map of lines in the source. Please note that calling this method does cause the `code` of this source to be loaded, if there is any. If no `code` is `available`, [`UnsupportedOperationException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/UnsupportedOperationException.html) is thrown. Use `createSection(int, int, int, int)` to create a SourceSection without character content. Parameters: `startLine` `int`: 1-based line number of the first character in the section. `startColumn` `int`: 1-based column number of the first character in the section. `length` `int`: the number of characters in the section. Returns `SourceSection`: newly created object representing the specified region. Throws: `UnsupportedOperationException` (unchecked): if this source does not contain `characters`. `IllegalArgumentException` (unchecked): if arguments are outside the text of the source bounds. See also: `createSection(int, int)`, `createSection(int, int, int, int)`. Cite: `com/oracle/truffle/api/source/Source.html#createSection(int,int,int)` ### toString() `public String toString()`. Since 19.0. Overrides `toString()`. Cite: `com/oracle/truffle/api/source/Source.html#toString()` ### newBuilder(String, CharSequence, String) `public static Source.LiteralBuilder newBuilder(String language, CharSequence characters, String name)`. Since 19.0. Creates a new character based literal source from a character sequence. The given characters must not mutate after they were accessed for the first time. Use this method for sources that do originate from a literal. For file or URL sources use the appropriate builder constructor and `SourceBuilder.content(CharSequence)`. Example usage: Parameters: `language` `String`: the language id, must not be `null`. `characters` `CharSequence`: the character sequence or string, must not be `null`. `name` `String`: the name of the source, if `null` then `"Unnamed"` will be used as name. Cite: `com/oracle/truffle/api/source/Source.html#newBuilder(java.lang.String,java.lang.CharSequence,java.lang.String)` ```java Source source = Source.newBuilder("js", "function() {\n" + " return 'Hi';\n" + "}\n", "hi.js").build(); assert "hi.js".equals(source.getName()); ``` ### newBuilder(String, ByteSequence, String) `public static Source.LiteralBuilder newBuilder(String language, ByteSequence bytes, String name)`. Since 19.0. Creates a new byte based literal source from a byte sequence. The given bytes must not mutate after they were accessed for the first time. Use this method for sources that do originate from a literal. For file or URL sources use the appropriate builder constructor and `SourceBuilder.content(ByteSequence)`. Example usage: Parameters: `language` `String`: the language id, must not be `null`. `bytes` `ByteSequence`: the byte sequence or string, must not be `null`. `name` `String`: the name of the source, if `null` then `"Unnamed"` will be used as name. Cite: `com/oracle/truffle/api/source/Source.html#newBuilder(java.lang.String,org.graalvm.polyglot.io.ByteSequence,java.lang.String)` ```java byte[] bytes = new byte[] {/* Binary */}; Source source = Source.newBuilder("llvm", ByteSequence.create(bytes), "").build(); ``` ### newBuilder(String, TruffleFile) `public static Source.SourceBuilder newBuilder(String language, TruffleFile file)`. Since 19.0. Creates a new file based source builder from a given file. A file based source is either interpreted as `binary` or `character` source depending on the `default MIME type` of the language, the `contents` or the specified `MIME type`. A language may be detected from an existing file using `findLanguage(TruffleFile)`. Example usage: Parameters: `language` `String`: the language id, must not be `null`. `file` `TruffleFile`: the file to use and load, must not be `null`. Cite: `com/oracle/truffle/api/source/Source.html#newBuilder(java.lang.String,com.oracle.truffle.api.TruffleFile)` ```java assert file.getName().endsWith(".java") : "Imagine 'c:\\sources\\Example.java' file"; String language = Source.findLanguage(file); Source source = Source.newBuilder(language, file).build(); assert file.getName().equals(source.getName()); assert file.getPath().equals(source.getPath()); assert file.toUri().equals(source.getURI()); ``` ### newBuilder(String, URL) `public static Source.SourceBuilder newBuilder(String language, URL url)`. Since 19.0. Creates a new URL based source builder from a given URL. A URL based source is either interpreted as `binary` or `character` source depending on the `default MIME type` of the language, the `contents` or the specified `MIME type`. A language may be detected from an existing file using `findLanguage(URL)`. Example usage: Parameters: `language` `String`: the language id, must not be `null`. `url` `URL`: the URL to use and load, must not be `null`. Cite: `com/oracle/truffle/api/source/Source.html#newBuilder(java.lang.String,java.net.URL)` ```java URL resource = relativeClass.getResource("sample.js"); Source source = Source.newBuilder("js", resource) .build(); assert resource.toExternalForm().equals(source.getPath()); assert "sample.js".equals(source.getName()); assert resource.toURI().equals(source.getURI()); ``` ### newBuilder(String, Reader, String) `public static Source.SourceBuilder newBuilder(String language, Reader source, String name)`. Since 19.0. Creates new character based literal source from a reader. Use this method for sources that do originate from a literal. For file or URL sources use the appropriate builder constructor and `SourceBuilder.content(CharSequence)`. Example usage: Cite: `com/oracle/truffle/api/source/Source.html#newBuilder(java.lang.String,java.io.Reader,java.lang.String)` ```java Reader stream = new InputStreamReader( relativeClass.getResourceAsStream("sample.js") ); Source source = Source.newBuilder("js", stream, "sample.js") .build(); assert "sample.js".equals(source.getName()); ``` ### newBuilder(Source) `public static Source.LiteralBuilder newBuilder(Source source)`. Since 19.2.0. Creates a new source builder that inherits from the given Source. The Source properties can be modified using the builder methods. Parameters: `source` `Source`: the source to inherit the properties from. Cite: `com/oracle/truffle/api/source/Source.html#newBuilder(com.oracle.truffle.api.source.Source)` ### findLanguage(TruffleFile) `public static String findLanguage(TruffleFile file) throws IOException`. Since 19.0. Returns the first language that supports evaluating the probed mime type of a given [`file`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/File.html). This method is a shortcut for: ` `` String mimeType = Source.findMimeType(file); return mimeType != null ? Source.findLanguage(mimeType) : null; `` `. Parameters: `file` `TruffleFile`: the file to find the first language for. Throws: `IOException`: if an error opening the file occurred. See also: `findMimeType(URL)`, `findLanguage(String)`. Cite: `com/oracle/truffle/api/source/Source.html#findLanguage(com.oracle.truffle.api.TruffleFile)` ### findLanguage(URL) `public static String findLanguage(URL url) throws IOException`. Since 19.0. Returns the first language that supports evaluating the probed mime type of a given [`URL`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/URL.html). This method is a shortcut for: ` `` String mimeType = Source.findMimeType(url); return mimeType != null ? Source.findLanguage(mimeType) : null; `` `. Parameters: `url` `URL`: the url to find the first language for. Throws: `IOException`: if an error opening the url occurred. See also: `findMimeType(URL)`, `findLanguage(String)`. Cite: `com/oracle/truffle/api/source/Source.html#findLanguage(java.net.URL)` ### findLanguage(String) `public static String findLanguage(String mimeType)`. Since 19.0. Returns the first installed language that supports evaluating sources for a given MIME type. Returns `null` if no language was found that supports a given MIME type. The languages are queried in the same order as returned by [`Engine.getLanguages()`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Engine.html#getLanguages%28%29). Cite: `com/oracle/truffle/api/source/Source.html#findLanguage(java.lang.String)` ### findMimeType(TruffleFile) `public static String findMimeType(TruffleFile file) throws IOException`. Since 19.0. Returns the probed MIME type for a given file, or `null` if no MIME type could be resolved. Typically, the MIME type is identified using the file extension and/or using its contents. Probing the MIME type of a `TruffleFile` may require to opening the file. Throws: `IOException`: if an error opening the file occurred. `SecurityException` (unchecked): if the used [`filesystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied file reading. See also: `findLanguage(TruffleFile)`. Cite: `com/oracle/truffle/api/source/Source.html#findMimeType(com.oracle.truffle.api.TruffleFile)` ### findMimeType(URL) `public static String findMimeType(URL url) throws IOException`. Since 19.0. Returns the probed MIME type for a given url, or `null` if no MIME type could be resolved. Typically the MIME type is identified using the file extension, connection meta-data and/or using it contents. Returns `null` if the language of the given file could not be detected. Probing the language of an URL may require to open a new URL connection. Throws: `IOException`: if an error opening the url occurred. `SecurityException` (unchecked): if the used [`filesystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied file reading. See also: `findLanguage(URL)`. Cite: `com/oracle/truffle/api/source/Source.html#findMimeType(java.net.URL)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ Source.LiteralBuilder [truffle-api](index.md) › [com.oracle.truffle.api.source](com/oracle/truffle/api/source/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.source`](com/oracle/truffle/api/source/index.md). Since 19.0. Nested in [`Source`](com/oracle/truffle/api/source/Source.md). ```java public final class Source.LiteralBuilder extends Source.SourceBuilder ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Source.SourceBuilder`](com/oracle/truffle/api/source/Source.SourceBuilder.md) > `LiteralBuilder` Allows one to specify additional attribute before [`creating`](com/oracle/truffle/api/source/Source.LiteralBuilder.md#build%28%29) new [`Source`](com/oracle/truffle/api/source/Source.md) instance. **See also** - [`For examples on how to use it.`](com/oracle/truffle/api/source/Source.SourceBuilder.md) ## Methods ### content(CharSequence) `public Source.LiteralBuilder content(CharSequence characters)`. Since 19.3. Specifies character based content of `to-be-built` `Source`. Using this method one can ignore the real content of a file or URL and use already read one, or completely different one. Use `CONTENT_NONE` to set no content, `Source.hasCharacters()` will be `false` then. The given characters must not mutate after they were accessed for the first time. Example: Parameters: `characters` `CharSequence`: the code to be available via `Source.getCharacters()`, or `CONTENT_NONE`. Returns `Source.LiteralBuilder`: instance of this builder - which's `build()` method no longer throws an [`IOException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/IOException.html). Overrides `content()`. Cite: `com/oracle/truffle/api/source/Source.LiteralBuilder.html#content(java.lang.CharSequence)` ```java URL resource = relativeClass.getResource("sample.js"); Source source = Source.newBuilder("js", resource) .content("{}") .build(); assert resource.toExternalForm().equals(source.getPath()); assert "sample.js".equals(source.getName()); assert resource.toExternalForm().equals(source.getURI().toString()); assert "{}".equals(source.getCharacters()); ``` ### content(ByteSequence) `public Source.LiteralBuilder content(ByteSequence bytes)`. Since 19.3. Specifies byte based content of `to-be-built` `Source`. Using this method one can ignore the real content of a file or URL and use already read one, or completely different one. The given bytes must not mutate after they were accessed for the first time. Example: Parameters: `bytes` `ByteSequence`: the code to be available via `Source.getBytes()`. Returns `Source.LiteralBuilder`: instance of this builder - which's `build()` method no longer throws an [`IOException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/IOException.html). Overrides `content()`. Cite: `com/oracle/truffle/api/source/Source.LiteralBuilder.html#content(org.graalvm.polyglot.io.ByteSequence)` ```java URL resource = relativeClass.getResource("sample.js"); Source source = Source.newBuilder("js", resource) .content("{}") .build(); assert resource.toExternalForm().equals(source.getPath()); assert "sample.js".equals(source.getName()); assert resource.toExternalForm().equals(source.getURI().toString()); assert "{}".equals(source.getCharacters()); ``` ### name(String) `public Source.LiteralBuilder name(String newName)`. Since 19.0. Specifies a name to the `to-be-built` `Source`. Parameters: `newName` `String`: name that replaces the previously given one. If set to `null` then `"Unnamed"` will be used. Returns `Source.LiteralBuilder`: instance of `this` builder. Overrides `name()`. Cite: `com/oracle/truffle/api/source/Source.LiteralBuilder.html#name(java.lang.String)` ### mimeType(String) `public Source.LiteralBuilder mimeType(String newMimeType)`. Since 19.0. Explicitly assigns a `MIME type` to the `to-be-built` `Source`. If the MIME type is `null` then the [`default MIME type`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Language.html#getDefaultMimeType%28%29) of the language will be used to interpret the source. If set explicitly then the language needs to [`support`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Language.html#getMimeTypes%28%29) the MIME type in order to `parse` a source. If not `null` then the MIME type will be verified containing no spaces and a '/' between group and sub-group. An example for a valid MIME type is: `text/javascript`. The MIME type can be guessed by the system based on `files` or `urls`. Parameters: `newMimeType` `String`: the new mime type to be assigned, or `null` if default MIME type should be used. Returns `Source.LiteralBuilder`: instance of `this` builder ready to `create new source`. Overrides `mimeType()`. Cite: `com/oracle/truffle/api/source/Source.LiteralBuilder.html#mimeType(java.lang.String)` ### cached(boolean) `public Source.LiteralBuilder cached(boolean cached)`. Since 19.0. Enables or disables code caching for this source. By default code caching is enabled. If `true` then the source does not require parsing every time this source is evaluated. If `false` then the source requires parsing every time the source is evaluated but does not remember any code. Disabling caching may be useful if the source is known to only be evaluated once. If a source instance is no longer referenced by the client then all code caches will be freed automatically. Also, if the underlying context or engine is no longer referenced then cached code for evaluated sources will be freed automatically. Returns `Source.LiteralBuilder`: instance of `this` builder ready to `create new source`. Overrides `cached()`. Cite: `com/oracle/truffle/api/source/Source.LiteralBuilder.html#cached(boolean)` ### internal(boolean) `public Source.LiteralBuilder internal(boolean enabled)`. Since 19.0. Marks the source as internal. Internal sources are those that aren't created by user, but rather inherently present by the language system. Calling this method influences result of create `Source.isInternal()`. Returns `Source.LiteralBuilder`: the instance of this builder. Overrides `internal()`. Cite: `com/oracle/truffle/api/source/Source.LiteralBuilder.html#internal(boolean)` ### interactive(boolean) `public Source.LiteralBuilder interactive(boolean enabled)`. Since 19.0. Marks the source as interactive. Evaluation of interactive sources by an `interactive language` can use the `environment` streams to print the result and read an input. However, non-interactive languages are expected to ignore the interactive property of sources and not use the environment streams. Any desired printing of the evaluated result provided by a non-interactive language needs to be handled by the caller. Calling of this method influences the result of `Source.isInteractive()`. Returns `Source.LiteralBuilder`: the instance of this builder. Overrides `interactive()`. Cite: `com/oracle/truffle/api/source/Source.LiteralBuilder.html#interactive(boolean)` ### uri(URI) `public Source.LiteralBuilder uri(URI ownUri)`. Since 19.0. Assigns new [`URI`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/URI.html) to the `to-be-created` `Source`. Each source provides `Source.getURI()` as a persistent identification of its location. A default value for the method is deduced from the location or content, but one can change it by using this method. Parameters: `ownUri` `URI`: the URL to use instead of default one, cannot be `null`. Returns `Source.LiteralBuilder`: the instance of this builder. Overrides `uri()`. Cite: `com/oracle/truffle/api/source/Source.LiteralBuilder.html#uri(java.net.URI)` ### canonicalizePath(boolean) `public Source.LiteralBuilder canonicalizePath(boolean canonicalize)`. Since 20.2. Whether the `Source.getPath()` (from the `TruffleFile`) should be canonicalized. By default the path is canonicalized to improve Source caching. If set to `false`, then `Source.getPath()` will be the same as the passed TruffleFile `TruffleFile.getPath()`. Parameters: `canonicalize` `boolean`: whether to canonicalize the path from the TruffleFile. Returns `Source.LiteralBuilder`: the instance of this builder. Overrides `canonicalizePath()`. Cite: `com/oracle/truffle/api/source/Source.LiteralBuilder.html#canonicalizePath(boolean)` ### encoding(Charset) `public Source.LiteralBuilder encoding(Charset encoding)`. Since 19.0. Explicitly assigns an encoding used to read the file content. If the encoding is `null` then the file contained encoding information is used. If the file doesn't provide an encoding information the default `UTF-8` encoding is used. Parameters: `encoding` `Charset`: the new file encoding to be used for reading the content. Returns `Source.LiteralBuilder`: instance of `this` builder ready to `create new source`. Overrides `encoding()`. Cite: `com/oracle/truffle/api/source/Source.LiteralBuilder.html#encoding(java.nio.charset.Charset)` ### option(String, String) `public Source.LiteralBuilder option(String key, String value)`. Sets a source option key and value for the built source. Source options allow you to attach language- or instrument-specific configuration to a source. These options are parsed and validated only when source is parsed by a language, rather than when the source is created. If the source is validated, all source options will be validated. Therefore, each language or instrument associated with a source option must be installed. The available source option keys can be found in the respective language or instrument documentation, or at runtime via [`Language.getSourceOptions()`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Language.html#getSourceOptions%28%29) or [`Instrument.getSourceOptions()`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Instrument.html#getSourceOptions%28%29). Description copied from `option()`. Parameters: `key` `String`: the option key (must not be null). `value` `String`: the option value (must not be null). Overrides `option()`. See also: `ParsingRequest.getOptionValues()`, `TruffleLanguage.getSourceOptionDescriptors()`, `Source.getOptions(TruffleLanguage)`. Cite: `com/oracle/truffle/api/source/Source.LiteralBuilder.html#option(java.lang.String,java.lang.String)` ### options(Map) `public Source.LiteralBuilder options(Map options)`. Shortcut for setting multiple `options` using a map. All values of the provided map must be non-null. Description copied from `options()`. Overrides `options()`. Cite: `com/oracle/truffle/api/source/Source.LiteralBuilder.html#options(java.util.Map)` ### build() `public Source build()`. Since 19.0. Uses configuration of this builder to create new `Source` object. Returns `Source`: the source object. Throws: `SecurityException` (unchecked): if the used [`filesystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied file reading. Overrides `build()`. Cite: `com/oracle/truffle/api/source/Source.LiteralBuilder.html#build()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ Source.SourceBuilder [truffle-api](index.md) › [com.oracle.truffle.api.source](com/oracle/truffle/api/source/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.source`](com/oracle/truffle/api/source/index.md). Since 19.0. Nested in [`Source`](com/oracle/truffle/api/source/Source.md). ```java public class Source.SourceBuilder ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `SourceBuilder` Allows one to specify additional attribute before [`creating`](com/oracle/truffle/api/source/Source.SourceBuilder.md#build%28%29) new [`Source`](com/oracle/truffle/api/source/Source.md) instance. To load a source from disk one can use: ```java assert file.getName().endsWith(".java") : "Imagine 'c:\\sources\\Example.java' file"; String language = Source.findLanguage(file); Source source = Source.newBuilder(language, file).build(); assert file.getName().equals(source.getName()); assert file.getPath().equals(source.getPath()); assert file.toUri().equals(source.getURI()); ``` To load source from a [`URL`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/URL.html) one can use: ```java URL resource = relativeClass.getResource("sample.js"); Source source = Source.newBuilder("js", resource) .build(); assert resource.toExternalForm().equals(source.getPath()); assert "sample.js".equals(source.getName()); assert resource.toURI().equals(source.getURI()); ``` To create a source representing characters: ```java Source source = Source.newBuilder("js", "function() {\n" + " return 'Hi';\n" + "}\n", "hi.js").build(); assert "hi.js".equals(source.getName()); ``` or read a source from a [`Reader`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/Reader.html): ```java Reader stream = new InputStreamReader( relativeClass.getResourceAsStream("sample.js") ); Source source = Source.newBuilder("js", stream, "sample.js") .build(); assert "sample.js".equals(source.getName()); ``` To create a source representing bytes: ```java byte[] bytes = new byte[] {/* Binary */}; Source source = Source.newBuilder("llvm", ByteSequence.create(bytes), "").build(); ``` Once your builder is configured, call [`build()`](com/oracle/truffle/api/source/Source.SourceBuilder.md#build%28%29) to perform the loading and construction of new [`Source`](com/oracle/truffle/api/source/Source.md). ## Methods ### name(String) `public Source.SourceBuilder name(String newName)`. Since 19.0. Specifies a name to the `to-be-built` `Source`. Parameters: `newName` `String`: name that replaces the previously given one. If set to `null` then `"Unnamed"` will be used. Returns `Source.SourceBuilder`: instance of `this` builder. Cite: `com/oracle/truffle/api/source/Source.SourceBuilder.html#name(java.lang.String)` ### content(CharSequence) `public Source.LiteralBuilder content(CharSequence characters)`. Since 19.0. Specifies character based content of `to-be-built` `Source`. Using this method one can ignore the real content of a file or URL and use already read one, or completely different one. Use `CONTENT_NONE` to set no content, `Source.hasCharacters()` will be `false` then. The given characters must not mutate after they were accessed for the first time. Example: Parameters: `characters` `CharSequence`: the code to be available via `Source.getCharacters()`, or `CONTENT_NONE`. Returns `Source.LiteralBuilder`: instance of this builder - which's `build()` method no longer throws an [`IOException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/IOException.html). Cite: `com/oracle/truffle/api/source/Source.SourceBuilder.html#content(java.lang.CharSequence)` ```java URL resource = relativeClass.getResource("sample.js"); Source source = Source.newBuilder("js", resource) .content("{}") .build(); assert resource.toExternalForm().equals(source.getPath()); assert "sample.js".equals(source.getName()); assert resource.toExternalForm().equals(source.getURI().toString()); assert "{}".equals(source.getCharacters()); ``` ### content(ByteSequence) `public Source.LiteralBuilder content(ByteSequence bytes)`. Since 19.0. Specifies byte based content of `to-be-built` `Source`. Using this method one can ignore the real content of a file or URL and use already read one, or completely different one. The given bytes must not mutate after they were accessed for the first time. Example: Parameters: `bytes` `ByteSequence`: the code to be available via `Source.getBytes()`. Returns `Source.LiteralBuilder`: instance of this builder - which's `build()` method no longer throws an [`IOException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/IOException.html). Cite: `com/oracle/truffle/api/source/Source.SourceBuilder.html#content(org.graalvm.polyglot.io.ByteSequence)` ```java URL resource = relativeClass.getResource("sample.js"); Source source = Source.newBuilder("js", resource) .content("{}") .build(); assert resource.toExternalForm().equals(source.getPath()); assert "sample.js".equals(source.getName()); assert resource.toExternalForm().equals(source.getURI().toString()); assert "{}".equals(source.getCharacters()); ``` ### mimeType(String) `public Source.SourceBuilder mimeType(String mimeType)`. Since 19.0. Explicitly assigns a `MIME type` to the `to-be-built` `Source`. If the MIME type is `null` then the [`default MIME type`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Language.html#getDefaultMimeType%28%29) of the language will be used to interpret the source. If set explicitly then the language needs to [`support`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Language.html#getMimeTypes%28%29) the MIME type in order to `parse` a source. If not `null` then the MIME type will be verified containing no spaces and a '/' between group and sub-group. An example for a valid MIME type is: `text/javascript`. The MIME type can be guessed by the system based on `files` or `urls`. Parameters: `mimeType` `String`: the new mime type to be assigned, or `null` if default MIME type should be used. Returns `Source.SourceBuilder`: instance of `this` builder ready to `create new source`. See also: `LanguageInfo.getDefaultMimeType()`, `LanguageInfo.getMimeTypes()`, `Source.findMimeType(TruffleFile)`, `Source.findMimeType(URL)`. Cite: `com/oracle/truffle/api/source/Source.SourceBuilder.html#mimeType(java.lang.String)` ### cached(boolean) `public Source.SourceBuilder cached(boolean enabled)`. Since 19.0. Enables or disables code caching for this source. By default code caching is enabled. If `true` then the source does not require parsing every time this source is evaluated. If `false` then the source requires parsing every time the source is evaluated but does not remember any code. Disabling caching may be useful if the source is known to only be evaluated once. If a source instance is no longer referenced by the client then all code caches will be freed automatically. Also, if the underlying context or engine is no longer referenced then cached code for evaluated sources will be freed automatically. Returns `Source.SourceBuilder`: instance of `this` builder ready to `create new source`. Cite: `com/oracle/truffle/api/source/Source.SourceBuilder.html#cached(boolean)` ### internal(boolean) `public Source.SourceBuilder internal(boolean enabled)`. Since 19.0. Marks the source as internal. Internal sources are those that aren't created by user, but rather inherently present by the language system. Calling this method influences result of create `Source.isInternal()`. Returns `Source.SourceBuilder`: the instance of this builder. Cite: `com/oracle/truffle/api/source/Source.SourceBuilder.html#internal(boolean)` ### interactive(boolean) `public Source.SourceBuilder interactive(boolean enabled)`. Since 19.0. Marks the source as interactive. Evaluation of interactive sources by an `interactive language` can use the `environment` streams to print the result and read an input. However, non-interactive languages are expected to ignore the interactive property of sources and not use the environment streams. Any desired printing of the evaluated result provided by a non-interactive language needs to be handled by the caller. Calling of this method influences the result of `Source.isInteractive()`. Returns `Source.SourceBuilder`: the instance of this builder. Cite: `com/oracle/truffle/api/source/Source.SourceBuilder.html#interactive(boolean)` ### uri(URI) `public Source.SourceBuilder uri(URI ownUri)`. Since 19.0. Assigns new [`URI`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/URI.html) to the `to-be-created` `Source`. Each source provides `Source.getURI()` as a persistent identification of its location. A default value for the method is deduced from the location or content, but one can change it by using this method. Parameters: `ownUri` `URI`: the URL to use instead of default one, cannot be `null`. Returns `Source.SourceBuilder`: the instance of this builder. Cite: `com/oracle/truffle/api/source/Source.SourceBuilder.html#uri(java.net.URI)` ### canonicalizePath(boolean) `public Source.SourceBuilder canonicalizePath(boolean canonicalize)`. Since 20.2. Whether the `Source.getPath()` (from the `TruffleFile`) should be canonicalized. By default the path is canonicalized to improve Source caching. If set to `false`, then `Source.getPath()` will be the same as the passed TruffleFile `TruffleFile.getPath()`. Parameters: `canonicalize` `boolean`: whether to canonicalize the path from the TruffleFile. Returns `Source.SourceBuilder`: the instance of this builder. Cite: `com/oracle/truffle/api/source/Source.SourceBuilder.html#canonicalizePath(boolean)` ### encoding(Charset) `public Source.SourceBuilder encoding(Charset encoding)`. Since 19.0. Explicitly assigns an encoding used to read the file content. If the encoding is `null` then the file contained encoding information is used. If the file doesn't provide an encoding information the default `UTF-8` encoding is used. Parameters: `encoding` `Charset`: the new file encoding to be used for reading the content. Returns `Source.SourceBuilder`: instance of `this` builder ready to `create new source`. Cite: `com/oracle/truffle/api/source/Source.SourceBuilder.html#encoding(java.nio.charset.Charset)` ### option(String, String) `public Source.SourceBuilder option(String key, String value)`. Since 25.0. Sets a source option key and value for the built source. Source options allow you to attach language- or instrument-specific configuration to a source. These options are parsed and validated only when source is parsed by a language, rather than when the source is created. If the source is validated, all source options will be validated. Therefore, each language or instrument associated with a source option must be installed. The available source option keys can be found in the respective language or instrument documentation, or at runtime via [`Language.getSourceOptions()`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Language.html#getSourceOptions%28%29) or [`Instrument.getSourceOptions()`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/Instrument.html#getSourceOptions%28%29). Parameters: `key` `String`: the option key (must not be null). `value` `String`: the option value (must not be null). See also: `ParsingRequest.getOptionValues()`, `TruffleLanguage.getSourceOptionDescriptors()`, `Source.getOptions(TruffleLanguage)`. Cite: `com/oracle/truffle/api/source/Source.SourceBuilder.html#option(java.lang.String,java.lang.String)` ### options(Map) `public Source.SourceBuilder options(Map options)`. Since 25.0. Shortcut for setting multiple `options` using a map. All values of the provided map must be non-null. Cite: `com/oracle/truffle/api/source/Source.SourceBuilder.html#options(java.util.Map)` ### build() `public Source build() throws IOException`. Since 19.0. Uses configuration of this builder to create new `Source` object. The method throws an [`IOException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/IOException.html) if an error loading the source occurred. Returns `Source`: the source object. Throws: `IOException`: if an error reading the content occurred. `SecurityException` (unchecked): if the used [`filesystem`](https://graalvm.elide.help/25.6.0-elide.4/api/polyglot/org/graalvm/polyglot/io/FileSystem.html) denied file reading. Cite: `com/oracle/truffle/api/source/Source.SourceBuilder.html#build()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ SourceSection [truffle-api](index.md) › [com.oracle.truffle.api.source](com/oracle/truffle/api/source/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.source`](com/oracle/truffle/api/source/index.md). Since 0.8 or earlier. ```java public abstract class SourceSection ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `SourceSection` Description of contiguous section of text within a [`Source`](com/oracle/truffle/api/source/Source.md) of program code.; supports multiple modes of access to the text and its location. Two available source sections are considered equal if their sources, start and length are equal. [`Unavailable`](com/oracle/truffle/api/source/SourceSection.md#isAvailable%28%29) source sections are compared by identity. Source sections can be used as keys in hash maps. **See also** - [`Source.createSection(int)`](com/oracle/truffle/api/source/Source.md#createSection%28int%29) - [`Source.createSection(int, int)`](com/oracle/truffle/api/source/Source.md#createSection%28int,int%29) - [`Source.createSection(int, int, int)`](com/oracle/truffle/api/source/Source.md#createSection%28int,int,int%29) - [`Source.createSection(int, int, int, int)`](com/oracle/truffle/api/source/Source.md#createSection%28int,int,int,int%29) - [`Source.createUnavailableSection()`](com/oracle/truffle/api/source/Source.md#createUnavailableSection%28%29) ## Methods ### isAvailable() `public abstract boolean isAvailable()`. Since 0.18. Returns whether this is a special instance that signifies that source information is available. Unavailable source sections can be created using `Source.createUnavailableSection()`. Available source sections are never equal to unavailable source sections. Unavailable source sections return the same indices and lengths as empty source sections starting at character index `0`. See also: `Source.createUnavailableSection()`. Cite: `com/oracle/truffle/api/source/SourceSection.html#isAvailable()` ### hasLines() `public abstract boolean hasLines()`. Since 19.0. Returns `true` if this section has a line number information, `false` otherwise. When `true`, `getStartLine()` and `getEndLine()` return valid line numbers, when `false`, `getStartLine()` and `getEndLine()` return `1`. Cite: `com/oracle/truffle/api/source/SourceSection.html#hasLines()` ### hasColumns() `public abstract boolean hasColumns()`. Since 19.0. Returns `true` if this section has a column number information, `false` otherwise. When `true`, `hasLines()` is `true` as well, `getStartColumn()` and `getEndColumn()` return valid column numbers. When `false`, `getStartColumn()` and `getEndColumn()` return `1`. Cite: `com/oracle/truffle/api/source/SourceSection.html#hasColumns()` ### hasCharIndex() `public abstract boolean hasCharIndex()`. Since 19.0. Returns `true` if this section has a character index information, `false` otherwise. When `true`, `getCharIndex()`, `getCharEndIndex()` and `getCharLength()` return valid character indices, when `false`, `getCharIndex()`, `getCharEndIndex()` and `getCharLength()` return `0`. Cite: `com/oracle/truffle/api/source/SourceSection.html#hasCharIndex()` ### getSource() `public final Source getSource()`. Since 0.8 or earlier. Representation of the source program that contains this section. Returns `Source`: the source object. Cite: `com/oracle/truffle/api/source/SourceSection.html#getSource()` ### getStartLine() `public abstract int getStartLine()`. Since 0.8 or earlier. Returns 1-based line number of the first character in this section (inclusive). Returns `1` for out of bounds or `unavailable` source sections, or source sections not `having lines`. Returns `int`: the starting line number. See also: `hasLines()`. Cite: `com/oracle/truffle/api/source/SourceSection.html#getStartLine()` ### getStartColumn() `public abstract int getStartColumn()`. Since 0.8 or earlier. Returns the 1-based column number of the first character in this section (inclusive). Returns `1` for out of bounds or `unavailable` source sections, or source sections not `having columns`. Returns `int`: the starting column number. See also: `hasColumns()`. Cite: `com/oracle/truffle/api/source/SourceSection.html#getStartColumn()` ### getEndLine() `public abstract int getEndLine()`. Since 0.8 or earlier. Returns 1-based line number of the last character in this section (inclusive). Returns `1` for out of bounds or `unavailable` source sections, or source sections not `having lines`. Returns `int`: the starting line number. See also: `hasLines()`. Cite: `com/oracle/truffle/api/source/SourceSection.html#getEndLine()` ### getEndColumn() `public abstract int getEndColumn()`. Since 0.8 or earlier. Returns the 1-based column number of the last character in this section (inclusive). Returns `1` for out of bounds or `unavailable` source sections, or source sections not `having columns`. Returns `int`: the starting column number. See also: `hasColumns()`. Cite: `com/oracle/truffle/api/source/SourceSection.html#getEndColumn()` ### getCharIndex() `public abstract int getCharIndex()`. Since 0.8 or earlier. Returns the 0-based index of the first character in this section. Returns `0` for `unavailable` source sections, or sections not `having character index`. The returned index might be out of bounds of the source code if assertions (-ea) are not enabled. Returns `int`: the starting character index. See also: `hasCharIndex()`. Cite: `com/oracle/truffle/api/source/SourceSection.html#getCharIndex()` ### getCharLength() `public abstract int getCharLength()`. Since 0.8 or earlier. Returns the length of this section in characters. Returns `0` for `unavailable` source sections, or sections not `having character index`. The returned length might be out of bounds of the source code if assertions (-ea) are not enabled. Returns `int`: the number of characters in the section. See also: `hasCharIndex()`. Cite: `com/oracle/truffle/api/source/SourceSection.html#getCharLength()` ### getCharEndIndex() `public abstract int getCharEndIndex()`. Since 0.8 or earlier. Returns the index of the text position immediately following the last character in the section. Returns `0` for `unavailable` source sections, or sections not `having character index`. The returned index might be out of bounds of the source code if assertions (-ea) are not enabled. Returns `int`: the end position of the section. See also: `hasCharIndex()`. Cite: `com/oracle/truffle/api/source/SourceSection.html#getCharEndIndex()` ### getCharacters() `public abstract CharSequence getCharacters()`. Since 0.28. Returns the source code fragment described by this section. Returns an empty character sequence for out of bounds or `unavailable` source sections, or sections whose source does not `have characters`. Returns `CharSequence`: the code as a CharSequence. See also: `Source.hasCharacters()`. Cite: `com/oracle/truffle/api/source/SourceSection.html#getCharacters()` ### toString() `public final String toString()`. Since 0.8 or earlier. Returns an implementation-defined string representation of this source section to be used for debugging purposes only. Overrides `toString()`. See also: `getCharacters()`. Cite: `com/oracle/truffle/api/source/SourceSection.html#toString()` ### hashCode() `public abstract int hashCode()`. Since 0.8 or earlier. Overrides `hashCode()`. Cite: `com/oracle/truffle/api/source/SourceSection.html#hashCode()` ### equals(Object) `public abstract boolean equals(Object obj)`. Since 0.8 or earlier. Overrides `equals(java.lang.Object)`. Cite: `com/oracle/truffle/api/source/SourceSection.html#equals(java.lang.Object)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ▣ com.oracle.truffle.api.staticobject [truffle-api](index.md) · Every page: [llms.txt](llms.txt) Package in truffle-api. Since 21.3.0. Static Object Model APIs to represent the layout of objects that, once defined, do not change the number and the type of their properties. For more information, read the [Javadoc](https://www.graalvm.org/truffle/javadoc/com/oracle/truffle/api/staticobject/package-summary.html) and the [tutorial](https://github.com/oracle/graal/blob/master/truffle/docs/StaticObjectModel.md). ## Interfaces - [`DefaultStaticObjectFactory`](com/oracle/truffle/api/staticobject/DefaultStaticObjectFactory.md): A trivial static object factory that allocates static objects of type Object. ## Classes - [`DefaultStaticProperty`](com/oracle/truffle/api/staticobject/DefaultStaticProperty.md): A trivial default implementation of StaticProperty. - [`StaticProperty`](com/oracle/truffle/api/staticobject/StaticProperty.md): StaticProperty objects represent the mapping between property identifiers and storage locations within static objects. - [`StaticShape`](com/oracle/truffle/api/staticobject/StaticShape.md): A StaticShape is an immutable descriptor of the layout of a static object and is a good entry point to learn about the Static Object Model. # ◇ DefaultStaticObjectFactory [truffle-api](index.md) › [com.oracle.truffle.api.staticobject](com/oracle/truffle/api/staticobject/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.staticobject`](com/oracle/truffle/api/staticobject/index.md). Since 21.3.0. ```java public interface DefaultStaticObjectFactory ``` A trivial static object factory that allocates static objects of type [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html). **See also** - [`StaticShape.Builder.build()`](com/oracle/truffle/api/staticobject/StaticShape.Builder.md#build%28%29) ## Methods ### create() `Object create()`. Since 21.3.0. Creates a static object of type [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) that have a visible constructor that accepts no arguments. Returns `Object`: the new static object instance. Cite: `com/oracle/truffle/api/staticobject/DefaultStaticObjectFactory.html#create()` # ◆ DefaultStaticProperty [truffle-api](index.md) › [com.oracle.truffle.api.staticobject](com/oracle/truffle/api/staticobject/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.staticobject`](com/oracle/truffle/api/staticobject/index.md). Since 21.3.0. ```java public final class DefaultStaticProperty extends StaticProperty ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`StaticProperty`](com/oracle/truffle/api/staticobject/StaticProperty.md) > `DefaultStaticProperty` A trivial default implementation of [`StaticProperty`](com/oracle/truffle/api/staticobject/StaticProperty.md). **See also** - [`StaticProperty`](com/oracle/truffle/api/staticobject/StaticProperty.md) ## Constructors ### DefaultStaticProperty(String) `public DefaultStaticProperty(String id)`. Since 21.3.0. Constructs a new DefaultStaticProperty. Parameters: `id` `String`: the id of the static property, which must be immutable and unique for a given shape. See also: `StaticProperty`. Cite: `com/oracle/truffle/api/staticobject/DefaultStaticProperty.html#(java.lang.String)` ## Methods ### getId() `public String getId()`. Since 21.3.0. StaticProperty instances must have a [`String`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html) identifier that is unique and constant for that shape. Subtypes of StaticProperty must make sure that the value returned by this method is constant in time. Returns `String`: the static property identifier. Overrides `getId()`. Cite: `com/oracle/truffle/api/staticobject/DefaultStaticProperty.html#getId()` ## Inherited members - From class [`StaticProperty`](com/oracle/truffle/api/staticobject/StaticProperty.md): [`compareAndExchangeBoolean`](com/oracle/truffle/api/staticobject/StaticProperty.md#compareAndExchangeBoolean%28java.lang.Object,boolean,boolean%29), [`compareAndExchangeByte`](com/oracle/truffle/api/staticobject/StaticProperty.md#compareAndExchangeByte%28java.lang.Object,byte,byte%29), [`compareAndExchangeChar`](com/oracle/truffle/api/staticobject/StaticProperty.md#compareAndExchangeChar%28java.lang.Object,char,char%29), [`compareAndExchangeDouble`](com/oracle/truffle/api/staticobject/StaticProperty.md#compareAndExchangeDouble%28java.lang.Object,double,double%29), [`compareAndExchangeFloat`](com/oracle/truffle/api/staticobject/StaticProperty.md#compareAndExchangeFloat%28java.lang.Object,float,float%29), [`compareAndExchangeInt`](com/oracle/truffle/api/staticobject/StaticProperty.md#compareAndExchangeInt%28java.lang.Object,int,int%29), [`compareAndExchangeLong`](com/oracle/truffle/api/staticobject/StaticProperty.md#compareAndExchangeLong%28java.lang.Object,long,long%29), [`compareAndExchangeObject`](com/oracle/truffle/api/staticobject/StaticProperty.md#compareAndExchangeObject%28java.lang.Object,java.lang.Object,java.lang.Object%29), [`compareAndExchangeShort`](com/oracle/truffle/api/staticobject/StaticProperty.md#compareAndExchangeShort%28java.lang.Object,short,short%29), [`compareAndSwapBoolean`](com/oracle/truffle/api/staticobject/StaticProperty.md#compareAndSwapBoolean%28java.lang.Object,boolean,boolean%29), [`compareAndSwapByte`](com/oracle/truffle/api/staticobject/StaticProperty.md#compareAndSwapByte%28java.lang.Object,byte,byte%29), [`compareAndSwapChar`](com/oracle/truffle/api/staticobject/StaticProperty.md#compareAndSwapChar%28java.lang.Object,char,char%29), [`compareAndSwapDouble`](com/oracle/truffle/api/staticobject/StaticProperty.md#compareAndSwapDouble%28java.lang.Object,double,double%29), [`compareAndSwapFloat`](com/oracle/truffle/api/staticobject/StaticProperty.md#compareAndSwapFloat%28java.lang.Object,float,float%29), [`compareAndSwapInt`](com/oracle/truffle/api/staticobject/StaticProperty.md#compareAndSwapInt%28java.lang.Object,int,int%29), [`compareAndSwapLong`](com/oracle/truffle/api/staticobject/StaticProperty.md#compareAndSwapLong%28java.lang.Object,long,long%29), [`compareAndSwapObject`](com/oracle/truffle/api/staticobject/StaticProperty.md#compareAndSwapObject%28java.lang.Object,java.lang.Object,java.lang.Object%29), [`compareAndSwapShort`](com/oracle/truffle/api/staticobject/StaticProperty.md#compareAndSwapShort%28java.lang.Object,short,short%29), [`getAndAddInt`](com/oracle/truffle/api/staticobject/StaticProperty.md#getAndAddInt%28java.lang.Object,int%29), [`getAndAddLong`](com/oracle/truffle/api/staticobject/StaticProperty.md#getAndAddLong%28java.lang.Object,long%29), [`getAndSetInt`](com/oracle/truffle/api/staticobject/StaticProperty.md#getAndSetInt%28java.lang.Object,int%29), [`getAndSetLong`](com/oracle/truffle/api/staticobject/StaticProperty.md#getAndSetLong%28java.lang.Object,long%29), [`getAndSetObject`](com/oracle/truffle/api/staticobject/StaticProperty.md#getAndSetObject%28java.lang.Object,java.lang.Object%29), [`getBoolean`](com/oracle/truffle/api/staticobject/StaticProperty.md#getBoolean%28java.lang.Object%29), [`getBooleanVolatile`](com/oracle/truffle/api/staticobject/StaticProperty.md#getBooleanVolatile%28java.lang.Object%29), [`getByte`](com/oracle/truffle/api/staticobject/StaticProperty.md#getByte%28java.lang.Object%29), [`getByteVolatile`](com/oracle/truffle/api/staticobject/StaticProperty.md#getByteVolatile%28java.lang.Object%29), [`getChar`](com/oracle/truffle/api/staticobject/StaticProperty.md#getChar%28java.lang.Object%29), [`getCharVolatile`](com/oracle/truffle/api/staticobject/StaticProperty.md#getCharVolatile%28java.lang.Object%29), [`getDouble`](com/oracle/truffle/api/staticobject/StaticProperty.md#getDouble%28java.lang.Object%29), [`getDoubleVolatile`](com/oracle/truffle/api/staticobject/StaticProperty.md#getDoubleVolatile%28java.lang.Object%29), [`getFloat`](com/oracle/truffle/api/staticobject/StaticProperty.md#getFloat%28java.lang.Object%29), [`getFloatVolatile`](com/oracle/truffle/api/staticobject/StaticProperty.md#getFloatVolatile%28java.lang.Object%29), [`getInt`](com/oracle/truffle/api/staticobject/StaticProperty.md#getInt%28java.lang.Object%29), [`getIntVolatile`](com/oracle/truffle/api/staticobject/StaticProperty.md#getIntVolatile%28java.lang.Object%29), [`getLong`](com/oracle/truffle/api/staticobject/StaticProperty.md#getLong%28java.lang.Object%29), [`getLongVolatile`](com/oracle/truffle/api/staticobject/StaticProperty.md#getLongVolatile%28java.lang.Object%29), [`getObject`](com/oracle/truffle/api/staticobject/StaticProperty.md#getObject%28java.lang.Object%29), [`getObjectVolatile`](com/oracle/truffle/api/staticobject/StaticProperty.md#getObjectVolatile%28java.lang.Object%29), [`getShort`](com/oracle/truffle/api/staticobject/StaticProperty.md#getShort%28java.lang.Object%29), [`getShortVolatile`](com/oracle/truffle/api/staticobject/StaticProperty.md#getShortVolatile%28java.lang.Object%29), [`setBoolean`](com/oracle/truffle/api/staticobject/StaticProperty.md#setBoolean%28java.lang.Object,boolean%29), [`setBooleanVolatile`](com/oracle/truffle/api/staticobject/StaticProperty.md#setBooleanVolatile%28java.lang.Object,boolean%29), [`setByte`](com/oracle/truffle/api/staticobject/StaticProperty.md#setByte%28java.lang.Object,byte%29), [`setByteVolatile`](com/oracle/truffle/api/staticobject/StaticProperty.md#setByteVolatile%28java.lang.Object,byte%29), [`setChar`](com/oracle/truffle/api/staticobject/StaticProperty.md#setChar%28java.lang.Object,char%29), [`setCharVolatile`](com/oracle/truffle/api/staticobject/StaticProperty.md#setCharVolatile%28java.lang.Object,char%29), [`setDouble`](com/oracle/truffle/api/staticobject/StaticProperty.md#setDouble%28java.lang.Object,double%29), [`setDoubleVolatile`](com/oracle/truffle/api/staticobject/StaticProperty.md#setDoubleVolatile%28java.lang.Object,double%29), [`setFloat`](com/oracle/truffle/api/staticobject/StaticProperty.md#setFloat%28java.lang.Object,float%29), [`setFloatVolatile`](com/oracle/truffle/api/staticobject/StaticProperty.md#setFloatVolatile%28java.lang.Object,float%29), [`setInt`](com/oracle/truffle/api/staticobject/StaticProperty.md#setInt%28java.lang.Object,int%29), [`setIntVolatile`](com/oracle/truffle/api/staticobject/StaticProperty.md#setIntVolatile%28java.lang.Object,int%29), [`setLong`](com/oracle/truffle/api/staticobject/StaticProperty.md#setLong%28java.lang.Object,long%29), [`setLongVolatile`](com/oracle/truffle/api/staticobject/StaticProperty.md#setLongVolatile%28java.lang.Object,long%29), [`setObject`](com/oracle/truffle/api/staticobject/StaticProperty.md#setObject%28java.lang.Object,java.lang.Object%29), [`setObjectVolatile`](com/oracle/truffle/api/staticobject/StaticProperty.md#setObjectVolatile%28java.lang.Object,java.lang.Object%29), [`setShort`](com/oracle/truffle/api/staticobject/StaticProperty.md#setShort%28java.lang.Object,short%29), [`setShortVolatile`](com/oracle/truffle/api/staticobject/StaticProperty.md#setShortVolatile%28java.lang.Object,short%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ StaticProperty [truffle-api](index.md) › [com.oracle.truffle.api.staticobject](com/oracle/truffle/api/staticobject/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.staticobject`](com/oracle/truffle/api/staticobject/index.md). Since 21.3.0. ```java public abstract class StaticProperty ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `StaticProperty` StaticProperty objects represent the mapping between [property identifiers](com/oracle/truffle/api/staticobject/StaticProperty.md#getId%28%29) and storage locations within static objects. Users of the Static Object Model can define custom subtypes of StaticProperty or use [`DefaultStaticProperty`](com/oracle/truffle/api/staticobject/DefaultStaticProperty.md), a trivial default implementation. In both cases, static properties must be registered to a [`StaticShape.Builder`](com/oracle/truffle/api/staticobject/StaticShape.Builder.md) using [`StaticShape.Builder.property(StaticProperty, Class, boolean)`](com/oracle/truffle/api/staticobject/StaticShape.Builder.md#property%28com.oracle.truffle.api.staticobject.StaticProperty,java.lang.Class,boolean%29). Then, after allocating a [`StaticShape`](com/oracle/truffle/api/staticobject/StaticShape.md) instance with one of the [`StaticShape.Builder.build()`](com/oracle/truffle/api/staticobject/StaticShape.Builder.md#build%28%29) methods and allocating a static object using the factory class provided by [`StaticShape.getFactory()`](com/oracle/truffle/api/staticobject/StaticShape.md#getFactory%28%29), users can call the accessor methods defined in StaticProperty to get and set property values stored in a static object instance. A StaticProperty instance can be added to only one [`StaticShape.Builder`](com/oracle/truffle/api/staticobject/StaticShape.Builder.md). StaticProperty instances registered to the same [`StaticShape.Builder`](com/oracle/truffle/api/staticobject/StaticShape.Builder.md) must have [a unique id](com/oracle/truffle/api/staticobject/StaticProperty.md#getId%28%29) for that builder. **See also** - [`DefaultStaticProperty`](com/oracle/truffle/api/staticobject/DefaultStaticProperty.md) ## Constructors ### StaticProperty() `protected StaticProperty()`. Since 21.3.0. Constructor for subclasses. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#()` ## Methods ### getId() `protected abstract String getId()`. Since 21.3.0. StaticProperty instances must have a [`String`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html) identifier that is unique and constant for that shape. Subtypes of StaticProperty must make sure that the value returned by this method is constant in time. Returns `String`: the static property identifier. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#getId()` ### getObject(Object) `public final Object getObject(Object obj)`. Since 21.3.0. Returns the [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of reading as if the variable was declared non-volatile. Parameters: `obj` `Object`: the static object that stores the static property value. Returns `Object`: the value of the static property stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is primitive, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#getObject(java.lang.Object)` ### getObjectVolatile(Object) `public final Object getObjectVolatile(Object obj)`. Since 21.3.0. Returns the [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of reading as if the variable was declared volatile. Parameters: `obj` `Object`: the static object that stores the static property value. Returns `Object`: the value of the static property stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is primitive, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#getObjectVolatile(java.lang.Object)` ### setObject(Object, Object) `public final void setObject(Object obj, Object value)`. Since 21.3.0. Sets the [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of setting as if the variable was declared non-volatile. Parameters: `obj` `Object`: the static object that stores the static property value. `value` `Object`: the new static property value, to be stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not assignable from [`the type of value`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#setObject(java.lang.Object,java.lang.Object)` ### setObjectVolatile(Object, Object) `public final void setObjectVolatile(Object obj, Object value)`. Since 21.3.0. Sets the [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of setting as if the variable was declared volatile. Parameters: `obj` `Object`: the static object that stores the static property value. `value` `Object`: the new static property value, to be stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not assignable from [`the type of value`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#setObjectVolatile(java.lang.Object,java.lang.Object)` ### compareAndSwapObject(Object, Object, Object) `public final boolean compareAndSwapObject(Object obj, Object expect, Object update)`. Since 21.3.0. Atomically sets the [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) value represented by this StaticProperty and stored in the specified static object to the given updated value if the current value `==` the expected value. Parameters: `obj` `Object`: the static object that stores the static property value. `expect` `Object`: the expected value. `update` `Object`: the new value. Returns `boolean`: `true` if successful. False return indicates that the actual value was not equal to the expected value. Throws: `IllegalArgumentException` (unchecked): if the static property type is not assignable from [`the type of value`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#compareAndSwapObject(java.lang.Object,java.lang.Object,java.lang.Object)` ### getAndSetObject(Object, Object) `public final Object getAndSetObject(Object obj, Object value)`. Since 21.3.0. Atomically sets the [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) value represented by this StaticProperty and stored in the specified static object to the given value and returns the old value. Parameters: `obj` `Object`: the static object that stores the static property value. `value` `Object`: the new value. Returns `Object`: the previous value. Throws: `IllegalArgumentException` (unchecked): if the static property type is not assignable from [`the type of value`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#getAndSetObject(java.lang.Object,java.lang.Object)` ### compareAndExchangeObject(Object, Object, Object) `public final Object compareAndExchangeObject(Object obj, Object expect, Object update)`. Since 21.3.0. Atomically sets the [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) value represented by this StaticProperty and stored in the specified static object to `newValue` if the current value, referred to as the * witness value*, `==` the expected value. Parameters: `obj` `Object`: the static object that stores the static property value. `expect` `Object`: the expected value. `update` `Object`: the new value. Returns `Object`: the witness value, which will be the same as the expected value if successful. Throws: `IllegalArgumentException` (unchecked): if the static property type is not assignable from [`the type of value`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#compareAndExchangeObject(java.lang.Object,java.lang.Object,java.lang.Object)` ### getBoolean(Object) `public final boolean getBoolean(Object obj)`. Since 21.3.0. Returns the boolean value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of reading as if the variable was declared non-volatile. Parameters: `obj` `Object`: the static object that stores the static property value. Returns `boolean`: the value of the static property stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the boolean class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#getBoolean(java.lang.Object)` ### getBooleanVolatile(Object) `public final boolean getBooleanVolatile(Object obj)`. Since 21.3.0. Returns the boolean value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of reading as if the variable was declared volatile. Parameters: `obj` `Object`: the static object that stores the static property value. Returns `boolean`: the value of the static property stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the boolean class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#getBooleanVolatile(java.lang.Object)` ### setBoolean(Object, boolean) `public final void setBoolean(Object obj, boolean value)`. Since 21.3.0. Sets the boolean value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of setting as if the variable was declared non-volatile. Parameters: `obj` `Object`: the static object that stores the static property value. `value` `boolean`: the new static property value, to be stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the boolean class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#setBoolean(java.lang.Object,boolean)` ### setBooleanVolatile(Object, boolean) `public final void setBooleanVolatile(Object obj, boolean value)`. Since 21.3.0. Sets the boolean value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of setting as if the variable was declared volatile. Parameters: `obj` `Object`: the static object that stores the static property value. `value` `boolean`: the new static property value, to be stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the boolean class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#setBooleanVolatile(java.lang.Object,boolean)` ### compareAndSwapBoolean(Object, boolean, boolean) `public final boolean compareAndSwapBoolean(Object obj, boolean expect, boolean update)`. Since 21.3.0. Atomically sets the boolean value represented by this StaticProperty and stored in the specified static object to the given updated value if the current value `==` the expected value. Parameters: `obj` `Object`: the static object that stores the static property value. `expect` `boolean`: the expected value. `update` `boolean`: the new value. Returns `boolean`: `true` if successful. False return indicates that the actual value was not equal to the expected value. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the boolean class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#compareAndSwapBoolean(java.lang.Object,boolean,boolean)` ### compareAndExchangeBoolean(Object, boolean, boolean) `public final boolean compareAndExchangeBoolean(Object obj, boolean expect, boolean update)`. Since 21.3.0. Atomically sets the boolean value represented by this StaticProperty and stored in the specified static object to `newValue` if the current value, referred to as the *witness value*, `==` the expected value. Parameters: `obj` `Object`: the static object that stores the static property value. `expect` `boolean`: the expected value. `update` `boolean`: the new value. Returns `boolean`: the witness value, which will be the same as the expected value if successful. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the boolean class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#compareAndExchangeBoolean(java.lang.Object,boolean,boolean)` ### getByte(Object) `public final byte getByte(Object obj)`. Since 21.3.0. Returns the byte value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of reading as if the variable was declared non-volatile. Parameters: `obj` `Object`: the static object that stores the static property value. Returns `byte`: the value of the static property stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the byte class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#getByte(java.lang.Object)` ### getByteVolatile(Object) `public final byte getByteVolatile(Object obj)`. Since 21.3.0. Returns the byte value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of reading as if the variable was declared volatile. Parameters: `obj` `Object`: the static object that stores the static property value. Returns `byte`: the value of the static property stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the byte class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#getByteVolatile(java.lang.Object)` ### setByte(Object, byte) `public final void setByte(Object obj, byte value)`. Since 21.3.0. Sets the byte value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of setting as if the variable was declared non-volatile. Parameters: `obj` `Object`: the static object that stores the static property value. `value` `byte`: the new static property value, to be stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the byte class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#setByte(java.lang.Object,byte)` ### setByteVolatile(Object, byte) `public final void setByteVolatile(Object obj, byte value)`. Since 21.3.0. Sets the byte value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of setting as if the variable was declared volatile. Parameters: `obj` `Object`: the static object that stores the static property value. `value` `byte`: the new static property value, to be stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the byte class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#setByteVolatile(java.lang.Object,byte)` ### compareAndSwapByte(Object, byte, byte) `public final boolean compareAndSwapByte(Object obj, byte expect, byte update)`. Since 21.3.0. Atomically sets the byte value represented by this StaticProperty and stored in the specified static object to the given updated value if the current value `==` the expected value. Parameters: `obj` `Object`: the static object that stores the static property value. `expect` `byte`: the expected value. `update` `byte`: the new value. Returns `boolean`: `true` if successful. False return indicates that the actual value was not equal to the expected value. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the byte class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#compareAndSwapByte(java.lang.Object,byte,byte)` ### compareAndExchangeByte(Object, byte, byte) `public final byte compareAndExchangeByte(Object obj, byte expect, byte update)`. Since 21.3.0. Atomically sets the byte value represented by this StaticProperty and stored in the specified static object to `newValue` if the current value, referred to as the *witness value*, `==` the expected value. Parameters: `obj` `Object`: the static object that stores the static property value. `expect` `byte`: the expected value. `update` `byte`: the new value. Returns `byte`: the witness value, which will be the same as the expected value if successful. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the byte class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#compareAndExchangeByte(java.lang.Object,byte,byte)` ### getChar(Object) `public final char getChar(Object obj)`. Since 21.3.0. Returns the char value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of reading as if the variable was declared non-volatile. Parameters: `obj` `Object`: the static object that stores the static property value. Returns `char`: the value of the static property stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the char class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#getChar(java.lang.Object)` ### getCharVolatile(Object) `public final char getCharVolatile(Object obj)`. Since 21.3.0. Returns the char value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of reading as if the variable was declared volatile. Parameters: `obj` `Object`: the static object that stores the static property value. Returns `char`: the value of the static property stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the char class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#getCharVolatile(java.lang.Object)` ### setChar(Object, char) `public final void setChar(Object obj, char value)`. Since 21.3.0. Sets the char value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of setting as if the variable was declared non-volatile. Parameters: `obj` `Object`: the static object that stores the static property value. `value` `char`: the new static property value, to be stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the char class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#setChar(java.lang.Object,char)` ### setCharVolatile(Object, char) `public final void setCharVolatile(Object obj, char value)`. Since 21.3.0. Sets the char value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of setting as if the variable was declared volatile. Parameters: `obj` `Object`: the static object that stores the static property value. `value` `char`: the new static property value, to be stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the char class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#setCharVolatile(java.lang.Object,char)` ### compareAndSwapChar(Object, char, char) `public final boolean compareAndSwapChar(Object obj, char expect, char update)`. Since 21.3.0. Atomically sets the char value represented by this StaticProperty and stored in the specified static object to the given updated value if the current value `==` the expected value. Parameters: `obj` `Object`: the static object that stores the static property value. `expect` `char`: the expected value. `update` `char`: the new value. Returns `boolean`: `true` if successful. False return indicates that the actual value was not equal to the expected value. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the char class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#compareAndSwapChar(java.lang.Object,char,char)` ### compareAndExchangeChar(Object, char, char) `public final char compareAndExchangeChar(Object obj, char expect, char update)`. Since 21.3.0. Atomically sets the char value represented by this StaticProperty and stored in the specified static object to `newValue` if the current value, referred to as the * witness value*, `==` the expected value. Parameters: `obj` `Object`: the static object that stores the static property value. `expect` `char`: the expected value. `update` `char`: the new value. Returns `char`: the witness value, which will be the same as the expected value if successful. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the char class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#compareAndExchangeChar(java.lang.Object,char,char)` ### getDouble(Object) `public final double getDouble(Object obj)`. Since 21.3.0. Returns the double value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of reading as if the variable was declared non-volatile. Parameters: `obj` `Object`: the static object that stores the static property value. Returns `double`: the value of the static property stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the double class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#getDouble(java.lang.Object)` ### getDoubleVolatile(Object) `public final double getDoubleVolatile(Object obj)`. Since 21.3.0. Returns the double value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of reading as if the variable was declared volatile. Parameters: `obj` `Object`: the static object that stores the static property value. Returns `double`: the value of the static property stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the double class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#getDoubleVolatile(java.lang.Object)` ### setDouble(Object, double) `public final void setDouble(Object obj, double value)`. Since 21.3.0. Sets the double value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of setting as if the variable was declared non-volatile. Parameters: `obj` `Object`: the static object that stores the static property value. `value` `double`: the new static property value, to be stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the double class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#setDouble(java.lang.Object,double)` ### setDoubleVolatile(Object, double) `public final void setDoubleVolatile(Object obj, double value)`. Since 21.3.0. Sets the double value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of setting as if the variable was declared volatile. Parameters: `obj` `Object`: the static object that stores the static property value. `value` `double`: the new static property value, to be stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the double class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#setDoubleVolatile(java.lang.Object,double)` ### compareAndSwapDouble(Object, double, double) `public final boolean compareAndSwapDouble(Object obj, double expect, double update)`. Since 21.3.0. Atomically sets the double value represented by this StaticProperty and stored in the specified static object to the given updated value if the current value `==` the expected value. Parameters: `obj` `Object`: the static object that stores the static property value. `expect` `double`: the expected value. `update` `double`: the new value. Returns `boolean`: `true` if successful. False return indicates that the actual value was not equal to the expected value. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the double class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#compareAndSwapDouble(java.lang.Object,double,double)` ### compareAndExchangeDouble(Object, double, double) `public final double compareAndExchangeDouble(Object obj, double expect, double update)`. Since 21.3.0. Atomically sets the double value represented by this StaticProperty and stored in the specified static object to `newValue` if the current value, referred to as the *witness value*, `==` the expected value. Parameters: `obj` `Object`: the static object that stores the static property value. `expect` `double`: the expected value. `update` `double`: the new value. Returns `double`: the witness value, which will be the same as the expected value if successful. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the double class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#compareAndExchangeDouble(java.lang.Object,double,double)` ### getFloat(Object) `public final float getFloat(Object obj)`. Since 21.3.0. Returns the float value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of reading as if the variable was declared non-volatile. Parameters: `obj` `Object`: the static object that stores the static property value. Returns `float`: the value of the static property stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the float class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#getFloat(java.lang.Object)` ### getFloatVolatile(Object) `public final float getFloatVolatile(Object obj)`. Since 21.3.0. Returns the float value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of reading as if the variable was declared volatile. Parameters: `obj` `Object`: the static object that stores the static property value. Returns `float`: the value of the static property stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the float class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#getFloatVolatile(java.lang.Object)` ### setFloat(Object, float) `public final void setFloat(Object obj, float value)`. Since 21.3.0. Sets the float value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of setting as if the variable was declared non-volatile. Parameters: `obj` `Object`: the static object that stores the static property value. `value` `float`: the new static property value, to be stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the float class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#setFloat(java.lang.Object,float)` ### setFloatVolatile(Object, float) `public final void setFloatVolatile(Object obj, float value)`. Since 21.3.0. Sets the float value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of setting as if the variable was declared volatile. Parameters: `obj` `Object`: the static object that stores the static property value. `value` `float`: the new static property value, to be stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the float class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#setFloatVolatile(java.lang.Object,float)` ### compareAndSwapFloat(Object, float, float) `public final boolean compareAndSwapFloat(Object obj, float expect, float update)`. Since 21.3.0. Atomically sets the float value represented by this StaticProperty and stored in the specified static object to the given updated value if the current value `==` the expected value. Parameters: `obj` `Object`: the static object that stores the static property value. `expect` `float`: the expected value. `update` `float`: the new value. Returns `boolean`: `true` if successful. False return indicates that the actual value was not equal to the expected value. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the float class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#compareAndSwapFloat(java.lang.Object,float,float)` ### compareAndExchangeFloat(Object, float, float) `public final float compareAndExchangeFloat(Object obj, float expect, float update)`. Since 21.3.0. Atomically sets the float value represented by this StaticProperty and stored in the specified static object to `newValue` if the current value, referred to as the *witness value*, `==` the expected value. Parameters: `obj` `Object`: the static object that stores the static property value. `expect` `float`: the expected value. `update` `float`: the new value. Returns `float`: the witness value, which will be the same as the expected value if successful. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the float class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#compareAndExchangeFloat(java.lang.Object,float,float)` ### getInt(Object) `public final int getInt(Object obj)`. Since 21.3.0. Returns the int value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of reading as if the variable was declared non-volatile. Parameters: `obj` `Object`: the static object that stores the static property value. Returns `int`: the value of the static property stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the int class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#getInt(java.lang.Object)` ### getIntVolatile(Object) `public final int getIntVolatile(Object obj)`. Since 21.3.0. Returns the int value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of reading as if the variable was declared volatile. Parameters: `obj` `Object`: the static object that stores the static property value. Returns `int`: the value of the static property stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the int class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#getIntVolatile(java.lang.Object)` ### setInt(Object, int) `public final void setInt(Object obj, int value)`. Since 21.3.0. Sets the int value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of setting as if the variable was declared non-volatile. Parameters: `obj` `Object`: the static object that stores the static property value. `value` `int`: the new static property value, to be stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the int class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#setInt(java.lang.Object,int)` ### setIntVolatile(Object, int) `public final void setIntVolatile(Object obj, int value)`. Since 21.3.0. Sets the int value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of setting as if the variable was declared volatile. Parameters: `obj` `Object`: the static object that stores the static property value. `value` `int`: the new static property value, to be stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the int class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#setIntVolatile(java.lang.Object,int)` ### compareAndSwapInt(Object, int, int) `public final boolean compareAndSwapInt(Object obj, int expect, int update)`. Since 21.3.0. Atomically sets the int value represented by this StaticProperty and stored in the specified static object to the given updated value if the current value `==` the expected value. Parameters: `obj` `Object`: the static object that stores the static property value. `expect` `int`: the expected value. `update` `int`: the new value. Returns `boolean`: `true` if successful. False return indicates that the actual value was not equal to the expected value. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the int class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#compareAndSwapInt(java.lang.Object,int,int)` ### compareAndExchangeInt(Object, int, int) `public final int compareAndExchangeInt(Object obj, int expect, int update)`. Since 21.3.0. Atomically sets the int value represented by this StaticProperty and stored in the specified static object to `newValue` if the current value, referred to as the *witness value*, `==` the expected value. Parameters: `obj` `Object`: the static object that stores the static property value. `expect` `int`: the expected value. `update` `int`: the new value. Returns `int`: the witness value, which will be the same as the expected value if successful. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#compareAndExchangeInt(java.lang.Object,int,int)` ### getAndAddInt(Object, int) `public final int getAndAddInt(Object obj, int delta)`. Since 21.3.0. Atomically adds the given value to the current int value represented by this StaticProperty and stored in the specified static object. Parameters: `obj` `Object`: the static object that stores the static property value. `delta` `int`: the value to add. Returns `int`: the previous value. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the int class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#getAndAddInt(java.lang.Object,int)` ### getAndSetInt(Object, int) `public final int getAndSetInt(Object obj, int value)`. Since 21.3.0. Atomically sets the int value represented by this StaticProperty and stored in the specified static object to the given value and returns the old value. Parameters: `obj` `Object`: the static object that stores the static property value. `value` `int`: the new value. Returns `int`: the previous value. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the int class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#getAndSetInt(java.lang.Object,int)` ### getLong(Object) `public final long getLong(Object obj)`. Since 21.3.0. Returns the long value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of reading as if the variable was declared non-volatile. Parameters: `obj` `Object`: the static object that stores the static property value. Returns `long`: the value of the static property stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the long class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#getLong(java.lang.Object)` ### getLongVolatile(Object) `public final long getLongVolatile(Object obj)`. Since 21.3.0. Returns the long value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of reading as if the variable was declared volatile. Parameters: `obj` `Object`: the static object that stores the static property value. Returns `long`: the value of the static property stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the long class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#getLongVolatile(java.lang.Object)` ### setLong(Object, long) `public final void setLong(Object obj, long value)`. Since 21.3.0. Sets the long value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of setting as if the variable was declared non-volatile. Parameters: `obj` `Object`: the static object that stores the static property value. `value` `long`: the new static property value, to be stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the long class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#setLong(java.lang.Object,long)` ### setLongVolatile(Object, long) `public final void setLongVolatile(Object obj, long value)`. Since 21.3.0. Sets the long value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of setting as if the variable was declared volatile. Parameters: `obj` `Object`: the static object that stores the static property value. `value` `long`: the new static property value, to be stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the long class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#setLongVolatile(java.lang.Object,long)` ### compareAndSwapLong(Object, long, long) `public final boolean compareAndSwapLong(Object obj, long expect, long update)`. Since 21.3.0. Atomically sets the long value represented by this StaticProperty and stored in the specified static object to the given updated value if the current value `==` the expected value. Parameters: `obj` `Object`: the static object that stores the static property value. `expect` `long`: the expected value. `update` `long`: the new value. Returns `boolean`: `true` if successful. False return indicates that the actual value was not equal to the expected value. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the long class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#compareAndSwapLong(java.lang.Object,long,long)` ### compareAndExchangeLong(Object, long, long) `public final long compareAndExchangeLong(Object obj, long expect, long update)`. Since 21.3.0. Atomically sets the long value represented by this StaticProperty and stored in the specified static object to `newValue` if the current value, referred to as the *witness value*, `==` the expected value. Parameters: `obj` `Object`: the static object that stores the static property value. `expect` `long`: the expected value. `update` `long`: the new value. Returns `long`: the witness value, which will be the same as the expected value if successful. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the long class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#compareAndExchangeLong(java.lang.Object,long,long)` ### getAndAddLong(Object, long) `public final long getAndAddLong(Object obj, long delta)`. Since 21.3.0. Atomically adds the given value to the current long value represented by this StaticProperty and stored in the specified static object. Parameters: `obj` `Object`: the static object that stores the static property value. `delta` `long`: the value to add. Returns `long`: the previous value. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the long class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#getAndAddLong(java.lang.Object,long)` ### getAndSetLong(Object, long) `public final long getAndSetLong(Object obj, long value)`. Since 21.3.0. Atomically sets the long value represented by this StaticProperty and stored in the specified static object to the given value and returns the old value. Parameters: `obj` `Object`: the static object that stores the static property value. `value` `long`: the new value. Returns `long`: the previous value. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the long class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#getAndSetLong(java.lang.Object,long)` ### getShort(Object) `public final short getShort(Object obj)`. Since 21.3.0. Returns the short value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of reading as if the variable was declared non-volatile. Parameters: `obj` `Object`: the static object that stores the static property value. Returns `short`: the value of the static property stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the short class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#getShort(java.lang.Object)` ### getShortVolatile(Object) `public final short getShortVolatile(Object obj)`. Since 21.3.0. Returns the short value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of reading as if the variable was declared volatile. Parameters: `obj` `Object`: the static object that stores the static property value. Returns `short`: the value of the static property stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the short class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#getShortVolatile(java.lang.Object)` ### setShort(Object, short) `public final void setShort(Object obj, short value)`. Since 21.3.0. Sets the short value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of setting as if the variable was declared non-volatile. Parameters: `obj` `Object`: the static object that stores the static property value. `value` `short`: the new static property value, to be stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the short class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#setShort(java.lang.Object,short)` ### setShortVolatile(Object, short) `public final void setShortVolatile(Object obj, short value)`. Since 21.3.0. Sets the short value represented by this StaticProperty and stored in the specified static object. This property access has the memory semantics of setting as if the variable was declared volatile. Parameters: `obj` `Object`: the static object that stores the static property value. `value` `short`: the new static property value, to be stored in static object obj. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the short class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#setShortVolatile(java.lang.Object,short)` ### compareAndSwapShort(Object, short, short) `public final boolean compareAndSwapShort(Object obj, short expect, short update)`. Since 21.3.0. Atomically sets the short value represented by this StaticProperty and stored in the specified static object to the given updated value if the current value `==` the expected value. Parameters: `obj` `Object`: the static object that stores the static property value. `expect` `short`: the expected value. `update` `short`: the new value. Returns `boolean`: `true` if successful. False return indicates that the actual value was not equal to the expected value. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the short class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#compareAndSwapShort(java.lang.Object,short,short)` ### compareAndExchangeShort(Object, short, short) `public final short compareAndExchangeShort(Object obj, short expect, short update)`. Since 21.3.0. Atomically sets the short value represented by this StaticProperty and stored in the specified static object to `newValue` if the current value, referred to as the *witness value*, `==` the expected value. Parameters: `obj` `Object`: the static object that stores the static property value. `expect` `short`: the expected value. `update` `short`: the new value. Returns `short`: the witness value, which will be the same as the expected value if successful. Throws: `IllegalArgumentException` (unchecked): if the static property type is not the short class, or obj does not have a `StaticShape` compatible with this static property. Cite: `com/oracle/truffle/api/staticobject/StaticProperty.html#compareAndExchangeShort(java.lang.Object,short,short)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ StaticShape [truffle-api](index.md) › [com.oracle.truffle.api.staticobject](com/oracle/truffle/api/staticobject/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.staticobject`](com/oracle/truffle/api/staticobject/index.md). Since 21.3.0. ```java public abstract class StaticShape ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `StaticShape` A StaticShape is an immutable descriptor of the layout of a static object and is a good entry point to learn about the Static Object Model. Here is an overview: - [`StaticShape.newBuilder(TruffleLanguage)`](com/oracle/truffle/api/staticobject/StaticShape.md#newBuilder%28com.oracle.truffle.api.TruffleLanguage%29) returns a [`StaticShape.Builder`](com/oracle/truffle/api/staticobject/StaticShape.Builder.md) object that can be used to [register](com/oracle/truffle/api/staticobject/StaticShape.Builder.md#property%28com.oracle.truffle.api.staticobject.StaticProperty,java.lang.Class,boolean%29) [static properties](com/oracle/truffle/api/staticobject/StaticProperty.md) and to generate a new static shape by calling one of its [build methods](com/oracle/truffle/api/staticobject/StaticShape.Builder.md#build%28%29). - [`StaticShape.getFactory()`](com/oracle/truffle/api/staticobject/StaticShape.md#getFactory%28%29) returns an implementation of the [default](com/oracle/truffle/api/staticobject/StaticShape.Builder.md#build%28%29) or the [user-defined](com/oracle/truffle/api/staticobject/StaticShape.Builder.md#build%28java.lang.Class,java.lang.Class%29) factory interface that must be used to allocate static objects with the current shape. - Property values stored in a static object of a given shape can be accessed by the [`StaticProperty`](com/oracle/truffle/api/staticobject/StaticProperty.md) instances registered to the builder that generated that shape or one of its [parent shapes](com/oracle/truffle/api/staticobject/StaticShape.Builder.md#build%28com.oracle.truffle.api.staticobject.StaticShape%29). Note that static shapes do not store the list of [static properties](com/oracle/truffle/api/staticobject/StaticProperty.md) associated to them. It is up to the user to store this information when required, for example in a class that contains references to the static shape and the list of [static properties](com/oracle/truffle/api/staticobject/StaticProperty.md). StaticShape cannot be subclassed by custom implementations and, when required, it allows [static properties](com/oracle/truffle/api/staticobject/StaticProperty.md) to check that the receiver object matches the expected shape. **Type parameters** - ``: the [default](com/oracle/truffle/api/staticobject/StaticShape.Builder.md#build%28%29) or the [user-defined](com/oracle/truffle/api/staticobject/StaticShape.Builder.md#build%28java.lang.Class,java.lang.Class%29) factory interface to allocate static objects **See also** - [`StaticShape.newBuilder(TruffleLanguage)`](com/oracle/truffle/api/staticobject/StaticShape.md#newBuilder%28com.oracle.truffle.api.TruffleLanguage%29) - [`StaticShape.Builder`](com/oracle/truffle/api/staticobject/StaticShape.Builder.md) - [`StaticProperty`](com/oracle/truffle/api/staticobject/StaticProperty.md) - [`DefaultStaticProperty`](com/oracle/truffle/api/staticobject/DefaultStaticProperty.md) - [`DefaultStaticObjectFactory`](com/oracle/truffle/api/staticobject/DefaultStaticObjectFactory.md) ## Nested types - [`StaticShape.Builder`](com/oracle/truffle/api/staticobject/StaticShape.Builder.md) (class): Builder class to construct StaticShape instances. ## Methods ### newBuilder(TruffleLanguage) `public static StaticShape.Builder newBuilder(TruffleLanguage language)`. Since 21.3.0. Creates a new static shape builder. The builder instance is not thread-safe and must not be used from multiple threads at the same time. Users of the Static Object Model are expected to define custom subtypes of `StaticProperty` or use `DefaultStaticProperty`, a trivial default implementation. In both cases, static properties must be registered to a static shape builder using `StaticShape.Builder.property(StaticProperty, Class, boolean)`. Then, after allocating a `StaticShape` instance with one of the `StaticShape.Builder.build()` methods and allocating a static object using the factory class provided by `StaticShape.getFactory()`, users can call the accessor methods defined in `StaticProperty` to get and set property values stored in a static object instance. Parameters: `language` `TruffleLanguage`: an instance of the `TruffleLanguage` that uses the Static Object Model. Returns `StaticShape.Builder`: a new static shape builder. Throws: `NullPointerException` (unchecked): if language is null. See also: `StaticShape`, `StaticProperty`, `DefaultStaticProperty`, `DefaultStaticObjectFactory`. Cite: `com/oracle/truffle/api/staticobject/StaticShape.html#newBuilder(com.oracle.truffle.api.TruffleLanguage)` ### getFactory() `public final T getFactory()`. Since 21.3.0. Returns an instance of the default or the user-defined factory interface that must be used to allocate static objects with the current shape. See also: `StaticShape.Builder.build()`, `StaticShape.Builder.build(StaticShape)`, `StaticShape.Builder.build(Class, Class)`. Cite: `com/oracle/truffle/api/staticobject/StaticShape.html#getFactory()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ StaticShape.Builder [truffle-api](index.md) › [com.oracle.truffle.api.staticobject](com/oracle/truffle/api/staticobject/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.staticobject`](com/oracle/truffle/api/staticobject/index.md). Since 21.3.0. Nested in [`StaticShape`](com/oracle/truffle/api/staticobject/StaticShape.md). ```java public static final class StaticShape.Builder ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Builder` Builder class to construct [`StaticShape`](com/oracle/truffle/api/staticobject/StaticShape.md) instances. The builder instance is not thread-safe and must not be used from multiple threads at the same time. **See also** - [`StaticShape.newBuilder(TruffleLanguage)`](com/oracle/truffle/api/staticobject/StaticShape.md#newBuilder%28com.oracle.truffle.api.TruffleLanguage%29) ## Methods ### property(StaticProperty, Class, boolean) `public StaticShape.Builder property(StaticProperty property, Class type, boolean storeAsFinal)`. Since 21.3.0. Adds a `StaticProperty` to the static shape to be constructed. The property id cannot be null or an empty String. It is not allowed to add two properties with the same id to the same builder, or to add the same property to more than one builder. Static shapes that extend a parent shape can have properties with the same id of those in the parent shape. Only property accesses that match the specified type are allowed. Property values can be optionally stored in a final field. Accesses to such values might be specially optimized by the compiler. For example, reads might be constant-folded. It is up to the user to enforce that property values stored as final are not assigned more than once. Parameters: `property` `StaticProperty`: the `StaticProperty` to be added. `type` `Class`: the type of the `StaticProperty` to be added. `storeAsFinal` `boolean`: if this property value can be stored in a final field. Returns `StaticShape.Builder`: the Builder instance. Throws: `IllegalArgumentException` (unchecked): if more than 65535 properties are added, or if the property id is an empty string or it is equal to the id of another static property already registered to this builder. `IllegalStateException` (unchecked): if this method is invoked after building a static shape. `NullPointerException` (unchecked): if the property id is null. See also: `DefaultStaticProperty`. Cite: `com/oracle/truffle/api/staticobject/StaticShape.Builder.html#property(com.oracle.truffle.api.staticobject.StaticProperty,java.lang.Class,boolean)` ### safetyChecks(boolean) `public StaticShape.Builder safetyChecks(boolean enabled)`. Since 25.3. Configures whether `StaticProperty` accesses to the `StaticShape` built by this builder perform safety checks. Disable safety checks only when every access to a property of this shape is guaranteed to use a receiver with a compatible shape. This can be established by static analysis or by equivalent checks in the language implementation. Otherwise, accesses may operate on incompatible storage and cause memory corruption. Before disabling safety checks, a detailed security review should verify that this invariant is maintained. If this method is not called, the static shape uses the engine-level `engine.RelaxStaticObjectSafetyChecks` option. The engine-level `engine.ForceStaticObjectSafetyChecks` option takes precedence over this builder configuration and always enables safety checks. Parameters: `enabled` `boolean`: `true` to enable safety checks, or `false` to disable them. Returns `StaticShape.Builder`: the Builder instance. Throws: `IllegalStateException` (unchecked): if this method is invoked after building a static shape. Cite: `com/oracle/truffle/api/staticobject/StaticShape.Builder.html#safetyChecks(boolean)` ### build() `public StaticShape build()`. Since 21.3.0. Builds a new static shape using the configuration of this builder. The factory class returned by `StaticShape.getFactory()` implements `DefaultStaticObjectFactory` and static objects extend [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html). Returns `StaticShape`: the new `StaticShape`. Throws: `IllegalStateException` (unchecked): if a static property was added to more than one builder or multiple times to the same builder, if this method is invoked more than once, or if one of the static property types is not visible to the class loader that loaded the default factory interface. See also: `DefaultStaticObjectFactory`, `StaticShape.Builder.build(StaticShape)`, `StaticShape.Builder.build(Class, Class)`. Cite: `com/oracle/truffle/api/staticobject/StaticShape.Builder.html#build()` ### build(StaticShape) `public StaticShape build(StaticShape parentShape)`. Since 21.3.0. Builds a new static shape that extends the provided parent `StaticShape`. Static properties of the parent shape can be used to access field values of static objects with the child shape. The factory class returned by `StaticShape.getFactory()` extends the one of the parent shape and static objects extend the static object class allocated by the factory class of the parent shape. Type parameters: ``: the generic type of the parent shape. Parameters: `parentShape` `StaticShape`: the parent shape. Returns `StaticShape`: the new `StaticShape`. Throws: `IllegalStateException` (unchecked): if a static property was added to more than one builder or multiple times to the same builder, if this method is invoked more than once, or if one of the static property types is not visible to the class loader that loaded the default factory interface. See also: `StaticShape.Builder.build()`, `StaticShape.Builder.build(Class, Class)`. Cite: `com/oracle/truffle/api/staticobject/StaticShape.Builder.html#build(com.oracle.truffle.api.staticobject.StaticShape)` ### build(Class, Class) `public StaticShape build(Class superClass, Class factoryInterface)`. Since 21.3.0. Builds a new static shape using the configuration of this builder. The factory class returned by `StaticShape.getFactory()` implements factoryInterface and static objects extend superClass. The following constraints are enforced: factoryInterface must be an interface; the arguments of every method in factoryInterface must match those of a visible constructor of superClass; the return type of every method in factoryInterface must be assignable from the superClass; superClass does not have abstract methods; if superClass is [`Cloneable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Cloneable.html), it cannot override [`Object.clone()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29) with a final method. Type parameters: ``: the class of the factory interface. Parameters: `superClass` `Class`: the class that static objects must extend. `factoryInterface` `Class`: the factory interface that the factory class returned by `StaticShape.getFactory()` must implement. Returns `StaticShape`: the new `StaticShape`. Throws: `IllegalArgumentException` (unchecked): if factoryInterface is not an interface, if the arguments of a method in factoryInterface do not match those of a visible constructor in superClass, if the return type of a method in factoryInterface is not assignable from superClass, if `StaticShape` is not visible to the class loader of factoryInterface, if superClass has abstract methods or if superClass is [`Cloneable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Cloneable.html) and overrides [`Object.clone()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29) with a final method. `IllegalStateException` (unchecked): if a static property was added to more than one builder or multiple times to the same builder, if this method is invoked more than once, or if one of the static property types is not visible to the class loader that loaded the factory interface. See also: `StaticShape.Builder.build()`, `StaticShape.Builder.build(StaticShape)`. Cite: `com/oracle/truffle/api/staticobject/StaticShape.Builder.html#build(java.lang.Class,java.lang.Class)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ▣ com.oracle.truffle.api.strings [truffle-api](index.md) · Every page: [llms.txt](llms.txt) Package in truffle-api. Since 22.1. Truffle String related APIs. Please see the [tutorial](https://github.com/oracle/graal/tree/master/truffle/docs/TruffleStrings.md) for further usage instructions. ## Interfaces - [`NativeAllocator`](com/oracle/truffle/api/strings/NativeAllocator.md): An allocation function for native buffers. - [`TranscodingErrorHandler`](com/oracle/truffle/api/strings/TranscodingErrorHandler.md): An error handler for transcoding operations such as TruffleString.SwitchEncodingNode. ## Classes - [`AbstractTruffleString`](com/oracle/truffle/api/strings/AbstractTruffleString.md): Abstract base class for Truffle strings. - [`InternalByteArray`](com/oracle/truffle/api/strings/InternalByteArray.md): Wrapper object containing a TruffleString's internal byte array, along with a byte offset and length defining the region in use. - [`MutableTruffleString`](com/oracle/truffle/api/strings/MutableTruffleString.md): Represents a mutable variant of a TruffleString. - [`MutableTruffleStringFactory`](com/oracle/truffle/api/strings/MutableTruffleStringFactory.md): No description. - [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md): Represents a primitive String type, which can be reused across languages. - [`TruffleStringBuilder`](com/oracle/truffle/api/strings/TruffleStringBuilder.md): The TruffleString equivalent to java.lang.StringBuilder. - [`TruffleStringBuilderFactory`](com/oracle/truffle/api/strings/TruffleStringBuilderFactory.md): No description. - [`TruffleStringBuilderUTF16`](com/oracle/truffle/api/strings/TruffleStringBuilderUTF16.md): The UTF-16-specific variant of TruffleStringBuilder. - [`TruffleStringBuilderUTF32`](com/oracle/truffle/api/strings/TruffleStringBuilderUTF32.md): The UTF-32-specific variant of TruffleStringBuilder. - [`TruffleStringBuilderUTF8`](com/oracle/truffle/api/strings/TruffleStringBuilderUTF8.md): The UTF-8-specific variant of TruffleStringBuilder. - [`TruffleStringFactory`](com/oracle/truffle/api/strings/TruffleStringFactory.md): No description. - [`TruffleStringIterator`](com/oracle/truffle/api/strings/TruffleStringIterator.md): An iterator object that allows iterating over a TruffleString's codepoints, without having to re-calculate codepoint indices on every access. - [`TruffleStringIteratorFactory`](com/oracle/truffle/api/strings/TruffleStringIteratorFactory.md): No description. # ◆ AbstractTruffleString [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Sealed abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. ```java public abstract sealed class AbstractTruffleString permits TruffleString, MutableTruffleString ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `AbstractTruffleString` Permitted subtypes: [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md), [`MutableTruffleString`](com/oracle/truffle/api/strings/MutableTruffleString.md) Abstract base class for Truffle strings. Useful when a value can be both a [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md) or a [`MutableTruffleString`](com/oracle/truffle/api/strings/MutableTruffleString.md). Note that values of this type are not valid interop values. They must be converted to [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md) before passing them to other languages. **See also** - [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md) ## Methods ### isEmpty() `public final boolean isEmpty()`. Since 22.1. Returns `true` if this string is empty. This method is allowed to be used on fast paths. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#isEmpty()` ### byteLength(TruffleString.Encoding) `public final int byteLength(TruffleString.Encoding expectedEncoding)`. Since 22.1. Get this string's length in bytes. This method is allowed to be used on fast paths. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#byteLength(com.oracle.truffle.api.strings.TruffleString.Encoding)` ### isCompatibleToUncached(TruffleString.Encoding) `public final boolean isCompatibleToUncached(TruffleString.Encoding expectedEncoding)`. Since 23.0. Returns `true` if this string is compatible to the given encoding. Compatible for `TruffleString` means it is byte-equivalent in both the encoding used to create this string and the given encoding. For `MutableTruffleString` this method only returned true if the passed encoding is the same encoding used to create this string. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#isCompatibleToUncached(com.oracle.truffle.api.strings.TruffleString.Encoding)` ### isManaged() `public final boolean isManaged()`. Since 22.1. Returns `true` if this string is *not* backed by a native pointer. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#isManaged()` ### isNative() `public final boolean isNative()`. Since 22.1. Returns `true` if this string is backed by a native pointer. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#isNative()` ### isImmutable() `public final boolean isImmutable()`. Since 22.1. Returns `true` if this string is immutable, i.e. an instance of `TruffleString`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#isImmutable()` ### isMutable() `public final boolean isMutable()`. Since 22.1. Returns `true` if this string is mutable, i.e. an instance of `MutableTruffleString`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#isMutable()` ### asTruffleStringUncached(TruffleString.Encoding) `public final TruffleString asTruffleStringUncached(TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.FromByteArrayNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#asTruffleStringUncached(com.oracle.truffle.api.strings.TruffleString.Encoding)` ### asManagedTruffleStringUncached(TruffleString.Encoding) `public final TruffleString asManagedTruffleStringUncached(TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.AsManagedNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#asManagedTruffleStringUncached(com.oracle.truffle.api.strings.TruffleString.Encoding)` ### asManagedTruffleStringUncached(TruffleString.Encoding, boolean) `public final TruffleString asManagedTruffleStringUncached(TruffleString.Encoding expectedEncoding, boolean cacheResult)`. Since 23.0. Shorthand for calling the uncached version of `TruffleString.AsManagedNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#asManagedTruffleStringUncached(com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### asMutableTruffleStringUncached(TruffleString.Encoding) `public final MutableTruffleString asMutableTruffleStringUncached(TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `MutableTruffleString.AsMutableTruffleStringNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#asMutableTruffleStringUncached(com.oracle.truffle.api.strings.TruffleString.Encoding)` ### asManagedMutableTruffleStringUncached(TruffleString.Encoding) `public final MutableTruffleString asManagedMutableTruffleStringUncached(TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.AsManagedNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#asManagedMutableTruffleStringUncached(com.oracle.truffle.api.strings.TruffleString.Encoding)` ### materializeUncached(AbstractTruffleString, TruffleString.Encoding) `@Deprecated(since = "25.1") public void materializeUncached(AbstractTruffleString a, TruffleString.Encoding expectedEncoding)`. Since 23.1. Deprecated since 25.1. since 25.1, use `materializeUncached(Encoding)` instead. Shorthand for calling the uncached version of `TruffleString.MaterializeNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#materializeUncached(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### materializeUncached(TruffleString.Encoding) `public void materializeUncached(TruffleString.Encoding expectedEncoding)`. Since 25.1. Shorthand for calling the uncached version of `TruffleString.MaterializeNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#materializeUncached(com.oracle.truffle.api.strings.TruffleString.Encoding)` ### materializeSubstringUncached(TruffleString.Encoding) `public TruffleString materializeSubstringUncached(TruffleString.Encoding expectedEncoding)`. Since 25.1. Shorthand for calling the uncached version of `TruffleString.MaterializeSubstringNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#materializeSubstringUncached(com.oracle.truffle.api.strings.TruffleString.Encoding)` ### getCodeRangeUncached(TruffleString.Encoding) `public final TruffleString.CodeRange getCodeRangeUncached(TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.GetCodeRangeNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#getCodeRangeUncached(com.oracle.truffle.api.strings.TruffleString.Encoding)` ### getCodeRangeImpreciseUncached(TruffleString.Encoding) `public final TruffleString.CodeRange getCodeRangeImpreciseUncached(TruffleString.Encoding expectedEncoding)`. Since 23.0. Shorthand for calling the uncached version of `TruffleString.GetCodeRangeImpreciseNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#getCodeRangeImpreciseUncached(com.oracle.truffle.api.strings.TruffleString.Encoding)` ### getByteCodeRangeUncached(TruffleString.Encoding) `public final TruffleString.CodeRange getByteCodeRangeUncached(TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.GetByteCodeRangeNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#getByteCodeRangeUncached(com.oracle.truffle.api.strings.TruffleString.Encoding)` ### codeRangeEqualsUncached(TruffleString.CodeRange) `public final boolean codeRangeEqualsUncached(TruffleString.CodeRange otherCodeRange)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.CodeRangeEqualsNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#codeRangeEqualsUncached(com.oracle.truffle.api.strings.TruffleString.CodeRange)` ### isValidUncached(TruffleString.Encoding) `public final boolean isValidUncached(TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.IsValidNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#isValidUncached(com.oracle.truffle.api.strings.TruffleString.Encoding)` ### getStringCompactionLevelUncached(TruffleString.Encoding) `public final TruffleString.CompactionLevel getStringCompactionLevelUncached(TruffleString.Encoding expectedEncoding)`. Since 23.0. Shorthand for calling the uncached version of `TruffleString.GetStringCompactionLevelNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#getStringCompactionLevelUncached(com.oracle.truffle.api.strings.TruffleString.Encoding)` ### codePointLengthUncached(TruffleString.Encoding) `public final int codePointLengthUncached(TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.CodePointLengthNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#codePointLengthUncached(com.oracle.truffle.api.strings.TruffleString.Encoding)` ### hashCodeUncached(TruffleString.Encoding) `public final int hashCodeUncached(TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.HashCodeNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#hashCodeUncached(com.oracle.truffle.api.strings.TruffleString.Encoding)` ### readByteUncached(int, TruffleString.Encoding) `public final int readByteUncached(int i, TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.ReadByteNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#readByteUncached(int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### readCharUTF16Uncached(int) `public final int readCharUTF16Uncached(int i)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.ReadCharUTF16Node`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#readCharUTF16Uncached(int)` ### byteLengthOfCodePointUncached(int, TruffleString.Encoding) `public final int byteLengthOfCodePointUncached(int byteIndex, TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.CodePointIndexToByteIndexNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#byteLengthOfCodePointUncached(int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### byteLengthOfCodePointUncached(int, TruffleString.Encoding, TruffleString.ErrorHandling) `public final int byteLengthOfCodePointUncached(int byteIndex, TruffleString.Encoding expectedEncoding, TruffleString.ErrorHandling errorHandling)`. Since 22.3. Shorthand for calling the uncached version of `TruffleString.CodePointIndexToByteIndexNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#byteLengthOfCodePointUncached(int,com.oracle.truffle.api.strings.TruffleString.Encoding,com.oracle.truffle.api.strings.TruffleString.ErrorHandling)` ### byteIndexToCodePointIndexUncached(int, int, TruffleString.Encoding) `public final int byteIndexToCodePointIndexUncached(int byteOffset, int byteIndex, TruffleString.Encoding expectedEncoding)`. Since 22.2. Shorthand for calling the uncached version of `TruffleString.ByteIndexToCodePointIndexNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#byteIndexToCodePointIndexUncached(int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### codePointIndexToByteIndexUncached(int, int, TruffleString.Encoding) `public final int codePointIndexToByteIndexUncached(int byteOffset, int codepointIndex, TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.CodePointIndexToByteIndexNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#codePointIndexToByteIndexUncached(int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### codePointAtIndexUncached(int, TruffleString.Encoding) `public final int codePointAtIndexUncached(int i, TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.CodePointAtIndexNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#codePointAtIndexUncached(int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### codePointAtIndexUncached(int, TruffleString.Encoding, TruffleString.ErrorHandling) `public final int codePointAtIndexUncached(int i, TruffleString.Encoding expectedEncoding, TruffleString.ErrorHandling errorHandling)`. Since 22.3. Shorthand for calling the uncached version of `TruffleString.CodePointAtIndexNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#codePointAtIndexUncached(int,com.oracle.truffle.api.strings.TruffleString.Encoding,com.oracle.truffle.api.strings.TruffleString.ErrorHandling)` ### codePointAtIndexUTF32Uncached(int) `public final int codePointAtIndexUTF32Uncached(int i)`. Since 25.1. Shorthand for calling the uncached version of `TruffleString.CodePointAtIndexNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#codePointAtIndexUTF32Uncached(int)` ### codePointAtByteIndexUncached(int, TruffleString.Encoding) `public final int codePointAtByteIndexUncached(int i, TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.CodePointAtByteIndexNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#codePointAtByteIndexUncached(int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### codePointAtByteIndexUncached(int, TruffleString.Encoding, TruffleString.ErrorHandling) `public final int codePointAtByteIndexUncached(int i, TruffleString.Encoding expectedEncoding, TruffleString.ErrorHandling errorHandling)`. Since 22.3. Shorthand for calling the uncached version of `TruffleString.CodePointAtByteIndexNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#codePointAtByteIndexUncached(int,com.oracle.truffle.api.strings.TruffleString.Encoding,com.oracle.truffle.api.strings.TruffleString.ErrorHandling)` ### byteIndexOfAnyByteUncached(int, int, …) `public final int byteIndexOfAnyByteUncached(int fromByteIndex, int maxByteIndex, byte[] values, TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.ByteIndexOfAnyByteNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#byteIndexOfAnyByteUncached(int,int,byte[],com.oracle.truffle.api.strings.TruffleString.Encoding)` ### charIndexOfAnyCharUTF16Uncached(int, int, char[]) `public final int charIndexOfAnyCharUTF16Uncached(int fromCharIndex, int maxCharIndex, char[] values)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.CharIndexOfAnyCharUTF16Node`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#charIndexOfAnyCharUTF16Uncached(int,int,char[])` ### intIndexOfAnyIntUTF32Uncached(int, int, int[]) `public final int intIndexOfAnyIntUTF32Uncached(int fromIntIndex, int maxIntIndex, int[] values)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.IntIndexOfAnyIntUTF32Node`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#intIndexOfAnyIntUTF32Uncached(int,int,int[])` ### indexOfCodePointUncached(int, int, …) `public final int indexOfCodePointUncached(int cp, int fromIndex, int toIndex, TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.IndexOfCodePointNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#indexOfCodePointUncached(int,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### byteIndexOfCodePointUncached(int, int, …) `public final int byteIndexOfCodePointUncached(int cp, int fromIndex, int toIndex, TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.ByteIndexOfCodePointNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#byteIndexOfCodePointUncached(int,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### lastIndexOfCodePointUncached(int, int, …) `public final int lastIndexOfCodePointUncached(int cp, int fromIndex, int toIndex, TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.LastIndexOfCodePointNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#lastIndexOfCodePointUncached(int,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### lastByteIndexOfCodePointUncached(int, int, …) `public final int lastByteIndexOfCodePointUncached(int cp, int fromIndex, int toIndex, TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.LastByteIndexOfCodePointNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#lastByteIndexOfCodePointUncached(int,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### indexOfStringUncached(AbstractTruffleString, int, …) `public final int indexOfStringUncached(AbstractTruffleString b, int fromIndex, int toIndex, TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.IndexOfStringNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#indexOfStringUncached(com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### byteIndexOfStringUncached(AbstractTruffleString, int, …) `public final int byteIndexOfStringUncached(AbstractTruffleString b, int fromIndex, int toIndex, TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.ByteIndexOfStringNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#byteIndexOfStringUncached(com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### byteIndexOfStringUncached(TruffleString.WithMask, int, …) `public final int byteIndexOfStringUncached(TruffleString.WithMask b, int fromIndex, int toIndex, TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.ByteIndexOfStringNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#byteIndexOfStringUncached(com.oracle.truffle.api.strings.TruffleString.WithMask,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### byteIndexOfStringSetUncached(int, int, TruffleString.StringSet) `public final long byteIndexOfStringSetUncached(int fromByteIndex, int toByteIndex, TruffleString.StringSet stringSet)`. Since 25.1. Shorthand for calling the uncached version of `TruffleString.ByteIndexOfStringSetNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#byteIndexOfStringSetUncached(int,int,com.oracle.truffle.api.strings.TruffleString.StringSet)` ### lastIndexOfStringUncached(AbstractTruffleString, int, …) `public final int lastIndexOfStringUncached(AbstractTruffleString b, int fromIndex, int toIndex, TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.LastIndexOfStringNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#lastIndexOfStringUncached(com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### lastByteIndexOfStringUncached(AbstractTruffleString, int, …) `public final int lastByteIndexOfStringUncached(AbstractTruffleString b, int fromIndex, int toIndex, TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.LastByteIndexOfStringNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#lastByteIndexOfStringUncached(com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### lastByteIndexOfStringUncached(TruffleString.WithMask, int, …) `public final int lastByteIndexOfStringUncached(TruffleString.WithMask b, int fromIndex, int toIndex, TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.LastByteIndexOfStringNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#lastByteIndexOfStringUncached(com.oracle.truffle.api.strings.TruffleString.WithMask,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### compareBytesUncached(AbstractTruffleString, TruffleString.Encoding) `public final int compareBytesUncached(AbstractTruffleString b, TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.CompareBytesNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#compareBytesUncached(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### compareCharsUTF16Uncached(AbstractTruffleString) `public final int compareCharsUTF16Uncached(AbstractTruffleString b)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.CompareCharsUTF16Node`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#compareCharsUTF16Uncached(com.oracle.truffle.api.strings.AbstractTruffleString)` ### compareIntsUTF32Uncached(AbstractTruffleString) `public final int compareIntsUTF32Uncached(AbstractTruffleString b)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.CompareIntsUTF32Node`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#compareIntsUTF32Uncached(com.oracle.truffle.api.strings.AbstractTruffleString)` ### regionEqualsUncached(int, AbstractTruffleString, …) `public final boolean regionEqualsUncached(int fromIndexA, AbstractTruffleString b, int fromIndexB, int regionLength, TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.RegionEqualNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#regionEqualsUncached(int,com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### regionEqualByteIndexUncached(int, AbstractTruffleString, …) `public final boolean regionEqualByteIndexUncached(int fromByteIndexA, AbstractTruffleString b, int fromByteIndexB, int byteLength, TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.RegionEqualByteIndexNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#regionEqualByteIndexUncached(int,com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### regionEqualByteIndexUncached(int, TruffleString.WithMask, …) `public final boolean regionEqualByteIndexUncached(int fromByteIndexA, TruffleString.WithMask b, int fromByteIndexB, int byteLength, TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.RegionEqualByteIndexNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#regionEqualByteIndexUncached(int,com.oracle.truffle.api.strings.TruffleString.WithMask,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### concatUncached(AbstractTruffleString, TruffleString.Encoding, boolean) `public final TruffleString concatUncached(AbstractTruffleString b, TruffleString.Encoding expectedEncoding, boolean lazy)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.ConcatNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#concatUncached(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### repeatUncached(int, TruffleString.Encoding) `public final TruffleString repeatUncached(int n, TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.RepeatNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#repeatUncached(int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### substringUncached(int, int, …) `public final TruffleString substringUncached(int fromIndex, int substringLength, TruffleString.Encoding expectedEncoding, boolean lazy)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.SubstringNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#substringUncached(int,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### substringByteIndexUncached(int, int, …) `public final TruffleString substringByteIndexUncached(int fromByteIndex, int byteLength, TruffleString.Encoding expectedEncoding, boolean lazy)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.SubstringByteIndexNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#substringByteIndexUncached(int,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### equalsUncached(AbstractTruffleString, TruffleString.Encoding) `public final boolean equalsUncached(AbstractTruffleString b, TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.EqualNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#equalsUncached(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### parseIntUncached() `public final int parseIntUncached() throws TruffleString.NumberFormatException`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.ParseIntNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#parseIntUncached()` ### parseIntUncached(int) `public final int parseIntUncached(int radix) throws TruffleString.NumberFormatException`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.ParseIntNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#parseIntUncached(int)` ### parseLongUncached() `public final long parseLongUncached() throws TruffleString.NumberFormatException`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.ParseLongNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#parseLongUncached()` ### parseLongUncached(int) `public final long parseLongUncached(int radix) throws TruffleString.NumberFormatException`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.ParseLongNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#parseLongUncached(int)` ### parseDoubleUncached() `public final double parseDoubleUncached() throws TruffleString.NumberFormatException`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.ParseDoubleNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#parseDoubleUncached()` ### getInternalByteArrayUncached(TruffleString.Encoding) `public final InternalByteArray getInternalByteArrayUncached(TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.GetInternalByteArrayNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#getInternalByteArrayUncached(com.oracle.truffle.api.strings.TruffleString.Encoding)` ### getInternalNativePointerUncached(TruffleString.Encoding) `public final Object getInternalNativePointerUncached(TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.GetInternalNativePointerNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#getInternalNativePointerUncached(com.oracle.truffle.api.strings.TruffleString.Encoding)` ### copyToByteArrayUncached(TruffleString.Encoding) `public final byte[] copyToByteArrayUncached(TruffleString.Encoding expectedEncoding)`. Since 22.3. Shorthand for calling the uncached version of `TruffleString.CopyToByteArrayNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#copyToByteArrayUncached(com.oracle.truffle.api.strings.TruffleString.Encoding)` ### copyToByteArrayUncached(int, byte[], …) `public final void copyToByteArrayUncached(int byteFromIndexA, byte[] dst, int byteFromIndexDst, int byteLength, TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.CopyToByteArrayNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#copyToByteArrayUncached(int,byte[],int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### copyToNativeMemoryUncached(int, Object, …) `public final void copyToNativeMemoryUncached(int byteFromIndexA, Object pointerObject, int byteFromIndexDst, int byteLength, TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.CopyToNativeMemoryNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#copyToNativeMemoryUncached(int,java.lang.Object,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### toValidStringUncached(TruffleString.Encoding) `public TruffleString toValidStringUncached(TruffleString.Encoding expectedEncoding)`. Since 23.1. Shorthand for calling the uncached version of `TruffleString.ToValidStringNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#toValidStringUncached(com.oracle.truffle.api.strings.TruffleString.Encoding)` ### toJavaStringUncached() `public final String toJavaStringUncached()`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.ToJavaStringNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#toJavaStringUncached()` ### switchEncodingUncached(TruffleString.Encoding) `public final TruffleString switchEncodingUncached(TruffleString.Encoding targetEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.SwitchEncodingNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#switchEncodingUncached(com.oracle.truffle.api.strings.TruffleString.Encoding)` ### switchEncodingUncached(TruffleString.Encoding, TranscodingErrorHandler) `public final TruffleString switchEncodingUncached(TruffleString.Encoding targetEncoding, TranscodingErrorHandler errorHandler)`. Since 23.1. Shorthand for calling the uncached version of `TruffleString.SwitchEncodingNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#switchEncodingUncached(com.oracle.truffle.api.strings.TruffleString.Encoding,com.oracle.truffle.api.strings.TranscodingErrorHandler)` ### forceEncodingUncached(TruffleString.Encoding, TruffleString.Encoding) `public final TruffleString forceEncodingUncached(TruffleString.Encoding expectedEncoding, TruffleString.Encoding targetEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.ForceEncodingNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#forceEncodingUncached(com.oracle.truffle.api.strings.TruffleString.Encoding,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### createCodePointIteratorUncached(TruffleString.Encoding) `public final TruffleStringIterator createCodePointIteratorUncached(TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.CreateCodePointIteratorNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#createCodePointIteratorUncached(com.oracle.truffle.api.strings.TruffleString.Encoding)` ### createBackwardCodePointIteratorUncached(TruffleString.Encoding) `public final TruffleStringIterator createBackwardCodePointIteratorUncached(TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `TruffleString.CreateBackwardCodePointIteratorNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#createBackwardCodePointIteratorUncached(com.oracle.truffle.api.strings.TruffleString.Encoding)` ### equals(Object) `public final boolean equals(Object obj)`. Since 22.1. Returns `true` if this string is equal to `obj`. `TruffleString` does not attempt to automatically convert differently encoded strings during comparison, make sure to convert both strings to a common encoding before comparing them! Overrides `equals(java.lang.Object)`. See also: `TruffleString.EqualNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#equals(java.lang.Object)` ### hashCode() `public final int hashCode()`. Since 22.1. Returns this string's hashcode. Note that the hashcode is dependent on the string's encoding, make sure to convert strings to a common encoding before comparing their hash codes! Overrides `hashCode()`. See also: `TruffleString.HashCodeNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#hashCode()` ### toString() `public final String toString()`. Since 22.1. Returns a [`String`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html) representation of this string. Do not use this on fast paths. Overrides `toString()`. See also: `TruffleString.ToJavaStringNode`. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#toString()` ### toStringDebug() `public final String toStringDebug()`. Since 22.1. Returns debug information about this string. For debugging purposes only. The format of the information returned by this method is unspecified and may change at any time. Cite: `com/oracle/truffle/api/strings/AbstractTruffleString.html#toStringDebug()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ InternalByteArray [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. ```java public final class InternalByteArray ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `InternalByteArray` Wrapper object containing a [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md)'s internal byte array, along with a byte offset and length defining the region in use. ## Methods ### getArray() `public byte[] getArray()`. Since 22.1. Get the internal byte array. Do not modify the array's contents! Cite: `com/oracle/truffle/api/strings/InternalByteArray.html#getArray()` ### getOffset() `public int getOffset()`. Since 22.1. Get the string region's starting index. Cite: `com/oracle/truffle/api/strings/InternalByteArray.html#getOffset()` ### getLength() `public int getLength()`. Since 22.1. Get the string region's length. Cite: `com/oracle/truffle/api/strings/InternalByteArray.html#getLength()` ### getEnd() `public int getEnd()`. Since 22.1. Get the string region's end (`offset + length`). Cite: `com/oracle/truffle/api/strings/InternalByteArray.html#getEnd()` ### get(int) `public byte get(int index)`. Since 22.2. Read the byte at `getArray()[getOffset() + index]` and return it as a byte, similar to `TruffleString.ReadByteNode`. Consider using `TruffleString.ReadByteNode` (and `TruffleString.MaterializeNode` before) instead if not needing the byte[] for other purposes, as that will avoid extra copying if the string `is stored in native memory`. Cite: `com/oracle/truffle/api/strings/InternalByteArray.html#get(int)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ MutableTruffleString [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. ```java public final class MutableTruffleString extends AbstractTruffleString ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`AbstractTruffleString`](com/oracle/truffle/api/strings/AbstractTruffleString.md) > `MutableTruffleString` Represents a mutable variant of a [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). This class also accepts all operations of TruffleString. This class is not thread-safe and allows overwriting bytes in its internal byte array or native pointer via [`WriteByteNode`](com/oracle/truffle/api/strings/MutableTruffleString.WriteByteNode.md). The internal array or native pointer may also be modified externally, but the corresponding MutableTruffleString must be notified of this via [`notifyExternalMutation()`](com/oracle/truffle/api/strings/MutableTruffleString.md#notifyExternalMutation%28%29). MutableTruffleString is not a Truffle interop type, and must be converted to an immutable [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md) via [`AsTruffleStringNode`](com/oracle/truffle/api/strings/TruffleString.AsTruffleStringNode.md) before passing a language boundary. **See also** - [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md) ## Nested types - [`MutableTruffleString.AsManagedNode`](com/oracle/truffle/api/strings/MutableTruffleString.AsManagedNode.md) (abstract class): Node to get the given AbstractTruffleString as a managed MutableTruffleString, meaning that the resulting string's backing memory is not a native pointer. - [`MutableTruffleString.AsMutableTruffleStringNode`](com/oracle/truffle/api/strings/MutableTruffleString.AsMutableTruffleStringNode.md) (abstract class): Node to get a AbstractTruffleString as a MutableTruffleString. - [`MutableTruffleString.ConcatNode`](com/oracle/truffle/api/strings/MutableTruffleString.ConcatNode.md) (abstract class): Node to create a new MutableTruffleString by concatenating two strings. - [`MutableTruffleString.ForceEncodingNode`](com/oracle/truffle/api/strings/MutableTruffleString.ForceEncodingNode.md) (abstract class): Node to forcibly assign any encoding to a string. - [`MutableTruffleString.FromByteArrayNode`](com/oracle/truffle/api/strings/MutableTruffleString.FromByteArrayNode.md) (abstract class): Node to create a new MutableTruffleString from a byte array. - [`MutableTruffleString.FromNativePointerNode`](com/oracle/truffle/api/strings/MutableTruffleString.FromNativePointerNode.md) (abstract class): Node to create a new MutableTruffleString from an interop object representing a native pointer. - [`MutableTruffleString.SubstringByteIndexNode`](com/oracle/truffle/api/strings/MutableTruffleString.SubstringByteIndexNode.md) (abstract class): SubstringNode, but with byte indices. - [`MutableTruffleString.SubstringNode`](com/oracle/truffle/api/strings/MutableTruffleString.SubstringNode.md) (abstract class): Node to create a new mutable substring of a string. - [`MutableTruffleString.SwitchEncodingNode`](com/oracle/truffle/api/strings/MutableTruffleString.SwitchEncodingNode.md) (abstract class): Node to get a given string in a specific encoding. - [`MutableTruffleString.WriteByteNode`](com/oracle/truffle/api/strings/MutableTruffleString.WriteByteNode.md) (abstract class): Node to write a byte into a mutable string. ## Methods ### notifyExternalMutation() `public void notifyExternalMutation()`. Since 22.1. Notify this mutable string of an external modification of its internal content. This method must be called after every direct write (not via `WriteByteNode`) to the byte array or native pointer the string is using as internal storage. Exemplary usage scenario: Suppose a `MutableTruffleString` was created by wrapping a native pointer via `FromNativePointerNode`. If the native pointer is passed to a native function that may modify the pointer's contents, this method must be called afterwards, to ensure consistency. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.html#notifyExternalMutation()` ### fromByteArrayUncached(byte[], int, …) `public static MutableTruffleString fromByteArrayUncached(byte[] value, int byteOffset, int byteLength, TruffleString.Encoding encoding, boolean copy)`. Since 22.1. Shorthand for calling the uncached version of `FromByteArrayNode`. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.html#fromByteArrayUncached(byte[],int,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### fromNativePointerUncached(Object, int, …) `public static MutableTruffleString fromNativePointerUncached(Object pointerObject, int byteOffset, int byteLength, TruffleString.Encoding encoding, boolean copy)`. Since 22.1. Shorthand for calling the uncached version of `FromNativePointerNode`. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.html#fromNativePointerUncached(java.lang.Object,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### writeByteUncached(int, byte, TruffleString.Encoding) `public void writeByteUncached(int byteIndex, byte value, TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `WriteByteNode`. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.html#writeByteUncached(int,byte,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### concatUncached(AbstractTruffleString, TruffleString.Encoding) `public MutableTruffleString concatUncached(AbstractTruffleString b, TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `ConcatNode`. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.html#concatUncached(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### substringUncached(int, int, TruffleString.Encoding) `public MutableTruffleString substringUncached(int byteOffset, int byteLength, TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `SubstringNode`. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.html#substringUncached(int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### substringByteIndexUncached(int, int, TruffleString.Encoding) `public MutableTruffleString substringByteIndexUncached(int byteOffset, int byteLength, TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `SubstringByteIndexNode`. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.html#substringByteIndexUncached(int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ## Inherited members - From class [`AbstractTruffleString`](com/oracle/truffle/api/strings/AbstractTruffleString.md): [`asManagedMutableTruffleStringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#asManagedMutableTruffleStringUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`asManagedTruffleStringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#asManagedTruffleStringUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`asManagedTruffleStringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#asManagedTruffleStringUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding,boolean%29), [`asMutableTruffleStringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#asMutableTruffleStringUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`asTruffleStringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#asTruffleStringUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`byteIndexOfAnyByteUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#byteIndexOfAnyByteUncached%28int,int,byte[],com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`byteIndexOfCodePointUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#byteIndexOfCodePointUncached%28int,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`byteIndexOfStringSetUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#byteIndexOfStringSetUncached%28int,int,com.oracle.truffle.api.strings.TruffleString.StringSet%29), [`byteIndexOfStringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#byteIndexOfStringUncached%28com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`byteIndexOfStringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#byteIndexOfStringUncached%28com.oracle.truffle.api.strings.TruffleString.WithMask,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`byteIndexToCodePointIndexUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#byteIndexToCodePointIndexUncached%28int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`byteLength`](com/oracle/truffle/api/strings/AbstractTruffleString.md#byteLength%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`byteLengthOfCodePointUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#byteLengthOfCodePointUncached%28int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`byteLengthOfCodePointUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#byteLengthOfCodePointUncached%28int,com.oracle.truffle.api.strings.TruffleString.Encoding,com.oracle.truffle.api.strings.TruffleString.ErrorHandling%29), [`charIndexOfAnyCharUTF16Uncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#charIndexOfAnyCharUTF16Uncached%28int,int,char[]%29), [`codePointAtByteIndexUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#codePointAtByteIndexUncached%28int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`codePointAtByteIndexUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#codePointAtByteIndexUncached%28int,com.oracle.truffle.api.strings.TruffleString.Encoding,com.oracle.truffle.api.strings.TruffleString.ErrorHandling%29), [`codePointAtIndexUTF32Uncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#codePointAtIndexUTF32Uncached%28int%29), [`codePointAtIndexUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#codePointAtIndexUncached%28int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`codePointAtIndexUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#codePointAtIndexUncached%28int,com.oracle.truffle.api.strings.TruffleString.Encoding,com.oracle.truffle.api.strings.TruffleString.ErrorHandling%29), [`codePointIndexToByteIndexUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#codePointIndexToByteIndexUncached%28int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`codePointLengthUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#codePointLengthUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`codeRangeEqualsUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#codeRangeEqualsUncached%28com.oracle.truffle.api.strings.TruffleString.CodeRange%29), [`compareBytesUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#compareBytesUncached%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`compareCharsUTF16Uncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#compareCharsUTF16Uncached%28com.oracle.truffle.api.strings.AbstractTruffleString%29), [`compareIntsUTF32Uncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#compareIntsUTF32Uncached%28com.oracle.truffle.api.strings.AbstractTruffleString%29), [`concatUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#concatUncached%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean%29), [`copyToByteArrayUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#copyToByteArrayUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`copyToByteArrayUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#copyToByteArrayUncached%28int,byte[],int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`copyToNativeMemoryUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#copyToNativeMemoryUncached%28int,java.lang.Object,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`createBackwardCodePointIteratorUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#createBackwardCodePointIteratorUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`createCodePointIteratorUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#createCodePointIteratorUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`equals`](com/oracle/truffle/api/strings/AbstractTruffleString.md#equals%28java.lang.Object%29), [`equalsUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#equalsUncached%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`forceEncodingUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#forceEncodingUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`getByteCodeRangeUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#getByteCodeRangeUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`getCodeRangeImpreciseUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#getCodeRangeImpreciseUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`getCodeRangeUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#getCodeRangeUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`getInternalByteArrayUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#getInternalByteArrayUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`getInternalNativePointerUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#getInternalNativePointerUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`getStringCompactionLevelUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#getStringCompactionLevelUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`hashCode`](com/oracle/truffle/api/strings/AbstractTruffleString.md#hashCode%28%29), [`hashCodeUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#hashCodeUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`indexOfCodePointUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#indexOfCodePointUncached%28int,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`indexOfStringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#indexOfStringUncached%28com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`intIndexOfAnyIntUTF32Uncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#intIndexOfAnyIntUTF32Uncached%28int,int,int[]%29), [`isCompatibleToUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#isCompatibleToUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`isEmpty`](com/oracle/truffle/api/strings/AbstractTruffleString.md#isEmpty%28%29), [`isImmutable`](com/oracle/truffle/api/strings/AbstractTruffleString.md#isImmutable%28%29), [`isManaged`](com/oracle/truffle/api/strings/AbstractTruffleString.md#isManaged%28%29), [`isMutable`](com/oracle/truffle/api/strings/AbstractTruffleString.md#isMutable%28%29), [`isNative`](com/oracle/truffle/api/strings/AbstractTruffleString.md#isNative%28%29), [`isValidUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#isValidUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`lastByteIndexOfCodePointUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#lastByteIndexOfCodePointUncached%28int,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`lastByteIndexOfStringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#lastByteIndexOfStringUncached%28com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`lastByteIndexOfStringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#lastByteIndexOfStringUncached%28com.oracle.truffle.api.strings.TruffleString.WithMask,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`lastIndexOfCodePointUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#lastIndexOfCodePointUncached%28int,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`lastIndexOfStringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#lastIndexOfStringUncached%28com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`materializeSubstringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#materializeSubstringUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`materializeUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#materializeUncached%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`materializeUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#materializeUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`parseDoubleUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#parseDoubleUncached%28%29), [`parseIntUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#parseIntUncached%28%29), [`parseIntUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#parseIntUncached%28int%29), [`parseLongUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#parseLongUncached%28%29), [`parseLongUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#parseLongUncached%28int%29), [`readByteUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#readByteUncached%28int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`readCharUTF16Uncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#readCharUTF16Uncached%28int%29), [`regionEqualByteIndexUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#regionEqualByteIndexUncached%28int,com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`regionEqualByteIndexUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#regionEqualByteIndexUncached%28int,com.oracle.truffle.api.strings.TruffleString.WithMask,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`regionEqualsUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#regionEqualsUncached%28int,com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`repeatUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#repeatUncached%28int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`substringByteIndexUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#substringByteIndexUncached%28int,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean%29), [`substringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#substringUncached%28int,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean%29), [`switchEncodingUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#switchEncodingUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`switchEncodingUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#switchEncodingUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding,com.oracle.truffle.api.strings.TranscodingErrorHandler%29), [`toJavaStringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#toJavaStringUncached%28%29), [`toString`](com/oracle/truffle/api/strings/AbstractTruffleString.md#toString%28%29), [`toStringDebug`](com/oracle/truffle/api/strings/AbstractTruffleString.md#toStringDebug%28%29), [`toValidStringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#toValidStringUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ MutableTruffleString.AsManagedNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`MutableTruffleString`](com/oracle/truffle/api/strings/MutableTruffleString.md). ```java public abstract static class MutableTruffleString.AsManagedNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `AsManagedNode` Node to get the given [`AbstractTruffleString`](com/oracle/truffle/api/strings/AbstractTruffleString.md) as a managed [`MutableTruffleString`](com/oracle/truffle/api/strings/MutableTruffleString.md), meaning that the resulting string's backing memory is not a native pointer. See [`execute(AbstractTruffleString, TruffleString.Encoding)`](com/oracle/truffle/api/strings/MutableTruffleString.AsManagedNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, TruffleString.Encoding) `public abstract MutableTruffleString execute(AbstractTruffleString a, TruffleString.Encoding expectedEncoding)`. Since 22.1. If the given string is already a managed (i.e. not backed by a native pointer) string, return it. Otherwise, copy the string's native pointer content into a Java byte array and return a new string backed by the byte array. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.AsManagedNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static MutableTruffleString.AsManagedNode create()`. Since 22.1. Create a new `AsManagedNode`. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.AsManagedNode.html#create()` ### getUncached() `public static MutableTruffleString.AsManagedNode getUncached()`. Since 22.1. Get the uncached version of `AsManagedNode`. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.AsManagedNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ MutableTruffleString.AsMutableTruffleStringNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`MutableTruffleString`](com/oracle/truffle/api/strings/MutableTruffleString.md). ```java public abstract static class MutableTruffleString.AsMutableTruffleStringNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `AsMutableTruffleStringNode` Node to get a [`AbstractTruffleString`](com/oracle/truffle/api/strings/AbstractTruffleString.md) as a [`MutableTruffleString`](com/oracle/truffle/api/strings/MutableTruffleString.md). See [`execute(AbstractTruffleString, TruffleString.Encoding)`](com/oracle/truffle/api/strings/MutableTruffleString.AsMutableTruffleStringNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, TruffleString.Encoding) `public abstract MutableTruffleString execute(AbstractTruffleString a, TruffleString.Encoding expectedEncoding)`. Since 22.1. If the given string is already a `MutableTruffleString`, return it. If it is a `TruffleString`, create a new `MutableTruffleString`, copying the immutable string's contents. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.AsMutableTruffleStringNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static MutableTruffleString.AsMutableTruffleStringNode create()`. Since 22.1. Create a new `AsMutableTruffleStringNode`. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.AsMutableTruffleStringNode.html#create()` ### getUncached() `public static MutableTruffleString.AsMutableTruffleStringNode getUncached()`. Since 22.1. Get the uncached version of `AsMutableTruffleStringNode`. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.AsMutableTruffleStringNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ MutableTruffleString.ConcatNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`MutableTruffleString`](com/oracle/truffle/api/strings/MutableTruffleString.md). ```java public abstract static class MutableTruffleString.ConcatNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `ConcatNode` Node to create a new [`MutableTruffleString`](com/oracle/truffle/api/strings/MutableTruffleString.md) by concatenating two strings. ## Methods ### execute(AbstractTruffleString, AbstractTruffleString, TruffleString.Encoding) `public abstract MutableTruffleString execute(AbstractTruffleString a, AbstractTruffleString b, TruffleString.Encoding expectedEncoding)`. Since 22.1. Creates a new `MutableTruffleString` by concatenating two strings. The concatenation is performed eagerly since return value is mutable. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.ConcatNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static MutableTruffleString.ConcatNode create()`. Since 22.1. Create a new `ConcatNode`. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.ConcatNode.html#create()` ### getUncached() `public static MutableTruffleString.ConcatNode getUncached()`. Since 22.1. Get the uncached version of `ConcatNode`. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.ConcatNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ MutableTruffleString.ForceEncodingNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`MutableTruffleString`](com/oracle/truffle/api/strings/MutableTruffleString.md). ```java public abstract static class MutableTruffleString.ForceEncodingNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `ForceEncodingNode` Node to forcibly assign any encoding to a string. See [`execute(AbstractTruffleString, TruffleString.Encoding, TruffleString.Encoding)`](com/oracle/truffle/api/strings/MutableTruffleString.ForceEncodingNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, TruffleString.Encoding, TruffleString.Encoding) `public abstract MutableTruffleString execute(AbstractTruffleString a, TruffleString.Encoding expectedEncoding, TruffleString.Encoding targetEncoding)`. Since 22.1. Returns a version of string `a` assigned to the given encoding. If the string is already in the given encoding, it is returned. Otherwise, a new string containing the same (copied) bytes but assigned to the new encoding is returned. **This node does not transcode the string's contents in any way, it is the "encoding-equivalent" to a C-style reinterpret-cast.**. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.ForceEncodingNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static MutableTruffleString.ForceEncodingNode create()`. Since 22.1. Create a new `MutableTruffleString.ForceEncodingNode`. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.ForceEncodingNode.html#create()` ### getUncached() `public static MutableTruffleString.ForceEncodingNode getUncached()`. Since 22.1. Get the uncached version of `MutableTruffleString.ForceEncodingNode`. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.ForceEncodingNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ MutableTruffleString.FromByteArrayNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`MutableTruffleString`](com/oracle/truffle/api/strings/MutableTruffleString.md). ```java public abstract static class MutableTruffleString.FromByteArrayNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `FromByteArrayNode` Node to create a new [`MutableTruffleString`](com/oracle/truffle/api/strings/MutableTruffleString.md) from a byte array. See [`execute(byte[], int, int, TruffleString.Encoding, boolean)`](com/oracle/truffle/api/strings/MutableTruffleString.FromByteArrayNode.md#execute%28byte[],int,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean%29) for details. ## Methods ### execute(byte[], int, …) `public abstract MutableTruffleString execute(byte[] value, int byteOffset, int byteLength, TruffleString.Encoding encoding, boolean copy)`. Since 22.1. Creates a new `MutableTruffleString` from a byte array. The array content is assumed to be encoded in the given encoding already. This operation allows non-copying string creation, i.e. the array parameter can be used directly by passing `copy = false`. If the array is modified after non-copying string creation, the string must be notified of this via `MutableTruffleString.notifyExternalMutation()` . Cite: `com/oracle/truffle/api/strings/MutableTruffleString.FromByteArrayNode.html#execute(byte[],int,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### create() `public static MutableTruffleString.FromByteArrayNode create()`. Since 22.1. Create a new `FromByteArrayNode`. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.FromByteArrayNode.html#create()` ### getUncached() `public static MutableTruffleString.FromByteArrayNode getUncached()`. Since 22.1. Get the uncached version of `FromByteArrayNode`. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.FromByteArrayNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ MutableTruffleString.FromNativePointerNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`MutableTruffleString`](com/oracle/truffle/api/strings/MutableTruffleString.md). ```java public abstract static class MutableTruffleString.FromNativePointerNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `FromNativePointerNode` Node to create a new [`MutableTruffleString`](com/oracle/truffle/api/strings/MutableTruffleString.md) from an interop object representing a native pointer. See [`execute(Object, int, int, TruffleString.Encoding, boolean)`](com/oracle/truffle/api/strings/MutableTruffleString.FromNativePointerNode.md#execute%28java.lang.Object,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean%29) for details. ## Methods ### execute(Object, int, …) `public abstract MutableTruffleString execute(Object pointerObject, int byteOffset, int byteLength, TruffleString.Encoding encoding, boolean copy)`. Since 22.1. Create a new `MutableTruffleString` from an interop object representing a native pointer (`isPointer(pointerObject)` must return `true`). The pointer is immediately unboxed with (`asPointer(pointerObject)`) and saved until the end of the string's lifetime, i.e. `MutableTruffleString` assumes that the pointer address does not change. The pointer's content is assumed to be encoded in the given encoding already. If `copy` is `false`, the native pointer is used directly as the new string's backing storage. Caution: If the pointer's content is modified after string creation, the string must be notified of this via `MutableTruffleString.notifyExternalMutation()`. **WARNING:** `MutableTruffleString` cannot reason about the lifetime of the native pointer, so it is up to the user to **make sure that the native pointer is valid to access and not freed as long the `pointerObject` is alive** (if `copy` is `false`). To help with this the MutableTruffleString keeps a reference to the given `pointerObject`, so the `pointerObject` is kept alive at least as long as the MutableTruffleString is used. In order to be able to use the string past the native pointer's life time, convert it to a managed string via `MutableTruffleString.AsManagedNode` **before the native pointer is freed**. Since GraalVM version 25.1, the native pointer may also be passed as a boxed long value in place of `pointerObject`. Note that in this case, the resulting `MutableTruffleString` cannot keep a reference an associated object for life-time tracking. The user is responsible for making sure the native buffer is not freed as long as the `MutableTruffleString` object is alive. If `copy` is `true`, the pointer's contents are copied to a Java byte array, and the pointer can be freed safely after the operation completes. This operation requires native access permissions (`TruffleLanguage.Env#isNativeAccessAllowed()`). Cite: `com/oracle/truffle/api/strings/MutableTruffleString.FromNativePointerNode.html#execute(java.lang.Object,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### create() `public static MutableTruffleString.FromNativePointerNode create()`. Since 22.1. Create a new `FromNativePointerNode`. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.FromNativePointerNode.html#create()` ### getUncached() `public static MutableTruffleString.FromNativePointerNode getUncached()`. Since 22.1. Get the uncached version of `FromNativePointerNode`. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.FromNativePointerNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ MutableTruffleString.SubstringByteIndexNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`MutableTruffleString`](com/oracle/truffle/api/strings/MutableTruffleString.md). ```java public abstract static class MutableTruffleString.SubstringByteIndexNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `SubstringByteIndexNode` [`SubstringNode`](com/oracle/truffle/api/strings/MutableTruffleString.SubstringNode.md), but with byte indices. ## Methods ### execute(AbstractTruffleString, int, …) `public abstract MutableTruffleString execute(AbstractTruffleString a, int byteOffset, int byteLength, TruffleString.Encoding expectedEncoding)`. Since 22.1. `SubstringNode`, but with byte indices. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.SubstringByteIndexNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static MutableTruffleString.SubstringByteIndexNode create()`. Since 22.1. Create a new `SubstringByteIndexNode`. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.SubstringByteIndexNode.html#create()` ### getUncached() `public static MutableTruffleString.SubstringByteIndexNode getUncached()`. Since 22.1. Get the uncached version of `SubstringByteIndexNode`. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.SubstringByteIndexNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ MutableTruffleString.SubstringNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`MutableTruffleString`](com/oracle/truffle/api/strings/MutableTruffleString.md). ```java public abstract static class MutableTruffleString.SubstringNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `SubstringNode` Node to create a new mutable substring of a string. See [`execute(AbstractTruffleString, int, int, TruffleString.Encoding)`](com/oracle/truffle/api/strings/MutableTruffleString.SubstringNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, int, …) `public abstract MutableTruffleString execute(AbstractTruffleString a, int fromIndex, int length, TruffleString.Encoding expectedEncoding)`. Since 22.1. Create a new mutable substring of `a`, starting from `fromIndex`, with length `length`. The substring is performed eagerly since return value is mutable. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.SubstringNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static MutableTruffleString.SubstringNode create()`. Since 22.1. Create a new `SubstringNode`. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.SubstringNode.html#create()` ### getUncached() `public static MutableTruffleString.SubstringNode getUncached()`. Since 22.1. Get the uncached version of `SubstringNode`. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.SubstringNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ MutableTruffleString.SwitchEncodingNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`MutableTruffleString`](com/oracle/truffle/api/strings/MutableTruffleString.md). ```java public abstract static class MutableTruffleString.SwitchEncodingNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `SwitchEncodingNode` Node to get a given string in a specific encoding. See [`execute(AbstractTruffleString, TruffleString.Encoding, TranscodingErrorHandler)`](com/oracle/truffle/api/strings/MutableTruffleString.SwitchEncodingNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding,com.oracle.truffle.api.strings.TranscodingErrorHandler%29) for details. ## Methods ### execute(AbstractTruffleString, TruffleString.Encoding) `public final MutableTruffleString execute(AbstractTruffleString a, TruffleString.Encoding encoding)`. Since 22.1. Returns a version of string `a` that is encoded in the given encoding, which may be the string itself or a converted version. If no lossless conversion is possible, the string is converted on a best-effort basis; no exception is thrown and characters which cannot be mapped in the target encoding are replaced by `'�'` (for UTF-\*) or `'?'`. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.SwitchEncodingNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### execute(AbstractTruffleString, TruffleString.Encoding, TranscodingErrorHandler) `public abstract MutableTruffleString execute(AbstractTruffleString a, TruffleString.Encoding encoding, TranscodingErrorHandler errorHandler)`. Since 23.1. Returns a version of string `a` that is encoded in the given encoding, which may be the string itself or a converted version. Transcoding errors are handled with `errorHandler`. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.SwitchEncodingNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding,com.oracle.truffle.api.strings.TranscodingErrorHandler)` ### create() `public static MutableTruffleString.SwitchEncodingNode create()`. Since 22.1. Create a new `MutableTruffleString.SwitchEncodingNode`. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.SwitchEncodingNode.html#create()` ### getUncached() `public static MutableTruffleString.SwitchEncodingNode getUncached()`. Since 22.1. Get the uncached version of `MutableTruffleString.SwitchEncodingNode`. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.SwitchEncodingNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ MutableTruffleString.WriteByteNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`MutableTruffleString`](com/oracle/truffle/api/strings/MutableTruffleString.md). ```java public abstract static class MutableTruffleString.WriteByteNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `WriteByteNode` Node to write a byte into a mutable string. ## Methods ### execute(MutableTruffleString, int, …) `public abstract void execute(MutableTruffleString a, int byteIndex, byte value, TruffleString.Encoding expectedEncoding)`. Since 22.1. Writes a byte into the given mutable string. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.WriteByteNode.html#execute(com.oracle.truffle.api.strings.MutableTruffleString,int,byte,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static MutableTruffleString.WriteByteNode create()`. Since 22.1. Create a new `WriteByteNode`. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.WriteByteNode.html#create()` ### getUncached() `public static MutableTruffleString.WriteByteNode getUncached()`. Since 22.1. Get the uncached version of `WriteByteNode`. Cite: `com/oracle/truffle/api/strings/MutableTruffleString.WriteByteNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ MutableTruffleStringFactory [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). ```java public final class MutableTruffleStringFactory ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `MutableTruffleStringFactory` ## Constructors ### MutableTruffleStringFactory() `public MutableTruffleStringFactory()`. Declared by the compiler. Creates a new MutableTruffleStringFactory instance. Cite: `com/oracle/truffle/api/strings/MutableTruffleStringFactory.html#()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◇ NativeAllocator [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 23.0. ```java @FunctionalInterface public interface NativeAllocator ``` An allocation function for native buffers. ## Methods ### allocate(int) `Object allocate(int byteSize)`. Since 23.0. Allocates a new native buffer of `byteSize` bytes. The return value must be a Truffle object as expected by `TruffleString.FromNativePointerNode`. Cite: `com/oracle/truffle/api/strings/NativeAllocator.html#allocate(int)` # ◇ TranscodingErrorHandler [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Interface in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 23.1. ```java @FunctionalInterface public interface TranscodingErrorHandler ``` An error handler for transcoding operations such as [`TruffleString.SwitchEncodingNode`](com/oracle/truffle/api/strings/TruffleString.SwitchEncodingNode.md). ## Nested types - [`TranscodingErrorHandler.ReplacementString`](com/oracle/truffle/api/strings/TranscodingErrorHandler.ReplacementString.md) (record): Result type of apply(AbstractTruffleString, int, int, TruffleString.Encoding, TruffleString.Encoding). ## Fields ### DEFAULT `TranscodingErrorHandler DEFAULT`. Since 23.1. The default transcoding error handler. In UTF encodings, it replaces invalid codepoints with `0xfffd`, in all other encodings it uses `'?'` instead. Exceptions: in UTF-16 and UTF-32, it keeps [`UTF-16 surrogate values`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Character.html#isSurrogate%28char%29). Cite: `com/oracle/truffle/api/strings/TranscodingErrorHandler.html#DEFAULT` ### DEFAULT_KEEP_SURROGATES_IN_UTF8 `TranscodingErrorHandler DEFAULT_KEEP_SURROGATES_IN_UTF8`. Since 23.1. Same as `DEFAULT`, but also keeps [`UTF-16 surrogate values`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Character.html#isSurrogate%28char%29) in UTF-8. Cite: `com/oracle/truffle/api/strings/TranscodingErrorHandler.html#DEFAULT_KEEP_SURROGATES_IN_UTF8` ## Methods ### apply(AbstractTruffleString, int, …) `TranscodingErrorHandler.ReplacementString apply(AbstractTruffleString sourceString, int byteIndex, int estimatedByteLength, TruffleString.Encoding sourceEncoding, TruffleString.Encoding targetEncoding)`. Since 23.1. Transcoding error handler implementation. This method is called once for every byte region that could not be transcoded from `sourceEncoding` to `targetEncoding`. Parameters: `sourceString` `AbstractTruffleString`: the string currently being transcoded. `byteIndex` `int`: starting index of region that could not be transcoded. `estimatedByteLength` `int`: estimated byte length of erroneous region. `sourceEncoding` `TruffleString.Encoding`: the source string's encoding. `targetEncoding` `TruffleString.Encoding`: the target encoding. Returns `TranscodingErrorHandler.ReplacementString`: a string to use instead of the invalid region. Cite: `com/oracle/truffle/api/strings/TranscodingErrorHandler.html#apply(com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding,com.oracle.truffle.api.strings.TruffleString.Encoding)` # ▤ TranscodingErrorHandler.ReplacementString [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Record in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 23.1. Nested in [`TranscodingErrorHandler`](com/oracle/truffle/api/strings/TranscodingErrorHandler.md). ```java public record TranscodingErrorHandler.ReplacementString(TruffleString replacement, int byteLength) ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Record`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Record.html) > `ReplacementString` Result type of [`apply(AbstractTruffleString, int, int, TruffleString.Encoding, TruffleString.Encoding)`](com/oracle/truffle/api/strings/TranscodingErrorHandler.md#apply%28com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding,com.oracle.truffle.api.strings.TruffleString.Encoding%29). **Record components** - `replacement` [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md): the string to use as replacement for the erroneous region in the source string. - `byteLength` `int`: the byte length of the region to replace. If this value is negative, let the transcoder determine the region length instead. ## Constructors ### ReplacementString(TruffleString, int) `public ReplacementString(TruffleString replacement, int byteLength)`. Declared by the compiler. Creates a new ReplacementString instance. Parameters: `replacement` `TruffleString`: the string to use as replacement for the erroneous region in the source string. `byteLength` `int`: the byte length of the region to replace. If this value is negative, let the transcoder determine the region length instead. Cite: `com/oracle/truffle/api/strings/TranscodingErrorHandler.ReplacementString.html#(com.oracle.truffle.api.strings.TruffleString,int)` ## Methods ### toString() `public final String toString()`. Returns a string containing the record class name and its component names and values. Returns `String`: Returns a string containing the record class name and its component names and values. Overrides `toString()`. Cite: `com/oracle/truffle/api/strings/TranscodingErrorHandler.ReplacementString.html#toString()` ### hashCode() `public final int hashCode()`. Returns a hash code computed from the record components. Returns `int`: Returns a hash code computed from the record components. Overrides `hashCode()`. Cite: `com/oracle/truffle/api/strings/TranscodingErrorHandler.ReplacementString.html#hashCode()` ### equals(Object) `public final boolean equals(Object o)`. Returns whether the other object is a record of the same class with equal components. Parameters: `o` `Object`: The object to compare with this record. Returns `boolean`: Returns whether the other object is a record of the same class with equal components. Overrides `equals(java.lang.Object)`. Cite: `com/oracle/truffle/api/strings/TranscodingErrorHandler.ReplacementString.html#equals(java.lang.Object)` ### replacement() `public TruffleString replacement()`. the string to use as replacement for the erroneous region in the source string. Returns `TruffleString`: the string to use as replacement for the erroneous region in the source string. Cite: `com/oracle/truffle/api/strings/TranscodingErrorHandler.ReplacementString.html#replacement()` ### byteLength() `public int byteLength()`. the byte length of the region to replace. If this value is negative, let the transcoder determine the region length instead. Returns `int`: the byte length of the region to replace. If this value is negative, let the transcoder determine the region length instead. Cite: `com/oracle/truffle/api/strings/TranscodingErrorHandler.ReplacementString.html#byteLength()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. ```java public final class TruffleString extends AbstractTruffleString ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`AbstractTruffleString`](com/oracle/truffle/api/strings/AbstractTruffleString.md) > `TruffleString` Represents a primitive String type, which can be reused across languages. Language implementers are encouraged to use Truffle Strings as their language's string type for easier interoperability and better performance. Truffle strings can be encoded in a number of [`encodings`](com/oracle/truffle/api/strings/TruffleString.Encoding.md). A [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md) object can cache multiple representations (in multiple encodings) of the same string in the string object itself. A single [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md) instance can also represent the same string in multiple encodings, if the string's content would be equal in all such encodings (e.g. a string containing only ASCII characters can be viewed as being encoded in almost any encoding, since the encoded bytes would be equal). To facilitate this, all methods have an `expectedEncoding` parameter to indicate which encoding a given string should be viewed in. [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md) instances can be created via one of the following nodes, or via [`TruffleStringBuilder`](com/oracle/truffle/api/strings/TruffleStringBuilder.md). - [`FromByteArrayNode`](com/oracle/truffle/api/strings/TruffleString.FromByteArrayNode.md) - [`FromCharArrayUTF16Node`](com/oracle/truffle/api/strings/TruffleString.FromCharArrayUTF16Node.md) - [`FromJavaStringNode`](com/oracle/truffle/api/strings/TruffleString.FromJavaStringNode.md) - [`FromIntArrayUTF32Node`](com/oracle/truffle/api/strings/TruffleString.FromIntArrayUTF32Node.md) - [`FromNativePointerNode`](com/oracle/truffle/api/strings/TruffleString.FromNativePointerNode.md) - [`FromCodePointNode`](com/oracle/truffle/api/strings/TruffleString.FromCodePointNode.md) - [`FromLongNode`](com/oracle/truffle/api/strings/TruffleString.FromLongNode.md) For iteration use [`TruffleStringIterator`](com/oracle/truffle/api/strings/TruffleStringIterator.md). There is a version of [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md) that is also mutable. See [`MutableTruffleString`](com/oracle/truffle/api/strings/MutableTruffleString.md) for details. Please see the [tutorial](https://github.com/oracle/graal/tree/master/truffle/docs/TruffleStrings.md) for further usage instructions. ## Nested types - [`TruffleString.AsManagedNode`](com/oracle/truffle/api/strings/TruffleString.AsManagedNode.md) (abstract class): Node to get the given AbstractTruffleString as a managed TruffleString, meaning that the resulting string's backing memory is not a native pointer. - [`TruffleString.AsNativeNode`](com/oracle/truffle/api/strings/TruffleString.AsNativeNode.md) (abstract class): Node to convert a potentially managed TruffleString to a native string. - [`TruffleString.AsTruffleStringNode`](com/oracle/truffle/api/strings/TruffleString.AsTruffleStringNode.md) (abstract class): Node to get the given AbstractTruffleString as a TruffleString. - [`TruffleString.ByteIndexOfAnyByteNode`](com/oracle/truffle/api/strings/TruffleString.ByteIndexOfAnyByteNode.md) (abstract class): Node to find the index of the first occurrence of any byte from a given array. - [`TruffleString.ByteIndexOfCodePointNode`](com/oracle/truffle/api/strings/TruffleString.ByteIndexOfCodePointNode.md) (abstract class): IndexOfCodePointNode, but with byte indices. - [`TruffleString.ByteIndexOfCodePointSetNode`](com/oracle/truffle/api/strings/TruffleString.ByteIndexOfCodePointSetNode.md) (abstract class): Node to find the byte index of the first occurrence of a codepoint present in a given codepoint set. - [`TruffleString.ByteIndexOfStringNode`](com/oracle/truffle/api/strings/TruffleString.ByteIndexOfStringNode.md) (abstract class): IndexOfStringNode, but with byte indices. - [`TruffleString.ByteIndexOfStringSetNode`](com/oracle/truffle/api/strings/TruffleString.ByteIndexOfStringSetNode.md) (abstract class): Node to find the byte index of the first occurrence of any string contained in a given string set. - [`TruffleString.ByteIndexToCodePointIndexNode`](com/oracle/truffle/api/strings/TruffleString.ByteIndexToCodePointIndexNode.md) (abstract class): Node to convert a given byte index to a codepoint index. - [`TruffleString.ByteLengthOfCodePointNode`](com/oracle/truffle/api/strings/TruffleString.ByteLengthOfCodePointNode.md) (abstract class): Node to get the number of bytes occupied by the codepoint starting at a given byte index. - [`TruffleString.CharIndexOfAnyCharUTF16Node`](com/oracle/truffle/api/strings/TruffleString.CharIndexOfAnyCharUTF16Node.md) (abstract class): Node to find the index of the first occurrence of any char from a given array. - [`TruffleString.CodePointAtByteIndexNode`](com/oracle/truffle/api/strings/TruffleString.CodePointAtByteIndexNode.md) (abstract class): Node to read a codepoint at a given byte index. - [`TruffleString.CodePointAtIndexNode`](com/oracle/truffle/api/strings/TruffleString.CodePointAtIndexNode.md) (abstract class): Node to read a codepoint at a given codepoint index. - [`TruffleString.CodePointAtIndexUTF32Node`](com/oracle/truffle/api/strings/TruffleString.CodePointAtIndexUTF32Node.md) (abstract class): Node to read a codepoint at a given codepoint index from a UTF-32 string. - [`TruffleString.CodePointIndexToByteIndexNode`](com/oracle/truffle/api/strings/TruffleString.CodePointIndexToByteIndexNode.md) (abstract class): Node to convert a given codepoint index to a byte index. - [`TruffleString.CodePointLengthNode`](com/oracle/truffle/api/strings/TruffleString.CodePointLengthNode.md) (abstract class): Node to get the number of codepoints in a string. - [`TruffleString.CodePointSet`](com/oracle/truffle/api/strings/TruffleString.CodePointSet.md) (class): A set of codepoints in a given encoding. - [`TruffleString.CodeRange`](com/oracle/truffle/api/strings/TruffleString.CodeRange.md) (enum class): Provides information about a string's content. - [`TruffleString.CodeRangeEqualsNode`](com/oracle/truffle/api/strings/TruffleString.CodeRangeEqualsNode.md) (abstract class): Node to check if a string's code range is equal to the given CodeRange. - [`TruffleString.CompactionLevel`](com/oracle/truffle/api/strings/TruffleString.CompactionLevel.md) (enum class): Represents a string's compaction level, i.e. - [`TruffleString.CompareBytesNode`](com/oracle/truffle/api/strings/TruffleString.CompareBytesNode.md) (abstract class): Node to compare two strings byte-by-byte. - [`TruffleString.CompareCharsUTF16Node`](com/oracle/truffle/api/strings/TruffleString.CompareCharsUTF16Node.md) (abstract class): Node to compare two UTF-16 strings. - [`TruffleString.CompareIntsUTF32Node`](com/oracle/truffle/api/strings/TruffleString.CompareIntsUTF32Node.md) (abstract class): Node to compare two UTF-32 strings. - [`TruffleString.ConcatNode`](com/oracle/truffle/api/strings/TruffleString.ConcatNode.md) (abstract class): Node to concatenate two strings. - [`TruffleString.CopyToByteArrayNode`](com/oracle/truffle/api/strings/TruffleString.CopyToByteArrayNode.md) (abstract class): Node to copy a region of a string into a byte array. - [`TruffleString.CopyToNativeMemoryNode`](com/oracle/truffle/api/strings/TruffleString.CopyToNativeMemoryNode.md) (abstract class): Node to copy a region of a string into native memory. - [`TruffleString.CreateBackwardCodePointIteratorNode`](com/oracle/truffle/api/strings/TruffleString.CreateBackwardCodePointIteratorNode.md) (abstract class): Node to create a TruffleStringIterator. - [`TruffleString.CreateCodePointIteratorNode`](com/oracle/truffle/api/strings/TruffleString.CreateCodePointIteratorNode.md) (abstract class): Node to create a TruffleStringIterator. - [`TruffleString.Encoding`](com/oracle/truffle/api/strings/TruffleString.Encoding.md) (enum class): The list of encodings supported by TruffleString. - [`TruffleString.EqualNode`](com/oracle/truffle/api/strings/TruffleString.EqualNode.md) (abstract class): Node to check two strings for equality. - [`TruffleString.ErrorHandling`](com/oracle/truffle/api/strings/TruffleString.ErrorHandling.md) (enum class): Error handling instructions for operations that return integer values, such as indices or code points. - [`TruffleString.ForceEncodingNode`](com/oracle/truffle/api/strings/TruffleString.ForceEncodingNode.md) (abstract class): Node to forcibly assign any encoding to a string. - [`TruffleString.FromByteArrayNode`](com/oracle/truffle/api/strings/TruffleString.FromByteArrayNode.md) (abstract class): Node to create a new TruffleString from a byte array. - [`TruffleString.FromByteArrayWithCompactionUTF32Node`](com/oracle/truffle/api/strings/TruffleString.FromByteArrayWithCompactionUTF32Node.md) (abstract class): Node to create a new TruffleString from a byte array. - [`TruffleString.FromCharArrayUTF16Node`](com/oracle/truffle/api/strings/TruffleString.FromCharArrayUTF16Node.md) (abstract class): Node to create a new UTF-16 TruffleString from a char array. - [`TruffleString.FromCodePointNode`](com/oracle/truffle/api/strings/TruffleString.FromCodePointNode.md) (abstract class): Node to create a new TruffleString from a single codepoint. - [`TruffleString.FromIntArrayUTF32Node`](com/oracle/truffle/api/strings/TruffleString.FromIntArrayUTF32Node.md) (abstract class): Node to create a new UTF-32 TruffleString from an int-array. - [`TruffleString.FromJavaStringNode`](com/oracle/truffle/api/strings/TruffleString.FromJavaStringNode.md) (abstract class): Node to create a new TruffleString from a Java string. - [`TruffleString.FromLongNode`](com/oracle/truffle/api/strings/TruffleString.FromLongNode.md) (abstract class): Node to create a new TruffleString from a long value. - [`TruffleString.FromNativePointerNode`](com/oracle/truffle/api/strings/TruffleString.FromNativePointerNode.md) (abstract class): Node to create a new TruffleString from an interop object representing a native pointer. - [`TruffleString.FromNativePointerWithCompactionUTF32Node`](com/oracle/truffle/api/strings/TruffleString.FromNativePointerWithCompactionUTF32Node.md) (abstract class): Node to create a new TruffleString from an interop object representing a native pointer. - [`TruffleString.FromZeroTerminatedNativePointerNode`](com/oracle/truffle/api/strings/TruffleString.FromZeroTerminatedNativePointerNode.md) (abstract class): Equivalent to FromNativePointerNode for zero-terminated buffers, i.e. - [`TruffleString.GetByteCodeRangeNode`](com/oracle/truffle/api/strings/TruffleString.GetByteCodeRangeNode.md) (abstract class): Node to get a string's "byte-based" CodeRange. - [`TruffleString.GetCodeRangeImpreciseNode`](com/oracle/truffle/api/strings/TruffleString.GetCodeRangeImpreciseNode.md) (abstract class): Node to get a string's possibly imprecise CodeRange. - [`TruffleString.GetCodeRangeNode`](com/oracle/truffle/api/strings/TruffleString.GetCodeRangeNode.md) (abstract class): Node to get a string's precise CodeRange. - [`TruffleString.GetInternalByteArrayNode`](com/oracle/truffle/api/strings/TruffleString.GetInternalByteArrayNode.md) (abstract class): Node to get a string's internal byte array. - [`TruffleString.GetInternalNativePointerNode`](com/oracle/truffle/api/strings/TruffleString.GetInternalNativePointerNode.md) (abstract class): Node to get a native string's pointer object or raw pointer. - [`TruffleString.GetStringCompactionLevelNode`](com/oracle/truffle/api/strings/TruffleString.GetStringCompactionLevelNode.md) (abstract class): Node to get a string's CompactionLevel. - [`TruffleString.HashCodeNode`](com/oracle/truffle/api/strings/TruffleString.HashCodeNode.md) (abstract class): Node to get a string's hash code. - [`TruffleString.IllegalByteArrayLengthException`](com/oracle/truffle/api/strings/TruffleString.IllegalByteArrayLengthException.md) (exception): This exception is thrown when any operation tries to create a UTF-16 or UTF-32 string with an invalid byte length (not a multiple of 2/4 bytes). - [`TruffleString.IndexOfCodePointNode`](com/oracle/truffle/api/strings/TruffleString.IndexOfCodePointNode.md) (abstract class): Node to find the index of the first occurrence of a given code point. - [`TruffleString.IndexOfStringNode`](com/oracle/truffle/api/strings/TruffleString.IndexOfStringNode.md) (abstract class): Node to find the index of the first occurrence of a given string. - [`TruffleString.IntIndexOfAnyIntUTF32Node`](com/oracle/truffle/api/strings/TruffleString.IntIndexOfAnyIntUTF32Node.md) (abstract class): Node to find the index of the first occurrence of any int from a given array. - [`TruffleString.IsValidNode`](com/oracle/truffle/api/strings/TruffleString.IsValidNode.md) (abstract class): Node to check if a string is encoded correctly. - [`TruffleString.LastByteIndexOfCodePointNode`](com/oracle/truffle/api/strings/TruffleString.LastByteIndexOfCodePointNode.md) (abstract class): LastIndexOfCodePointNode, but with byte indices. - [`TruffleString.LastByteIndexOfStringNode`](com/oracle/truffle/api/strings/TruffleString.LastByteIndexOfStringNode.md) (abstract class): LastIndexOfStringNode, but with byte indices. - [`TruffleString.LastIndexOfCodePointNode`](com/oracle/truffle/api/strings/TruffleString.LastIndexOfCodePointNode.md) (abstract class): Node to find the codepoint index of the last occurrence of a given code point. - [`TruffleString.LastIndexOfStringNode`](com/oracle/truffle/api/strings/TruffleString.LastIndexOfStringNode.md) (abstract class): Node to find the index of the last occurrence of a given string. - [`TruffleString.MaterializeNode`](com/oracle/truffle/api/strings/TruffleString.MaterializeNode.md) (abstract class): Node to force materialization of any lazy internal data. - [`TruffleString.MaterializeSubstringNode`](com/oracle/truffle/api/strings/TruffleString.MaterializeSubstringNode.md) (abstract class): Extended version of MaterializeNode that also materializes substrings/string views created via e.g. - [`TruffleString.NumberFormatException`](com/oracle/truffle/api/strings/TruffleString.NumberFormatException.md) (exception): This exception may be thrown by ParseIntNode, ParseLongNode or ParseDoubleNode to indicate that the given string cannot be parsed as an integer, long or double value. - [`TruffleString.ParseDoubleNode`](com/oracle/truffle/api/strings/TruffleString.ParseDoubleNode.md) (abstract class): Node to parse a given string as a double value. - [`TruffleString.ParseIntNode`](com/oracle/truffle/api/strings/TruffleString.ParseIntNode.md) (abstract class): Node to parse a given string as an int value. - [`TruffleString.ParseLongNode`](com/oracle/truffle/api/strings/TruffleString.ParseLongNode.md) (abstract class): Node to parse a given string as a long value. - [`TruffleString.ReadByteNode`](com/oracle/truffle/api/strings/TruffleString.ReadByteNode.md) (abstract class): Node to read a single byte from a string. - [`TruffleString.ReadCharUTF16Node`](com/oracle/truffle/api/strings/TruffleString.ReadCharUTF16Node.md) (abstract class): Node to read a single char from a UTF-16 string. - [`TruffleString.RegionEqualByteIndexNode`](com/oracle/truffle/api/strings/TruffleString.RegionEqualByteIndexNode.md) (abstract class): Node to check for a region match, byte-by-byte. - [`TruffleString.RegionEqualNode`](com/oracle/truffle/api/strings/TruffleString.RegionEqualNode.md) (abstract class): Node to check codepoint equality of two string regions. - [`TruffleString.RepeatNode`](com/oracle/truffle/api/strings/TruffleString.RepeatNode.md) (abstract class): Node to repeat a given string N times. - [`TruffleString.StringSet`](com/oracle/truffle/api/strings/TruffleString.StringSet.md) (class): A set of strings in a given encoding. - [`TruffleString.SubstringByteIndexNode`](com/oracle/truffle/api/strings/TruffleString.SubstringByteIndexNode.md) (abstract class): SubstringNode, but with byte indices. - [`TruffleString.SubstringNode`](com/oracle/truffle/api/strings/TruffleString.SubstringNode.md) (abstract class): Node to create a substring of a given string. - [`TruffleString.SwitchEncodingNode`](com/oracle/truffle/api/strings/TruffleString.SwitchEncodingNode.md) (abstract class): Node to get a given string in a specific encoding. - [`TruffleString.ToJavaStringNode`](com/oracle/truffle/api/strings/TruffleString.ToJavaStringNode.md) (abstract class): Node to get a java.lang.String representation of a TruffleString. - [`TruffleString.ToValidStringNode`](com/oracle/truffle/api/strings/TruffleString.ToValidStringNode.md) (abstract class): Node to replace all invalid bytes in a given string, such that the resulting string is valid. - [`TruffleString.WithMask`](com/oracle/truffle/api/strings/TruffleString.WithMask.md) (class): Extended parameter type for the operations ByteIndexOfStringNode, LastByteIndexOfStringNode and RegionEqualByteIndexNode. ## Methods ### fromCodePointUncached(int, TruffleString.Encoding) `public static TruffleString fromCodePointUncached(int codepoint, TruffleString.Encoding encoding)`. Since 22.1. Shorthand for calling the uncached version of `FromCodePointNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.html#fromCodePointUncached(int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### fromCodePointUncached(int, TruffleString.Encoding, boolean) `public static TruffleString fromCodePointUncached(int codepoint, TruffleString.Encoding encoding, boolean allowUTF16Surrogates)`. Since 22.2. Shorthand for calling the uncached version of `FromCodePointNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.html#fromCodePointUncached(int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### fromLongUncached(long, TruffleString.Encoding, boolean) `public static TruffleString fromLongUncached(long value, TruffleString.Encoding encoding, boolean lazy)`. Since 22.1. Shorthand for calling the uncached version of `FromLongNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.html#fromLongUncached(long,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### fromByteArrayUncached(byte[], TruffleString.Encoding) `public static TruffleString fromByteArrayUncached(byte[] value, TruffleString.Encoding encoding)`. Since 22.1. Shorthand for calling the uncached version of `FromByteArrayNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.html#fromByteArrayUncached(byte[],com.oracle.truffle.api.strings.TruffleString.Encoding)` ### fromByteArrayUncached(byte[], TruffleString.Encoding, boolean) `public static TruffleString fromByteArrayUncached(byte[] value, TruffleString.Encoding encoding, boolean copy)`. Since 22.1. Shorthand for calling the uncached version of `FromByteArrayNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.html#fromByteArrayUncached(byte[],com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### fromByteArrayUncached(byte[], int, …) `public static TruffleString fromByteArrayUncached(byte[] value, int byteOffset, int byteLength, TruffleString.Encoding encoding, boolean copy)`. Since 22.1. Shorthand for calling the uncached version of `FromByteArrayNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.html#fromByteArrayUncached(byte[],int,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### fromCharArrayUTF16Uncached(char[]) `public static TruffleString fromCharArrayUTF16Uncached(char[] value)`. Since 22.1. Shorthand for calling the uncached version of `FromCharArrayUTF16Node`. Cite: `com/oracle/truffle/api/strings/TruffleString.html#fromCharArrayUTF16Uncached(char[])` ### fromCharArrayUTF16Uncached(char[], int, int) `public static TruffleString fromCharArrayUTF16Uncached(char[] value, int charOffset, int charLength)`. Since 22.1. Shorthand for calling the uncached version of `FromCharArrayUTF16Node`. Cite: `com/oracle/truffle/api/strings/TruffleString.html#fromCharArrayUTF16Uncached(char[],int,int)` ### fromJavaStringUncached(String, TruffleString.Encoding) `public static TruffleString fromJavaStringUncached(String s, TruffleString.Encoding encoding)`. Since 22.1. Shorthand for calling the uncached version of `FromJavaStringNode`. For constant strings, it is recommended to use `fromConstant(String, Encoding)` instead. Cite: `com/oracle/truffle/api/strings/TruffleString.html#fromJavaStringUncached(java.lang.String,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### fromJavaStringUncached(String, int, …) `public static TruffleString fromJavaStringUncached(String s, int charOffset, int length, TruffleString.Encoding encoding, boolean copy)`. Since 22.1. Shorthand for calling the uncached version of `FromJavaStringNode`. For constant strings, it is recommended to use `fromConstant(String, Encoding)` instead. Cite: `com/oracle/truffle/api/strings/TruffleString.html#fromJavaStringUncached(java.lang.String,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### fromConstant(String, TruffleString.Encoding) `public static TruffleString fromConstant(String s, TruffleString.Encoding encoding)`. Since 23.0. Shorthand for calling the uncached version of `FromJavaStringNode`. This variant also forces the calculation of the string's precise `CodeRange` and hash code. Cite: `com/oracle/truffle/api/strings/TruffleString.html#fromConstant(java.lang.String,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### fromIntArrayUTF32Uncached(int[]) `public static TruffleString fromIntArrayUTF32Uncached(int[] value)`. Since 22.1. Shorthand for calling the uncached version of `FromIntArrayUTF32Node`. Cite: `com/oracle/truffle/api/strings/TruffleString.html#fromIntArrayUTF32Uncached(int[])` ### fromIntArrayUTF32Uncached(int[], int, int) `public static TruffleString fromIntArrayUTF32Uncached(int[] value, int intOffset, int intLength)`. Since 22.1. Shorthand for calling the uncached version of `FromIntArrayUTF32Node`. Cite: `com/oracle/truffle/api/strings/TruffleString.html#fromIntArrayUTF32Uncached(int[],int,int)` ### fromNativePointerUncached(Object, int, …) `public static TruffleString fromNativePointerUncached(Object pointerObject, int byteOffset, int byteLength, TruffleString.Encoding encoding, boolean copy)`. Since 22.1. Shorthand for calling the uncached version of `FromNativePointerNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.html#fromNativePointerUncached(java.lang.Object,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### fromZeroTerminatedNativePointer8BitUncached(Object, int, …) `public static TruffleString fromZeroTerminatedNativePointer8BitUncached(Object pointerObject, int byteOffset, TruffleString.Encoding encoding, boolean copy)`. Since 25.1. Shorthand for calling the uncached version of `FromZeroTerminatedNativePointerNode.execute8Bit`. Cite: `com/oracle/truffle/api/strings/TruffleString.html#fromZeroTerminatedNativePointer8BitUncached(java.lang.Object,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### fromZeroTerminatedNativePointer16BitUncached(Object, int, …) `public static TruffleString fromZeroTerminatedNativePointer16BitUncached(Object pointerObject, int byteOffset, TruffleString.Encoding encoding, boolean copy)`. Since 25.1. Shorthand for calling the uncached version of `FromZeroTerminatedNativePointerNode.execute16Bit`. Cite: `com/oracle/truffle/api/strings/TruffleString.html#fromZeroTerminatedNativePointer16BitUncached(java.lang.Object,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### fromZeroTerminatedNativePointer32BitUncached(Object, int, …) `public static TruffleString fromZeroTerminatedNativePointer32BitUncached(Object pointerObject, int byteOffset, TruffleString.Encoding encoding, boolean copy)`. Since 25.1. Shorthand for calling the uncached version of `FromZeroTerminatedNativePointerNode.execute32Bit`. Cite: `com/oracle/truffle/api/strings/TruffleString.html#fromZeroTerminatedNativePointer32BitUncached(java.lang.Object,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### fromByteArrayWithCompactionUTF32Uncached(byte[], int, …) `public static TruffleString fromByteArrayWithCompactionUTF32Uncached(byte[] array, int byteOffset, int byteLength, TruffleString.CompactionLevel compactionLevel, boolean copy)`. Since 25.1. Shorthand for calling the uncached version of `FromByteArrayWithCompactionUTF32Node`. Cite: `com/oracle/truffle/api/strings/TruffleString.html#fromByteArrayWithCompactionUTF32Uncached(byte[],int,int,com.oracle.truffle.api.strings.TruffleString.CompactionLevel,boolean)` ### fromNativePointerWithCompactionUTF32Uncached(Object, int, …) `public static TruffleString fromNativePointerWithCompactionUTF32Uncached(Object pointerObject, int byteOffset, int byteLength, TruffleString.CompactionLevel compactionLevel, boolean copy)`. Since 25.1. Shorthand for calling the uncached version of `FromNativePointerWithCompactionUTF32Node`. Cite: `com/oracle/truffle/api/strings/TruffleString.html#fromNativePointerWithCompactionUTF32Uncached(java.lang.Object,int,int,com.oracle.truffle.api.strings.TruffleString.CompactionLevel,boolean)` ### asNativeUncached(NativeAllocator, TruffleString.Encoding, …) `public TruffleString asNativeUncached(NativeAllocator allocator, TruffleString.Encoding expectedEncoding, boolean useCompaction, boolean cacheResult)`. Since 23.0. Shorthand for calling the uncached version of `AsNativeNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.html#asNativeUncached(com.oracle.truffle.api.strings.NativeAllocator,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean,boolean)` ## Inherited members - From class [`AbstractTruffleString`](com/oracle/truffle/api/strings/AbstractTruffleString.md): [`asManagedMutableTruffleStringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#asManagedMutableTruffleStringUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`asManagedTruffleStringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#asManagedTruffleStringUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`asManagedTruffleStringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#asManagedTruffleStringUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding,boolean%29), [`asMutableTruffleStringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#asMutableTruffleStringUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`asTruffleStringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#asTruffleStringUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`byteIndexOfAnyByteUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#byteIndexOfAnyByteUncached%28int,int,byte[],com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`byteIndexOfCodePointUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#byteIndexOfCodePointUncached%28int,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`byteIndexOfStringSetUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#byteIndexOfStringSetUncached%28int,int,com.oracle.truffle.api.strings.TruffleString.StringSet%29), [`byteIndexOfStringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#byteIndexOfStringUncached%28com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`byteIndexOfStringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#byteIndexOfStringUncached%28com.oracle.truffle.api.strings.TruffleString.WithMask,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`byteIndexToCodePointIndexUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#byteIndexToCodePointIndexUncached%28int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`byteLength`](com/oracle/truffle/api/strings/AbstractTruffleString.md#byteLength%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`byteLengthOfCodePointUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#byteLengthOfCodePointUncached%28int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`byteLengthOfCodePointUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#byteLengthOfCodePointUncached%28int,com.oracle.truffle.api.strings.TruffleString.Encoding,com.oracle.truffle.api.strings.TruffleString.ErrorHandling%29), [`charIndexOfAnyCharUTF16Uncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#charIndexOfAnyCharUTF16Uncached%28int,int,char[]%29), [`codePointAtByteIndexUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#codePointAtByteIndexUncached%28int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`codePointAtByteIndexUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#codePointAtByteIndexUncached%28int,com.oracle.truffle.api.strings.TruffleString.Encoding,com.oracle.truffle.api.strings.TruffleString.ErrorHandling%29), [`codePointAtIndexUTF32Uncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#codePointAtIndexUTF32Uncached%28int%29), [`codePointAtIndexUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#codePointAtIndexUncached%28int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`codePointAtIndexUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#codePointAtIndexUncached%28int,com.oracle.truffle.api.strings.TruffleString.Encoding,com.oracle.truffle.api.strings.TruffleString.ErrorHandling%29), [`codePointIndexToByteIndexUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#codePointIndexToByteIndexUncached%28int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`codePointLengthUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#codePointLengthUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`codeRangeEqualsUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#codeRangeEqualsUncached%28com.oracle.truffle.api.strings.TruffleString.CodeRange%29), [`compareBytesUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#compareBytesUncached%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`compareCharsUTF16Uncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#compareCharsUTF16Uncached%28com.oracle.truffle.api.strings.AbstractTruffleString%29), [`compareIntsUTF32Uncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#compareIntsUTF32Uncached%28com.oracle.truffle.api.strings.AbstractTruffleString%29), [`concatUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#concatUncached%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean%29), [`copyToByteArrayUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#copyToByteArrayUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`copyToByteArrayUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#copyToByteArrayUncached%28int,byte[],int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`copyToNativeMemoryUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#copyToNativeMemoryUncached%28int,java.lang.Object,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`createBackwardCodePointIteratorUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#createBackwardCodePointIteratorUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`createCodePointIteratorUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#createCodePointIteratorUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`equals`](com/oracle/truffle/api/strings/AbstractTruffleString.md#equals%28java.lang.Object%29), [`equalsUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#equalsUncached%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`forceEncodingUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#forceEncodingUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`getByteCodeRangeUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#getByteCodeRangeUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`getCodeRangeImpreciseUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#getCodeRangeImpreciseUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`getCodeRangeUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#getCodeRangeUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`getInternalByteArrayUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#getInternalByteArrayUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`getInternalNativePointerUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#getInternalNativePointerUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`getStringCompactionLevelUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#getStringCompactionLevelUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`hashCode`](com/oracle/truffle/api/strings/AbstractTruffleString.md#hashCode%28%29), [`hashCodeUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#hashCodeUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`indexOfCodePointUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#indexOfCodePointUncached%28int,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`indexOfStringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#indexOfStringUncached%28com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`intIndexOfAnyIntUTF32Uncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#intIndexOfAnyIntUTF32Uncached%28int,int,int[]%29), [`isCompatibleToUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#isCompatibleToUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`isEmpty`](com/oracle/truffle/api/strings/AbstractTruffleString.md#isEmpty%28%29), [`isImmutable`](com/oracle/truffle/api/strings/AbstractTruffleString.md#isImmutable%28%29), [`isManaged`](com/oracle/truffle/api/strings/AbstractTruffleString.md#isManaged%28%29), [`isMutable`](com/oracle/truffle/api/strings/AbstractTruffleString.md#isMutable%28%29), [`isNative`](com/oracle/truffle/api/strings/AbstractTruffleString.md#isNative%28%29), [`isValidUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#isValidUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`lastByteIndexOfCodePointUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#lastByteIndexOfCodePointUncached%28int,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`lastByteIndexOfStringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#lastByteIndexOfStringUncached%28com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`lastByteIndexOfStringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#lastByteIndexOfStringUncached%28com.oracle.truffle.api.strings.TruffleString.WithMask,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`lastIndexOfCodePointUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#lastIndexOfCodePointUncached%28int,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`lastIndexOfStringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#lastIndexOfStringUncached%28com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`materializeSubstringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#materializeSubstringUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`materializeUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#materializeUncached%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`materializeUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#materializeUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`parseDoubleUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#parseDoubleUncached%28%29), [`parseIntUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#parseIntUncached%28%29), [`parseIntUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#parseIntUncached%28int%29), [`parseLongUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#parseLongUncached%28%29), [`parseLongUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#parseLongUncached%28int%29), [`readByteUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#readByteUncached%28int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`readCharUTF16Uncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#readCharUTF16Uncached%28int%29), [`regionEqualByteIndexUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#regionEqualByteIndexUncached%28int,com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`regionEqualByteIndexUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#regionEqualByteIndexUncached%28int,com.oracle.truffle.api.strings.TruffleString.WithMask,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`regionEqualsUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#regionEqualsUncached%28int,com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`repeatUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#repeatUncached%28int,com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`substringByteIndexUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#substringByteIndexUncached%28int,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean%29), [`substringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#substringUncached%28int,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean%29), [`switchEncodingUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#switchEncodingUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`switchEncodingUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#switchEncodingUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding,com.oracle.truffle.api.strings.TranscodingErrorHandler%29), [`toJavaStringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#toJavaStringUncached%28%29), [`toString`](com/oracle/truffle/api/strings/AbstractTruffleString.md#toString%28%29), [`toStringDebug`](com/oracle/truffle/api/strings/AbstractTruffleString.md#toStringDebug%28%29), [`toValidStringUncached`](com/oracle/truffle/api/strings/AbstractTruffleString.md#toValidStringUncached%28com.oracle.truffle.api.strings.TruffleString.Encoding%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.AsManagedNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.AsManagedNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `AsManagedNode` Node to get the given [`AbstractTruffleString`](com/oracle/truffle/api/strings/AbstractTruffleString.md) as a managed [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md), meaning that the resulting string's backing memory is not a native pointer. See [`execute(AbstractTruffleString, TruffleString.Encoding)`](com/oracle/truffle/api/strings/TruffleString.AsManagedNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, TruffleString.Encoding) `public final TruffleString execute(AbstractTruffleString a, TruffleString.Encoding expectedEncoding)`. Since 22.1. Returns a given string if it is already managed (i.e. not backed by a native pointer), otherwise, copies the string's native pointer content into a Java byte array and returns a new string backed by the byte array. Cite: `com/oracle/truffle/api/strings/TruffleString.AsManagedNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### execute(AbstractTruffleString, TruffleString.Encoding, boolean) `public abstract TruffleString execute(AbstractTruffleString a, TruffleString.Encoding expectedEncoding, boolean cacheResult)`. Since 23.0. If the given string is already a managed (i.e. not backed by a native pointer) string, return it. Otherwise, copy the string's native pointer content into a Java byte array and return a new string backed by the byte array. Parameters: `cacheResult` `boolean`: if set to `true`, managed strings created from native `TruffleString` instances are cached in the native string's internal transcoding cache. Note that this will keep the native string alive and reachable via `AsNativeNode`. Subsequent calls of `AsManagedNode` with `cacheResult=true` on the same native string are guaranteed to return the same managed string. This parameter is expected to be `partial evaluation constant`. Cite: `com/oracle/truffle/api/strings/TruffleString.AsManagedNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### create() `public static TruffleString.AsManagedNode create()`. Since 22.1. Create a new `AsManagedNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.AsManagedNode.html#create()` ### getUncached() `public static TruffleString.AsManagedNode getUncached()`. Since 22.1. Get the uncached version of `AsManagedNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.AsManagedNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.AsNativeNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 23.0. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.AsNativeNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `AsNativeNode` Node to convert a potentially [`managed`](com/oracle/truffle/api/strings/AbstractTruffleString.md#isManaged%28%29) [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md) to a [`native`](com/oracle/truffle/api/strings/AbstractTruffleString.md#isNative%28%29) string. ## Methods ### execute(TruffleString, NativeAllocator, …) `public abstract TruffleString execute(TruffleString a, NativeAllocator allocator, TruffleString.Encoding expectedEncoding, boolean useCompaction, boolean cacheResult)`. Since 23.0. Convert a potentially `managed` `TruffleString` to a `native` string. If the given string is `native` already, it is returned. Otherwise, a new string with a backing native buffer allocated via `allocator` is created and stored in the given managed string's internal transcoding cache, such that subsequent calls on the same string will return the same native string. This operation requires native access permissions (`TruffleLanguage.Env#isNativeAccessAllowed()`). Parameters: `allocator` `NativeAllocator`: a function implementing `NativeAllocator`. This parameter is expected to be `partial evaluation constant`. `useCompaction` `boolean`: if set to `true`, `Encoding.UTF_32` and `Encoding.UTF_16` - encoded strings may be compacted also in the native representation. Otherwise, no string compaction is applied to the native string. This parameter is expected to be `partial evaluation constant`. `cacheResult` `boolean`: if set to `true`, the newly created native string will be cached in the given managed string's internal transcoding cache ring, guaranteeing that subsequent calls on the managed string return the same native string. Note that this ties the lifetime of the native string to that of the managed string. This parameter is expected to be `partial evaluation constant`. Cite: `com/oracle/truffle/api/strings/TruffleString.AsNativeNode.html#execute(com.oracle.truffle.api.strings.TruffleString,com.oracle.truffle.api.strings.NativeAllocator,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean,boolean)` ### create() `public static TruffleString.AsNativeNode create()`. Since 23.0. Create a new `AsNativeNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.AsNativeNode.html#create()` ### getUncached() `public static TruffleString.AsNativeNode getUncached()`. Since 23.0. Get the uncached version of `AsNativeNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.AsNativeNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.AsTruffleStringNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.AsTruffleStringNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `AsTruffleStringNode` Node to get the given [`AbstractTruffleString`](com/oracle/truffle/api/strings/AbstractTruffleString.md) as a [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). See [`execute(AbstractTruffleString, TruffleString.Encoding)`](com/oracle/truffle/api/strings/TruffleString.AsTruffleStringNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, TruffleString.Encoding) `public abstract TruffleString execute(AbstractTruffleString value, TruffleString.Encoding expectedEncoding)`. Since 22.1. If the given string is already a `TruffleString`, return it. If it is a `MutableTruffleString`, create a new `TruffleString`, copying the mutable string's contents. Cite: `com/oracle/truffle/api/strings/TruffleString.AsTruffleStringNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.AsTruffleStringNode create()`. Since 22.1. Create a new `AsTruffleStringNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.AsTruffleStringNode.html#create()` ### getUncached() `public static TruffleString.AsTruffleStringNode getUncached()`. Since 22.1. Get the uncached version of `AsTruffleStringNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.AsTruffleStringNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.ByteIndexOfAnyByteNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.ByteIndexOfAnyByteNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `ByteIndexOfAnyByteNode` Node to find the index of the first occurrence of any byte from a given array. See [`execute(AbstractTruffleString, int, int, byte[], TruffleString.Encoding)`](com/oracle/truffle/api/strings/TruffleString.ByteIndexOfAnyByteNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,int,int,byte[],com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, int, …) `public abstract int execute(AbstractTruffleString a, int fromByteIndex, int maxByteIndex, byte[] values, TruffleString.Encoding expectedEncoding)`. Since 22.1. Return the byte index of the first occurrence of any byte contained in `values`, bounded by `fromByteIndex` (inclusive) and `maxByteIndex` (exclusive). If none of the values is found, return a negative value. Cite: `com/oracle/truffle/api/strings/TruffleString.ByteIndexOfAnyByteNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int,int,byte[],com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.ByteIndexOfAnyByteNode create()`. Since 22.1. Create a new `ByteIndexOfAnyByteNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ByteIndexOfAnyByteNode.html#create()` ### getUncached() `public static TruffleString.ByteIndexOfAnyByteNode getUncached()`. Since 22.1. Get the uncached version of `ByteIndexOfAnyByteNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ByteIndexOfAnyByteNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.ByteIndexOfCodePointNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.ByteIndexOfCodePointNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `ByteIndexOfCodePointNode` [`IndexOfCodePointNode`](com/oracle/truffle/api/strings/TruffleString.IndexOfCodePointNode.md), but with byte indices. ## Methods ### execute(AbstractTruffleString, int, …) `public abstract int execute(AbstractTruffleString a, int codepoint, int fromByteIndex, int toByteIndex, TruffleString.Encoding expectedEncoding)`. Since 22.1. `IndexOfCodePointNode`, but with byte indices. Cite: `com/oracle/truffle/api/strings/TruffleString.ByteIndexOfCodePointNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.ByteIndexOfCodePointNode create()`. Since 22.1. Create a new `ByteIndexOfCodePointNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ByteIndexOfCodePointNode.html#create()` ### getUncached() `public static TruffleString.ByteIndexOfCodePointNode getUncached()`. Since 22.1. Get the uncached version of `ByteIndexOfCodePointNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ByteIndexOfCodePointNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.ByteIndexOfCodePointSetNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 23.0. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.ByteIndexOfCodePointSetNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `ByteIndexOfCodePointSetNode` Node to find the byte index of the first occurrence of a codepoint present in a given codepoint set. See [`execute(AbstractTruffleString, int, int, TruffleString.CodePointSet)`](com/oracle/truffle/api/strings/TruffleString.ByteIndexOfCodePointSetNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.CodePointSet%29) for details. ## Methods ### execute(AbstractTruffleString, int, …) `public final int execute(AbstractTruffleString a, int fromByteIndex, int toByteIndex, TruffleString.CodePointSet codePointSet)`. Since 23.0. Returns the byte index of the first codepoint present in the given `CodePointSet`, bounded by `fromByteIndex` (inclusive) and `toByteIndex` (exclusive). `ByteIndexOfCodePointSetNode` will specialize on the given `CodePointSet`'s content, which is therefore required to be `partial evaluation constant`. Usage example: A node that scans a string for a known set of code points and escapes them with '\\'. Parameters: `codePointSet` `TruffleString.CodePointSet`: The set of codepoints to look for. This parameter is expected to be `partial evaluation constant`. Cite: `com/oracle/truffle/api/strings/TruffleString.ByteIndexOfCodePointSetNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.CodePointSet)` ```java abstract static class StringEscapeNode extends Node { public static final TruffleString.Encoding ENCODING = TruffleString.Encoding.UTF_32; public static final TruffleString.ByteIndexOfCodePointSetNode.CodePointSet ESCAPE_CHARS = TruffleString.ByteIndexOfCodePointSetNode.CodePointSet.fromRanges(new int[]{ '\n', '\n', '\r', '\r', // .... }, ENCODING); abstract TruffleString execute(TruffleString input); @Specialization static TruffleString run(TruffleString input, @Cached TruffleString.ByteIndexOfCodePointSetNode byteIndexOfCodePointSetNode, @Cached TruffleStringBuilder.AppendSubstringByteIndexNode appendSubstringByteIndexNode, @Cached TruffleString.CodePointAtByteIndexNode codePointAtByteIndexNode, @Cached TruffleStringBuilder.AppendCodePointNode appendCodePointNode, @Cached TruffleString.ByteLengthOfCodePointNode byteLengthOfCodePointNode, @Cached TruffleStringBuilder.ToStringNode toStringNode) { int byteLength = input.byteLength(ENCODING); TruffleStringBuilder sb = TruffleStringBuilder.create(ENCODING, byteLength); int lastPos = 0; int pos = 0; while (pos >= 0) { pos = byteIndexOfCodePointSetNode.execute(input, lastPos, byteLength, ESCAPE_CHARS); int substringLength = (pos < 0 ? byteLength : pos) - lastPos; appendSubstringByteIndexNode.execute(sb, input, lastPos, substringLength); if (pos >= 0) { int codePoint = codePointAtByteIndexNode.execute(input, pos, ENCODING); appendCodePointNode.execute(sb, '\\'); appendCodePointNode.execute(sb, codePoint); int codePointLength = byteLengthOfCodePointNode.execute(input, pos, ENCODING); lastPos = pos + codePointLength; } } return toStringNode.execute(sb); } } ``` ### execute(AbstractTruffleString, int, …) `public abstract int execute(AbstractTruffleString a, int fromByteIndex, int toByteIndex, TruffleString.CodePointSet codePointSet, boolean usePreciseCodeRange)`. Since 24.1. Returns the byte index of the first codepoint present in the given `CodePointSet`, bounded by `fromByteIndex` (inclusive) and `toByteIndex` (exclusive). Parameters: `usePreciseCodeRange` `boolean`: If this parameter is set to `true`, the node may evaluate the input string's precise code range for better search performance. For more details, see `GetCodeRangeNode` and `GetCodeRangeImpreciseNode`. This parameter is expected to be `partial evaluation constant`. Cite: `com/oracle/truffle/api/strings/TruffleString.ByteIndexOfCodePointSetNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.CodePointSet,boolean)` ### create() `public static TruffleString.ByteIndexOfCodePointSetNode create()`. Since 23.0. Create a new `ByteIndexOfCodePointSetNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ByteIndexOfCodePointSetNode.html#create()` ### getUncached() `public static TruffleString.ByteIndexOfCodePointSetNode getUncached()`. Since 23.0. Get the uncached version of `ByteIndexOfCodePointSetNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ByteIndexOfCodePointSetNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.ByteIndexOfStringNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.ByteIndexOfStringNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `ByteIndexOfStringNode` [`IndexOfStringNode`](com/oracle/truffle/api/strings/TruffleString.IndexOfStringNode.md), but with byte indices. ## Methods ### execute(AbstractTruffleString, AbstractTruffleString, …) `public final int execute(AbstractTruffleString a, AbstractTruffleString b, int fromByteIndex, int toByteIndex, TruffleString.Encoding expectedEncoding)`. Since 22.1. `IndexOfStringNode`, but with byte indices. Cite: `com/oracle/truffle/api/strings/TruffleString.ByteIndexOfStringNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### execute(AbstractTruffleString, TruffleString.WithMask, …) `public final int execute(AbstractTruffleString a, TruffleString.WithMask b, int fromByteIndex, int toByteIndex, TruffleString.Encoding expectedEncoding)`. Since 22.1. `IndexOfStringNode`, but with byte indices. This variant accepts a `TruffleString.WithMask` as the search value `b`, which changes the searching algorithm in the following manner: whenever the contents of `a` and `b` are compared, the mask is OR'ed to `a`, as shown in this exemplary method: Cite: `com/oracle/truffle/api/strings/TruffleString.ByteIndexOfStringNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.WithMask,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ```java boolean bytesEqualAt(TruffleString a, int byteIndexA, TruffleString.WithMask b, int byteIndexB) { return (readByte(a, byteIndexA) | readByte(b.mask, byteIndexB)) == readByte(b, byteIndexB); } ``` ### create() `public static TruffleString.ByteIndexOfStringNode create()`. Since 22.1. Create a new `ByteIndexOfStringNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ByteIndexOfStringNode.html#create()` ### getUncached() `public static TruffleString.ByteIndexOfStringNode getUncached()`. Since 22.1. Get the uncached version of `ByteIndexOfStringNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ByteIndexOfStringNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.ByteIndexOfStringSetNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 25.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.ByteIndexOfStringSetNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `ByteIndexOfStringSetNode` Node to find the byte index of the first occurrence of any string contained in a given string set. See [`execute(AbstractTruffleString, int, int, TruffleString.StringSet)`](com/oracle/truffle/api/strings/TruffleString.ByteIndexOfStringSetNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.StringSet%29) for details. ## Methods ### execute(AbstractTruffleString, int, …) `public abstract long execute(AbstractTruffleString a, int fromByteIndex, int toByteIndex, TruffleString.StringSet stringSet)`. Since 25.1. Returns the byte index of the first occurrence of any string present in the given `StringSet`, bounded by `fromByteIndex` (inclusive) and `toByteIndex` (exclusive). The returned `long` packs the resulting byte index into the high 32 bits and the matching pattern's index into the low 32 bits. If no match is found, the result packs `-1` for both fields. If multiple strings match at the first matching byte index, the string with the lowest index in the array passed to `StringSet.fromArray(AbstractTruffleString[], Encoding)` is selected. `ByteIndexOfStringSetNode` will specialize on the given `StringSet`'s content, which is therefore required to be `partial evaluation constant`. Cite: `com/oracle/truffle/api/strings/TruffleString.ByteIndexOfStringSetNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.StringSet)` ### unpackResultByteIndex(long) `public static int unpackResultByteIndex(long result)`. Since 25.1. Returns the byte index part of a result returned by `execute(AbstractTruffleString, int, int, TruffleString.StringSet)`. Cite: `com/oracle/truffle/api/strings/TruffleString.ByteIndexOfStringSetNode.html#unpackResultByteIndex(long)` ### unpackResultPatternIndex(long) `public static int unpackResultPatternIndex(long result)`. Since 25.1. Returns the pattern index part of a result returned by `execute(AbstractTruffleString, int, int, TruffleString.StringSet)`. Cite: `com/oracle/truffle/api/strings/TruffleString.ByteIndexOfStringSetNode.html#unpackResultPatternIndex(long)` ### resultIsMatch(long) `public static boolean resultIsMatch(long result)`. Since 25.1. Returns `true` if the given result, as returned by `execute(AbstractTruffleString, int, int, TruffleString.StringSet)`, represents a successful match. Cite: `com/oracle/truffle/api/strings/TruffleString.ByteIndexOfStringSetNode.html#resultIsMatch(long)` ### create() `public static TruffleString.ByteIndexOfStringSetNode create()`. Since 25.1. Create a new `ByteIndexOfStringSetNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ByteIndexOfStringSetNode.html#create()` ### getUncached() `public static TruffleString.ByteIndexOfStringSetNode getUncached()`. Since 25.1. Get the uncached version of `ByteIndexOfStringSetNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ByteIndexOfStringSetNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.ByteIndexToCodePointIndexNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.2. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.ByteIndexToCodePointIndexNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `ByteIndexToCodePointIndexNode` Node to convert a given byte index to a codepoint index. See [`execute(AbstractTruffleString, int, int, TruffleString.Encoding)`](com/oracle/truffle/api/strings/TruffleString.ByteIndexToCodePointIndexNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, int, …) `public abstract int execute(AbstractTruffleString a, int byteOffset, int byteIndex, TruffleString.Encoding expectedEncoding)`. Since 22.2. Convert the given byte index to a codepoint index, relative to starting point `byteOffset`. Cite: `com/oracle/truffle/api/strings/TruffleString.ByteIndexToCodePointIndexNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.ByteIndexToCodePointIndexNode create()`. Since 22.2. Create a new `ByteIndexToCodePointIndexNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ByteIndexToCodePointIndexNode.html#create()` ### getUncached() `public static TruffleString.ByteIndexToCodePointIndexNode getUncached()`. Since 22.2. Get the uncached version of `ByteIndexToCodePointIndexNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ByteIndexToCodePointIndexNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.ByteLengthOfCodePointNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.ByteLengthOfCodePointNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `ByteLengthOfCodePointNode` Node to get the number of bytes occupied by the codepoint starting at a given byte index. See [`execute(AbstractTruffleString, int, TruffleString.Encoding)`](com/oracle/truffle/api/strings/TruffleString.ByteLengthOfCodePointNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, int, TruffleString.Encoding) `public final int execute(AbstractTruffleString a, int byteIndex, TruffleString.Encoding expectedEncoding)`. Since 22.1. Get the number of bytes occupied by the codepoint starting at `byteIndex`, with `best-effort` error handling. Cite: `com/oracle/truffle/api/strings/TruffleString.ByteLengthOfCodePointNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### execute(AbstractTruffleString, int, …) `public abstract int execute(AbstractTruffleString a, int byteIndex, TruffleString.Encoding expectedEncoding, TruffleString.ErrorHandling errorHandling)`. Since 22.3. Get the number of bytes occupied by the codepoint starting at `byteIndex`. Parameters: `errorHandling` `TruffleString.ErrorHandling`: if set to `ErrorHandling.BEST_EFFORT`, this node will return the encoding's minimum number of bytes per codepoint if an error occurs while reading the codepoint. If set to `ErrorHandling.RETURN_NEGATIVE`, a negative value will be returned instead, where two error cases are distinguished: if the codepoint is invalid, the return value is -1. If the codepoint is an unfinished, possibly valid byte sequence at the end of the string, the return value is `-1 - (number of missing bytes)`. This parameter is expected to be `partial evaluation constant`. Cite: `com/oracle/truffle/api/strings/TruffleString.ByteLengthOfCodePointNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int,com.oracle.truffle.api.strings.TruffleString.Encoding,com.oracle.truffle.api.strings.TruffleString.ErrorHandling)` ### create() `public static TruffleString.ByteLengthOfCodePointNode create()`. Since 22.1. Create a new `ByteLengthOfCodePointNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ByteLengthOfCodePointNode.html#create()` ### getUncached() `public static TruffleString.ByteLengthOfCodePointNode getUncached()`. Since 22.1. Get the uncached version of `ByteLengthOfCodePointNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ByteLengthOfCodePointNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.CharIndexOfAnyCharUTF16Node [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.CharIndexOfAnyCharUTF16Node extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `CharIndexOfAnyCharUTF16Node` Node to find the index of the first occurrence of any `char` from a given array. See [`execute(AbstractTruffleString, int, int, char[])`](com/oracle/truffle/api/strings/TruffleString.CharIndexOfAnyCharUTF16Node.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,int,int,char[]%29) for details. ## Methods ### execute(AbstractTruffleString, int, …) `public abstract int execute(AbstractTruffleString a, int fromCharIndex, int maxCharIndex, char[] values)`. Since 22.1. Return the char index of the first occurrence of any char contained in `values`, bounded by `fromCharIndex` (inclusive) and `maxCharIndex` (exclusive). If none of the values is found, return a negative value. Cite: `com/oracle/truffle/api/strings/TruffleString.CharIndexOfAnyCharUTF16Node.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int,int,char[])` ### create() `public static TruffleString.CharIndexOfAnyCharUTF16Node create()`. Since 22.1. Create a new `CharIndexOfAnyCharUTF16Node`. Cite: `com/oracle/truffle/api/strings/TruffleString.CharIndexOfAnyCharUTF16Node.html#create()` ### getUncached() `public static TruffleString.CharIndexOfAnyCharUTF16Node getUncached()`. Since 22.1. Get the uncached version of `CharIndexOfAnyCharUTF16Node`. Cite: `com/oracle/truffle/api/strings/TruffleString.CharIndexOfAnyCharUTF16Node.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.CodePointAtByteIndexNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.CodePointAtByteIndexNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `CodePointAtByteIndexNode` Node to read a codepoint at a given byte index. See [`execute(AbstractTruffleString, int, TruffleString.Encoding)`](com/oracle/truffle/api/strings/TruffleString.CodePointAtByteIndexNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, int, TruffleString.Encoding) `public final int execute(AbstractTruffleString a, int i, TruffleString.Encoding expectedEncoding)`. Since 22.1. Decode and return the codepoint at byte index `i`, with `best-effort` error handling. Cite: `com/oracle/truffle/api/strings/TruffleString.CodePointAtByteIndexNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### execute(AbstractTruffleString, int, …) `public abstract int execute(AbstractTruffleString a, int i, TruffleString.Encoding expectedEncoding, TruffleString.ErrorHandling errorHandling)`. Since 22.3. Decode and return the codepoint at byte index `i`. Parameters: `errorHandling` `TruffleString.ErrorHandling`: analogous to `CodePointAtIndexNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.CodePointAtByteIndexNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int,com.oracle.truffle.api.strings.TruffleString.Encoding,com.oracle.truffle.api.strings.TruffleString.ErrorHandling)` ### create() `public static TruffleString.CodePointAtByteIndexNode create()`. Since 22.1. Create a new `CodePointAtByteIndexNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.CodePointAtByteIndexNode.html#create()` ### getUncached() `public static TruffleString.CodePointAtByteIndexNode getUncached()`. Since 22.1. Get the uncached version of `CodePointAtByteIndexNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.CodePointAtByteIndexNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.CodePointAtIndexNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.CodePointAtIndexNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `CodePointAtIndexNode` Node to read a codepoint at a given codepoint index. See [`execute(AbstractTruffleString, int, TruffleString.Encoding)`](com/oracle/truffle/api/strings/TruffleString.CodePointAtIndexNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, int, TruffleString.Encoding) `public final int execute(AbstractTruffleString a, int i, TruffleString.Encoding expectedEncoding)`. Since 22.1. Decode and return the codepoint at codepoint index `i`, with `best-effort` error handling. Cite: `com/oracle/truffle/api/strings/TruffleString.CodePointAtIndexNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### execute(AbstractTruffleString, int, …) `public abstract int execute(AbstractTruffleString a, int i, TruffleString.Encoding expectedEncoding, TruffleString.ErrorHandling errorHandling)`. Since 22.3. Decode and return the codepoint at codepoint index `i`. Parameters: `errorHandling` `TruffleString.ErrorHandling`: if set to `ErrorHandling.BEST_EFFORT`, the return value on invalid codepoints depends on `expectedEncoding`: `Encoding.UTF_8`: Unicode Replacement character `0xFFFD`; `Encoding.UTF_16`: the (16-bit) `char` value read at index `i`; `Encoding.UTF_32`: the (32-bit) `int` value read at index `i`; `Encoding.US_ASCII`, `Encoding.ISO_8859_1`, `Encoding.BYTES`: the (8-bit) unsigned `byte` value read at index `i`; All other Encodings: Unicode Replacement character `0xFFFD` If set to `ErrorHandling.RETURN_NEGATIVE`, `-1` will be returned instead. This parameter is expected to be `partial evaluation constant`. Cite: `com/oracle/truffle/api/strings/TruffleString.CodePointAtIndexNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int,com.oracle.truffle.api.strings.TruffleString.Encoding,com.oracle.truffle.api.strings.TruffleString.ErrorHandling)` ### create() `public static TruffleString.CodePointAtIndexNode create()`. Since 22.1. Create a new `CodePointAtIndexNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.CodePointAtIndexNode.html#create()` ### getUncached() `public static TruffleString.CodePointAtIndexNode getUncached()`. Since 22.1. Get the uncached version of `CodePointAtIndexUTF32Node`. Cite: `com/oracle/truffle/api/strings/TruffleString.CodePointAtIndexNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.CodePointAtIndexUTF32Node [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 25.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.CodePointAtIndexUTF32Node extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `CodePointAtIndexUTF32Node` Node to read a codepoint at a given codepoint index from a UTF-32 string. See [`execute(AbstractTruffleString, int)`](com/oracle/truffle/api/strings/TruffleString.CodePointAtIndexUTF32Node.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,int%29) for details. ## Methods ### execute(AbstractTruffleString, int) `public abstract int execute(AbstractTruffleString a, int i)`. Since 25.1. Decode and return the codepoint at codepoint index `i`. This node is a specialized version of `CodePointAtIndexNode` for UTF-32 strings, with `best-effort` error handling. This node should be preferred over the generic `CodePointAtIndexNode` when possible for better performance during warmup / in interpreter mode. Cite: `com/oracle/truffle/api/strings/TruffleString.CodePointAtIndexUTF32Node.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int)` ### create() `public static TruffleString.CodePointAtIndexUTF32Node create()`. Since 25.1. Create a new `CodePointAtIndexUTF32Node`. Cite: `com/oracle/truffle/api/strings/TruffleString.CodePointAtIndexUTF32Node.html#create()` ### getUncached() `public static TruffleString.CodePointAtIndexUTF32Node getUncached()`. Since 25.1. Get the uncached version of `CodePointAtIndexUTF32Node`. Cite: `com/oracle/truffle/api/strings/TruffleString.CodePointAtIndexUTF32Node.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.CodePointIndexToByteIndexNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.CodePointIndexToByteIndexNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `CodePointIndexToByteIndexNode` Node to convert a given codepoint index to a byte index. See [`execute(AbstractTruffleString, int, int, TruffleString.Encoding)`](com/oracle/truffle/api/strings/TruffleString.CodePointIndexToByteIndexNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, int, …) `public abstract int execute(AbstractTruffleString a, int byteOffset, int codepointIndex, TruffleString.Encoding expectedEncoding)`. Since 22.1. Convert the given codepoint index to a byte index, relative to starting point `byteOffset`. Cite: `com/oracle/truffle/api/strings/TruffleString.CodePointIndexToByteIndexNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.CodePointIndexToByteIndexNode create()`. Since 22.1. Create a new `CodePointIndexToByteIndexNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.CodePointIndexToByteIndexNode.html#create()` ### getUncached() `public static TruffleString.CodePointIndexToByteIndexNode getUncached()`. Since 22.1. Get the uncached version of `CodePointIndexToByteIndexNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.CodePointIndexToByteIndexNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.CodePointLengthNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.CodePointLengthNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `CodePointLengthNode` Node to get the number of codepoints in a string. ## Methods ### execute(AbstractTruffleString, TruffleString.Encoding) `public abstract int execute(AbstractTruffleString a, TruffleString.Encoding expectedEncoding)`. Since 22.1. Return the number of codepoints in the string. If the string is not encoded correctly (if its coderange is `CodeRange.BROKEN`), every broken minimum-length sequence in the encoding (4 bytes for UTF-32, 2 bytes for UTF-16, 1 byte for other encodings) adds 1 to the length. Cite: `com/oracle/truffle/api/strings/TruffleString.CodePointLengthNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.CodePointLengthNode create()`. Since 22.1. Create a new `CodePointLengthNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.CodePointLengthNode.html#create()` ### getUncached() `public static TruffleString.CodePointLengthNode getUncached()`. Since 22.1. Get the uncached version of `CodePointLengthNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.CodePointLengthNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.CodePointSet [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 23.0. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public static final class TruffleString.CodePointSet ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `CodePointSet` A set of codepoints in a given encoding. Used in [`ByteIndexOfCodePointSetNode.execute(AbstractTruffleString, int, int, TruffleString.CodePointSet)`](com/oracle/truffle/api/strings/TruffleString.ByteIndexOfCodePointSetNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.CodePointSet%29). ## Methods ### fromRanges(int[], TruffleString.Encoding) `public static TruffleString.CodePointSet fromRanges(int[] ranges, TruffleString.Encoding encoding)`. Since 23.0. Creates a new `CodePointSet` from the given list of ranges. This operation is expensive, it is recommended to cache the result. Parameters: `ranges` `int[]`: a sorted list of non-adjacent codepoint ranges. For every two consecutive array elements, the first is interpreted as the range's inclusive lower bound, and the second element is the range's inclusive upper bound. Example: an array `[1, 4, 8, 10]` represents the inclusive ranges `[1-4]` and `[8-10]`. Cite: `com/oracle/truffle/api/strings/TruffleString.CodePointSet.html#fromRanges(int[],com.oracle.truffle.api.strings.TruffleString.Encoding)` ### isIntrinsicCandidate(TruffleString.CodeRange) `public boolean isIntrinsicCandidate(TruffleString.CodeRange codeRange)`. Since 23.0. Returns `true` if `ByteIndexOfCodePointSetNode` may implement the search for this particular code point set in strings with the given code range by dispatching to a compiler intrinsic. Cite: `com/oracle/truffle/api/strings/TruffleString.CodePointSet.html#isIntrinsicCandidate(com.oracle.truffle.api.strings.TruffleString.CodeRange)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ≡ TruffleString.CodeRange [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Enum class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public enum TruffleString.CodeRange ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html) > `CodeRange` Provides information about a string's content. All values of this enum describe a set of codepoints potentially contained by a string reporting said value. ## Enum constants ### ASCII `ASCII`. Since 22.1. All codepoints in this string are part of the Basic Latin Unicode block, also known as ASCII (0x00 - 0x7f). Cite: `com/oracle/truffle/api/strings/TruffleString.CodeRange.html#ASCII` ### LATIN_1 `LATIN_1`. Since 22.1. All codepoints in this string are part of the ISO-8859-1 character set (0x00 - 0xff), which is equivalent to the union of the Basic Latin and the Latin-1 Supplement Unicode block. If this code range is `precise`, at least one codepoint is outside the ASCII range (greater than 0x7f). Applicable to `Encoding.ISO_8859_1`, `Encoding.UTF_16` and `Encoding.UTF_32` only. Cite: `com/oracle/truffle/api/strings/TruffleString.CodeRange.html#LATIN_1` ### BMP `BMP`. Since 22.1. All codepoints in this string are part of the Unicode Basic Multilingual Plane (BMP) ( 0x0000 - 0xffff). If this code range is `precise`, at least one codepoint is outside the LATIN_1 range (greater than 0xff). Applicable to `Encoding.UTF_16` and `Encoding.UTF_32` only. Cite: `com/oracle/truffle/api/strings/TruffleString.CodeRange.html#BMP` ### VALID `VALID`. Since 22.1. This string is encoded correctly (`IsValidNode` returns `true`), and if this code range is `precise`, at least one codepoint is outside the largest other applicable code range (e.g. greater than 0x7f on `Encoding.UTF_8`, greater than 0xffff on `Encoding.UTF_16`). Cite: `com/oracle/truffle/api/strings/TruffleString.CodeRange.html#VALID` ### BROKEN `BROKEN`. Since 22.1. If this code range is `precise`, the string is not encoded correctly (`IsValidNode` returns `false`), and contains at least one invalid codepoint. `Otherwise`, no information about the string is known. Cite: `com/oracle/truffle/api/strings/TruffleString.CodeRange.html#BROKEN` ## Methods ### values() `public static TruffleString.CodeRange[] values()`. Returns the enum constants in declaration order. Returns `TruffleString.CodeRange[]`: Returns the enum constants in declaration order. Cite: `com/oracle/truffle/api/strings/TruffleString.CodeRange.html#values()` ### valueOf(String) `public static TruffleString.CodeRange valueOf(String name)`. Returns the enum constant with the given name. Parameters: `name` `String`: The exact name of the enum constant. Returns `TruffleString.CodeRange`: Returns the enum constant with the given name. Cite: `com/oracle/truffle/api/strings/TruffleString.CodeRange.html#valueOf(java.lang.String)` ### isSubsetOf(TruffleString.CodeRange) `public boolean isSubsetOf(TruffleString.CodeRange other)`. Since 22.1. Returns `true` if this set of potential codepoints is equal to or contained by `other`. Cite: `com/oracle/truffle/api/strings/TruffleString.CodeRange.html#isSubsetOf(com.oracle.truffle.api.strings.TruffleString.CodeRange)` ### isSupersetOf(TruffleString.CodeRange) `public boolean isSupersetOf(TruffleString.CodeRange other)`. Since 22.1. Returns `true` if this set of potential codepoints is equal to or contains `other`. Cite: `com/oracle/truffle/api/strings/TruffleString.CodeRange.html#isSupersetOf(com.oracle.truffle.api.strings.TruffleString.CodeRange)` ## Inherited members - From class [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#clone%28%29), [`compareTo`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#compareTo%28E%29), [`describeConstable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#describeConstable%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#finalize%28%29), [`getDeclaringClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#getDeclaringClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#hashCode%28%29), [`name`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#name%28%29), [`ordinal`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#ordinal%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#toString%28%29), [`valueOf`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#valueOf%28java.lang.Class,java.lang.String%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.CodeRangeEqualsNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.CodeRangeEqualsNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `CodeRangeEqualsNode` Node to check if a string's code range is equal to the given [`CodeRange`](com/oracle/truffle/api/strings/TruffleString.CodeRange.md). See [`execute(AbstractTruffleString, TruffleString.CodeRange)`](com/oracle/truffle/api/strings/TruffleString.CodeRangeEqualsNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.CodeRange%29) for details. ## Methods ### execute(AbstractTruffleString, TruffleString.CodeRange) `public abstract boolean execute(AbstractTruffleString a, TruffleString.CodeRange codeRange)`. Since 22.1. Returns `true` if the string's code range is equal to the given `CodeRange`. Use this operation when caching code range instances, e.g.: Cite: `com/oracle/truffle/api/strings/TruffleString.CodeRangeEqualsNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.CodeRange)` ```java @Specialization(guards = "codeRangeEqualsNode.execute(a, cachedCodeRange)") static void someOperation(TString a, @Cached TruffleString.GetCodeRangeNode getCodeRangeNode, @Cached TruffleString.CodeRangeEqualsNode codeRangeEqualsNode, @Cached("getCodeRangeNode.execute(this, a)") CodeRange cachedCodeRange) { // ... } ``` ### create() `public static TruffleString.CodeRangeEqualsNode create()`. Since 22.1. Create a new `CodeRangeEqualsNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.CodeRangeEqualsNode.html#create()` ### getUncached() `public static TruffleString.CodeRangeEqualsNode getUncached()`. Since 22.1. Get the uncached version of `CodeRangeEqualsNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.CodeRangeEqualsNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ≡ TruffleString.CompactionLevel [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Enum class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 23.0. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public enum TruffleString.CompactionLevel ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html) > `CompactionLevel` Represents a string's compaction level, i.e. the internal number of bytes per array element. This is relevant only for [`Encoding.UTF_16`](com/oracle/truffle/api/strings/TruffleString.Encoding.md#UTF_16) and [`Encoding.UTF_32`](com/oracle/truffle/api/strings/TruffleString.Encoding.md#UTF_32), since TruffleString doesn't support string compaction on any other encoding. ## Enum constants ### S1 `S1`. Since 23.0. One byte per array element. Cite: `com/oracle/truffle/api/strings/TruffleString.CompactionLevel.html#S1` ### S2 `S2`. Since 23.0. Two bytes per array element. Cite: `com/oracle/truffle/api/strings/TruffleString.CompactionLevel.html#S2` ### S4 `S4`. Since 23.0. Four bytes per array element. Cite: `com/oracle/truffle/api/strings/TruffleString.CompactionLevel.html#S4` ## Methods ### values() `public static TruffleString.CompactionLevel[] values()`. Returns the enum constants in declaration order. Returns `TruffleString.CompactionLevel[]`: Returns the enum constants in declaration order. Cite: `com/oracle/truffle/api/strings/TruffleString.CompactionLevel.html#values()` ### valueOf(String) `public static TruffleString.CompactionLevel valueOf(String name)`. Returns the enum constant with the given name. Parameters: `name` `String`: The exact name of the enum constant. Returns `TruffleString.CompactionLevel`: Returns the enum constant with the given name. Cite: `com/oracle/truffle/api/strings/TruffleString.CompactionLevel.html#valueOf(java.lang.String)` ### getBytes() `public final int getBytes()`. Since 23.0. Get the number of bytes per internal array element. Cite: `com/oracle/truffle/api/strings/TruffleString.CompactionLevel.html#getBytes()` ### getLog2() `public final int getLog2()`. Since 23.0. Get the number of bytes per internal array element in log2 format. Cite: `com/oracle/truffle/api/strings/TruffleString.CompactionLevel.html#getLog2()` ## Inherited members - From class [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#clone%28%29), [`compareTo`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#compareTo%28E%29), [`describeConstable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#describeConstable%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#finalize%28%29), [`getDeclaringClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#getDeclaringClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#hashCode%28%29), [`name`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#name%28%29), [`ordinal`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#ordinal%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#toString%28%29), [`valueOf`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#valueOf%28java.lang.Class,java.lang.String%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.CompareBytesNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.CompareBytesNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `CompareBytesNode` Node to compare two strings byte-by-byte. See [`execute(AbstractTruffleString, AbstractTruffleString, TruffleString.Encoding)`](com/oracle/truffle/api/strings/TruffleString.CompareBytesNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, AbstractTruffleString, TruffleString.Encoding) `public abstract int execute(AbstractTruffleString a, AbstractTruffleString b, TruffleString.Encoding expectedEncoding)`. Since 22.1. Compare strings `a` and `b` byte-by-byte. Returns zero if `a` and `b` are equal. If `a` is equal to `b` up to its length, but `b` is longer than `a`, a negative value is returned. In the inverse case, a positive value is returned. Otherwise, elements `a[i]` and `b[i]` at a byte index `i` are different. If `a[i]` is greater than `b[i]`, a positive value is returned, otherwise a negative value is returned. Cite: `com/oracle/truffle/api/strings/TruffleString.CompareBytesNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.CompareBytesNode create()`. Since 22.1. Create a new `CompareBytesNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.CompareBytesNode.html#create()` ### getUncached() `public static TruffleString.CompareBytesNode getUncached()`. Since 22.1. Get the uncached version of `CompareBytesNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.CompareBytesNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.CompareCharsUTF16Node [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.CompareCharsUTF16Node extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `CompareCharsUTF16Node` Node to compare two UTF-16 strings. See [`execute(AbstractTruffleString, AbstractTruffleString)`](com/oracle/truffle/api/strings/TruffleString.CompareCharsUTF16Node.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.AbstractTruffleString%29) for details. ## Methods ### execute(AbstractTruffleString, AbstractTruffleString) `public abstract int execute(AbstractTruffleString a, AbstractTruffleString b)`. Since 22.1. Compare UTF-16 strings `a` and `b` char-by-char. Returns zero if `a` and `b` are equal. If `a` is equal to `b` up to its length, but `b` is longer than `a`, a negative value is returned. In the inverse case, a positive value is returned. Otherwise, elements `a[i]` and `b[i]` at an index `i` are different. If `a[i]` is greater than `b[i]`, a positive value is returned, otherwise a negative value is returned. Cite: `com/oracle/truffle/api/strings/TruffleString.CompareCharsUTF16Node.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.AbstractTruffleString)` ### create() `public static TruffleString.CompareCharsUTF16Node create()`. Since 22.1. Create a new `CompareCharsUTF16Node`. Cite: `com/oracle/truffle/api/strings/TruffleString.CompareCharsUTF16Node.html#create()` ### getUncached() `public static TruffleString.CompareCharsUTF16Node getUncached()`. Since 22.1. Get the uncached version of `CompareCharsUTF16Node`. Cite: `com/oracle/truffle/api/strings/TruffleString.CompareCharsUTF16Node.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.CompareIntsUTF32Node [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.CompareIntsUTF32Node extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `CompareIntsUTF32Node` Node to compare two UTF-32 strings. See [`execute(AbstractTruffleString, AbstractTruffleString)`](com/oracle/truffle/api/strings/TruffleString.CompareIntsUTF32Node.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.AbstractTruffleString%29) for details. ## Methods ### execute(AbstractTruffleString, AbstractTruffleString) `public abstract int execute(AbstractTruffleString a, AbstractTruffleString b)`. Since 22.1. Compare UTF-32 strings `a` and `b` int-by-int. Returns zero if `a` and `b` are equal. If `a` is equal to `b` up to its length, but `b` is longer than `a`, a negative value is returned. In the inverse case, a positive value is returned. Otherwise, elements `a[i]` and `b[i]` at an index `i` are different. If `a[i]` is greater than `b[i]`, a positive value is returned, otherwise a negative value is returned. Cite: `com/oracle/truffle/api/strings/TruffleString.CompareIntsUTF32Node.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.AbstractTruffleString)` ### create() `public static TruffleString.CompareIntsUTF32Node create()`. Since 22.1. Create a new `CompareIntsUTF32Node`. Cite: `com/oracle/truffle/api/strings/TruffleString.CompareIntsUTF32Node.html#create()` ### getUncached() `public static TruffleString.CompareIntsUTF32Node getUncached()`. Since 22.1. Get the uncached version of `CompareIntsUTF32Node`. Cite: `com/oracle/truffle/api/strings/TruffleString.CompareIntsUTF32Node.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.ConcatNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.ConcatNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `ConcatNode` Node to concatenate two strings. See [`execute(AbstractTruffleString, AbstractTruffleString, TruffleString.Encoding, boolean)`](com/oracle/truffle/api/strings/TruffleString.ConcatNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean%29) for details. ## Methods ### execute(AbstractTruffleString, AbstractTruffleString, …) `public abstract TruffleString execute(AbstractTruffleString a, AbstractTruffleString b, TruffleString.Encoding expectedEncoding, boolean lazy)`. Since 22.1. Create a new string by concatenating `a` and `b`. Parameters: `lazy` `boolean`: if `true`, the creation of the new string's internal array may be delayed until it is required by another operation. This parameter is expected to be `partial evaluation constant`. Cite: `com/oracle/truffle/api/strings/TruffleString.ConcatNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### create() `public static TruffleString.ConcatNode create()`. Since 22.1. Create a new `ConcatNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ConcatNode.html#create()` ### getUncached() `public static TruffleString.ConcatNode getUncached()`. Since 22.1. Get the uncached version of `ConcatNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ConcatNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.CopyToByteArrayNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.CopyToByteArrayNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `CopyToByteArrayNode` Node to copy a region of a string into a byte array. See [`execute(AbstractTruffleString, int, byte[], int, int, TruffleString.Encoding)`](com/oracle/truffle/api/strings/TruffleString.CopyToByteArrayNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,int,byte[],int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, TruffleString.Encoding) `public final byte[] execute(AbstractTruffleString string, TruffleString.Encoding expectedEncoding)`. Since 22.2. Copy the entire string to a byte[] and return it. Cite: `com/oracle/truffle/api/strings/TruffleString.CopyToByteArrayNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### execute(AbstractTruffleString, int, …) `public abstract void execute(AbstractTruffleString a, int byteFromIndexA, byte[] dst, int byteFromIndexDst, int byteLength, TruffleString.Encoding expectedEncoding)`. Since 22.1. Copy a region of the given `TruffleString` `a`, bounded by `byteFromIndexA` and `byteLength` into the given byte array, at starting at `byteFromIndexDst`. Cite: `com/oracle/truffle/api/strings/TruffleString.CopyToByteArrayNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int,byte[],int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.CopyToByteArrayNode create()`. Since 22.1. Create a new `CopyToByteArrayNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.CopyToByteArrayNode.html#create()` ### getUncached() `public static TruffleString.CopyToByteArrayNode getUncached()`. Since 22.1. Get the uncached version of `CopyToByteArrayNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.CopyToByteArrayNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.CopyToNativeMemoryNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.CopyToNativeMemoryNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `CopyToNativeMemoryNode` Node to copy a region of a string into native memory. See [`execute(AbstractTruffleString, int, Object, int, int, TruffleString.Encoding)`](com/oracle/truffle/api/strings/TruffleString.CopyToNativeMemoryNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,int,java.lang.Object,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, int, …) `public abstract void execute(AbstractTruffleString a, int byteFromIndexA, Object pointerObject, int byteFromIndexDst, int byteLength, TruffleString.Encoding expectedEncoding)`. Since 22.1. Copy a region of the given `TruffleString` `a`, bounded by `byteFromIndexA` and `byteLength` into the given interop object representing a native pointer (`isPointer(pointerObject)` must return `true`), starting at `byteFromIndexDst`. This operation requires native access permissions (`TruffleLanguage.Env#isNativeAccessAllowed()`). Since GraalVM version 25.1, the native pointer may also be passed as a primitive long value in place of `pointerObject`. Cite: `com/oracle/truffle/api/strings/TruffleString.CopyToNativeMemoryNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int,java.lang.Object,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.CopyToNativeMemoryNode create()`. Since 22.1. Create a new `CopyToNativeMemoryNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.CopyToNativeMemoryNode.html#create()` ### getUncached() `public static TruffleString.CopyToNativeMemoryNode getUncached()`. Since 22.1. Get the uncached version of `CopyToNativeMemoryNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.CopyToNativeMemoryNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.CreateBackwardCodePointIteratorNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.CreateBackwardCodePointIteratorNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `CreateBackwardCodePointIteratorNode` Node to create a [`TruffleStringIterator`](com/oracle/truffle/api/strings/TruffleStringIterator.md). See [`execute(AbstractTruffleString, TruffleString.Encoding)`](com/oracle/truffle/api/strings/TruffleString.CreateBackwardCodePointIteratorNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, TruffleString.Encoding) `public final TruffleStringIterator execute(AbstractTruffleString a, TruffleString.Encoding expectedEncoding)`. Since 22.1. Returns a `TruffleStringIterator`, which allows iterating this string's code points, with `best-effort error handling`. Cite: `com/oracle/truffle/api/strings/TruffleString.CreateBackwardCodePointIteratorNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### execute(AbstractTruffleString, TruffleString.Encoding, TruffleString.ErrorHandling) `public abstract TruffleStringIterator execute(AbstractTruffleString a, TruffleString.Encoding expectedEncoding, TruffleString.ErrorHandling errorHandling)`. Since 22.3. Returns a `TruffleStringIterator`, which allows iterating this string's code points. The iterator is initialized to begin iteration at the end of the string, use `TruffleStringIterator.PreviousNode` to iterate in reverse order. Parameters: `errorHandling` `TruffleString.ErrorHandling`: analogous to `CodePointAtIndexNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.CreateBackwardCodePointIteratorNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding,com.oracle.truffle.api.strings.TruffleString.ErrorHandling)` ### create() `public static TruffleString.CreateBackwardCodePointIteratorNode create()`. Since 22.1. Create a new `CreateBackwardCodePointIteratorNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.CreateBackwardCodePointIteratorNode.html#create()` ### getUncached() `public static TruffleString.CreateBackwardCodePointIteratorNode getUncached()`. Since 22.1. Get the uncached version of `CreateBackwardCodePointIteratorNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.CreateBackwardCodePointIteratorNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.CreateCodePointIteratorNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.CreateCodePointIteratorNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `CreateCodePointIteratorNode` Node to create a [`TruffleStringIterator`](com/oracle/truffle/api/strings/TruffleStringIterator.md). See [`execute(AbstractTruffleString, TruffleString.Encoding)`](com/oracle/truffle/api/strings/TruffleString.CreateCodePointIteratorNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, TruffleString.Encoding) `public final TruffleStringIterator execute(AbstractTruffleString a, TruffleString.Encoding expectedEncoding)`. Since 22.1. Returns a `TruffleStringIterator`, which allows iterating this string's code points, with `best-effort error handling`. Cite: `com/oracle/truffle/api/strings/TruffleString.CreateCodePointIteratorNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### execute(AbstractTruffleString, TruffleString.Encoding, TruffleString.ErrorHandling) `public abstract TruffleStringIterator execute(AbstractTruffleString a, TruffleString.Encoding expectedEncoding, TruffleString.ErrorHandling errorHandling)`. Since 22.3. Returns a `TruffleStringIterator`, which allows iterating this string's code points. The iterator is initialized to begin iteration at the start of the string, use `TruffleStringIterator.NextNode` to iterate. Parameters: `errorHandling` `TruffleString.ErrorHandling`: analogous to `CodePointAtIndexNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.CreateCodePointIteratorNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding,com.oracle.truffle.api.strings.TruffleString.ErrorHandling)` ### create() `public static TruffleString.CreateCodePointIteratorNode create()`. Since 22.1. Create a new `CreateCodePointIteratorNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.CreateCodePointIteratorNode.html#create()` ### getUncached() `public static TruffleString.CreateCodePointIteratorNode getUncached()`. Since 22.1. Get the uncached version of `CreateCodePointIteratorNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.CreateCodePointIteratorNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ≡ TruffleString.Encoding [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Enum class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public enum TruffleString.Encoding ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html) > `Encoding` The list of encodings supported by [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md) is especially optimized for the following encodings: - `UTF-32`: this means UTF-32 *in your system's endianness*. [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md) transparently compacts UTF-32 strings to 8-bit or 16-bit representations, where possible. - `UTF-16`: this means UTF-16 *in your system's endianness*. [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md) transparently compacts UTF-16 strings to 8-bit representations, where possible. - `UTF-8` - `ISO-8859-1` - `US-ASCII` - `BYTES`, which is essentially identical to US-ASCII, with the only difference being that `BYTES` treats all byte values as valid codepoints. All other encodings are supported using the JRuby JCodings library, which incurs more [`TruffleBoundary`](com/oracle/truffle/api/CompilerDirectives.TruffleBoundary.md) calls. NOTE: to enable support for these encodings, `TruffleLanguage.Registration#needsAllEncodings()` must be set to `true` in the truffle language's registration. ## Enum constants ### UTF_32LE `UTF_32LE`. Since 22.1. UTF-32LE. Directly supported if the current system is little-endian. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#UTF_32LE` ### UTF_32BE `UTF_32BE`. Since 22.1. UTF-32BE. Directly supported if the current system is big-endian. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#UTF_32BE` ### UTF_16LE `UTF_16LE`. Since 22.1. UTF-16LE. Directly supported if the current system is little-endian. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#UTF_16LE` ### UTF_16BE `UTF_16BE`. Since 22.1. UTF-16BE. Directly supported if the current system is big-endian. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#UTF_16BE` ### ISO_8859_1 `ISO_8859_1`. Since 22.1. ISO-8859-1, also known as LATIN-1, which is equivalent to US-ASCII + the LATIN-1 Supplement Unicode block. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#ISO_8859_1` ### UTF_8 `UTF_8`. Since 22.1. UTF-8. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#UTF_8` ### US_ASCII `US_ASCII`. Since 22.1. US-ASCII, which maps only 7-bit characters. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#US_ASCII` ### BYTES `BYTES`. Since 22.1. Special "encoding" BYTES: This encoding is identical to US-ASCII, but treats all values outside the us-ascii range as valid codepoints as well. Caution: no codepoint mappings are defined for non-us-ascii values in this encoding, so `SwitchEncodingNode` will replace all of them with `'?'` when converting from or to BYTES! To preserve all bytes and "reinterpret" a BYTES string in another encoding, use `ForceEncodingNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#BYTES` ### Big5 `Big5`. Since 22.1. Big5. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#Big5` ### Big5_HKSCS `Big5_HKSCS`. Since 22.1. Big5-HKSCS. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#Big5_HKSCS` ### Big5_UAO `Big5_UAO`. Since 22.1. Big5-UAO. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#Big5_UAO` ### CESU_8 `CESU_8`. Since 23.0. CESU-8. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#CESU_8` ### CP51932 `CP51932`. Since 22.1. CP51932. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#CP51932` ### CP850 `CP850`. Since 22.1. CP850. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#CP850` ### CP852 `CP852`. Since 22.1. CP852. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#CP852` ### CP855 `CP855`. Since 22.1. CP855. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#CP855` ### CP949 `CP949`. Since 22.1. CP949. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#CP949` ### CP950 `CP950`. Since 22.1. CP950. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#CP950` ### CP951 `CP951`. Since 22.1. CP951. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#CP951` ### EUC_JIS_2004 `EUC_JIS_2004`. Since 22.1. EUC-JIS-2004. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#EUC_JIS_2004` ### EUC_JP `EUC_JP`. Since 22.1. EUC-JP. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#EUC_JP` ### EUC_KR `EUC_KR`. Since 22.1. EUC-KR. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#EUC_KR` ### EUC_TW `EUC_TW`. Since 22.1. EUC-TW. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#EUC_TW` ### Emacs_Mule `Emacs_Mule`. Since 22.1. Emacs-Mule. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#Emacs_Mule` ### EucJP_ms `EucJP_ms`. Since 22.1. EucJP-ms. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#EucJP_ms` ### GB12345 `GB12345`. Since 22.1. GB12345. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#GB12345` ### GB18030 `GB18030`. Since 22.1. GB18030. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#GB18030` ### GB1988 `GB1988`. Since 22.1. GB1988. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#GB1988` ### GB2312 `GB2312`. Since 22.1. GB2312. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#GB2312` ### GBK `GBK`. Since 22.1. GBK. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#GBK` ### IBM437 `IBM437`. Since 22.1. IBM437. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#IBM437` ### IBM720 `IBM720`. Since 23.0. IBM720. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#IBM720` ### IBM737 `IBM737`. Since 22.1. IBM737. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#IBM737` ### IBM775 `IBM775`. Since 22.1. IBM775. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#IBM775` ### IBM852 `IBM852`. Since 22.1. IBM852. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#IBM852` ### IBM855 `IBM855`. Since 22.1. IBM855. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#IBM855` ### IBM857 `IBM857`. Since 22.1. IBM857. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#IBM857` ### IBM860 `IBM860`. Since 22.1. IBM860. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#IBM860` ### IBM861 `IBM861`. Since 22.1. IBM861. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#IBM861` ### IBM862 `IBM862`. Since 22.1. IBM862. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#IBM862` ### IBM863 `IBM863`. Since 22.1. IBM863. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#IBM863` ### IBM864 `IBM864`. Since 22.1. IBM864. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#IBM864` ### IBM865 `IBM865`. Since 22.1. IBM865. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#IBM865` ### IBM866 `IBM866`. Since 22.1. IBM866. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#IBM866` ### IBM869 `IBM869`. Since 22.1. IBM869. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#IBM869` ### ISO_8859_10 `ISO_8859_10`. Since 22.1. ISO-8859-10. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#ISO_8859_10` ### ISO_8859_11 `ISO_8859_11`. Since 22.1. ISO-8859-11. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#ISO_8859_11` ### ISO_8859_13 `ISO_8859_13`. Since 22.1. ISO-8859-13. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#ISO_8859_13` ### ISO_8859_14 `ISO_8859_14`. Since 22.1. ISO-8859-14. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#ISO_8859_14` ### ISO_8859_15 `ISO_8859_15`. Since 22.1. ISO-8859-15. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#ISO_8859_15` ### ISO_8859_16 `ISO_8859_16`. Since 22.1. ISO-8859-16. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#ISO_8859_16` ### ISO_8859_2 `ISO_8859_2`. Since 22.1. ISO-8859-2. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#ISO_8859_2` ### ISO_8859_3 `ISO_8859_3`. Since 22.1. ISO-8859-3. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#ISO_8859_3` ### ISO_8859_4 `ISO_8859_4`. Since 22.1. ISO-8859-4. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#ISO_8859_4` ### ISO_8859_5 `ISO_8859_5`. Since 22.1. ISO-8859-5. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#ISO_8859_5` ### ISO_8859_6 `ISO_8859_6`. Since 22.1. ISO-8859-6. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#ISO_8859_6` ### ISO_8859_7 `ISO_8859_7`. Since 22.1. ISO-8859-7. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#ISO_8859_7` ### ISO_8859_8 `ISO_8859_8`. Since 22.1. ISO-8859-8. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#ISO_8859_8` ### ISO_8859_9 `ISO_8859_9`. Since 22.1. ISO-8859-9. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#ISO_8859_9` ### KOI8_R `KOI8_R`. Since 22.1. KOI8-R. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#KOI8_R` ### KOI8_U `KOI8_U`. Since 22.1. KOI8-U. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#KOI8_U` ### MacCentEuro `MacCentEuro`. Since 22.1. MacCentEuro. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#MacCentEuro` ### MacCroatian `MacCroatian`. Since 22.1. MacCroatian. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#MacCroatian` ### MacCyrillic `MacCyrillic`. Since 22.1. MacCyrillic. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#MacCyrillic` ### MacGreek `MacGreek`. Since 22.1. MacGreek. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#MacGreek` ### MacIceland `MacIceland`. Since 22.1. MacIceland. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#MacIceland` ### MacJapanese `MacJapanese`. Since 22.1. MacJapanese. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#MacJapanese` ### MacRoman `MacRoman`. Since 22.1. MacRoman. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#MacRoman` ### MacRomania `MacRomania`. Since 22.1. MacRomania. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#MacRomania` ### MacThai `MacThai`. Since 22.1. MacThai. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#MacThai` ### MacTurkish `MacTurkish`. Since 22.1. MacTurkish. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#MacTurkish` ### MacUkraine `MacUkraine`. Since 22.1. MacUkraine. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#MacUkraine` ### SJIS_DoCoMo `SJIS_DoCoMo`. Since 22.1. SJIS-DoCoMo. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#SJIS_DoCoMo` ### SJIS_KDDI `SJIS_KDDI`. Since 22.1. SJIS-KDDI. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#SJIS_KDDI` ### SJIS_SoftBank `SJIS_SoftBank`. Since 22.1. SJIS-SoftBank. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#SJIS_SoftBank` ### Shift_JIS `Shift_JIS`. Since 22.1. Shift-JIS. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#Shift_JIS` ### Stateless_ISO_2022_JP `Stateless_ISO_2022_JP`. Since 22.1. Stateless-ISO-2022-JP. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#Stateless_ISO_2022_JP` ### Stateless_ISO_2022_JP_KDDI `Stateless_ISO_2022_JP_KDDI`. Since 22.1. Stateless-ISO-2022-JP-KDDI. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#Stateless_ISO_2022_JP_KDDI` ### TIS_620 `TIS_620`. Since 22.1. TIS-620. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#TIS_620` ### UTF8_DoCoMo `UTF8_DoCoMo`. Since 22.1. UTF8-DoCoMo. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#UTF8_DoCoMo` ### UTF8_KDDI `UTF8_KDDI`. Since 22.1. UTF8-KDDI. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#UTF8_KDDI` ### UTF8_MAC `UTF8_MAC`. Since 22.1. UTF8-MAC. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#UTF8_MAC` ### UTF8_SoftBank `UTF8_SoftBank`. Since 22.1. UTF8-SoftBank. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#UTF8_SoftBank` ### Windows_1250 `Windows_1250`. Since 22.1. Windows-1250. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#Windows_1250` ### Windows_1251 `Windows_1251`. Since 22.1. Windows-1251. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#Windows_1251` ### Windows_1252 `Windows_1252`. Since 22.1. Windows-1252. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#Windows_1252` ### Windows_1253 `Windows_1253`. Since 22.1. Windows-1253. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#Windows_1253` ### Windows_1254 `Windows_1254`. Since 22.1. Windows-1254. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#Windows_1254` ### Windows_1255 `Windows_1255`. Since 22.1. Windows-1255. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#Windows_1255` ### Windows_1256 `Windows_1256`. Since 22.1. Windows-1256. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#Windows_1256` ### Windows_1257 `Windows_1257`. Since 22.1. Windows-1257. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#Windows_1257` ### Windows_1258 `Windows_1258`. Since 22.1. Windows-1258. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#Windows_1258` ### Windows_31J `Windows_31J`. Since 22.1. Windows-31J. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#Windows_31J` ### Windows_874 `Windows_874`. Since 22.1. Windows-874. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#Windows_874` ### CP50220 `CP50220`. Since 22.1. CP50220. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#CP50220` ### CP50221 `CP50221`. Since 22.1. CP50221. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#CP50221` ### IBM037 `IBM037`. Since 22.1. IBM037. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#IBM037` ### ISO_2022_JP `ISO_2022_JP`. Since 22.1. ISO-2022-JP. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#ISO_2022_JP` ### ISO_2022_JP_2 `ISO_2022_JP_2`. Since 22.1. ISO-2022-JP-2. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#ISO_2022_JP_2` ### ISO_2022_JP_KDDI `ISO_2022_JP_KDDI`. Since 22.1. ISO-2022-JP-KDDI. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#ISO_2022_JP_KDDI` ### UTF_7 `UTF_7`. Since 22.1. UTF-7. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#UTF_7` ## Fields ### UTF_32 `public static final TruffleString.Encoding UTF_32`. Since 22.1. UTF-32 in *the current system's endianness*, without byte-order mark, with transparent string compaction. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#UTF_32` ### UTF_16 `public static final TruffleString.Encoding UTF_16`. Since 22.1. UTF-16 in *the current system's endianness*, without byte-order mark, with transparent string compaction. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#UTF_16` ## Methods ### values() `public static TruffleString.Encoding[] values()`. Returns the enum constants in declaration order. Returns `TruffleString.Encoding[]`: Returns the enum constants in declaration order. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#values()` ### valueOf(String) `public static TruffleString.Encoding valueOf(String name)`. Returns the enum constant with the given name. Parameters: `name` `String`: The exact name of the enum constant. Returns `TruffleString.Encoding`: Returns the enum constant with the given name. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#valueOf(java.lang.String)` ### getEmpty() `public TruffleString getEmpty()`. Since 22.1. Get an empty `TruffleString` with this encoding. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#getEmpty()` ### fromJCodingName(String) `public static TruffleString.Encoding fromJCodingName(String name)`. Since 22.1. Get the `Encoding` corresponding to the given encoding name from the `JCodings` library. Cite: `com/oracle/truffle/api/strings/TruffleString.Encoding.html#fromJCodingName(java.lang.String)` ## Inherited members - From class [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#clone%28%29), [`compareTo`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#compareTo%28E%29), [`describeConstable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#describeConstable%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#finalize%28%29), [`getDeclaringClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#getDeclaringClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#hashCode%28%29), [`name`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#name%28%29), [`ordinal`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#ordinal%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#toString%28%29), [`valueOf`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#valueOf%28java.lang.Class,java.lang.String%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.EqualNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.EqualNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `EqualNode` Node to check two strings for equality. The [`TruffleString.equals(Object)`](com/oracle/truffle/api/strings/AbstractTruffleString.md#equals%28java.lang.Object%29)-method delegates to this node. ## Methods ### execute(AbstractTruffleString, AbstractTruffleString, TruffleString.Encoding) `public abstract boolean execute(AbstractTruffleString a, AbstractTruffleString b, TruffleString.Encoding expectedEncoding)`. Since 22.1. Returns `true` if `a` and `b` are byte-by-byte equal when considered in `expectedEncoding`. Note that this method requires both strings to be compatible to the `expectedEncoding`, just like all other operations with an `expectedEncoding` parameter! The `TruffleString.equals(Object)`-method delegates to this method. Cite: `com/oracle/truffle/api/strings/TruffleString.EqualNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.EqualNode create()`. Since 22.1. Create a new `EqualNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.EqualNode.html#create()` ### getUncached() `public static TruffleString.EqualNode getUncached()`. Since 22.1. Get the uncached version of `EqualNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.EqualNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ≡ TruffleString.ErrorHandling [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Enum class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.3. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public enum TruffleString.ErrorHandling ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html) > `ErrorHandling` Error handling instructions for operations that return integer values, such as indices or code points. ## Enum constants ### BEST_EFFORT `BEST_EFFORT`. Since 22.3. This mode generally means that the operation will try to determine the "most reasonable" or "most useful" return value in respect to the expected encoding and the error that occurred. For example: best-effort error handling will cause `CodePointAtByteIndexNode` to return the value of the integer read when reading an invalid codepoint from a `Encoding.UTF_32` string. Cite: `com/oracle/truffle/api/strings/TruffleString.ErrorHandling.html#BEST_EFFORT` ### RETURN_NEGATIVE `RETURN_NEGATIVE`. Since 22.3. This mode will cause a negative value to be returned in all error cases. For example: return-negative error handling will cause `CodePointAtByteIndexNode` to return a negative value when reading an invalid codepoint from a `Encoding.UTF_32` string. Cite: `com/oracle/truffle/api/strings/TruffleString.ErrorHandling.html#RETURN_NEGATIVE` ## Methods ### values() `public static TruffleString.ErrorHandling[] values()`. Returns the enum constants in declaration order. Returns `TruffleString.ErrorHandling[]`: Returns the enum constants in declaration order. Cite: `com/oracle/truffle/api/strings/TruffleString.ErrorHandling.html#values()` ### valueOf(String) `public static TruffleString.ErrorHandling valueOf(String name)`. Returns the enum constant with the given name. Parameters: `name` `String`: The exact name of the enum constant. Returns `TruffleString.ErrorHandling`: Returns the enum constant with the given name. Cite: `com/oracle/truffle/api/strings/TruffleString.ErrorHandling.html#valueOf(java.lang.String)` ## Inherited members - From class [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#clone%28%29), [`compareTo`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#compareTo%28E%29), [`describeConstable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#describeConstable%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#finalize%28%29), [`getDeclaringClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#getDeclaringClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#hashCode%28%29), [`name`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#name%28%29), [`ordinal`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#ordinal%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#toString%28%29), [`valueOf`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#valueOf%28java.lang.Class,java.lang.String%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.ForceEncodingNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.ForceEncodingNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `ForceEncodingNode` Node to forcibly assign any encoding to a string. See [`execute(AbstractTruffleString, TruffleString.Encoding, TruffleString.Encoding)`](com/oracle/truffle/api/strings/TruffleString.ForceEncodingNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, TruffleString.Encoding, TruffleString.Encoding) `public abstract TruffleString execute(AbstractTruffleString a, TruffleString.Encoding expectedEncoding, TruffleString.Encoding targetEncoding)`. Since 22.1. Returns a version of string `a` assigned to the given encoding, which may be the string itself or a new string. The string itself may be returned even if it was originally created using a different encoding, if the string is byte-equivalent in both encodings. If the string is not byte-equivalent in both encodings, a new string containing the same bytes but assigned to the new encoding is returned. **This node does not transcode the string's contents in any way, it is the "encoding-equivalent" to a C-style reinterpret-cast.**. Cite: `com/oracle/truffle/api/strings/TruffleString.ForceEncodingNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.ForceEncodingNode create()`. Since 22.1. Create a new `ForceEncodingNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ForceEncodingNode.html#create()` ### getUncached() `public static TruffleString.ForceEncodingNode getUncached()`. Since 22.1. Get the uncached version of `ForceEncodingNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ForceEncodingNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.FromByteArrayNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.FromByteArrayNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `FromByteArrayNode` Node to create a new [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md) from a byte array. See [`execute(byte[], int, int, TruffleString.Encoding, boolean)`](com/oracle/truffle/api/strings/TruffleString.FromByteArrayNode.md#execute%28byte[],int,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean%29) for details. ## Methods ### execute(byte[], TruffleString.Encoding) `public final TruffleString execute(byte[] value, TruffleString.Encoding encoding)`. Since 22.1. Creates a new `TruffleString` from a byte array. See `execute(byte[], int, int, TruffleString.Encoding, boolean)` for details. Cite: `com/oracle/truffle/api/strings/TruffleString.FromByteArrayNode.html#execute(byte[],com.oracle.truffle.api.strings.TruffleString.Encoding)` ### execute(byte[], TruffleString.Encoding, boolean) `public final TruffleString execute(byte[] value, TruffleString.Encoding encoding, boolean copy)`. Since 22.1. Creates a new `TruffleString` from a byte array. See `execute(byte[], int, int, TruffleString.Encoding, boolean)` for details. Cite: `com/oracle/truffle/api/strings/TruffleString.FromByteArrayNode.html#execute(byte[],com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### execute(byte[], int, …) `public abstract TruffleString execute(byte[] value, int byteOffset, int byteLength, TruffleString.Encoding encoding, boolean copy)`. Since 22.1. Creates a new `TruffleString` from a byte array. The array content is assumed to be encoded in the given encoding already. This operation allows non-copying string creation, i.e. the array parameter can be used directly by passing `copy = false`. Caution: `TruffleString` assumes the array to be immutable, do not modify the byte array after passing it to the non-copying variant of this operation! Cite: `com/oracle/truffle/api/strings/TruffleString.FromByteArrayNode.html#execute(byte[],int,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### create() `public static TruffleString.FromByteArrayNode create()`. Since 22.1. Create a new `FromByteArrayNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.FromByteArrayNode.html#create()` ### getUncached() `public static TruffleString.FromByteArrayNode getUncached()`. Since 22.1. Get the uncached version of `FromByteArrayNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.FromByteArrayNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.FromByteArrayWithCompactionUTF32Node [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 25.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.FromByteArrayWithCompactionUTF32Node extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `FromByteArrayWithCompactionUTF32Node` Node to create a new [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md) from a byte array. See [`execute`](com/oracle/truffle/api/strings/TruffleString.FromByteArrayWithCompactionUTF32Node.md#execute%28byte[],int,int,com.oracle.truffle.api.strings.TruffleString.CompactionLevel,boolean%29) for details. ## Methods ### execute(byte[], int, …) `public abstract TruffleString execute(byte[] array, int byteOffset, int byteLength, TruffleString.CompactionLevel compactionLevel, boolean copy)`. Since 25.1. UTF-32-specific version of `FromByteArrayNode` that accepts compacted buffers. Passing `CompactionLevel.S1` means that the string is compacted to single bytes, i.e. it is equivalent to a `Encoding.ISO_8859_1` string. Analogously, passing `CompactionLevel.S2` means that the buffer is equivalent to a `UCS-2` string. Examples: Note that this node may further compact (and therefore copy) the array if possible, or inflate if it contains illegal codepoints (i.e. surrogate values): Parameters: `compactionLevel` `TruffleString.CompactionLevel`: describes the given string's compaction level. `CompactionLevel.S1` means one byte per codepoint, `CompactionLevel.S2` means two bytes per codepoint, and `CompactionLevel.S4` corresponds to four bytes per codepoint. Not strictly required to be `partial evaluation constant`, but still recommended, since this parameter being constant avoids two branches and associated stub calls. `copy` `boolean`: analogous to the `copy` parameter of `FromByteArrayNode`. Must be `partial evaluation constant`. Cite: `com/oracle/truffle/api/strings/TruffleString.FromByteArrayWithCompactionUTF32Node.html#execute(byte[],int,int,com.oracle.truffle.api.strings.TruffleString.CompactionLevel,boolean)` ```java byte[] array = {'a', 'b', 'c'}; TruffleString str = fromByteArrayWithCompactionUTF32Node.execute(array, 0, array.length, CompactionLevel.S1, false); // returns a UTF-32 string "abc", re-using the byte array without copy ``` ```java byte[] array = {0x34, 0x12, 0x78, 0x56}; TruffleString str = fromByteArrayWithCompactionUTF32Node.execute(array, 0, array.length, CompactionLevel.S2, false); // returns a UTF-32 string "ሴ噸", re-using the byte array without copy ``` ```java byte[] array = {0x45, 0x23, 0x01, 0x00}; TruffleString str = fromByteArrayWithCompactionUTF32Node.execute(array, 0, array.length, CompactionLevel.S4, false); // returns a UTF-32 string containing the single codepoint 0x12345, re-using the byte array // without copy ``` ```java byte[] array = {'a', 0x00, 'b', 0x00}; TruffleString str = fromByteArrayWithCompactionUTF32Node.execute(array, 0, array.length, CompactionLevel.S2, false); // returns a UTF-32 string "ab", copying and further compacting the given array despite // copy=false ``` ### create() `public static TruffleString.FromByteArrayWithCompactionUTF32Node create()`. Since 25.1. Create a new `FromByteArrayWithCompactionUTF32Node`. Cite: `com/oracle/truffle/api/strings/TruffleString.FromByteArrayWithCompactionUTF32Node.html#create()` ### getUncached() `public static TruffleString.FromByteArrayWithCompactionUTF32Node getUncached()`. Since 25.1. Get the uncached version of `FromByteArrayWithCompactionUTF32Node`. Cite: `com/oracle/truffle/api/strings/TruffleString.FromByteArrayWithCompactionUTF32Node.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.FromCharArrayUTF16Node [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.FromCharArrayUTF16Node extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `FromCharArrayUTF16Node` Node to create a new UTF-16 [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md) from a char array. ## Methods ### execute(char[]) `public final TruffleString execute(char[] value)`. Since 22.1. Creates a UTF-16 `TruffleString` from a char array. Cite: `com/oracle/truffle/api/strings/TruffleString.FromCharArrayUTF16Node.html#execute(char[])` ### execute(char[], int, int) `public abstract TruffleString execute(char[] value, int charOffset, int charLength)`. Since 22.1. Creates a UTF-16 `TruffleString` from a char-array. Cite: `com/oracle/truffle/api/strings/TruffleString.FromCharArrayUTF16Node.html#execute(char[],int,int)` ### create() `public static TruffleString.FromCharArrayUTF16Node create()`. Since 22.1. Create a new `FromCharArrayUTF16Node`. Cite: `com/oracle/truffle/api/strings/TruffleString.FromCharArrayUTF16Node.html#create()` ### getUncached() `public static TruffleString.FromCharArrayUTF16Node getUncached()`. Since 22.1. Get the uncached version of `FromCharArrayUTF16Node`. Cite: `com/oracle/truffle/api/strings/TruffleString.FromCharArrayUTF16Node.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.FromCodePointNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.FromCodePointNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `FromCodePointNode` Node to create a new [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md) from a single codepoint. ## Methods ### execute(int, TruffleString.Encoding) `public final TruffleString execute(int codepoint, TruffleString.Encoding encoding)`. Since 22.1. Creates a new TruffleString from a given code point. Cite: `com/oracle/truffle/api/strings/TruffleString.FromCodePointNode.html#execute(int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### execute(int, TruffleString.Encoding, boolean) `public abstract TruffleString execute(int codepoint, TruffleString.Encoding encoding, boolean allowUTF16Surrogates)`. Since 22.2. Creates a new TruffleString from a given code point. If `allowUTF16Surrogates` is `true`, [`UTF-16 surrogate values`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Character.html#isSurrogate%28char%29) passed as `codepoint` will not result in a `null` return value, but instead be encoded on a best-effort basis. This option is only supported on `TruffleString.Encoding.UTF_16` and `TruffleString.Encoding.UTF_32`. Returns `TruffleString`: a new `TruffleString`, or `null` if the given codepoint is not defined in the given encoding. Cite: `com/oracle/truffle/api/strings/TruffleString.FromCodePointNode.html#execute(int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### create() `public static TruffleString.FromCodePointNode create()`. Since 22.1. Create a new `FromCodePointNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.FromCodePointNode.html#create()` ### getUncached() `public static TruffleString.FromCodePointNode getUncached()`. Since 22.1. Get the uncached version of `FromCodePointNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.FromCodePointNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.FromIntArrayUTF32Node [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.FromIntArrayUTF32Node extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `FromIntArrayUTF32Node` Node to create a new UTF-32 [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md) from an int-array. ## Methods ### execute(int[]) `public final TruffleString execute(int[] value)`. Since 22.1. Creates a UTF-32 `TruffleString` from an int-array. Cite: `com/oracle/truffle/api/strings/TruffleString.FromIntArrayUTF32Node.html#execute(int[])` ### execute(int[], int, int) `public abstract TruffleString execute(int[] value, int intOffset, int intLength)`. Since 22.1. Creates a UTF-32 `TruffleString` from an int-array. Cite: `com/oracle/truffle/api/strings/TruffleString.FromIntArrayUTF32Node.html#execute(int[],int,int)` ### create() `public static TruffleString.FromIntArrayUTF32Node create()`. Since 22.1. Create a new `FromIntArrayUTF32Node`. Cite: `com/oracle/truffle/api/strings/TruffleString.FromIntArrayUTF32Node.html#create()` ### getUncached() `public static TruffleString.FromIntArrayUTF32Node getUncached()`. Since 22.1. Get the uncached version of `FromIntArrayUTF32Node`. Cite: `com/oracle/truffle/api/strings/TruffleString.FromIntArrayUTF32Node.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.FromJavaStringNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.FromJavaStringNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `FromJavaStringNode` Node to create a new [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md) from a Java string. See [`execute(String, int, int, TruffleString.Encoding, boolean)`](com/oracle/truffle/api/strings/TruffleString.FromJavaStringNode.md#execute%28java.lang.String,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean%29) for details. ## Methods ### execute(String, TruffleString.Encoding) `public final TruffleString execute(String value, TruffleString.Encoding encoding)`. Since 22.1. Creates a `TruffleString` from a Java string, re-using its internal byte array if possible. Cite: `com/oracle/truffle/api/strings/TruffleString.FromJavaStringNode.html#execute(java.lang.String,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### execute(String, int, …) `public abstract TruffleString execute(String value, int charOffset, int length, TruffleString.Encoding encoding, boolean copy)`. Since 22.1. Creates a `TruffleString` from a given region in a Java string, re-using its internal byte array if possible and the region covers the entire string. If `copy` is `false`, the Java string's internal byte array will be re-used even if the region does not cover the entire string. Note that this will keep the Java string's byte array alive as long as the resulting `TruffleString` is alive. Cite: `com/oracle/truffle/api/strings/TruffleString.FromJavaStringNode.html#execute(java.lang.String,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### create() `public static TruffleString.FromJavaStringNode create()`. Since 22.1. Create a new `FromJavaStringNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.FromJavaStringNode.html#create()` ### getUncached() `public static TruffleString.FromJavaStringNode getUncached()`. Since 22.1. Get the uncached version of `FromJavaStringNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.FromJavaStringNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.FromLongNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.FromLongNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `FromLongNode` Node to create a new [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md) from a `long` value. See [`execute(long, TruffleString.Encoding, boolean)`](com/oracle/truffle/api/strings/TruffleString.FromLongNode.md#execute%28long,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean%29) for details. ## Methods ### execute(long, TruffleString.Encoding, boolean) `public abstract TruffleString execute(long value, TruffleString.Encoding encoding, boolean lazy)`. Since 22.1. Creates a 10's complement string from the given long value, using ASCII digits (0x30 - 0x39). This operation does not support encodings that are incompatible with the ASCII character set. Parameters: `lazy` `boolean`: if true, the string representation of the number is computed lazily the first time it is needed. This parameter is expected to be `partial evaluation constant`. Cite: `com/oracle/truffle/api/strings/TruffleString.FromLongNode.html#execute(long,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### create() `public static TruffleString.FromLongNode create()`. Since 22.1. Create a new `FromLongNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.FromLongNode.html#create()` ### getUncached() `public static TruffleString.FromLongNode getUncached()`. Since 22.1. Get the uncached version of `FromLongNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.FromLongNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.FromNativePointerNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.FromNativePointerNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `FromNativePointerNode` Node to create a new [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md) from an interop object representing a native pointer. See [`execute(Object, int, int, TruffleString.Encoding, boolean)`](com/oracle/truffle/api/strings/TruffleString.FromNativePointerNode.md#execute%28java.lang.Object,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean%29) for details. ## Methods ### execute(Object, int, …) `public abstract TruffleString execute(Object pointerObject, int byteOffset, int byteLength, TruffleString.Encoding encoding, boolean copy)`. Since 22.1. Create a new `TruffleString` from an interop object representing a native pointer ( `isPointer(pointerObject)` must return `true`). The pointer is immediately unboxed with (`asPointer(pointerObject)`) and saved in the `TruffleString` instance, i.e. `TruffleString` assumes that the pointer address does not change. The pointer's content is assumed to be encoded in the given encoding already. If `copy` is `false`, the native pointer is used directly as the new string's backing storage. Caution: `TruffleString` assumes the pointer's content to be immutable, do not modify the pointer's content after passing it to this operation! **WARNING:** `TruffleString` cannot reason about the lifetime of the native pointer, so it is up to the user to **make sure that the native pointer is valid to access and not freed as long the `pointerObject` is alive** (if `copy` is `false`). To help with this the TruffleString keeps a reference to the given `pointerObject`, so the `pointerObject` is kept alive at least as long as the TruffleString is used. In order to be able to use the string past the native pointer's life time, convert it to a managed string via `AsManagedNode` **before the native pointer is freed**. Since GraalVM version 25.1, the native pointer may also be passed as a boxed long value in place of `pointerObject`. Note that in this case, the resulting `TruffleString` cannot keep a reference an associated object for life-time tracking. The user is responsible for making sure the native buffer is not freed as long as the `TruffleString` object is alive. If `copy` is `true`, the pointer's contents are copied to a Java byte array, and the pointer can be freed safely after the operation completes. This operation requires native access permissions (`TruffleLanguage.Env#isNativeAccessAllowed()`). Cite: `com/oracle/truffle/api/strings/TruffleString.FromNativePointerNode.html#execute(java.lang.Object,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### create() `public static TruffleString.FromNativePointerNode create()`. Since 22.1. Create a new `FromNativePointerNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.FromNativePointerNode.html#create()` ### getUncached() `public static TruffleString.FromNativePointerNode getUncached()`. Since 22.1. Get the uncached version of `FromNativePointerNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.FromNativePointerNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.FromNativePointerWithCompactionUTF32Node [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 25.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.FromNativePointerWithCompactionUTF32Node extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `FromNativePointerWithCompactionUTF32Node` Node to create a new [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md) from an interop object representing a native pointer. See [`execute`](com/oracle/truffle/api/strings/TruffleString.FromNativePointerWithCompactionUTF32Node.md#execute%28java.lang.Object,int,int,com.oracle.truffle.api.strings.TruffleString.CompactionLevel,boolean%29) for details. ## Methods ### execute(Object, int, …) `public abstract TruffleString execute(Object pointerObject, int byteOffset, int byteLength, TruffleString.CompactionLevel compactionLevel, boolean copy)`. Since 25.1. Native buffer variant of `FromByteArrayWithCompactionUTF32Node`. See `FromByteArrayWithCompactionUTF32Node.execute` for more details. Parameters: `pointerObject` `Object`: native buffer, analogous to the `pointerObject` parameter of `FromNativePointerNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.FromNativePointerWithCompactionUTF32Node.html#execute(java.lang.Object,int,int,com.oracle.truffle.api.strings.TruffleString.CompactionLevel,boolean)` ### create() `public static TruffleString.FromNativePointerWithCompactionUTF32Node create()`. Since 25.1. Create a new `FromNativePointerWithCompactionUTF32Node`. Cite: `com/oracle/truffle/api/strings/TruffleString.FromNativePointerWithCompactionUTF32Node.html#create()` ### getUncached() `public static TruffleString.FromNativePointerWithCompactionUTF32Node getUncached()`. Since 25.1. Get the uncached version of `FromNativePointerWithCompactionUTF32Node`. Cite: `com/oracle/truffle/api/strings/TruffleString.FromNativePointerWithCompactionUTF32Node.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.FromZeroTerminatedNativePointerNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 25.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.FromZeroTerminatedNativePointerNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `FromZeroTerminatedNativePointerNode` Equivalent to [`FromNativePointerNode`](com/oracle/truffle/api/strings/TruffleString.FromNativePointerNode.md) for zero-terminated buffers, i.e. the string's length is determined by the position of the first zero-value found. This operation requires native access permissions (`TruffleLanguage.Env#isNativeAccessAllowed()`). **See also** - [`FromNativePointerNode`](com/oracle/truffle/api/strings/TruffleString.FromNativePointerNode.md) ## Methods ### execute8Bit(Object, int, …) `public final TruffleString execute8Bit(Object pointerObject, int byteOffset, TruffleString.Encoding encoding, boolean copy)`. Since 25.1. Equivalent to `FromNativePointerNode.execute` with the only difference being that the native buffer's length is determined by the position of the first 8-bit zero value in the buffer. Cite: `com/oracle/truffle/api/strings/TruffleString.FromZeroTerminatedNativePointerNode.html#execute8Bit(java.lang.Object,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### execute16Bit(Object, int, …) `public final TruffleString execute16Bit(Object pointerObject, int byteOffset, TruffleString.Encoding encoding, boolean copy)`. Since 25.1. Equivalent to `FromNativePointerNode.execute` with the only difference being that the native buffer's length is determined by the position of the first 16-bit zero value in the buffer. Note that the 16-bit zero value's position is checked in 2-byte increments starting from `native pointer + byte offset`, so a zero value starting at an odd byte index is ignored. Cite: `com/oracle/truffle/api/strings/TruffleString.FromZeroTerminatedNativePointerNode.html#execute16Bit(java.lang.Object,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### execute32Bit(Object, int, …) `public final TruffleString execute32Bit(Object pointerObject, int byteOffset, TruffleString.Encoding encoding, boolean copy)`. Since 25.1. Equivalent to `FromNativePointerNode.execute` with the only difference being that the native buffer's length is determined by the position of the first 32-bit zero value in the buffer. Note that the 32-bit zero value's position is checked in 4-byte increments starting from `native pointer + byte offset`, so a zero value starting at an index that isn't a multiple of 4 is ignored. Cite: `com/oracle/truffle/api/strings/TruffleString.FromZeroTerminatedNativePointerNode.html#execute32Bit(java.lang.Object,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### create() `public static TruffleString.FromZeroTerminatedNativePointerNode create()`. Since 25.1. Create a new `FromZeroTerminatedNativePointerNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.FromZeroTerminatedNativePointerNode.html#create()` ### getUncached() `public static TruffleString.FromZeroTerminatedNativePointerNode getUncached()`. Since 25.1. Get the uncached version of `FromZeroTerminatedNativePointerNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.FromZeroTerminatedNativePointerNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.GetByteCodeRangeNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.GetByteCodeRangeNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `GetByteCodeRangeNode` Node to get a string's "byte-based" [`CodeRange`](com/oracle/truffle/api/strings/TruffleString.CodeRange.md). See [`execute(AbstractTruffleString, TruffleString.Encoding)`](com/oracle/truffle/api/strings/TruffleString.GetByteCodeRangeNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, TruffleString.Encoding) `public abstract TruffleString.CodeRange execute(AbstractTruffleString a, TruffleString.Encoding expectedEncoding)`. Since 22.1. Get the string's "byte-based" `CodeRange`. This differs from `GetCodeRangeNode` in the following way: A string is only considered to be in the `CodeRange.ASCII` code range if its encoding is byte-based, so `Encoding.UTF_16` and `Encoding.UTF_32` cannot be `CodeRange.ASCII`.; `CodeRange.LATIN_1` and `CodeRange.BMP` are mapped to `CodeRange.VALID`; . The return value is always one of `CodeRange.ASCII`, `CodeRange.VALID` or `CodeRange.BROKEN`. Cite: `com/oracle/truffle/api/strings/TruffleString.GetByteCodeRangeNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.GetByteCodeRangeNode create()`. Since 22.1. Create a new `GetByteCodeRangeNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.GetByteCodeRangeNode.html#create()` ### getUncached() `public static TruffleString.GetByteCodeRangeNode getUncached()`. Since 22.1. Get the uncached version of `GetByteCodeRangeNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.GetByteCodeRangeNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.GetCodeRangeImpreciseNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 23.0. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.GetCodeRangeImpreciseNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `GetCodeRangeImpreciseNode` Node to get a string's possibly imprecise [`CodeRange`](com/oracle/truffle/api/strings/TruffleString.CodeRange.md). **See also** - [`CodeRange`](com/oracle/truffle/api/strings/TruffleString.CodeRange.md) - [`GetCodeRangeNode`](com/oracle/truffle/api/strings/TruffleString.GetCodeRangeNode.md) ## Methods ### execute(AbstractTruffleString, TruffleString.Encoding) `public abstract TruffleString.CodeRange execute(AbstractTruffleString a, TruffleString.Encoding expectedEncoding)`. Since 23.0. Get the string's possibly imprecise `CodeRange`. This node will never attempt to calculate a more precise code range, instead it will only return what is currently known. Cite: `com/oracle/truffle/api/strings/TruffleString.GetCodeRangeImpreciseNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.GetCodeRangeImpreciseNode create()`. Since 23.0. Create a new `GetCodeRangeImpreciseNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.GetCodeRangeImpreciseNode.html#create()` ### getUncached() `public static TruffleString.GetCodeRangeImpreciseNode getUncached()`. Since 23.0. Get the uncached version of `GetCodeRangeImpreciseNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.GetCodeRangeImpreciseNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.GetCodeRangeNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.GetCodeRangeNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `GetCodeRangeNode` Node to get a string's precise [`CodeRange`](com/oracle/truffle/api/strings/TruffleString.CodeRange.md). **See also** - [`CodeRange`](com/oracle/truffle/api/strings/TruffleString.CodeRange.md) - [`GetCodeRangeImpreciseNode`](com/oracle/truffle/api/strings/TruffleString.GetCodeRangeImpreciseNode.md) ## Methods ### execute(AbstractTruffleString, TruffleString.Encoding) `public abstract TruffleString.CodeRange execute(AbstractTruffleString a, TruffleString.Encoding expectedEncoding)`. Since 22.1. Get the string's precise `CodeRange`. This operation will cause a full string scan if the precise code range is currently unknown. Cite: `com/oracle/truffle/api/strings/TruffleString.GetCodeRangeNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.GetCodeRangeNode create()`. Since 22.1. Create a new `GetCodeRangeNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.GetCodeRangeNode.html#create()` ### getUncached() `public static TruffleString.GetCodeRangeNode getUncached()`. Since 22.1. Get the uncached version of `GetCodeRangeNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.GetCodeRangeNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.GetInternalByteArrayNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.GetInternalByteArrayNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `GetInternalByteArrayNode` Node to get a string's internal byte array. See [`execute(AbstractTruffleString, TruffleString.Encoding)`](com/oracle/truffle/api/strings/TruffleString.GetInternalByteArrayNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, TruffleString.Encoding) `public abstract InternalByteArray execute(AbstractTruffleString a, TruffleString.Encoding expectedEncoding)`. Since 22.1. Get the given string's internal byte array. The returned byte array must not be modified. Note that this operation may also return a copy of the string's internal storage, if the internal format does not match the regular encoded string format; compacted and native strings will always yield a copy. CAUTION: TruffleString re-uses internal byte arrays whenever possible, DO NOT modify the arrays returned by this operation. Use this operation only when absolutely necessary. Reading a string's contents should always be done via nodes like `ReadByteNode`, `ReadCharUTF16Node`, `CodePointAtIndexNode`, `CodePointAtByteIndexNode` etc., if at all possible. If mutability is required, use `MutableTruffleString` instead. Cite: `com/oracle/truffle/api/strings/TruffleString.GetInternalByteArrayNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.GetInternalByteArrayNode create()`. Since 22.1. Create a new `GetInternalByteArrayNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.GetInternalByteArrayNode.html#create()` ### getUncached() `public static TruffleString.GetInternalByteArrayNode getUncached()`. Since 22.1. Get the uncached version of `GetInternalByteArrayNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.GetInternalByteArrayNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.GetInternalNativePointerNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.GetInternalNativePointerNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `GetInternalNativePointerNode` Node to get a [`native`](com/oracle/truffle/api/strings/AbstractTruffleString.md#isNative%28%29) string's pointer object or raw pointer. See [`execute(AbstractTruffleString, TruffleString.Encoding)`](com/oracle/truffle/api/strings/TruffleString.GetInternalNativePointerNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, TruffleString.Encoding) `public abstract Object execute(AbstractTruffleString a, TruffleString.Encoding expectedEncoding)`. Since 22.1. Get the given string's pointer object which was passed to `FromNativePointerNode`. If the string was created from a boxed [`Long`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Long.html) raw native pointer, this node returns that raw pointer as a boxed [`Long`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Long.html). In that case, there is no associated object kept alive for lifetime tracking, so the caller remains responsible for ensuring that the native memory remains valid. If the string is not backed by a native pointer, this node will throw an [`UnsupportedOperationException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/UnsupportedOperationException.html). Use `AbstractTruffleString.isNative()` to check whether the string is actually backed by a native pointer before calling this node. Caution: If the given string is a `TruffleString`, the native pointer must not be modified as long as the string is used. Cite: `com/oracle/truffle/api/strings/TruffleString.GetInternalNativePointerNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.GetInternalNativePointerNode create()`. Since 22.1. Create a new `GetInternalNativePointerNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.GetInternalNativePointerNode.html#create()` ### getUncached() `public static TruffleString.GetInternalNativePointerNode getUncached()`. Since 22.1. Get the uncached version of `GetInternalNativePointerNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.GetInternalNativePointerNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.GetStringCompactionLevelNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 23.0. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.GetStringCompactionLevelNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `GetStringCompactionLevelNode` Node to get a string's [`CompactionLevel`](com/oracle/truffle/api/strings/TruffleString.CompactionLevel.md). ## Methods ### execute(AbstractTruffleString, TruffleString.Encoding) `public abstract TruffleString.CompactionLevel execute(AbstractTruffleString a, TruffleString.Encoding expectedEncoding)`. Since 23.0. Get the string's `CompactionLevel`. Since string compaction is only supported on `Encoding.UTF_16` and `Encoding.UTF_32`, this node will return `CompactionLevel.S1` on all other encodings. Cite: `com/oracle/truffle/api/strings/TruffleString.GetStringCompactionLevelNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.GetStringCompactionLevelNode create()`. Since 23.0. Create a new `GetStringCompactionLevelNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.GetStringCompactionLevelNode.html#create()` ### getUncached() `public static TruffleString.GetStringCompactionLevelNode getUncached()`. Since 23.0. Get the uncached version of `GetStringCompactionLevelNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.GetStringCompactionLevelNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.HashCodeNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.HashCodeNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `HashCodeNode` Node to get a string's hash code. See [`execute(AbstractTruffleString, TruffleString.Encoding)`](com/oracle/truffle/api/strings/TruffleString.HashCodeNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. **See also** - [`TruffleString.hashCode()`](com/oracle/truffle/api/strings/AbstractTruffleString.md#hashCode%28%29) ## Methods ### execute(AbstractTruffleString, TruffleString.Encoding) `public abstract int execute(AbstractTruffleString a, TruffleString.Encoding expectedEncoding)`. Since 22.1. Returns the string's hash code. The hash is dependent on the string's encoding, make sure to convert strings to a common encoding before comparing their hash codes! Cite: `com/oracle/truffle/api/strings/TruffleString.HashCodeNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.HashCodeNode create()`. Since 22.1. Create a new `HashCodeNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.HashCodeNode.html#create()` ### getUncached() `public static TruffleString.HashCodeNode getUncached()`. Since 22.1. Get the uncached version of `HashCodeNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.HashCodeNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ⚡︎ TruffleString.IllegalByteArrayLengthException [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Exception in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.3. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public static final class TruffleString.IllegalByteArrayLengthException extends IllegalArgumentException ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) > [`Exception`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Exception.html) > [`RuntimeException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/RuntimeException.html) > [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) > `IllegalByteArrayLengthException` This exception is thrown when any operation tries to create a [`UTF-16`](com/oracle/truffle/api/strings/TruffleString.Encoding.md#UTF_16) or [`UTF-32`](com/oracle/truffle/api/strings/TruffleString.Encoding.md#UTF_32) string with an invalid byte length (not a multiple of 2/4 bytes). ## Inherited members - From class [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html): [`addSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#addSuppressed%28java.lang.Throwable%29), [`fillInStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#fillInStackTrace%28%29), [`getCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getCause%28%29), [`getLocalizedMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getLocalizedMessage%28%29), [`getMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getMessage%28%29), [`getStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getStackTrace%28%29), [`getSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getSuppressed%28%29), [`initCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#initCause%28java.lang.Throwable%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintStream%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintWriter%29), [`setStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#setStackTrace%28java.lang.StackTraceElement[]%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.IndexOfCodePointNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.IndexOfCodePointNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `IndexOfCodePointNode` Node to find the index of the first occurrence of a given code point. See [`execute(AbstractTruffleString, int, int, int, TruffleString.Encoding)`](com/oracle/truffle/api/strings/TruffleString.IndexOfCodePointNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,int,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, int, …) `public abstract int execute(AbstractTruffleString a, int codepoint, int fromIndex, int toIndex, TruffleString.Encoding expectedEncoding)`. Since 22.1. Return the codepoint index of the first occurrence of `codepoint`, bounded by `fromIndex` (inclusive) and `toIndex` (exclusive), if no occurrence is found return a negative value. Cite: `com/oracle/truffle/api/strings/TruffleString.IndexOfCodePointNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.IndexOfCodePointNode create()`. Since 22.1. Create a new `IndexOfCodePointNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.IndexOfCodePointNode.html#create()` ### getUncached() `public static TruffleString.IndexOfCodePointNode getUncached()`. Since 22.1. Get the uncached version of `IndexOfCodePointNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.IndexOfCodePointNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.IndexOfStringNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.IndexOfStringNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `IndexOfStringNode` Node to find the index of the first occurrence of a given string. See [`execute(AbstractTruffleString, AbstractTruffleString, int, int, TruffleString.Encoding)`](com/oracle/truffle/api/strings/TruffleString.IndexOfStringNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, AbstractTruffleString, …) `public abstract int execute(AbstractTruffleString a, AbstractTruffleString b, int fromIndex, int toIndex, TruffleString.Encoding expectedEncoding)`. Since 22.1. Return the codepoint index of the first occurrence of `string`, bounded by `fromIndex` (inclusive) and `toIndex` (exclusive), if no occurrence is found return a negative value. Cite: `com/oracle/truffle/api/strings/TruffleString.IndexOfStringNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.IndexOfStringNode create()`. Since 22.1. Create a new `IndexOfStringNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.IndexOfStringNode.html#create()` ### getUncached() `public static TruffleString.IndexOfStringNode getUncached()`. Since 22.1. Get the uncached version of `IndexOfStringNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.IndexOfStringNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.IntIndexOfAnyIntUTF32Node [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.IntIndexOfAnyIntUTF32Node extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `IntIndexOfAnyIntUTF32Node` Node to find the index of the first occurrence of any `int` from a given array. See [`execute(AbstractTruffleString, int, int, int[])`](com/oracle/truffle/api/strings/TruffleString.IntIndexOfAnyIntUTF32Node.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,int,int,int[]%29) for details. ## Methods ### execute(AbstractTruffleString, int, …) `public abstract int execute(AbstractTruffleString a, int fromIntIndex, int maxIntIndex, int[] values)`. Since 22.1. Return the int index of the first occurrence of any int contained in `values`, bounded by `fromIntIndex` (inclusive) and `maxIntIndex` (exclusive). If none of the values is found, return a negative value. Cite: `com/oracle/truffle/api/strings/TruffleString.IntIndexOfAnyIntUTF32Node.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int,int,int[])` ### create() `public static TruffleString.IntIndexOfAnyIntUTF32Node create()`. Since 22.1. Create a new `IntIndexOfAnyIntUTF32Node`. Cite: `com/oracle/truffle/api/strings/TruffleString.IntIndexOfAnyIntUTF32Node.html#create()` ### getUncached() `public static TruffleString.IntIndexOfAnyIntUTF32Node getUncached()`. Since 22.1. Get the uncached version of `IntIndexOfAnyIntUTF32Node`. Cite: `com/oracle/truffle/api/strings/TruffleString.IntIndexOfAnyIntUTF32Node.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.IsValidNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.IsValidNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `IsValidNode` Node to check if a string is encoded correctly. ## Methods ### execute(AbstractTruffleString, TruffleString.Encoding) `public abstract boolean execute(AbstractTruffleString a, TruffleString.Encoding expectedEncoding)`. Since 22.1. Returns `true` if the string encoded correctly. Cite: `com/oracle/truffle/api/strings/TruffleString.IsValidNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.IsValidNode create()`. Since 22.1. Create a new `IsValidNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.IsValidNode.html#create()` ### getUncached() `public static TruffleString.IsValidNode getUncached()`. Since 22.1. Get the uncached version of `IsValidNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.IsValidNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.LastByteIndexOfCodePointNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.LastByteIndexOfCodePointNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `LastByteIndexOfCodePointNode` [`LastIndexOfCodePointNode`](com/oracle/truffle/api/strings/TruffleString.LastIndexOfCodePointNode.md), but with byte indices. ## Methods ### execute(AbstractTruffleString, int, …) `public abstract int execute(AbstractTruffleString a, int codepoint, int fromByteIndex, int toByteIndex, TruffleString.Encoding expectedEncoding)`. Since 22.1. `LastIndexOfCodePointNode`, but with byte indices. Cite: `com/oracle/truffle/api/strings/TruffleString.LastByteIndexOfCodePointNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.LastByteIndexOfCodePointNode create()`. Since 22.1. Create a new `LastByteIndexOfCodePointNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.LastByteIndexOfCodePointNode.html#create()` ### getUncached() `public static TruffleString.LastByteIndexOfCodePointNode getUncached()`. Since 22.1. Get the uncached version of `LastByteIndexOfCodePointNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.LastByteIndexOfCodePointNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.LastByteIndexOfStringNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.LastByteIndexOfStringNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `LastByteIndexOfStringNode` [`LastIndexOfStringNode`](com/oracle/truffle/api/strings/TruffleString.LastIndexOfStringNode.md), but with byte indices. ## Methods ### execute(AbstractTruffleString, AbstractTruffleString, …) `public final int execute(AbstractTruffleString a, AbstractTruffleString b, int fromIndex, int toIndex, TruffleString.Encoding expectedEncoding)`. Since 22.1. `LastIndexOfStringNode`, but with byte indices. Cite: `com/oracle/truffle/api/strings/TruffleString.LastByteIndexOfStringNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### execute(AbstractTruffleString, TruffleString.WithMask, …) `public final int execute(AbstractTruffleString a, TruffleString.WithMask b, int fromIndex, int toIndex, TruffleString.Encoding expectedEncoding)`. Since 22.1. `LastIndexOfStringNode`, but with byte indices. This variant accepts a `TruffleString.WithMask` as the search value `b`, which changes the searching algorithm in the following manner: whenever the contents of `a` and `b` are compared, the mask is OR'ed to `a`, as shown in this exemplary method: Cite: `com/oracle/truffle/api/strings/TruffleString.LastByteIndexOfStringNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.WithMask,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ```java boolean bytesEqualAt(TruffleString a, int byteIndexA, TruffleString.WithMask b, int byteIndexB) { return (readByte(a, byteIndexA) | readByte(b.mask, byteIndexB)) == readByte(b, byteIndexB); } ``` ### create() `public static TruffleString.LastByteIndexOfStringNode create()`. Since 22.1. Create a new `LastByteIndexOfStringNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.LastByteIndexOfStringNode.html#create()` ### getUncached() `public static TruffleString.LastByteIndexOfStringNode getUncached()`. Since 22.1. Get the uncached version of `LastByteIndexOfStringNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.LastByteIndexOfStringNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.LastIndexOfCodePointNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.LastIndexOfCodePointNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `LastIndexOfCodePointNode` Node to find the codepoint index of the last occurrence of a given code point. See [`execute(AbstractTruffleString, int, int, int, TruffleString.Encoding)`](com/oracle/truffle/api/strings/TruffleString.LastIndexOfCodePointNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,int,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, int, …) `public abstract int execute(AbstractTruffleString a, int codepoint, int fromIndex, int toIndex, TruffleString.Encoding expectedEncoding)`. Since 22.1. Return the codepoint index of the last occurrence of `codepoint`, bounded by `fromIndex` (exclusive upper limit) and `toIndex` (inclusive lower limit), if no occurrence is found return a negative value. Cite: `com/oracle/truffle/api/strings/TruffleString.LastIndexOfCodePointNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.LastIndexOfCodePointNode create()`. Since 22.1. Create a new `LastIndexOfCodePointNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.LastIndexOfCodePointNode.html#create()` ### getUncached() `public static TruffleString.LastIndexOfCodePointNode getUncached()`. Since 22.1. Get the uncached version of `LastIndexOfCodePointNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.LastIndexOfCodePointNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.LastIndexOfStringNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.LastIndexOfStringNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `LastIndexOfStringNode` Node to find the index of the last occurrence of a given string. See [`execute(AbstractTruffleString, AbstractTruffleString, int, int, TruffleString.Encoding)`](com/oracle/truffle/api/strings/TruffleString.LastIndexOfStringNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, AbstractTruffleString, …) `public abstract int execute(AbstractTruffleString a, AbstractTruffleString b, int fromIndex, int toIndex, TruffleString.Encoding expectedEncoding)`. Since 22.1. Return the codepoint index of the last occurrence of `string`, bounded by `fromIndex` (exclusive upper limit) and `toIndex` (inclusive lower limit), if no occurrence is found return a negative value. Cite: `com/oracle/truffle/api/strings/TruffleString.LastIndexOfStringNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.LastIndexOfStringNode create()`. Since 22.1. Create a new `LastIndexOfStringNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.LastIndexOfStringNode.html#create()` ### getUncached() `public static TruffleString.LastIndexOfStringNode getUncached()`. Since 22.1. Get the uncached version of `LastIndexOfStringNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.LastIndexOfStringNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.MaterializeNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.MaterializeNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `MaterializeNode` Node to force materialization of any lazy internal data. Use this node to avoid materialization code inside loops, e.g. when iterating over a string's code points or bytes. ## Methods ### execute(AbstractTruffleString, TruffleString.Encoding) `public abstract void execute(AbstractTruffleString a, TruffleString.Encoding expectedEncoding)`. Since 22.1. Forces materialization of any lazy internal data. Use this node to avoid materialization code inside loops, e.g. when iterating over a string's code points or bytes. Cite: `com/oracle/truffle/api/strings/TruffleString.MaterializeNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.MaterializeNode create()`. Since 22.1. Create a new `MaterializeNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.MaterializeNode.html#create()` ### getUncached() `public static TruffleString.MaterializeNode getUncached()`. Since 22.1. Get the uncached version of `MaterializeNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.MaterializeNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.MaterializeSubstringNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 25.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.MaterializeSubstringNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `MaterializeSubstringNode` Extended version of [`MaterializeNode`](com/oracle/truffle/api/strings/TruffleString.MaterializeNode.md) that also materializes substrings/string views created via e.g. [`SubstringNode`](com/oracle/truffle/api/strings/TruffleString.SubstringNode.md) with the `lazy` parameter set to `true` or via [`FromByteArrayNode`](com/oracle/truffle/api/strings/TruffleString.FromByteArrayNode.md) with the `copy` parameter set to `false`. Note that this node returns a potentially new [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md), because these substrings cannot be materialized internally. [`Native-backed`](com/oracle/truffle/api/strings/AbstractTruffleString.md#isNative%28%29) strings are kept as-is, since this node cannot decide whether a native-backed string is a substring/string view. Lazy substrings keep a reference to the potentially larger byte array they were created from, which may keep more memory alive than necessary (see the caveats mentioned at [`SubstringNode.execute`](com/oracle/truffle/api/strings/TruffleString.SubstringNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean%29)). With this node, unnecessarily held memory is reclaimed by copying the referenced subregions. This is especially useful if a string is added to a data structure known to be long-lived, e.g. during string interning. **See also** - [`SubstringNode.execute`](com/oracle/truffle/api/strings/TruffleString.SubstringNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean%29) ## Methods ### execute(AbstractTruffleString, TruffleString.Encoding) `public abstract TruffleString execute(AbstractTruffleString a, TruffleString.Encoding expectedEncoding)`. Since 25.1. Extended version of `MaterializeNode` that also materializes substrings/string views created via e.g. `SubstringNode` with the `lazy` parameter set to `true` or via `FromByteArrayNode` with the `copy` parameter set to `false`. Note that this node returns a potentially new `TruffleString`, because these substrings cannot be materialized internally. `Native-backed` strings are kept as-is, since this node cannot decide whether a native-backed string is a substring/string view. Lazy substrings keep a reference to the potentially larger byte array they were created from, which may keep more memory alive than necessary (see the caveats mentioned at `SubstringNode.execute`). With this node, unnecessarily held memory is reclaimed by copying the referenced subregions. This is especially useful if a string is added to a data structure known to be long-lived, e.g. during string interning. See also: `SubstringNode.execute`. Cite: `com/oracle/truffle/api/strings/TruffleString.MaterializeSubstringNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.MaterializeSubstringNode create()`. Since 25.1. Create a new `MaterializeSubstringNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.MaterializeSubstringNode.html#create()` ### getUncached() `public static TruffleString.MaterializeSubstringNode getUncached()`. Since 25.1. Get the uncached version of `MaterializeSubstringNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.MaterializeSubstringNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ⚡︎ TruffleString.NumberFormatException [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Exception in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public static final class TruffleString.NumberFormatException extends Exception ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html) > [`Exception`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Exception.html) > `NumberFormatException` This exception may be thrown by [`ParseIntNode`](com/oracle/truffle/api/strings/TruffleString.ParseIntNode.md), [`ParseLongNode`](com/oracle/truffle/api/strings/TruffleString.ParseLongNode.md) or [`ParseDoubleNode`](com/oracle/truffle/api/strings/TruffleString.ParseDoubleNode.md) to indicate that the given string cannot be parsed as an integer, long or double value. This exception does not record stack traces for performance reasons. ## Methods ### getMessage() `public String getMessage()`. Since 22.3. Returns a detailed error message. Not designed to be used on fast paths. Overrides `getMessage()`. Cite: `com/oracle/truffle/api/strings/TruffleString.NumberFormatException.html#getMessage()` ### fillInStackTrace() `public Throwable fillInStackTrace()`. Since 22.1. No stack trace for this exception. Overrides `fillInStackTrace()`. Cite: `com/oracle/truffle/api/strings/TruffleString.NumberFormatException.html#fillInStackTrace()` ## Inherited members - From class [`Throwable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html): [`addSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#addSuppressed%28java.lang.Throwable%29), [`getCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getCause%28%29), [`getLocalizedMessage`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getLocalizedMessage%28%29), [`getStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getStackTrace%28%29), [`getSuppressed`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#getSuppressed%28%29), [`initCause`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#initCause%28java.lang.Throwable%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintStream%29), [`printStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#printStackTrace%28java.io.PrintWriter%29), [`setStackTrace`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#setStackTrace%28java.lang.StackTraceElement[]%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Throwable.html#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.ParseDoubleNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.ParseDoubleNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `ParseDoubleNode` Node to parse a given string as a double value. ## Methods ### execute(AbstractTruffleString) `public abstract double execute(AbstractTruffleString a) throws TruffleString.NumberFormatException`. Since 22.1. Parse the given string as a double value, or throw `NumberFormatException`. Cite: `com/oracle/truffle/api/strings/TruffleString.ParseDoubleNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString)` ### create() `public static TruffleString.ParseDoubleNode create()`. Since 22.1. Create a new `ParseDoubleNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ParseDoubleNode.html#create()` ### getUncached() `public static TruffleString.ParseDoubleNode getUncached()`. Since 22.1. Get the uncached version of `ParseDoubleNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ParseDoubleNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.ParseIntNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.ParseIntNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `ParseIntNode` Node to parse a given string as an int value. ## Methods ### execute(AbstractTruffleString, int) `public abstract int execute(AbstractTruffleString a, int radix) throws TruffleString.NumberFormatException`. Since 22.1. Parse the given string as an int value, or throw `NumberFormatException`. Cite: `com/oracle/truffle/api/strings/TruffleString.ParseIntNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int)` ### create() `public static TruffleString.ParseIntNode create()`. Since 22.1. Create a new `ParseIntNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ParseIntNode.html#create()` ### getUncached() `public static TruffleString.ParseIntNode getUncached()`. Since 22.1. Get the uncached version of `ParseIntNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ParseIntNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.ParseLongNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.ParseLongNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `ParseLongNode` Node to parse a given string as a long value. ## Methods ### execute(AbstractTruffleString, int) `public abstract long execute(AbstractTruffleString a, int radix) throws TruffleString.NumberFormatException`. Since 22.1. Parse the given string as a long value, or throw `NumberFormatException`. Cite: `com/oracle/truffle/api/strings/TruffleString.ParseLongNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int)` ### create() `public static TruffleString.ParseLongNode create()`. Since 22.1. Create a new `ParseLongNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ParseLongNode.html#create()` ### getUncached() `public static TruffleString.ParseLongNode getUncached()`. Since 22.1. Get the uncached version of `ParseLongNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ParseLongNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.ReadByteNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.ReadByteNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `ReadByteNode` Node to read a single byte from a string. See [`execute(AbstractTruffleString, int, TruffleString.Encoding)`](com/oracle/truffle/api/strings/TruffleString.ReadByteNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, int, TruffleString.Encoding) `public abstract int execute(AbstractTruffleString a, int byteIndex, TruffleString.Encoding expectedEncoding)`. Since 22.1. Read a single byte from a string. If used inside a loop or repetitively, `MaterializeNode` should be used before. Cite: `com/oracle/truffle/api/strings/TruffleString.ReadByteNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.ReadByteNode create()`. Since 22.1. Create a new `ReadByteNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ReadByteNode.html#create()` ### getUncached() `public static TruffleString.ReadByteNode getUncached()`. Since 22.1. Get the uncached version of `ReadByteNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ReadByteNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.ReadCharUTF16Node [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.ReadCharUTF16Node extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `ReadCharUTF16Node` Node to read a single char from a UTF-16 string. ## Methods ### execute(AbstractTruffleString, int) `public final char execute(AbstractTruffleString a, int charIndex)`. Since 22.1. Read a single char from a UTF-16 string. Cite: `com/oracle/truffle/api/strings/TruffleString.ReadCharUTF16Node.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int)` ### executeLE(AbstractTruffleString, int) `public final char executeLE(AbstractTruffleString a, int charIndex)`. Since 26.0. Read a single char from a UTF-16LE string. Cite: `com/oracle/truffle/api/strings/TruffleString.ReadCharUTF16Node.html#executeLE(com.oracle.truffle.api.strings.AbstractTruffleString,int)` ### executeBE(AbstractTruffleString, int) `public final char executeBE(AbstractTruffleString a, int charIndex)`. Since 26.0. Read a single char from a UTF-16BE string. Cite: `com/oracle/truffle/api/strings/TruffleString.ReadCharUTF16Node.html#executeBE(com.oracle.truffle.api.strings.AbstractTruffleString,int)` ### create() `public static TruffleString.ReadCharUTF16Node create()`. Since 22.1. Create a new `ReadCharUTF16Node`. Cite: `com/oracle/truffle/api/strings/TruffleString.ReadCharUTF16Node.html#create()` ### getUncached() `public static TruffleString.ReadCharUTF16Node getUncached()`. Since 22.1. Get the uncached version of `ReadCharUTF16Node`. Cite: `com/oracle/truffle/api/strings/TruffleString.ReadCharUTF16Node.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.RegionEqualByteIndexNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.RegionEqualByteIndexNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `RegionEqualByteIndexNode` Node to check for a region match, byte-by-byte. See [`execute(AbstractTruffleString, int, AbstractTruffleString, int, int, TruffleString.Encoding)`](com/oracle/truffle/api/strings/TruffleString.RegionEqualByteIndexNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,int,com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29) and [`execute(AbstractTruffleString, int, TruffleString.WithMask, int, int, TruffleString.Encoding)`](com/oracle/truffle/api/strings/TruffleString.RegionEqualByteIndexNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,int,com.oracle.truffle.api.strings.TruffleString.WithMask,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, int, …) `public final boolean execute(AbstractTruffleString a, int fromByteIndexA, AbstractTruffleString b, int fromByteIndexB, int length, TruffleString.Encoding expectedEncoding)`. Since 22.1. Checks for a region match, byte-by-byte. Cite: `com/oracle/truffle/api/strings/TruffleString.RegionEqualByteIndexNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int,com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### execute(AbstractTruffleString, int, …) `public final boolean execute(AbstractTruffleString a, int fromByteIndexA, TruffleString.WithMask b, int fromByteIndexB, int length, TruffleString.Encoding expectedEncoding)`. Since 22.1. Checks for a region match, byte-by-byte. This variant accepts a `TruffleString.WithMask` as the search value `b`, which changes the matching algorithm in the following manner: when the contents of `a` and `b` are compared, the mask is OR'ed to `a`, as shown in this exemplary method: Cite: `com/oracle/truffle/api/strings/TruffleString.RegionEqualByteIndexNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int,com.oracle.truffle.api.strings.TruffleString.WithMask,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ```java boolean bytesEqualAt(TruffleString a, int byteIndexA, TruffleString.WithMask b, int byteIndexB) { return (readByte(a, byteIndexA) | readByte(b.mask, byteIndexB)) == readByte(b, byteIndexB); } ``` ### create() `public static TruffleString.RegionEqualByteIndexNode create()`. Since 22.1. Create a new `RegionEqualByteIndexNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.RegionEqualByteIndexNode.html#create()` ### getUncached() `public static TruffleString.RegionEqualByteIndexNode getUncached()`. Since 22.1. Get the uncached version of `RegionEqualByteIndexNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.RegionEqualByteIndexNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.RegionEqualNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.RegionEqualNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `RegionEqualNode` Node to check codepoint equality of two string regions. See [`execute(AbstractTruffleString, int, AbstractTruffleString, int, int, TruffleString.Encoding)`](com/oracle/truffle/api/strings/TruffleString.RegionEqualNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,int,com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29). ## Methods ### execute(AbstractTruffleString, int, …) `public abstract boolean execute(AbstractTruffleString a, int fromIndexA, AbstractTruffleString b, int fromIndexB, int length, TruffleString.Encoding expectedEncoding)`. Since 22.1. Checks for codepoint equality in a region with the given codepoint index and codepoint length. Equivalent to: Cite: `com/oracle/truffle/api/strings/TruffleString.RegionEqualNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int,com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ```java for (int i = 0; i < length; i++) { if (codePointAt(a, fromIndexA + i) != codePointAt(b, fromIndexB + i)) { return false; } } return true; ``` ### create() `public static TruffleString.RegionEqualNode create()`. Since 22.1. Create a new `RegionEqualNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.RegionEqualNode.html#create()` ### getUncached() `public static TruffleString.RegionEqualNode getUncached()`. Since 22.1. Get the uncached version of `RegionEqualNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.RegionEqualNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.RepeatNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.RepeatNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `RepeatNode` Node to repeat a given string `N` times. See [`execute(AbstractTruffleString, int, TruffleString.Encoding)`](com/oracle/truffle/api/strings/TruffleString.RepeatNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,int,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, int, TruffleString.Encoding) `public abstract TruffleString execute(AbstractTruffleString a, int n, TruffleString.Encoding expectedEncoding)`. Since 22.1. Create a new string by repeating `n` times string `a`. Cite: `com/oracle/truffle/api/strings/TruffleString.RepeatNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.RepeatNode create()`. Since 22.1. Create a new `RepeatNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.RepeatNode.html#create()` ### getUncached() `public static TruffleString.RepeatNode getUncached()`. Since 22.1. Get the uncached version of `RepeatNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.RepeatNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.StringSet [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 25.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public static final class TruffleString.StringSet ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `StringSet` A set of strings in a given encoding. Used in [`ByteIndexOfStringSetNode.execute(AbstractTruffleString, int, int, TruffleString.StringSet)`](com/oracle/truffle/api/strings/TruffleString.ByteIndexOfStringSetNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.StringSet%29). ## Methods ### fromArray(AbstractTruffleString[], TruffleString.Encoding) `public static TruffleString.StringSet fromArray(AbstractTruffleString[] strings, TruffleString.Encoding encoding)`. Since 25.1. Creates a new `StringSet` from the given array of strings. This operation is expensive, it is recommended to cache the result. Parameters: `strings` `AbstractTruffleString[]`: list of strings to search for. Empty and `CodeRange.BROKEN` strings are unsupported. `encoding` `TruffleString.Encoding`: `strings`' encoding. Must be a *supported* encoding, i.e. `UTF-8/16/32`, `Encoding.ISO_8859_1` or `Encoding.US_ASCII`. Cite: `com/oracle/truffle/api/strings/TruffleString.StringSet.html#fromArray(com.oracle.truffle.api.strings.AbstractTruffleString[],com.oracle.truffle.api.strings.TruffleString.Encoding)` ### fromArray(TruffleString.WithMask[], TruffleString.Encoding) `public static TruffleString.StringSet fromArray(TruffleString.WithMask[] strings, TruffleString.Encoding encoding)`. Since 25.1. Creates a new `StringSet` from the given array of strings with masks. This operation is expensive, it is recommended to cache the result. Matching uses the same semantics as `WithMask` with some additional restrictions: a pattern code unit matches a haystack code unit if `(haystack | mask) == pattern`, but the mask may only have one set bit per code unit, and it may not have a larger code range than all search patterns, e.g. if all strings are `CodeRange.ASCII`, the mask may not have a code unit `0x80`. The restrictions of the maskless variant also apply here. Cite: `com/oracle/truffle/api/strings/TruffleString.StringSet.html#fromArray(com.oracle.truffle.api.strings.TruffleString.WithMask[],com.oracle.truffle.api.strings.TruffleString.Encoding)` ### isIntrinsicCandidate(TruffleString.CodeRange) `public boolean isIntrinsicCandidate(TruffleString.CodeRange codeRange)`. Since 25.1. Returns `true` if `ByteIndexOfStringSetNode` may implement the search for this particular string set in strings with the given code range by dispatching to a compiler intrinsic. This is useful for use cases where the caller has a faster implementation for non-intrinsified paths. Cite: `com/oracle/truffle/api/strings/TruffleString.StringSet.html#isIntrinsicCandidate(com.oracle.truffle.api.strings.TruffleString.CodeRange)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.SubstringByteIndexNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.SubstringByteIndexNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `SubstringByteIndexNode` [`SubstringNode`](com/oracle/truffle/api/strings/TruffleString.SubstringNode.md), but with byte indices. ## Methods ### execute(AbstractTruffleString, int, …) `public abstract TruffleString execute(AbstractTruffleString a, int fromByteIndex, int byteLength, TruffleString.Encoding expectedEncoding, boolean lazy)`. Since 22.1. `SubstringNode`, but with byte indices. Cite: `com/oracle/truffle/api/strings/TruffleString.SubstringByteIndexNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### create() `public static TruffleString.SubstringByteIndexNode create()`. Since 22.1. Create a new `SubstringByteIndexNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.SubstringByteIndexNode.html#create()` ### getUncached() `public static TruffleString.SubstringByteIndexNode getUncached()`. Since 22.1. Get the uncached version of `SubstringByteIndexNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.SubstringByteIndexNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.SubstringNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.SubstringNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `SubstringNode` Node to create a substring of a given string. See [`execute(AbstractTruffleString, int, int, TruffleString.Encoding, boolean)`](com/oracle/truffle/api/strings/TruffleString.SubstringNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean%29) for details. ## Methods ### execute(AbstractTruffleString, int, …) `public abstract TruffleString execute(AbstractTruffleString a, int fromIndex, int length, TruffleString.Encoding expectedEncoding, boolean lazy)`. Since 22.1. Create a substring of `a`, starting from codepoint index `fromIndex`, with codepoint length `length`. If `lazy` is `true`, `a`'s internal storage will be re-used instead of creating a copy of the requested range. Since the resulting string will have a reference to `a`'s internal storage, and `TruffleString` currently does *not* resize/trim the substring's internal storage at any point, the `lazy` variant effectively creates a memory leak! The caller is responsible for deciding whether this is acceptable or not. Cite: `com/oracle/truffle/api/strings/TruffleString.SubstringNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int,int,com.oracle.truffle.api.strings.TruffleString.Encoding,boolean)` ### create() `public static TruffleString.SubstringNode create()`. Since 22.1. Create a new `SubstringNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.SubstringNode.html#create()` ### getUncached() `public static TruffleString.SubstringNode getUncached()`. Since 22.1. Get the uncached version of `SubstringNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.SubstringNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.SwitchEncodingNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.SwitchEncodingNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `SwitchEncodingNode` Node to get a given string in a specific encoding. See [`execute(AbstractTruffleString, TruffleString.Encoding)`](com/oracle/truffle/api/strings/TruffleString.SwitchEncodingNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, TruffleString.Encoding) `public final TruffleString execute(AbstractTruffleString a, TruffleString.Encoding encoding)`. Since 22.1. Returns a version of string `a` that is encoded in the given encoding, which may be the string itself or a converted version. Note that the string itself may be returned even if it was originally created using a different encoding, if the string is byte-equivalent in both encodings. If no lossless conversion is possible, the string is converted on a best-effort basis; no exception is thrown and characters which cannot be mapped in the target encoding are replaced by `'�'` (for UTF-\*) or `'?'`. Cite: `com/oracle/truffle/api/strings/TruffleString.SwitchEncodingNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### execute(AbstractTruffleString, TruffleString.Encoding, TranscodingErrorHandler) `public abstract TruffleString execute(AbstractTruffleString a, TruffleString.Encoding encoding, TranscodingErrorHandler errorHandler)`. Since 23.1. Returns a version of string `a` that is encoded in the given encoding, which may be the string itself or a converted version. Note that the string itself may be returned even if it was originally created using a different encoding, if the string is byte-equivalent in both encodings. Transcoding errors are handled with `errorHandler`. Cite: `com/oracle/truffle/api/strings/TruffleString.SwitchEncodingNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding,com.oracle.truffle.api.strings.TranscodingErrorHandler)` ### create() `public static TruffleString.SwitchEncodingNode create()`. Since 22.1. Create a new `SwitchEncodingNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.SwitchEncodingNode.html#create()` ### getUncached() `public static TruffleString.SwitchEncodingNode getUncached()`. Since 22.1. Get the uncached version of `SwitchEncodingNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.SwitchEncodingNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.ToJavaStringNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.ToJavaStringNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `ToJavaStringNode` Node to get a [`java.lang.String`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html) representation of a [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ## Methods ### execute(AbstractTruffleString) `public abstract String execute(AbstractTruffleString a)`. Since 22.1. Return a [`java.lang.String`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html) representation of the given `TruffleString`. Cite: `com/oracle/truffle/api/strings/TruffleString.ToJavaStringNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString)` ### create() `public static TruffleString.ToJavaStringNode create()`. Since 22.1. Create a new `ToJavaStringNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ToJavaStringNode.html#create()` ### getUncached() `public static TruffleString.ToJavaStringNode getUncached()`. Since 22.1. Get the uncached version of `ToJavaStringNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ToJavaStringNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.ToValidStringNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 23.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public abstract static class TruffleString.ToValidStringNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `ToValidStringNode` Node to replace all invalid bytes in a given string, such that the resulting string is [`valid`](com/oracle/truffle/api/strings/TruffleString.IsValidNode.md). See [`execute(AbstractTruffleString, TruffleString.Encoding)`](com/oracle/truffle/api/strings/TruffleString.ToValidStringNode.md#execute%28com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding%29) for details. ## Methods ### execute(AbstractTruffleString, TruffleString.Encoding) `public abstract TruffleString execute(AbstractTruffleString a, TruffleString.Encoding expectedEncoding)`. Since 23.1. Returns a version of string `a` that contains only valid codepoints, which may be the string itself or a converted version. Invalid byte sequences are replaced with `'�'` (for UTF-\*) or `'?'`. This is useful for string sanitization in all uses cases where a string is required to actually be `valid`, such as libraries that actively reject broken input, network and file system I/O, etc. Cite: `com/oracle/truffle/api/strings/TruffleString.ToValidStringNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.ToValidStringNode create()`. Since 23.1. Create a new `SwitchEncodingNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ToValidStringNode.html#create()` ### getUncached() `public static TruffleString.ToValidStringNode getUncached()`. Since 23.1. Get the uncached version of `SwitchEncodingNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.ToValidStringNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.WithMask [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ```java public static final class TruffleString.WithMask ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `WithMask` Extended parameter type for the operations [`ByteIndexOfStringNode`](com/oracle/truffle/api/strings/TruffleString.ByteIndexOfStringNode.md), [`LastByteIndexOfStringNode`](com/oracle/truffle/api/strings/TruffleString.LastByteIndexOfStringNode.md) and [`RegionEqualByteIndexNode`](com/oracle/truffle/api/strings/TruffleString.RegionEqualByteIndexNode.md). These operations can optionally perform a logical OR operation when matching their string parameters against each other, in the following way: Given a parameter [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md) `a` and [`WithMask`](com/oracle/truffle/api/strings/TruffleString.WithMask.md) `b`, region equality will be checked as shown in this exemplary method: ```java boolean regionEquals(TruffleString a, int fromIndexA, TruffleString.WithMask b, int fromIndexB) { for (int i = 0; i < length; i++) { if ((readRaw(a, fromIndexA + i) | readRaw(b.mask, i)) != readRaw(b.string, fromIndexB + i)) { return false; } } return true; } ``` **See also** - [`ByteIndexOfStringNode`](com/oracle/truffle/api/strings/TruffleString.ByteIndexOfStringNode.md) - [`LastByteIndexOfStringNode`](com/oracle/truffle/api/strings/TruffleString.LastByteIndexOfStringNode.md) - [`RegionEqualByteIndexNode`](com/oracle/truffle/api/strings/TruffleString.RegionEqualByteIndexNode.md) ## Nested types - [`TruffleString.WithMask.CreateNode`](com/oracle/truffle/api/strings/TruffleString.WithMask.CreateNode.md) (abstract class): Node to create a new WithMask from a string and a byte array. - [`TruffleString.WithMask.CreateUTF16Node`](com/oracle/truffle/api/strings/TruffleString.WithMask.CreateUTF16Node.md) (abstract class): Node to create a new WithMask from a UTF-16 string and a char array. - [`TruffleString.WithMask.CreateUTF32Node`](com/oracle/truffle/api/strings/TruffleString.WithMask.CreateUTF32Node.md) (abstract class): Node to create a new WithMask from a UTF-32 string and an int array. ## Methods ### createUncached(AbstractTruffleString, byte[], TruffleString.Encoding) `public static TruffleString.WithMask createUncached(AbstractTruffleString a, byte[] mask, TruffleString.Encoding expectedEncoding)`. Since 22.1. Shorthand for calling the uncached version of `CreateNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.WithMask.html#createUncached(com.oracle.truffle.api.strings.AbstractTruffleString,byte[],com.oracle.truffle.api.strings.TruffleString.Encoding)` ### createUTF16Uncached(AbstractTruffleString, char[]) `public static TruffleString.WithMask createUTF16Uncached(AbstractTruffleString a, char[] mask)`. Since 22.1. Shorthand for calling the uncached version of `CreateUTF16Node`. Cite: `com/oracle/truffle/api/strings/TruffleString.WithMask.html#createUTF16Uncached(com.oracle.truffle.api.strings.AbstractTruffleString,char[])` ### createUTF32Uncached(AbstractTruffleString, int[]) `public static TruffleString.WithMask createUTF32Uncached(AbstractTruffleString a, int[] mask)`. Since 22.1. Shorthand for calling the uncached version of `CreateUTF32Node`. Cite: `com/oracle/truffle/api/strings/TruffleString.WithMask.html#createUTF32Uncached(com.oracle.truffle.api.strings.AbstractTruffleString,int[])` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.WithMask.CreateNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString.WithMask`](com/oracle/truffle/api/strings/TruffleString.WithMask.md). ```java public abstract static class TruffleString.WithMask.CreateNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `CreateNode` Node to create a new [`WithMask`](com/oracle/truffle/api/strings/TruffleString.WithMask.md) from a string and a byte array. See `#execute(AbstractTruffleString, byte[], Encoding)` for details. ## Methods ### execute(AbstractTruffleString, byte[], TruffleString.Encoding) `public abstract TruffleString.WithMask execute(AbstractTruffleString a, byte[] mask, TruffleString.Encoding expectedEncoding)`. Since 22.1. Creates a new `WithMask` from `a` and `mask`. `mask.length` must be equal to the string's length in bytes. Cannot be used for UTF-16 or UTF-32 strings. Cite: `com/oracle/truffle/api/strings/TruffleString.WithMask.CreateNode.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,byte[],com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleString.WithMask.CreateNode create()`. Since 22.1. Create a new `TruffleString.WithMask.CreateNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.WithMask.CreateNode.html#create()` ### getUncached() `public static TruffleString.WithMask.CreateNode getUncached()`. Since 22.1. Get the uncached version of `TruffleString.WithMask.CreateNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.WithMask.CreateNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.WithMask.CreateUTF16Node [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString.WithMask`](com/oracle/truffle/api/strings/TruffleString.WithMask.md). ```java public abstract static class TruffleString.WithMask.CreateUTF16Node extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `CreateUTF16Node` Node to create a new [`WithMask`](com/oracle/truffle/api/strings/TruffleString.WithMask.md) from a UTF-16 string and a char array. See `#execute(AbstractTruffleString, char[])` for details. ## Methods ### execute(AbstractTruffleString, char[]) `public abstract TruffleString.WithMask execute(AbstractTruffleString a, char[] mask)`. Since 22.1. Creates a new `WithMask` from `a` and `mask`. `mask.length` must be equal to the string's length in `char`s. Cite: `com/oracle/truffle/api/strings/TruffleString.WithMask.CreateUTF16Node.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,char[])` ### create() `public static TruffleString.WithMask.CreateUTF16Node create()`. Since 22.1. Create a new `TruffleString.WithMask.CreateNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.WithMask.CreateUTF16Node.html#create()` ### getUncached() `public static TruffleString.WithMask.CreateUTF16Node getUncached()`. Since 22.1. Get the uncached version of `TruffleString.WithMask.CreateNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.WithMask.CreateUTF16Node.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleString.WithMask.CreateUTF32Node [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleString.WithMask`](com/oracle/truffle/api/strings/TruffleString.WithMask.md). ```java public abstract static class TruffleString.WithMask.CreateUTF32Node extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `CreateUTF32Node` Node to create a new [`WithMask`](com/oracle/truffle/api/strings/TruffleString.WithMask.md) from a UTF-32 string and an int array. See `#execute(AbstractTruffleString, int[])` for details. ## Methods ### execute(AbstractTruffleString, int[]) `public abstract TruffleString.WithMask execute(AbstractTruffleString a, int[] mask)`. Since 22.1. Creates a new `WithMask` from `a` and `mask`. `mask.length` must be equal to the string's length in `int`s. Cite: `com/oracle/truffle/api/strings/TruffleString.WithMask.CreateUTF32Node.html#execute(com.oracle.truffle.api.strings.AbstractTruffleString,int[])` ### create() `public static TruffleString.WithMask.CreateUTF32Node create()`. Since 22.1. Create a new `TruffleString.WithMask.CreateNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.WithMask.CreateUTF32Node.html#create()` ### getUncached() `public static TruffleString.WithMask.CreateUTF32Node getUncached()`. Since 22.1. Get the uncached version of `TruffleString.WithMask.CreateNode`. Cite: `com/oracle/truffle/api/strings/TruffleString.WithMask.CreateUTF32Node.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleStringBuilder [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Sealed abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. ```java public abstract sealed class TruffleStringBuilder permits TruffleStringBuilderGeneric, TruffleStringBuilderUTF8, TruffleStringBuilderUTF16, TruffleStringBuilderUTF32 ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `TruffleStringBuilder` Permitted subtypes: `TruffleStringBuilderGeneric`, [`TruffleStringBuilderUTF8`](com/oracle/truffle/api/strings/TruffleStringBuilderUTF8.md), [`TruffleStringBuilderUTF16`](com/oracle/truffle/api/strings/TruffleStringBuilderUTF16.md), [`TruffleStringBuilderUTF32`](com/oracle/truffle/api/strings/TruffleStringBuilderUTF32.md) The [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md) equivalent to [`java.lang.StringBuilder`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/StringBuilder.html). This builder eagerly fills up a byte array with all strings passed to its `Append`-nodes. For lazy string concatenation, use [`TruffleString.ConcatNode`](com/oracle/truffle/api/strings/TruffleString.ConcatNode.md) instead. ## Nested types - [`TruffleStringBuilder.AppendByteNode`](com/oracle/truffle/api/strings/TruffleStringBuilder.AppendByteNode.md) (abstract class): Node to append a single byte to a string builder. - [`TruffleStringBuilder.AppendCharUTF16Node`](com/oracle/truffle/api/strings/TruffleStringBuilder.AppendCharUTF16Node.md) (abstract class): Node to append a single char to a string builder. - [`TruffleStringBuilder.AppendCodePointNode`](com/oracle/truffle/api/strings/TruffleStringBuilder.AppendCodePointNode.md) (abstract class): Node to append a codepoint to a string builder. - [`TruffleStringBuilder.AppendIntNumberNode`](com/oracle/truffle/api/strings/TruffleStringBuilder.AppendIntNumberNode.md) (abstract class): Node to append an integer to a string builder. - [`TruffleStringBuilder.AppendJavaStringUTF16Node`](com/oracle/truffle/api/strings/TruffleStringBuilder.AppendJavaStringUTF16Node.md) (abstract class): Node to append a substring of a given java.lang.String to a string builder. - [`TruffleStringBuilder.AppendLongNumberNode`](com/oracle/truffle/api/strings/TruffleStringBuilder.AppendLongNumberNode.md) (abstract class): Node to append a long value to a string builder. - [`TruffleStringBuilder.AppendStringNode`](com/oracle/truffle/api/strings/TruffleStringBuilder.AppendStringNode.md) (abstract class): Node to append a given TruffleString to a string builder. - [`TruffleStringBuilder.AppendSubstringByteIndexNode`](com/oracle/truffle/api/strings/TruffleStringBuilder.AppendSubstringByteIndexNode.md) (abstract class): Node to append a substring of a given TruffleString to a string builder. - [`TruffleStringBuilder.ToStringNode`](com/oracle/truffle/api/strings/TruffleStringBuilder.ToStringNode.md) (abstract class): Node to materialize a string builder as a TruffleString. ## Methods ### isEmpty() `public final boolean isEmpty()`. Since 22.1. Returns true if this string builder is empty. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.html#isEmpty()` ### byteLength() `public final int byteLength()`. Since 22.1. Returns this string builder's byte length. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.html#byteLength()` ### create(TruffleString.Encoding) `public static TruffleStringBuilder create(TruffleString.Encoding encoding)`. Since 22.1. Create a new string builder with the given encoding. If the encoding is known ahead of time, use `createUTF8()`, `createUTF16()` or `createUTF32()` instead. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.html#create(com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create(TruffleString.Encoding, int) `public static TruffleStringBuilder create(TruffleString.Encoding encoding, int initialCapacity)`. Since 22.1. Create a new string builder with the given encoding, and pre-allocate the given number of bytes. If the encoding is known ahead of time, use `createUTF8(int)`, `createUTF16(int)` or `createUTF32(int)` instead. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.html#create(com.oracle.truffle.api.strings.TruffleString.Encoding,int)` ### createUTF8() `public static TruffleStringBuilderUTF8 createUTF8()`. Since 23.1. Create a new UTF-8 string builder. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.html#createUTF8()` ### createUTF8(int) `public static TruffleStringBuilderUTF8 createUTF8(int initialCapacity)`. Since 23.1. Create a new UTF-8 string builder and pre-allocate the given number of bytes. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.html#createUTF8(int)` ### createUTF16() `public static TruffleStringBuilderUTF16 createUTF16()`. Since 23.1. Create a new UTF-16 string builder. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.html#createUTF16()` ### createUTF16(int) `public static TruffleStringBuilderUTF16 createUTF16(int initialCapacity)`. Since 23.1. Create a new UTF-16 string builder and pre-allocate the given number of chars. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.html#createUTF16(int)` ### createUTF32() `public static TruffleStringBuilderUTF32 createUTF32()`. Since 23.1. Create a new UTF-32 string builder. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.html#createUTF32()` ### createUTF32(int) `public static TruffleStringBuilderUTF32 createUTF32(int initialCapacity)`. Since 23.1. Create a new UTF-32 string builder and pre-allocate the given number of codepoints. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.html#createUTF32(int)` ### appendByteUncached(byte) `public final void appendByteUncached(byte value)`. Since 22.1. Shorthand for calling the uncached version of `AppendByteNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.html#appendByteUncached(byte)` ### appendCharUTF16Uncached(char) `public final void appendCharUTF16Uncached(char value)`. Since 22.1. Shorthand for calling the uncached version of `AppendCharUTF16Node`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.html#appendCharUTF16Uncached(char)` ### appendCodePointUncached(int) `public final void appendCodePointUncached(int codepoint)`. Since 22.1. Shorthand for calling the uncached version of `AppendCodePointNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.html#appendCodePointUncached(int)` ### appendCodePointUncached(int, int) `public final void appendCodePointUncached(int codepoint, int repeat)`. Since 22.2. Shorthand for calling the uncached version of `AppendCodePointNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.html#appendCodePointUncached(int,int)` ### appendCodePointUncached(int, int, boolean) `public final void appendCodePointUncached(int codepoint, int repeat, boolean allowUTF16Surrogates)`. Since 22.2. Shorthand for calling the uncached version of `AppendCodePointNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.html#appendCodePointUncached(int,int,boolean)` ### appendIntNumberUncached(int) `public final void appendIntNumberUncached(int value)`. Since 22.1. Shorthand for calling the uncached version of `AppendIntNumberNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.html#appendIntNumberUncached(int)` ### appendLongNumberUncached(long) `public final void appendLongNumberUncached(long value)`. Since 22.1. Shorthand for calling the uncached version of `AppendLongNumberNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.html#appendLongNumberUncached(long)` ### appendStringUncached(TruffleString) `public final void appendStringUncached(TruffleString a)`. Since 22.1. Shorthand for calling the uncached version of `AppendStringNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.html#appendStringUncached(com.oracle.truffle.api.strings.TruffleString)` ### appendSubstringByteIndexUncached(TruffleString, int, int) `public final void appendSubstringByteIndexUncached(TruffleString a, int fromByteIndex, int byteLength)`. Since 22.1. Shorthand for calling the uncached version of `AppendSubstringByteIndexNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.html#appendSubstringByteIndexUncached(com.oracle.truffle.api.strings.TruffleString,int,int)` ### appendJavaStringUTF16Uncached(String) `public final void appendJavaStringUTF16Uncached(String a)`. Since 22.1. Shorthand for calling the uncached version of `AppendJavaStringUTF16Node`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.html#appendJavaStringUTF16Uncached(java.lang.String)` ### appendJavaStringUTF16Uncached(String, int, int) `public final void appendJavaStringUTF16Uncached(String a, int fromCharIndex, int charLength)`. Since 22.1. Shorthand for calling the uncached version of `AppendJavaStringUTF16Node`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.html#appendJavaStringUTF16Uncached(java.lang.String,int,int)` ### toStringUncached() `public final TruffleString toStringUncached()`. Since 22.1. Shorthand for calling the uncached version of `ToStringNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.html#toStringUncached()` ### toString() `public final String toString()`. Since 22.1. Convert the string builder's content to a java string. Do not use this on a fast path. Overrides `toString()`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.html#toString()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleStringBuilder.AppendByteNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleStringBuilder`](com/oracle/truffle/api/strings/TruffleStringBuilder.md). ```java public abstract static class TruffleStringBuilder.AppendByteNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `AppendByteNode` Node to append a single byte to a string builder. ## Methods ### execute(TruffleStringBuilder, byte) `public abstract void execute(TruffleStringBuilder sb, byte value)`. Since 22.1. Append a single byte to the string builder. Does not support UTF-16 and UTF-32; use `AppendCharUTF16Node` and `AppendCodePointNode` instead. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendByteNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilder,byte)` ### execute(TruffleStringBuilderUTF8, byte) `public abstract void execute(TruffleStringBuilderUTF8 sb, byte value)`. Since 25.1. Overload of `execute(TruffleStringBuilder, byte)` for performance reasons. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendByteNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF8,byte)` ### create() `public static TruffleStringBuilder.AppendByteNode create()`. Since 22.1. Create a new `AppendByteNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendByteNode.html#create()` ### getUncached() `public static TruffleStringBuilder.AppendByteNode getUncached()`. Since 22.1. Get the uncached version of `AppendByteNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendByteNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleStringBuilder.AppendCharUTF16Node [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleStringBuilder`](com/oracle/truffle/api/strings/TruffleStringBuilder.md). ```java public abstract static class TruffleStringBuilder.AppendCharUTF16Node extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `AppendCharUTF16Node` Node to append a single char to a string builder. For UTF-16 only. ## Methods ### execute(TruffleStringBuilderUTF16, char) `public abstract void execute(TruffleStringBuilderUTF16 sb, char value)`. Since 22.1. Append a single char to the string builder. For UTF-16 only. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendCharUTF16Node.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF16,char)` ### create() `public static TruffleStringBuilder.AppendCharUTF16Node create()`. Since 22.1. Create a new `AppendCharUTF16Node`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendCharUTF16Node.html#create()` ### getUncached() `public static TruffleStringBuilder.AppendCharUTF16Node getUncached()`. Since 22.1. Get the uncached version of `AppendCharUTF16Node`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendCharUTF16Node.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleStringBuilder.AppendCodePointNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleStringBuilder`](com/oracle/truffle/api/strings/TruffleStringBuilder.md). ```java public abstract static class TruffleStringBuilder.AppendCodePointNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `AppendCodePointNode` Node to append a codepoint to a string builder. ## Methods ### execute(TruffleStringBuilder, int) `public final void execute(TruffleStringBuilder sb, int codepoint)`. Since 22.1. Append a codepoint to the string builder. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendCodePointNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilder,int)` ### execute(TruffleStringBuilderUTF8, int) `public final void execute(TruffleStringBuilderUTF8 sb, int codepoint)`. Since 25.1. Overload of `execute(TruffleStringBuilder, int)` for performance reasons. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendCodePointNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF8,int)` ### execute(TruffleStringBuilderUTF16, int) `public final void execute(TruffleStringBuilderUTF16 sb, int codepoint)`. Since 25.1. Overload of `execute(TruffleStringBuilder, int)` for performance reasons. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendCodePointNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF16,int)` ### execute(TruffleStringBuilderUTF32, int) `public final void execute(TruffleStringBuilderUTF32 sb, int codepoint)`. Since 25.1. Overload of `execute(TruffleStringBuilder, int)` for performance reasons. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendCodePointNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF32,int)` ### execute(TruffleStringBuilder, int, int) `public final void execute(TruffleStringBuilder sb, int codepoint, int repeat)`. Since 22.2. Append a codepoint to the string builder, `repeat` times. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendCodePointNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilder,int,int)` ### execute(TruffleStringBuilderUTF8, int, int) `public final void execute(TruffleStringBuilderUTF8 sb, int codepoint, int repeat)`. Since 25.1. Overload of `execute(TruffleStringBuilder, int, int)` for performance reasons. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendCodePointNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF8,int,int)` ### execute(TruffleStringBuilderUTF16, int, int) `public final void execute(TruffleStringBuilderUTF16 sb, int codepoint, int repeat)`. Since 25.1. Overload of `execute(TruffleStringBuilder, int, int)` for performance reasons. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendCodePointNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF16,int,int)` ### execute(TruffleStringBuilderUTF32, int, int) `public final void execute(TruffleStringBuilderUTF32 sb, int codepoint, int repeat)`. Since 25.1. Overload of `execute(TruffleStringBuilder, int, int)` for performance reasons. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendCodePointNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF32,int,int)` ### execute(TruffleStringBuilder, int, …) `public abstract void execute(TruffleStringBuilder sb, int codepoint, int repeat, boolean allowUTF16Surrogates)`. Since 22.2. Append a codepoint to the string builder, `repeat` times. If `allowUTF16Surrogates` is `true`, [`UTF-16 surrogate values`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Character.html#isSurrogate%28char%29) passed as `codepoint` will not cause an [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html), but instead be encoded on a best-effort basis. This option is only supported on `Encoding.UTF_16` and `Encoding.UTF_32`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendCodePointNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilder,int,int,boolean)` ### execute(TruffleStringBuilderUTF8, int, …) `public abstract void execute(TruffleStringBuilderUTF8 sb, int codepoint, int repeat, boolean allowUTF16Surrogates)`. Since 25.1. Overload of `execute(TruffleStringBuilder, int, int, boolean)` for performance reasons. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendCodePointNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF8,int,int,boolean)` ### execute(TruffleStringBuilderUTF16, int, …) `public abstract void execute(TruffleStringBuilderUTF16 sb, int codepoint, int repeat, boolean allowUTF16Surrogates)`. Since 25.1. Overload of `execute(TruffleStringBuilder, int, int, boolean)` for performance reasons. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendCodePointNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF16,int,int,boolean)` ### execute(TruffleStringBuilderUTF32, int, …) `public abstract void execute(TruffleStringBuilderUTF32 sb, int codepoint, int repeat, boolean allowUTF16Surrogates)`. Since 25.1. Overload of `execute(TruffleStringBuilder, int, int, boolean)` for performance reasons. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendCodePointNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF32,int,int,boolean)` ### create() `public static TruffleStringBuilder.AppendCodePointNode create()`. Since 22.1. Create a new `AppendCodePointNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendCodePointNode.html#create()` ### getUncached() `public static TruffleStringBuilder.AppendCodePointNode getUncached()`. Since 22.1. Get the uncached version of `AppendCodePointNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendCodePointNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleStringBuilder.AppendIntNumberNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleStringBuilder`](com/oracle/truffle/api/strings/TruffleStringBuilder.md). ```java public abstract static class TruffleStringBuilder.AppendIntNumberNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `AppendIntNumberNode` Node to append an integer to a string builder. See [`execute(TruffleStringBuilder, int)`](com/oracle/truffle/api/strings/TruffleStringBuilder.AppendIntNumberNode.md#execute%28com.oracle.truffle.api.strings.TruffleStringBuilder,int%29) for details. ## Methods ### execute(TruffleStringBuilder, int) `public abstract void execute(TruffleStringBuilder sb, int value)`. Since 22.1. Append the base-10 string equivalent of a given integer to the string builder. For ASCII-compatible encodings only. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendIntNumberNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilder,int)` ### execute(TruffleStringBuilderUTF8, int) `public abstract void execute(TruffleStringBuilderUTF8 sb, int value)`. Since 25.1. Overload of `execute(TruffleStringBuilder, int)` for performance reasons. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendIntNumberNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF8,int)` ### execute(TruffleStringBuilderUTF16, int) `public abstract void execute(TruffleStringBuilderUTF16 sb, int value)`. Since 25.1. Overload of `execute(TruffleStringBuilder, int)` for performance reasons. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendIntNumberNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF16,int)` ### execute(TruffleStringBuilderUTF32, int) `public abstract void execute(TruffleStringBuilderUTF32 sb, int value)`. Since 25.1. Overload of `execute(TruffleStringBuilder, int)` for performance reasons. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendIntNumberNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF32,int)` ### create() `public static TruffleStringBuilder.AppendIntNumberNode create()`. Since 22.1. Create a new `AppendIntNumberNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendIntNumberNode.html#create()` ### getUncached() `public static TruffleStringBuilder.AppendIntNumberNode getUncached()`. Since 22.1. Get the uncached version of `AppendIntNumberNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendIntNumberNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleStringBuilder.AppendJavaStringUTF16Node [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleStringBuilder`](com/oracle/truffle/api/strings/TruffleStringBuilder.md). ```java public abstract static class TruffleStringBuilder.AppendJavaStringUTF16Node extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `AppendJavaStringUTF16Node` Node to append a substring of a given [`java.lang.String`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html) to a string builder. See [`execute(TruffleStringBuilderUTF16, String, int, int)`](com/oracle/truffle/api/strings/TruffleStringBuilder.AppendJavaStringUTF16Node.md#execute%28com.oracle.truffle.api.strings.TruffleStringBuilderUTF16,java.lang.String,int,int%29) for details. ## Methods ### execute(TruffleStringBuilderUTF16, String) `public final void execute(TruffleStringBuilderUTF16 sb, String a)`. Since 22.1. Append a substring of a given [`java.lang.String`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html) to the string builder. For UTF-16 only. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendJavaStringUTF16Node.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF16,java.lang.String)` ### execute(TruffleStringBuilderUTF16, String, …) `public abstract void execute(TruffleStringBuilderUTF16 sb, String a, int fromCharIndex, int charLength)`. Since 22.1. Append a substring of a given [`java.lang.String`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html), starting at char index `fromIndex` and ending at `fromIndex + length`, to the string builder. For UTF-16 only. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendJavaStringUTF16Node.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF16,java.lang.String,int,int)` ### create() `public static TruffleStringBuilder.AppendJavaStringUTF16Node create()`. Since 22.1. Create a new `AppendJavaStringUTF16Node`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendJavaStringUTF16Node.html#create()` ### getUncached() `public static TruffleStringBuilder.AppendJavaStringUTF16Node getUncached()`. Since 22.1. Get the uncached version of `AppendJavaStringUTF16Node`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendJavaStringUTF16Node.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleStringBuilder.AppendLongNumberNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleStringBuilder`](com/oracle/truffle/api/strings/TruffleStringBuilder.md). ```java public abstract static class TruffleStringBuilder.AppendLongNumberNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `AppendLongNumberNode` Node to append a `long` value to a string builder. See [`execute(TruffleStringBuilder, long)`](com/oracle/truffle/api/strings/TruffleStringBuilder.AppendLongNumberNode.md#execute%28com.oracle.truffle.api.strings.TruffleStringBuilder,long%29) for details. ## Methods ### execute(TruffleStringBuilder, long) `public abstract void execute(TruffleStringBuilder sb, long value)`. Since 22.1. Append the base-10 string equivalent of a given long value to the string builder. For ASCII-compatible encodings only. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendLongNumberNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilder,long)` ### execute(TruffleStringBuilderUTF8, long) `public abstract void execute(TruffleStringBuilderUTF8 sb, long value)`. Since 25.1. Overload of `execute(TruffleStringBuilder, long)` for performance reasons. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendLongNumberNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF8,long)` ### execute(TruffleStringBuilderUTF16, long) `public abstract void execute(TruffleStringBuilderUTF16 sb, long value)`. Since 25.1. Overload of `execute(TruffleStringBuilder, long)` for performance reasons. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendLongNumberNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF16,long)` ### execute(TruffleStringBuilderUTF32, long) `public abstract void execute(TruffleStringBuilderUTF32 sb, long value)`. Since 25.1. Overload of `execute(TruffleStringBuilder, long)` for performance reasons. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendLongNumberNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF32,long)` ### create() `public static TruffleStringBuilder.AppendLongNumberNode create()`. Since 22.1. Create a new `AppendLongNumberNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendLongNumberNode.html#create()` ### getUncached() `public static TruffleStringBuilder.AppendLongNumberNode getUncached()`. Since 22.1. Get the uncached version of `AppendLongNumberNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendLongNumberNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleStringBuilder.AppendStringNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleStringBuilder`](com/oracle/truffle/api/strings/TruffleStringBuilder.md). ```java public abstract static class TruffleStringBuilder.AppendStringNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `AppendStringNode` Node to append a given [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md) to a string builder. ## Methods ### execute(TruffleStringBuilder, AbstractTruffleString) `public abstract void execute(TruffleStringBuilder sb, AbstractTruffleString a)`. Since 22.1. Append a given `TruffleString` to the string builder. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendStringNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilder,com.oracle.truffle.api.strings.AbstractTruffleString)` ### execute(TruffleStringBuilderUTF8, AbstractTruffleString) `public abstract void execute(TruffleStringBuilderUTF8 sb, AbstractTruffleString a)`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendStringNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF8,com.oracle.truffle.api.strings.AbstractTruffleString)` ### execute(TruffleStringBuilderUTF16, AbstractTruffleString) `public abstract void execute(TruffleStringBuilderUTF16 sb, AbstractTruffleString a)`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendStringNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF16,com.oracle.truffle.api.strings.AbstractTruffleString)` ### execute(TruffleStringBuilderUTF32, AbstractTruffleString) `public abstract void execute(TruffleStringBuilderUTF32 sb, AbstractTruffleString a)`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendStringNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF32,com.oracle.truffle.api.strings.AbstractTruffleString)` ### create() `public static TruffleStringBuilder.AppendStringNode create()`. Since 22.1. Create a new `AppendStringNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendStringNode.html#create()` ### getUncached() `public static TruffleStringBuilder.AppendStringNode getUncached()`. Since 22.1. Get the uncached version of `AppendStringNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendStringNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleStringBuilder.AppendSubstringByteIndexNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleStringBuilder`](com/oracle/truffle/api/strings/TruffleStringBuilder.md). ```java public abstract static class TruffleStringBuilder.AppendSubstringByteIndexNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `AppendSubstringByteIndexNode` Node to append a substring of a given [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md) to a string builder. See [`execute(TruffleStringBuilder, AbstractTruffleString, int, int)`](com/oracle/truffle/api/strings/TruffleStringBuilder.AppendSubstringByteIndexNode.md#execute%28com.oracle.truffle.api.strings.TruffleStringBuilder,com.oracle.truffle.api.strings.AbstractTruffleString,int,int%29) for details. ## Methods ### execute(TruffleStringBuilder, AbstractTruffleString, …) `public abstract void execute(TruffleStringBuilder sb, AbstractTruffleString a, int fromByteIndex, int byteLength)`. Since 22.1. Append a substring of a given `TruffleString`, starting at byte index `fromByteIndex` and ending at byte index `fromByteIndex + byteLength`, to the string builder. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendSubstringByteIndexNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilder,com.oracle.truffle.api.strings.AbstractTruffleString,int,int)` ### execute(TruffleStringBuilderUTF8, AbstractTruffleString, …) `public abstract void execute(TruffleStringBuilderUTF8 sb, AbstractTruffleString a, int fromByteIndex, int byteLength)`. Since 25.1. Overload of `execute(TruffleStringBuilder, AbstractTruffleString, int, int)` for performance reasons. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendSubstringByteIndexNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF8,com.oracle.truffle.api.strings.AbstractTruffleString,int,int)` ### execute(TruffleStringBuilderUTF16, AbstractTruffleString, …) `public abstract void execute(TruffleStringBuilderUTF16 sb, AbstractTruffleString a, int fromByteIndex, int byteLength)`. Since 25.1. Overload of `execute(TruffleStringBuilder, AbstractTruffleString, int, int)` for performance reasons. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendSubstringByteIndexNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF16,com.oracle.truffle.api.strings.AbstractTruffleString,int,int)` ### execute(TruffleStringBuilderUTF32, AbstractTruffleString, …) `public abstract void execute(TruffleStringBuilderUTF32 sb, AbstractTruffleString a, int fromByteIndex, int byteLength)`. Since 25.1. Overload of `execute(TruffleStringBuilder, AbstractTruffleString, int, int)` for performance reasons. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendSubstringByteIndexNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF32,com.oracle.truffle.api.strings.AbstractTruffleString,int,int)` ### create() `public static TruffleStringBuilder.AppendSubstringByteIndexNode create()`. Since 22.1. Create a new `AppendSubstringByteIndexNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendSubstringByteIndexNode.html#create()` ### getUncached() `public static TruffleStringBuilder.AppendSubstringByteIndexNode getUncached()`. Since 22.1. Get the uncached version of `AppendSubstringByteIndexNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.AppendSubstringByteIndexNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleStringBuilder.ToStringNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleStringBuilder`](com/oracle/truffle/api/strings/TruffleStringBuilder.md). ```java public abstract static class TruffleStringBuilder.ToStringNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `ToStringNode` Node to materialize a string builder as a [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md). ## Methods ### execute(TruffleStringBuilder) `public final TruffleString execute(TruffleStringBuilder sb)`. Since 22.1. Materialize this string builder to a `TruffleString`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.ToStringNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilder)` ### execute(TruffleStringBuilderUTF8) `public final TruffleString execute(TruffleStringBuilderUTF8 sb)`. Since 25.1. Overload of `execute(TruffleStringBuilder)` for performance reasons. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.ToStringNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF8)` ### execute(TruffleStringBuilderUTF16) `public final TruffleString execute(TruffleStringBuilderUTF16 sb)`. Since 25.1. Overload of `execute(TruffleStringBuilder)` for performance reasons. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.ToStringNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF16)` ### execute(TruffleStringBuilderUTF32) `public final TruffleString execute(TruffleStringBuilderUTF32 sb)`. Since 25.1. Overload of `execute(TruffleStringBuilder)` for performance reasons. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.ToStringNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF32)` ### execute(TruffleStringBuilder, boolean) `public abstract TruffleString execute(TruffleStringBuilder sb, boolean lazy)`. Since 22.1. Materialize this string builder to a `TruffleString`. If `lazy` is `true`, `sb`'s internal storage will be re-used even if there are unused bytes. Since the resulting string will have a reference to `sb`'s internal storage, and `TruffleString` currently does *not* resize/trim the substring's internal storage at any point, the `lazy` variant effectively creates a memory leak! The caller is responsible for deciding whether this is acceptable or not. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.ToStringNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilder,boolean)` ### execute(TruffleStringBuilderUTF8, boolean) `public abstract TruffleString execute(TruffleStringBuilderUTF8 sb, boolean lazy)`. Since 25.1. Overload of `execute(TruffleStringBuilder, boolean)` for performance reasons. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.ToStringNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF8,boolean)` ### execute(TruffleStringBuilderUTF16, boolean) `public abstract TruffleString execute(TruffleStringBuilderUTF16 sb, boolean lazy)`. Since 25.1. Overload of `execute(TruffleStringBuilder, boolean)` for performance reasons. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.ToStringNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF16,boolean)` ### execute(TruffleStringBuilderUTF32, boolean) `public abstract TruffleString execute(TruffleStringBuilderUTF32 sb, boolean lazy)`. Since 25.1. Overload of `execute(TruffleStringBuilder, boolean)` for performance reasons. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.ToStringNode.html#execute(com.oracle.truffle.api.strings.TruffleStringBuilderUTF32,boolean)` ### create() `public static TruffleStringBuilder.ToStringNode create()`. Since 22.1. Create a new `ToStringNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.ToStringNode.html#create()` ### getUncached() `public static TruffleStringBuilder.ToStringNode getUncached()`. Since 22.1. Get the uncached version of `ToStringNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilder.ToStringNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleStringBuilderFactory [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). ```java public final class TruffleStringBuilderFactory ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `TruffleStringBuilderFactory` ## Constructors ### TruffleStringBuilderFactory() `public TruffleStringBuilderFactory()`. Declared by the compiler. Creates a new TruffleStringBuilderFactory instance. Cite: `com/oracle/truffle/api/strings/TruffleStringBuilderFactory.html#()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleStringBuilderUTF16 [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 23.1. ```java public final class TruffleStringBuilderUTF16 extends TruffleStringBuilder ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`TruffleStringBuilder`](com/oracle/truffle/api/strings/TruffleStringBuilder.md) > `TruffleStringBuilderUTF16` The UTF-16-specific variant of [`TruffleStringBuilder`](com/oracle/truffle/api/strings/TruffleStringBuilder.md). For best performance, use this type explicitly wherever possible. ## Inherited members - From class [`TruffleStringBuilder`](com/oracle/truffle/api/strings/TruffleStringBuilder.md): [`appendByteUncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendByteUncached%28byte%29), [`appendCharUTF16Uncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendCharUTF16Uncached%28char%29), [`appendCodePointUncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendCodePointUncached%28int%29), [`appendCodePointUncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendCodePointUncached%28int,int%29), [`appendCodePointUncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendCodePointUncached%28int,int,boolean%29), [`appendIntNumberUncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendIntNumberUncached%28int%29), [`appendJavaStringUTF16Uncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendJavaStringUTF16Uncached%28java.lang.String%29), [`appendJavaStringUTF16Uncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendJavaStringUTF16Uncached%28java.lang.String,int,int%29), [`appendLongNumberUncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendLongNumberUncached%28long%29), [`appendStringUncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendStringUncached%28com.oracle.truffle.api.strings.TruffleString%29), [`appendSubstringByteIndexUncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendSubstringByteIndexUncached%28com.oracle.truffle.api.strings.TruffleString,int,int%29), [`byteLength`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#byteLength%28%29), [`create`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#create%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`create`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#create%28com.oracle.truffle.api.strings.TruffleString.Encoding,int%29), [`createUTF16`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#createUTF16%28%29), [`createUTF16`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#createUTF16%28int%29), [`createUTF32`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#createUTF32%28%29), [`createUTF32`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#createUTF32%28int%29), [`createUTF8`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#createUTF8%28%29), [`createUTF8`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#createUTF8%28int%29), [`isEmpty`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#isEmpty%28%29), [`toString`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#toString%28%29), [`toStringUncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#toStringUncached%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleStringBuilderUTF32 [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 23.1. ```java public final class TruffleStringBuilderUTF32 extends TruffleStringBuilder ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`TruffleStringBuilder`](com/oracle/truffle/api/strings/TruffleStringBuilder.md) > `TruffleStringBuilderUTF32` The UTF-32-specific variant of [`TruffleStringBuilder`](com/oracle/truffle/api/strings/TruffleStringBuilder.md). For best performance, use this type explicitly wherever possible. ## Inherited members - From class [`TruffleStringBuilder`](com/oracle/truffle/api/strings/TruffleStringBuilder.md): [`appendByteUncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendByteUncached%28byte%29), [`appendCharUTF16Uncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendCharUTF16Uncached%28char%29), [`appendCodePointUncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendCodePointUncached%28int%29), [`appendCodePointUncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendCodePointUncached%28int,int%29), [`appendCodePointUncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendCodePointUncached%28int,int,boolean%29), [`appendIntNumberUncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendIntNumberUncached%28int%29), [`appendJavaStringUTF16Uncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendJavaStringUTF16Uncached%28java.lang.String%29), [`appendJavaStringUTF16Uncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendJavaStringUTF16Uncached%28java.lang.String,int,int%29), [`appendLongNumberUncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendLongNumberUncached%28long%29), [`appendStringUncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendStringUncached%28com.oracle.truffle.api.strings.TruffleString%29), [`appendSubstringByteIndexUncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendSubstringByteIndexUncached%28com.oracle.truffle.api.strings.TruffleString,int,int%29), [`byteLength`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#byteLength%28%29), [`create`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#create%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`create`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#create%28com.oracle.truffle.api.strings.TruffleString.Encoding,int%29), [`createUTF16`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#createUTF16%28%29), [`createUTF16`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#createUTF16%28int%29), [`createUTF32`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#createUTF32%28%29), [`createUTF32`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#createUTF32%28int%29), [`createUTF8`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#createUTF8%28%29), [`createUTF8`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#createUTF8%28int%29), [`isEmpty`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#isEmpty%28%29), [`toString`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#toString%28%29), [`toStringUncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#toStringUncached%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleStringBuilderUTF8 [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 23.1. ```java public final class TruffleStringBuilderUTF8 extends TruffleStringBuilder ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`TruffleStringBuilder`](com/oracle/truffle/api/strings/TruffleStringBuilder.md) > `TruffleStringBuilderUTF8` The UTF-8-specific variant of [`TruffleStringBuilder`](com/oracle/truffle/api/strings/TruffleStringBuilder.md). For best performance, use this type explicitly wherever possible. ## Inherited members - From class [`TruffleStringBuilder`](com/oracle/truffle/api/strings/TruffleStringBuilder.md): [`appendByteUncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendByteUncached%28byte%29), [`appendCharUTF16Uncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendCharUTF16Uncached%28char%29), [`appendCodePointUncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendCodePointUncached%28int%29), [`appendCodePointUncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendCodePointUncached%28int,int%29), [`appendCodePointUncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendCodePointUncached%28int,int,boolean%29), [`appendIntNumberUncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendIntNumberUncached%28int%29), [`appendJavaStringUTF16Uncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendJavaStringUTF16Uncached%28java.lang.String%29), [`appendJavaStringUTF16Uncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendJavaStringUTF16Uncached%28java.lang.String,int,int%29), [`appendLongNumberUncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendLongNumberUncached%28long%29), [`appendStringUncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendStringUncached%28com.oracle.truffle.api.strings.TruffleString%29), [`appendSubstringByteIndexUncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#appendSubstringByteIndexUncached%28com.oracle.truffle.api.strings.TruffleString,int,int%29), [`byteLength`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#byteLength%28%29), [`create`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#create%28com.oracle.truffle.api.strings.TruffleString.Encoding%29), [`create`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#create%28com.oracle.truffle.api.strings.TruffleString.Encoding,int%29), [`createUTF16`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#createUTF16%28%29), [`createUTF16`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#createUTF16%28int%29), [`createUTF32`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#createUTF32%28%29), [`createUTF32`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#createUTF32%28int%29), [`createUTF8`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#createUTF8%28%29), [`createUTF8`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#createUTF8%28int%29), [`isEmpty`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#isEmpty%28%29), [`toString`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#toString%28%29), [`toStringUncached`](com/oracle/truffle/api/strings/TruffleStringBuilder.md#toStringUncached%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleStringFactory [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). ```java public final class TruffleStringFactory ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `TruffleStringFactory` ## Nested types - [`TruffleStringFactory.WithMaskFactory`](com/oracle/truffle/api/strings/TruffleStringFactory.WithMaskFactory.md) (class): No description. ## Constructors ### TruffleStringFactory() `public TruffleStringFactory()`. Declared by the compiler. Creates a new TruffleStringFactory instance. Cite: `com/oracle/truffle/api/strings/TruffleStringFactory.html#()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleStringFactory.WithMaskFactory [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Nested in [`TruffleStringFactory`](com/oracle/truffle/api/strings/TruffleStringFactory.md). ```java public static final class TruffleStringFactory.WithMaskFactory ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `WithMaskFactory` ## Constructors ### WithMaskFactory() `public WithMaskFactory()`. Declared by the compiler. Creates a new WithMaskFactory instance. Cite: `com/oracle/truffle/api/strings/TruffleStringFactory.WithMaskFactory.html#()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleStringIterator [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. ```java public final class TruffleStringIterator ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `TruffleStringIterator` An iterator object that allows iterating over a [`TruffleString`](com/oracle/truffle/api/strings/TruffleString.md)'s codepoints, without having to re-calculate codepoint indices on every access. Usage Example: ```java abstract static class SomeNode extends Node { @Specialization static void someSpecialization( TruffleString string, @Cached TruffleString.CreateCodePointIteratorNode createCodePointIteratorNode, @Cached TruffleStringIterator.NextNode nextNode, @Cached TruffleString.CodePointLengthNode codePointLengthNode, @Cached TruffleString.CodePointAtIndexNode codePointAtIndexNode) { // iterating over a string's code points using TruffleStringIterator TruffleStringIterator iterator = createCodePointIteratorNode.execute(string, Encoding.UTF_8); while (iterator.hasNext()) { System.out.printf("%x%n", nextNode.execute(iterator)); } // uncached variant: TruffleStringIterator iterator2 = string.createCodePointIteratorUncached(Encoding.UTF_8); while (iterator2.hasNext()) { System.out.printf("%x%n", iterator2.nextUncached()); } // suboptimal variant: using CodePointAtIndexNode in a loop int codePointLength = codePointLengthNode.execute(string, Encoding.UTF_8); for (int i = 0; i < codePointLength; i++) { // performance problem: codePointAtIndexNode may have to calculate the byte index // corresponding // to codepoint index i for every loop iteration System.out.printf("%x%n", codePointAtIndexNode.execute(string, i, Encoding.UTF_8)); } } } ``` ## Nested types - [`TruffleStringIterator.NextNode`](com/oracle/truffle/api/strings/TruffleStringIterator.NextNode.md) (abstract class): Returns the next codepoint in the string. - [`TruffleStringIterator.PreviousNode`](com/oracle/truffle/api/strings/TruffleStringIterator.PreviousNode.md) (abstract class): Returns the previous codepoint in the string. ## Methods ### hasNext() `public boolean hasNext()`. Since 22.1. Returns `true` if there are more codepoints remaining. Cite: `com/oracle/truffle/api/strings/TruffleStringIterator.html#hasNext()` ### hasPrevious() `public boolean hasPrevious()`. Since 22.1. Returns `true` if there are more codepoints remaining in reverse direction. Cite: `com/oracle/truffle/api/strings/TruffleStringIterator.html#hasPrevious()` ### getByteIndex() `public int getByteIndex()`. Since 22.3. Returns the next codepoint's byte index, where "byte index" refers the codepoint's first byte in forward mode, while in backward mode it refers to the first byte *after* the codepoint. Cite: `com/oracle/truffle/api/strings/TruffleStringIterator.html#getByteIndex()` ### nextUncached() `@Deprecated(since = "25.0") public int nextUncached()`. Since 22.1. Deprecated since 25.0. use `nextUncached(Encoding)` instead. Shorthand for calling the uncached version of `NextNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringIterator.html#nextUncached()` ### nextUncached(TruffleString.Encoding) `public int nextUncached(TruffleString.Encoding expectedEncoding)`. Since 25.0. Shorthand for calling the uncached version of `NextNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringIterator.html#nextUncached(com.oracle.truffle.api.strings.TruffleString.Encoding)` ### previousUncached() `@Deprecated(since = "25.0") public int previousUncached()`. Since 22.1. Deprecated since 25.0. use `previousUncached(Encoding)` instead. Shorthand for calling the uncached version of `PreviousNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringIterator.html#previousUncached()` ### previousUncached(TruffleString.Encoding) `public int previousUncached(TruffleString.Encoding expectedEncoding)`. Since 25.0. Shorthand for calling the uncached version of `PreviousNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringIterator.html#previousUncached(com.oracle.truffle.api.strings.TruffleString.Encoding)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleStringIterator.NextNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleStringIterator`](com/oracle/truffle/api/strings/TruffleStringIterator.md). ```java public abstract static class TruffleStringIterator.NextNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `NextNode` Returns the next codepoint in the string. ## Methods ### execute(TruffleStringIterator) `@Deprecated(since = "25.0") public final int execute(TruffleStringIterator it)`. Since 22.1. Deprecated since 25.0. use `execute(TruffleStringIterator, Encoding)` instead. Returns the next codepoint in the string. Cite: `com/oracle/truffle/api/strings/TruffleStringIterator.NextNode.html#execute(com.oracle.truffle.api.strings.TruffleStringIterator)` ### execute(TruffleStringIterator, TruffleString.Encoding) `public abstract int execute(TruffleStringIterator it, TruffleString.Encoding encoding)`. Since 25.0. Returns the next codepoint in the string. Cite: `com/oracle/truffle/api/strings/TruffleStringIterator.NextNode.html#execute(com.oracle.truffle.api.strings.TruffleStringIterator,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleStringIterator.NextNode create()`. Since 22.1. Create a new `NextNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringIterator.NextNode.html#create()` ### getUncached() `public static TruffleStringIterator.NextNode getUncached()`. Since 22.1. Get the uncached version of `NextNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringIterator.NextNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleStringIterator.PreviousNode [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). Since 22.1. Nested in [`TruffleStringIterator`](com/oracle/truffle/api/strings/TruffleStringIterator.md). ```java public abstract static class TruffleStringIterator.PreviousNode extends AbstractPublicNode ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Node`](com/oracle/truffle/api/nodes/Node.md) > `AbstractPublicNode` > `PreviousNode` Returns the previous codepoint in the string. ## Methods ### execute(TruffleStringIterator) `@Deprecated(since = "25.0") public final int execute(TruffleStringIterator it)`. Since 22.1. Deprecated since 25.0. use `execute(TruffleStringIterator, Encoding)` instead. Returns the previous codepoint in the string. Cite: `com/oracle/truffle/api/strings/TruffleStringIterator.PreviousNode.html#execute(com.oracle.truffle.api.strings.TruffleStringIterator)` ### execute(TruffleStringIterator, TruffleString.Encoding) `public abstract int execute(TruffleStringIterator it, TruffleString.Encoding encoding)`. Since 25.0. Returns the previous codepoint in the string. Cite: `com/oracle/truffle/api/strings/TruffleStringIterator.PreviousNode.html#execute(com.oracle.truffle.api.strings.TruffleStringIterator,com.oracle.truffle.api.strings.TruffleString.Encoding)` ### create() `public static TruffleStringIterator.PreviousNode create()`. Since 22.1. Create a new `PreviousNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringIterator.PreviousNode.html#create()` ### getUncached() `public static TruffleStringIterator.PreviousNode getUncached()`. Since 22.1. Get the uncached version of `PreviousNode`. Cite: `com/oracle/truffle/api/strings/TruffleStringIterator.PreviousNode.html#getUncached()` ## Inherited members - From class [`Node`](com/oracle/truffle/api/nodes/Node.md): [`accept`](com/oracle/truffle/api/nodes/Node.md#accept%28com.oracle.truffle.api.nodes.NodeVisitor%29), [`adoptChildren`](com/oracle/truffle/api/nodes/Node.md#adoptChildren%28%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.lang.Runnable%29), [`atomic`](com/oracle/truffle/api/nodes/Node.md#atomic%28java.util.concurrent.Callable%29), [`copy`](com/oracle/truffle/api/nodes/Node.md#copy%28%29), [`deepCopy`](com/oracle/truffle/api/nodes/Node.md#deepCopy%28%29), [`getChildren`](com/oracle/truffle/api/nodes/Node.md#getChildren%28%29), [`getCost`](com/oracle/truffle/api/nodes/Node.md#getCost%28%29), [`getDebugProperties`](com/oracle/truffle/api/nodes/Node.md#getDebugProperties%28%29), [`getDescription`](com/oracle/truffle/api/nodes/Node.md#getDescription%28%29), [`getEncapsulatingSourceSection`](com/oracle/truffle/api/nodes/Node.md#getEncapsulatingSourceSection%28%29), [`getLock`](com/oracle/truffle/api/nodes/Node.md#getLock%28%29), [`getParent`](com/oracle/truffle/api/nodes/Node.md#getParent%28%29), [`getRootNode`](com/oracle/truffle/api/nodes/Node.md#getRootNode%28%29), [`getSourceSection`](com/oracle/truffle/api/nodes/Node.md#getSourceSection%28%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T%29), [`insert`](com/oracle/truffle/api/nodes/Node.md#insert%28T[]%29), [`isAdoptable`](com/oracle/truffle/api/nodes/Node.md#isAdoptable%28%29), [`isSafelyReplaceableBy`](com/oracle/truffle/api/nodes/Node.md#isSafelyReplaceableBy%28com.oracle.truffle.api.nodes.Node%29), [`notifyInserted`](com/oracle/truffle/api/nodes/Node.md#notifyInserted%28com.oracle.truffle.api.nodes.Node%29), [`onReplace`](com/oracle/truffle/api/nodes/Node.md#onReplace%28com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T%29), [`replace`](com/oracle/truffle/api/nodes/Node.md#replace%28T,java.lang.CharSequence%29), [`reportPolymorphicSpecialize`](com/oracle/truffle/api/nodes/Node.md#reportPolymorphicSpecialize%28%29), [`reportReplace`](com/oracle/truffle/api/nodes/Node.md#reportReplace%28com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.CharSequence%29), [`toString`](com/oracle/truffle/api/nodes/Node.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleStringIteratorFactory [truffle-api](index.md) › [com.oracle.truffle.api.strings](com/oracle/truffle/api/strings/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.strings`](com/oracle/truffle/api/strings/index.md). ```java public final class TruffleStringIteratorFactory ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `TruffleStringIteratorFactory` ## Constructors ### TruffleStringIteratorFactory() `public TruffleStringIteratorFactory()`. Declared by the compiler. Creates a new TruffleStringIteratorFactory instance. Cite: `com/oracle/truffle/api/strings/TruffleStringIteratorFactory.html#()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ▣ com.oracle.truffle.api.utilities [truffle-api](index.md) · Every page: [llms.txt](llms.txt) Package in truffle-api. Since 0.8 or older. Various utility classes that aim to make the development of TruffleLanguage guest languages easier. We try to capture common language patterns in this package. Here is an overview of patterns that we have captured so far: - [`com.oracle.truffle.api.utilities.AssumedValue`](com/oracle/truffle/api/utilities/AssumedValue.md) speculates on global values to remain unchanged. - [`com.oracle.truffle.api.utilities.CyclicAssumption`](com/oracle/truffle/api/utilities/CyclicAssumption.md) speculates on assumptions that might invalidate more often but are assumed to stabilize over time. ## Classes - [`AssumedValue`](com/oracle/truffle/api/utilities/AssumedValue.md): A value that the compiler can assume is constant, but can be changed by invalidation. - [`CyclicAssumption`](com/oracle/truffle/api/utilities/CyclicAssumption.md): Holds an Assumption, and knows how to recreate it with the same properties on invalidation. - [`FinalBitSet`](com/oracle/truffle/api/utilities/FinalBitSet.md): Read-only bitset designed for partial evaluation. - [`JSONHelper`](com/oracle/truffle/api/utilities/JSONHelper.md): Helper function that allows to dump the AST during creation to a JSON format. - [`MathUtils`](com/oracle/truffle/api/utilities/MathUtils.md): This class contains mathematical methods that are not already provided by java.lang.Math that are generally useful for language implementations. - [`TruffleWeakReference`](com/oracle/truffle/api/utilities/TruffleWeakReference.md): Creates a new weak reference that is safe to be used in compiled code paths. ## Enums - [`TriState`](com/oracle/truffle/api/utilities/TriState.md): An utility value with three states, TRUE, FALSE, and UNDEFINED. # ◆ AssumedValue [truffle-api](index.md) › [com.oracle.truffle.api.utilities](com/oracle/truffle/api/utilities/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.utilities`](com/oracle/truffle/api/utilities/index.md). Since 0.8 or earlier. ```java public class AssumedValue ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `AssumedValue` A value that the compiler can assume is constant, but can be changed by invalidation. Compiled code that uses the value will be invalidated each time the value changes, so you should take care to only change values infrequently, or to monitor the number of times the value has changed and at some point to replace the value with something more generic so that it does not have to be changed and code does not have to keep being recompiled. ## Constructors ### AssumedValue(T) `public AssumedValue(T initialValue)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/utilities/AssumedValue.html#(T)` ### AssumedValue(String, T) `public AssumedValue(String name, T initialValue)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/utilities/AssumedValue.html#(java.lang.String,T)` ## Methods ### get() `public T get()`. Since 0.8 or earlier. Get the current value, updating it if it has been `set`. The compiler may be able to make this method return a constant value, but still accommodate mutation. Cite: `com/oracle/truffle/api/utilities/AssumedValue.html#get()` ### set(T) `public void set(T newValue)`. Since 0.8 or earlier. Set a new value, which will be picked up the next time `get` is called. Cite: `com/oracle/truffle/api/utilities/AssumedValue.html#set(T)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ CyclicAssumption [truffle-api](index.md) › [com.oracle.truffle.api.utilities](com/oracle/truffle/api/utilities/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.utilities`](com/oracle/truffle/api/utilities/index.md). Since 0.8 or earlier. ```java public class CyclicAssumption ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `CyclicAssumption` Holds an [`Assumption`](com/oracle/truffle/api/Assumption.md), and knows how to recreate it with the same properties on invalidation. Used as an Assumption factory that safely invalidates the previous Assumption and creates a new Assumption on invalidation. Note that you should be careful that repeated invalidations do not cause a deoptimization loop in that same way that you would with any other assumption. The Assumption instance should be obtained before doing the operation depending on it. In other words: 1. Obtain the current Assumption with [`CyclicAssumption.getAssumption()`](com/oracle/truffle/api/utilities/CyclicAssumption.md#getAssumption%28%29) 2. Perform the operation/lookup which depends on the assumption 3. Cache the result and the Assumption On the fast-path, first check if the assumption is valid and in that case return the cached result. When invalidating, first write the new value, then invalidate the CyclicAssumption. ```java class MyContext { CyclicAssumption symbolsRedefined = new CyclicAssumption("symbols"); Map symbols = new ConcurrentHashMap<>(); public void redefineSymbol(String symbol, Object value) { symbols.put(symbol, value); symbolsRedefined.invalidate(); } } class SymbolLookupNode extends Node { final MyContext context; final String symbol; @CompilationFinal volatile LookupResult cachedLookup; SymbolLookupNode(MyContext context, String symbol) { this.context = context; this.symbol = symbol; } public Object execute() { LookupResult lookup = cachedLookup; if (lookup == null || !lookup.assumption.isValid()) { CompilerDirectives.transferToInterpreterAndInvalidate(); cachedLookup = doLookup(symbol); } return cachedLookup.value; } private LookupResult doLookup(String name) { // First get the Assumption CyclicAssumption symbolsRedefined = context.symbolsRedefined; Assumption assumption = symbolsRedefined.getAssumption(); // Then lookup the value Object value = context.symbols.get(name); return new LookupResult(assumption, value); } } class LookupResult { final Assumption assumption; final Object value; LookupResult(Assumption assumption, Object value) { this.assumption = assumption; this.value = value; } } ``` ## Constructors ### CyclicAssumption(String) `public CyclicAssumption(String name)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/utilities/CyclicAssumption.html#(java.lang.String)` ## Methods ### invalidate() `public void invalidate()`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/utilities/CyclicAssumption.html#invalidate()` ### invalidate(String) `public void invalidate(String message)`. Since 0.33. Cite: `com/oracle/truffle/api/utilities/CyclicAssumption.html#invalidate(java.lang.String)` ### getAssumption() `public Assumption getAssumption()`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/utilities/CyclicAssumption.html#getAssumption()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ FinalBitSet [truffle-api](index.md) › [com.oracle.truffle.api.utilities](com/oracle/truffle/api/utilities/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.utilities`](com/oracle/truffle/api/utilities/index.md). Since 20.0. ```java public final class FinalBitSet ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `FinalBitSet` Read-only bitset designed for partial evaluation. The implementation is partially re-used from [`BitSet`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/BitSet.html). **See also** - [`BitSet`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/BitSet.html) ## Fields ### EMPTY `public static final FinalBitSet EMPTY`. Since 20.0. An empty bit set of size 0. Cite: `com/oracle/truffle/api/utilities/FinalBitSet.html#EMPTY` ## Methods ### toLongArray() `public long[] toLongArray()`. Since 20.0. Returns a new long array containing all the bits in this bit set. This method is designed for partial evaluation. More precisely, if `long[] longs = s.toLongArray();` then `longs.length == (s.length()+63)/64` and `s.get(n) == ((longs[n/64] & (1L<<(n%64))) != 0)` for all `n < 64 * longs.length`. Returns `long[]`: a long array containing a little-endian representation of all the bits in this bit set. Cite: `com/oracle/truffle/api/utilities/FinalBitSet.html#toLongArray()` ### get(int) `public boolean get(int bitIndex)`. Since 20.0. Returns the value of the bit with the specified index. The value is `true` if the bit with the index `bitIndex` is currently set in this `FinalBitSet`; otherwise, the result is `false`. This method is designed for partial evaluation and is guaranteed to fold if the receiver and the bitIndex parameter are constant. Parameters: `bitIndex` `int`: the bit index. Returns `boolean`: the value of the bit with the specified index. Throws: `IndexOutOfBoundsException` (unchecked): if the specified index is negative. Cite: `com/oracle/truffle/api/utilities/FinalBitSet.html#get(int)` ### length() `public int length()`. Since 20.0. Returns the "logical size" of this `FinalBitSet`: the index of the highest set bit in the `FinalBitSet` plus one. Returns zero if the `FinalBitSet` contains no set bits. This method is designed for partial evaluation and is guaranteed to fold if the receiver is constant. Returns `int`: the logical size of this `FinalBitSet`. Cite: `com/oracle/truffle/api/utilities/FinalBitSet.html#length()` ### isEmpty() `public boolean isEmpty()`. Since 20.0. Returns true if this `FinalBitSet` contains no bits that are set to `true`. This method is designed for partial evaluation and is guaranteed to fold if the receiver is constant. Returns `boolean`: boolean indicating whether this `FinalBitSet` is empty. Cite: `com/oracle/truffle/api/utilities/FinalBitSet.html#isEmpty()` ### equals(Object) `public boolean equals(Object obj)`. Since 20.0. Compares this object against the specified object. The result is `true` if and only if the argument is not `null` and is a `FinalBitSet` object that has exactly the same set of bits set to `true` as this bit set. That is, for every nonnegative `int` index `k`, must be true. The current sizes of the two bit sets are not compared. Parameters: `obj` `Object`: the object to compare with. Returns `boolean`: `true` if the objects are the same; `false` otherwise. Overrides `equals(java.lang.Object)`. See also: `size()`. Cite: `com/oracle/truffle/api/utilities/FinalBitSet.html#equals(java.lang.Object)` ```java ((BitSet) obj).get(k) == this.get(k) ``` ### hashCode() `public int hashCode()`. Since 20.0. Returns the hash code value for this bit set. The hash code depends only on which bits are set within this `FinalBitSet`. The hash code is defined to be the result of the following calculation: Note that the hash code changes if the set of bits is altered. Returns `int`: the hash code value for this bit set. Overrides `hashCode()`. Cite: `com/oracle/truffle/api/utilities/FinalBitSet.html#hashCode()` ```java public int hashCode() { long h = 1234; long[] words = toLongArray(); for (int i = words.length; --i >= 0;) h ^= words[i] * (i + 1); return (int) ((h >> 32) ^ h); } ``` ### size() `public int size()`. Since 20.0. Returns the number of bits of space actually in use by this `FinalBitSet` to represent bit values. The maximum element in the set is the size - 1st element. This method is designed for partial evaluation and is guaranteed to fold if the receiver is constant. Returns `int`: the number of bits currently in this bit set. Cite: `com/oracle/truffle/api/utilities/FinalBitSet.html#size()` ### cardinality() `public int cardinality()`. Since 20.0. Returns the number of bits set to `true` in this `BitSet`. Returns `int`: the number of bits set to `true` in this `BitSet`. Cite: `com/oracle/truffle/api/utilities/FinalBitSet.html#cardinality()` ### nextSetBit(int) `public int nextSetBit(int fromIndex)`. Since 20.0. Returns the index of the first bit that is set to `true` that occurs on or after the specified starting index. If no such bit exists then `-1` is returned. To iterate over the `true` bits in a `FinalBitSet`, use the following loop: Parameters: `fromIndex` `int`: the index to start checking from (inclusive). Returns `int`: the index of the next set bit, or `-1` if there is no such bit. Throws: `IndexOutOfBoundsException` (unchecked): if the specified index is negative. Cite: `com/oracle/truffle/api/utilities/FinalBitSet.html#nextSetBit(int)` ```java for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) { // operate on index i here if (i == Integer.MAX_VALUE) { break; // or (i+1) would overflow } } ``` ### nextClearBit(int) `public int nextClearBit(int fromIndex)`. Since 20.0. Returns the index of the first bit that is set to `false` that occurs on or after the specified starting index. Parameters: `fromIndex` `int`: the index to start checking from (inclusive). Returns `int`: the index of the next clear bit. Throws: `IndexOutOfBoundsException` (unchecked): if the specified index is negative. Cite: `com/oracle/truffle/api/utilities/FinalBitSet.html#nextClearBit(int)` ### toString() `public String toString()`. Since 20.0. Returns a string representation of this bit set. For every index for which this `BitSet` contains a bit in the set state, the decimal representation of that index is included in the result. Such indices are listed in order from lowest to highest, separated by ", " (a comma and a space) and surrounded by braces, resulting in the usual mathematical notation for a set of integers. Returns `String`: a string representation of this bit set. Overrides `toString()`. See also: [`BitSet.toString()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/BitSet.html#toString%28%29). Cite: `com/oracle/truffle/api/utilities/FinalBitSet.html#toString()` ### valueOf(long[]) `public static FinalBitSet valueOf(long[] longs)`. Since 20.0. Returns a new bit set containing all the bits in the given long array. More precisely, `FinalBitSet.valueOf(longs).get(n) == ((longs[n/64] & (1L<<(n%64))) != 0)` for all `n < 64 * longs.length`. Parameters: `longs` `long[]`: a long array containing a little-endian representation of a sequence of bits to be used as the initial bits of the new bit set. Returns `FinalBitSet`: a `FinalBitSet` containing all the bits in the long array. Cite: `com/oracle/truffle/api/utilities/FinalBitSet.html#valueOf(long[])` ### valueOf(BitSet) `public static FinalBitSet valueOf(BitSet originalBitSet)`. Since 20.0. Returns a new final bit set from a Java [`BitSet`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/BitSet.html) instance. The original bit set will be copied. Cite: `com/oracle/truffle/api/utilities/FinalBitSet.html#valueOf(java.util.BitSet)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ JSONHelper [truffle-api](index.md) › [com.oracle.truffle.api.utilities](com/oracle/truffle/api/utilities/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.utilities`](com/oracle/truffle/api/utilities/index.md). Since 0.8 or earlier. ```java @Deprecated(since = "24.1.0") public final class JSONHelper ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `JSONHelper` > **⊘ Deprecated since 24.1.0.** > > This class is deprecated and will be removed in a future version. Helper function that allows to dump the AST during creation to a JSON format. ## Nested types - [`JSONHelper.JSONArrayBuilder`](com/oracle/truffle/api/utilities/JSONHelper.JSONArrayBuilder.md) (class): No description. - [`JSONHelper.JSONObjectBuilder`](com/oracle/truffle/api/utilities/JSONHelper.JSONObjectBuilder.md) (class): No description. - [`JSONHelper.JSONStringBuilder`](com/oracle/truffle/api/utilities/JSONHelper.JSONStringBuilder.md) (abstract class): No description. ## Methods ### object() `public static JSONHelper.JSONObjectBuilder object()`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/utilities/JSONHelper.html#object()` ### array() `public static JSONHelper.JSONArrayBuilder array()`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/utilities/JSONHelper.html#array()` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ JSONHelper.JSONArrayBuilder [truffle-api](index.md) › [com.oracle.truffle.api.utilities](com/oracle/truffle/api/utilities/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.utilities`](com/oracle/truffle/api/utilities/index.md). Since 0.8 or earlier. Nested in [`JSONHelper`](com/oracle/truffle/api/utilities/JSONHelper.md). ```java public static final class JSONHelper.JSONArrayBuilder extends JSONHelper.JSONStringBuilder ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`JSONHelper.JSONStringBuilder`](com/oracle/truffle/api/utilities/JSONHelper.JSONStringBuilder.md) > `JSONArrayBuilder` ## Methods ### add(String) `public JSONHelper.JSONArrayBuilder add(String value)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/utilities/JSONHelper.JSONArrayBuilder.html#add(java.lang.String)` ### add(Number) `public JSONHelper.JSONArrayBuilder add(Number value)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/utilities/JSONHelper.JSONArrayBuilder.html#add(java.lang.Number)` ### add(Boolean) `public JSONHelper.JSONArrayBuilder add(Boolean value)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/utilities/JSONHelper.JSONArrayBuilder.html#add(java.lang.Boolean)` ### add(JSONHelper.JSONStringBuilder) `public JSONHelper.JSONArrayBuilder add(JSONHelper.JSONStringBuilder value)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/utilities/JSONHelper.JSONArrayBuilder.html#add(com.oracle.truffle.api.utilities.JSONHelper.JSONStringBuilder)` ### appendTo(StringBuilder) `protected void appendTo(StringBuilder sb)`. Since 0.8 or earlier. Overrides `appendTo()`. Cite: `com/oracle/truffle/api/utilities/JSONHelper.JSONArrayBuilder.html#appendTo(java.lang.StringBuilder)` ## Inherited members - From class [`JSONHelper.JSONStringBuilder`](com/oracle/truffle/api/utilities/JSONHelper.JSONStringBuilder.md): [`appendValue`](com/oracle/truffle/api/utilities/JSONHelper.JSONStringBuilder.md#appendValue%28java.lang.StringBuilder,java.lang.Object%29), [`toString`](com/oracle/truffle/api/utilities/JSONHelper.JSONStringBuilder.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ JSONHelper.JSONObjectBuilder [truffle-api](index.md) › [com.oracle.truffle.api.utilities](com/oracle/truffle/api/utilities/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.utilities`](com/oracle/truffle/api/utilities/index.md). Since 0.8 or earlier. Nested in [`JSONHelper`](com/oracle/truffle/api/utilities/JSONHelper.md). ```java public static final class JSONHelper.JSONObjectBuilder extends JSONHelper.JSONStringBuilder ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`JSONHelper.JSONStringBuilder`](com/oracle/truffle/api/utilities/JSONHelper.JSONStringBuilder.md) > `JSONObjectBuilder` ## Methods ### add(String, String) `public JSONHelper.JSONObjectBuilder add(String key, String value)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/utilities/JSONHelper.JSONObjectBuilder.html#add(java.lang.String,java.lang.String)` ### add(String, Number) `public JSONHelper.JSONObjectBuilder add(String key, Number value)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/utilities/JSONHelper.JSONObjectBuilder.html#add(java.lang.String,java.lang.Number)` ### add(String, Boolean) `public JSONHelper.JSONObjectBuilder add(String key, Boolean value)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/utilities/JSONHelper.JSONObjectBuilder.html#add(java.lang.String,java.lang.Boolean)` ### add(String, JSONHelper.JSONStringBuilder) `public JSONHelper.JSONObjectBuilder add(String key, JSONHelper.JSONStringBuilder value)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/utilities/JSONHelper.JSONObjectBuilder.html#add(java.lang.String,com.oracle.truffle.api.utilities.JSONHelper.JSONStringBuilder)` ### appendTo(StringBuilder) `protected void appendTo(StringBuilder sb)`. Since 0.8 or earlier. Overrides `appendTo()`. Cite: `com/oracle/truffle/api/utilities/JSONHelper.JSONObjectBuilder.html#appendTo(java.lang.StringBuilder)` ## Inherited members - From class [`JSONHelper.JSONStringBuilder`](com/oracle/truffle/api/utilities/JSONHelper.JSONStringBuilder.md): [`appendValue`](com/oracle/truffle/api/utilities/JSONHelper.JSONStringBuilder.md#appendValue%28java.lang.StringBuilder,java.lang.Object%29), [`toString`](com/oracle/truffle/api/utilities/JSONHelper.JSONStringBuilder.md#toString%28%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ JSONHelper.JSONStringBuilder [truffle-api](index.md) › [com.oracle.truffle.api.utilities](com/oracle/truffle/api/utilities/index.md) · Every page: [llms.txt](llms.txt) Abstract class in [`com.oracle.truffle.api.utilities`](com/oracle/truffle/api/utilities/index.md). Since 0.8 or earlier. Nested in [`JSONHelper`](com/oracle/truffle/api/utilities/JSONHelper.md). ```java public abstract static class JSONHelper.JSONStringBuilder ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `JSONStringBuilder` ## Methods ### toString() `public final String toString()`. Since 0.8 or earlier. Overrides `toString()`. Cite: `com/oracle/truffle/api/utilities/JSONHelper.JSONStringBuilder.html#toString()` ### appendTo(StringBuilder) `protected abstract void appendTo(StringBuilder sb)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/utilities/JSONHelper.JSONStringBuilder.html#appendTo(java.lang.StringBuilder)` ### appendValue(StringBuilder, Object) `protected static void appendValue(StringBuilder sb, Object value)`. Since 0.8 or earlier. Cite: `com/oracle/truffle/api/utilities/JSONHelper.JSONStringBuilder.html#appendValue(java.lang.StringBuilder,java.lang.Object)` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ MathUtils [truffle-api](index.md) › [com.oracle.truffle.api.utilities](com/oracle/truffle/api/utilities/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.utilities`](com/oracle/truffle/api/utilities/index.md). Since 24.1. ```java public final class MathUtils ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `MathUtils` This class contains mathematical methods that are not already provided by [`java.lang.Math`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Math.html) that are generally useful for language implementations. ## Methods ### asinh(double) `public static double asinh(double x)`. Since 24.1. Computes the inverse (area) hyperbolic sine (asinh) of a `double` value. Parameters: `x` `double`: The number whose inverse hyperbolic sine is to be returned. Returns `double`: The inverse hyperbolic sine of `x`. Cite: `com/oracle/truffle/api/utilities/MathUtils.html#asinh(double)` ```java asinh(x); derived from fdlibm (s_asinh.c) Method : Based on asinh(x) = sign(x) * log [ |x| + sqrt(x*x+1) ] we have asinh(x) := x if 1+x*x=1, := sign(x)*(log(x)+ln2)) for large |x|, else := sign(x)*log(2|x|+1/(|x|+sqrt(x*x+1))) if|x|>2, else := sign(x)*log1p(|x| + x^2/(1 + sqrt(1+x^2))) ``` ### acosh(double) `public static double acosh(double x)`. Since 24.1. Computes the inverse (area) hyperbolic cosine (acosh) of a `double` value. Parameters: `x` `double`: The number whose inverse hyperbolic cosine is to be returned. Returns `double`: The inverse hyperbolic cosine of `x`. Cite: `com/oracle/truffle/api/utilities/MathUtils.html#acosh(double)` ```java __ieee754_acosh(x); derived from fdlibm (e_acosh.c) Method : Based on acosh(x) = log [ x + sqrt(x*x-1) ] we have acosh(x) := log(x)+ln2, if x is large; else acosh(x) := log(2x-1/(sqrt(x*x-1)+x)) if x>2; else acosh(x) := log1p(t+sqrt(2.0*t+t*t)); where t=x-1. Special cases: acosh(x) is NaN with signal if x<1. acosh(NaN) is NaN without signal. ``` ### atanh(double) `public static double atanh(double x)`. Since 24.1. Computes the inverse (area) hyperbolic tangent (atanh) of a `double` value. Parameters: `x` `double`: The number whose inverse hyperbolic tangent is to be returned. Returns `double`: The inverse hyperbolic tangent of `x`. Cite: `com/oracle/truffle/api/utilities/MathUtils.html#atanh(double)` ```java __ieee754_atanh(x); derived from fdlibm (e_atanh.c) Method : 1.Reduced x to positive by atanh(-x) = -atanh(x) 2.For x>=0.5 1 2x x atanh(x) = --- * log(1 + -------) = 0.5 * log1p(2 * --------) 2 1 - x 1 - x For x<0.5 atanh(x) = 0.5*log1p(2x+2x*x/(1-x)) Special cases: atanh(x) is NaN if |x| > 1 with signal; atanh(NaN) is that NaN with no signal; atanh(+-1) is +-INF with signal. ``` ## Inherited members - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ≡ TriState [truffle-api](index.md) › [com.oracle.truffle.api.utilities](com/oracle/truffle/api/utilities/index.md) · Every page: [llms.txt](llms.txt) Enum class in [`com.oracle.truffle.api.utilities`](com/oracle/truffle/api/utilities/index.md). Since 20.2. ```java public enum TriState ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html) > `TriState` An utility value with three states, [`TRUE`](com/oracle/truffle/api/utilities/TriState.md#TRUE), [`FALSE`](com/oracle/truffle/api/utilities/TriState.md#FALSE), and [`UNDEFINED`](com/oracle/truffle/api/utilities/TriState.md#UNDEFINED). [`TriState`](com/oracle/truffle/api/utilities/TriState.md) is preferable to using a [`Boolean`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Boolean.html) value with [`Boolean.TRUE`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Boolean.html#TRUE), [`Boolean.FALSE`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Boolean.html#FALSE) and `null`, because [`Boolean`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Boolean.html) has a public constructor which requires the use of [`Boolean.equals(Object)`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Boolean.html#equals%28java.lang.Object%29) to compare the values. The comparison with [`Boolean.equals(Object)`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Boolean.html#equals%28java.lang.Object%29) is too slow. ## Enum constants ### TRUE `TRUE`. Since 20.2. The state is true. Similar to [`Boolean.TRUE`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Boolean.html#TRUE). Cite: `com/oracle/truffle/api/utilities/TriState.html#TRUE` ### FALSE `FALSE`. Since 20.2. The state is false. Similar to [`Boolean.FALSE`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Boolean.html#FALSE). Cite: `com/oracle/truffle/api/utilities/TriState.html#FALSE` ### UNDEFINED `UNDEFINED`. Since 20.2. The state is undefined. Similar to `null`. Cite: `com/oracle/truffle/api/utilities/TriState.html#UNDEFINED` ## Methods ### values() `public static TriState[] values()`. Returns the enum constants in declaration order. Returns `TriState[]`: Returns the enum constants in declaration order. Cite: `com/oracle/truffle/api/utilities/TriState.html#values()` ### valueOf(String) `public static TriState valueOf(String name)`. Returns the enum constant with the given name. Parameters: `name` `String`: The exact name of the enum constant. Returns `TriState`: Returns the enum constant with the given name. Cite: `com/oracle/truffle/api/utilities/TriState.html#valueOf(java.lang.String)` ### valueOf(boolean) `public static TriState valueOf(boolean b)`. Since 20.2. Create a `TriState` from a primitive boolean. Cite: `com/oracle/truffle/api/utilities/TriState.html#valueOf(boolean)` ### valueOf(Boolean) `public static TriState valueOf(Boolean b)`. Since 20.2. Create a `TriState` from a boxed [`Boolean`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Boolean.html) explicitely checking for `null` and returning `UNDEFINED`. Cite: `com/oracle/truffle/api/utilities/TriState.html#valueOf(java.lang.Boolean)` ## Inherited members - From class [`Enum`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#clone%28%29), [`compareTo`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#compareTo%28E%29), [`describeConstable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#describeConstable%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#finalize%28%29), [`getDeclaringClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#getDeclaringClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#hashCode%28%29), [`name`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#name%28%29), [`ordinal`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#ordinal%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#toString%28%29), [`valueOf`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Enum.html#valueOf%28java.lang.Class,java.lang.String%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29) # ◆ TruffleWeakReference [truffle-api](index.md) › [com.oracle.truffle.api.utilities](com/oracle/truffle/api/utilities/index.md) · Every page: [llms.txt](llms.txt) Class in [`com.oracle.truffle.api.utilities`](com/oracle/truffle/api/utilities/index.md). Since 20.2. ```java public final class TruffleWeakReference extends WeakReference ``` Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > [`Reference`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ref/Reference.html) > [`WeakReference`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ref/WeakReference.html) > `TruffleWeakReference` Creates a new weak reference that is safe to be used in compiled code paths. If a weak reference is [`PE constant`](com/oracle/truffle/api/CompilerDirectives.md#isPartialEvaluationConstant%28java.lang.Object%29) then the [`referenced object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ref/Reference.html#get%28%29) will be [`PE constant`](com/oracle/truffle/api/CompilerDirectives.md#isPartialEvaluationConstant%28java.lang.Object%29) as well. When a language is compiled using native-image then a closed world closure of all runtime compiled methods is computed. That list of methods can rely on static type information only. If the host application or any of the loaded libraries uses custom weak reference sub-classes that were not designed for partial evaluation then these method will be listed as runtime compilable methods, causing black listed method errors at native-image compilation time. To avoid this problem use this custom weak reference subclass which is designed for PE if used as exact class of the field. **Wrong usage** of weak references in compiled code paths: ```java class MyNode extends Node { @CompilationFinal private WeakReference reference; Object execute(Object arg) { if (reference == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); reference = new WeakReference<>(arg); } return reference.get(); } } ``` **Correct usage** of weak references in compiled code paths : ```java static class MyNode extends Node { @CompilationFinal private TruffleWeakReference reference; Object execute(Object arg) { if (reference == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); reference = new TruffleWeakReference(arg); } return reference.get(); } } ``` ## Constructors ### TruffleWeakReference(T) `public TruffleWeakReference(T t)`. Since 20.2. Creates a new Truffle weak reference that refers to the given object. The new reference is not registered with any queue. See also: [`WeakReference.WeakReference(Object)`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ref/WeakReference.html#%3Cinit%3E%28T%29). Cite: `com/oracle/truffle/api/utilities/TruffleWeakReference.html#(T)` ### TruffleWeakReference(T, ReferenceQueue) `public TruffleWeakReference(T referent, ReferenceQueue q)`. Since 20.2. Creates a new Truffle weak reference that refers to the given object and is registered with the given queue. See also: [`WeakReference.WeakReference(Object, ReferenceQueue)`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ref/WeakReference.html#%3Cinit%3E%28T,java.lang.ref.ReferenceQueue%29). Cite: `com/oracle/truffle/api/utilities/TruffleWeakReference.html#(T,java.lang.ref.ReferenceQueue)` ## Inherited members - From class [`Reference`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ref/Reference.html): [`clear`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ref/Reference.html#clear%28%29), [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ref/Reference.html#clone%28%29), [`enqueue`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ref/Reference.html#enqueue%28%29), [`get`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ref/Reference.html#get%28%29), [`isEnqueued`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ref/Reference.html#isEnqueued%28%29), [`reachabilityFence`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ref/Reference.html#reachabilityFence%28java.lang.Object%29), [`refersTo`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/ref/Reference.html#refersTo%28T%29) - From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29)