Skip to content

Commit e1fece5

Browse files
hansonrhansonr
authored andcommitted
Updated Differences for long, BitSet, and Scanner
1 parent 7463f1a commit e1fece5

File tree

12 files changed

+132
-25
lines changed

12 files changed

+132
-25
lines changed
155 Bytes
Binary file not shown.

sources/net.sf.j2s.core/dist/swingjs/differences.txt

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ ever be shadowed or overridden by subclasses. For example, we see in java.lang.T
3131
----------------------------------
3232

3333

34-
updated 12/6/2020 -- note about restrictions on long, including BitSet
34+
updated 12/6/2020 -- note about restrictions on long, including BitSet and Scanner
3535
updated 3/21/2020 -- adds note about HashMap, Hashtable, and HashSet iterator ordering
3636
updated 3/20/2020 -- adds note about interning, new String("xxx"), and "xxx"
3737
updated 2/26/2020 -- adds Graphics.setClip issue
@@ -481,7 +481,8 @@ MINOR ISSUES--requiring some rewriting/refactoring outside of SwingJS
481481

482482
See below for a full discussion.
483483

484-
Restrictions on long and BitSet
484+
Restrictions on long
485+
Restriction on BitSet and Scanner
485486
HashMap, Hashtable, and HashSet iterator ordering
486487
interning, new String("xxx") vs "xxx"
487488
Names with "$" and "_"
@@ -588,8 +589,8 @@ changed to JSToolkit.isDispatchThread()
588589
MINOR ISSUES--requiring some rewriting/refactoring outside of SwingJS
589590
=====================================================================
590591

591-
restrictions on long and BitSet
592-
-------------------------------
592+
restrictions on long
593+
--------------------
593594

594595
Java's 64-bit long type is not supported in JavaScript. There is no Int64Array in JavaScript,
595596
and 0x20000000000000 + 1 evaluates to 0x20000000000000, not 0x20000000000001.
@@ -624,6 +625,24 @@ and also, in JavaScript only, we also have:
624625
double d = 0x2000000000000L;
625626
assert(((long) d) == 0);
626627

628+
629+
restrictions on BitSet and Scanner
630+
----------------------------------
631+
632+
Because of the issue of long being only 53 bits, any time a method returns a long value, considerations must
633+
be made as to whether this will work in JavaScript. In particular, BitSet and Scanner have issues.
634+
635+
In SwingJS, java.util.BitSet has been implemented as a 32-bit integer-based bitset. This was no problem in
636+
Java 6, but starting with Java 7, a method was added to BitSet that allows for the extraction of the
637+
underlying long[] word data. This is not work in JavaScript. Instead, SwingJS java.util.Bitset.toLongArray() will deliver
638+
32-bit int[] data.
639+
640+
SwingJS Scanner has hasNextLong() and nextLong(), and although it will scan through long numbers,
641+
Scanner will choke on long numbers greater than the JavaScript 53-bit limit. hasNextLong() will
642+
return false, and nextLong() will throw an InputMismatchException triggered by the NumberFormatException
643+
thrown by Long.parseLong().
644+
645+
627646
HashMap, Hashtable, and HashSet iterator ordering
628647
-------------------------------------------------
629648

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20201206104919
1+
20201206115202
155 Bytes
Binary file not shown.

sources/net.sf.j2s.core/dist/swingjs/ver/3.2.9/differences.txt

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ ever be shadowed or overridden by subclasses. For example, we see in java.lang.T
3131
----------------------------------
3232

3333

34-
updated 12/6/2020 -- note about restrictions on long, including BitSet
34+
updated 12/6/2020 -- note about restrictions on long, including BitSet and Scanner
3535
updated 3/21/2020 -- adds note about HashMap, Hashtable, and HashSet iterator ordering
3636
updated 3/20/2020 -- adds note about interning, new String("xxx"), and "xxx"
3737
updated 2/26/2020 -- adds Graphics.setClip issue
@@ -481,7 +481,8 @@ MINOR ISSUES--requiring some rewriting/refactoring outside of SwingJS
481481

482482
See below for a full discussion.
483483

