Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8261511

jextract fails to handle name clashes between unrelated constants

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: repo-panama
    • Fix Version/s: None
    • Component/s: tools

      Description

      The library I use declares a function pointer within a struct's field
      named "read" [1]. I think you see where this is going...

          typedef struct ucs_config_parser {
               int (*read) (const char *buf, void *dest,
          const void *arg);
               int (*write)(char *buf, size_t max,
                                                 const void *src, const void
          *arg);
               ucs_status_t (*clone)(const void *src, void *dest,
          const void *arg);
               void (*release)(void *ptr, const void *arg);
               void (*help)(char *buf, size_t max, const
          void *arg);
               const void *arg;
          } ucs_config_parser_t;


      Since "unistd.h" also declares a "read" function [2], jextract then
      (correctly) generates a MethodHandle for it
      but uses the wrong FunctionDescriptor belonging to ucx's "read" in the
      process.

          static final FunctionDescriptor read$FUNC_ =
          FunctionDescriptor.of(C_INT,
                   C_POINTER,
                   C_POINTER,
                   C_POINTER
          );

          static final MethodHandle read$MH_ = RuntimeHelper.downcallHandle(
                   LIBRARIES, "read",
                   "(ILjdk/incubator/foreign/MemoryAddress;J)J",
                   read$FUNC_, false
          );


      As you can see the generated FunctionDescriptor and the descriptor
      string ("(ILjdk/incubator/foreign/MemoryAddress;J)J")
      do not match. On startup, I immediately get the following Exception
      originating from the downcallHandle call.

          Caused by: java.lang.IllegalArgumentException: Carrier size
          mismatch: int != b64[abi/kind=POINTER]

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              sundar Sundararajan Athijegannathan
              Reporter:
              mcimadamore Maurizio Cimadamore
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: