Hi David,

Looking at original code once again, I think this was actually a bug. The WeakReference instance constructed in (old) line 82, can be GCed right away, since nobody is using the local variable after assignment. I f WeakReference is GCed it can not be enqueued. The promotion of local variable into a field is one way to fix this. The other would be to use the local variable somewhere down the code path, like for example in a final throw statement:

 110          throw new IllegalStateException("Reference Handler thread stuck. 
weakRef.get(): " + weakRef.get());


This would also reveal some more info about the WeakReference when there's no sure answer after 10 seconds and could be added to the test anyway.

Regards, Peter

On 07/02/2013 06:38 AM, David Holmes wrote:
This recently added test was found to fail under some conditions - namely client compiler with -Xcomp. It seems that the use of all local variables enabled the compiler to optimize things in a way that stopped the weakref from being enqueued as expected. Simple fix was to make the weakref a field.

http://cr.openjdk.java.net/~dholmes/8016341/webrev/

Thanks,
David

Reply via email to