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

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

GitHub user danielsun1106 opened a pull request:

    https://github.com/apache/groovy/pull/807

    GROOVY-8819: java.lang.VerifyError when calling this() with static fi…

    …nal field from a super class

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

    $ git pull https://github.com/danielsun1106/groovy GROOVY-8819

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

    https://github.com/apache/groovy/pull/807.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 #807
    
----
commit 070f98bfc7a07e06d941cc5d148ccbec6e9da690
Author: danielsun1106 <realbluesun@...>
Date:   2018-10-07T11:11:56Z

    GROOVY-8819: java.lang.VerifyError when calling this() with static final 
field from a super class

----


> java.lang.VerifyError when calling this() with static final field from a 
> super class
> ------------------------------------------------------------------------------------
>
>                 Key: GROOVY-8819
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8819
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 2.4.x, 2.5.2
>            Reporter: Keith Suderman
>            Priority: Minor
>
> If a constructor attempts to call _this(X)_, where _X_ is a _static final_ 
> field defined in a super class a _java.lang.VerifyError_ is thrown at runtime 
> . This only occurs if _X_ is not qualified with the super class name.
> {code:java|title=Parent.java|borderStyle=solid}
> class Parent { 
>       static final String DEFAULT = 'default' 
> }
> {code}
> {code:java|title=Child.java|borderStyle=solid}
> class Child extends Parent {
>       String value
>       Child() { this(DEFAULT) }  // <-- here
>       Child(String value) { this.value = value }
> }
> {code}
> {noformat:title=java.lang.VerifyError}
>  Caught: java.lang.VerifyError: Bad type on operand stack
>  Exception Details:
>  Location:
>  Child.<init>()V @10: invokeinterface
>  Reason:
>  Type uninitializedThis (current frame, stack[2]) is not assignable to 
> 'java/lang/Object'
>  Current Frame:
>  bci: @10
>  flags: \{ flagThisUninit }
>  locals: \{ uninitializedThis, 
> '[Lorg/codehaus/groovy/runtime/callsite/CallSite;' }
>  stack: \{ uninitializedThis, 
> 'org/codehaus/groovy/runtime/callsite/CallSite', uninitializedThis }
>  Bytecode:
>  0x0000000: b800 114c 2a2b 1212 322a b900 1802 00b8
>  0x0000010: 001e c000 20b7 0023 b1 
> {noformat}
> *Workaround*
> Simply ensure that references to static final fields from the super class are 
> qualified with the super class name.
> {code:java|title=Child.java|borderStyle=solid}
> class Child extends Parent {
>       String value
>       Child() { this(Parent.DEFAULT) }  // ok
>       Child(String value) { this.value = value }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to