This PR adds a check so that out-of-size segments throw UOE when converted to a byte buffer.
--------- - [x] I confirm that I make this contribution in accordance with the [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). ------------- Commit messages: - Use common logic for exception handling - Add length check to MS::asByteBuffer Changes: https://git.openjdk.org/jdk/pull/33412/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=33412&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8392363 Stats: 25 lines in 2 files changed: 15 ins; 0 del; 10 mod Patch: https://git.openjdk.org/jdk/pull/33412.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/33412/head:pull/33412 PR: https://git.openjdk.org/jdk/pull/33412
