[ https://issues.apache.org/jira/browse/GROOVY-9523?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles updated GROOVY-9523: -------------------------------- Labels: enum (was: ) > MissingMethodException when referencing a private enum method > ------------------------------------------------------------- > > Key: GROOVY-9523 > URL: https://issues.apache.org/jira/browse/GROOVY-9523 > Project: Groovy > Issue Type: Bug > Components: groovy-runtime > Affects Versions: 2.5.11 > Reporter: Mauro Molinari > Priority: Major > Labels: enum > > Consider this Groovy class: > > {code:groovy} > package test64 > import groovy.transform.CompileDynamic > import groovy.transform.CompileStatic > @CompileStatic > class Test64 { > @CompileDynamic > static enum ShippingAddressSynchType { > ACCOUNTING { > @Override > void synch(Test64 customer) { > truncate('foo', 2) > } > }; > void synch(Test64 customer) { } > private String truncate(String input, int maxLength) { > if(!input) > return input > if(input.length() > maxLength) > input = input[0..maxLength - 1] > return input > } > } > } > {code} > and a Java class to run it: > {code:java} > package test64; > import test64.Test64.ShippingAddressSynchType; > public class Test64Main { > public static void main(String[] args) { > Test64 t = new Test64(); > ShippingAddressSynchType.ACCOUNTING.synch(t); > } > } > {code} > If you run this code, you'll get: > {noformat} > Exception in thread "main" groovy.lang.MissingMethodException: No signature > of method: test64.Test64$ShippingAddressSynchType$1.truncate() is applicable > for argument types: (String, Integer) values: [foo, 2] > at > org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:70) > at > org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:83) > at > org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51) > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:156) > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:176) > at test64.Test64$ShippingAddressSynchType$1.synch(Test64.groovy:14) > at test64.Test64Main.main(Test64Main.java:9) > {noformat} -- This message was sent by Atlassian Jira (v8.20.10#820010)