You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by db...@apache.org on 2012/06/06 04:12:24 UTC

svn commit: r1346709 - /commons/sandbox/classscan/branches/commons-finder/src/main/java/org/apache/commons/classscan/finder/AnnotationFinder.java

Author: dblevins
Date: Wed Jun  6 02:12:23 2012
New Revision: 1346709

URL: http://svn.apache.org/viewvc?rev=1346709&view=rev
Log:
Trimmed trivial asm references from Info code

Modified:
    commons/sandbox/classscan/branches/commons-finder/src/main/java/org/apache/commons/classscan/finder/AnnotationFinder.java

Modified: commons/sandbox/classscan/branches/commons-finder/src/main/java/org/apache/commons/classscan/finder/AnnotationFinder.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/branches/commons-finder/src/main/java/org/apache/commons/classscan/finder/AnnotationFinder.java?rev=1346709&r1=1346708&r2=1346709&view=diff
==============================================================================
--- commons/sandbox/classscan/branches/commons-finder/src/main/java/org/apache/commons/classscan/finder/AnnotationFinder.java (original)
+++ commons/sandbox/classscan/branches/commons-finder/src/main/java/org/apache/commons/classscan/finder/AnnotationFinder.java Wed Jun  6 02:12:23 2012
@@ -1223,30 +1223,28 @@ public class AnnotationFinder implements
 
     public static class MethodInfo extends Annotatable implements Info {
         private final ClassInfo declaringClass;
-        private final String descriptor;
         private final String name;
         private final List<List<AnnotationInfo>> parameterAnnotations = new ArrayList<List<AnnotationInfo>>();
+        private final List<String> parameters = new SingleLinkedList<String>();
         private Member method;
 
         public MethodInfo(ClassInfo info, Constructor constructor) {
             super(constructor);
             this.declaringClass = info;
             this.name = "<init>";
-            this.descriptor = null;
         }
 
         public MethodInfo(ClassInfo info, Method method) {
             super(method);
             this.declaringClass = info;
             this.name = method.getName();
-            this.descriptor = method.getReturnType().getName();
             this.method = method;
         }
 
-        public MethodInfo(ClassInfo declarignClass, String name, String descriptor) {
+        public MethodInfo(ClassInfo declarignClass, String name, List<String> params) {
             this.declaringClass = declarignClass;
             this.name = name;
-            this.descriptor = descriptor;
+            this.parameters.addAll(params);
         }
 
         @Override
@@ -1298,13 +1296,10 @@ public class AnnotationFinder implements
         }
 
         private Method toMethod() throws ClassNotFoundException {
-            org.objectweb.asm.commons.Method method = new org.objectweb.asm.commons.Method(name, descriptor);
-
             Class<?> clazz = this.declaringClass.get();
             final List<Class> parameterTypes = new ArrayList<Class>();
 
-            for (Type type : method.getArgumentTypes()) {
-                String paramType = type.getClassName();
+            for (String paramType : parameters) {
                 try {
                     parameterTypes.add(Classes.forName(paramType, clazz.getClassLoader()));
                 } catch (ClassNotFoundException cnfe) {
@@ -1410,7 +1405,6 @@ public class AnnotationFinder implements
         }
 
         public AnnotationInfo(String name) {
-            name = Type.getType(name).getClassName();
             this.name = name.intern();
         }
 
@@ -1535,7 +1529,8 @@ public class AnnotationFinder implements
 
         @Override
         public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
-            AnnotationInfo annotationInfo = new AnnotationInfo(desc);
+            final String name = Type.getType(desc).getClassName();
+            AnnotationInfo annotationInfo = new AnnotationInfo(name);
             info.getAnnotations().add(annotationInfo);
             index(annotationInfo, info);
             return new InfoBuildingVisitor(annotationInfo);
@@ -1551,8 +1546,14 @@ public class AnnotationFinder implements
 
         @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 ClassInfo classInfo = ((ClassInfo) info);
+            final List<String> params = new ArrayList<String>();
+            org.objectweb.asm.commons.Method method = new org.objectweb.asm.commons.Method(name, desc);
+            for (Type type : method.getArgumentTypes()) {
+                params.add(type.getClassName());
+            }
+
+            MethodInfo methodInfo = new MethodInfo(classInfo, name, params);
 
             classInfo.getMethods().add(methodInfo);
             return new InfoBuildingVisitor(methodInfo);
@@ -1561,9 +1562,10 @@ public class AnnotationFinder implements
 
         @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);
+            final MethodInfo methodInfo = ((MethodInfo) info);
+            final List<AnnotationInfo> annotationInfos = methodInfo.getParameterAnnotations(param);
+            final String name = Type.getType(desc).getClassName();
+            final AnnotationInfo annotationInfo = new AnnotationInfo(name);
             annotationInfos.add(annotationInfo);
             return new InfoBuildingVisitor(annotationInfo);
         }