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

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()

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:



signature.asc (501 bytes) Download Attachment