Uploaded image for project: 'Code Tools'
  1. Code Tools
  2. CODETOOLS-7903354

jextract generates redundant cast in ofAddress method

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • None
    • None
    • tools
    • None

      File: t.h

      void (*f)(int);

      The generated f.java looks as follows:

      public interface f {

          void apply(int _x0);
          static MemorySegment allocate(f fi, MemorySession session) {
              return RuntimeHelper.upcallStub(f.class, fi, constants$0.f$FUNC, session);
          }
          static f ofAddress(MemorySegment addr, MemorySession session) {
              MemorySegment symbol = MemorySegment.ofAddress(addr.address(), 0, session);
              return (int __x0) -> {
                  try {
                      constants$0.f$MH.invokeExact((MemorySegment)symbol, __x0);
                  } catch (Throwable ex$) {
                      throw new AssertionError("should not reach here", ex$);
                  }
              };
          }
      }

      Note the redundant cast in the line:

                      constants$0.f$MH.invokeExact((MemorySegment)symbol, __x0);

            sundar Sundararajan Athijegannathan
            sundar Sundararajan Athijegannathan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: