On Thu, 18 Jun 2026 12:56:53 GMT, Alan Bateman <[email protected]> wrote:
>> Can I please get a review of this change which specifies that the >> `IdentityException` throws a `NullPointerException` if the `Class` passed to >> its constructor is null? >> >> This change is being proposed as part of the JEP-401 standard library >> changes that are currently under review at >> https://github.com/openjdk/jdk/pull/31123. >> >> A new jtreg test has been introduced to verify the basic semantics of this >> exception class. >> >> --------- >> - [x] I confirm that I make this contribution in accordance with the >> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). > > src/java.base/share/classes/java/lang/IdentityException.java line 52: > >> 50: * >> 51: * @apiNote >> 52: * This constructor does not verify that the given {@code clazz} is >> a value class. > > URISyntaxException and InvalidPathException are examples of exceptions with > specialized constructors (not one of the usual 4) that throw IAE when invoked > with a bad parameter. I don't know if this was looked at, and rejected, at > some point. I think it's reasonable to throw `IllegalArgumentException`, when `clazz` is not null and is an identity class. I had hesitated doing that for the same reason as you note - I don't have prior knowledge of these discussions. I'll update this PR to throw the IAE, run existing tests and then wait for a few days to see if anyone says we should not throw the IAE. ------------- PR Review Comment: https://git.openjdk.org/valhalla/pull/2562#discussion_r3436118216
