<div dir="ltr">Hi there, I am really happy that Panama-FFI finally released, congratulation! <div><br></div><div>I have been using Panama's features since JDK19, and when I am migrating to JDK22, I found that Heap segment could be passed to native functions if the call is really short, which is really helpful in lots of ways.</div><div><br></div><div>However, allocating heap segments are not so convenient as allocating  native segments, it seems that we could only use MemorySegment.ofArray() to transform an array into a memorysegment.</div><div><br></div><div>Hence I got several question:</div><div><br></div><div>1. Could there be a HeapArena, which targets at allocating heap segments with given byteSize and byteAlignment, just like native segments? That would be pretty helpful in a lot of scenarios.</div><div><br></div><div>2. Could there be an API, for developers, to allocate a heap segment, with no zero-bytes filled, so that heap allocation would be much faster?</div><div><br></div><div>3. I noticed that, when calling MemorySegment.get() or MemorySegment.set() methods, it will use the underlying Varhandle to do the job, I read about Varhandle in <a href="https://jornvernee.github.io/methodhandles/2024/01/19/methodhandle-primer.html">https://jornvernee.github.io/methodhandles/2024/01/19/methodhandle-primer.html</a>, and when I run the following code:</div><div><br></div><div><div style="background-color:rgb(30,31,34);color:rgb(188,190,196)"><pre style="font-family:"Cascadia Mono",monospace;font-size:10.5pt">System.<span style="color:rgb(199,125,187);font-style:italic">out</span>.println(ValueLayout.<span style="color:rgb(199,125,187);font-style:italic">JAVA_INT</span>.varHandle().hasInvokeExactBehavior());</pre></div></div><div><br></div><div>the result is false, so there is no InvokeExactBehaviour, which is not recommended. I thought this could be a mistake, or it's intended to handle the auto-boxing conversion, please take a look at this.</div><div><br></div><div>Best regards!</div></div>