git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@336 30ef5769-5b8d-40dd-aea6-55b5d6557bb3tags/rel_3_17_1_ga
@@ -281,6 +281,8 @@ see javassist.Dump. | |||
<h2>Changes</h2> | |||
<p>-version 3.5 | |||
<p>-version 3.4 on November 17, 2006 | |||
<ul> | |||
<li>A bug in CodeConverter#replaceFieldRead() and CodeConverter#replaceFieldWrite() |
@@ -224,7 +224,8 @@ public class CodeConverter { | |||
String d1 = origMethod.getMethodInfo2().getDescriptor(); | |||
String d2 = substMethod.getMethodInfo2().getDescriptor(); | |||
if (!d1.equals(d2)) | |||
throw new CannotCompileException("signature mismatch"); | |||
throw new CannotCompileException("signature mismatch: " | |||
+ substMethod.getLongName()); | |||
int mod1 = origMethod.getModifiers(); | |||
int mod2 = substMethod.getModifiers(); | |||
@@ -232,7 +233,8 @@ public class CodeConverter { | |||
|| (Modifier.isPrivate(mod1) && !Modifier.isPrivate(mod2)) | |||
|| origMethod.getDeclaringClass().isInterface() | |||
!= substMethod.getDeclaringClass().isInterface()) | |||
throw new CannotCompileException("invoke-type mismatch"); | |||
throw new CannotCompileException("invoke-type mismatch " | |||
+ substMethod.getLongName()); | |||
transformers = new TransformCall(transformers, origMethod, | |||
substMethod); |
@@ -81,6 +81,14 @@ public abstract class CtBehavior extends CtMember { | |||
buffer.append(methodInfo.getDescriptor()); | |||
} | |||
/** | |||
* Returns the method or constructor name followed by parameter types | |||
* such as <code>javassist.CtBehavior.stBody(String)</code>. | |||
* | |||
* @since 3.5 | |||
*/ | |||
public abstract String getLongName(); | |||
/** | |||
* Returns the MethodInfo representing this method/constructor in the | |||
* class file. |
@@ -52,7 +52,7 @@ public abstract class CtClass { | |||
/** | |||
* The version number of this release. | |||
*/ | |||
public static final String version = "3.4"; | |||
public static final String version = "3.5unstable"; | |||
/** | |||
* Prints the version number and the copyright notice. |
@@ -115,6 +115,18 @@ public final class CtConstructor extends CtBehavior { | |||
return methodInfo.isStaticInitializer(); | |||
} | |||
/** | |||
* Returns the constructor name followed by parameter types | |||
* such as <code>javassist.CtConstructor(CtClass[],CtClass)</code>. | |||
* | |||
* @since 3.5 | |||
*/ | |||
public String getLongName() { | |||
return getDeclaringClass().getName() | |||
+ (isConstructor() ? Descriptor.toString(getSignature()) | |||
: ("." + MethodInfo.nameClinit + "()")); | |||
} | |||
/** | |||
* Obtains the name of this constructor. | |||
* It is the same as the simple name of the class declaring this |
@@ -154,6 +154,17 @@ public final class CtMethod extends CtBehavior { | |||
&& ((CtMethod)obj).getStringRep().equals(getStringRep()); | |||
} | |||
/** | |||
* Returns the method name followed by parameter types | |||
* such as <code>javassist.CtMethod.setBody(String)</code>. | |||
* | |||
* @since 3.5 | |||
*/ | |||
public String getLongName() { | |||
return getDeclaringClass().getName() + "." | |||
+ getName() + Descriptor.toString(getSignature()); | |||
} | |||
/** | |||
* Obtains the name of this method. | |||
*/ |
@@ -684,6 +684,69 @@ public class Descriptor { | |||
return n; | |||
} | |||
/** | |||
* Returns a human-readable representation of the | |||
* given descriptor. For example, <code>Ljava/lang/Object;</code> | |||
* is converted into <code>java.lang.Object</code>. | |||
* <code>(I[I)V</code> is converted into <code>(int, int[])</code> | |||
* (the return type is ignored). | |||
*/ | |||
public static String toString(String desc) { | |||
return PrettyPrinter.toString(desc); | |||
} | |||
static class PrettyPrinter { | |||
static String toString(String desc) { | |||
StringBuffer sbuf = new StringBuffer(); | |||
if (desc.charAt(0) == '(') { | |||
int pos = 1; | |||
sbuf.append('('); | |||
while (desc.charAt(pos) != ')') { | |||
if (pos > 1) | |||
sbuf.append(','); | |||
pos = readType(sbuf, pos, desc); | |||
} | |||
sbuf.append(')'); | |||
} | |||
else | |||
readType(sbuf, 0, desc); | |||
return sbuf.toString(); | |||
} | |||
static int readType(StringBuffer sbuf, int pos, String desc) { | |||
char c = desc.charAt(pos); | |||
int arrayDim = 0; | |||
while (c == '[') { | |||
arrayDim++; | |||
c = desc.charAt(++pos); | |||
} | |||
if (c == 'L') | |||
while (true) { | |||
c = desc.charAt(++pos); | |||
if (c == ';') | |||
break; | |||
if (c == '/') | |||
c = '.'; | |||
sbuf.append(c); | |||
} | |||
else { | |||
CtClass t = toPrimitiveClass(c); | |||
sbuf.append(t.getName()); | |||
} | |||
while (arrayDim-- > 0) | |||
sbuf.append("[]"); | |||
return pos + 1; | |||
} | |||
} | |||
/** | |||
* An Iterator over a descriptor. | |||
*/ |