You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Sergiu Dumitriu (JIRA)" <ji...@apache.org> on 2015/12/04 21:53:10 UTC
[jira] [Assigned] (VELOCITY-870) Exception displayed when trying to
loop over an Iterable private class
[ https://issues.apache.org/jira/browse/VELOCITY-870?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sergiu Dumitriu reassigned VELOCITY-870:
----------------------------------------
Assignee: Sergiu Dumitriu
> Exception displayed when trying to loop over an Iterable private class
> ----------------------------------------------------------------------
>
> 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
> Assignee: Sergiu Dumitriu
>
> 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-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org