Class WordFactory
java.lang.Object
org.graalvm.word.WordFactory
Provides factory method to create machine-word-sized values.
In an execution environment where value returned by this factory words are boxed values (e.g. not
in Native Image runtime), a Pointer value will throw UnsatisfiedLinkError if any
of its memory access operations (i.e., read, write, compare-and-swap etc.) or
conversion-to-Object operations (i.e., toObject) are invoked.
In a Native Image runtime, word values are distinct from Object values. To
avoid problems related to this, word values must never be used as Objects, even when
javac would allow it (e.g., Map<Long, Pointer>). The Native Image builder will
detect such usages and raise an error.
- Since:
- 19.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends PointerBase>
TThe null pointer, i.e., a word with all bits set to 0.static <T extends PointerBase>
Tpointer(long val) Unsafe conversion from a Java long value to apointer.static <T extends SignedWord>
Tsigned(int val) Creates a word whose value is supplied by avalwhich is sign-extended on a 64-bit platform.static <T extends SignedWord>
Tsigned(long val) Creates a word whose value is supplied byval.static <T extends UnsignedWord>
Tunsigned(int val) Creates a word whose value is supplied byvalwhich is zero-extended on a 64-bit platform.static <T extends UnsignedWord>
Tunsigned(long val) Creates a word whose value is supplied byvalwhich is (lossily) narrowed on a 32-bit platform.static <T extends WordBase>
Tzero()The constant 0, i.e., the word with no bits set.
-
Method Details
-
zero
The constant 0, i.e., the word with no bits set. There is no difference between a signed and unsigned zero.- Returns:
- the constant 0.
- Since:
- 19.0
-
nullPointer
The null pointer, i.e., a word with all bits set to 0. There is no difference between a signed or unsignedzero().- Returns:
- a word value representing the null pointer
- Since:
- 19.0
-
unsigned
Creates a word whose value is supplied byvalwhich is (lossily) narrowed on a 32-bit platform.- Parameters:
val- a 64-bit unsigned value- Returns:
- the value cast to Word
- Since:
- 19.0
-
pointer
Unsafe conversion from a Java long value to apointer. The parameter is treated as an unsigned 64-bit value (in contrast to the semantics of a Java long).- Parameters:
val- a 64 bit unsigned value- Returns:
- the value cast to PointerBase
- Since:
- 19.0
-
unsigned
Creates a word whose value is supplied byvalwhich is zero-extended on a 64-bit platform.- Parameters:
val- a 32 bit unsigned value- Returns:
- the value cast to Word
- Since:
- 19.0
-
signed
Creates a word whose value is supplied byval.- Parameters:
val- a 64-bit signed value- Returns:
- the value cast to Word
- Since:
- 19.0
-
signed
Creates a word whose value is supplied by avalwhich is sign-extended on a 64-bit platform.- Parameters:
val- a 32-bit signed value- Returns:
- the value cast to Word
- Since:
- 19.0
-