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

Anton Kozlov akozlov at openjdk.java.net
Mon Apr 25 17:55:58 UTC 2022


On Wed, 20 Apr 2022 19:46:49 GMT, Dan Heidinga <heidinga at openjdk.org> wrote:

>> Anton Kozlov has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains two additional commits since the last revision:
>> 
>>  - Merge remote-tracking branch 'jdk/crac/crac' into refqueue-2
>>  - Update ReferenceHandle for CRaC
>>    
>>    * Hide new API for internal use
>>    * Add timeout
>>    * Remove REFERENCE_HANDLER resource
>
> 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 :)

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

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


More information about the crac-dev mailing list