You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Claude Brisson (JIRA)" <ji...@apache.org> on 2018/10/14 11:29:00 UTC
[jira] [Closed] (VELOCITY-858) Class
org.apache.velocity.util.introspection.UberspectImpl can not access a
member of class com.google.common.collect.Iterables$8 with modifiers
"public"
[ https://issues.apache.org/jira/browse/VELOCITY-858?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Claude Brisson closed VELOCITY-858.
-----------------------------------
> Class org.apache.velocity.util.introspection.UberspectImpl can not access a member of class com.google.common.collect.Iterables$8 with modifiers "public"
> ---------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: VELOCITY-858
> URL: https://issues.apache.org/jira/browse/VELOCITY-858
> Project: Velocity
> Issue Type: Bug
> Affects Versions: 1.7
> Environment: Java 8, guava
> Reporter: Andrey Chursin
> Assignee: Claude Brisson
> Priority: Major
> Fix For: 2.0
>
>
> 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();
> }
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org