On 08/31/2017 12:05 PM, Kazunori Ogata wrote: > Bug report: https://bugs.openjdk.java.net/browse/JDK-8187033 > Webrev: http://cr.openjdk.java.net/~horii/8187033/webrev.00/
Alas, this change is incorrect. It introduces the race between readers and writers of dataLayout field. Which means, whatever writers have done in ClassDataSlot[] array is not guaranteed to be visible to the readers of $dataLayout. You can argue this race is benign, but it is not. ClassDataSlot has only the final fields, which is handy. But the problem is with the ClassDataSlot[] array itself: its elements are not "final". Maybe doing the wrapper with final field around it would help, at the expense of additional dereference, e.g.: private DataLayout dataLayout; class DataLayout { final ClassDataSlot[] slots; // "final" is important here DataLayout(List<ClassDataSlot> src) { this.slots = src.toArray(new ClassDataSlot[src.size()]; } } ClassDataSlot[] getClassDataLayout() throws InvalidClassException { if (dataLayout == null) { dataLayout = getClassDataLayout0(); } return dataLayout.slots; } Plus maybe replace all declarations of ObjectStreamClass.ClassDataSlot[] with ObjectStreamClass.DataLayout after this... Thanks, -Aleksey