Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove spring-asm and inline ASM 4 into spring-core

ASM 4.0 is generally compatibile with Java 7 classfiles, particularly
including 'invokedynamic' instructions. This is important when
considering that Spring's component-scanning support is internally
ASM-based and it is increasingly likely that component classes having
invokedynamic instructions may be encountered and read by ASM.
This upgrade, then, is primarily preventive in nature.

Changes include:

 - upgrade from ASM 2.2.3 to ASM 4.0

 - adapt to ASM API changes as necessary throughout spring-core,
   resulting in no impact to the public Spring API.

 - remove dedicated spring-asm module

 - use new :spring-core:asmRepackJar task to repackage
   org.objectweb.asm => org.springframework.asm as per usual and write
   repackaged classes directly into spring-core jar

The choice to eliminate the spring-asm module altogether and instead
inline the repackaged classes directly into spring-core is first to
eliminate an otherwise unnecessary second jar. spring-core has a
non-optional dependency on spring-asm meaning it is always on the
application classpath. This change simplifies that situation by
consoliding two jars into one. The second reason for this choice is in
anticipation of upgrading CGLIB to version 3 and inlining it into
spring-core as well. See subsequent commit for details.

Issue: SPR-9669
commit c16f18a5fd659f34d6290b5f2cffe54534b7592a 1 parent 69a3929
@cbeams cbeams authored
Showing with 161 additions and 75 deletions.
  1. +3 −3 .settings/gradle/com.springsource.sts.gradle.core.import.prefs
  2. +2 −2 .settings/gradle/com.springsource.sts.gradle.refresh.prefs
  3. +22 −31 build.gradle
  4. +0 −1  settings.gradle
  5. +0 −11 spring-asm/src/main/java/org/springframework/asm/package-info.java
  6. +11 −4 {spring-asm → spring-core}/src/main/java/org/springframework/asm/SpringAsmInfo.java
  7. +30 −0 spring-core/src/main/java/org/springframework/asm/package-info.java
  8. +22 −0 spring-core/src/main/java/org/springframework/asm/util/package-info.java
  9. +9 −5 spring-core/src/main/java/org/springframework/core/LocalVariableTableParameterNameDiscoverer.java
  10. +2 −2 spring-core/src/main/java/org/springframework/core/ParameterNameDiscoverer.java
  11. +3 −1 spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationAttributesReadingVisitor.java
  12. +47 −6 spring-core/src/main/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitor.java
  13. +4 −4 spring-core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java
  14. +1 −1  spring-core/src/main/java/org/springframework/core/type/classreading/SimpleMetadataReader.java
  15. +1 −0  src/dist/changelog.txt
  16. +4 −4 src/dist/license.txt
