--- a/src/java.xml/share/classes/javax/xml/validation/SchemaFactoryFinder.java Mon Sep 25 19:44:28 2017 +0530
+++ b/src/java.xml/share/classes/javax/xml/validation/SchemaFactoryFinder.java Wed Oct 04 10:33:08 2017 -0700
@@ -25,6 +25,7 @@
package javax.xml.validation;
+import com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -167,7 +168,7 @@
String r = SecuritySupport.getSystemProperty(propertyName);
if(r!=null) {
debugPrintln(()->"The value is '"+r+"'");
- sf = createInstance(r, true);
+ sf = createInstance(r);
if(sf!=null) return sf;
} else
debugPrintln(()->"The property is undefined.");
@@ -201,7 +202,7 @@
debugPrintln(()->"found " + factoryClassName + " in $java.home/conf/jaxp.properties");
if (factoryClassName != null) {
- sf = createInstance(factoryClassName, true);
+ sf = createInstance(factoryClassName);
if(sf != null){
return sf;
}
@@ -226,7 +227,7 @@
// platform default
if(schemaLanguage.equals("http://www.w3.org/2001/XMLSchema")) {
debugPrintln(()->"attempting to use the platform default XML Schema validator");
- return createInstance("com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory", true);
+ return new XMLSchemaFactory();
}
debugPrintln(()->"all things were tried, but none was found. bailing out.");
@@ -273,11 +274,7 @@
* @return null
* if it fails. Error messages will be printed by this method.
*/
- SchemaFactory createInstance( String className ) {
- return createInstance( className, false );
- }
-
- SchemaFactory createInstance( String className, boolean useServicesMechanism ) {
+ SchemaFactory createInstance(String className) {
SchemaFactory schemaFactory = null;
debugPrintln(()->"createInstance(" + className + ")");
@@ -296,12 +293,7 @@
throw new ClassCastException(clazz.getName()
+ " cannot be cast to " + SchemaFactory.class);
}
- if (!useServicesMechanism) {
- schemaFactory = newInstanceNoServiceLoader(clazz);
- }
- if (schemaFactory == null) {
- schemaFactory = (SchemaFactory) clazz.getConstructor().newInstance();
- }
+ schemaFactory = (SchemaFactory) clazz.getConstructor().newInstance();
} catch (ClassCastException | IllegalAccessException | IllegalArgumentException |
InstantiationException | InvocationTargetException | NoSuchMethodException |
SecurityException ex) {
@@ -315,50 +307,6 @@
return schemaFactory;
}
- /**
- * Try to construct using newXMLSchemaFactoryNoServiceLoader
- * method if available.
- */
- private static SchemaFactory newInstanceNoServiceLoader(
- Class<?> providerClass
- ) {
- // Retain maximum compatibility if no security manager.
- if (System.getSecurityManager() == null) {
- return null;
- }
- try {
- final Method creationMethod =
- providerClass.getDeclaredMethod(
- "newXMLSchemaFactoryNoServiceLoader"
- );
- final int modifiers = creationMethod.getModifiers();
-
- // Do not call the method if it's not public static.
- if (!Modifier.isStatic(modifiers) || !Modifier.isPublic(modifiers)) {
- return null;
- }
-
- // Only calls "newXMLSchemaFactoryNoServiceLoader" if it's
- // declared to return an instance of SchemaFactory.
- final Class<?> returnType = creationMethod.getReturnType();
- if (SERVICE_CLASS.isAssignableFrom(returnType)) {
- return SERVICE_CLASS.cast(creationMethod.invoke(null, (Object[])null));
- } else {
- // Should not happen since
- // XMLSchemaFactory.newXMLSchemaFactoryNoServiceLoader is
- // declared to return XMLSchemaFactory.
- throw new ClassCastException(returnType
- + " cannot be cast to " + SERVICE_CLASS);
- }
- } catch(ClassCastException e) {
- throw new SchemaFactoryConfigurationError(e.getMessage(), e);
- } catch (NoSuchMethodException exc) {
- return null;
- } catch (Exception exc) {
- return null;
- }
- }
-
// Call isSchemaLanguageSupported with initial context.
private boolean isSchemaLanguageSupportedBy(final SchemaFactory factory,
final String schemaLanguage,