Vincent Massol created VELOCITY-870: ---------------------------------------
Summary: UberspectImpl should check class visibility before calling iterator() Key: VELOCITY-870 URL: https://issues.apache.org/jira/browse/VELOCITY-870 Project: Velocity Issue Type: Bug Components: Engine Affects Versions: 1.7 Reporter: Vincent Massol Specifically I got the following failure (see also https://java.net/jira/browse/TRUEVFS-158): {noformat} ... Caused by: java.lang.IllegalAccessException: Class org.apache.velocity.util.introspection.UberspectImpl can not access a member of class net.java.truevfs.access.TFileSystem$Stream with modifiers "public" at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:109) at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:261) at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:253) at java.lang.reflect.Method.invoke(Method.java:599) at org.apache.velocity.util.introspection.UberspectImpl.getIterator(UberspectImpl.java:158) {noformat} The problem as I understand it is that TrueVFS returns a private class and Velocity shouldn't try to call iterator() on it since it's private. Right now the UberspectImpl code does this: {code} Class type = obj.getClass(); try { Method iter = type.getMethod("iterator", null); Class returns = iter.getReturnType(); if (Iterator.class.isAssignableFrom(returns)) { try { return (Iterator)iter.invoke(obj, null); ... {code} Instead, it could continue to do this but if the method is private then it could also fallback to something like the following: {code} Class type = Iterable.class; if (obj instanceof Iterable) { Method iter = type.getMethod("iterator", null); return (Iterator) iter.invoke(obj, null); } {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org For additional commands, e-mail: dev-h...@velocity.apache.org