@@ -70,8 +70,8 @@ final class Frame {
70
70
* stack types. VALUE depends on KIND. For LOCAL types, it is an index in
71
71
* the input local variable types. For STACK types, it is a position
72
72
* relatively to the top of input frame stack. For BASE types, it is either
73
- * one of the constants defined in FrameVisitor , or for OBJECT and
74
- * UNINITIALIZED types, a tag and an index in the type table.
73
+ * one of the constants defined below , or for OBJECT and UNINITIALIZED
74
+ * types, a tag and an index in the type table.
75
75
*
76
76
* Output frames can contain types of any kind and with a positive or
77
77
* negative dimension (and even unassigned types, represented by 0 - which
@@ -1417,6 +1417,7 @@ private static boolean merge(final ClassWriter cw, int t,
1417
1417
// if t is the NULL type, merge(u,t)=u, so there is no change
1418
1418
return false ;
1419
1419
} else if ((t & (DIM | BASE_KIND )) == (u & (DIM | BASE_KIND ))) {
1420
+ // if t and u have the same dimension and same base kind
1420
1421
if ((u & BASE_KIND ) == OBJECT ) {
1421
1422
// if t is also a reference type, and if u and t have the
1422
1423
// same dimension merge(u,t) = dim(t) | common parent of the
@@ -1425,13 +1426,21 @@ private static boolean merge(final ClassWriter cw, int t,
1425
1426
| cw .getMergedType (t & BASE_VALUE , u & BASE_VALUE );
1426
1427
} else {
1427
1428
// if u and t are array types, but not with the same element
1428
- // type, merge(u,t)=java/lang/Object
1429
- v = OBJECT | cw .addType ("java/lang/Object" );
1429
+ // type, merge(u,t) = dim(u) - 1 | java/lang/Object
1430
+ int vdim = ELEMENT_OF + (u & DIM );
1431
+ v = vdim | OBJECT | cw .addType ("java/lang/Object" );
1430
1432
}
1431
1433
} else if ((t & BASE_KIND ) == OBJECT || (t & DIM ) != 0 ) {
1432
- // if t is any other reference or array type,
1433
- // merge(u,t)=java/lang/Object
1434
- v = OBJECT | cw .addType ("java/lang/Object" );
1434
+ // if t is any other reference or array type, the merged type
1435
+ // is min(udim, tdim) | java/lang/Object, where udim is the
1436
+ // array dimension of u, minus 1 if u is an array type with a
1437
+ // primitive element type (and similarly for tdim).
1438
+ int tdim = (((t & DIM ) == 0 || (t & BASE_KIND ) == OBJECT ) ? 0
1439
+ : ELEMENT_OF ) + (t & DIM );
1440
+ int udim = (((u & DIM ) == 0 || (u & BASE_KIND ) == OBJECT ) ? 0
1441
+ : ELEMENT_OF ) + (u & DIM );
1442
+ v = Math .min (tdim , udim ) | OBJECT
1443
+ | cw .addType ("java/lang/Object" );
1435
1444
} else {
1436
1445
// if t is any other type, merge(u,t)=TOP
1437
1446
v = TOP ;
0 commit comments