diff options
author | Mark Wielaard <mark@klomp.org> | 2002-03-02 15:05:47 +0000 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2002-03-02 15:05:47 +0000 |
commit | 534835e4ee63589fa330b338e5a2426d91d73853 (patch) | |
tree | ad3542dd5646ff994d94f62d780e7b2bed1b104b /vm | |
parent | d0e9a0cd1236f1580bb6e5910bc62aaf772b65d3 (diff) | |
download | classpath-534835e4ee63589fa330b338e5a2426d91d73853.tar.gz |
* lib/standard.omit: java/security/cert/CertPathValidatorException.java
added.
* vm/reference/java/lang/reflect/Method.java (equals): reimplement.
Diffstat (limited to 'vm')
-rw-r--r-- | vm/reference/java/lang/reflect/Method.java | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/vm/reference/java/lang/reflect/Method.java b/vm/reference/java/lang/reflect/Method.java index 454628b2b..4af6c00be 100644 --- a/vm/reference/java/lang/reflect/Method.java +++ b/vm/reference/java/lang/reflect/Method.java @@ -145,15 +145,54 @@ extends AccessibleObject implements Member * Compare two objects to see if they are semantically equivalent. * Two Methods are semantically equivalent if they have the same declaring * class, name, and parameter list. This ignores different exception - * clauses, but since you can't create a Method except through the VM, - * this is just the == relation. + * clauses or return types. * * @param o the object to compare to * @return <code>true</code> if they are equal; <code>false</code> if not */ public boolean equals(Object o) { - return this == o; + // Implementation note: + // The following is a correct but possibly slow implementation. + // + // This class has a private field 'slot' that could be used by + // the VM implementation to "link" a particular method to a Class. + // In that case equals could be simply implemented as: + // + // if (o instanceof Method) + // { + // Method m = (Method)o; + // return m.declaringClass == this.declaringClass + // && m.slot == this.slot; + // } + // return false; + // + // If a VM uses the Method class as their native/internal representation + // then just using the following would be optimal: + // + // return return this == o; + // + + if (!(o instanceof Method)) + return false; + + Method m = (Method)o; + if(!name.equals(m.name)) + return false; + + if(declaringClass != m.declaringClass) + return false; + + Class[] params1 = getParameterTypes(); + Class[] params2 = m.getParameterTypes(); + if(params1.length != params2.length) + return false; + + for(int i = 0; i < params1.length; i++) + if(params1[i] != params2[i]) + return false; + + return true; } /** |