You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2022/02/03 22:33:01 UTC

[jira] [Closed] (GROOVY-10103) Lambda with command method call fails with cast exception

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

Paul King closed GROOVY-10103.
------------------------------

> Lambda with command method call fails with cast exception
> ---------------------------------------------------------
>
>                 Key: GROOVY-10103
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10103
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 4.0.0-alpha-3
>            Reporter: Eric Milles
>            Priority: Major
>             Fix For: 4.0.0-beta-2
>
>         Attachments: image-2021-05-21-12-09-03-211.png
>
>
> Consider the following:
> {code:groovy}
> import java.util.function.*
> Supplier<String> s = () -> 'hello'
> print s.get()
> Consumer<String> c = x -> print x;
> c.accept(' ')
> Function<Integer, String> f = (Integer i) -> { 'world' }
> print f(42)
> {code}
> This script prints "hello world" under Groovy 3 but fails at runtime under Groovy 4 with exception:
> {code}
> org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'interface java.util.function.Consumer' with class 'java.lang.Class' to class 'java.util.function.Consumer'
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)