Values computed by a ClassValue should not strongly reference the ClassValue

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: P3
    • tbd
    • Affects Version/s: 9
    • Component/s: core-libs
    • Cause Known

      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.

            Assignee:
            Paul Sandoz
            Reporter:
            Paul Sandoz
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: