RFR: 8373631: Improve classes in the "jdk.jpackage.internal.util.function" package
Alexey Semenyuk
asemenyuk at openjdk.org
Fri Dec 12 23:56:08 UTC 2025
- Add exception type as an additional generic parameter to all `Throwing...` interfaces
- Add unit tests for "jdk.jpackage.internal.util.function" package
- Add `ExceptionBox.toUnchecked()`. It is equivalent to `ExceptionBox.rethrowUnchecked()`, but doesn't throw
- Replace `ExceptionBox.rethrowUnchecked(...)` with `ExceptionBox.toUnchecked(...)`; this increased test coverage of "jdk.jpackage.internal.util.function" package from 86% to 97%
- Change exception handling in `ExceptionBox.toUnchecked()` (former `ExceptionBox.rethrowUnchecked()`):
- `InterruptedException`: instead of rethrowing an exception of this type, it calls `Thread.currentThread().interrupt()` and then rethrows it
- Add `ExceptionBox.unbox()` (former `TKit.unbox()`). It is complementary to `ExceptionBox.toUnchecked()`
- Catch `Exception` instead of `Throwable` where appropriate to avoid catching `Error`-s. The idea is not to handle fatal errors
- Replace vague `throws Throwable` exception specifications with more specific ones where appropriate
- Add `ExceptionBox.reachedUnreachable()` for use in locations that control flow is not expected to reach
-------------
Commit messages:
- Replace `ExceptionBox.rethrowUnchecked()` with `throw ExceptionBox.toUnchecked()`; remove ExceptionBox.rethrowUnchecked().
- ExceptionBox: add toUnchecked() and use it in all Throwing<Name> classes instead of ExceptionBox.rethrowUnchecked(). This change results in 100% coverage for these classes in the unit tests. Add unit tests. Add ExceptionBox.reachedUnreachable().
- Throwing<NAME>: make these classes generic; don't catch Throwable-s, catch Exception-s instead and let Error-s out.
Changes: https://git.openjdk.org/jdk/pull/28731/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=28731&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8373631
Stats: 713 lines in 52 files changed: 476 ins; 27 del; 210 mod
Patch: https://git.openjdk.org/jdk/pull/28731.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/28731/head:pull/28731
PR: https://git.openjdk.org/jdk/pull/28731
More information about the core-libs-dev
mailing list