[
https://issues.apache.org/jira/browse/GROOVY-11091?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17731352#comment-17731352
]
Paul King commented on GROOVY-11091:
------------------------------------
Groovy "promotes" a "static main(args)" method to have a "void" return type and
"String[]" arg type. This is one of Groovy's "simpler scripting" features. You
don't need a String[] arg type but can use def or no type for the argument. So,
if you search instead for "String[]" arg type you will find your method. Or use
any parameter type except "Object" to avoid the "promotion".
This is by design but in theory could be finessed in several ways. We could
have a marker interface (say) which turned off this auto-promotion. We could
(and probably should) at least check for an existing main(String[]) variant and
not promote in that case (then you'd have a workaround of manually adding such
a method even if it did nothing).
We should probably also handle having a non-static main method since this is
what JEP 445 ("simpler scripting for Java") is meant to support.
> Reflection bug
> --------------
>
> Key: GROOVY-11091
> URL: https://issues.apache.org/jira/browse/GROOVY-11091
> Project: Groovy
> Issue Type: Bug
> Components: groovy-runtime
> Affects Versions: 4.0.12
> Environment: Linux 64
> Java 17.0.7
> Groovy 4.0.12
> Reporter: Blake McBride
> Priority: Minor
> Attachments: Test3.java, Test4.groovy
>
>
> groovyClass.getMethod throws an exception if the method name is "main" AND it
> takes a single, Object argument. The attached simple sample demonstrates it.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)