484-
Restrictions on long and BitSet
484+
Restrictions on long
485+
Restriction on BitSet and Scanner
485486
HashMap, Hashtable, and HashSet iterator ordering
486487
interning, new String("xxx") vs "xxx"
487488
Names with "$" and "_"
@@ -588,8 +589,8 @@ changed to JSToolkit.isDispatchThread()
588589
MINOR ISSUES--requiring some rewriting/refactoring outside of SwingJS
589590
=====================================================================
590591

591-
restrictions on long and BitSet
592-
-------------------------------
592+
restrictions on long
593+
--------------------
593594

594595
Java's 64-bit long type is not supported in JavaScript. There is no Int64Array in JavaScript,
595596
and 0x20000000000000 + 1 evaluates to 0x20000000000000, not 0x20000000000001.
@@ -624,6 +625,24 @@ and also, in JavaScript only, we also have:
624625
double d = 0x2000000000000L;
625626
assert(((long) d) == 0);
626627

628+
629+
restrictions on BitSet and Scanner
630+
----------------------------------
631+
632+
Because of the issue of long being only 53 bits, any time a method returns a long value, considerations must
633+
be made as to whether this will work in JavaScript. In particular, BitSet and Scanner have issues.
634+
635+
In SwingJS, java.util.BitSet has been implemented as a 32-bit integer-based bitset. This was no problem in
636+
Java 6, but starting with Java 7, a method was added to BitSet that allows for the extraction of the
637+
underlying long[] word data. This is not work in JavaScript. Instead, SwingJS java.util.Bitset.toLongArray() will deliver
638+
32-bit int[] data.
639+
640+
SwingJS Scanner has hasNextLong() and nextLong(), and although it will scan through long numbers,
641+
Scanner will choke on long numbers greater than the JavaScript 53-bit limit. hasNextLong() will
642+
return false, and nextLong() will throw an InputMismatchException triggered by the NumberFormatException
643+
thrown by Long.parseLong().
644+
645+
627646
HashMap, Hashtable, and HashSet iterator ordering
628647
-------------------------------------------------
629648

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20201206104919
1+
20201206115202
155 Bytes
Binary file not shown.

sources/net.sf.j2s.java.core/dist/differences.txt

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ ever be shadowed or overridden by subclasses. For example, we see in java.lang.T
3131
----------------------------------
3232

3333

34-
updated 12/6/2020 -- note about restrictions on long, including BitSet
34+
updated 12/6/2020 -- note about restrictions on long, including BitSet and Scanner
3535
updated 3/21/2020 -- adds note about HashMap, Hashtable, and HashSet iterator ordering
3636
updated 3/20/2020 -- adds note about interning, new String("xxx"), and "xxx"
3737
updated 2/26/2020 -- adds Graphics.setClip issue
@@ -481,7 +481,8 @@ MINOR ISSUES--requiring some rewriting/refactoring outside of SwingJS
481481

482482
See below for a full discussion.
483483

484-
Restrictions on long and BitSet
484+
Restrictions on long
485+
Restriction on BitSet and Scanner
485486
HashMap, Hashtable, and HashSet iterator ordering
486487
interning, new String("xxx") vs "xxx"
487488
Names with "$" and "_"
@@ -588,8 +589,8 @@ changed to JSToolkit.isDispatchThread()
588589
MINOR ISSUES--requiring some rewriting/refactoring outside of SwingJS
589590
=====================================================================
590591

591-
restrictions on long and BitSet
592-
-------------------------------
592+
restrictions on long
593+
--------------------
593594

594595
Java's 64-bit long type is not supported in JavaScript. There is no Int64Array in JavaScript,
595596
and 0x20000000000000 + 1 evaluates to 0x20000000000000, not 0x20000000000001.
@@ -624,6 +625,24 @@ and also, in JavaScript only, we also have:
624625
double d = 0x2000000000000L;
625626
assert(((long) d) == 0);
626627

628+
629+
restrictions on BitSet and Scanner
630+
----------------------------------
631+
632+
Because of the issue of long being only 53 bits, any time a method returns a long value, considerations must
633+
be made as to whether this will work in JavaScript. In particular, BitSet and Scanner have issues.
634+
635+
In SwingJS, java.util.BitSet has been implemented as a 32-bit integer-based bitset. This was no problem in
636+
Java 6, but starting with Java 7, a method was added to BitSet that allows for the extraction of the
637+
underlying long[] word data. This is not work in JavaScript. Instead, SwingJS java.util.Bitset.toLongArray() will deliver
638+
32-bit int[] data.
639+
640+
SwingJS Scanner has hasNextLong() and nextLong(), and although it will scan through long numbers,
641+
Scanner will choke on long numbers greater than the JavaScript 53-bit limit. hasNextLong() will
642+
return false, and nextLong() will throw an InputMismatchException triggered by the NumberFormatException
643+
thrown by Long.parseLong().
644+
645+
627646
HashMap, Hashtable, and HashSet iterator ordering
628647
-------------------------------------------------
629648

sources/net.sf.j2s.java.core/doc/Differences.txt

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ ever be shadowed or overridden by subclasses. For example, we see in java.lang.T
3131
----------------------------------
3232

3333

34-
updated 12/6/2020 -- note about restrictions on long, including BitSet
34+
updated 12/6/2020 -- note about restrictions on long, including BitSet and Scanner
3535
updated 3/21/2020 -- adds note about HashMap, Hashtable, and HashSet iterator ordering
3636
updated 3/20/2020 -- adds note about interning, new String("xxx"), and "xxx"
3737
updated 2/26/2020 -- adds Graphics.setClip issue
@@ -481,7 +481,8 @@ MINOR ISSUES--requiring some rewriting/refactoring outside of SwingJS
481481

482482
See below for a full discussion.
483483

484-
Restrictions on long and BitSet
484+
Restrictions on long
485+
Restriction on BitSet and Scanner
485486
HashMap, Hashtable, and HashSet iterator ordering
486487
interning, new String("xxx") vs "xxx"
487488
Names with "$" and "_"
@@ -588,8 +589,8 @@ changed to JSToolkit.isDispatchThread()
588589
MINOR ISSUES--requiring some rewriting/refactoring outside of SwingJS
589590
=====================================================================
590591

591-
restrictions on long and BitSet
592-
-------------------------------
592+
restrictions on long
593+
--------------------
593594

594595
Java's 64-bit long type is not supported in JavaScript. There is no Int64Array in JavaScript,
595596
and 0x20000000000000 + 1 evaluates to 0x20000000000000, not 0x20000000000001.
@@ -624,6 +625,24 @@ and also, in JavaScript only, we also have:
624625
double d = 0x2000000000000L;
625626
assert(((long) d) == 0);
626627

628+
629+
restrictions on BitSet and Scanner
630+
----------------------------------
631+
632+
Because of the issue of long being only 53 bits, any time a method returns a long value, considerations must
633+
be made as to whether this will work in JavaScript. In particular, BitSet and Scanner have issues.
634+
635+
In SwingJS, java.util.BitSet has been implemented as a 32-bit integer-based bitset. This was no problem in
636+
Java 6, but starting with Java 7, a method was added to BitSet that allows for the extraction of the
637+
underlying long[] word data. This is not work in JavaScript. Instead, SwingJS java.util.Bitset.toLongArray() will deliver
638+
32-bit int[] data.
639+
640+
SwingJS Scanner has hasNextLong() and nextLong(), and although it will scan through long numbers,
641+
Scanner will choke on long numbers greater than the JavaScript 53-bit limit. hasNextLong() will
642+
return false, and nextLong() will throw an InputMismatchException triggered by the NumberFormatException
643+
thrown by Long.parseLong().
644+
645+
627646
HashMap, Hashtable, and HashSet iterator ordering
628647
-------------------------------------------------
629648

sources/net.sf.j2s.java.core/src/java/util/BitSet.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
import java.nio.ByteBuffer;
2121
import java.nio.ByteOrder;
2222
import java.nio.IntBuffer;
23-
import java.nio.LongBuffer;
2423
import java.util.stream.IntStream;
2524
import java.util.stream.StreamSupport;
2625

2726
import javajs.api.JSONEncodable;
2827
import javajs.util.SB;
28+
import swingjs.JSUtil;
2929

3030

3131
/**
@@ -1028,6 +1028,7 @@ public BitSet get(int fromIndex, int toIndex) {
10281028
* @return
10291029
*/
10301030
public long[] toLongArray() {
1031+
JSUtil.notImplemented("BitSet.toLongArray returns a 32-bit array");
10311032
long[] a = new long[words.length];
10321033
for (int i = a.length; --i >= 0;)
10331034
a[i] = words[i];

0 commit comments

Comments
 (0)