Details
Description
When a plugin contains an Immutable class (annotated with @Immutable), an application with this plugin installed sometimes fails to compile, giving this stacktrace:
[groovyc] org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
[groovyc] General error during canonicalization: Explicit constructors not allowed for @Immutable class: ImmutableExample
[groovyc]
[groovyc] java.lang.RuntimeException: Explicit constructors not allowed for @Immutable class: ImmutableExample
[groovyc] at org.codehaus.groovy.transform.ImmutableASTTransformation.createConstructor(ImmutableASTTransformation.java:308)
[groovyc] at org.codehaus.groovy.transform.ImmutableASTTransformation.visit(ImmutableASTTransformation.java:117)
[groovyc] at org.codehaus.groovy.transform.ASTTransformationVisitor.visitClass(ASTTransformationVisitor.java:129)
...
This only happens the first time you compile the application, and only when another plugin is also installed. I have been able to reproduce it with the shiro plugin and with the spring-security-core plugin.
Steps to reproduce:
1. create a new plugin 'immutable-bug-plugin'
2. in this plugin, create a Groovy class 'ImmutableExample', annotated with @Immutable. The class should be under src/groovy
3. in this same plugin, create a service, 'ImmutableService'. In a service method, a new instance of the ImmutableExample class should be created, for example: def example = new ImmutableExample('hello', 'world')
4. create a new application 'immutable-bug-demo'
5. in the BuildConfig, add an inline dependency to the plugin you just created: grails.plugin.location.'immutable-bug-plugin'='../immutable-bug-plugin'
6. install the shiro plugin in the application
7. execute 'grails run-app': the compilation will fail
8. execute 'grails run-app' again: the compilation will succeed
A sample plugin and application was attached to this issue.
Issue Links
- depends on
-
GRAILS-7981
Upgrade to Groovy 1.8.2
-
Activity
- All
- Comments
- Work Log
- History
- Activity
- Git Commits