Skip to content

Commit 4ca360a

Browse files
hansonrhansonr
authored andcommitted
bug fix int[][] clone fails
1 parent 1d8e790 commit 4ca360a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

sources/net.sf.j2s.java.core/src/test/Test_Array.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ class Test_Array extends Test_ {
1111

1212
static int y;
1313
static {
14+
15+
16+
int[][] ia = (int[][])c33def2b;
17+
int[][] ib = ia.clone();
18+
assert("[[I".equals(ib.getClass().getName()));
19+
1420
int x = 3;
1521
y = x;
1622
Test_Array[] a = new Test_Array[3];

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
// TODO: still a lot of references to window[...]
1111

12+
// BH 2019.07.27 fixes array(intArray).clone
1213
// BH 2019.07.09 adds Java String.trim()
1314
// BH 2019.05.21 changes Clazz.isClassDefined to Clazz._isClassDefined for compression
1415
// BH 2019.05.13 fixes for Math.getExponent, Math.IEEERemainder, Array.equals(Object)
@@ -214,7 +215,7 @@ var _array = function(baseClass, paramType, ndims, params, isClone) {
214215
}
215216
params.push(paramType);
216217
var nbits = 0;
217-
if (ndims != 0) {
218+
if (ndims != 0 && !(isClone && Array.isArray(params[1]))) {
218219
switch (prim) {
219220
case "B":
220221
nbits = 8;

0 commit comments

Comments
 (0)