Tommy Svensson created GROOVY-10652:
---------------------------------------
Summary: Code that worked in Groovy 3 throws exception in Groovy
4.0.1
Key: GROOVY-10652
URL: https://issues.apache.org/jira/browse/GROOVY-10652
Project: Groovy
Issue Type: Bug
Reporter: Tommy Svensson
The following code is an example of this fail:
{{ @NotNull Line removeBegNumberDot() {}}
{{ Line line = this}}
{{ if (this.origLine.trim() =~ /^[0-9]+\..*/){ final int ix =
this.origLine.indexOf(".") }}
{{ // As of Groovy 4 this no longer works! }}
{{ // line = newLine(this.origLine[(ix+1)..-1]) line =
newLine(this.origLine[(ix+1)..-1]) }}{{// <-- }}
{{ }}}
{{ line}}
{{ }}}
{{This method is part of class Line!}}
Results in the following stack trace:
java.lang.NoSuchMethodError: 'void groovy.lang.IntRange.<init>(boolean,
boolean, int, int)'
at se.natusoft.doc.markdown.io.Line.removeBegNumberDot(Line.groovy:160)
at ...
In Groovy 3 this both compiles and executes without problem, but with Groovy
4.0.1 it does compile, but gets above exception when executed. It looks like
there is functionality missing the the Groovy 4.0.1 runtime library for
groovy.lang.IntRange. But it is the Groovy 4.0.1 compiler that has produced the
code that uses IntRange, so it can possibly produce the wrong code.
For now I have to rewrite this method doing it the Java way rather than the
Groovy way.
Again, the code does compile, but the compiler produces code that can't be
executed.
It is being built for JDK 11 byte code. Don't believe that matters though.
--
This message was sent by Atlassian Jira
(v8.20.7#820007)