[jboss-cvs] javassist/src/main/javassist/bytecode ...

Shigeru Chiba chiba at is.titech.ac.jp
Tue Feb 6 11:40:35 EST 2007


  User: chiba   
  Date: 07/02/06 11:40:35

  Modified:    src/main/javassist/bytecode   SignatureAttribute.java
                        ClassFileWriter.java
  Log:
  supported generic type signatures.
  
  Revision  Changes    Path
  1.5       +22 -0     javassist/src/main/javassist/bytecode/SignatureAttribute.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SignatureAttribute.java
  ===================================================================
  RCS file: /cvsroot/jboss/javassist/src/main/javassist/bytecode/SignatureAttribute.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- SignatureAttribute.java	6 Feb 2007 16:05:29 -0000	1.4
  +++ SignatureAttribute.java	6 Feb 2007 16:40:35 -0000	1.5
  @@ -489,6 +489,9 @@
           }
       }
   
  +    /**
  +     * Type variables.
  +     */
       public static class TypeVariable extends ObjectType {
           String name;
   
  @@ -516,6 +519,7 @@
        *
        * @param  sig                  the signature.
        * @throws BadBytecode          thrown when a syntactical error is found.
  +     * @since 3.5
        */
       public static ClassSignature toClassSignature(String sig) throws BadBytecode {
           try {
  @@ -531,6 +535,7 @@
        *
        * @param  sig                  the signature.
        * @throws BadBytecode          thrown when a syntactical error is found.
  +     * @since 3.5
        */
       public static MethodSignature toMethodSignature(String sig) throws BadBytecode {
           try {
  @@ -541,6 +546,23 @@
           }
       }
   
  +    /**
  +     * Parses the given signature string as a field type signature.
  +     *
  +     * @param  sig                  the signature string.
  +     * @return the field type signature.
  +     * @throws BadBytecode          thrown when a syntactical error is found.
  +     * @since 3.5
  +     */
  +    public static ObjectType toFieldSignature(String sig) throws BadBytecode {
  +        try {
  +            return parseObjectType(sig, new Cursor(), false);
  +        }
  +        catch (IndexOutOfBoundsException e) {
  +            throw error(sig);
  +        }
  +    }
  +
       private static ClassSignature parseSig(String sig)
           throws BadBytecode, IndexOutOfBoundsException
       {
  
  
  
  1.11      +9 -7      javassist/src/main/javassist/bytecode/ClassFileWriter.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ClassFileWriter.java
  ===================================================================
  RCS file: /cvsroot/jboss/javassist/src/main/javassist/bytecode/ClassFileWriter.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -b -r1.10 -r1.11
  --- ClassFileWriter.java	6 Feb 2007 16:05:29 -0000	1.10
  +++ ClassFileWriter.java	6 Feb 2007 16:40:35 -0000	1.11
  @@ -68,7 +68,7 @@
               out.println(Modifier.toString(AccessFlag.toModifier(acc))
                           + " " + finfo.getName() + "\t"
                           + finfo.getDescriptor());
  -            printAttributes(finfo.getAttributes(), out, false);
  +            printAttributes(finfo.getAttributes(), out, 'f');
           }
   
           out.println();
  @@ -80,15 +80,15 @@
               out.println(Modifier.toString(AccessFlag.toModifier(acc))
                           + " " + minfo.getName() + "\t"
                           + minfo.getDescriptor());
  -            printAttributes(minfo.getAttributes(), out, false);
  +            printAttributes(minfo.getAttributes(), out, 'm');
               out.println();
           }
   
           out.println();
  -        printAttributes(cf.getAttributes(), out, true);
  +        printAttributes(cf.getAttributes(), out, 'c');
       }
   
  -    static void printAttributes(List list, PrintWriter out, boolean forClass) {
  +    static void printAttributes(List list, PrintWriter out, char kind) {
           if (list == null)
               return;
   
  @@ -104,7 +104,7 @@
                               + ", " + ca.getExceptionTable().size()
                               + " catch blocks");
                   out.println("<code attribute begin>");
  -                printAttributes(ca.getAttributes(), out, forClass);
  +                printAttributes(ca.getAttributes(), out, kind);
                   out.println("<code attribute end>");
               }
               else if (ai instanceof StackMapTable) {
  @@ -118,10 +118,12 @@
                   out.println("signature: " + sig);
                   try {
                       String s;
  -                    if (forClass)
  +                    if (kind == 'c')
                           s = SignatureAttribute.toClassSignature(sig).toString();
  -                    else
  +                    else if (kind == 'm')
                           s = SignatureAttribute.toMethodSignature(sig).toString();
  +                    else
  +                        s = SignatureAttribute.toFieldSignature(sig).toString();
   
                       out.println("           " + s);
                   }
  
  
  



More information about the jboss-cvs-commits mailing list