aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/javassist/CtMethod.java
diff options
context:
space:
mode:
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2004-08-22 13:04:09 +0000
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2004-08-22 13:04:09 +0000
commit5d5407d0af21c23595e18aaae07eca9866e8f448 (patch)
treec1d52984266ff45282ac454cefc6cf5ab2f545a0 /src/main/javassist/CtMethod.java
parent8c82477b4172ed0db9e5d866a0dba22ae20eb23f (diff)
downloadjavassist-5d5407d0af21c23595e18aaae07eca9866e8f448.tar.gz
javassist-5d5407d0af21c23595e18aaae07eca9866e8f448.zip
fixed a bug in CtClass.getMethods() and javassist.reflect package
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@126 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main/javassist/CtMethod.java')
-rw-r--r--src/main/javassist/CtMethod.java24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/main/javassist/CtMethod.java b/src/main/javassist/CtMethod.java
index f0547150..9d9416b3 100644
--- a/src/main/javassist/CtMethod.java
+++ b/src/main/javassist/CtMethod.java
@@ -28,12 +28,12 @@ import javassist.bytecode.*;
*/
public final class CtMethod extends CtBehavior {
protected CtMethod next;
- protected int cachedHashCode;
+ protected String cachedStringRep;
CtMethod(MethodInfo minfo, CtClass declaring) {
super(declaring, minfo);
next = null;
- cachedHashCode = 0;
+ cachedStringRep = null;
}
/**
@@ -163,17 +163,17 @@ public final class CtMethod extends CtBehavior {
* the hash codes for the two methods are equal.
*/
public int hashCode() {
- /* This method is overridden in ExistingMethod for optimization.
- */
- if (cachedHashCode == 0) {
- String signature
- = methodInfo.getName() + ':' + methodInfo.getDescriptor();
+ return getStringRep().hashCode();
+ }
- // System.identityHashCode() returns 0 only for null.
- cachedHashCode = System.identityHashCode(signature.intern());
- }
+ /* This method is also called by CtClassType.getMethods0().
+ */
+ final String getStringRep() {
+ if (cachedStringRep == null)
+ cachedStringRep = methodInfo.getName()
+ + Descriptor.getParamDescriptor(methodInfo.getDescriptor());
- return cachedHashCode;
+ return cachedStringRep;
}
/**
@@ -182,7 +182,7 @@ public final class CtMethod extends CtBehavior {
*/
public boolean equals(Object obj) {
return obj != null && obj instanceof CtMethod
- && obj.hashCode() == hashCode();
+ && ((CtMethod)obj).getStringRep().equals(getStringRep());
}
/**