groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul King (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (GROOVY-7330) Incorrect dynamic proxy creation from map when there are default methods
Date Sun, 19 Aug 2018 07:03:00 GMT

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

Paul King resolved GROOVY-7330.
-------------------------------
       Resolution: Fixed
         Assignee: Paul King
    Fix Version/s: 2.5.3

Proposed PR merged. Thanks for spotting the issue.

> Incorrect dynamic proxy creation from map when there are default methods
> ------------------------------------------------------------------------
>
>                 Key: GROOVY-7330
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7330
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 2.4.1
>            Reporter: Dmitry Ovchinnikov
>            Assignee: Paul King
>            Priority: Critical
>              Labels: Java_8, default-methods
>             Fix For: 2.5.3
>
>
> {code:java}
> package org.dimitrovchi.groovybugs;
> import groovy.lang.GroovyShell;
> import org.codehaus.groovy.control.CompilerConfiguration;
> import org.codehaus.groovy.runtime.DefaultGroovyMethods;
> import org.junit.Assert;
> import org.junit.Test;
> import java.util.Map;
> /**
>  * @author Dmitry Ovchinnikov
>  */
> public class MapToProxyTest {
>     private final GroovyShell shell;
>     public MapToProxyTest() {
>         final CompilerConfiguration cc = new CompilerConfiguration();
>         cc.setTargetBytecode(CompilerConfiguration.JDK8);
>         shell = new GroovyShell(cc);
>     }
>     @Test
>     public void testMapToProxy() {
>         final Map map = (Map) shell.evaluate("[x: {10}, y: {20}]");
>         final SomeInterface si = DefaultGroovyMethods.asType(map, SomeInterface.class);
>         Assert.assertEquals(20, si.y());
>         Assert.assertEquals(10, si.x()); // assertion error: si.x() == 1
>     }
>     public interface SomeInterface {
>         default int x() {
>             return 1;
>         }
>         int y();
>     }
> }
> {code}
> JDK 1.8u31



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

Mime
View raw message