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

SA's ConstantPool.java uses incorrect computation to read long value in the constant pool

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 22
    • 22
    • hotspot
    • None
    • b07

      Comparing String.class generated by SA's dumpclass command with the original String class (using javap) the `serialVersionUID` field is different in the two classs.
      In the original it is:

        private static final long serialVersionUID;
          descriptor: J
          flags: (0x001a) ACC_PRIVATE, ACC_STATIC, ACC_FINAL
          ConstantValue: long -6849794470754667710l

      In the dumped class it is:

        private static final long serialVersionUID;
          descriptor: J
          flags: (0x001a) ACC_PRIVATE, ACC_STATIC, ACC_FINAL
          ConstantValue: long 2050732866l

      Long value is read by ConstantPool use this method:

        public long getLongAt(long index) {
          int oneHalf = getAddress().getJIntAt(indexOffset(index + 1));
          int otherHalf = getAddress().getJIntAt(indexOffset(index));
          // buildLongFromIntsPD accepts higher address value, lower address value
          // in that order.
          return VM.getVM().buildLongFromIntsPD(oneHalf, otherHalf);
        }

      This is not correct because each entry in the runtime constant pool is 8-bytes (on 64-bit platforms) and the long value is stored as at "index" and the value at "index+1" is not used. This code above tries to read "oneHalf" from "index+1" which is not valid.
      The correct way is to just use getAddress().getJLongAt(indexOffset(index)).

            asmehra Ashutosh Mehra
            asmehra Ashutosh Mehra
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: