[crac] RFR: Update Reference Handling for CRaC [v2]

Dan Heidinga heidinga at openjdk.java.net
Fri May 27 15:53:31 UTC 2022


On Mon, 25 Apr 2022 17:52:12 GMT, Anton Kozlov <akozlov at openjdk.org> wrote:

>> src/java.base/share/classes/java/lang/ref/Reference.java line 331:
>> 
>>> 329: 
>>> 330:             @Override
>>> 331:             public boolean waitForQueueProcessed(ReferenceQueue<?> queue,
>> 
>> Should this method be static as it doesn't use the instance's state?  
>> 
>> Alternatively, if it's for *this* reference's queue, then the instance variable should be used and the queue parameter can be removed.
>> 
>> Actually, I'm starting to think this method shouldn't exist on reference.  It belongs on the ReferenceQueue rather than here.  Possibly as a static helper method if there's a need to expose the version that takes a queue.
>
> This is an interface method of JavaLangRefAccess that exposes some package-private java.lang.ref methods. So it cannot be static. `this` in this context is the instance of that JavaLangRefAccess. And the interface methods just calls the instance method of ReferenceQueue as you suggest.
> 
> That instance method is intentionally made not-public, so our EA code will be compatible with JDK17. After some thought, this looks like better approach than introducing new public methods until those methods will be agreed to be good ones. I don't feel this for the method, after all, I found a better name since the last patch in this area :)

Reading this again, I now see the new method is a member of the `new JavaLangRefAccess() {}` class which makes perfect sense for why it's here like this.

-------------

PR: https://git.openjdk.java.net/crac/pull/22


More information about the crac-dev mailing list