DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21686>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21686 TransletLoader generates a NPE if current thread context's class loader is null Summary: TransletLoader generates a NPE if current thread context's class loader is null Product: XalanJ2 Version: 2.5 Platform: All OS/Version: Windows NT/2K Status: NEW Severity: Normal Priority: Other Component: org.apache.xalan.xsltc AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] This is a fairly simple bug in the No Check For Null pattern. The current version of org.apache.xalan.xsltc.runtime.TransletLoader (Xalan 2.5.1) has the following code in it's constructor (around line 95): ------ ClassLoader loader = Thread.currentThread().getContextClassLoader(); // Following line can cause NPE final String loaderName = loader.getClass().getName(); if (loaderName.equals("sun.misc.Launcher$ExtClassLoader")) { loader = ClassLoader.getSystemClassLoader(); } ------ The variable 'loader' can have value null - because according to Sun, "Some implementations may use null to represent the bootstrap class loader." - see: http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Class.html#getClassLoader() Using Sun's J2SE v.1.4.2 on W2K (which does appear to use null to represent the bootstrap class loader) this does indeed cause an NPE. The correct code should be: ------ ClassLoader loader = Thread.currentThread().getContextClassLoader(); if (loader == null || loader.getClass().getName().equals("sun.misc.Launcher$ExtClassLoader")) { loader = ClassLoader.getSystemClassLoader(); } ------ I'll submit this patch to [EMAIL PROTECTED] . cheers, Roberto
