]> source.dussan.org Git - aspectj.git/commitdiff
373461 - attempted restructure of nameToSignature
authorAndy Clement <aclement@vmware.com>
Wed, 7 Mar 2012 20:09:41 +0000 (12:09 -0800)
committerAndy Clement <aclement@vmware.com>
Wed, 7 Mar 2012 20:09:41 +0000 (12:09 -0800)
org.aspectj.matcher/src/org/aspectj/weaver/UnresolvedType.java

index cc48f78bc5f26d39a40786ee767d18dc2876cd61..19fb6290800cdb683ace30b3985886fe4a802ae0 100644 (file)
@@ -744,60 +744,56 @@ public class UnresolvedType implements Traceable, TypeVariableDeclaringElement {
                if (name.endsWith("[]")) {
                        return "[" + nameToSignature(name.substring(0, name.length() - 2));
                }
-               if (len != 0) {
-                       // check if someone is calling us with something that is a signature already
-                       assert name.charAt(0) != '[';
-
-                       if (name.indexOf("<") == -1) {
-                               // not parameterized
-                               return new StringBuilder("L").append(name.replace('.', '/')).append(';').toString();
-                       } else {
-                               StringBuffer nameBuff = new StringBuffer();
-                               int nestLevel = 0;
-                               nameBuff.append("P");
-                               for (int i = 0; i < name.length(); i++) {
-                                       char c = name.charAt(i);
-                                       switch (c) {
-                                       case '.':
-                                               nameBuff.append('/');
-                                               break;
-                                       case '<':
-                                               nameBuff.append("<");
-                                               nestLevel++;
-                                               StringBuffer innerBuff = new StringBuffer();
-                                               while (nestLevel > 0) {
-                                                       c = name.charAt(++i);
-                                                       if (c == '<') {
-                                                               nestLevel++;
-                                                       }
-                                                       if (c == '>') {
-                                                               nestLevel--;
-                                                       }
-                                                       if (c == ',' && nestLevel == 1) {
-                                                               nameBuff.append(nameToSignature(innerBuff.toString()));
-                                                               innerBuff = new StringBuffer();
-                                                       } else {
-                                                               if (nestLevel > 0) {
-                                                                       innerBuff.append(c);
-                                                               }
+               if (len == 0) {
+                       throw new BCException("Bad type name: " + name);
+               }
+                       
+               if (name.indexOf("<") == -1) {
+                       // not parameterized
+                       return new StringBuilder("L").append(name.replace('.', '/')).append(';').toString();
+               } else {
+                       StringBuffer nameBuff = new StringBuffer();
+                       int nestLevel = 0;
+                       nameBuff.append("P");
+                       for (int i = 0; i < len; i++) {
+                               char c = name.charAt(i);
+                               switch (c) {
+                               case '.':
+                                       nameBuff.append('/');
+                                       break;
+                               case '<':
+                                       nameBuff.append("<");
+                                       nestLevel++;
+                                       StringBuffer innerBuff = new StringBuffer();
+                                       while (nestLevel > 0) {
+                                               c = name.charAt(++i);
+                                               if (c == '<') {
+                                                       nestLevel++;
+                                               } else if (c == '>') {
+                                                       nestLevel--;
+                                               }
+                                               if (c == ',' && nestLevel == 1) {
+                                                       nameBuff.append(nameToSignature(innerBuff.toString()));
+                                                       innerBuff = new StringBuffer();
+                                               } else {
+                                                       if (nestLevel > 0) {
+                                                               innerBuff.append(c);
                                                        }
                                                }
-                                               nameBuff.append(nameToSignature(innerBuff.toString()));
-                                               nameBuff.append('>');
-                                               break;
-                                       case '>':
-                                               throw new IllegalStateException("Should by matched by <");
-                                       case ',':
-                                               throw new IllegalStateException("Should only happen inside <...>");
-                                       default:
-                                               nameBuff.append(c);
                                        }
+                                       nameBuff.append(nameToSignature(innerBuff.toString()));
+                                       nameBuff.append('>');
+                                       break;
+//                             case '>':
+//                                     throw new IllegalStateException("Should by matched by <");
+//                             case ',':
+//                                     throw new IllegalStateException("Should only happen inside <...>");
+                               default:
+                                       nameBuff.append(c);
                                }
-                               nameBuff.append(";");
-                               return nameBuff.toString();
                        }
-               } else {
-                       throw new BCException("Bad type name: " + name);
+                       nameBuff.append(";");
+                       return nameBuff.toString();
                }
        }