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

MethodHandles.arrayConstructor can be cached

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 21
    • core-libs

      MethodHandles.arrayConstructor calls asType on a trusted method handle that's known to return instances of the array type. We can swap the asType() call with viewAsType(type, false) for better creation performance. In addition, it can probably be cached like other array element accessors; in JDK 20 its creation performance is 61ns/op (tested with String[]), while the cached int[] element accessors are created at 1.5ms/op.

            liach Chen Liang
            liach Chen Liang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: