RFR: 8178966: Don't swallow early bootstrap exceptions in Boolean.getBoolean, Integer.getInteger and Long.getLong

Eirik Bjørsnøs eirbjo at openjdk.org
Sun Nov 17 20:30:00 UTC 2024


Please review this PR which removes exceptional control flow in `Boolean::getBoolean`, `Integer::getInteger` and `Long::getLong`.

These methods are catching `IllegalArgumentException` and `NullPointerException`, thrown by `System::getProperty` via `System::checkKey`. This PR replaces the exceptional control flow with explicit checks that the system property name is non-null and non-empty before calling into `System::getProperty`.

As JDK-8178966 points out, there is a possibility that System.getProperty could throw one of NPE and IAE for other reasons than the name being null or empty. This risk is reduced now that custom security managers cannot interfere. Adding to that, if such exceptions are thrown today, they are masked by these methods catching and swallowing them by returning false or default values. It's better to expose such  bugs if they exist.

GHA results pending. Local tier2 ran successfully.

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

Commit messages:
 - Avoid exceptional control flow in Boolean.getBoolean, Integer.getInteger, Long.getLong

Changes: https://git.openjdk.org/jdk/pull/22183/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=22183&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8178966
  Stats: 16 lines in 3 files changed: 0 ins; 13 del; 3 mod
  Patch: https://git.openjdk.org/jdk/pull/22183.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/22183/head:pull/22183

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


More information about the core-libs-dev mailing list