Description: Upgrade from ASM 3 to ASM 4. This patch can be dropped after upgrading to Spring 3.2 or later
Origin: backport, https://github.com/spring-projects/spring-framework/commit/c16f18a5
Bug: https://jira.spring.io/browse/SPR-9669
--- /dev/null
+++ b/projects/org.springframework.core/src/main/java/org/springframework/asm/SpringAsmInfo.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2002-2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.asm;
+
+/**
+ * Utility class exposing constants related to Spring's internal repackaging of the ASM
+ * bytecode manipulation library.
+ *
+ * <p>See <a href="package-summary.html">package-level Javadoc</a> for more
+ * information on {@code org.springframework.asm}.
+ *
+ * @author Chris Beams
+ * @since 3.2
+ */
+public final class SpringAsmInfo {
+
+	/**
+	 * The ASM version used internally throughout the framework.
+	 *
+	 * @see Opcodes#ASM4
+	 */
+	public static final int ASM_VERSION = org.objectweb.asm.Opcodes.ASM4;
+
+}
--- a/projects/org.springframework.core/src/main/java/org/springframework/core/LocalVariableTableParameterNameDiscoverer.java
+++ b/projects/org.springframework.core/src/main/java/org/springframework/core/LocalVariableTableParameterNameDiscoverer.java
@@ -29,11 +29,12 @@
 import org.apache.commons.logging.LogFactory;
 
 import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassVisitor;
 import org.objectweb.asm.Label;
 import org.objectweb.asm.MethodVisitor;
 import org.objectweb.asm.Opcodes;
 import org.objectweb.asm.Type;
-import org.objectweb.asm.commons.EmptyVisitor;
+import org.springframework.asm.SpringAsmInfo;
 import org.springframework.util.ClassUtils;
 
 /**
@@ -78,7 +79,7 @@
 	}
 
 	@SuppressWarnings("unchecked")
-	public String[] getParameterNames(Constructor ctor) {
+	public String[] getParameterNames(Constructor<?> ctor) {
 		Class<?> declaringClass = ctor.getDeclaringClass();
 		Map<Member, String[]> map = this.parameterNamesCache.get(declaringClass);
 		if (map == null) {
@@ -136,7 +137,7 @@
 	 * Helper class that inspects all methods (constructor included) and then
 	 * attempts to find the parameter names for that member.
 	 */