View
6 .settings/gradle/com.springsource.sts.gradle.core.import.prefs
@@ -1,9 +1,9 @@
#com.springsource.sts.gradle.core.preferences.GradleImportPreferences
-#Thu Feb 23 14:10:34 CET 2012
+#Thu Aug 9 11:34:43 CEST 2012
enableAfterTasks=true
afterTasks=afterEclipseImport;
enableDependendencyManagement=false
enableBeforeTasks=true
-projects=;spring-aop;spring-asm;spring-aspects;spring-beans;spring-context;spring-context-support;spring-core;spring-expression;spring-instrument;spring-instrument-tomcat;spring-jdbc;spring-jms;spring-orm;spring-oxm;spring-struts;spring-test;spring-tx;spring-web;spring-webmvc;spring-webmvc-portlet;
+projects=;spring-aop;spring-aspects;spring-beans;spring-context;spring-context-support;spring-core;spring-expression;spring-instrument;spring-instrument-tomcat;spring-jdbc;spring-jms;spring-orm;spring-oxm;spring-struts;spring-test;spring-tx;spring-web;spring-webmvc;spring-webmvc-portlet;
enableDSLD=false
-beforeTasks=cleanEclipse;eclipse;\:spring-asm\:jar;\:spring-oxm\:compileTestJava;
+beforeTasks=cleanEclipse;eclipse;\:spring-oxm\:compileTestJava;
View
4 .settings/gradle/com.springsource.sts.gradle.refresh.prefs
@@ -1,9 +1,9 @@
#com.springsource.sts.gradle.core.actions.GradleRefreshPreferences
-#Thu Feb 23 14:12:55 CET 2012
+#Thu Aug 9 11:34:43 CEST 2012
enableAfterTasks=true
afterTasks=afterEclipseImport;
useHierarchicalNames=false
enableBeforeTasks=true
addResourceFilters=false
enableDSLD=false
-beforeTasks=cleanEclipse;eclipse;\:spring-asm\:jar;\:spring-oxm\:compileTestJava;
+beforeTasks=cleanEclipse;eclipse;\:spring-oxm\:compileTestJava;
View
53 build.gradle
@@ -88,30 +88,27 @@ configure(subprojects) { subproject ->
}
-project("spring-asm") {
- description = 'Spring ASM'
- ext.asmVersion = '2.2.3'
+project('spring-core') {
+ description = 'Spring Core'
+
+ def asmVersion = '4.0'
configurations {
- asm
jarjar
- }
- dependencies {
- asm "asm:asm:${asmVersion}@jar", "asm:asm-commons:${asmVersion}@jar"
- jarjar 'com.googlecode.jarjar:jarjar:1.3'
+ asm
}
- task repackageAsm(type: Jar) { jar ->
- jar.baseName = "asm-repack"
- jar.version = asmVersion
+ task asmRepackJar(type: Jar) { repackJar ->
+ repackJar.baseName = "spring-asm-repack"
+ repackJar.version = asmVersion
doLast() {
project.ant {
taskdef name: "jarjar", classname: "com.tonicsystems.jarjar.JarJarTask",
classpath: configurations.jarjar.asPath
- jarjar(destfile: archivePath, index: "true", filesetmanifest: "merge") {
- configurations.asm.each { jarfile ->
- zipfileset(src: jarfile)
+ jarjar(destfile: repackJar.archivePath) {
+ configurations.asm.each { originalJar ->
+ zipfileset(src: originalJar)
}
rule(pattern: 'org.objectweb.asm.**', result: 'org.springframework.asm.@1')
}
@@ -119,24 +116,11 @@ project("spring-asm") {
}
}
- jar {
- dependsOn repackageAsm
- from(zipTree(repackageAsm.archivePath)) {
- exclude 'META-INF/INDEX.LIST'
- }
- }
-}
-
-project('spring-core') {
- description = 'Spring Core'
dependencies {
- // depend on spring-asm project in order to have it show up as a
- // <dependency> in the generated pom
- compile project(":spring-asm")
- // depend directly on the spring-asm jar to avoid errors in Eclipse/STS
- compile files(project(":spring-asm").jar.archivePath) {
- builtBy project(":spring-asm").jar
- }
+ asm "org.ow2.asm:asm:${asmVersion}@jar", "org.ow2.asm:asm-commons:${asmVersion}@jar"
+ jarjar 'com.googlecode.jarjar:jarjar:1.3'
+
+ compile files(asmRepackJar)
compile "commons-logging:commons-logging:1.1.1"
compile("org.aspectj:aspectjweaver:${aspectjVersion}", optional)
compile("net.sf.jopt-simple:jopt-simple:3.0") { dep ->
@@ -153,6 +137,13 @@ project('spring-core') {
testCompile "xmlunit:xmlunit:1.2"
testCompile "org.codehaus.woodstox:wstx-asl:3.2.7"
}
+
+ jar {
+ // inline all repackaged asm classes directly into the spring-core jar
+ from(asmRepackJar) {
+ exclude 'META-INF/**'
+ }
+ }
}
project('spring-beans') {
View
1  settings.gradle
@@ -1,7 +1,6 @@
rootProject.name = 'spring'
include 'spring-aop'
-include 'spring-asm'
include 'spring-aspects'
include 'spring-beans'
include 'spring-context'
View
11 spring-asm/src/main/java/org/springframework/asm/package-info.java
@@ -1,11 +0,0 @@
-/**
- * Spring's repackaging of {@code org.objectweb.asm.*} (for internal use only).
- * <p>This repackaging technique avoids any potential conflicts with
- * dependencies on ASM at the application level or from other third-party
- * libraries and frameworks.
- * <p>As this repackaging happens at the classfile level, sources and Javadoc
- * are not available here. See the original ObjectWeb
- * <a href="http://asm.ow2.org/asm223/javadoc/user">ASM 2.2.3 Javadoc</a>
- * for details when working with these classes.
- */
-package org.springframework.asm;
View
15 ...n/java/org/springframework/asm/SpringAsmInfo.java → ...n/java/org/springframework/asm/SpringAsmInfo.java
@@ -17,10 +17,9 @@
package org.springframework.asm;
/**
- * Placeholder to allow Javadoc generation. Required because
- * <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4492654">this bug</a>
- * does not allow the generation of Javadoc for packages having only a
- * {@code package-info.java} file.
+ * 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}.
*
@@ -28,4 +27,12 @@
* @since 3.2
*/
public final class SpringAsmInfo {
+
+ /**
+ * The ASM version used internally throughout the framework.
+ *
+ * @see Opcodes#ASM4
+ */
+ public static final int ASM_VERSION = Opcodes.ASM4;
+
}
View
30 spring-core/src/main/java/org/springframework/asm/package-info.java
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+/**
+ * Spring's repackaging of <a href="http://asm.ow2.org">org.objectweb.asm 4</a> (for
+ * internal use only).
+ * <p>This repackaging technique avoids any potential conflicts with
+ * dependencies on ASM at the application level or from other third-party
+ * libraries and frameworks.
+ * <p>As this repackaging happens at the classfile level, sources and Javadoc
+ * are not available here. See the original ObjectWeb
+ * <a href="http://asm.ow2.org/asm40/javadoc/user">ASM 4 Javadoc</a>
+ * for details when working with these classes.
+ *
+ * @since 3.2
+ */
+package org.springframework.asm;
View
22 spring-core/src/main/java/org/springframework/asm/util/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+/**
+ * Dummy implementations of asm-util classes (for internal use only).
+ *
+ * @since 3.2
+ */
+package org.springframework.asm.util;
View
14 spring-core/src/main/java/org/springframework/core/LocalVariableTableParameterNameDiscoverer.java
@@ -29,11 +29,12 @@
import org.apache.commons.logging.LogFactory;
import org.springframework.asm.ClassReader;
+import org.springframework.asm.ClassVisitor;
import org.springframework.asm.Label;
import org.springframework.asm.MethodVisitor;
import org.springframework.asm.Opcodes;
+import org.springframework.asm.SpringAsmInfo;
import org.springframework.asm.Type;
-import org.springframework.asm.commons.EmptyVisitor;
import org.springframework.util.ClassUtils;
/**
@@ -49,6 +50,7 @@
* @author Adrian Colyer
* @author Costin Leau
* @author Juergen Hoeller
+ * @author Chris Beams
* @since 2.0
*/
public class LocalVariableTableParameterNameDiscoverer implements ParameterNameDiscoverer {
@@ -77,7 +79,7 @@
return null;
}
- 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) {
@@ -110,7 +112,7 @@
try {
ClassReader classReader = new ClassReader(is);
Map<Member, String[]> map = new ConcurrentHashMap<Member, String[]>();
- classReader.accept(new ParameterNameDiscoveringVisitor(clazz, map), false);
+ classReader.accept(new ParameterNameDiscoveringVisitor(clazz, map), 0);
return map;
}
catch (IOException ex) {
@@ -135,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>";
@@ -143,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;
}
@@ -166,7 +169,7 @@ private static boolean isStatic(int access) {
}
- private static class LocalVariableTableVisitor extends EmptyVisitor {
+ private static class LocalVariableTableVisitor extends MethodVisitor {
private static final String CONSTRUCTOR = "<init>";
@@ -187,6 +190,7 @@ private static boolean isStatic(int access) {
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;
View
4 spring-core/src/main/java/org/springframework/core/ParameterNameDiscoverer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2006 the original author or authors.
+ * 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.
@@ -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);
}
View
4 ...ng-core/src/main/java/org/springframework/core/type/classreading/AnnotationAttributesReadingVisitor.java
@@ -29,6 +29,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.asm.AnnotationVisitor;
+import org.springframework.asm.SpringAsmInfo;
import org.springframework.asm.Type;
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.annotation.AnnotationUtils;
@@ -41,7 +42,7 @@
* @author Juergen Hoeller
* @since 3.1.1
*/
-abstract class AbstractRecursiveAnnotationVisitor implements AnnotationVisitor {
+abstract class AbstractRecursiveAnnotationVisitor extends AnnotationVisitor {
protected final Log logger = LogFactory.getLog(this.getClass());
@@ -51,6 +52,7 @@
public AbstractRecursiveAnnotationVisitor(ClassLoader classLoader, AnnotationAttributes attributes) {
+ super(SpringAsmInfo.ASM_VERSION);
this.classLoader = classLoader;
this.attributes = attributes;
}
View
53 spring-core/src/main/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2009 the original author or authors.
+ * 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.
@@ -25,7 +25,7 @@
import org.springframework.asm.FieldVisitor;
import org.springframework.asm.MethodVisitor;
import org.springframework.asm.Opcodes;
-import org.springframework.asm.commons.EmptyVisitor;
+import org.springframework.asm.SpringAsmInfo;
import org.springframework.core.type.ClassMetadata;
import org.springframework.util.ClassUtils;
@@ -38,9 +38,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;
@@ -61,6 +62,11 @@
private Set<String> memberClassNames = new LinkedHashSet<String>();
+ 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);
@@ -99,7 +105,7 @@ public void visitSource(String source, String debug) {
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
// no-op
- return new EmptyVisitor();
+ return new EmptyAnnotationVisitor();
}
public void visitAttribute(Attribute attr) {
@@ -108,12 +114,12 @@ public void visitAttribute(Attribute attr) {
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() {
@@ -170,3 +176,38 @@ public String getSuperClassName() {
}
}
+
+
+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);
+ }
+
+}
View
8 spring-core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java
@@ -20,10 +20,10 @@
import java.util.Map;
import org.springframework.asm.AnnotationVisitor;
-import org.springframework.asm.MethodAdapter;
+import org.springframework.asm.MethodVisitor;
import org.springframework.asm.Opcodes;
+import org.springframework.asm.SpringAsmInfo;
import org.springframework.asm.Type;
-import org.springframework.asm.commons.EmptyVisitor;
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.type.MethodMetadata;
import org.springframework.util.MultiValueMap;
@@ -39,7 +39,7 @@
* @author Chris Beams
* @since 3.0
*/
-final class MethodMetadataReadingVisitor extends MethodAdapter implements MethodMetadata {
+final class MethodMetadataReadingVisitor extends MethodVisitor implements MethodMetadata {
private final String name;
@@ -55,7 +55,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;
View
2  spring-core/src/main/java/org/springframework/core/type/classreading/SimpleMetadataReader.java
@@ -56,7 +56,7 @@
}
AnnotationMetadataReadingVisitor visitor = new AnnotationMetadataReadingVisitor(classLoader);
- classReader.accept(visitor, true);
+ classReader.accept(visitor, ClassReader.SKIP_DEBUG);
this.annotationMetadata = visitor;
// (since AnnotationMetadataReader extends ClassMetadataReadingVisitor)
View
1  src/dist/changelog.txt
@@ -36,6 +36,7 @@ Changes in version 3.2 M2 (2012-08-xx)
* introduced countRowsInTableWhere() and dropTables() in JdbcTestUtils (SPR-9235)
* introduced JdbcTemplate in tx base classes in the TestContext framework (SPR-8990)
* introduced countRowsInTableWhere() and dropTables() in tx base test classes (SPR-9665)
+* inlined ASM 4.0 into spring-core, removed spring-asm subproject and jar (SPR-9669)
Changes in version 3.2 M1 (2012-05-28)
View
8 src/dist/license.txt
@@ -202,18 +202,18 @@
=======================================================================
-SPRING FRAMEWORK 3.1 SUBCOMPONENTS:
+SPRING FRAMEWORK 3.2 SUBCOMPONENTS:
-Spring Framework 3.1 includes a number of subcomponents with
+Spring Framework 3.2 includes a number of subcomponents with
separate copyright notices and license terms. The product that
includes this file does not necessarily use all the open source
subcomponents referred to below. Your use of the source
code for these subcomponents is subject to the terms and
conditions of the following licenses.
->>> asm-2.2.3:
+>>> asm-4.0:
-Copyright (c) 2000-2005 INRIA, France Telecom
+Copyright (c) 2000-2011 INRIA, France Telecom
All rights reserved.
Redistribution and use in source and binary forms, with or without
Please sign in to comment.
Something went wrong with that request. Please try again.