xbean/0001-Unshade-ASM.patch
2014-11-21 11:56:16 +01:00

402 lines
17 KiB
Diff

From 8d151d56250e13e5bdc21bc0df1e2f334010f268 Mon Sep 17 00:00:00 2001
From: Mikolaj Izdebski <mizdebsk@redhat.com>
Date: Fri, 21 Nov 2014 09:39:00 +0100
Subject: [PATCH 1/4] Unshade ASM
---
pom.xml | 23 ------------
xbean-finder/pom.xml | 5 ---
.../org/apache/xbean/finder/AbstractFinder.java | 30 ++++++++-------
.../org/apache/xbean/finder/AnnotationFinder.java | 43 +++++++++++-----------
xbean-reflect/pom.xml | 13 -------
.../xbean/recipe/AsmParameterNameLoader.java | 6 ++-
.../org/apache/xbean/recipe/ReflectionUtil.java | 8 +---
.../xbean/recipe/XbeanAsmParameterNameLoader.java | 18 +++++----
8 files changed, 53 insertions(+), 93 deletions(-)
diff --git a/pom.xml b/pom.xml
index dd4d7ee..0c17645 100644
--- a/pom.xml
+++ b/pom.xml
@@ -217,26 +217,6 @@
<artifactId>xbean-telnet</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>org.apache.xbean</groupId>
- <artifactId>xbean-asm-shaded</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.xbean</groupId>
- <artifactId>xbean-asm5-shaded</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.xbean</groupId>
- <artifactId>xbean-asm-util</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.xbean</groupId>
- <artifactId>xbean-finder-shaded</artifactId>
- <version>${project.version}</version>
- </dependency>
<!-- external dependencies -->
@@ -412,7 +392,6 @@
<module>xbean-classloader</module>
<module>xbean-classpath</module>
<module>xbean-bundleutils</module>
- <module>xbean-asm-util</module>
<module>xbean-finder</module>
<module>xbean-naming</module>
<module>xbean-reflect</module>
@@ -420,8 +399,6 @@
<module>xbean-spring</module>
<module>xbean-telnet</module>
<module>maven-xbean-plugin</module>
- <module>xbean-asm5-shaded</module>
- <module>xbean-finder-shaded</module>
</modules>
<reporting>
diff --git a/xbean-finder/pom.xml b/xbean-finder/pom.xml
index 6048ac3..4f20b5f 100644
--- a/xbean-finder/pom.xml
+++ b/xbean-finder/pom.xml
@@ -58,11 +58,6 @@
<version>4.3.1</version>
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>org.apache.xbean</groupId>
- <artifactId>xbean-asm-util</artifactId>
- <version>${project.version}</version>
- </dependency>
</dependencies>
<build>
<plugins>
diff --git a/xbean-finder/src/main/java/org/apache/xbean/finder/AbstractFinder.java b/xbean-finder/src/main/java/org/apache/xbean/finder/AbstractFinder.java
index 8beb72b..164a490 100644
--- a/xbean-finder/src/main/java/org/apache/xbean/finder/AbstractFinder.java
+++ b/xbean-finder/src/main/java/org/apache/xbean/finder/AbstractFinder.java
@@ -34,10 +34,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.xbean.asm5.original.commons.EmptyVisitor;
import org.apache.xbean.finder.util.SingleLinkedList;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
@@ -908,15 +908,17 @@ public abstract class AbstractFinder implements IAnnotationFinder {
}
}
- public class InfoBuildingVisitor extends EmptyVisitor {
+ public class InfoBuildingVisitor extends ClassVisitor {
private Info info;
private String path;
public InfoBuildingVisitor(String path) {
+ super(Opcodes.ASM5);
this.path = path;
}
public InfoBuildingVisitor(Info info) {
+ super(Opcodes.ASM5);
this.info = info;
}
@@ -949,7 +951,7 @@ public abstract class AbstractFinder implements IAnnotationFinder {
AnnotationInfo annotationInfo = new AnnotationInfo(desc);
info.getAnnotations().add(annotationInfo);
getAnnotationInfos(annotationInfo.getName()).add(info);
- return new InfoBuildingVisitor(annotationInfo).annotationVisitor();
+ return null;
}
@Override
@@ -957,7 +959,7 @@ public abstract class AbstractFinder implements IAnnotationFinder {
ClassInfo classInfo = ((ClassInfo) info);
FieldInfo fieldInfo = new FieldInfo(classInfo, name, desc);
classInfo.getFields().add(fieldInfo);
- return new InfoBuildingVisitor(fieldInfo).fieldVisitor();
+ return null;
}
@Override
@@ -965,16 +967,16 @@ public abstract class AbstractFinder implements IAnnotationFinder {
ClassInfo classInfo = ((ClassInfo) info);
MethodInfo methodInfo = new MethodInfo(classInfo, name, desc);
classInfo.getMethods().add(methodInfo);
- return new InfoBuildingVisitor(methodInfo).methodVisitor();
- }
-
- @Override
- public AnnotationVisitor visitMethodParameterAnnotation(int param, String desc, boolean visible) {
- MethodInfo methodInfo = ((MethodInfo) info);
- List<AnnotationInfo> annotationInfos = methodInfo.getParameterAnnotations(param);
- AnnotationInfo annotationInfo = new AnnotationInfo(desc);
- annotationInfos.add(annotationInfo);
- return new InfoBuildingVisitor(annotationInfo).annotationVisitor();
+ return new MethodVisitor(Opcodes.ASM5) {
+ @Override
+ public AnnotationVisitor visitParameterAnnotation(int param, String desc, boolean visible) {
+ MethodInfo methodInfo = ((MethodInfo) info);
+ List<AnnotationInfo> annotationInfos = methodInfo.getParameterAnnotations(param);
+ AnnotationInfo annotationInfo = new AnnotationInfo(desc);
+ annotationInfos.add(annotationInfo);
+ return null;
+ }
+ };
}
}
diff --git a/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotationFinder.java b/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotationFinder.java
index ea96d78..48b2262 100644
--- a/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotationFinder.java
+++ b/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotationFinder.java
@@ -20,13 +20,13 @@
package org.apache.xbean.finder;
-import org.apache.xbean.asm5.original.commons.EmptyVisitor;
import org.apache.xbean.finder.archive.Archive;
import org.apache.xbean.finder.util.Classes;
import org.apache.xbean.finder.util.SingleLinkedList;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.Attribute;
import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
@@ -1755,13 +1755,15 @@ public class AnnotationFinder implements IAnnotationFinder {
initAnnotationInfos(annotationInfo.getName()).add(info);
}
- public class InfoBuildingVisitor extends EmptyVisitor {
+ public class InfoBuildingVisitor extends ClassVisitor {
private Info info;
public InfoBuildingVisitor() {
+ super(Opcodes.ASM5);
}
public InfoBuildingVisitor(Info info) {
+ super(Opcodes.ASM5);
this.info = info;
}
@@ -1809,7 +1811,7 @@ public class AnnotationFinder implements IAnnotationFinder {
AnnotationInfo annotationInfo = new AnnotationInfo(desc);
info.getAnnotations().add(annotationInfo);
index(annotationInfo, info);
- return new InfoBuildingVisitor(annotationInfo).annotationVisitor();
+ return null;
}
@Override
@@ -1817,32 +1819,31 @@ public class AnnotationFinder implements IAnnotationFinder {
ClassInfo classInfo = ((ClassInfo) info);
FieldInfo fieldInfo = new FieldInfo(classInfo, name, desc);
classInfo.getFields().add(fieldInfo);
- return new InfoBuildingVisitor(fieldInfo).fieldVisitor();
+ return null;
}
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
ClassInfo classInfo = ((ClassInfo) info);
- MethodInfo methodInfo = new MethodInfo(classInfo, name, desc);
+ final MethodInfo methodInfo = new MethodInfo(classInfo, name, desc);
classInfo.getMethods().add(methodInfo);
- return new InfoBuildingVisitor(methodInfo).methodVisitor();
+ return new MethodVisitor(Opcodes.ASM5) {
+ @Override
+ public AnnotationVisitor visitParameterAnnotation(int param, String desc, boolean visible) {
+ List<AnnotationInfo> annotationInfos = methodInfo.getParameterAnnotations(param);
+ AnnotationInfo annotationInfo = new AnnotationInfo(desc);
+ annotationInfos.add(annotationInfo);
+
+ ParameterInfo parameterInfo = new ParameterInfo(methodInfo, param);
+ methodInfo.getParameters().add(parameterInfo);
+ index(annotationInfo, parameterInfo);
+
+ return null;
+ }
+ };
}
-
- @Override
- public AnnotationVisitor visitMethodParameterAnnotation(int param, String desc, boolean visible) {
- MethodInfo methodInfo = ((MethodInfo) info);
- List<AnnotationInfo> annotationInfos = methodInfo.getParameterAnnotations(param);
- AnnotationInfo annotationInfo = new AnnotationInfo(desc);
- annotationInfos.add(annotationInfo);
-
- ParameterInfo parameterInfo = new ParameterInfo(methodInfo, param);
- methodInfo.getParameters().add(parameterInfo);
- index(annotationInfo, parameterInfo);
-
- return new InfoBuildingVisitor(annotationInfo).annotationVisitor();
- }
}
public static class GenericAwareInfoBuildingVisitor extends SignatureVisitor {
@@ -2007,4 +2008,4 @@ public class AnnotationFinder implements IAnnotationFinder {
}
-}
\ No newline at end of file
+}
diff --git a/xbean-reflect/pom.xml b/xbean-reflect/pom.xml
index e9e51c7..0b80389 100644
--- a/xbean-reflect/pom.xml
+++ b/xbean-reflect/pom.xml
@@ -47,19 +47,6 @@
<optional>true</optional>
</dependency>
<dependency>
- <groupId>org.apache.xbean</groupId>
- <artifactId>xbean-asm-util</artifactId>
- <scope>provided</scope>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.apache.xbean</groupId>
- <artifactId>xbean-asm5-shaded</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- <optional>true</optional>
- </dependency>
- <dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.12</version>
diff --git a/xbean-reflect/src/main/java/org/apache/xbean/recipe/AsmParameterNameLoader.java b/xbean-reflect/src/main/java/org/apache/xbean/recipe/AsmParameterNameLoader.java
index 6859cad..f513b77 100644
--- a/xbean-reflect/src/main/java/org/apache/xbean/recipe/AsmParameterNameLoader.java
+++ b/xbean-reflect/src/main/java/org/apache/xbean/recipe/AsmParameterNameLoader.java
@@ -17,8 +17,8 @@
*/
package org.apache.xbean.recipe;
-import org.apache.xbean.asm5.original.commons.EmptyVisitor;
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;
@@ -211,7 +211,7 @@ public class AsmParameterNameLoader implements ParameterNameLoader {
}
}
- private static class AllParameterNamesDiscoveringVisitor extends EmptyVisitor {
+ private static class AllParameterNamesDiscoveringVisitor extends ClassVisitor {
private final Map<Constructor,List<String>> constructorParameters = new HashMap<Constructor,List<String>>();
private final Map<Method,List<String>> methodParameters = new HashMap<Method,List<String>>();
private final Map<String,Exception> exceptions = new HashMap<String,Exception>();
@@ -220,6 +220,7 @@ public class AsmParameterNameLoader implements ParameterNameLoader {
private final Map<String,Constructor> constructorMap = new HashMap<String,Constructor>();
public AllParameterNamesDiscoveringVisitor(Class type, String methodName) {
+ super(Opcodes.ASM5);
this.methodName = methodName;
List<Method> methods = new ArrayList<Method>(Arrays.asList(type.getMethods()));
@@ -232,6 +233,7 @@ public class AsmParameterNameLoader implements ParameterNameLoader {
}
public AllParameterNamesDiscoveringVisitor(Class type) {
+ super(Opcodes.ASM5);
this.methodName = "<init>";
List<Constructor> constructors = new ArrayList<Constructor>(Arrays.asList(type.getConstructors()));
diff --git a/xbean-reflect/src/main/java/org/apache/xbean/recipe/ReflectionUtil.java b/xbean-reflect/src/main/java/org/apache/xbean/recipe/ReflectionUtil.java
index 84ded16..39dfd58 100644
--- a/xbean-reflect/src/main/java/org/apache/xbean/recipe/ReflectionUtil.java
+++ b/xbean-reflect/src/main/java/org/apache/xbean/recipe/ReflectionUtil.java
@@ -41,13 +41,7 @@ public final class ReflectionUtil {
private static ParameterNameLoader parameterNamesLoader;
static {
- if (isClassAvailable("org.apache.xbean.asm5.ClassReader")) {
- parameterNamesLoader = new XbeanAsmParameterNameLoader();
- } else if (isClassAvailable("org.objectweb.asm.ClassReader")) {
- parameterNamesLoader = new AsmParameterNameLoader();
- } else if (isClassAvailable("org.apache.xbean.asm.ClassReader") || isClassAvailable("org.apache.xbean.asm4.ClassReader")) {
- throw new RuntimeException("Your xbean-asm-shade is too old, please upgrade to xbean-asm5-shade");
- }
+ parameterNamesLoader = new XbeanAsmParameterNameLoader();
}
private ReflectionUtil() {
diff --git a/xbean-reflect/src/main/java/org/apache/xbean/recipe/XbeanAsmParameterNameLoader.java b/xbean-reflect/src/main/java/org/apache/xbean/recipe/XbeanAsmParameterNameLoader.java
index 4a89c44..6242dd3 100644
--- a/xbean-reflect/src/main/java/org/apache/xbean/recipe/XbeanAsmParameterNameLoader.java
+++ b/xbean-reflect/src/main/java/org/apache/xbean/recipe/XbeanAsmParameterNameLoader.java
@@ -17,12 +17,12 @@
*/
package org.apache.xbean.recipe;
-import org.apache.xbean.asm5.shade.commons.EmptyVisitor;
-import org.apache.xbean.asm5.ClassReader;
-import org.apache.xbean.asm5.Label;
-import org.apache.xbean.asm5.MethodVisitor;
-import org.apache.xbean.asm5.Opcodes;
-import org.apache.xbean.asm5.Type;
+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 java.io.IOException;
import java.io.InputStream;
@@ -211,7 +211,7 @@ public class XbeanAsmParameterNameLoader implements ParameterNameLoader {
}
}
- private static class AllParameterNamesDiscoveringVisitor extends EmptyVisitor {
+ private static class AllParameterNamesDiscoveringVisitor extends ClassVisitor {
private final Map<Constructor,List<String>> constructorParameters = new HashMap<Constructor,List<String>>();
private final Map<Method,List<String>> methodParameters = new HashMap<Method,List<String>>();
private final Map<String,Exception> exceptions = new HashMap<String,Exception>();
@@ -220,6 +220,7 @@ public class XbeanAsmParameterNameLoader implements ParameterNameLoader {
private final Map<String,Constructor> constructorMap = new HashMap<String,Constructor>();
public AllParameterNamesDiscoveringVisitor(Class type, String methodName) {
+ super(Opcodes.ASM5);
this.methodName = methodName;
List<Method> methods = new ArrayList<Method>(Arrays.asList(type.getMethods()));
@@ -232,6 +233,7 @@ public class XbeanAsmParameterNameLoader implements ParameterNameLoader {
}
public AllParameterNamesDiscoveringVisitor(Class type) {
+ super(Opcodes.ASM5);
this.methodName = "<init>";
List<Constructor> constructors = new ArrayList<Constructor>(Arrays.asList(type.getConstructors()));
@@ -312,4 +314,4 @@ public class XbeanAsmParameterNameLoader implements ParameterNameLoader {
return null;
}
}
-}
\ No newline at end of file
+}
--
1.9.3