aries-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew MacGaffey (Jira)" <j...@apache.org>
Subject [jira] [Created] (ARIES-1989) Blueprint not able to assign complex generics
Date Fri, 10 Jul 2020 17:31:00 GMT
Andrew MacGaffey created ARIES-1989:
---------------------------------------

             Summary: Blueprint not able to assign complex generics
                 Key: ARIES-1989
                 URL: https://issues.apache.org/jira/browse/ARIES-1989
             Project: Aries
          Issue Type: Bug
          Components: Blueprint
    Affects Versions: 1.0
            Reporter: Andrew MacGaffey
         Attachments: BugTestPlugin.zip, target_platform_blueprint.zip

Initializing a property with a "ref" element fails with complex generics

 
{code:java}
public interface EndpointHandler {}{code}
{{}}

 

 
{code:java}
public interface EndpointServer <H extends EndpointHandler>{}{code}
{{}}

 

 
{code:java}
public interface HandlerFactory <S> {}
{code}
 

 
{code:java}
public abstract class AbstractFactory <H extends EndpointHandler, S extends EndpointServer<H>>{
 HandlerFactory<S> handlerFactory = null;
 public HandlerFactory<S> getHandlerFactory() {
  return handlerFactory;
 }
 public void setHandlerFactory(HandlerFactory<S> handlerFactory) {
  this.handlerFactory = handlerFactory;
 }
}{code}
{{}}

 

 
{code:java}
public class ConcreteFactory extends AbstractFactory<MyHandler, MyServer<MyHandler>>
{ }{code}
 

 
{code:java}
public class ConcreteHandlerFactory implements HandlerFactory<MyServer<MyHandler>>
{}
{code}
 

 
{code:java}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
 xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.2.0">
 
 <bean id="concreteHandlerFactory" class="bugtest.ConcreteHandlerFactory" />
 <bean id="concreteFactory" class="bugtest.ConcreteFactory">
 <property name="handlerFactory" ref="concreteHandlerFactory" />
 </bean>
 
</blueprint>

{code}
The problem manifests in 
{code:java}
if (from.equals(to)) {
 return true;
 }
 if (from.getRawClass() == to.getRawClass()) {
 if (to.size() == 0) {
 return true;
 }
 if (from.size() == to.size()) {
 boolean ok = true;
 for (int i = 0; i < from.size(); i++) {
 ReifiedType tf = from.getActualTypeArgument(i);
 ReifiedType tt = to.getActualTypeArgument(i);
 if (!isWildcardCompatible(tf, tt)) {         <<================= HERE
 ok = false;
 break;
 }
 }
 if (ok) {
 return true;
 }
 }
 } else {
 ReifiedType t = getExactSuperType(from, to.getRawClass());
 if (t != null) {
 return isTypeAssignable(t, to);
 }
 }
 return false;
 }{code}
ReifiedType tt has the correct generic class EndpointServer but has 0 parameters. So the assignment
fails.

Hacking this with a property of type"Object" and a cast works. The type structure and assignment
also work in rather ancient spring-dm

 

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Mime
View raw message