Blob Blame History Raw
From aaf9dad09a9a26c5de3c2910d910b24a258b0b1d Mon Sep 17 00:00:00 2001
From: Michael Simacek <msimacek@redhat.com>
Date: Tue, 1 Dec 2015 12:36:21 +0100
Subject: [PATCH 1/3] Unshade ASM

---
 .../org/apache/xbean/finder/AbstractFinder.java    | 31 ++++++++--------
 .../org/apache/xbean/finder/AnnotationFinder.java  | 43 +++++++++++-----------
 .../xbean/recipe/XbeanAsmParameterNameLoader.java  | 16 ++++----
 3 files changed, 46 insertions(+), 44 deletions(-)

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 6bf1f3c..fab8b88 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,24 +959,23 @@ 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
         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();
-        }
-
-        @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) {
+                    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 7d68cd9..6454aa1 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;
@@ -1790,13 +1790,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;
         }
 
@@ -1844,7 +1846,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
@@ -1852,32 +1854,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 {
@@ -2042,4 +2043,4 @@ public class AnnotationFinder implements IAnnotationFinder {
 
     }
 
-}
\ No newline at end of file
+}
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 dea2f2a..dbbfb51 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,13 +17,6 @@
  */
 package org.apache.xbean.recipe;
 
-import org.apache.xbean.asm5.ClassReader;
-import org.apache.xbean.asm5.ClassVisitor;
-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 java.io.IOException;
 import java.io.InputStream;
 import java.lang.reflect.Constructor;
@@ -37,6 +30,13 @@ import java.util.List;
 import java.util.Map;
 import java.util.WeakHashMap;
 
+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;
+
 /**
  * Implementation of ParameterNameLoader that uses ASM to read the parameter names from the local variable table in the
  * class byte code.
@@ -314,4 +314,4 @@ public class XbeanAsmParameterNameLoader implements ParameterNameLoader {
             return null;
         }
     }
-}
\ No newline at end of file
+}
-- 
2.5.0