Skip to content

Commit 9d92d69

Browse files
committed
full primitive casting
1 parent cf454e2 commit 9d92d69

File tree

2 files changed

+2
-21
lines changed

2 files changed

+2
-21
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ solution: recast as:
797797

798798

799799

800-
TODO #21 (byte) ignored so that 0xFF remains 0xFF.
800+
FIXED #21 (byte) ignored so that 0xFF remains 0xFF.
801801

802802
With the implementation of Int8Array in j2sJmol, it becomes more important to consider
803803
the issue of no byte type in JavaScript. In particular, the construction

sources/net.sf.j2s.core/src/net/sf/j2s/core/astvisitors/ASTScriptVisitor.java

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060

6161
// TODO: static calls to static methods do not trigger "musts" dependency
6262

63+
// BH 9/8/2017 -- primitive numeric casting -- (byte) was ignored so that (byte) 0xFF remained 0xFF.
6364
// BH 9/7/2017 -- fixed multiple issues with char and Character
6465
// BH 9/4/2017 -- java.awt, javax.swing, swingjs code added; additional fixes required
6566
// BH 8/30/2017 -- all i/o working, including printf and FileOutputStream
@@ -90,26 +91,6 @@ interface Editable {
9091
class EditDialog extends Dialog implements AdjustmentListener, ActionListener, ItemListener {
9192
...
9293
93-
TODO #21 (byte) ignored so that 0xFF remains 0xFF.
94-
95-
With the implementation of Int8Array in j2sJmol, it becomes more important to consider
96-
the issue of no byte type in JavaScript. In particular, the construction
97-
98-
bytes[3] == (byte) 0xFF
99-
100-
is being translated as
101-
102-
bytes[3] == 0xFF
103-
104-
and will evaluate FALSE since JavaScript Int8Array elements cannot have value 255.
105-
106-
The solution is to recast the byte as an integer, not the other way around:
107-
108-
(bytes[3] & 0xFF) == 0xFF
109-
110-
which now works for both Java and JavaScript.
111-
112-
11394
TODO #16 when an inner public class is called by another class using instanceOf, that inner class becomes an optional load.
11495
but optional loads must still be loaded, and unless declared in package.js, J2S will look for xxx.xxx.Outer/Inner.js
11596
because the inner classes are not fully declared.

0 commit comments

Comments
 (0)