Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
4.0.9
-
None
Description
When a method that returns a value is used as a Consumer, a runtime Error is produced.
class BugRepro extends Specification { def 'repro'() { expect: new Demo().run() } } @CompileStatic class Demo { List<String> strings = [] void run() { Optional.of('hello') .ifPresent(strings::add) } }
Condition failed with Exception: new Demo().run() | | | java.lang.BootstrapMethodError: bootstrap method initialization exception | at java.base/java.lang.invoke.BootstrapMethodInvoker.invoke(BootstrapMethodInvoker.java:194) | at java.base/java.lang.invoke.CallSite.makeSite(CallSite.java:307) | at java.base/java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(MethodHandleNatives.java:258) | at java.base/java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:248) | at Demo.run(BugRepro.groovy:18) | at BugRepro.repro(BugRepro.groovy:9) | Caused by: java.lang.invoke.LambdaConversionException: Type mismatch for lambda expected return: boolean is not convertible to void | at java.base/java.lang.invoke.AbstractValidatingLambdaMetafactory.checkDescriptor(AbstractValidatingLambdaMetafactory.java:317) | at java.base/java.lang.invoke.AbstractValidatingLambdaMetafactory.validateMetafactoryArgs(AbstractValidatingLambdaMetafactory.java:294) | at java.base/java.lang.invoke.LambdaMetafactory.metafactory(LambdaMetafactory.java:328) | at java.base/java.lang.invoke.BootstrapMethodInvoker.invoke(BootstrapMethodInvoker.java:127) | ... 5 more <Demo@18e8473e strings=[]> at BugRepro.repro(BugRepro.groovy:9) Caused by: java.lang.BootstrapMethodError: bootstrap method initialization exception at java.base/java.lang.invoke.BootstrapMethodInvoker.invoke(BootstrapMethodInvoker.java:194) at java.base/java.lang.invoke.CallSite.makeSite(CallSite.java:307) at java.base/java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(MethodHandleNatives.java:258) at java.base/java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:248) at Demo.run(BugRepro.groovy:18) ... 1 more Caused by: java.lang.invoke.LambdaConversionException: Type mismatch for lambda expected return: boolean is not convertible to void at java.base/java.lang.invoke.AbstractValidatingLambdaMetafactory.checkDescriptor(AbstractValidatingLambdaMetafactory.java:317) at java.base/java.lang.invoke.AbstractValidatingLambdaMetafactory.validateMetafactoryArgs(AbstractValidatingLambdaMetafactory.java:294) at java.base/java.lang.invoke.LambdaMetafactory.metafactory(LambdaMetafactory.java:328) at java.base/java.lang.invoke.BootstrapMethodInvoker.invoke(BootstrapMethodInvoker.java:127) ... 5 more