Skip to content

Commit

Permalink
[JVM] Fix conversion to unsigned int
Browse files Browse the repository at this point in the history
... in VMArray with 32 bit. The old code handled the 1 as a signed
integer, so that (1 << 32) just evaluated to 1.

An alternative would have been to use Integer.toUnsignedLong(i),
which is available since Java 8. We could change to those methods
in the future -- but for consistency the should be used for the
other types of VMArrays as well.
  • Loading branch information
usev6 committed Nov 24, 2021
1 parent f3a510c commit 81fe411
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Expand Up @@ -9,7 +9,7 @@ public class MultiDimArrayInstance_u32 extends MultiDimArrayInstanceBase {
public int[] slots;

private static long widen(int i) {
return i < 0 ? i + (1 << 32) : i;
return i < 0 ? i + (1L << 32) : i;
}

@Override
Expand Down
Expand Up @@ -12,7 +12,7 @@ public class VMArrayInstance_u32 extends VMArrayInstanceBase {
public int[] slots;

private static long widen(int i) {
return i < 0 ? i + (1 << 32) : i;
return i < 0 ? i + (1L << 32) : i;
}

@Override
Expand Down

0 comments on commit 81fe411

Please sign in to comment.