On Wed, 1 Jul 2026 23:26:50 GMT, Chen Liang <[email protected]> wrote:

> Make sure object-writing serialization fails for "strict in serializable 
> super". We currently already fail when they are deserialized.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

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

> 358:         // Note: AVC with no strict instance field like java.lang.Number 
> is allowed;
> 359:         // non-serializable superclasses are allowed because their 
> constructors are called
> 360:         requiresDeserializer = serializable && 
> (ValueClass.isConcreteValueClass(cl) || 
> ValueClass.hasStrictInstanceField(cl));

This looks the right test.  You might want to expand "AVC" comment as anyone 
reading this might not know it means abstract value class.

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

> 397:                     if (deserializer == null) {
> 398:                         serializeEx = deserializeEx = new 
> ExceptionInfo(cl.getName(),
> 399:                                 "cannot serialize due to concrete value 
> class or strict instance fields");

Having "concrete" in the exception message might be confusing, I think it would 
be okay to reduce it to "value class" here.

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

PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2612#discussion_r3512456868
PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2612#discussion_r3512470975

Reply via email to