JDK-4726427 : Ability to specify ClassLoader to XMLDecoder.
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2002-08-05
  • Updated: 2002-08-08
  • Resolved: 2002-08-08
Related Reports
Duplicate :  
Description

Name: gm110360			Date: 08/05/2002


FULL PRODUCT VERSION :
java version "1.4.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)


FULL OPERATING SYSTEM VERSION :
Microsoft Windows XP [Version 5.1.2600]

ADDITIONAL OPERATING SYSTEMS :
Generic feature, not relating to OS.


A DESCRIPTION OF THE PROBLEM :
There is no way to specify how classes are to be loaded
when decoding an xml-format. Instead (this can be
determined by code-inspection only) the
Thread.getContextClassLoader() is used. This is not
flexible enough for some situations. As a concrete example
an EJB can not set the contextClassLoader and therefor can
only used the class-loader set by the application-server.
I'm sure there are other examples as well.

My suggestion is to add a constructor for XMLDecoder that
takes a ClassLoader as a parameter and the instance will
use this ClassLoader to load all classes for the JavaBean
to be decoded.

REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER WORKAROUND :
The current work-around is to set the contextClassLoader
when decoding do that every time one is decoding a
JavaBean.
(Review ID: 159375) 
======================================================================

Comments
EVALUATION This is a duplicate of 4676532. I'll consider specifying the classloader as an argument to the constructor. java.beans.Statement is the class that uses the classloader and it wouldn't be good idea to declare a static reference to the classloader. ###@###.### 2002-08-08
08-08-2002