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

ReferenceType.constantPool() may throw NullPointerException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • tbd
    • 6
    • core-svc
    • None
    • generic
    • generic

      This is implementstion of ReferenceTypeImpl.constantPool():

      1012 public byte[] constantPool() {
      1013 try {
      1014 getConstantPoolInfo();
      1015 } catch (RuntimeException exc) {
      1016 throw exc;
      1017 }
      1018 if (constantPoolBytesRef != null) {
      1019 byte[] cpbytes = (byte[])constantPoolBytesRef.get();
      1020 /*
      1021 * Arrays are always modifiable, so it is a little unsafe
      1022 * to return the cached bytecodes directly; instead, we
      1023 * make a clone at the cost of using more memory.
      1024 */
      1025 return (byte[])cpbytes.clone();
      1026 } else {
      1027 return null;
      1028 }
      1029 }

      Implementation uses soft reference 'constantPoolBytesRef' to keep constant pool bytes, but constantPoolBytesRef.get()(line 1019) may return null if soft reference has been cleared, method 'constantPool()' doesn't check it and in this case cpbytes.clone()(line 1025) may thow NullPointerException.

            swamyv Swamy Venkataramanappa (Inactive)
            sboikovsunw Semen Boikov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: