Skip to content

Commit 0fad76f

Browse files
java-team-github-botGoogle Java Core Libraries
authored andcommitted
Implement tests for memory leaks/crashes in UnmodifiableSortedMultiset, and add comments in places where the cycle could not be resolved without some refactoring.
RELNOTES=n/a PiperOrigin-RevId: 785577286
1 parent e0041c6 commit 0fad76f

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

android/guava/src/com/google/common/collect/ImmutableRangeSet.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,10 @@ Object writeReplace() {
382382
}
383383
}
384384

385+
// TODO(b/418181860): This method creates retain cycles in J2ObjC. In order to break the cycle,
386+
// there needs to be separate classes for primary and complement range set, where the primary one
387+
// would hold {@code @LazyInit @RetainedWith @Nullable} reference to its complement, and the other
388+
// {@code final} reference.
385389
@Override
386390
public ImmutableRangeSet<C> complement() {
387391
ImmutableRangeSet<C> result = complement;

android/guava/src/com/google/common/collect/UnmodifiableSortedMultiset.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ public NavigableSet<E> elementSet() {
6363

6464
@LazyInit private transient @Nullable UnmodifiableSortedMultiset<E> descendingMultiset;
6565

66+
// TODO(b/418181860): This method creates retain cycles in J2ObjC. In order to break the cycle,
67+
// there needs to be separate classes for primary and descending multiset, where the primary one
68+
// would hold {@code @LazyInit @RetainedWith @Nullable} reference to its descending multiset, and
69+
// the other {@code final} reference.
6670
@Override
6771
public SortedMultiset<E> descendingMultiset() {
6872
UnmodifiableSortedMultiset<E> result = descendingMultiset;

guava/src/com/google/common/collect/ImmutableRangeSet.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,10 @@ Object writeReplace() {
381381
}
382382
}
383383

384+
// TODO(b/418181860): This method creates retain cycles in J2ObjC. In order to break the cycle,
385+
// there needs to be separate classes for primary and complement range set, where the primary one
386+
// would hold {@code @LazyInit @RetainedWith @Nullable} reference to its complement, and the other
387+
// {@code final} reference.
384388
@Override
385389
public ImmutableRangeSet<C> complement() {
386390
ImmutableRangeSet<C> result = complement;

guava/src/com/google/common/collect/UnmodifiableSortedMultiset.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ public NavigableSet<E> elementSet() {
6363

6464
@LazyInit private transient @Nullable UnmodifiableSortedMultiset<E> descendingMultiset;
6565

66+
// TODO(b/418181860): This method creates retain cycles in J2ObjC. In order to break the cycle,
67+
// there needs to be separate classes for primary and descending multiset, where the primary one
68+
// would hold {@code @LazyInit @RetainedWith @Nullable} reference to its descending multiset, and
69+
// the other {@code final} reference.
6670
@Override
6771
public SortedMultiset<E> descendingMultiset() {
6872
UnmodifiableSortedMultiset<E> result = descendingMultiset;

0 commit comments

Comments
 (0)