0

Migration from grails 3.3.5 -> grails 4.0.0.M2

My class has been annotated with @GrailsCompileStatic & it used to compile without any issues in 3.3.5.

Many other classes are also showing errors for methods which are additionally provided by groovy such as Date.parse() or Date.format() or Date.minus()

Error:

FileCommandReader.groovy: 163: [Static type checking] - Cannot find matching method java.util.Date#parse(java.lang.String, java.lang.String). Please check if the declared type is correct and if the method exists.
 @ line 163, column 17.
                Date expiry = Date.parse("HH:mm:ss", cols[2]);
Pritesh Mhatre
  • 3,847
  • 2
  • 23
  • 27

1 Answers1

1

This isn't really a @GrailsCompileStatic issue. Grails 4.0 uses Groovy 2.5.6. The following code will not compile with Groovy 2.5.6...

import groovy.transform.CompileStatic

@CompileStatic
class Helper {

    void someMethod() {
        Date.parse '', ''
    }
}

Grails 3.3.5 uses Groovy 2.4.15 and the code above is valid in Groovy 2.4.15.

Jeff Scott Brown
  • 26,804
  • 2
  • 30
  • 47
  • 1
    The groovy-dateutil methods are an optional module in Groovy 2.5 making way for the now recommended groovy-datetime module (java.time package). You need to add the extra groovy-dateutil dependency if you want to use those extension methods. – Paul King Mar 28 '19 at 21:55
  • Thanks @PaulKing will use alternate options. – Pritesh Mhatre Mar 29 '19 at 03:17