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

Eric Milles updated GROOVY-11363:
---------------------------------
    Affects Version/s: 3.0.21

> Bootstrap method error for method reference used with a primitive literal
> -------------------------------------------------------------------------
>
>                 Key: GROOVY-11363
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11363
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 3.0.21, 5.0.0-alpha-8, 4.0.21
>            Reporter: Paul King
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 5.0.0-alpha-9, 4.0.22
>
>
> This code:
> {code}
> import groovy.transform.CompileStatic
> import java.util.function.Supplier
> @CompileStatic
> Supplier<String> method() {
>     5::toString
> }
> method().get()
> {code}
> Fails with this error:
> {noformat}
> java.lang.BootstrapMethodError: bootstrap method initialization exception
>       at 
> java.base/java.lang.invoke.BootstrapMethodInvoker.invoke(BootstrapMethodInvoker.java:188)
>       at java.base/java.lang.invoke.CallSite.makeSite(CallSite.java:315)
>       at 
> java.base/java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(MethodHandleNatives.java:281)
>       at 
> java.base/java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:271)
>       at ConsoleScript9.method(ConsoleScript9:6)
>         ...
> Caused by: java.lang.invoke.LambdaConversionException: Type mismatch in 
> captured lambda parameter 0: expecting int, found class java.lang.Object
> {noformat}
> It seems like 3.0.x versions are unaffected and 4.0.13 was the first version 
> exhibiting this behavior.
> My initial expectation is that the wrapper type/boxed version should be used.
> See also:
> https://stackoverflow.com/questions/78369048/groovy3-how-to-get-java-lambdas-instead-of-closures



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to