karaf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anton Johansson (JIRA)" <j...@apache.org>
Subject [jira] [Created] (KARAF-5177) Mismatching interface and implementation return type causes generic type loss
Date Fri, 02 Jun 2017 13:14:04 GMT
Anton Johansson created KARAF-5177:
--------------------------------------

             Summary: Mismatching interface and implementation return type causes generic
type loss
                 Key: KARAF-5177
                 URL: https://issues.apache.org/jira/browse/KARAF-5177
             Project: Karaf
          Issue Type: Bug
          Components: karaf-core
            Reporter: Anton Johansson


Hey!

We're running a quite old Karaf now, and we have plans on upgrading. We're running 2.4.2.

We just noticed a very strange and dangerous thing in our environment.

Say I have an interface:

public interface ITest {
    Collection<MyType> getTypes();
}

... and an implementation:
public class Test implements ITest {
    List<MyType> getTypes() {
        return emptyList();
    }
}

Notice the mismatching return types. We do some reflection based scanning when we create our
services. So if we analyze the class Test, and get the method #getTypes(), and then get the
generic return type (#getGenericReturnType()), it will give us the following declaration:
java.util.Collection

We should really get this declaration:
java.util.List<com.mypackage.MyType>

If I change so the return types match, I do get the correct declaration. As you can see, we
lose the generic information about the return type, which is devastation for us. It's also
very hard to notice this issue, because the generic return type is only used in some cases,
in a clustered environment.

Do you know why this happens?



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message