src/share/classes/java/sql/DriverManager.java

Print this page

        

*** 28,37 **** --- 28,38 ---- import java.util.Iterator; import java.util.ServiceLoader; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.concurrent.CopyOnWriteArrayList; + import sun.reflect.Reflection; /** * <P>The basic service for managing a set of JDBC drivers.<br> * <B>NOTE:</B> The {@link <code>DataSource</code>} interface, new in the
*** 460,469 **** --- 461,479 ---- } } //------------------------------------------------------------------------ + // 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) { boolean result = false; if(driver != null) {
*** 602,613 **** println("getConnection: no suitable driver found for "+ url); 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(); } /* * Wrapper class for registered Drivers in order to not expose Driver.equals() --- 612,621 ----