<!DOCTYPE html>
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hello,</p>
    <p>jextract generated code contains multiple times this pattern when
      handling the `Throwable` declared by `MethodHandle#invokeExact`:<br>
      ```<br>
      try {<br>
          mh.invokeExact(...);<br>
      } catch (Throwable ex) {<br>
          throw new AssertionError("should not reach here", ex);<br>
      }<br>
      ```</p>
    <p>The problem is that this actually seems to be reachable:</p>
    <ul>
      <li>When for example a closed Arena is used, or a confined Arena
        is used by a different thread, see for example
<a class="moz-txt-link-freetext" href="https://github.com/tree-sitter/java-tree-sitter/issues/44#issuecomment-2402356147">https://github.com/tree-sitter/java-tree-sitter/issues/44#issuecomment-2402356147</a><br>
        Maybe in some cases this represents incorrect usage of the
        jextract generated code, but it seems at least in some cases
        (e.g. usage from wrong thread) an AssertionError is
        inappropriate.<br>
      </li>
      <li>Probably when a JVM error occurs</li>
    </ul>
    <p><br>
    </p>
    <p>So maybe it would be better to generate code like this?<br>
      ```<br>
      try {<br>
          mh.invokeExact(...);<br>
      } catch (Error | RuntimeException ex) {<br>
          throw ex;<br>
      } catch (Throwable ex) {<br>
          throw new AssertionError("should not reach here", ex);<br>
      }<br>
      ```</p>
    <p><br>
    </p>
    <p>Side note: <a class="moz-txt-link-freetext" href="https://bugreport.java.com/bugreport/start_form">https://bugreport.java.com/bugreport/start_form</a>
      currently does not support reporting jextract issues; when
      selecting "Component: Tools Issues", the "Subcomponent" dropdown
      does not offer "jextract". Is that intended?</p>
    <p><br>
    </p>
    <p>Kind regards<br>
    </p>
  </body>
</html>