7122142 : (ann) Race condition between isAnnotationPresent and getAnnotations

Peter Levart peter.levart at gmail.com
Wed Jun 19 19:16:25 UTC 2013

On 06/19/2013 08:54 PM, Alan Bateman wrote:
> On 19/06/2013 15:23, Peter Levart wrote:
>> Hi,
>> Since the bulk of changes to annotations and reflection have 
>> stabilized, I'm bringing up a re-based batch that I have proposed 
>> some months ago:
>> http://mail.openjdk.java.net/pipermail/core-libs-dev/2013-February/014203.html 
>> :
>> This patch is one angle of attack for bug 7122142. The other is, off 
>> course, removing the other synchronized keyword (on 
>> Class.initAnnotationsIfNecessary()). I'm planning to do that too, but 
>> in a more straight-forward manner.
>> Regards, Peter
> Thank you for coming back to this.
> I've looked over the webrev and the approach looks good to me. Joel 
> might want to look at this too. Do you think you could include a test 
> (as we try to include a test with all fixes if we can)?

Hi Alan,

I'll do the tests for both issues. The 1st (deadlock) will be 
straightforward (I think). But the second requires two versions of 
source file for single class. The 1st version is compiled with the test 
and the 2nd version is compiled separately and used to run the test (to 
simulate separate compilation). Do you happen to know if something like 
that has already been done in some JDK test or how to approach writing 
such test (whether there's already any infrastructure built that might 
support such tests)?

> It would be good to remove the synchronizaiton on 
> initAnnotationsIfNecessary too, but one step as time (and smaller 
> changes are always easier to discuss).

One step at a time, right. I actually thought that to be a separate, 
unrelated patch that just happens to solve the same bug, but it also 
solves the other one:

8011940 : java.lang.Class.getAnnotations() always enters synchronized method

Regards, Peter

> -Alan

More information about the core-libs-dev mailing list