Skip to content

Commit c83fdf6

Browse files
committed
j2sClazz - allow for new int[] a = {"c",1,2}
1 parent 4245b60 commit c83fdf6

File tree

2 files changed

+4992
-2
lines changed

2 files changed

+4992
-2
lines changed

sources/net.sf.j2s.java.core/srcjs/js/j2sClazz.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
// Google closure compiler cannot handle Clazz.new or Clazz.super
99

10+
// BH 5/19/2018 8:22:25 PM fix for new int[] {'a'}
1011
// BH 4/16/2018 6:14:10 PM msie flag in monitor
1112
// BH 2/22/2018 12:34:07 AM array.clone() fix
1213
// BH 2/20/2018 12:59:28 AM adds Character.isISOControl
@@ -853,10 +854,14 @@ var newTypedA = function(baseClass, args, nBits, ndims) {
853854
// Clazz.newA(5 ,null, "SA") new String[5] val = null
854855
// Clazz.newA(-1, ["A","B"], "SA") new String[] val = {"A", "B"}
855856
// Clazz.newA(3, 5, 0, "IAA") new int[3][5] (second pass, so now args = [5, 0, "IA"])
856-
if (val == null)
857+
if (val == null) {
857858
nBits = 0;
858-
else if (nBits > 0 && dim < 0)
859+
} else if (nBits > 0 && dim < 0) {
860+
// make sure this is not a character
861+
for (var i = val.length; --i >= 0;)
862+
val[i].charAt && (val[i] = val[i].charAt(0));
859863
dim = val; // because we can initialize an array using new Int32Array([...])
864+
}
860865
if (nBits > 0)
861866
ndims = 1;
862867
var atype;

0 commit comments

Comments
 (0)