--- old/src/java.base/share/classes/java/io/ObjectStreamClass.java 2017-09-03 17:11:03.864477957 +0900 +++ new/src/java.base/share/classes/java/io/ObjectStreamClass.java 2017-09-03 17:11:03.792477939 +0900 @@ -172,7 +172,7 @@ /** reflector for setting/getting serializable field values */ private FieldReflector fieldRefl; /** data layout of serialized objects described by this class desc */ - private volatile ClassDataSlot[] dataLayout; + private ClassDataSlot[] dataLayout; /** serialization-appropriate constructor, or null if none */ private Constructor cons; @@ -1186,6 +1186,17 @@ } /** + * Class to ensure elements of ClassDataSlot[] are visible to other + * threads. The "final" qualifier of the variable slots is necessary. + */ + private static class DataLayout { + final ClassDataSlot[] slots; + DataLayout(ClassDataSlot[] s) { + slots = s; + } + } + + /** * Returns array of ClassDataSlot instances representing the data layout * (including superclass data) for serialized objects described by this * class descriptor. ClassDataSlots are ordered by inheritance with those @@ -1195,7 +1206,8 @@ ClassDataSlot[] getClassDataLayout() throws InvalidClassException { // REMIND: synchronize instead of relying on volatile? if (dataLayout == null) { - dataLayout = getClassDataLayout0(); + ClassDataSlot[] slots = getClassDataLayout0(); + dataLayout = new DataLayout(slots).slots; } return dataLayout; }