You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@river.apache.org by pe...@apache.org on 2009/09/26 03:10:57 UTC

svn commit: r819080 - /incubator/river/jtsk/trunk/src/com/sun/jini/tool/classdepend/AbstractDependencyVisitor.java

Author: peter_firmstone
Date: Sat Sep 26 01:10:57 2009
New Revision: 819080

URL: http://svn.apache.org/viewvc?rev=819080&view=rev
Log:
Changes to cleanly support Annotations and Generic Types in bytecode River-163 Resolution

Modified:
    incubator/river/jtsk/trunk/src/com/sun/jini/tool/classdepend/AbstractDependencyVisitor.java

Modified: incubator/river/jtsk/trunk/src/com/sun/jini/tool/classdepend/AbstractDependencyVisitor.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/com/sun/jini/tool/classdepend/AbstractDependencyVisitor.java?rev=819080&r1=819079&r2=819080&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/com/sun/jini/tool/classdepend/AbstractDependencyVisitor.java (original)
+++ incubator/river/jtsk/trunk/src/com/sun/jini/tool/classdepend/AbstractDependencyVisitor.java Sat Sep 26 01:10:57 2009
@@ -30,6 +30,8 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 import org.objectweb.asm.AnnotationVisitor;
 import org.objectweb.asm.ClassVisitor;
 import org.objectweb.asm.FieldVisitor;
@@ -126,11 +128,28 @@
         addNameInternal(owner);
         addDesc(desc);
     }
-
+    
+    String pattern = "^\\[{0,2}L{0,1}(\\w+[/.]{1}[\\w$\\d/.]+);{0,1}$";
+    Pattern arrayOfObjects = Pattern.compile(pattern);
     public void visitMethodInsn(int opcode, String owner, String name,
 				String desc)
     {
-        addNameInternal(owner);
+        /* This filters out Generic's and primitive owners.
+         *
+         * Also when the owner is an array, containing Objects and
+         * the method name is clone(), (I think it's got something to do
+         * with cloning array's, this must be a new java 5 language feature
+         * I tested 1.4 code without this ever occurring)      
+         * we can't get the Object's type
+         * using Type.getType(owner) due to the nature of 
+         * the ASM Core API requiring bytecode be read sequentially.
+         * This only occurs with clone() which returns java.lang.Object
+         */
+        Matcher match = arrayOfObjects.matcher(owner);
+        while (match.find()){
+            String object = match.group(1);
+            addNameInternal(object);
+        } 
         addMethodDesc(desc);
     }
 
@@ -187,7 +206,7 @@
     }
 
     public void visitInnerClassType(String name) {
-        addNameInternal(name);
+        // This is not a fully qualified class name, ignore.
     }
 
     /* -- Utilities -- */