RFR 9: 8138696 : java.lang.ref.Cleaner - an easy to use alternative to finalization
Mandy Chung
mandy.chung at oracle.com
Wed Dec 16 20:59:35 UTC 2015
> On Dec 16, 2015, at 12:42 PM, Roger Riggs <Roger.Riggs at Oracle.com> wrote:
> Nit: There is no return value and this @return is not needed.
>> * @return does not return
>>
> right
I’m seeing this in other places. You can take them out before you push (no new webrev needed).
>>
>> In the test:
>> 228 Object o = r.get();
>> 229 if (!(r instanceof PhantomReference) && !cleaned) {
>> 230 Reference<?> expectedRef = test.getRef();
>> 231 Assert.assertEquals(expectedRef.get(), o,
>> 232 "Object reference incorrect");
>> 233 }
>>
>> Curious on this test case: Is r.get() calling the overridden get() method that always throws null?
>>
> The verifyGetRef is used to test both the subclassable XXXCleanable refs and
> the PhantomCleanableRef that is exposed using Cleaner.register.
> verifyGetRef can be simplified since it is only used (now) to verify the ref before it is cleaned so get returns non-null, except for phantoms.
>
I see it now - this object is an instance of the test’s defined subclass. is not a PhantomCleanableRef (nor Weak/Soft).
The confusion comes from:
234 } catch (UnsupportedOperationException uoe) {
this method may verify the objects created from Cleaner. It may be a good future improvement to separate the custom subclass and Cleaner implementation to make it easier to understand.
Thanks. No further comment from me.
Mandy
More information about the core-libs-dev
mailing list