You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Jochen Kemnade (JIRA)" <ji...@apache.org> on 2016/02/22 14:45:19 UTC

[jira] [Updated] (TAP5-2032) GenericsUtils does not handle generics properly when extracting the actual type

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

Jochen Kemnade updated TAP5-2032:
---------------------------------
    Labels: bulk-close-candidate  (was: )

This issue affects an old version of Tapestry that is not actively developed anymore, and is therefore prone to be bulk-closed in the near future.

If the issue still persists with the most recent version of Tapestry (currently 5.4.0, available from Maven Central), please update it as soon as possible and add '5.4.0') to the issue's affected versions.

> GenericsUtils does not handle generics properly when extracting the actual type
> -------------------------------------------------------------------------------
>
>                 Key: TAP5-2032
>                 URL: https://issues.apache.org/jira/browse/TAP5-2032
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-ioc
>    Affects Versions: 5.3.6
>            Reporter: DI Florian Hackenberger
>            Assignee: Thiago H. de Paula Figueiredo
>              Labels: bulk-close-candidate
>
> We have the following interfaces / classes
> public interface IPersonWithRoleAssociation<A> extends IEntityAssociationWithInfo<A, Person> {
> 	PersonRole getRole();
> 	void setRole(PersonRole role);
> }
> public interface IEntityAssociationWithInfo<P, C> {
> 	P getParent();
> 	void setParent(P parent);
> 	C getChild();
> 	void setChild(C child);
> }
> public class Person implements Serializable {
> 	....
> 	String name;
> 	public String getName() {
> 		return name;
> 	}
> }
> and the page:
> public class EditPersonsWithRoles {
> 	@Property(write=false) IPersonWithRoleAssociation<A> personWithRole;
> }
> and the template snippet:
> <t:textfield t:id="personSex" t:value="personWithRole.child.name"/>
> Leads to the following exception:
> Exception generating conduit for expression 'personWithRole.child.name': ...
> ...
> Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
> 	at org.apache.tapestry5.ioc.internal.util.GenericsUtils.resolve(GenericsUtils.java:388) ~[tapestry-ioc-5.3.6.jar:na]
> 	at org.apache.tapestry5.ioc.internal.util.GenericsUtils.resolve(GenericsUtils.java:128) ~[tapestry-ioc-5.3.6.jar:na]
> 	at org.apache.tapestry5.ioc.internal.util.GenericsUtils.extractActualType(GenericsUtils.java:74) ~[tapestry-ioc-5.3.6.jar:na]
> 	at org.apache.tapestry5.internal.services.PropertyConduitSourceImpl$PropertyConduitBuilder.buildGetterMethodAccessTerm(PropertyConduitSourceImpl.java:1119) ~[tapestry-core-5.3.6.jar:na]
> At GenericsUtils.java:388 we have:
> resolved = ((ParameterizedType) t).getActualTypeArguments()[i];
> where:
> i = 1
> resolved = C
> ((ParameterizedType) t).getActualTypeArguments() = [org.topfive.entities.IPersonWithRoleAssociation<P>]
> so the problem seems to be that the code assumes that it can find the type information for C as the second generic parameter for IPersonWithRoleAssociation, when in fact is is the second generic parameter for the superclass IEntityAssociationWithInfo which IPersonWithRoleAssociation extends and passes C explicitly (Person). Everything is fine, if I use a marker interface for Person (IPerson) and declare:
> public interface IPersonWithRoleAssociation<A, P extends IPerson> extends IEntityAssociationWithInfo<A, P>



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)