-	private static class ParameterNameDiscoveringVisitor extends EmptyVisitor {
+	private static class ParameterNameDiscoveringVisitor extends ClassVisitor {
 
 		private static final String STATIC_CLASS_INIT = "<clinit>";
 
@@ -144,6 +145,7 @@
 		private final Map<Member, String[]> memberMap;
 
 		public ParameterNameDiscoveringVisitor(Class<?> clazz, Map<Member, String[]> memberMap) {
+			super(SpringAsmInfo.ASM_VERSION);
 			this.clazz = clazz;
 			this.memberMap = memberMap;
 		}
@@ -167,7 +169,7 @@
 	}
 
 
-	private static class LocalVariableTableVisitor extends EmptyVisitor {
+	private static class LocalVariableTableVisitor extends MethodVisitor {
 
 		private static final String CONSTRUCTOR = "<init>";
 
@@ -188,6 +190,7 @@
 
 		public LocalVariableTableVisitor(Class<?> clazz, Map<Member, String[]> map, String name, String desc,
 				boolean isStatic) {
+			super(SpringAsmInfo.ASM_VERSION);
 			this.clazz = clazz;
 			this.memberMap = map;
 			this.name = name;
--- a/projects/org.springframework.core/src/main/java/org/springframework/core/ParameterNameDiscoverer.java
+++ b/projects/org.springframework.core/src/main/java/org/springframework/core/ParameterNameDiscoverer.java
@@ -49,6 +49,6 @@
 	 * @return an array of parameter names if the names can be resolved,
 	 * or <code>null</code> if they cannot
 	 */
-	String[] getParameterNames(Constructor ctor);
+	String[] getParameterNames(Constructor<?> ctor);
 
 }
--- a/projects/org.springframework.core/src/main/java/org/springframework/core/type/classreading/AnnotationAttributesReadingVisitor.java
+++ b/projects/org.springframework.core/src/main/java/org/springframework/core/type/classreading/AnnotationAttributesReadingVisitor.java
@@ -27,7 +27,6 @@
 
 import org.objectweb.asm.AnnotationVisitor;
 import org.objectweb.asm.Type;
-import org.objectweb.asm.commons.EmptyVisitor;
 import org.springframework.core.annotation.AnnotationUtils;
 import org.springframework.util.ObjectUtils;
 import org.springframework.util.ReflectionUtils;
@@ -38,7 +37,7 @@
  * @author Juergen Hoeller
  * @since 3.0
  */
-final class AnnotationAttributesReadingVisitor implements AnnotationVisitor {
+final class AnnotationAttributesReadingVisitor extends AnnotationVisitor {
 
 	private final String annotationType;
 
@@ -54,7 +53,7 @@
 	public AnnotationAttributesReadingVisitor(
 			String annotationType, Map<String, Map<String, Object>> attributesMap,
 			Map<String, Set<String>> metaAnnotationMap, ClassLoader classLoader) {
-
+                super(org.springframework.asm.SpringAsmInfo.ASM_VERSION);
 		this.annotationType = annotationType;
 		this.attributesMap = attributesMap;
 		this.metaAnnotationMap = metaAnnotationMap;
@@ -82,11 +81,11 @@
 	}
 
 	public AnnotationVisitor visitAnnotation(String name, String desc) {
-		return new EmptyVisitor();
+		return new EmptyAnnotationVisitor();
 	}
 
 	public AnnotationVisitor visitArray(final String attrName) {
-		return new AnnotationVisitor() {
+		return new AnnotationVisitor(org.springframework.asm.SpringAsmInfo.ASM_VERSION) {
 			public void visit(String name, Object value) {
 				Object newValue = value;
 				Object existingValue = localAttributes.get(attrName);
@@ -103,10 +102,10 @@
 			public void visitEnum(String name, String desc, String value) {
 			}
 			public AnnotationVisitor visitAnnotation(String name, String desc) {
-				return new EmptyVisitor();
+				return new EmptyAnnotationVisitor();
 			}
 			public AnnotationVisitor visitArray(String name) {
-				return new EmptyVisitor();
+				return new EmptyAnnotationVisitor();
 			}
 			public void visitEnd() {
 			}
--- a/projects/org.springframework.core/src/main/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitor.java
+++ b/projects/org.springframework.core/src/main/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitor.java
@@ -22,7 +22,7 @@
 import org.objectweb.asm.FieldVisitor;
 import org.objectweb.asm.MethodVisitor;
 import org.objectweb.asm.Opcodes;
-import org.objectweb.asm.commons.EmptyVisitor;
+import org.springframework.asm.SpringAsmInfo;
 import org.springframework.core.type.ClassMetadata;
 import org.springframework.util.ClassUtils;
 
@@ -35,9 +35,10 @@
  * @author Costin Leau
  * @author Mark Fisher
  * @author Ramnivas Laddad
+ * @author Chris Beams
  * @since 2.5
  */
-class ClassMetadataReadingVisitor implements ClassVisitor, ClassMetadata {
+class ClassMetadataReadingVisitor extends ClassVisitor implements ClassMetadata {
 
 	private String className;
 
@@ -56,6 +57,11 @@
 	private String[] interfaces;
 	
 
+	public ClassMetadataReadingVisitor() {
+		super(SpringAsmInfo.ASM_VERSION);
+	}
+
+
 	public void visit(int version, int access, String name, String signature, String supername, String[] interfaces) {
 		this.className = ClassUtils.convertResourcePathToClassName(name);
 		this.isInterface = ((access & Opcodes.ACC_INTERFACE) != 0);
@@ -87,7 +93,7 @@
 
 	public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
 		// no-op
-		return new EmptyVisitor();
+		return new EmptyAnnotationVisitor();
 	}
 
 	public void visitAttribute(Attribute attr) {
@@ -96,12 +102,12 @@
 
 	public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
 		// no-op
-		return new EmptyVisitor();
+		return new EmptyFieldVisitor();
 	}
 
 	public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
 		// no-op
-		return new EmptyVisitor();
+		return new EmptyMethodVisitor();
 	}
 
 	public void visitEnd() {
@@ -154,3 +160,38 @@
 	}
 
 }
+
+
+class EmptyAnnotationVisitor extends AnnotationVisitor {
+
+	public EmptyAnnotationVisitor() {
+		super(SpringAsmInfo.ASM_VERSION);
+	}
+
+	@Override
+	public AnnotationVisitor visitAnnotation(String name, String desc) {
+		return this;
+	}
+
+	@Override
+	public AnnotationVisitor visitArray(String name) {
+		return this;
+	}
+}
+
+
+class EmptyMethodVisitor extends MethodVisitor {
+
+	public EmptyMethodVisitor() {
+		super(SpringAsmInfo.ASM_VERSION);
+	}
+}
+
+
+class EmptyFieldVisitor extends FieldVisitor {
+
+	public EmptyFieldVisitor() {
+		super(SpringAsmInfo.ASM_VERSION);
+	}
+
+}
--- a/projects/org.springframework.core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java
+++ b/projects/org.springframework.core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java
@@ -20,10 +20,10 @@
 import java.util.Map;
 
 import org.objectweb.asm.AnnotationVisitor;
-import org.objectweb.asm.MethodAdapter;
+import org.objectweb.asm.MethodVisitor;
 import org.objectweb.asm.Opcodes;
 import org.objectweb.asm.Type;
-import org.objectweb.asm.commons.EmptyVisitor;
+import org.springframework.asm.SpringAsmInfo;
 import org.springframework.core.type.MethodMetadata;
 import org.springframework.util.MultiValueMap;
 
@@ -37,7 +37,7 @@
  * @author Costin Leau
  * @since 3.0
  */
-final class MethodMetadataReadingVisitor extends MethodAdapter implements MethodMetadata {
+final class MethodMetadataReadingVisitor extends MethodVisitor implements MethodMetadata {
 
 	private final String name;
 
@@ -53,7 +53,7 @@
 
 	public MethodMetadataReadingVisitor(String name, int access, String declaringClassName, ClassLoader classLoader,
 			MultiValueMap<String, MethodMetadata> methodMetadataMap) {
-		super(new EmptyVisitor());
+		super(SpringAsmInfo.ASM_VERSION);
 		this.name = name;
 		this.access = access;
 		this.declaringClassName = declaringClassName;
