Tom Tromey wrote: > Archie> Howver, this contradicts the JDK 1.4 docs, which say that the > Archie> method's return type must also be equal: > > Archie> Is this a classpath bug? > > Yes. Care to submit a patch?
Sure! See below... fortunately this vastly simplifies things :-) > Maybe this changed from 1.3 to 1.4. I know a lot of changes like this > are happening in preparation for the addition of generics. > > Could you see if this did change from 1.3? If so we can add an > @specnote to explain the change. It turns out the comparision has included the return type since JDK 1.2. Thanks, -Archie __________________________________________________________________________ Archie Cobbs * Precision I/O * http://www.precisionio.com --- classpath/classpath-0.05/vm/reference/java/lang/reflect/Method.java Wed Dec 18 02:28:29 2002 +++ /home/archie/jc/classpath/java/lang/reflect/Method.java Thu Feb 27 18:04:53 2003 @@ -144,57 +134,14 @@ /** * 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 or return types. + * class, name, parameter list, and return type. * * @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) { - // 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 this == o; - // - if (o == null) - return false; - - 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; + return this == o; } /** _______________________________________________ Classpath mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/classpath