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

Values computed by a ClassValue should not strongly reference the ClassValue

    Details

    • Type: Bug
    • Status: Open
    • Priority: P3
    • Resolution: Unresolved
    • Affects Version/s: 9
    • Fix Version/s: tbd
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Understanding:
      Cause Known

      Description

      A computed value produced by a ClassValue instance should not strongly refer to that instance, for example:

      class Holder {
        Object o;
        Holder(Object o) { this.o = o; }
      }

      class MyClassValue extends ClassValue<Holder> {
        Holder computerValue(Class<?> type) {
          return new Holder(this);
        }
      }

      In the current JDK implementation this will prevent classes from being garbage collected and therefore cause a memory link.

      Rather than changing the implementation of ClassValue to support such an edge case it is preferred to update the documentation of ClassValue.computeValue warning against such behaviour.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                psandoz Paul Sandoz (Inactive)
                Reporter:
                psandoz Paul Sandoz (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: