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)
- duplicates
-
JDK-8146360 Deprecated loader mechanism (step 4) fails to load factory implementing JAXBContextFactory (NPE)
-
- Closed
-
-
JDK-8145111 NPE is thrown when JAXBContextFactory implementation is specified by jaxb.properties file
-
- Closed
-
-
JDK-8146360 Deprecated loader mechanism (step 4) fails to load factory implementing JAXBContextFactory (NPE)
-
- Closed
-
- relates to
-
JDK-8148626 URI.toURL needs to use protocol Handler to parse file URIs
-
- Resolved
-
-
JDK-8150173 JAXBContext.newInstance causes PrivilegedActionException when createContext's declared in abstract class extended by discovered JAXB implementation
-
- Closed
-