--- old/src/share/classes/java/sql/DriverManager.java Thu Jun 7 13:10:12 2012 +++ new/src/share/classes/java/sql/DriverManager.java Thu Jun 7 13:10:11 2012 @@ -30,6 +30,7 @@ import java.security.AccessController; import java.security.PrivilegedAction; import java.util.concurrent.CopyOnWriteArrayList; +import sun.reflect.Reflection; /** @@ -461,7 +462,16 @@ } //------------------------------------------------------------------------ + + // Internal method used to get the caller's class loader. + // Replaces the call to the native method + private static ClassLoader getCallerClassLoader() { + Class cc = Reflection.getCallerClass(3); + ClassLoader cl = cc != null ? cc.getClassLoader() : null; + return cl; + } + // Indicates whether the class object that would be created if the code calling // DriverManager is accessible. private static boolean isDriverAllowed(Driver driver, ClassLoader classLoader) { @@ -604,8 +614,6 @@ throw new SQLException("No suitable driver found for "+ url, "08001"); } - /* Returns the caller's class loader, or null if none */ - private static native ClassLoader getCallerClassLoader(); }