Hi, I really like this change and I have a few comments:
- Please move forName(String) to VMClass, some VMs might be able to get the caller's ClassLoader in a more efficient way. - Same goes for isArray(), getting the class name can potentially be an expensive operation. - getSigners() should return a clone of the signers array. - internalGetMethods() should not return overridden virtual methods multiple times, see attached file for what I think is a correct implementation Regards, Jeroen > > -----Original Message----- > From: Brian Jones [mailto:[EMAIL PROTECTED] > Sent: Thursday, April 03, 2003 07:38 > To: Archie Cobbs > Cc: [EMAIL PROTECTED] > > Archie Cobbs <[EMAIL PROTECTED]> writes: > > > Below is a subset of my current set of diffs for java.lang.Class. > > I'm sending them just for anyone to look at and for > consideration for > > checking in. I think some of them could be useful for classpath. > > I'd be interested to hear what other people think. > > > > I've made a few modifications by splitting out the native > methods into VMClass. When committed I'll move Class.java to > classpath/java/lang/ and out of the vm/reference directory. > I've added gnu.classpath.RawData following gcj's lead in this > case. I'm seeking comments before committing this patch > based on Archie's work. Sorry I'm personally taking so long > with a lot of the patches submitted lately. > > Thanks, > Brian > -- > Brian Jones <[EMAIL PROTECTED]> > >
private Method[] internalGetMethods() { java.util.HashMap map = new java.util.HashMap(); Method[] methods; Class[] interfaces = getInterfaces(); for(int i = 0; i < interfaces.length; i++) { methods = interfaces[i].internalGetMethods(); for(int j = 0; j < methods.length; j++) { map.put(new MethodKey(methods[j]), methods[j]); } } Class superClass = getSuperclass(); if(superClass != null) { methods = superclass.internalGetMethods(); for(int i = 0; i < methods.length; i++) { map.put(new MethodKey(methods[i]), methods[i]); } } methods = getDeclaredMethods(true); for(int i = 0; i < methods.length; i++) { map.put(new MethodKey(methods[i]), methods[i]); } return (Method[])map.values().toArray(new Method[map.size()]); } private static final class MethodKey { private String name; private Class[] params; private Class returnType; private int hash; MethodKey(Method m) { name = m.getName(); params = m.getParameterTypes(); returnType = m.getReturnType(); hash = name.hashCode() ^ returnType.hashCode(); for(int i = 0; i < params.length; i++) { hash ^= params[i].hashCode(); } } public boolean equals(Object o) { if(o instanceof MethodKey) { MethodKey m = (MethodKey)o; if(m.name.equals(name) && m.params.length == params.length && m.returnType == returnType) { for(int i = 0; i < params.length; i++) { if(m.params[i] != params[i]) { return false; } } return true; } } return false; } public int hashCode() { return hash; } }
_______________________________________________ Classpath mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/classpath