<div dir="ltr"><div>In Java 21 FFM, attempting a write operation on a MemorySegment configured as ReadOnly throws a <i>UnsupportedOperationException (UOE),</i> which makes sense.</div><div><br></div><div>However, starting with Java 22, FFM, attempting a write operation on a MemorySegment configured as ReadOnly throws a <i>IllegalArgumentException (IAE),</i> which makes less sense to me.   </div><div><br></div><div>I guess you could argue it either way, but one could look at it this way:</div><div><ul><li>The target is correct, but the operation is incorrect -- thus, UOE makes sense </li><li>The target of the operation is incorrect, but the operation is correct -- thus, IAE makes sense</li><li>The target is correct and the operation is correct, but the target is incorrectly configured as read-only -- thus UOE makes sense</li><li>Both the target and the operation are incorrect -- thus, either UOE or IAE could make sense.</li></ul></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div>Please enlighten me.</div><div><br></div><div>Lee.</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div>