Shaping C-like structs into memory segments – Foreign (Function) Memory API

146. Shaping C-like structs into memory segments Let’s consider the C-like struct from the following figure: Figure 7.12 – A C-like structure So, in Figure 7.12, we have a C-like ... Read MoreRead More

0 Comments

Shaping C-like unions into memory segments – Foreign (Function) Memory API

147. Shaping C-like unions into memory segments Let’s consider the C-like union from the following figure (the members of a C union share the same memory location (the member’s largest ... Read MoreRead More

0 Comments

Introducing layout reshaping – Foreign (Function) Memory API

153. Introducing layout reshaping Let’s suppose that we have the following nested model (the exact same model as in Problem 151): SequenceLayout innerSeq  = MemoryLayout.sequenceLayout(5, ValueLayout.JAVA_DOUBLE);SequenceLayout outerSeq  = MemoryLayout.sequenceLayout(10, innerSeq); ... Read MoreRead More

0 Comments

Tackling mapped memory segments – Foreign (Function) Memory API

157. Tackling mapped memory segments We know that a computer has limited physical memory referred to as RAM memory. Common sense though tells us that we cannot allocate a memory ... Read MoreRead More

0 Comments

Copying and slicing memory segments 2 – Foreign (Function) Memory API

Copying a part of the segment into another segment (2) Let’s consider the srcSegment (1, 2, 3, 4, -1, -1, -1, 52, 22, 33, -1, -1, -1, -1, -1, 4) ... Read MoreRead More

0 Comments

Copying and slicing memory segments – Foreign (Function) Memory API

149. Copying and slicing memory segments Let’s consider the following memory segment (arena is an instance of Arena): MemorySegment srcSegment = arena.allocateArray(  ValueLayout.JAVA_INT, 1, 2, 3, 4, -1, -1, -1,                        ... Read MoreRead More

0 Comments

Tackling the slicing allocator – Foreign (Function) Memory API

150. Tackling the slicing allocator Let’s consider the following three Java regular int arrays: int[] arr1 = new int[]{1, 2, 3, 4, 5, 6};int[] arr2 = new int[]{7, 8, 9};int[] ... Read MoreRead More

0 Comments

Introducing Jextract – Foreign (Function) Memory API

163. Introducing Jextract Jextract (https://github.com/openjdk/jextract) is a very handy tool capable to consume the headers of native libraries (*.h files) and producing low-level Java native bindings. Via this tool, we ... Read MoreRead More

0 Comments

Creating an electrical panel (hierarchy of classes) – Sealed and Hidden Classes

165. Creating an electrical panel (hierarchy of classes) Let’s assume that we want to model in code lines an electrical panel. Of course, we are not electricians, so in a ... Read MoreRead More

0 Comments

Closing the electrical panel before JDK 17 – Sealed and Hidden Classes

166. Closing the electrical panel before JDK 17 By its nature, an electrical panel is a closed unit of work. But, our code from the previous problem is far away ... Read MoreRead More

0 Comments