Possible bug assigning null to a boolean

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Possible bug assigning null to a boolean

Andrew Eisenberg
I am seeing the following behavior

[10:48] /tmp
$ groovy -version
Groovy Version: 2.1.1 JVM: 1.6.0_65 Vendor: Apple Inc. OS: Mac OS X

[10:46] /tmp
$ cat bad.groovy
boolean isnull = null
println isnull

[10:47] /tmp
$ groovy bad.groovy
Caught: java.lang.VerifyError: (class: trying2, method: run signature:
()Ljava/lang/Object;) Expecting to find integer on stack
java.lang.VerifyError: (class: trying2, method: run signature:
()Ljava/lang/Object;) Expecting to find integer on stack

[10:49] /tmp
$ cat good.groovy

def x = null
boolean isnull = x
println isnull

[10:49] /tmp
$ groovy good.groovy
false

Seems a little odd, no? I would expect the same result for both
scripts.  The verify error implies this is a compiler problem.  I'll
raise a bug for this if you think this is unexpected behavior.

thanks,
Andrew

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Possible bug assigning null to a boolean

Cédric Champeau
Hi Andrew,

I think you are facing https://jira.codehaus.org/browse/GROOVY-6419, fixed in 2.1.8.

Le 14/01/2014 19:52, Andrew Eisenberg a écrit :
I am seeing the following behavior

[10:48] /tmp
$ groovy -version
Groovy Version: 2.1.1 JVM: 1.6.0_65 Vendor: Apple Inc. OS: Mac OS X

[10:46] /tmp
$ cat bad.groovy
boolean isnull = null
println isnull

[10:47] /tmp
$ groovy bad.groovy
Caught: java.lang.VerifyError: (class: trying2, method: run signature:
()Ljava/lang/Object;) Expecting to find integer on stack
java.lang.VerifyError: (class: trying2, method: run signature:
()Ljava/lang/Object;) Expecting to find integer on stack

[10:49] /tmp
$ cat good.groovy

def x = null
boolean isnull = x
println isnull

[10:49] /tmp
$ groovy good.groovy
false

Seems a little odd, no? I would expect the same result for both
scripts.  The verify error implies this is a compiler problem.  I'll
raise a bug for this if you think this is unexpected behavior.

thanks,
Andrew

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email






-- 
Cédric Champeau
SpringSource - Pivotal
http://spring.io/
http://www.gopivotal.com/
http://twitter.com/CedricChampeau
Reply | Threaded
Open this post in threaded view
|

Re: Possible bug assigning null to a boolean

Andrew Eisenberg-2
Thanks!

