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

Descriptor parser fails with leading zeros in layout names

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • None
    • repo-panama
    • tools

      From panama-dev:
      https://mail.openjdk.java.net/pipermail/panama-dev/2019-December/006812.html

      Consider the following functions:

      int (*reserved00)(void *, void *, void *, void *, void *, void *, void *, void *);
      int (*reserved01)(void *, void *, void *, void *, void *, void *, void *, void *);
      int (*reserved02)(void *, void *, void *, void *, void *, void *, void *, void *);

      jextract correctly creates annotations from this, e.g.:
      u64(reserved00):(u64:vu64:vu64:vu64:vu64:vu64:vu64:vu64:v)i32

      The layout names are incorrectly parsed as: reserved0, reserved1 and reserved2, respectively. And at binding-time, this cause an exception (as the symbols could not be resolved):

      Exception in thread "main" java.lang.IllegalStateException: java.lang.RuntimeException: Failed to generate implementation for class interface com.example.fuse.fuse_h$fuse_operations
      at java.base/java.foreign.memory.Pointer.lambda$get$3(Pointer.java:170)
      at java.base/java.security.AccessController.doPrivileged(AccessController.java:312)
      at java.base/java.foreign.memory.Pointer.get(Pointer.java:166)
      at java.base/jdk.internal.foreign.ScopeImpl.allocateStruct(ScopeImpl.java:160)
      at com.example.fusepanama.Main.main(Main.java:28)
      Caused by: java.lang.RuntimeException: Failed to generate implementation for class interface com.example.fuse.fuse_h$fuse_operations
      at java.base/jdk.internal.foreign.LibrariesHelper.generateImpl(LibrariesHelper.java:67)
      at java.base/jdk.internal.foreign.LibrariesHelper$1.computeValue(LibrariesHelper.java:76)
      at java.base/jdk.internal.foreign.LibrariesHelper$1.computeValue(LibrariesHelper.java:72)
      at java.base/java.lang.ClassValue.getFromHashMap(ClassValue.java:226)
      at java.base/java.lang.ClassValue.getFromBackup(ClassValue.java:208)
      at java.base/java.lang.ClassValue.get(ClassValue.java:114)
      at java.base/jdk.internal.foreign.LibrariesHelper.getStructImplClass(LibrariesHelper.java:92)
      at java.base/jdk.internal.foreign.memory.References$OfStruct.makeSpecializedGetter(References.java:542)
      at java.base/jdk.internal.foreign.memory.References$OfStruct.getter(References.java:527)
      at java.base/jdk.internal.foreign.memory.LayoutTypeImpl.getter(LayoutTypeImpl.java:87)
      at java.base/java.foreign.memory.Pointer.lambda$get$3(Pointer.java:168)
      ... 4 more
      Caused by: java.lang.RuntimeException: Failed to generate method public abstract java.foreign.memory.Callback com.example.fuse.fuse_h$fuse_operations.reserved00$get()
      at java.base/jdk.internal.foreign.BinderClassGenerator.generateMembers(BinderClassGenerator.java:159)
      at java.base/jdk.internal.foreign.StructImplGenerator.generateMembers(StructImplGenerator.java:59)
      at java.base/jdk.internal.foreign.BinderClassGenerator.generate(BinderClassGenerator.java:110)
      at java.base/jdk.internal.foreign.LibrariesHelper.lambda$generateImpl$0(LibrariesHelper.java:64)
      at java.base/java.security.AccessController.doPrivileged(AccessController.java:312)
      at java.base/jdk.internal.foreign.LibrariesHelper.generateImpl(LibrariesHelper.java:63)
      ... 14 more
      Caused by: java.lang.NullPointerException
      at java.base/jdk.internal.foreign.StructImplGenerator.generateFieldAccessor(StructImplGenerator.java:113)
      at java.base/jdk.internal.foreign.StructImplGenerator.generateMethodImplementation(StructImplGenerator.java:105)
      at java.base/jdk.internal.foreign.BinderClassGenerator.generateMembers(BinderClassGenerator.java:156)
      ... 19 more

        1. 8235406.patch
          0.7 kB
          Maurizio Cimadamore

            henryjen Henry Jen
            mcimadamore Maurizio Cimadamore
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: