[ 
https://issues.apache.org/jira/browse/GROOVY-10652?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17551664#comment-17551664
 ] 

Eric Milles commented on GROOVY-10652:
--------------------------------------

The constructor referred to by {{groovy.lang.IntRange.<init>(boolean, boolean, 
int, int)}} is this one:
{code:java}
    /**
     * Creates a new inclusive aware <code>IntRange</code>
     *
     * @param inclusiveLeft     <code>true</code> if the from value is included 
in the range.
     * @param inclusiveRight    <code>true</code> if the to value is included 
in the range.
     * @param from              the first value in the range.
     * @param to                the last value in the range.
     */
    public IntRange(boolean inclusiveLeft, boolean inclusiveRight, int from, 
int to) {
        this.from = from;
        this.to = to;
        this.inclusiveRight = inclusiveRight;
        this.inclusiveLeft = inclusiveLeft;
        this.reverse = false; // range may still be reversed, this value is 
ignored for inclusive-aware ranges
        checkSize();
    }
{code}

It was added as part of GROOVY-9649 in 4.0a3.  You need a Groovy 4 runtime 
library on the classpath to have this.

> 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
>            Priority: Major
>
> The following code is an example of this fail:
> {code:groovy}
>     @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
>     }
> {code}
> This method is part of class Line! 
> Results in the following stack trace:
> {code}
> java.lang.NoSuchMethodError: 'void groovy.lang.IntRange.<init>(boolean, 
> boolean, int, int)'
> at se.natusoft.doc.markdown.io.Line.removeBegNumberDot(Line.groovy:160)
> at ...
> {code}
> 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)

Reply via email to