Skip to content

Commit fb66567

Browse files
committed
Final patches from ASM 5.0.2 release
Issue: SPR-11212
1 parent 6b20439 commit fb66567

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

spring-core/src/main/java/org/springframework/asm/ClassWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ public final void visitInnerClass(final String name,
756756
if (innerClasses == null) {
757757
innerClasses = new ByteVector();
758758
}
759-
// §4.7.6 of the JVMS states "Every CONSTANT_Class_info entry in the
759+
// Sec. 4.7.6 of the JVMS states "Every CONSTANT_Class_info entry in the
760760
// constant_pool table which represents a class or interface C that is
761761
// not a package member must have exactly one corresponding entry in the
762762
// classes array". To avoid duplicates we keep track in the intVal field

spring-core/src/main/java/org/springframework/asm/Frame.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ final class Frame {
7070
* stack types. VALUE depends on KIND. For LOCAL types, it is an index in
7171
* the input local variable types. For STACK types, it is a position
7272
* 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.
7575
*
7676
* Output frames can contain types of any kind and with a positive or
7777
* negative dimension (and even unassigned types, represented by 0 - which
@@ -1417,6 +1417,7 @@ private static boolean merge(final ClassWriter cw, int t,
14171417
// if t is the NULL type, merge(u,t)=u, so there is no change
14181418
return false;
14191419
} else if ((t & (DIM | BASE_KIND)) == (u & (DIM | BASE_KIND))) {
1420+
// if t and u have the same dimension and same base kind
14201421
if ((u & BASE_KIND) == OBJECT) {
14211422
// if t is also a reference type, and if u and t have the
14221423
// same dimension merge(u,t) = dim(t) | common parent of the
@@ -1425,13 +1426,21 @@ private static boolean merge(final ClassWriter cw, int t,
14251426
| cw.getMergedType(t & BASE_VALUE, u & BASE_VALUE);
14261427
} else {
14271428
// 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");
14301432
}
14311433
} 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");
14351444
} else {
14361445
// if t is any other type, merge(u,t)=TOP
14371446
v = TOP;

0 commit comments

Comments
 (0)