<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p>Seems related to this?</p>
    <p><a class="moz-txt-link-freetext" href="https://git.openjdk.org/jextract/pull/287">https://git.openjdk.org/jextract/pull/287</a></p>
    <p>It would be very helpful if you could try the option in that PR
      (you would need to build jextract manually) and see if that
      improves the situation.</p>
    <p>Cheers<br>
      Maurizio<br>
    </p>
    <div class="moz-cite-prefix">On 10/09/2025 12:46, Manuel
      Bleichenbacher wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:CAA7F5jJXVb3fRs23WhihVpJsFr2H=zSXLxqqn_H7WkH8WnagqA@mail.gmail.com">
      
      <div dir="ltr">Hi jextract team
        <div><br>
        </div>
        <div>I've been playing with the upcoming GraalVM 25 and its
          support for FFM. But I've run into an issue with code
          generated by jextract related to function pointers: it always
          instantiates both the downcall and upcall method handles,
          independent of which one is actually used. In my case, I would
          only need the downcall handle. The unnecessary upcall handle
          depends on another method ("apply") that GraalVM has correctly
          identified to never be called and is thus omitted from the
          native image. As a result, the application crashes at
          run-time.</div>
        <div><br>
        </div>
        <div>It wouldn't be such a problem if I was dealing with one or
          two function pointers. Then I would manually create the
          required FFM code with downcall handles only. However, I'm
          dealing with COM interfaces and the macOS IOKit version
          thereof:</div>
        <div><br>
        </div>
        <div>
          <p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;font-size-adjust:none;font-kerning:auto;font-variant-alternates:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-east-asian:normal;font-feature-settings:normal;color:rgb(11,79,121)"><span style="color:rgb(155,35,147)"><b>typedef</b></span><span style="color:rgba(0,0,0,0.85)"> </span><span style="color:rgb(155,35,147)"><b>struct</b></span><span style="color:rgba(0,0,0,0.85)"> </span>IOUSBInterfaceStruct942<span style="color:rgba(0,0,0,0.85)"> {</span></p>
          <p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;font-size-adjust:none;font-kerning:auto;font-variant-alternates:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-east-asian:normal;font-feature-settings:normal;color:rgb(15,104,160)"><span style="color:rgba(0,0,0,0.85)"><span class="gmail-Apple-converted-space">    </span></span>IUNKNOWN_C_GUTS<span style="color:rgba(0,0,0,0.85)">;</span></p>
          <p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;font-size-adjust:none;font-kerning:auto;font-variant-alternates:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-east-asian:normal;font-feature-settings:normal;color:rgba(0,0,0,0.85)"><span class="gmail-Apple-converted-space">    </span><span style="color:rgb(57,0,160)">IOReturn</span>
            (*CreateInterfaceAsyncEventSource)(<span style="color:rgb(155,35,147)"><b>void</b></span> *<span style="color:rgb(155,35,147)"><b>self</b></span>, <span style="color:rgb(57,0,160)">CFRunLoopSourceRef</span>
            *source);</p>
          <p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;font-size-adjust:none;font-kerning:auto;font-variant-alternates:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-east-asian:normal;font-feature-settings:normal;color:rgba(0,0,0,0.85)"><span class="gmail-Apple-converted-space">    </span><span style="color:rgb(57,0,160)">CFRunLoopSourceRef</span>
            (*GetInterfaceAsyncEventSource)(<span style="color:rgb(155,35,147)"><b>void</b></span> *<span style="color:rgb(155,35,147)"><b>self</b></span>);</p>
          <p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;font-size-adjust:none;font-kerning:auto;font-variant-alternates:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-east-asian:normal;font-feature-settings:normal;color:rgba(0,0,0,0.85)"><span class="gmail-Apple-converted-space">    </span><span style="color:rgb(57,0,160)">IOReturn</span>
            (*CreateInterfaceAsyncPort)(<span style="color:rgb(155,35,147)"><b>void</b></span> *<span style="color:rgb(155,35,147)"><b>self</b></span>, <span style="color:rgb(57,0,160)">mach_port_t</span> *port);</p>
          <p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;font-size-adjust:none;font-kerning:auto;font-variant-alternates:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-east-asian:normal;font-feature-settings:normal;color:rgba(0,0,0,0.85)"><span class="gmail-Apple-converted-space">    </span><span style="color:rgb(57,0,160)">mach_port_t</span>
            (*GetInterfaceAsyncPort)(<span style="color:rgb(155,35,147)"><b>void</b></span>
            *<span style="color:rgb(155,35,147)"><b>self</b></span>);</p>
          <p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;font-size-adjust:none;font-kerning:auto;font-variant-alternates:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-east-asian:normal;font-feature-settings:normal;color:rgba(0,0,0,0.85)"><span class="gmail-Apple-converted-space">    </span><span style="color:rgb(57,0,160)">IOReturn</span>
            (*USBInterfaceOpen)(<span style="color:rgb(155,35,147)"><b>void</b></span>
            *<span style="color:rgb(155,35,147)"><b>self</b></span>);</p>
          <p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;font-size-adjust:none;font-kerning:auto;font-variant-alternates:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-east-asian:normal;font-feature-settings:normal;color:rgba(0,0,0,0.85)"><span class="gmail-Apple-converted-space">    </span><span style="color:rgb(57,0,160)">IOReturn</span>
            (*USBInterfaceClose)(<span style="color:rgb(155,35,147)"><b>void</b></span>
            *<span style="color:rgb(155,35,147)"><b>self</b></span>);</p>
          <p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;font-size-adjust:none;font-kerning:auto;font-variant-alternates:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-east-asian:normal;font-feature-settings:normal;color:rgba(0,0,0,0.85)"><span class="gmail-Apple-converted-space">    </span><span style="color:rgb(57,0,160)">IOReturn</span>
            (*GetInterfaceClass)(<span style="color:rgb(155,35,147)"><b>void</b></span>
            *<span style="color:rgb(155,35,147)"><b>self</b></span>, <span style="color:rgb(57,0,160)">UInt8</span> *intfClass);</p>
          <p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;font-size-adjust:none;font-kerning:auto;font-variant-alternates:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-east-asian:normal;font-feature-settings:normal;color:rgba(0,0,0,0.85)"><span class="gmail-Apple-converted-space">    </span><span style="color:rgb(57,0,160)">IOReturn</span>
            (*GetInterfaceSubClass)(<span style="color:rgb(155,35,147)"><b>void</b></span>
            *<span style="color:rgb(155,35,147)"><b>self</b></span>, <span style="color:rgb(57,0,160)">UInt8</span> *intfSubClass);</p>
          <p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;font-size-adjust:none;font-kerning:auto;font-variant-alternates:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-east-asian:normal;font-feature-settings:normal;color:rgba(0,0,0,0.85)"><span class="gmail-Apple-converted-space">    </span><span style="color:rgb(57,0,160)">IOReturn</span>
            (*GetInterfaceProtocol)(<span style="color:rgb(155,35,147)"><b>void</b></span>
            *<span style="color:rgb(155,35,147)"><b>self</b></span>, <span style="color:rgb(57,0,160)">UInt8</span> *intfProtocol);</p>
          <p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;font-size-adjust:none;font-kerning:auto;font-variant-alternates:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-east-asian:normal;font-feature-settings:normal;color:rgba(0,0,0,0.85)"><span class="gmail-Apple-converted-space">    </span><span style="color:rgb(57,0,160)">IOReturn</span>
            (*GetDeviceVendor)(<span style="color:rgb(155,35,147)"><b>void</b></span>
            *<span style="color:rgb(155,35,147)"><b>self</b></span>, <span style="color:rgb(57,0,160)">UInt16</span> *devVendor);</p>
          <p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;font-size-adjust:none;font-kerning:auto;font-variant-alternates:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-east-asian:normal;font-feature-settings:normal;color:rgba(0,0,0,0.85)"> 
              ...</p>
          <br>
        </div>
        <div>These are structs that almost exclusively consist of
          function pointers. In the case of IOKit, the two main ones
          consist of 40 and 50 function pointers.</div>
        <div><br>
        </div>
        <div>Am I correct that there is currently no way to suppress the
          generation of upcall method handles?</div>
        <div><br>
        </div>
        <div>Are there any plans to to make the jextract generated code
          work well with GraalVM?</div>
        <div><br>
        </div>
        <div>Regards</div>
        <div>Manuel</div>
        <div><br>
        </div>
      </div>
    </blockquote>
  </body>
</html>