<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p>Hi,<br>
      I still think that leaning on the language to capture this morally
      wrong. For better or worse, the audience that requires native
      interop is a (very) small fraction of the entire Java ecosystem.</p>
    <p>Having a top-level "native" declaration would be very confusing.
      Try to put yourself in the shoes of a poor CS teacher that will
      have to explain what a native class is. Simply saying that you can
      ignore it if you don't need it is not good enough for a
      language/platform as popular as this.</p>
    <p>There are also many issues with the proposed approach. Some are:<br>
    </p>
    <p>* the layout of the native class seems to be determined by the
      record components. This means no way to add padding (or slippery
      slope to add padding via annotations).<br>
      * more on layouts, mapping int to JAVA_INT is ok, but only gets
      you so far - at some point you will need a layout that is 1-1 with
      the C layout, and, to do that, you need a tool which can
      understand the C code (unless you suggest to dump all this on
      javac)<br>
      * structs are great - what about unions? And arrays?<br>
      * the naming convention for getter and setter is hardwired in the
      language. Records specifically settled on using an accessor name
      that has the same name as the component, to avoid ambiguities as
      to what the "right" name should be.<br>
    </p>
    <p>And, all the code you write can _still_ be generated by a tool.</p>
    <p>So, rather than brainstorming on potential Java features which
      might never see the light of the day, why don't we instead try to
      discuss what is the problem we're trying to solve? <br>
    </p>
    <p>You mention, for instance, that:</p>
    <p>
      <blockquote type="cite">
        <p class="MsoNormal"><b>The bindings created by jextract can
            look confusing and scary to many less experienced java
            developers.</b></p>
      </blockquote>
      There are two issues in this sentence: first, shape of jextract
      bindings is not generated in stone. If we'd prefer an approach
      where structs are modelled with record classes, we could go there
      (but of course we'd need to provide some escape hatch for folks
      that want to operate with segments directly).</p>
    <p>Secondly, it assumes that jextract will be a tool ran by every
      Java developer out there, or that said developers will need to be
      able to "understand" what comes out of the tool. Which seems like
      a dubious claim. E.g. if the API generated by jextract is super
      friendly (static functions and records), does the user really care
      how jextract gets there?</p>
    <p>
      <blockquote type="cite">
        <p class="MsoNormal"><b>I think the ability to describe a native
            struct in 1 line instead of using an extra tool would
            simplify the process of interfacing with native structs a
            lot. </b></p>
      </blockquote>
      <br>
      But, where do these structs come from? If they come from a native
      function, well, you still need a method handle to get there.
      Surely method handles are "harder" to understand that a plain
      wrapper around a memory segment (again, assuming that developers
      care about what the generated bindings look like) ?</p>
    <p>Concluding, besides one-liner declaration convenience (which,
      again, is a questionable use case), I'm failing to see the smoking
      gun as to why this has to be a _language_ feature understood by
      the javac compiler and specified in the JLS (!!). This feature
      will have to be supported forever and will have to interoperate
      nicely with all the other features in the language. For instance,
      what does it mean to have a _generic_ native class?</p>
    <p>I believe you are grossly understimating the requirement bar for
      adding new features to the Java language.</p>
    <p>Maurizio<br>
    </p>
    <p><br>
    </p>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 09/11/2022 14:17,
      <a class="moz-txt-link-abbreviated" href="mailto:redio.development@gmail.com">redio.development@gmail.com</a> wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:024601d8f446$0ba217d0$22e64770$@gmail.com">
      
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <style>@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
        {font-family:"Yu Gothic";
        panose-1:2 11 4 0 0 0 0 0 0 0;}@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}@font-face
        {font-family:"\@Yu Gothic";
        panose-1:2 11 4 0 0 0 0 0 0 0;}p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}span.E-MailFormatvorlage18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}div.WordSection1
        {page:WordSection1;}</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
      <div class="WordSection1">
        <p class="MsoNormal">Prototype for native classes<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <div style="border:none;border-top:solid #E1E1E1
          1.0pt;padding:3.0pt 0cm 0cm 0cm">
          <p class="MsoNormal"><b>//example C-Struct Point:<o:p></o:p></b></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6" lang="FR">struct</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4" lang="FR"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0" lang="FR">Point</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4" lang="FR"> {<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4" lang="FR">    </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6" lang="FR">int</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4" lang="FR"> x,y;<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">};<o:p></o:p></span></p>
          <p class="MsoNormal"><b><o:p> </o:p></b></p>
          <p class="MsoNormal"><b>//the base class Native:<o:p></o:p></b></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">import</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">java</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">.</span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">lang</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">.</span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">foreign</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">.</span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">MemorySegment</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">;<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">import</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">java</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">.</span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">util</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">.</span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">Objects</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">;<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"><o:p> </o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">public</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">abstract</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">class</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">Native</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> {<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                <o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">protected</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">final</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">MemorySegment</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#4FC1FF">segment</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">;<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"><o:p> </o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">protected</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">Native</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">(</span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">MemorySegment</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">segment</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">) {<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                    </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">this</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">.</span><span style="font-size:10.5pt;font-family:Consolas;color:#4FC1FF">segment</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> = </span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">Objects</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">.</span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">requireNonNull</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">(</span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">segment</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">);<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                    </span><span style="font-size:10.5pt;font-family:Consolas;color:#C586C0">if</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> (</span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">segment</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">.</span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">byteSize</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">() != </span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">layout</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">().</span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">byteSize</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">())<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                        </span><span style="font-size:10.5pt;font-family:Consolas;color:#C586C0">throw</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#C586C0">new</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">IllegalArgumentException</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">(</span><span style="font-size:10.5pt;font-family:Consolas;color:#CE9178">"Segment
              does not match native class."</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">);<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                }<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                <o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">public</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">MemorySegment</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">segment</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">() {<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                    </span><span style="font-size:10.5pt;font-family:Consolas;color:#C586C0">return</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#4FC1FF">segment</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">;<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                }<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"><o:p> </o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">public</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">abstract</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">GroupLayout</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">layout</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">();<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">}<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"><o:p> </o:p></span></p>
          <p class="MsoNormal"><b><o:p> </o:p></b></p>
          <p class="MsoNormal"><b>//the declaration of the native class
              Point:<o:p></o:p></b></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">public</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">native</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">class</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#008469">Point</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">(</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">public</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> int </span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">x</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">, </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">public</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> int </span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">y</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">) {}<o:p></o:p></span></p>
          <p class="MsoNormal"><b><span lang="FR"><o:p> </o:p></span></b></p>
          <p class="MsoNormal"><b>//the expansion of the syntax above:<o:p></o:p></b></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">public</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">final</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">class</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">Point</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">extends</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">Native</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> {<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"><o:p> </o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">private</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">static</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">final</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">GroupLayout</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">$LAYOUT</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> = </span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">MemoryLayout</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">.</span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">structLayout</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">(<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                    </span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">ValueLayout</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">.</span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">JAVA_INT</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">.</span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">withBitAlignment</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">(</span><span style="font-size:10.5pt;font-family:Consolas;color:#B5CEA8">32</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">).</span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">withName</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">(</span><span style="font-size:10.5pt;font-family:Consolas;color:#CE9178">"x"</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">),<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                    </span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">ValueLayout</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">.</span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">JAVA_INT</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">.</span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">withBitAlignment</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">(</span><span style="font-size:10.5pt;font-family:Consolas;color:#B5CEA8">32</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">).</span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">withName</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">(</span><span style="font-size:10.5pt;font-family:Consolas;color:#CE9178">"y"</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">));<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"><o:p> </o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">private</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">static</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">final</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">VarHandle</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">X$HANDLE</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> = </span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">$LAYOUT</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">.</span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">varHandle</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">(</span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">MemoryLayout</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">.</span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">PathElement</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">.</span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">groupElement</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">(</span><span style="font-size:10.5pt;font-family:Consolas;color:#CE9178">"x"</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">));<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">private</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">static</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">final</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">VarHandle</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">Y$HANDLE</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> = </span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">$LAYOUT</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">.</span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">varHandle</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">(</span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">MemoryLayout</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">.</span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">PathElement</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">.</span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">groupElement</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">(</span><span style="font-size:10.5pt;font-family:Consolas;color:#CE9178">"y"</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">));<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"><o:p> </o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">public</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">Point</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">(</span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">MemorySegment</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">segment</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">) {<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                    </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">super</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">(segment);<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                }<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"><o:p> </o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">public</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">int</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">getX</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">() {<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                    </span><span style="font-size:10.5pt;font-family:Consolas;color:#C586C0">return</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> (</span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">int</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">)</span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">X$HANDLE</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">.</span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">get</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">(segment);<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                }<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"><o:p> </o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">public</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">void</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">setX</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">(</span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">int</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">x</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">) {<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                    </span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">X$HANDLE</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">.</span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">set</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">(segment,
              x);<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                }<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"><o:p> </o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">public</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">int</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">getY</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">() {<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                    </span><span style="font-size:10.5pt;font-family:Consolas;color:#C586C0">return</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> (</span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">int</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">)</span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">Y$HANDLE</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">.</span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">get</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">(segment);<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                }<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"><o:p> </o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">public</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">void</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">setY</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">(</span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">int</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">y</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">) {<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                    </span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">Y$HANDLE</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">.</span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">set</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">(segment,
              y);<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                }<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"><o:p> </o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                @</span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">Override</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"><o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                </span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">public</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">GroupLayout</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> </span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">layout</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">() {<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                    </span><span style="font-size:10.5pt;font-family:Consolas;color:#C586C0">return</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> $LAYOUT;<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"> 
                }<o:p></o:p></span></p>
          <p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">}<o:p></o:p></span></p>
          <p class="MsoNormal"><b><o:p> </o:p></b></p>
          <p class="MsoNormal"><b>The expansion would be done by the
              compiler at compile time just like records.<o:p></o:p></b></p>
          <p class="MsoNormal"><b>As said this is just a prototype and
              different or additional ideas are very welcome.<o:p></o:p></b></p>
          <p class="MsoNormal"><b>The visibility of the accessor methods
              can be set in the field declaration brackets.<o:p></o:p></b></p>
          <p class="MsoNormal"><b>To change visibility of only getter or
              setter you would simply choose the lower visibility and
              define a custom one instead of the default.<o:p></o:p></b></p>
          <p class="MsoNormal"><b>To access the default in the custom
              method super could be used.<o:p></o:p></b></p>
          <p class="MsoNormal"><b>As you might have notices this looks
              similar to the class jextract creates and that’s
              intentional.<o:p></o:p></b></p>
          <p class="MsoNormal"><b>If this would be implemented jextract
              could just create native classes as bindings to native
              structs.<o:p></o:p></b></p>
          <p class="MsoNormal"><b>This would practically shift the
              modeling of the concrete c struct from jextract to the
              javac compiler.<o:p></o:p></b></p>
          <p class="MsoNormal"><b>Since the native struct declaration is
              very simplistic the need for jextract could be reduced.<o:p></o:p></b></p>
          <p class="MsoNormal"><b>I think the ability to describe a
              native struct in 1 line instead of using an extra tool
              would simplify the process of interfacing with native
              structs a lot. <o:p></o:p></b></p>
          <p class="MsoNormal"><b>The bindings created by jextract can
              look confusing and scary to many less experienced java
              developers.<o:p></o:p></b></p>
          <p class="MsoNormal"><b>Working with a native class is the
              exact same as working with a mutable record like class
              with the benefits that it can be used to interact with
              native memory.<o:p></o:p></b></p>
          <p class="MsoNormal"><b>Thinking further jextract could
              actually insert the generated native classes in signatures
              of the java representation of native functions.<o:p></o:p></b></p>
          <p class="MsoNormal"><b>This idea would promote native structs
              to first class citizens in java.<o:p></o:p></b></p>
          <p class="MsoNormal"><b><o:p> </o:p></b></p>
          <p class="MsoNormal"><b>In great regards<o:p></o:p></b></p>
          <p class="MsoNormal"><b>RedIODev<o:p></o:p></b></p>
          <p class="MsoNormal"><b><o:p> </o:p></b></p>
          <p class="MsoNormal"><b><o:p> </o:p></b></p>
          <p class="MsoNormal"><b><span lang="DE">Von:</span></b><span lang="DE"> Red IO <a class="moz-txt-link-rfc2396E" href="mailto:redio.development@gmail.com"><redio.development@gmail.com></a> <br>
              <b>Gesendet:</b> Dienstag, 8. November 2022 14:01<br>
              <b>An:</b> Maurizio Cimadamore
              <a class="moz-txt-link-rfc2396E" href="mailto:maurizio.cimadamore@oracle.com"><maurizio.cimadamore@oracle.com></a><br>
              <b>Cc:</b> panama-dev <a class="moz-txt-link-rfc2396E" href="mailto:panama-dev@openjdk.org"><panama-dev@openjdk.org></a><br>
              <b>Betreff:</b> Re: Foreign memory access with classes<o:p></o:p></span></p>
        </div>
        <p class="MsoNormal"><o:p> </o:p></p>
        <div>
          <p class="MsoNormal">JPassport looks like a great take based
            on the raw Panama way of doing this. But it's still a pain
            to do and requires a precompiler. But both feel
            uncomfortable using strings to point to mark things.<o:p></o:p></p>
          <div>
            <p class="MsoNormal">Also my idea would still bahave like a
              normal class being on the heap (could be declared as
              primitive or value class but let's not focus on Valhalla).
              The only difference would be their fields, as they would
              technically not be part of the class. The only field part
              of the object would be the hidden MemorySegment managing
              the access of the fields.<o:p></o:p></p>
          </div>
          <div>
            <p class="MsoNormal">My biggest problem with the current
              solution is that they try to simulate a simple struct with
              a complex factory. I understand your concerns but there is
              no split in the type system like you feared. Native
              objects are simply different, that their fields are stored
              somewhere else. Other than that they are plain objects. If
              projecting method calls from fields is too complicated to
              implement we could go for a record like syntax and only
              exposing the fake fields through methods. Most java
              developers would probably never create their own native
              classes but use those declared in libraries and returned
              by library methods. In this scenario they would be
              indistinguishable from normal objects.<o:p></o:p></p>
          </div>
          <div>
            <p class="MsoNormal"><o:p> </o:p></p>
          </div>
          <div>
            <p class="MsoNormal">Regards <o:p></o:p></p>
          </div>
          <div>
            <p class="MsoNormal">RedIODev<o:p></o:p></p>
          </div>
        </div>
        <p class="MsoNormal"><o:p> </o:p></p>
        <div>
          <div>
            <p class="MsoNormal">On Tue, Nov 8, 2022, 11:44 Maurizio
              Cimadamore <<a href="mailto:maurizio.cimadamore@oracle.com" moz-do-not-send="true" class="moz-txt-link-freetext">maurizio.cimadamore@oracle.com</a>>
              wrote:<o:p></o:p></p>
          </div>
          <blockquote style="border:none;border-left:solid #CCCCCC
            1.0pt;padding:0cm 0cm 0cm
            6.0pt;margin-left:4.8pt;margin-right:0cm">
            <p class="MsoNormal">I believe adding Java syntax to model
              objects backed by memory segments <br>
              might be pushing things a little too far. From a
              pedagogical perspective <br>
              you would now have to explain to _every_ Java developers
              that there are <br>
              two different kinds of objects, plain and native, and the
              rules which <br>
              govern their access would be different (plain objects are
              <br>
              garbage-collected, native objects are not).<br>
              <br>
              Seems like a nightmare, for a relatively little pay off.
              Note that, if <br>
              you declare a record class with components X and Y, it is
              relatively <br>
              easy to construct a function that can read a segment, with
              given struct <br>
              layout into a record with matching components. I believe
              JPassport [1] <br>
              does something in this direction. With something like this
              you get <br>
              basically 90% of what you are aiming for, without the need
              to change the <br>
              language by adding a new keyword, and making the
              programming model more <br>
              complex for all the developers out there, including those
              who do not <br>
              care about off-heap access.<br>
              <br>
              Cheers<br>
              Maurizio<br>
              <br>
              [1] - <a href="https://urldefense.com/v3/__https://github.com/boulder-on/JPassport/__;!!ACWV5N9M2RV99hQ!PFL9I9iPIa7J3be47BPIHVN388hZLLr4dNMQ7LC0EPYnjKXvT5DXKRBtBkJ32-ZJ3AmFMJW5ARAraEGTMTov-QkyEgMr40HT5Q$" target="_blank" moz-do-not-send="true">https://github.com/boulder-on/JPassport/</a><br>
              <br>
              <br>
              On 08/11/2022 06:52, Red IO wrote:<br>
              > I just had a crazy idea on how to make foreign memory
              access work and <br>
              > feel like java native class member access.<br>
              > The idea is that you define special classes maybe
              with an interface or <br>
              > a special class keyword. This class can then be
              "constructed" using a <br>
              > MemorySegment being bound by its special and temporal
              bounds. The <br>
              > object would be either null or every memory access
              throws an exception <br>
              > when the bounds are breached. The class would be
              implicitly final and <br>
              > would extend a class Native.<br>
              > This could look something like this :<br>
              ><br>
              > //c struct<br>
              > typedef struct {<br>
              > int x;<br>
              > int y;<br>
              > } Point;<br>
              ><br>
              > //java native class<br>
              > public native class Point {<br>
              ><br>
              > int x;<br>
              > int y;<br>
              ><br>
              > //implicit and forced private constructor<br>
              > //normal creation would make things difficult<br>
              > }<br>
              ><br>
              > MemorySegment data =... //native memory<br>
              > Point p = data.object(Point.class);<br>
              ><o:p></o:p></p>
          </blockquote>
        </div>
      </div>
    </blockquote>
  </body>
</html>