[9] RFR (M): 8067344: Adjust java/lang/invoke/LFCaching/LFGarbageCollectedTest.java for recent changes in java.lang.invoke

Vladimir Ivanov vladimir.x.ivanov at oracle.com
Thu Dec 25 15:53:36 UTC 2014


Thanks for the feedback!

Your idea to use SoftReferences and check the referent sounds interesting.

However, I'm in favor of PhantomReferences here. Though SoftRefs have 
some benefits w.r.t. current LF cache implementation, they unnecessarily 
leak implementation details into the test.

PhantomRefs clearly state the intention of the test - get a notification 
once an object can be garbage collected.

Also, it makes the test more accurate. If we were to switch from 
SoftRefs to WeakRefs in the LF cache implementation, we wouldn't need to 
update the test.

Best regards,
Vladimir Ivanov

On 12/24/14 3:20 PM, Peter Levart wrote:
> Hi Vladimir,
> I just wanted to ask about the reason you used PhantomReference to
> detect that a referent is not softly reachable any more. You could use
> another SoftReference or a WeakReference for the same effect, since it
> is guaranteed that all SoftReferences for same referent are cleared
> atomically and WeakReferences are cleared when referent is not softly
> reachable any more. Using Weak or PhantomReference in test can
> theoretically give false failures, since the object can still be weakly
> of phantom reachable, but not softly reachable any more.
> I think that it is enough for test to check that the referent is not
> softly reachable any more, since cache is using SoftReferences.
> Therefore it would be most appropriate to use a SoftReference in test too.
> What do you think?
> Regards, Peter
> On 12/23/2014 01:40 PM, Vladimir Ivanov wrote:
>> Spotted some more problems:
>>   - need to skip identity operations (identity_* LambdaForms) in the
>> test, since corresponding LambdaForms reside in a permanent cache;
>>   - need to keep original test data for diagnostic purposes, since
>> getTestCaseData() produces new instance.
>> Updated version:
>> http://cr.openjdk.java.net/~vlivanov/8067344/webrev.01/
>> Best regards,
>> Vladimir Ivanov
>> On 12/22/14 11:53 PM, Vladimir Ivanov wrote:
>>> http://cr.openjdk.java.net/~vlivanov/8067344/webrev.00/
>>> https://bugs.openjdk.java.net/browse/JDK-8067344
>>> LFGarbageCollectedTest should be adjusted after JDK-8057020.
>>> There are a couple of problems with the test.
>>> (1) Existing logic to test that LambdaForm instance is collected isn't
>>> stable enough. Consequent System.GCs can hinder reference enqueueing.
>>> To speed up the test, I added -XX:SoftRefLRUPolicyMSPerMB=0 and limited
>>> the heap by -Xmx64m.
>>> (2) MethodType-based invoker caches are deliberately left strongly
>>> reachable. So, they should be skipped in the test.
>>> (3) Added additional diagnostic output to simplify failure analysis
>>> (test case details, method handle type and LambdaForm, heap dump
>>> (optional, -DHEAP_DUMP=true)).
>>> Testing: failing test.
>>> Thanks!
>>> Best regards,
>>> Vladimir Ivanov

More information about the core-libs-dev mailing list