Skip to content

Commit 637ad20

Browse files
committed
Latest ASM patches (fix for bug 317151 from ASM HEAD; ASM's 1.8 bytecode processing needs to be lenient with CGLIB 3.1)
Issue: SPR-11212
1 parent 49e3c2a commit 637ad20

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,11 @@ public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
193193
*/
194194
public AnnotationVisitor visitTypeAnnotation(int typeRef,
195195
TypePath typePath, String desc, boolean visible) {
196+
/* SPRING PATCH: REMOVED FOR COMPATIBILITY WITH CGLIB 3.1
196197
if (api < Opcodes.ASM5) {
197198
throw new RuntimeException();
198199
}
200+
*/
199201
if (cv != null) {
200202
return cv.visitTypeAnnotation(typeRef, typePath, desc, visible);
201203
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,11 @@ public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
116116
*/
117117
public AnnotationVisitor visitTypeAnnotation(int typeRef,
118118
TypePath typePath, String desc, boolean visible) {
119+
/* SPRING PATCH: REMOVED FOR COMPATIBILITY WITH CGLIB 3.1
119120
if (api < Opcodes.ASM5) {
120121
throw new RuntimeException();
121122
}
123+
*/
122124
if (fv != null) {
123125
return fv.visitTypeAnnotation(typeRef, typePath, desc, visible);
124126
}

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

Lines changed: 5 additions & 10 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 below, or for OBJECT and UNINITIALIZED
74-
* types, a tag and an index in the type table.
73+
* one of the constants defined in FrameVisitor, or for OBJECT and
74+
* UNINITIALIZED 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,7 +1417,6 @@ 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
14211420
if ((u & BASE_KIND) == OBJECT) {
14221421
// if t is also a reference type, and if u and t have the
14231422
// same dimension merge(u,t) = dim(t) | common parent of the
@@ -1430,13 +1429,9 @@ private static boolean merge(final ClassWriter cw, int t,
14301429
v = OBJECT | cw.addType("java/lang/Object");
14311430
}
14321431
} else if ((t & BASE_KIND) == OBJECT || (t & DIM) != 0) {
1433-
// if t is any other reference or array type, the merged type
1434-
// is Object, or min(dim(u), dim(t)) | java/lang/Object is u
1435-
// and t have different array dimensions
1436-
int tdim = t & DIM;
1437-
int udim = u & DIM;
1438-
v = (udim != tdim ? Math.min(tdim, udim) : 0) | OBJECT
1439-
| cw.addType("java/lang/Object");
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");
14401435
} else {
14411436
// if t is any other type, merge(u,t)=TOP
14421437
v = TOP;

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,11 @@ public MethodVisitor(final int api, final MethodVisitor mv) {
110110
* allowed (see {@link Opcodes}).
111111
*/
112112
public void visitParameter(String name, int access) {
113+
/* SPRING PATCH: REMOVED FOR COMPATIBILITY WITH CGLIB 3.1
113114
if (api < Opcodes.ASM5) {
114115
throw new RuntimeException();
115116
}
117+
*/
116118
if (mv != null) {
117119
mv.visitParameter(name, access);
118120
}
@@ -179,9 +181,11 @@ public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
179181
*/
180182
public AnnotationVisitor visitTypeAnnotation(int typeRef,
181183
TypePath typePath, String desc, boolean visible) {
184+
/* SPRING PATCH: REMOVED FOR COMPATIBILITY WITH CGLIB 3.1
182185
if (api < Opcodes.ASM5) {
183186
throw new RuntimeException();
184187
}
188+
*/
185189
if (mv != null) {
186190
return mv.visitTypeAnnotation(typeRef, typePath, desc, visible);
187191
}
@@ -693,9 +697,11 @@ public void visitMultiANewArrayInsn(String desc, int dims) {
693697
*/
694698
public AnnotationVisitor visitInsnAnnotation(int typeRef,
695699
TypePath typePath, String desc, boolean visible) {
700+
/* SPRING PATCH: REMOVED FOR COMPATIBILITY WITH CGLIB 3.1
696701
if (api < Opcodes.ASM5) {
697702
throw new RuntimeException();
698703
}
704+
*/
699705
if (mv != null) {
700706
return mv.visitInsnAnnotation(typeRef, typePath, desc, visible);
701707
}
@@ -753,9 +759,11 @@ public void visitTryCatchBlock(Label start, Label end, Label handler,
753759
*/
754760
public AnnotationVisitor visitTryCatchAnnotation(int typeRef,
755761
TypePath typePath, String desc, boolean visible) {
762+
/* SPRING PATCH: REMOVED FOR COMPATIBILITY WITH CGLIB 3.1
756763
if (api < Opcodes.ASM5) {
757764
throw new RuntimeException();
758765
}
766+
*/
759767
if (mv != null) {
760768
return mv.visitTryCatchAnnotation(typeRef, typePath, desc, visible);
761769
}
@@ -824,9 +832,11 @@ public void visitLocalVariable(String name, String desc, String signature,
824832
public AnnotationVisitor visitLocalVariableAnnotation(int typeRef,
825833
TypePath typePath, Label[] start, Label[] end, int[] index,
826834
String desc, boolean visible) {
835+
/* SPRING PATCH: REMOVED FOR COMPATIBILITY WITH CGLIB 3.1
827836
if (api < Opcodes.ASM5) {
828837
throw new RuntimeException();
829838
}
839+
*/
830840
if (mv != null) {
831841
return mv.visitLocalVariableAnnotation(typeRef, typePath, start,
832842
end, index, desc, visible);

0 commit comments

Comments
 (0)