: I tried initializing the cache in the constructor, but then the test case 
: failed with a null pointer exception on the first synchronized(cache) .
: Very strange, this seems to be a bug in the implementation of java 
: serialisation. The cache variable is transient, so it should not be affected
: at all by serialisation, but it appears to be affected nonetheless.

Ahhh... that actally makes a lot of sense.  transient fields won't be 
saved/restored in serialization, so initing only in the constructor isn't 
good enough, after it's been serialized it will be null.

: I had a quick look at the java serialisation spec, and iirc it was
: also mentioned that one might use a final variable initialized in
: the constructor. I did not try that (final transient cache), i preferred

I can't even fathom what it would mean to be both final and transient ... 
they seem diametricaly opposed to me (but it doesn't generate a compiler 
warning, so it must mean something)



-Hoss


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to