Kotlin Back-Tick escaping in method names: How does it work?

s1m0nw1 :

In Kotlin, it's possible to name a method using back-ticks like this:

fun `i am a test method`(){
   Assert.assertEquals("x", "x")
}

The compiler generates a method with underscores instead of blanks: "i_am_a_test_method", which seems reasonable as the JVM does not permit methods with blanks afaik. How can Junit and/or Gradle report these tests with the back-ticked name though?

yole :

In a Java method descriptor, several characters have a special meaning, namely [ ( ) / and ;. The space doesn't have any special meaning, and therefore it can be used directly in a method name; that's exactly what the compiler does. The spaces are not converted to underscores.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=466013&siteId=1