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/22 15:57:00 UTC

[jira] [Updated] (GROOVY-8724) Groovy static methods with dots causes compilation error

     [ https://issues.apache.org/jira/browse/GROOVY-8724?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eric Milles updated GROOVY-8724:
--------------------------------
    Labels: ClassFormatError  (was: )

> Groovy static methods with dots causes compilation error
> --------------------------------------------------------
>
>                 Key: GROOVY-8724
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8724
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.4.15, 2.5.2
>         Environment: Linux 16.04 Java 1.8.0_171 IDEA Community Edition 2018.1.6
>            Reporter: Markov Alexey
>            Priority: Major
>              Labels: ClassFormatError
>
> I have a problem with methods that have dots in their name. Here's a code example
>  
> {code:java}
> class SomeList {
>     SomeList(String field) {
>     }
>     static SomeList "Regular name of method"() {
>         println("regular method")
>     }
>     static SomeList "Name with.dot"() {
>         println("method with dot")
>     }
> }
> {code}
> and i have test for it which cause compilation error:
>  
>  
> {code:java}
> class SomeListTests {
>     @Test
>     def "some list test"() {
>         //given
>         SomeList list = new SomeList()
>         //when
>         list."Regular name of method"()
>         //then
>         //compilation error
>     }
> }
> {code}
> Even if i run it in IDEA or with ./gradlew test it crashes with error:
>  
>  
> {code:java}
> Error:Groovyc: While compiling tests of example-project_test: BUG! exception in phase 'semantic analysis' in source unit '/home/alex/Projects/example-project/src/test/groovy/SomeListTests.groovy' Problem loading class SomeList
> at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:970)
> ... and so on i can drop all at comments{code}
> BUT if i run Groovy script like this:
>  
> Script:
>  
> {code:java}
> SomeList."Regular name of method"()
> SomeList."Name with.dot"()
> {code}
> Run:
>  
>  
> {code:java}
> class Main {
>     public static void main(String[] args) {
>         GroovyShell shell = new GroovyShell()
>         shell.run(new File("""pathToFile/Script.groovy"""), Collections.emptyList())
>         println "Everything is cool"
>     }
> }
> {code}
> I have everything perfect:
>  
> {code:java}
> regular method
> method with dot
> Everything is cool
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.20.7#820007)