> On Jan 18, 2021, at 12:28 PM, Peter Levart <plev...@openjdk.java.net> wrote: > If you introduce a private method in Reference: > > private void enqueueFromPending() { > var q = queue; > if (q != ReferenceQueue.NULL) q.enqueue(this); > } > > ...and use it Reference.processPendingReferences while loop like this: > > if (ref instanceof Cleaner) { > ... > } else { > ref.enqueueFromPending(); > } > > Then you can keep the signature of `ReferenceQueue.enqueue(Reference<? > extends T> r)` and no unchecked casts are needed there.
Nice! And this reverts all changes to ReferenceQueue.java > But what you have is OK and much better than what was before. Thanks, but I’m going to take your improvement. I’ll update the PR once I’ve re-run some tests.