You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/02/02 07:05:51 UTC
[jira] [Commented] (GROOVY-8069) Annotation based logging of
complex expression in closure throws GroovyCastException when statically
compiled
[ https://issues.apache.org/jira/browse/GROOVY-8069?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15849542#comment-15849542 ]
ASF GitHub Bot commented on GROOVY-8069:
----------------------------------------
GitHub user shils opened a pull request:
https://github.com/apache/groovy/pull/487
GROOVY-8069: Annotation based logging of complex expression in closur…
…e throws GroovyCastException with SC.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/shils/groovy GROOVY-8069
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/groovy/pull/487.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #487
----
commit e0be19e84308100e1a9b60a44c6458d33b071d84
Author: Shil Sinha <sh...@apache.org>
Date: 2017-02-02T06:48:01Z
GROOVY-8069: Annotation based logging of complex expression in closure throws GroovyCastException with SC
----
> Annotation based logging of complex expression in closure throws GroovyCastException when statically compiled
> -------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-8069
> URL: https://issues.apache.org/jira/browse/GROOVY-8069
> Project: Groovy
> Issue Type: Bug
> Components: Static compilation
> Affects Versions: 2.4.8
> Reporter: Shil Sinha
> Assignee: Shil Sinha
>
> Example:
> {code}
> @groovy.util.logging.Log
> @groovy.transform.CompileStatic
> class Foo {
> void bar() {
> def callable = {
> log.info('a' + 1)
> }
> callable.call()
> }
> }
> new Foo().bar()
> {code}
> The log statement in the code above results in the following runtime exception:
> {code}
> org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'Foo@14ec4505' with class 'Foo' to class 'java.util.logging.Logger'
> {code}
> The case where the closure is in a static method is similar; the object being cast to a Logger is a Class instead.
> This appears to be due to the implicitThis field being set incorrectly on the guard method call expression (log.isLoggable(Level) in the default case) created in implementations of LoggingStrategy.wrapLoggingMethodCall.
>
> Prior to Groovy 2.4.8, log statements inside closures were not guarded (https://issues.apache.org/jira/browse/GROOVY-6932), so this bug wasn't visible.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)