From 637ad20cd308d0603742bc61cf9c068db6bf2903 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 16 Apr 2014 12:35:26 +0200 Subject: [PATCH] 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 --- .../org/springframework/asm/ClassVisitor.java | 2 ++ .../org/springframework/asm/FieldVisitor.java | 2 ++ .../main/java/org/springframework/asm/Frame.java | 15 +++++---------- .../org/springframework/asm/MethodVisitor.java | 10 ++++++++++ 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/asm/ClassVisitor.java b/spring-core/src/main/java/org/springframework/asm/ClassVisitor.java index 4a495862d4..ba58188a51 100644 --- a/spring-core/src/main/java/org/springframework/asm/ClassVisitor.java +++ b/spring-core/src/main/java/org/springframework/asm/ClassVisitor.java @@ -193,9 +193,11 @@ public abstract class ClassVisitor { */ public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) { + /* SPRING PATCH: REMOVED FOR COMPATIBILITY WITH CGLIB 3.1 if (api < Opcodes.ASM5) { throw new RuntimeException(); } + */ if (cv != null) { return cv.visitTypeAnnotation(typeRef, typePath, desc, visible); } diff --git a/spring-core/src/main/java/org/springframework/asm/FieldVisitor.java b/spring-core/src/main/java/org/springframework/asm/FieldVisitor.java index 8863e668e4..2822f3b23f 100644 --- a/spring-core/src/main/java/org/springframework/asm/FieldVisitor.java +++ b/spring-core/src/main/java/org/springframework/asm/FieldVisitor.java @@ -116,9 +116,11 @@ public abstract class FieldVisitor { */ public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) { + /* SPRING PATCH: REMOVED FOR COMPATIBILITY WITH CGLIB 3.1 if (api < Opcodes.ASM5) { throw new RuntimeException(); } + */ if (fv != null) { return fv.visitTypeAnnotation(typeRef, typePath, desc, visible); } diff --git a/spring-core/src/main/java/org/springframework/asm/Frame.java b/spring-core/src/main/java/org/springframework/asm/Frame.java index fcabe0d9df..f851ff6436 100644 --- a/spring-core/src/main/java/org/springframework/asm/Frame.java +++ b/spring-core/src/main/java/org/springframework/asm/Frame.java @@ -70,8 +70,8 @@ final class Frame { * stack types. VALUE depends on KIND. For LOCAL types, it is an index in * the input local variable types. For STACK types, it is a position * relatively to the top of input frame stack. For BASE types, it is either - * one of the constants defined below, or for OBJECT and UNINITIALIZED - * types, a tag and an index in the type table. + * one of the constants defined in FrameVisitor, or for OBJECT and + * UNINITIALIZED types, a tag and an index in the type table. * * Output frames can contain types of any kind and with a positive or * negative dimension (and even unassigned types, represented by 0 - which @@ -1417,7 +1417,6 @@ final class Frame { // if t is the NULL type, merge(u,t)=u, so there is no change return false; } else if ((t & (DIM | BASE_KIND)) == (u & (DIM | BASE_KIND))) { - // if t and u have the same dimension and same base kind if ((u & BASE_KIND) == OBJECT) { // if t is also a reference type, and if u and t have the // same dimension merge(u,t) = dim(t) | common parent of the @@ -1430,13 +1429,9 @@ final class Frame { v = OBJECT | cw.addType("java/lang/Object"); } } else if ((t & BASE_KIND) == OBJECT || (t & DIM) != 0) { - // if t is any other reference or array type, the merged type - // is Object, or min(dim(u), dim(t)) | java/lang/Object is u - // and t have different array dimensions - int tdim = t & DIM; - int udim = u & DIM; - v = (udim != tdim ? Math.min(tdim, udim) : 0) | OBJECT - | cw.addType("java/lang/Object"); + // if t is any other reference or array type, + // merge(u,t)=java/lang/Object + v = OBJECT | cw.addType("java/lang/Object"); } else { // if t is any other type, merge(u,t)=TOP v = TOP; diff --git a/spring-core/src/main/java/org/springframework/asm/MethodVisitor.java b/spring-core/src/main/java/org/springframework/asm/MethodVisitor.java index fc64fe23b2..4d5c50b98e 100644 --- a/spring-core/src/main/java/org/springframework/asm/MethodVisitor.java +++ b/spring-core/src/main/java/org/springframework/asm/MethodVisitor.java @@ -110,9 +110,11 @@ public abstract class MethodVisitor { * allowed (see {@link Opcodes}). */ public void visitParameter(String name, int access) { + /* SPRING PATCH: REMOVED FOR COMPATIBILITY WITH CGLIB 3.1 if (api < Opcodes.ASM5) { throw new RuntimeException(); } + */ if (mv != null) { mv.visitParameter(name, access); } @@ -179,9 +181,11 @@ public abstract class MethodVisitor { */ public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) { + /* SPRING PATCH: REMOVED FOR COMPATIBILITY WITH CGLIB 3.1 if (api < Opcodes.ASM5) { throw new RuntimeException(); } + */ if (mv != null) { return mv.visitTypeAnnotation(typeRef, typePath, desc, visible); } @@ -693,9 +697,11 @@ public abstract class MethodVisitor { */ public AnnotationVisitor visitInsnAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) { + /* SPRING PATCH: REMOVED FOR COMPATIBILITY WITH CGLIB 3.1 if (api < Opcodes.ASM5) { throw new RuntimeException(); } + */ if (mv != null) { return mv.visitInsnAnnotation(typeRef, typePath, desc, visible); } @@ -753,9 +759,11 @@ public abstract class MethodVisitor { */ public AnnotationVisitor visitTryCatchAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) { + /* SPRING PATCH: REMOVED FOR COMPATIBILITY WITH CGLIB 3.1 if (api < Opcodes.ASM5) { throw new RuntimeException(); } + */ if (mv != null) { return mv.visitTryCatchAnnotation(typeRef, typePath, desc, visible); } @@ -824,9 +832,11 @@ public abstract class MethodVisitor { public AnnotationVisitor visitLocalVariableAnnotation(int typeRef, TypePath typePath, Label[] start, Label[] end, int[] index, String desc, boolean visible) { + /* SPRING PATCH: REMOVED FOR COMPATIBILITY WITH CGLIB 3.1 if (api < Opcodes.ASM5) { throw new RuntimeException(); } + */ if (mv != null) { return mv.visitLocalVariableAnnotation(typeRef, typePath, start, end, index, desc, visible);