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

jextract crashes due to name clash with pointer to function typedefs

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • None
    • None
    • tools
    • generic
    • generic

      File: test.h

      typedef void (func)(int x, const void *addr);


      $ jextract test.h
      WARNING: Using incubator modules: jdk.incubator.foreign
      In memory compilation failed: warning: using incubating module(s): jdk.incubator.foreign
      func.java:16: error: variable addr is already defined in method ofAddress(MemoryAddress,ResourceScope)
      return (int x, jdk.incubator.foreign.MemoryAddress addr) -> {
                                                         ^
      1 error
      1 warning

      $ jextract --source test.h
      WARNING: Using incubator modules: jdk.incubator.foreign
      $ cat func.java
      // Generated by jextract

      import java.lang.invoke.MethodHandle;
      import java.lang.invoke.VarHandle;
      import java.nio.ByteOrder;
      import jdk.incubator.foreign.*;
      import static jdk.incubator.foreign.ValueLayout.*;
      public interface func {

          void apply(int x, jdk.incubator.foreign.MemoryAddress addr);
          static NativeSymbol allocate(func fi, ResourceScope scope) {
              return RuntimeHelper.upcallStub(func.class, fi, constants$0.func$FUNC, "(ILjdk/incubator/foreign/MemoryAddress;)V", scope);
          }
          static func ofAddress(MemoryAddress addr, ResourceScope scope) {
              NativeSymbol symbol = NativeSymbol.ofAddress("func::" + Long.toHexString(addr.toRawLongValue()), addr, scope);
      return (int x, jdk.incubator.foreign.MemoryAddress addr) -> {
                  try {
                      constants$0.func$MH.invokeExact(symbol, x, (jdk.incubator.foreign.Addressable)addr);
                  } catch (Throwable ex$) {
                      throw new AssertionError("should not reach here", ex$);
                  }
              };
          }
      }


      Names like "addr", "scope" used in FunctionalInterfaceBuilder can clash with identifiers from C headers.

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

              Created:
              Updated:
              Resolved: