You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2016/05/11 12:02:13 UTC
[jira] [Comment Edited] (GROOVY-7836) CompileStatic + static inner
class + EqualsAndHashCode gives VerifyError in equals
[ https://issues.apache.org/jira/browse/GROOVY-7836?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15279383#comment-15279383 ]
Paul King edited comment on GROOVY-7836 at 5/11/16 12:02 PM:
-------------------------------------------------------------
Just confirming that I get the error (@CompileStatic is required to get the error) on 2.4.6 but not on master. I'll investigate some more when I get a chance.
was (Author: paulk):
Just confirming that I get the error (@CompileStatic is required to get the error) on 2.4.6 but not on master. I'll investigate some more.
> CompileStatic + static inner class + EqualsAndHashCode gives VerifyError in equals
> ----------------------------------------------------------------------------------
>
> Key: GROOVY-7836
> URL: https://issues.apache.org/jira/browse/GROOVY-7836
> Project: Groovy
> Issue Type: Bug
> Components: Static compilation
> Affects Versions: 2.4.6
> Reporter: Jason Winnebeck
>
> {code}
> import groovy.transform.CompileStatic
> import groovy.transform.EqualsAndHashCode
> @CompileStatic
> class Parent {
> List<Integer> getInts() { [0] }
> @EqualsAndHashCode
> static class Child {
> List<Integer> ints
> }
> }
> println GroovySystem.version
> println new Parent.Child()
> {code}
> The key is the inner class having a property matching the parent's.
> Result:
> {code}
> 2.4.6
> java.lang.VerifyError: (class: Parent$Child, method: equals signature: (Ljava/lang/Object;)Z) Incompatible object argument for function call
> {code}
> Inspecting the bytecode, I see the following:
> {code}
> L13
> ALOAD 0
> INVOKEVIRTUAL Parent.getInts ()Ljava/util/List;
> ALOAD 2
> INVOKEVIRTUAL Parent$Child.getInts ()Ljava/util/List;
> INVOKESTATIC org/codehaus/groovy/runtime/ScriptBytecodeAdapter.compareEqual (Ljava/lang/Object;Ljava/lang/Object;)Z
> IFNE L14
> ICONST_1
> {code}
> It appears that the bytecode is attempting to call a method on the outer class, even though the inner class is static and there is no reason to access the outer class.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)