[kaffe] java.io.ObjectInputStream: final field cannot be restored
Guilhem Lavaux
guilhem.lavaux at free.fr
Wed Mar 24 03:34:02 PST 2004
Guilhem Lavaux wrote:
> Ito Kazumitsu wrote:
>
>> Hi,
>
>
> Hi Ito !
>
>>
>> Interested in Prevayler (http://www.prevayler.org/), which is
>> marked untested in our "Compatibility - Application Testing",
>> I tried it.
>>
>> The result was unsatisfactory. The simplest demo of Prevayler
>> cannot run on kaffe. After studying the cause of the error,
>> I found something buggy in java.io.ObjectInputStream.
>>
>> My test program is attaced below. The test shows that a
>> field that is marked "final" cannot be restored by
>> java.io.ObjectInputStream#readObject.
>>
>
> This is linked to ObjectStreamField.java:67
>
> toset = !Modifier.isFinal(field.getModifiers());
>
> I guess it was placed there for a good reason but I don't remember which
> one. We have to check in the spec again.
>
The reason was quite evident... you can't set a final variable. It's
rather someone sets (or doesn't set) A to the right value when it is
initializing a new instance using readObject().
Cheers,
Guilhem.
More information about the kaffe
mailing list