--- old/src/java.xml/share/classes/javax/xml/validation/SchemaFactoryFinder.java 2016-12-14 14:27:36.544997222 +0300
+++ new/src/java.xml/share/classes/javax/xml/validation/SchemaFactoryFinder.java 2016-12-14 14:27:36.452994954 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,7 @@
import java.util.Properties;
import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
+import java.util.function.Supplier;
/**
* Implementation of {@link SchemaFactory#newInstance(String)}.
@@ -72,11 +73,11 @@
/**
*
Conditional debug printing.
*
- * @param msg to print
+ * @param msgGen Supplier function that returns debug message
*/
- private static void debugPrintln(String msg) {
+ private static void debugPrintln(Supplier msgGen) {
if (debug) {
- System.err.println("JAXP: " + msg);
+ System.err.println("JAXP: " + msgGen.get());
}
}
@@ -106,7 +107,7 @@
private void debugDisplayClassLoader() {
try {
if( classLoader == ss.getContextClassLoader() ) {
- debugPrintln("using thread context class loader ("+classLoader+") for search");
+ debugPrintln(()->"using thread context class loader ("+classLoader+") for search");
return;
}
} catch( Throwable unused ) {
@@ -114,11 +115,11 @@
}
if( classLoader==ClassLoader.getSystemClassLoader() ) {
- debugPrintln("using system class loader ("+classLoader+") for search");
+ debugPrintln(()->"using system class loader ("+classLoader+") for search");
return;
}
- debugPrintln("using class loader ("+classLoader+") for search");
+ debugPrintln(()->"using class loader ("+classLoader+") for search");
}
/**
@@ -142,9 +143,9 @@
}
SchemaFactory f = _newFactory(schemaLanguage);
if (f != null) {
- debugPrintln("factory '" + f.getClass().getName() + "' was found for " + schemaLanguage);
+ debugPrintln(()->"factory '" + f.getClass().getName() + "' was found for " + schemaLanguage);
} else {
- debugPrintln("unable to find a factory for " + schemaLanguage);
+ debugPrintln(()->"unable to find a factory for " + schemaLanguage);
}
return f;
}
@@ -163,17 +164,17 @@
// system property look up
try {
- debugPrintln("Looking up system property '"+propertyName+"'" );
+ debugPrintln(()->"Looking up system property '"+propertyName+"'" );
String r = ss.getSystemProperty(propertyName);
if(r!=null) {
- debugPrintln("The value is '"+r+"'");
+ debugPrintln(()->"The value is '"+r+"'");
sf = createInstance(r, true);
if(sf!=null) return sf;
} else
- debugPrintln("The property is undefined.");
+ debugPrintln(()->"The property is undefined.");
} catch( Throwable t ) {
if( debug ) {
- debugPrintln("failed to look up system property '"+propertyName+"'" );
+ debugPrintln(()->"failed to look up system property '"+propertyName+"'" );
t.printStackTrace();
}
}
@@ -191,14 +192,14 @@
File f=new File( configFile );
firstTime = false;
if(ss.doesFileExist(f)){
- debugPrintln("Read properties file " + f);
+ debugPrintln(()->"Read properties file " + f);
cacheProps.load(ss.getFileInputStream(f));
}
}
}
}
final String factoryClassName = cacheProps.getProperty(propertyName);
- debugPrintln("found " + factoryClassName + " in $java.home/conf/jaxp.properties");
+ debugPrintln(()->"found " + factoryClassName + " in $java.home/conf/jaxp.properties");
if (factoryClassName != null) {
sf = createInstance(factoryClassName, true);
@@ -225,11 +226,11 @@
// platform default
if(schemaLanguage.equals("http://www.w3.org/2001/XMLSchema")) {
- debugPrintln("attempting to use the platform default XML Schema validator");
+ debugPrintln(()->"attempting to use the platform default XML Schema validator");
return createInstance("com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory", true);
}
- debugPrintln("all things were tried, but none was found. bailing out.");
+ debugPrintln(()->"all things were tried, but none was found. bailing out.");
return null;
}
@@ -280,15 +281,15 @@
SchemaFactory createInstance( String className, boolean useServicesMechanism ) {
SchemaFactory schemaFactory = null;
- debugPrintln("createInstance(" + className + ")");
+ debugPrintln(()->"createInstance(" + className + ")");
// get Class from className
Class> clazz = createClass(className);
if (clazz == null) {
- debugPrintln("failed to getClass(" + className + ")");
+ debugPrintln(()->"failed to getClass(" + className + ")");
return null;
}
- debugPrintln("loaded " + className + " from " + which(clazz));
+ debugPrintln(()->"loaded " + className + " from " + which(clazz));
// instantiate Class as a SchemaFactory
try {
@@ -303,19 +304,19 @@
schemaFactory = (SchemaFactory) clazz.newInstance();
}
} catch (ClassCastException classCastException) {
- debugPrintln("could not instantiate " + clazz.getName());
+ debugPrintln(()->"could not instantiate " + clazz.getName());
if (debug) {
classCastException.printStackTrace();
}
return null;
} catch (IllegalAccessException illegalAccessException) {
- debugPrintln("could not instantiate " + clazz.getName());
+ debugPrintln(()->"could not instantiate " + clazz.getName());
if (debug) {
illegalAccessException.printStackTrace();
}
return null;
} catch (InstantiationException instantiationException) {
- debugPrintln("could not instantiate " + clazz.getName());
+ debugPrintln(()->"could not instantiate " + clazz.getName());
if (debug) {
instantiationException.printStackTrace();
}