JDK-8145104 : NPE is thrown when JAXBContextFactory implementation is specified in system property
  • Type: Bug
  • Component: xml
  • Sub-Component: jaxb
  • Affected Version: 9
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2015-12-10
  • Updated: 2017-05-10
  • Resolved: 2016-01-29
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b104Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
Let's consider the code below:

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBContextFactory;
import javax.xml.bind.JAXBException;
import java.util.Map;

public class Test3 {
    public static class Factory implements JAXBContextFactory {
        @Override
        public JAXBContext createContext(Class<?>[] classesToBeBound, Map<String, ?> properties) throws JAXBException {
            throw new Error();
        }

        @Override
        public JAXBContext createContext(String contextPath, ClassLoader classLoader, Map<String, ?> properties)
                throws JAXBException {
            throw new Error();
        }
    }
    public static void main(String[] args) throws JAXBException {
        System.setProperty(JAXBContext.JAXB_CONTEXT_FACTORY, "Test3$Factory");
        try {
            JAXBContext.newInstance(Test3.class);
        } catch (Throwable t) {
            t.printStackTrace();
        }
    }
}

This code produces following stack trace when being run on JDKb94:

java.lang.NullPointerException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:520)
	at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:258)
	at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:249)
	at javax.xml.bind.ContextFinder.find(ContextFinder.java:355)
	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:662)
	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:606)
	at Test3.main(Test3.java:29)
Comments
The issue would be updated after it is available in the promoted build (I suppose it should be b104)
03-02-2016

Could you please provide information which promoted JDK build contains this fix. Now "Resolved in Build" contains 'team'.
02-02-2016