Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 1.2.2, 1.3
-
Fix Version/s: 1.4
-
Component/s: Converters
-
Labels:None
Description
Because PureJavaReflectionProvider.instantiateUsingSerialization uses ObjectInputStream to unmarshal objects without a no-argument constructor, it fails when the process happens in OSGi, where the ObjectInputStream class lives in one classloader, but the target class lives in another. This is because Class.forName ignores the contextClassLoader, and uses the caller class' classloader instead. This is really a JDK bug, but since we cannot expect a quick resolution of this problem at the JDK level, a workaround should be used in XStream.
Hi Denis, so what should we do instead? AFAICS there's no possibility to pass the classloader to use into the ObjectInputStream. The situation only happens when the type itself has no default ctor i.e. in consequence we do not have a possibility to recreate such an object anymore. XStream cannot implement a workaround, it was alreaday the workaround. It is limited to the JDK level here.