JDK-8211295 : DriverManager::getConnection fails to find driver if it's called from JDBC RowSet
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.sql
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2018-09-29
  • Updated: 2019-05-16
  • Resolved: 2018-10-01
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 12
11.0.3-oracleFixed 12 b14Fixed
Description
See [1] for the test case reproducing the failure.

java.sql and java.sql.rowset were deprivileged in JDK 9 and loaded by the platform class loader.  They were loaded by the bootstrap class loader in JDK 8 where DriverManager::getConnection special cases if the caller loader is null (bootstrap class loader), then it will use TCCL.

[1] http://mail.openjdk.java.net/pipermail/core-libs-dev/2018-September/055755.html
Comments
Fix Request Our customer who migrate from Java8 to Java11u may hit this problem. Risk can be minimum. The patch applied cleanly. (I'm not familiar with this process, please let me know if something is wrong.)
12-02-2019

Fix has been sent out for external review
01-10-2018

I think a long-term fix is remove @CallerSensitive from DriverManager and the API should specify to use TCCL (see JDK-8154346) An interim fix may be: In the getConnection(String url, java.util.Properties info, Class<?> caller) method, special case for both bootstrap class loader and platform class loader as follows: if (callerCL == null || callerCL == ClassLoader.getPlatformClassLoader()) { callerCL = Thread.currentThread().getContextClassLoader(); }
29-09-2018