On Wed, 10 Jan 2024 20:54:20 GMT, Peter Levart <plev...@openjdk.org> wrote:
> I belive there is a bug in `AbstractMemorySegmentImpl#mismatch` method. It > returns `-1` (meaning that regions are equal) when passing the same instance > of MemorySegment as both `srcSegment` and `dstSegment` parameters regardless > of whether `srcFromOffset` and `dstFromOffset` as well as `srcToOffset` and > `dstToOffset` are also equal. > > Am I right? Note there's another bug for this: https://bugs.openjdk.org/browse/JDK-8323524 src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java line 684: > 682: srcImpl.checkAccess(srcFromOffset, srcBytes, true); > 683: dstImpl.checkAccess(dstFromOffset, dstBytes, true); > 684: if (dstImpl.equals(srcImpl) && srcFromOffset == dstFromOffset && > srcBytes == dstBytes) { I'm also ok to completely drop this check (or move it into the instance version of the mismatch method). This also needs a test. ------------- PR Comment: https://git.openjdk.org/jdk/pull/17354#issuecomment-1885824510 PR Review Comment: https://git.openjdk.org/jdk/pull/17354#discussion_r1448045022