Skip to content

Conversation

@BobHanson
Copy link
Collaborator

restrictions on BitSet and Scanner

Because of the issue of long being only 53 bits, any time a method returns a long value, considerations must
be made as to whether this will work in JavaScript. In particular, BitSet and Scanner have issues.

In SwingJS, java.util.BitSet has been implemented as a 32-bit integer-based bitset. This was no problem in
Java 6, but starting with Java 7, a method was added to BitSet that allows for the extraction of the
underlying long[] word data. This is not work in JavaScript. Instead, SwingJS java.util.Bitset.toLongArray() will deliver
32-bit int[] data.

SwingJS Scanner has hasNextLong() and nextLong(), and although it will scan through long numbers,
Scanner will choke on long numbers greater than the JavaScript 53-bit limit. hasNextLong() will
return false, and nextLong() will throw an InputMismatchException triggered by the NumberFormatException
thrown by Long.parseLong().

hansonr and others added 6 commits December 5, 2020 18:02
 - was using |0, but that is only for int32
- sets upper/lower limit for long values to 53 bits
    (+/-1FFFFFFFFFFFFF)

- fixes issues with number parsing involving limits and "0x"
- sets upper/lower limit for long values to 53 bits
    (+/-1FFFFFFFFFFFFF)

- fixes issues with number parsing involving limits and "0x"
@BobHanson BobHanson merged commit 8388836 into java2script:master Dec 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant