Skip to content

Commit a5e9583

Browse files
committed
proper Object[] instanceof handling
1 parent 39c5158 commit a5e9583

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,50 @@ class Test_Array extends Test_ {
5151

5252
public static void main(String[] args) {
5353

54+
Object[][] oaa = new Object[2][];
55+
56+
57+
// Object[][] is Object[]
58+
if (oaa instanceof Object[]) {
59+
System.out.println("OK");
60+
} else {
61+
assert(false);
62+
}
63+
64+
// Object[][] is not Object[][][]
65+
if (oaa instanceof Object[][][]) {
66+
assert(false);
67+
} else {
68+
System.out.println("OK");
69+
}
70+
71+
// String[][] is Object[]
72+
if (s3_ instanceof Object[]) {
73+
System.out.println("OK");
74+
} else {
75+
assert(false);
76+
}
77+
78+
// String[][] is Object[][]
79+
if (s3_ instanceof Object[][]) {
80+
System.out.println("OK");
81+
} else {
82+
assert(false);
83+
}
84+
85+
// int[] is not Object[]
86+
if (i3 instanceof Object[]) {
87+
assert(false);
88+
} else {
89+
System.out.println("OK");
90+
}
91+
92+
if (s3 instanceof Object[][]) {
93+
assert(false);
94+
} else {
95+
System.out.println("OK");
96+
}
97+
5498
try {
5599
System.out.println(Class.forName("[C").getName());
56100
System.out.println(((new test.Test_Array[0]).getClass().getName()));

0 commit comments

Comments
 (0)