groovyc allows compiling methods with < and > in its name

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

groovyc allows compiling methods with < and > in its name

Alvarez, David
Hi,

We have found out that although something like:
public class Repro {

  def "bad<_>method"() {
  }

  void test() {
    println "Passed"
  }

  public static void main(String[] args) {
    Repro r = new Repro()
    r.test()
  }
}

Will not run in groovy, groovyc will happily compile it into a
classfile. That classfile can be later executed by OpenJDK8u265 (but
not by newer versions).

The .class file generated by groovy (tested with 3.0.6) would be a
classfile with major version 52, which corresponds to JDK8. According
to the JVM spec [1], that would be an illegal name.

For what I've read in the groovy syntax, it seems that < and > (U+003C
and U+003E) are not valid in groovy either [2]

I mention this because starting with OpenJDK8, stricter checks will be
performed when loading a classfile into the JVM, and the previous
example would cause a ClassFormatError.

There is also a discussion in the jdk8u-dev mailing list about this:
https://mail.openjdk.java.net/pipermail/jdk8u-dev/2020-October/012760.html


David

---
[1]
https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.2.2
[2]
http://docs.groovy-lang.org/next/html/documentation/#_normal_identifiers


signature.asc (501 bytes) Download Attachment