grails-core
grails-core copied to clipboard
@GrailsCompileStatic(TypeCheckingMode.SKIP) is generating an Index 0 out of bounds for length 0 error
Expected Behavior
My application was using Grails 5.1.2 and I decided to update to Grails 5.1.4 today. The project is getting some errors related to @GrailsCompileStatic(TypeCheckingMode.SKIP). On the previous version (5.1.2) was working as expected. I use this annotation on Controllers, Services and Domains.
this is the error Index 0 out of bounds for length 0
Any idea?
Actual Behaviour
- What went wrong: Execution failed for task ':compileGroovy'.
BUG! exception in phase 'semantic analysis' in source unit '/Users/adrian/Sites/hulimotors/myapp/grails-app/controllers/myapp/RestaurantController.groovy' Index 0 out of bounds for length 0
Steps To Reproduce
- curl -O https://start.grails.org/myapp.zip -d profile=rest-api -d features=events,mongodb,security
- cd myapp
- grails create-domain-class Restaurant
- grails generate-all myapp.Restaurant
- Add new action method on the Controller
- Add @GrailsCompileStatic to the Controller
.
Environment Information
macOS Monterey version 12.3
openjdk version "11.0.14" 2022-01-18 OpenJDK Runtime Environment Temurin-11.0.14+9 (build 11.0.14+9) OpenJDK 64-Bit Server VM Temurin-11.0.14+9 (build 11.0.14+9, mixed mode)
Example Application
No response
Version
5.1.4
Thank you for reporting the issue. I will take a look soon.
Does the compilation succeed if you use @groovy.transform.CompileDynamic
instead of @GrailsCompileStatic(TypeCheckingMode.SKIP)
?
Yes, it does. It's working with @groovy.transform.CompileDynamic annotation. Do We have to start using @CompileDynamic instead of @GrailsCompileStatic(TypeCheckingMode.SKIP) ? or In fact there is a bug about it in this 5.1.4 version
Do We have to start using @CompileDynamic instead of @GrailsCompileStatic(TypeCheckingMode.SKIP) ?
Not necessarily, but there may not be any good reason not to do that.
or In fact there is a bug about it in this 5.1.4 version
I have not debugged it but it appears to be a bug.
I've encountered the same issue upgrading a Grails app from 5.1.1 to 5.1.7 with a drain class that contains
@GrailsCompileStatic(TypeCheckingMode.SKIP)
I can confirm switching to @CompileDynamic
resolves the issue.
Any update here? We just upgraded our production app to Grails 5 and this seems to be a blocker.
@sagrawal31 just switch @GrailsCompileStatic(TypeCheckingMode.SKIP)
to @CompileDynamic
Hi, @codeconsole. Thanks for the reply. Yes, for now I moved forward with @CompileDynamic
. Thank you!
This is working fine for me till 5.3.3. BUT with 6.0.0 I am getting this issue.
BUG! exception in phase 'semantic analysis' in source unit 'MyService.groovy' Index 0 out of bounds for length 0
@CompileDynamic
resolve the issue
Any news regarding this bug? I've upgraded my app from Grails 4 to Grails 6 and I'm getting this issue too.
Removing @GrailsCompileStatic
or replacing it with @CompileDynamic
fixes the issue but is this actually the solution?