-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
None
-
tiger
-
x86, sparc
-
solaris_8, windows_xp
It seems to be impossible to get the XMLDecoder class to use a class loader
other than the default systemClassLoader when decoding an XML stream. I've
tested 2 methods to achieve this, both fail....
This is a major issue because it is not possible for example to load
packages into a system using the URLClassLoader and then use XMLDecoder to
instantiate objects contained in those packages.
The attached example demonstrates both attempts I've made to get XMLDecoder
to use a specific ClassLoader.
The code base attached includes a jar test.jar file which contains a simple
test.message class.
Running encode.sh will write a test.xml file representing an instance of
test.message
Running java decode will fail to load Decode the xml, putting test.jar
in the classpath will run java -cp test.jar:. decode
The sample code makes two attempts to use the Decoder. Both tests
create a URLClassLoader which references test.jar
In the first test an owner object is created which is actually the
class test.message which has been loaded by the URLClassLoader. I then
use this owner object as the owner of XMLDecoder.
In the second test I instantiate XMLDecoder using reflection. The XMLDecoder
class is loaded by URLClassLoader (which has the test.jar reference), but
it still fails to decode.
All tests were run with JDK 1.4.0-b92 on SPARC Solaris 9b58
- duplicates
-
JDK-4726427 Ability to specify ClassLoader to XMLDecoder.
- Closed
- relates to
-
JDK-6582164 JavaBeans tests should be open source
- Resolved