Can't upgrade yet, but will try to soon. Actually, my company's still
using Groovy 1.8.6. :(

On Tue, Jan 14, 2014 at 11:06 AM, Cédric Champeau
<[hidden email]> wrote:

> Hi Andrew,
>
> I think you are facing https://jira.codehaus.org/browse/GROOVY-6419, fixed
> in 2.1.8.
>
> Le 14/01/2014 19:52, Andrew Eisenberg a écrit :
>
> I am seeing the following behavior
>
> [10:48] /tmp
> $ groovy -version
> Groovy Version: 2.1.1 JVM: 1.6.0_65 Vendor: Apple Inc. OS: Mac OS X
>
> [10:46] /tmp
> $ cat bad.groovy
> boolean isnull = null
> println isnull
>
> [10:47] /tmp
> $ groovy bad.groovy
> Caught: java.lang.VerifyError: (class: trying2, method: run signature:
> ()Ljava/lang/Object;) Expecting to find integer on stack
> java.lang.VerifyError: (class: trying2, method: run signature:
> ()Ljava/lang/Object;) Expecting to find integer on stack
>
> [10:49] /tmp
> $ cat good.groovy
>
> def x = null
> boolean isnull = x
> println isnull
>
> [10:49] /tmp
> $ groovy good.groovy
> false
>
> Seems a little odd, no? I would expect the same result for both
> scripts.  The verify error implies this is a compiler problem.  I'll
> raise a bug for this if you think this is unexpected behavior.
>
> thanks,
> Andrew
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
>
>
>
>
> --
> Cédric Champeau
> SpringSource - Pivotal
> http://spring.io/
> http://www.gopivotal.com/
> http://twitter.com/CedricChampeau

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Possible bug assigning null to a boolean

Jochen Theodorou
In reply to this post by Andrew Eisenberg
Am 14.01.2014 19:52, schrieb Andrew Eisenberg:

> I am seeing the following behavior
>
> [10:48] /tmp
> $ groovy -version
> Groovy Version: 2.1.1 JVM: 1.6.0_65 Vendor: Apple Inc. OS: Mac OS X
>
> [10:46] /tmp
> $ cat bad.groovy
> boolean isnull = null
> println isnull
>
> [10:47] /tmp
> $ groovy bad.groovy
> Caught: java.lang.VerifyError: (class: trying2, method: run signature:
> ()Ljava/lang/Object;) Expecting to find integer on stack
> java.lang.VerifyError: (class: trying2, method: run signature:
> ()Ljava/lang/Object;) Expecting to find integer on stack

can you try the newest Groovy version? I think I fixed a bug like that

> [10:49] /tmp
> $ cat good.groovy
>
> def x = null
> boolean isnull = x
> println isnull
>
> [10:49] /tmp
> $ groovy good.groovy
> false
>
> Seems a little odd, no? I would expect the same result for both
> scripts.  The verify error implies this is a compiler problem.  I'll
> raise a bug for this if you think this is unexpected behavior.

in the second case x is an object for the groovy compiler, so it emits
code, that transforms that object into a boolean. In the second case the
compiler wrongly assumes null can be directly assigned and thus is
compiling this wrong.

bye blackdrag

--
Jochen "blackdrag" Theodorou - Groovy Project Tech Lead
blog: http://blackdragsview.blogspot.com/
german groovy discussion newsgroup: de.comp.lang.misc
For Groovy programming sources visit http://groovy-lang.org


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Possible bug assigning null to a boolean

Andrew Eisenberg-2
In reply to this post by Cédric Champeau
Yep. Fixed on Groovy 2.2.1. Thanks.

On Tue, Jan 14, 2014 at 11:06 AM, Cédric Champeau
<[hidden email]> wrote:

> Hi Andrew,
>
> I think you are facing https://jira.codehaus.org/browse/GROOVY-6419, fixed
> in 2.1.8.
>
> Le 14/01/2014 19:52, Andrew Eisenberg a écrit :
>
> I am seeing the following behavior
>
> [10:48] /tmp
> $ groovy -version
> Groovy Version: 2.1.1 JVM: 1.6.0_65 Vendor: Apple Inc. OS: Mac OS X
>
> [10:46] /tmp
> $ cat bad.groovy
> boolean isnull = null
> println isnull
>
> [10:47] /tmp
> $ groovy bad.groovy
> Caught: java.lang.VerifyError: (class: trying2, method: run signature:
> ()Ljava/lang/Object;) Expecting to find integer on stack
> java.lang.VerifyError: (class: trying2, method: run signature:
> ()Ljava/lang/Object;) Expecting to find integer on stack
>
> [10:49] /tmp
> $ cat good.groovy
>
> def x = null
> boolean isnull = x
> println isnull
>
> [10:49] /tmp
> $ groovy good.groovy
> false
>
> Seems a little odd, no? I would expect the same result for both
> scripts.  The verify error implies this is a compiler problem.  I'll
> raise a bug for this if you think this is unexpected behavior.
>
> thanks,
> Andrew
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
>
>
>
>
> --
> Cédric Champeau
> SpringSource - Pivotal
> http://spring.io/
> http://www.gopivotal.com/
> http://twitter.com/CedricChampeau

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email