RFR: 8321387: SegmentAllocator:allocateFrom(AddressLayout, MemorySegment) does not throw stated UnsupportedOperationException
Per Minborg
pminborg at openjdk.org
Wed Dec 6 13:57:43 UTC 2023
This PR proposes to change the exception type for exceptions thrown for certain methods with a parameter of type `MemorySegment` when it is `MemorySegment::isReadOnly`. Previously an `UnsupportedOperationException` was specified but in some cases, in reality, an `IllegalArgumentException` was thrown.
The principle used in this PR is that operations acting on an MS where the MS is `this` should throw an `UnsupportedOperationException` whereas in cases where the MS is a *parameter* an `IllegalArgumentException` should be thrown.
It should be noted that this PR retains the previous behavior for MS VarHandle access (even though the MS is a parameter to the accessor methods, the first parameter can be said to represent `this`).
-------------
Commit messages:
- Retain old behavior for MS VarHandle access
- Change some throws from UOE to IAE
Changes: https://git.openjdk.org/jdk/pull/16993/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=16993&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8321387
Stats: 94 lines in 8 files changed: 39 ins; 4 del; 51 mod
Patch: https://git.openjdk.org/jdk/pull/16993.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/16993/head:pull/16993
PR: https://git.openjdk.org/jdk/pull/16993
More information about the core-libs-dev
mailing list