aries-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (ARIES-1849) Aries proxy does not work with interface default methods
Date Thu, 10 Jan 2019 14:55:00 GMT

    [ https://issues.apache.org/jira/browse/ARIES-1849?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16739484#comment-16739484
] 

ASF GitHub Bot commented on ARIES-1849:
---------------------------------------

GitHub user rovarga opened a pull request:

    https://github.com/apache/aries/pull/94

    [ARIES-1849] do not use invokevirtual for interface default methods

    A default method is still an interface method, hence we should use invokeinterface, not
invokevirtual, otherwise we will get an IncompatibleClassChangeError from hotspot.
    
    Signed-off-by: Robert Varga <robert.varga@pantheon.tech>

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/rovarga/aries aries1849

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/aries/pull/94.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #94
    
----
commit 00ea87b194df241765df0c4af324735a16f70345
Author: Robert Varga <robert.varga@...>
Date:   2019-01-10T14:51:48Z

    [ARIES-1849] do not use invokevirtual for interface default methods
    
    Signed-off-by: Robert Varga <robert.varga@pantheon.tech>

----


> Aries proxy does not work with interface default methods
> --------------------------------------------------------
>
>                 Key: ARIES-1849
>                 URL: https://issues.apache.org/jira/browse/ARIES-1849
>             Project: Aries
>          Issue Type: Bug
>          Components: Proxy
>    Affects Versions: proxy-impl-1.1.2
>            Reporter: Nicolas Dutertry
>            Priority: Major
>
> Since Java 8 it is possible to define default implementations inside interface definition.
> It seems that Aries proxy is not compatible with interface default methods. As a result
it is not possible to use a blueprint reference to a service implementing an interface with
default method.
> The following unit test demonstrates the issue :
> {code:java}
> import java.util.Collections;
> import org.apache.aries.proxy.UnableToProxyException;
> import org.apache.aries.proxy.impl.interfaces.InterfaceProxyGenerator;
> import org.junit.Assert;
> import org.junit.Test;
> public class InterfaceProxyGeneratorTest {
>     public static interface Service {
>         String getName();
>         
>         default String getValue() {
>             return "default";
>         }
>     }
>     
>     public static class ServiceImpl implements Service {
>         @Override
>         public String getName() {
>             return "serviceimpl";
>         }
>         
>         @Override
>         public String getValue() {
>             return "value";
>         }
>     }
>     
>     @Test
>     public void testProxy() throws UnableToProxyException {
>         ServiceImpl serviceImpl = new ServiceImpl();
>         Assert.assertEquals("serviceimpl", serviceImpl.getName());
>         Assert.assertEquals("value", serviceImpl.getValue());
>         
>         Service proxy = (Service)InterfaceProxyGenerator.getProxyInstance(
>             null, null, Collections.singleton(Service.class),
>             () -> {
>                 return serviceImpl;
>             },
>             null);
>         
>         Assert.assertNotNull(proxy);        
>         Assert.assertEquals("serviceimpl", proxy.getName());
>         Assert.assertEquals("value", proxy.getValue());
>     }
> }{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message