[10] RFR: 8184603: Create ObjectStreamField signature lazily when possible

Aleksey Shipilev shade at redhat.com
Fri Jul 14 13:33:56 UTC 2017

On 07/14/2017 03:25 PM, Aleksey Shipilev wrote:
> On 07/14/2017 02:47 PM, Claes Redestad wrote:
>>> For extra points remove the superfluous null assignment of
>>> `signature` and `field` ( as well as `offset` ).
>> 'field' is final so that'd make javac cry bloody murder, but I fixed the
>> rest and cleaned up a bit for consistency:
>> http://cr.openjdk.java.net/~redestad/8184603/jdk.01/
> Can you also not do $signature field "volatile", for the sake on non-x86
> platforms? I think getSignature() has a benign race then, which is safe.

Hm, there is ObjectStreamField(String name, String signature, boolean unshared)
constructor that passes naked signature.

There are two issues here:
  a) getSignature() would now ignore the signature passed via that constructor,
because it will redo the signature from $type field, which is initialized to
Object.class for references;
  b) neither volatile nor blank qualifier would help to survive the racy read of
OSF.signature field if OSF was initialized with that private constructor.

I guess careful inspection of that constructor uses would tame these problems.


More information about the core-libs-dev mailing list