Class Library
- All Implemented Interfaces:
NodeInterface
,Cloneable
- Direct Known Subclasses:
DynamicDispatchLibrary
,DynamicObjectLibrary
,InteropLibrary
,NodeLibrary
,ReflectionLibrary
GenerateLibrary
. Implementations for the abstract methods specified in this classes are
not supposed to be implemented manually.- Since:
- 19.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.oracle.truffle.api.nodes.Node
Node.Child, Node.Children
-
Constructor Summary
-
Method Summary
Methods inherited from class com.oracle.truffle.api.nodes.Node
accept, adoptChildren, atomic, atomic, copy, deepCopy, getChildren, getCost, getDebugProperties, getDescription, getEncapsulatingSourceSection, getLock, getParent, getRootNode, getSourceSection, insert, insert, isAdoptable, isSafelyReplaceableBy, notifyInserted, onReplace, replace, replace, reportPolymorphicSpecialize, toString
-
Constructor Details
-
Library
protected Library()Default constructor for sub-classes. Libraries always have a no-arg protected constructor.- Since:
- 19.0
-
-
Method Details
-
accepts
Returnstrue
if this library instance supports sending messages with the given receiver. If accepts returnsfalse
and a library message is sent anyway then anAssertionError
is thrown if assertions are enabled (-ea). Otherwise aNullPointerException
orClassCastException
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 returnfalse
. 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 returntrue
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 theinternally 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.
- Since:
- 19.0
- See Also:
-