[jboss-cvs] javassist/src/main/javassist ...
Shigeru Chiba
chiba at is.titech.ac.jp
Fri Aug 25 14:41:32 EDT 2006
User: chiba
Date: 06/08/25 14:41:32
Modified: src/main/javassist CodeConverter.java
Log:
extended CodeConverter.
Revision Changes Path
1.7 +34 -1 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.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- CodeConverter.java 11 Jan 2006 06:45:54 -0000 1.6
+++ CodeConverter.java 25 Aug 2006 18:41:32 -0000 1.7
@@ -204,7 +204,7 @@
/**
* Modify method invocations in a method body so that a different
- * method is invoked.
+ * method will be invoked.
*
* <p>Note that the target object, the parameters, or
* the type of invocation
@@ -226,11 +226,44 @@
if (!d1.equals(d2))
throw new CannotCompileException("signature mismatch");
+ int mod1 = origMethod.getModifiers();
+ int mod2 = substMethod.getModifiers();
+ if (Modifier.isPrivate(mod1) != Modifier.isPrivate(mod2)
+ || Modifier.isStatic(mod1) != Modifier.isStatic(mod2)
+ || origMethod.getDeclaringClass().isInterface()
+ != substMethod.getDeclaringClass().isInterface())
+ throw new CannotCompileException("invoke-type mismatch");
+
transformers = new TransformCall(transformers, origMethod,
substMethod);
}
/**
+ * Correct invocations to a method that has been renamed.
+ * If a method is renamed, calls to that method must be also
+ * modified so that the method with the new name will be called.
+ *
+ * <p>The method must be declared in the same class before and
+ * after it is renamed.
+ *
+ * <p>Note that the target object, the parameters, or
+ * the type of invocation
+ * (static method call, interface call, or private method call)
+ * are not modified. Only the method name is changed.
+ *
+ * @param oldMethodName the old name of the method.
+ * @param newMethod the method with the new name.
+ * @see javassist.CtMethod#setName(String)
+ */
+ public void redirectMethodCall(String oldMethodName,
+ CtMethod newMethod)
+ throws CannotCompileException
+ {
+ transformers
+ = new TransformCall(transformers, oldMethodName, newMethod);
+ }
+
+ /**
* Insert a call to another method before an existing method call.
* That "before" method must be static. The return type must be
* <code>void</code>. As parameters, the before method receives
More information about the jboss-cvs-commits
mailing list