-
Type:
Bug
-
Status: Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.7
-
Fix Version/s: 2.0
-
Component/s: None
-
Labels:None
-
Environment:Java 8, guava
Probably related issue:
https://issues.apache.org/jira/browse/VELOCITY-579
I am passing result of guava's Iterables.transform() to velocity.
Attempt to iterate over it throws access exception, as UberspectImpl tries to access method iterator on object's class
Class type = obj.getClass();
...
Method iter = type.getMethod("iterator", null);
Problem is, that while iterator() method is public, class com.google.common.collect.Iterables$8 is private, so velocity can't access it's method through reflection.
I suggest call Iterable::iterator() for classes implementing Iterable, instead of trying to access method through reflection, as you already do for Collection implementations.
Basically, replace (in UberspectImpl::getIterator(Object, Info))
else if (obj instanceof Collection)
{ return ((Collection) obj).iterator(); }with
else if (obj instanceof Iterable)
{ return ((Iterable) obj).iterator(); }