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 2015/10/23 03:19:27 UTC

[jira] [Commented] (GROOVY-7644) ExternalizeMethods generates incorrect bytecode for statically compiled nested classes

    [ https://issues.apache.org/jira/browse/GROOVY-7644?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14970243#comment-14970243 ] 

ASF GitHub Bot commented on GROOVY-7644:
----------------------------------------

GitHub user shils opened a pull request:

    https://github.com/apache/incubator-groovy/pull/157

    GROOVY-7644 ExternalizeMethods generates incorrect bytecode for stati…

    …cally compiled nested classes

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/shils/incubator-groovy GROOVY-7644

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-groovy/pull/157.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 #157
    
----
commit 8b1107aa24fedad567d5f72e3dcb0cdfae84ca5e
Author: Shil Sinha <sh...@apache.org>
Date:   2015-10-23T01:16:49Z

    GROOVY-7644 ExternalizeMethods generates incorrect bytecode for statically compiled nested classes

----


> ExternalizeMethods generates incorrect bytecode for statically compiled nested classes
> --------------------------------------------------------------------------------------
>
>                 Key: GROOVY-7644
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7644
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation
>    Affects Versions: 2.4.5
>         Environment: OSX 10.10, JDK 1.8
>            Reporter: Shil Sinha
>            Assignee: Cédric Champeau
>
> When @AutoExternalize and @CompileStatic are both applied to a nested (static) class, the generated writeExternal and readExternal methods call writeObject/readObject on 'this' rather than on their arguments. This results in IncompatibleClassChange errors at runtime. Example:
> {code}
> class Person {
>     @groovy.transform.ToString(includePackage=false)
>     @groovy.transform.AutoExternalize
>     @groovy.transform.CompileStatic
>     static class AddressCS {
>         String street, town
>     }
> }
> {code}
> The bytecode generated for the Person.AddressCS.writeExternal method is:
> {code}
> public writeExternal(Ljava/io/ObjectOutput;)V throws java/io/IOException 
>    L0
>     ALOAD 0
>     ALOAD 0
>     GETFIELD Person$AddressCS.street : Ljava/lang/String;
>     INVOKEINTERFACE java/io/ObjectOutput.writeObject (Ljava/lang/Object;)V
>     ACONST_NULL
>     POP
>     ALOAD 0
>     ALOAD 0
>     GETFIELD Person$AddressCS.town : Ljava/lang/String;
>     INVOKEINTERFACE java/io/ObjectOutput.writeObject (Ljava/lang/Object;)V
>     ACONST_NULL
>     POP
>    L1
>     RETURN
>     LOCALVARIABLE this LPerson$AddressCS; L0 L1 0
>     LOCALVARIABLE out Ljava/io/ObjectOutput; L0 L1 1
>     MAXSTACK = 2
>     MAXLOCALS = 2
> {code}
> This seems to occur because the writeObject method call expressions within writeExternal have implicitThis set to true. 
> The problem is essentially the same for generated readExternal methods.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)