You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Chiang Seng Chang (Jira)" <ji...@apache.org> on 2020/09/12 13:43:00 UTC
[jira] [Comment Edited] (GROOVY-9737) Groovy 3.0.5 VerifyError if
superclass has static and non-static overloading methods
[ https://issues.apache.org/jira/browse/GROOVY-9737?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17194736#comment-17194736 ]
Chiang Seng Chang edited comment on GROOVY-9737 at 9/12/20, 1:42 PM:
---------------------------------------------------------------------
Workaround is to make
{noformat}
protected void fun(String s)
{noformat}
static
{noformat}
static void fun(String s)
{noformat}
But because this issue only manifest during runtime with no compilation error or warning, finding all the workarounds required in existing code can be challenging.
was (Author: chacs):
Workaround is to make
protected void fun(String s)
static
static void fun(String s)
But because this issue only manifest during runtime with no compilation error or warning, finding all the workarounds required in existing code can be challenging.
> Groovy 3.0.5 VerifyError if superclass has static and non-static overloading methods
> ------------------------------------------------------------------------------------
>
> Key: GROOVY-9737
> URL: https://issues.apache.org/jira/browse/GROOVY-9737
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 3.0.5
> Reporter: Chiang Seng Chang
> Priority: Major
> Attachments: g3ve.tar.gz
>
>
> java.lang.VerifyError instantiating a concrete class if superclass has static and non-static overloading methods.
> superclass:
> {noformat}
> package bar
> import groovy.transform.CompileStatic
> @CompileStatic
> abstract class SuperProblem {
> static void fun(Integer i) {}
> protected void fun(String s) {}
> }
> {noformat}
> concrete class:
> {noformat}
> package foo
> import bar.SuperProblem
> import groovy.transform.CompileStatic
> @CompileStatic
> class Problem extends SuperProblem {
> protected void doit() {
> fun('')
> }
> }
> {noformat}
> harness:
> {noformat}
> package app
> import foo.Problem
> import groovy.transform.CompileStatic
> @CompileStatic
> class Test {
> static void main(String[] args) {
> Problem problem = new Problem()
> println('SHOULD NOT SEE THIS BECAUSE IT MEANS Class Problem HAS NO PROBLEM!!!')
> }
> }
> {noformat}
>
> Observations:
> # No compilation error.
> # Superclass must be in a different package.
> # Groovy 2.5.13 has no such issue.
> I have included the test project,
> {noformat}
> ./gradlew run
> {noformat}
> produces this error:
> {noformat}
> % ./gradlew run
> > Task :run FAILED
> Exception in thread "main" java.lang.VerifyError: Bad access to protected data in invokevirtual
> Exception Details:
> Location:
> foo/Problem.doit()V @12: invokevirtual
> Reason:
> Type 'bar/SuperProblem' (current frame, stack[0]) is not assignable to 'foo/Problem'
> Current Frame:
> bci: @12
> flags: { }
> locals: { 'foo/Problem' }
> stack: { 'bar/SuperProblem', 'java/lang/String' }
> Bytecode:
> 0x0000000: 1202 1204 b800 17c0 0004 1219 b600 1d01
> 0x0000010: 57b1
> at app.Test.main(Test.groovy:13)
> {noformat}
>
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)