[prev in list] [next in list] [prev in thread] [next in thread] 

List:       velocity-dev
Subject:    [jira] [Closed] (VELOCITY-870) Exception displayed when trying to loop over an Iterable private clas
From:       "Sergiu Dumitriu (JIRA)" <jira () apache ! org>
Date:       2015-12-04 21:44:11
Message-ID: JIRA.12918969.1449233014000.276574.1449265451082 () Atlassian ! JIRA
[Download RAW message or body]


     [ https://issues.apache.org/jira/browse/VELOCITY-870?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel \
]

Sergiu Dumitriu closed VELOCITY-870.
------------------------------------
       Resolution: Fixed
    Fix Version/s: 1.x
                   2.x
                   1.7.x

> 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
> Fix For: 1.7.x, 2.x, 1.x
> 
> 
> 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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic