[concurrency-interest] RFR (S): JEP-142: Reduce Cache Contention on Specified Fields

Aleksey Shipilev aleksey.shipilev at oracle.com
Fri Nov 23 15:07:16 EST 2012


On 11/23/2012 11:43 PM, Doug Lea wrote:
> (Warning: cross-posting, so replies may bounce to one or both lists.)
> 
>> However, this still has a drawback that the subclass annotation will
>> only affect the fields in the subclass, and not in the superclasses
>> (laying the superclass fields on the same offsets in the subclass is
>> important to get cheap polymorphism).
> 
> 
> Considering that the only usages with predictable effects will be
> on leaf/final classes anyway, perhaps the @Contended annotation
> should only have a defined effect on layout when applied to final
> classes (plus statics). This also seems to be the only case when a
> developer can have an empirical basic for using the annotation.
> And if there someday turns out to be some reason to lift this
> restriction, it would be possible to do so.

I don't think so. My comment was that you can't change the padding for
the superclass fields, but the contended safety for the superclass
fields should actually stay intact. I.e.,

 class Base {
    @Contended
    private int mySuperImportantField;
 }

...should NOT be compromised with

 class Rogue extends Base {
    private int wannaKillYourPadding;
 }

...and it doesn't in the present version, and it sticks with the same
principle: once superclass fields are laid out, you stick with that
layout in all the subclasses.

-Aleksey.


More information about the Concurrency-interest mailing list