JDK-6369399 : (cl) REGRESSION: NPE exception throws when invoked from a JNI callback thread
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang:class_loading
  • Affected Version: 6
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux,windows_xp
  • CPU: x86
  • Submitted: 2006-01-06
  • Updated: 2012-10-08
  • Resolved: 2006-06-09
Related Reports
Duplicate :  
J2SE Version (please include all output from java -version flag):

  java version "1.6.0-rc"
  Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-rc-b65)
  Java HotSpot(TM) Client VM (build 1.6.0-rc-b65, mixed mode, sharing)

Does this problem occur on J2SE 1.4.x or 5.0.x ?  Yes / No (pick one)

  Not in 1.5

Operating System Configuration Information (be specific):

  Windows XP SP2

Hardware Configuration Information (be specific):

  Processor	x86 Family 15 Model 2 Stepping 4 GenuineIntel ~2545 Mhz
  BIOS Version/Date	Award Software International, Inc. 6.00 PG, 19/08/2002
 1GB memory

Bug Description:

  DocumentBuilderFactory.newInstance() fails with "javax.xml.parsers.FactoryConfigurationError:
  Provider com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl could not be
  instantiated: java.lang.NullPointerException" when invoked from a JNI callback thread that
  has been correctly attached to the VM. Worked in 1.5.

  The stack-trace for the NullPointerException isn't available.

  Not sure at what point in the Mustang cycle this bug was introduced as I've only just 
  tried the application using it.

Steps to Reproduce (be specific):

  Not easy to include stuff for this JNI application.

more information from the submitter:

it appears that the NullPointerException is being 
generated because the (JNI) Thread doesn't have a "contextClassLoader" 
defined for it.

in javax.xml.parsers.FactoryFinder we end up in the "newInstance" method 
with parameter "cl" set to null (this is due to the calling method "find" 
"classLoader = FactoryFinder.class.getClassLoader();" to get the classloader 
and this returning "null", which apparently can mean "bootstrap class 

"newInstance" then goes ahead and calls ss.getContextClassLoader() which 
gets the Thread's contextClassLoader which is "null". The code then fails on 
the subsequent line attempting "cl.cloadClass(className);

    static Object newInstance(String className, ClassLoader cl,
        boolean doFallback)
        throws ConfigurationError
        // assert(className != null);
        try {
            Class providerClass;
            if (cl == null) {
            // If classloader is null get the context class loader
            cl = ss.getContextClassLoader();
            providerClass = cl.loadClass(className);

EVALUATION This is a duplicate of 6350682.