From: Ken A. <kan...@bb...> - 2004-10-25 15:03:24
|
Thanks for trying to fix this. The problem was the code did not check the permission on the method or the class. StringBuilder is a package protected abstract class. I think package protecting it is wrong, but maybe that had some deep language design reason for this. Here's the fixed version (i just checked it in, so it will be in cvs tomorrow). public static Vector methodVectorMerge(Class c, String name, Vector result,boolean canAccessPrivateData) { Class s = c.getSuperclass(); if (s != null) result = methodVectorMerge(s, name, result,canAccessPrivateData); Class[] is = c.getInterfaces(); for (int i = 0; i < is.length; i = i + 1) result = methodVectorMerge(is[i], name, result,canAccessPrivateData); Method[] ms = getMethods(c,canAccessPrivateData); for(int i = 0; i < ms.length; i++) { Method m = ms[i]; if ((!Modifier.isStatic(m.getModifiers())) && // KRA 25OCT04: Fixes problem with .append in JDK 1.5.0 (canAccessPrivateData || (Modifier.isPublic(m.getModifiers()) && Modifier.isPublic(m.getDeclaringClass().getModifiers())) && m.getName().equals(name))) maybeAdd(result, m); } return result; } At 01:31 AM 10/23/2004 +0300, Tatu Tarvainen wrote: >I posted earlier about reflection problems under Java 5. > >The invoker prefers superclass methods over subclass methods, which is >fine with interfaces, but causes problems in the StringBuffer scenario. >I don't know if my solution is the right one in all situations but it >solved my specific problems. > >I made the following change to jsint/Invoke.java: > >Change: > /** Only add an instance method if no superclass provides one. **/ > private static void maybeAdd(Vector result, Method m1) { > for(int i = 0; i < result.size(); i++) { > Method m2 = ((Method) result.elementAt(i)); > if(parameterTypesMatch(getParameterTypes(m1), > getParameterTypes(m2))) > return; > } > result.addElement(m1); > } > >To the following: > /** Only add an instance method if no superclass provides one. **/ > private static void maybeAdd(Vector result, Method m1) { > for(int i = 0; i < result.size(); i++) { > Method m2 = ((Method) result.elementAt(i)); > if(parameterTypesMatch(getParameterTypes(m1), > getParameterTypes(m2))) { > /* TTA: prefer methods provided by the subclass over >superclass methods, > * but not over interface methods. > */ > if(!m2.getDeclaringClass().isInterface()) > result.set(i, m1); > return; > } > } > result.addElement(m1); > } > >-- >Tatu Tarvainen > > > >------------------------------------------------------- >This SF.net email is sponsored by: IT Product Guide on ITManagersJournal >Use IT products in your business? Tell us what you think of them. Give us >Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more >http://productguide.itmanagersjournal.com/guidepromo.tmpl >_______________________________________________ >Jscheme-devel mailing list >Jsc...@li... >https://lists.sourceforge.net/lists/listinfo/jscheme-devel |