RFR: 8344365: SecurityManager cleanups in java.sql and java.sql.rowset modules

Eirik Bjørsnøs eirbjo at openjdk.org
Sun Nov 17 19:53:56 UTC 2024


Please review this PR which cleans up SecurityManager-related code in `java.sql` and `java.sql.rowset` modules post JEP-486

There are quite a few changes to review, but all relatively straightforward:

`DriverManager`
* Remove `SecurityManager::checkPermission` calls in the `setLogWriter`, `setLogStream` and `deregisterDriver` methods
* Remove two now-unused package private SQLPermission constants
* `ensureDriversInitialized` is updated to remove `AccessController::doPrivileged` when reading a system property and when initializing drivers

`CachedRowSetImpl`
*  Remove `AccessController::doPrivileged` when getting a `SyncFactory` instance
* `getObject` is update to remove a call to `ReflectUtil::checkPackageAccess`


`SerialJavaObject`
*  `getFields` is updated to remove call to `ReflectUtil::checkPackageAccess`. `@CallerSensitive` is no longer needed for this method.

`SyncFactory`
* `initMapIfNecessary` is updated to remove call to `AccessController::doPrivileged` when reading system properties and when reading properties from an input stream
* `getInstance` is updated to remove calls to `ReflectUtil::checkPackageAccess`
* `setLogger` method is updated to remove call to `SecurityManager::checkPermission`
* `setJNDIContext` methods are updated to remove call to `SecurityManager::checkPermission`

`RowsetProvider`
*  Static initializer is updated to call `System::getProperty` directly
* `newFactory` is updated to call `System::getProperty` directly
* `newFactory` is updated to not call `ReflectUtil.checkPackageAccess`
* `getContextClassLoader` is updated to not call `AccessController::doPrivileged`
* `getFactoryClass` is updated to not call `ReflectUtil.checkPackageAccess`
* `getSystemProperty` is removed


`SQLInputImpl`
*  A call to `ReflectUtil::checkPackageAccess` is removed

`XmlReaderContentHandler::endElement`
* Replace `ReflectUtil.forName` with `Class::forName`

 `TestPolicy.java` in `test/java/sql/testng/util`
* This  is now unused and removed

Ran `test/jdk/java/sql` and `test/jdk/javax/sql` tests locally. GHA results pending.

-------------

Commit messages:
 - Remove unused class TestPolicy from test/java/sql/testng/util
 - Remove unused SQLPermission constants
 - Update copyright
 - Remove calls to ReflectUtil.checkPackageAccess
 - Inline call to Class.forName
 - Remove call to ReflectUtil::checkPackageAccess
 - Remove @SuppressWarnings("removal")
 - SecurityManager-related cleanups for java.sql and java.sql.rowset

Changes: https://git.openjdk.org/jdk/pull/22185/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=22185&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8344365
  Stats: 403 lines in 9 files changed: 10 ins; 349 del; 44 mod
  Patch: https://git.openjdk.org/jdk/pull/22185.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/22185/head:pull/22185

PR: https://git.openjdk.org/jdk/pull/22185


More information about the core-libs-dev mailing list