You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2022/05/21 15:04:00 UTC
[jira] [Commented] (GROOVY-9853) ClassFormatError using method reference on interface target
[ https://issues.apache.org/jira/browse/GROOVY-9853?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17540440#comment-17540440 ]
Eric Milles commented on GROOVY-9853:
-------------------------------------
Isolated a bit further:
{code:groovy}
import java.util.function.Function
@groovy.transform.CompileStatic
def test() {
Function<CharSequence, Integer> f = CharSequence::length
f.apply("")
}
print test()
{code}
Java equivalent that runs successfully:
{code:java}
import java.util.function.Function;
public class Groovy9853 {
public static void main(String[] args) throws Exception {
Function<CharSequence, Integer> f = CharSequence::length;
System.err.println(f.apply(""));
}
}
{code}
> ClassFormatError using method reference on interface target
> -----------------------------------------------------------
>
> Key: GROOVY-9853
> URL: https://issues.apache.org/jira/browse/GROOVY-9853
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 3.0.7, 4.0.2
> Reporter: Christopher Smith
> Priority: Major
>
> After upgrading to 3.0.7, using {{interfaceField::method}} is resulting in bytecode output containing an InterfaceMethodref that looks as expected. When running it in the Eclipse JUnit runner, however (which I think is unimportant), I'm getting a loading error from the JVM:
> {code}
> Caused by: java.lang.ClassFormatError: Invalid constant pool index 130 in class file com/example/sendgrid/SendgridMailSender (not a method)
> {code}
> where the offending constant is
> {code}
> #130 = InterfaceMethodref #126.#129 // com/sendgrid/SendGridAPI.api:(Lcom/sendgrid/Request;)Lcom/sendgrid/Response;
> {code}
> from the 4.6.8 SendGrid SDK.
> Compiling with 3.0.6 seems to work. Replacing {{::}} with {{.&}} seems to work.
> The JVM is 11.0.9-hs-adpt.
--
This message was sent by Atlassian Jira
(v8.20.7#820007)