#35 XMLReaderFactory and classloader (2nd)

SAX_2.0
closed-duplicate
nobody
5
2002-01-29
2002-01-28
Anonymous
No

(Sorry, but previous submittal reported an error
and forgot about my patch - mnl@mnl.de)

I have run into a problem with your implementation of
XMLReaderFactory in the J2EE environment.

The problem is that your implementation uses
Class.forName. As I assume you certainly know, this is
not "up-to-date" (see
http://www.javageeks.com/Papers/ClassForName/ for details).

I therefore propose the following patch:

*** XMLReaderFactory.java.orig Thu Nov 15 20:26:47 2001
--- XMLReaderFactory.java Sat Jan 12 14:47:54 2002
***************
*** 113,119 ****
throws SAXException
{
try {
! return
(XMLReader)(Class.forName(className).newInstance());
} catch (ClassNotFoundException e1) {
throw new SAXException("SAX2 driver class " +
className +
" not found", e1);
--- 113,120 ----
throws SAXException
{
try {
! ClassLoader cl =
Thread.currentThread().getContextClassLoader();
! return
(XMLReader)cl.loadClass(className).newInstance();
} catch (ClassNotFoundException e1) {
throw new SAXException("SAX2 driver class " +
className +
" not found", e1);

Discussion

  • David Brownell
    David Brownell
    2002-01-29

    Logged In: YES
    user_id=44117

    This has been fixed in the sax2 r2pre2 and r2pre3
    releases for many months now. And in a way that
    doesn't impose an undesirable jdk 1.2 requirement.
    UPGRADE!

     
  • David Brownell
    David Brownell
    2002-01-29

    • status: open --> closed-duplicate