-
Bug
-
Resolution: Fixed
-
P4
-
22, 23
-
b06
-
generic
-
generic
After JDK-8306055, when anyone attempts to (reflectively) load an XML class that has a dependency on jdk.xml.internal.JdkXmlUtils, for example XMLDocumentFragmentScannerImpl, then a NPE is being thrown and the class initializer of the class fails.
In other words, a class load order constraint has been introduced withJDK-8306055. If jdk.xml.internal.JdkXmlUtils is loaded first and XMLDocumentFragmentScannerImpl second, class loading passes. If XMLDocumentFragmentScannerImpl is loaded first and JdkXmlUtils second class loading fails.
Simple reproducer:
echo 'new com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl()' | ./bin/jshell -J-showversion --add-exports java.xml/com.sun.org.apache.xerces.internal.impl=ALL-UNNAMED -
openjdk version "23-internal" 2024-09-17
OpenJDK Runtime Environment (build 23-internal-adhoc.sgehwolf.jdk-jdk)
OpenJDK 64-Bit Server VM (build 23-internal-adhoc.sgehwolf.jdk-jdk, mixed mode, sharing)
Exception java.lang.ExceptionInInitializerError
at XMLDocumentFragmentScannerImpl.<clinit> (XMLDocumentFragmentScannerImpl.java:193)
at (#1:1)
Caused by: java.lang.NullPointerException: Cannot invoke "[Ljava.lang.String;.clone()" because "com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.RECOGNIZED_PROPERTIES" is null
at XMLDocumentFragmentScannerImpl.getRecognizedProperties (XMLDocumentFragmentScannerImpl.java:764)
at XMLDocumentScannerImpl.getRecognizedProperties (XMLDocumentScannerImpl.java:449)
at XML11Configuration.addRecognizedParamsAndSetDefaults (XML11Configuration.java:1518)
at XML11Configuration.addComponent (XML11Configuration.java:1462)
at XML11Configuration.<init> (XML11Configuration.java:612)
at XIncludeAwareParserConfiguration.<init> (XIncludeAwareParserConfiguration.java:136)
at XIncludeAwareParserConfiguration.<init> (XIncludeAwareParserConfiguration.java:93)
at SAXParser.<init> (SAXParser.java:121)
at SAXParserImpl$JAXPSAXParser.<init> (SAXParserImpl.java:405)
at SAXParserImpl.<init> (SAXParserImpl.java:137)
at SAXParserImpl.<init> (SAXParserImpl.java:124)
at SAXParserFactoryImpl.newSAXParserImpl (SAXParserFactoryImpl.java:104)
at SAXParserFactoryImpl.setFeature (SAXParserFactoryImpl.java:144)
at CatalogImpl.getParser (CatalogImpl.java:312)
at CatalogImpl.parse (CatalogImpl.java:290)
at CatalogImpl.load (CatalogImpl.java:171)
at CatalogManager.catalog (CatalogManager.java:73)
at JdkCatalog.init (JdkCatalog.java:43)
at XMLSecurityManager.prepareCatalog (XMLSecurityManager.java:305)
at XMLSecurityManager.<init> (XMLSecurityManager.java:290)
at SAXParserFactoryImpl.<init> (SAXParserFactoryImpl.java:72)
at JdkXmlUtils.getSAXFactory (JdkXmlUtils.java:441)
at JdkXmlUtils.<clinit> (JdkXmlUtils.java:97)
...
Expected behaviour:
Class initializer passes (no NPE being thrown).
Actual behaviour:
java.lang.ExceptionInInitializerError is being thrown, caused by an NPE during a clone() operation.
When JdkXmlUtils is being loaded first this works
Additional info:
This used to work with JDK 21.
echo 'new com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl()' | ./bin/jshell -J-showversion --add-exports java.xml/com.sun.org.apache.xerces.internal.impl=ALL-UNNAMED -
openjdk version "21.0.1" 2023-10-17
OpenJDK Runtime Environment (Red_Hat-21.0.1.0.12-4) (build 21.0.1+12)
OpenJDK 64-Bit Server VM (Red_Hat-21.0.1.0.12-4) (build 21.0.1+12, mixed mode, sharing)
<no exception>
In other words, a class load order constraint has been introduced with
Simple reproducer:
echo 'new com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl()' | ./bin/jshell -J-showversion --add-exports java.xml/com.sun.org.apache.xerces.internal.impl=ALL-UNNAMED -
openjdk version "23-internal" 2024-09-17
OpenJDK Runtime Environment (build 23-internal-adhoc.sgehwolf.jdk-jdk)
OpenJDK 64-Bit Server VM (build 23-internal-adhoc.sgehwolf.jdk-jdk, mixed mode, sharing)
Exception java.lang.ExceptionInInitializerError
at XMLDocumentFragmentScannerImpl.<clinit> (XMLDocumentFragmentScannerImpl.java:193)
at (#1:1)
Caused by: java.lang.NullPointerException: Cannot invoke "[Ljava.lang.String;.clone()" because "com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.RECOGNIZED_PROPERTIES" is null
at XMLDocumentFragmentScannerImpl.getRecognizedProperties (XMLDocumentFragmentScannerImpl.java:764)
at XMLDocumentScannerImpl.getRecognizedProperties (XMLDocumentScannerImpl.java:449)
at XML11Configuration.addRecognizedParamsAndSetDefaults (XML11Configuration.java:1518)
at XML11Configuration.addComponent (XML11Configuration.java:1462)
at XML11Configuration.<init> (XML11Configuration.java:612)
at XIncludeAwareParserConfiguration.<init> (XIncludeAwareParserConfiguration.java:136)
at XIncludeAwareParserConfiguration.<init> (XIncludeAwareParserConfiguration.java:93)
at SAXParser.<init> (SAXParser.java:121)
at SAXParserImpl$JAXPSAXParser.<init> (SAXParserImpl.java:405)
at SAXParserImpl.<init> (SAXParserImpl.java:137)
at SAXParserImpl.<init> (SAXParserImpl.java:124)
at SAXParserFactoryImpl.newSAXParserImpl (SAXParserFactoryImpl.java:104)
at SAXParserFactoryImpl.setFeature (SAXParserFactoryImpl.java:144)
at CatalogImpl.getParser (CatalogImpl.java:312)
at CatalogImpl.parse (CatalogImpl.java:290)
at CatalogImpl.load (CatalogImpl.java:171)
at CatalogManager.catalog (CatalogManager.java:73)
at JdkCatalog.init (JdkCatalog.java:43)
at XMLSecurityManager.prepareCatalog (XMLSecurityManager.java:305)
at XMLSecurityManager.<init> (XMLSecurityManager.java:290)
at SAXParserFactoryImpl.<init> (SAXParserFactoryImpl.java:72)
at JdkXmlUtils.getSAXFactory (JdkXmlUtils.java:441)
at JdkXmlUtils.<clinit> (JdkXmlUtils.java:97)
...
Expected behaviour:
Class initializer passes (no NPE being thrown).
Actual behaviour:
java.lang.ExceptionInInitializerError is being thrown, caused by an NPE during a clone() operation.
When JdkXmlUtils is being loaded first this works
Additional info:
This used to work with JDK 21.
echo 'new com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl()' | ./bin/jshell -J-showversion --add-exports java.xml/com.sun.org.apache.xerces.internal.impl=ALL-UNNAMED -
openjdk version "21.0.1" 2023-10-17
OpenJDK Runtime Environment (Red_Hat-21.0.1.0.12-4) (build 21.0.1+12)
OpenJDK 64-Bit Server VM (Red_Hat-21.0.1.0.12-4) (build 21.0.1+12, mixed mode, sharing)
<no exception>
- relates to
-
JDK-8306055 Add a built-in Catalog to JDK XML module
-
- Resolved
-
- links to
-
Commit(master) openjdk/jdk/e6902cfc
-
Review(master) openjdk/jdk/22803