[ https://issues.apache.org/jira/browse/TAP5-2032?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16211078#comment-16211078 ]
Jochen Kemnade edited comment on TAP5-2032 at 11/3/17 7:52 AM: --------------------------------------------------------------- I can actually reproduce a variation of this in the 5.5.0 alphas (thanks [~mihasik] for spotting it in the first place). {code:java} public interface IdentifiableEnum<E extends Enum<E>, ID extends Number> { ID getId(); } public enum ById implements IdentifiableEnum<ById, Byte> { ; public Byte getId() { return null; } } new PropertyAccessImpl().getAdapter(ById.class); {code} produces {noformat} ... Caused by: java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: 1 at org.apache.tapestry5.ioc.internal.services.PropertyAccessImpl.buildAdapter(PropertyAccessImpl.java:116) at org.apache.tapestry5.ioc.internal.services.PropertyAccessImpl.getAdapter(PropertyAccessImpl.java:80) at ioc.specs.PropertyAccessImplSpec.Build adapter for enum implementing generic interface(PropertyAccessImplSpec.groovy:827) Caused by: java.lang.ArrayIndexOutOfBoundsException: 1 at org.apache.tapestry5.ioc.internal.util.GenericsUtils.resolve(GenericsUtils.java:386) at org.apache.tapestry5.ioc.internal.util.GenericsUtils.resolve(GenericsUtils.java:126) at org.apache.tapestry5.ioc.internal.util.GenericsUtils.extractGenericReturnType(GenericsUtils.java:39) at org.apache.tapestry5.ioc.internal.services.ClassPropertyAdapterImpl.<init>(ClassPropertyAdapterImpl.java:115) at org.apache.tapestry5.ioc.internal.services.PropertyAccessImpl.buildAdapter(PropertyAccessImpl.java:112) ... 2 more {noformat} was (Author: jkemnade): I can actually reproduce a variation of this in the 5.5.0 alphas (thanks [~mihasik] for spotting it in the first place). {code:java} public interface IdentifiableEnum<E extends Enum<E>, ID extends Number> { ID getId(); } public enum ById implements IdentifiableEnum<ById, Byte> { public Byte getId() { return null; } } new PropertyAccessImpl().getAdapter(ById.class) {code} produces {noformat} ... Caused by: java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: 1 at org.apache.tapestry5.ioc.internal.services.PropertyAccessImpl.buildAdapter(PropertyAccessImpl.java:116) at org.apache.tapestry5.ioc.internal.services.PropertyAccessImpl.getAdapter(PropertyAccessImpl.java:80) at ioc.specs.PropertyAccessImplSpec.Build adapter for enum implementing generic interface(PropertyAccessImplSpec.groovy:827) Caused by: java.lang.ArrayIndexOutOfBoundsException: 1 at org.apache.tapestry5.ioc.internal.util.GenericsUtils.resolve(GenericsUtils.java:386) at org.apache.tapestry5.ioc.internal.util.GenericsUtils.resolve(GenericsUtils.java:126) at org.apache.tapestry5.ioc.internal.util.GenericsUtils.extractGenericReturnType(GenericsUtils.java:39) at org.apache.tapestry5.ioc.internal.services.ClassPropertyAdapterImpl.<init>(ClassPropertyAdapterImpl.java:115) at org.apache.tapestry5.ioc.internal.services.PropertyAccessImpl.buildAdapter(PropertyAccessImpl.java:112) ... 2 more {noformat} > 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, 5.5.0, 5.4.3 > Reporter: DI Florian Hackenberger > Assignee: Thiago H. de Paula Figueiredo > Priority: Major > > We have the following interfaces / classes > {code:java} > 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; > } > } > {code} > and the page: > {code:java} > public class EditPersonsWithRoles { > @Property(write=false) IPersonWithRoleAssociation<A> personWithRole; > } > {code} > and the template snippet: > {code:html} > <t:textfield t:id="personSex" t:value="personWithRole.child.name"/> > {code} > Leads to the following exception: > {noformat} > 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] > {noformat} > At GenericsUtils.java:388 we have: > {code:java} > resolved = ((ParameterizedType) t).getActualTypeArguments()[i]; > {code} > where: > {code:java} > i = 1 > resolved = C > ((ParameterizedType) t).getActualTypeArguments() = > [org.topfive.entities.IPersonWithRoleAssociation<P>] > {code} > 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: > {code:java} > public interface IPersonWithRoleAssociation<A, P extends IPerson> extends > IEntityAssociationWithInfo<A, P> > {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)