classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] RFC: Patch for duplicate entries in serialPersistentFie


From: Mark Wielaard
Subject: Re: [cp-patches] RFC: Patch for duplicate entries in serialPersistentFields
Date: Sun, 11 Dec 2005 16:27:06 +0100

On Sat, 2005-12-10 at 20:16 +0100, Guilhem Lavaux wrote:
> Hi,
> 
> Here is a patch which (partially) fix a regression in kaffe. If you 
> define a class like that:
> 
> class A
> {
> private static final ObjectStreamField[] serialPersistentFields =
>                  {
>                       new ObjectStreamField("i", int.class),
>                       new ObjectStreamField("i", int.class)
>               };
> 
> /* ... */
> };
> 
> then the JDK throws an InvalidClassException in ObjectStreamClass.lookup.
> This goes against the API. However it is true that we must take into 
> account the presence of duplicate fields. So I propose we throw an 
> InvalidClassException on writing the object if this sort of situation 
> happens.

Why not do similar and throw the InvalidClassException from
ObjectStreamClass.lookup()?
(But then document that clearly in our version of course.)

If you do like in your patch then at least document this behavior. It is
slightly confusing that ObjectStreamClass.lookup() returns a non-null
result, but getFields() suddenly returns an empty ObjectStreamField
array as if there are no Serializable fields. Now user code has no real
way to check whether that is because the ObjectStreamClass is invalid
(because of bogus serialPersistentFields) or because it just has no
serializable fields.

Cheers,

Mark

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]