From: <cg...@us...> - 2006-08-15 03:45:57
|
Revision: 2889 Author: cgroves Date: 2006-08-14 20:45:52 -0700 (Mon, 14 Aug 2006) ViewCVS: http://svn.sourceforge.net/jython/?rev=2889&view=rev Log Message: ----------- setAccessible(true) on public methods of package private classes when added to a PyJavaClass. This is a cleaner fix for bug #628315 so I'm backing out the previous commit too. Modified Paths: -------------- trunk/jython/src/org/python/core/PyJavaClass.java Modified: trunk/jython/src/org/python/core/PyJavaClass.java =================================================================== --- trunk/jython/src/org/python/core/PyJavaClass.java 2006-08-13 02:46:22 UTC (rev 2888) +++ trunk/jython/src/org/python/core/PyJavaClass.java 2006-08-15 03:45:52 UTC (rev 2889) @@ -159,10 +159,6 @@ setBeanInfoCustom(proxyClass, methods); setFields(proxyClass); setMethods(proxyClass, methods); - Class[] intfs = proxyClass.getInterfaces(); - for(int i = 0; i < intfs.length; i++) { - setMethods(intfs[i], intfs[i].getMethods()); - } } catch(SecurityException se) {} } @@ -417,11 +413,23 @@ Class dc = method.getDeclaringClass(); if (dc != c) continue; - int mods = dc.getModifiers(); - if(!(Modifier.isPublic(mods) || Modifier.isPrivate(mods) || Modifier.isProtected(mods))) { - // skip package protected classes such as AbstractStringBuilder - // or UNIXProcess - continue; + if(isPackagedProtected(dc) && Modifier.isPublic(method.getModifiers())) { + /* + * Set public methods on package protected classes accessible so + * that reflected calls to the method in subclasses of the + * package protected class will succeed. Yes, it's convoluted. + * + * This fails when done through reflection due to Sun JVM bug + * 4071957(http://tinyurl.com/le9vo). 4533479 actually describes + * the problem we're seeing, but there are a bevy of reflection + * bugs that stem from 4071957. Supposedly it'll be fixed in + * Dolphin but it's been promised in every version since Tiger + * so don't hold your breath. + * + */ + try { + method.setAccessible(true); + } catch(SecurityException se) {} } if (ignoreMethod(method)) continue; @@ -429,6 +437,11 @@ } } + public static boolean isPackagedProtected(Class c) { + int mods = c.getModifiers(); + return !(Modifier.isPublic(mods) || Modifier.isPrivate(mods) || Modifier.isProtected(mods)); + } + /* Adds a bean property to this class */ void addProperty(String name, Class propClass, Method getMethod, Method setMethod) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |