[ https://issues.apache.org/jira/browse/GROOVY-8724?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16580768#comment-16580768 ]
Paul King edited comment on GROOVY-8724 at 8/15/18 7:48 AM: ------------------------------------------------------------ The JVM doesn't allow particular characters in identifiers: {{. ; [ /}} (that is, period or semicolon or left square bracket or forward slash) nor {{<}} and {{>}} except for the special names {{<init>}} and {{<clinit>}}: https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.2.2 There might be times when Groovy let's you sneak in some additional characters so long as your class is in memory and not written out to a class file. If there is, you can argue that we should report an error in such cases if you try to write out to a classfile. But long story short - I'd recommend not using those characters. was (Author: paulk): The JVM doesn't allow particular characters in identifiers: {{. ; [ /}} (that is, period or semicolon or left square bracket or forward slash) nor {{<}} and {{>}} except for the special names {{<init>}} and {{<clinit>}}: https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.2.2 Groovy let's you sneak in some additional characters so long as your class is in memory and not written out to a class file. You can argue that we should report an error in such cases if you try to write out to a classfile. > 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 > Environment: Linux 16.04 Java 1.8.0_171 IDEA Community Edition > 2018.1.6 > Reporter: Markov Alexey > Priority: Major > > 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 (v7.6.3#76005)