Hello,
I'm trying to send objects from bundles over a dedicated communication bundle to an other framework. For communication I use Java standard serialization (with ObjectStreams) over TCP/IP.
Communication flow is the following: A sender-bundle will pass serializable objects to a transmit-sender which will serialize the objects and send them via TCP/IP to a transmit-receiver. The receiver will then deserialize the received objects and pass them to the receiver-bundle.
As the OSGi classloading architecture is different than the native one, I have to make a littel hack with the classloader: As I assume that the receiver-bundle should know the classes which he receives (= has them imported or otherwise accessible by its classloader), I use the classloader of the receiver instead of the transmit-receiver to load the class. (Via the Bundle.loadClass(..) method). This works fine for custom classes, however, this does not work for arrays of custom types. (Which are not known to the transmit-receiver classloader but to the receiver-bundle.)
Edit: ObjectInputStream.readObject(...) throws an ClassNotFoundException, if It tries to deserialize an array. (I assume that this exception origins in the Bundle.loadClass(...) method of the receiver-bundle. )
It does work with java.util.List or other Serializable classes. It also works for custom types which contains fields of other custom types as long as they are not arrays.
So the question is: Is there any difference in the way arrays are de/serialized? Or are they loaded differently?