You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@karaf.apache.org by "Jean-Baptiste Onofré (JIRA)" <ji...@apache.org> on 2018/04/09 12:44:00 UTC

[jira] [Resolved] (KARAF-5177) Mismatching interface and implementation return type causes generic type loss

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

Jean-Baptiste Onofré resolved KARAF-5177.
-----------------------------------------
    Resolution: Cannot Reproduce

I'm not able to reproduce your issue. Can you please provide a complete test case ?

> 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
>            Priority: Major
>
> 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:
> {code}
> public interface ITest {
>     Collection<MyType> getTypes();
> }
> {code}
> ... and an implementation:
> {code}
> public class Test implements ITest {
>     List<MyType> getTypes() {
>         return emptyList();
>     }
> }
> {code}
> 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
(v7.6.3#76005)