RFR: 8132984: incorrect type for Reference.discovered
Kim Barrett
kim.barrett at oracle.com
Mon Jan 18 19:51:27 UTC 2021
> On Jan 18, 2021, at 12:28 PM, Peter Levart <plevart at 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.
More information about the core-libs-dev
mailing list