2007-01-08

Workaround for ClassCastException due to different classloaders.

This I found as a workaround for a ClassCastException I had problems with, when I did not want to mess with Classloaders. I can't take credit for it, as I did not write, think, implement, or in any other way contribute to this. I found it here, by John Davison!

ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream( baos );
oos.writeObject( c2 );

ByteArrayInputStream bais = new ByteArrayInputStream(
baos.toByteArray() );
ObjectInputStream ois = new ObjectInputStream( bais );
FooBar newC2 = (FooBar) ois.readObject();

2007-01-04


I matsalen på jobbet...
Ingen på jobbet trodde det gick att blogga så smidigt, så detta gjorde jag när vi satt och åt.