jaxp/src/java.xml/share/classes/javax/xml/transform/FactoryFinder.java
changeset 42806 35843e3d5ef1
parent 27574 2e8afdf5c6fb
child 45853 bfa06be36a17
--- a/jaxp/src/java.xml/share/classes/javax/xml/transform/FactoryFinder.java	Mon Dec 19 11:13:32 2016 +0800
+++ b/jaxp/src/java.xml/share/classes/javax/xml/transform/FactoryFinder.java	Mon Dec 19 18:45:58 2016 +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;
 
 /**
  * <p>Implements pluggable Datatypes.</p>
@@ -83,9 +84,9 @@
         }
     }
 
-    private static void dPrint(String msg) {
+    private static void dPrint(Supplier<String> msgGen) {
         if (debug) {
-            System.err.println("JAXP: " + msg);
+            System.err.println("JAXP: " + msgGen.get());
         }
     }
 
@@ -177,10 +178,9 @@
             if (instance == null) {
                 instance = providerClass.newInstance();
             }
-            if (debug) {    // Extra check to avoid computing cl strings
-                dPrint("created new instance of " + providerClass +
-                       " using ClassLoader: " + cl);
-            }
+            final ClassLoader clD = cl;
+            dPrint(()->"created new instance of " + providerClass +
+                       " using ClassLoader: " + clD);
             return type.cast(instance);
         }
         catch (ClassNotFoundException x) {
@@ -255,12 +255,12 @@
 
         final String factoryId = type.getName();
 
-        dPrint("find factoryId =" + factoryId);
+        dPrint(()->"find factoryId =" + factoryId);
         // Use the system property first
         try {
             String systemProp = ss.getSystemProperty(factoryId);
             if (systemProp != null) {
-                dPrint("found system property, value=" + systemProp);
+                dPrint(()->"found system property, value=" + systemProp);
                 return newInstance(type, systemProp, null, true, true);
             }
         }
@@ -278,7 +278,7 @@
                         File f = new File(configFile);
                         firstTime = false;
                         if (ss.doesFileExist(f)) {
-                            dPrint("Read properties file "+f);
+                            dPrint(()->"Read properties file "+f);
                             cacheProps.load(ss.getFileInputStream(f));
                         }
                     }
@@ -287,7 +287,7 @@
             final String factoryClassName = cacheProps.getProperty(factoryId);
 
             if (factoryClassName != null) {
-                dPrint("found in ${java.home}/conf/jaxp.properties, value=" + factoryClassName);
+                dPrint(()->"found in ${java.home}/conf/jaxp.properties, value=" + factoryClassName);
                 return newInstance(type, factoryClassName, null, true, true);
             }
         }
@@ -305,7 +305,7 @@
                 "Provider for " + factoryId + " cannot be found");
         }
 
-        dPrint("loaded from fallback value: " + fallbackClassName);
+        dPrint(()->"loaded from fallback value: " + fallbackClassName);
         return newInstance(type, fallbackClassName, null, true, true);
     }