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

ZIP libraries could benefit from new intrinsic accessors to byte arrays

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • None
    • core-libs
    • None

      Currently only ByteBuffer access profits from bug JDK-8026049.
      Please see this report as motivation to fix bug JDK-6914113

      code example from ZipFileSystem:
      -----------------------------
                  // Now scan the block backwards for END header signature
                  for (int i = buf.length - ENDHDR; i >= 0; i--) {
                      if (buf[i+0] == (byte)'P' &&
                          buf[i+1] == (byte)'K' &&
                          buf[i+2] == (byte)'\005' &&
                          buf[i+3] == (byte)'\006' &&
      -----------------------------
      code examples from ZipUtils:
      -----------------------------
          /**
           * Fetches unsigned 16-bit value from byte array at specified offset.
           * The bytes are assumed to be in Intel (little-endian) byte order.
           */
          public static final int get16(byte b[], int off) {
              return (b[off] & 0xff) | ((b[off + 1] & 0xff) << 8);
          }

          // fields access methods
          static final int CH(byte[] b, int n) {
              return b[n] & 0xff ;
          }

          static final int SH(byte[] b, int n) {
              return (b[n] & 0xff) | ((b[n + 1] & 0xff) << 8);
          }


            sherman Xueming Shen
            ulfzibis Ulf Zibis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: