RFR: 8313961: Enhance identification of special serialization methods [v2]

ExE Boss duke at openjdk.org
Mon Aug 21 16:22:31 UTC 2023


On Mon, 21 Aug 2023 16:04:49 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:

>> This improves the identification of the serialization magic fields and methods.
>
> Raffaello Giulietti has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Removed a spurious, unintended file.

src/java.base/share/classes/java/io/ObjectStreamClass.java line 1670:

> 1668:         ObjectStreamField[] serialPersistentFields = null;
> 1669:         try {
> 1670:             Field f = getDeclaredField(cl, ObjectStreamField[].class, "serialPersistentFields");

This can technically be a breaking change, as it was supported for the field to have a declared type that is assignable from `ObjectStreamField[]`, as long as it held an `ObjectStreamField[]` instance at runtime, even if it wasn’t officially supported.


class Example implements Serializable {
	// This used to work before this patch in OpenJDK
	private static final Object serialPersistentFields = new ObjectStreamField[] {
		// ...
	};

	// ...
}

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/15364#discussion_r1300341941


More information about the build-dev mailing list