Description
Specifically I got the following failure (see also https://java.net/jira/browse/TRUEVFS-158):
... 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)
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:
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); ...
Instead, it could continue to do this but if the method is private then it could also fallback to something like the following:
Class type = Iterable.class; if (obj instanceof Iterable) { Method iter = type.getMethod("iterator", null); return (Iterator) iter.invoke(obj, null); }
Attachments
Issue Links
- is related to
-
VELOCITY-871 #foreach should work over any Iterable class
-
- Closed
-