We have JUnit tests written in Groovy and most method identifers contains periods. This is an example:
import org.junit.Assert
import org.junit.Test
class MethodNameTest {
@Test
void "test with ... dots "() {
Assert.assertTrue(false);
}
}
This was working using groovy 2.4.15 and JDK 8. However, after updating to JDK 11, we are now having "Illegal method name" errors:
Exception in thread "main" java.lang.ClassFormatError: Illegal method name "test with ... dots " in class MethodNameTest
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
We also tried updating groovy to 2.5.9 but it still gives this error. Is there any way to fix this when using jdk 11?
We had read that the dot character is not in the list of valid java identifiers (as per ยง3.8) but we are wondering why groovy can support it on JDK 8 but not in JDK 11. We can just modify the tests to adapt but we will be grateful if anyone can explain how and why this happens.
Thanks!
edit I am running the tests via Intellij IDEA. We have a gradle project that uses groovy as a dependency.