diff --git a/platform/util/src/com/intellij/util/containers/UnsafeWeakList.java b/platform/util/src/com/intellij/util/containers/UnsafeWeakList.java index 5be6cb8f95c3..1b58516fab54 100644 --- a/platform/util/src/com/intellij/util/containers/UnsafeWeakList.java +++ b/platform/util/src/com/intellij/util/containers/UnsafeWeakList.java @@ -35,6 +35,9 @@ import java.util.*; *
  • Is NOT RandomAccess, because garbage collector can remove element at any time
  • *
  • Does NOT support null elements
  • * + * Please note that since weak references can be collected at any time, index-based methods (like get(index)) + * or size-based methods (like size()) are dangerous, misleading, error-inducing and are not supported. + * Instead, please use add(element) and iterator(). */ public class UnsafeWeakList extends AbstractCollection { protected final List> myList; @@ -237,6 +240,11 @@ public class UnsafeWeakList extends AbstractCollection { return ContainerUtil.mapNotNull(myList, UnsafeWeakList.deref()); } + /** + * Since weak references can be collected at any time, + * this method considered dangerous, misleading, error-inducing and are is not supported. + * Instead, please use add(element) and iterator() + */ @Override @Deprecated public int size() { diff --git a/platform/util/src/com/intellij/util/containers/WeakList.java b/platform/util/src/com/intellij/util/containers/WeakList.java index 86aeb973fd6e..5468ea0b16ee 100644 --- a/platform/util/src/com/intellij/util/containers/WeakList.java +++ b/platform/util/src/com/intellij/util/containers/WeakList.java @@ -30,6 +30,9 @@ import java.util.List; *
  • Is NOT RandomAccess, because garbage collector can remove element at any time
  • *
  • Does NOT support null elements
  • * + * Please note that since weak references can be collected at any time, index-based methods (like get(index)) + * or size-based methods (like size()) are dangerous, misleading, error-inducing and are not supported. + * Instead, please use add(element) and iterator(). */ public class WeakList extends UnsafeWeakList { public WeakList() {