On Tue, 16 Dec 2025 23:16:42 GMT, eunbin son <[email protected]> wrote:
>> ## Summary >> Adds comprehensive edge case tests for `Objects.requireNonNull`, >> `requireNonNullElse`, and `requireNonNullElseGet` methods to improve >> test coverage. >> >> ## Problem >> The current test suite for `Objects.requireNonNull` methods covers >> basic cases but lacks edge case coverage. >> >> ## Solution >> This PR adds tests for the following edge cases: >> - requireNonNull with null Supplier parameter >> - requireNonNull with Supplier that throws exception >> - requireNonNullElse with both arguments null >> - requireNonNullElseGet with null supplier >> - requireNonNullElseGet with supplier returning null >> >> ## Issue >> Fixes JDK-8373661 >> >> **JBS Issue Link**: >> https://bugs.java.com/bugdatabase/view_bug?bug_id=JDK-8373661 >> >> ## Type of Change >> - [x] Test addition/modification >> - [ ] Bug fix >> - [ ] New feature >> - [ ] Documentation improvement >> - [ ] Refactoring >> >> ## Testing >> >> make test TEST="jtreg:test/jdk/java/util/Objects" > > eunbin son has refreshed the contents of this pull request, and previous > commits have been removed. The incremental views will show differences > compared to the previous content of the PR. The pull request contains one new > commit since the last revision: > > 8373661: Convert BasicObjectsTest to JUnit format > > - Converted all 17 test methods from jtreg main-method format to JUnit > - Removed main() method > - Added @run junit annotation > - All tests follow OpenJDK JUnit testing patterns > > Thanks to @RogerRiggs for the feedback. test/jdk/java/util/Objects/BasicObjectsTest.java line 305: > 303: RuntimeException.class, > 304: () -> Objects.requireNonNull(null, () -> { > 305: throw new RuntimeException("Supplier exception"); Instead of detecting by message, you can allocate an exception outside of the lambda, throw it here, and assertSame your exception with the assertThrows returned exception. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/28845#discussion_r2625097382
