Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Blocker
-
Resolution: Unresolved
-
Affects Version/s: 1.0.2, 1.1.1
-
Fix Version/s: None
-
Component/s: XML
-
Labels:None
-
Environment:JDK 1.6.0 and above
-
Number of attachments :
Description
Due to a bug which has appeared in JDK 1.6.0 release (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6434149)
Java will bug while trying to use the 'loadClass' method of the ClassLoader Class on an array classname
("[..." : e.g. "[I" array of int).
So it's NOT a bug of Castor per se but can be blocking until the problem is fixed in the JDK/JRE. Until then, the fix at the Castor's
codebase level is the following (file : castor-X.Y.Z/src/main/java/org/exolab/castor/xml/UnmarshalHandler.java)
/**
- Loads and returns the class with the given class name using the
- given loader.
- @param className the name of the class to load
- @param loader the ClassLoader to use, this may be null.
- *********************************************************************
- PATCH : C.Assemat - 11/05/2007 due to the bug of loadClass in JDK 1.6
- *********************************************************************
**/
private Class loadClass(String className, ClassLoader loader)
throws ClassNotFoundException
{ // -- patch only if jdk 1.6 AND 'array class' if ( className.startsWith("[") ) return Class.forName(className); //-- use passed in loader else if ( loader != null ) return loader.loadClass(className); //-- use internal loader else if (_loader != null) return _loader.loadClass(className); //-- no loader available use Class.forName return Class.forName(className); }//-- loadClass
I am not sure that is the right fix, as it basically switches to another way of loading a class for all arrays. Rather than doing this, I'd limit the use of this scenario to JDK 6.0 only. And even if that's possible, I wonder how I woudl distinguish between scenarios where a Java 6 JVM has the bug and another one does not.