Hi Roman, On Fri, Jan 16, 2009 at 6:05 PM, Roman Kennke <ro...@kennke.org> wrote: > Hi Oleg, > >> I'd synchronized setting/getting of access field. And (perhaps) I'd only >> allow >> set this field once. > > Good ideas. I implemented both suggestions. Webrev is updated at the > same URL.
As far as I can see you add synchronization only to setter, but you should also add synchronization when you read this field. So you should either make access field volatile, or add synchronized getter and use it to get the field. Oleg. > /Roman > >> >> Regards, Oleg. >> >> On Fri, Jan 16, 2009 at 5:14 PM, Roman Kennke <ro...@kennke.org> wrote: >> > Today I found the aweful (sorry) ComponentAccessor. I quickly rewrote it >> > using what I call the 'friends for Java' pattern (described here: >> > >> > http://kennke.org/blog/2009/01/08/friends-for-java/ >> > >> > ). >> > >> > This has a couple of advantages: >> > >> > - no reflection (I don't like reflection) >> > - compile-time safety >> > - better IDE support (i.e. I was trying to trace >> > ComponentPeer.getGraphicsConfiguration() back today, and only got to >> > Window.resetGC(), because this one is only called via reflection in >> > ComponentAccessor). >> > - I'd guess that performance is slighly better, but that probably >> > doesn't matter much in these cases. >> > >> > Do you think that should go into OpenJDK? >> > >> > Webrev: http://kennke.org/~roman/componentaccess/webrev/ >> > >> > Cheers, Roman >> > >> > -- >> > http://kennke.org/blog/ >> > > -- > http://kennke.org/blog/ >