Exception change? and Reason?
Lee Rhodes
leerho at gmail.com
Sat Apr 26 19:31:58 UTC 2025
In Java 21 FFM, attempting a write operation on a MemorySegment configured
as ReadOnly throws a *UnsupportedOperationException (UOE),* which makes
sense.
However, starting with Java 22, FFM, attempting a write operation on a
MemorySegment configured as ReadOnly throws a *IllegalArgumentException
(IAE),* which makes less sense to me.
I guess you could argue it either way, but one could look at it this way:
- The target is correct, but the operation is incorrect -- thus, UOE
makes sense
- The target of the operation is incorrect, but the operation is correct
-- thus, IAE makes sense
- The target is correct and the operation is correct, but the target is
incorrectly configured as read-only -- thus UOE makes sense
- Both the target and the operation are incorrect -- thus, either UOE or
IAE could make sense.
Of these 4 cases, I would think the first 3 are the most common, in which
case the UOE would be the most likely cause.
I'm sure the Java authors must have a more eloquent reason why this was
changed, and I tried to find release notes that would explain this change
but to no avail.
Please enlighten me.
Lee.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20250426/675d8495/attachment-0001.htm>
More information about the panama-dev
mailing list