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

Shigeru Chiba chiba at is.titech.ac.jp
Mon Sep 8 06:56:50 EDT 2008


  User: chiba   
  Date: 08/09/08 06:56:50

  Modified:    src/main/javassist  CodeConverter.java
  Log:
  implemented CodeConverter.replaceNew(CtClass,CtClass)
  
  Revision  Changes    Path
  1.15      +28 -2     javassist/src/main/javassist/CodeConverter.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CodeConverter.java
  ===================================================================
  RCS file: /cvsroot/jboss/javassist/src/main/javassist/CodeConverter.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -b -r1.14 -r1.15
  --- CodeConverter.java	24 May 2008 05:12:39 -0000	1.14
  +++ CodeConverter.java	8 Sep 2008 10:56:50 -0000	1.15
  @@ -98,6 +98,32 @@
       }
   
       /**
  +     * Modify a method body so that instantiation of the class
  +     * specified by <code>oldClass</code>
  +     * is replaced with instantiation of another class <code>newClass</code>.
  +     * For example,
  +     * <code>replaceNew(ctPoint, ctPoint2)</code>
  +     * (where <code>ctPoint</code> and <code>ctPoint2</code> are
  +     * compile-time classes for class <code>Point</code> and class
  +     * <code>Point2</code>, respectively)
  +     * replaces all occurrences of:
  +     *
  +     * <ul><code>new Point(x, y)</code></ul>
  +     *
  +     * in the method body with:
  +     *
  +     * <ul><code>new Point2(x, y)</code></ul>
  +     *
  +     * <p>Note that <code>Point2</code> must be type-compatible with <code>Point</code>.
  +     * It must have the same set of methods, fields, and constructors as the
  +     * replaced class. 
  +     */
  +    public void replaceNew(CtClass oldClass, CtClass newClass) {
  +        transformers = new TransformNewClass(transformers, oldClass.getName(),
  +                                             newClass.getName());
  +    }
  +
  +    /**
        * Modify a method body so that field read/write expressions access
        * a different field from the original one.
        *
  @@ -503,7 +529,7 @@
        * as array access replacements.
        *
        * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
  -     * @version $Revision: 1.14 $
  +     * @version $Revision: 1.15 $
        */
       public interface ArrayAccessReplacementMethodNames
       {
  @@ -612,7 +638,7 @@
        * accesses to array elements.
        *
        * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
  -     * @version $Revision: 1.14 $
  +     * @version $Revision: 1.15 $
        */
       public static class DefaultArrayAccessReplacementMethodNames
           implements ArrayAccessReplacementMethodNames
  
  
  



More information about the jboss-cvs-commits mailing list