[
https://issues.apache.org/jira/browse/GROOVY-12591?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Scott Murphy Heiberg updated GROOVY-12591:
------------------------------------------
Description:
On master, a statically compiled method or constructor reference with a String
parameter inside an interface makes the interface fail to load:
{code:groovy}
@groovy.transform.CompileStatic
interface I {
static java.util.function.Function<String, String> f() { String::trim }
}
I.f()
{code}
{noformat}
java.lang.ClassFormatError: Method gstring$String$trim$1 in class I has illegal
modifiers: 0x101A
{noformat}
GROOVY-12536 adds a synthetic adapter method that converts a GString argument
to String, and creates it {{private static final}}. The JVM rejects
{{ACC_FINAL}} on an interface method (JVMS 4.6). The other helper methods of
method references leave out {{ACC_FINAL}} in interfaces since GROOVY-12488. No
test of GROOVY-12536 had a method reference in an interface;
{{MethodReferenceTest.testMethodReferencesInStaticAndDefaultMethodsOfInterface}}
from GROOVY-12488 has, and fails on master since both were merged, on every
JDK.
Affects master only (7.0.0-SNAPSHOT); no release has both changes.
was:
On master, a statically compiled method or constructor reference with a String
parameter inside an interface makes the interface fail to load:
{code:groovy}
@groovy.transform.CompileStatic
interface I {
static java.util.function.Function<String, String> f() { String::trim }
}
I.f()
{code}
{noformat}
java.lang.ClassFormatError: Method gstring$... in class I has illegal
modifiers: 0x101A
{noformat}
GROOVY-12536 adds a synthetic adapter method that converts a GString argument
to String, and creates it {{private static final}}. The JVM rejects
{{ACC_FINAL}} on an interface method (JVMS 4.6). The other helper methods of
method references leave out {{ACC_FINAL}} in interfaces since GROOVY-12488;
each change passed on its own, and together they fail
{{MethodReferenceTest.testMethodReferencesInStaticAndDefaultMethodsOfInterface}}
on master, on every JDK.
Affects master only (7.0.0-SNAPSHOT); no release has both changes.
> SC: a method reference in an interface fails to load with ClassFormatError:
> the GString adapter method is final
> ---------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-12591
> URL: https://issues.apache.org/jira/browse/GROOVY-12591
> Project: Groovy
> Issue Type: Bug
> Reporter: Scott Murphy Heiberg
> Priority: Major
>
> On master, a statically compiled method or constructor reference with a
> String parameter inside an interface makes the interface fail to load:
> {code:groovy}
> @groovy.transform.CompileStatic
> interface I {
> static java.util.function.Function<String, String> f() { String::trim }
> }
> I.f()
> {code}
> {noformat}
> java.lang.ClassFormatError: Method gstring$String$trim$1 in class I has
> illegal modifiers: 0x101A
> {noformat}
> GROOVY-12536 adds a synthetic adapter method that converts a GString argument
> to String, and creates it {{private static final}}. The JVM rejects
> {{ACC_FINAL}} on an interface method (JVMS 4.6). The other helper methods of
> method references leave out {{ACC_FINAL}} in interfaces since GROOVY-12488.
> No test of GROOVY-12536 had a method reference in an interface;
> {{MethodReferenceTest.testMethodReferencesInStaticAndDefaultMethodsOfInterface}}
> from GROOVY-12488 has, and fails on master since both were merged, on every
> JDK.
> Affects master only (7.0.0-SNAPSHOT); no release has both changes.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)