You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Renato Athaydes (Jira)" <ji...@apache.org> on 2022/02/25 14:21:00 UTC

[jira] [Created] (GROOVY-10513) Incorrect bytecode generated for default interface methods with array parameter

Renato Athaydes created GROOVY-10513:
----------------------------------------

             Summary: Incorrect bytecode generated for default interface methods with array parameter
                 Key: GROOVY-10513
                 URL: https://issues.apache.org/jira/browse/GROOVY-10513
             Project: Groovy
          Issue Type: Bug
          Components: Compiler
    Affects Versions: 4.0.0
            Reporter: Renato Athaydes


Given the following interface:

 

{{interface MyTrait {}}

{{   default String loadKeyStoreFrom(String url, Object... passwordChars) {}}
{{     ''}}
{{   }}}

{{}}}

 

Compile this to a jar file (this matters as the bug does not happen when compiled at the same time).

 

Now, run this test:

 

{{package tests}}

{{import org.junit.jupiter.api.Test}}

{{class ExampleTest implements MyTrait {}}

{{   @Test}}
{{   def 'my test'() {}}
{{     assert loadKeyStoreFrom('', ''.chars) == ''}}
{{   }}}

{{}}}

 

I get the following error:

 

{{▶ groovy -cp build/libs/groovy-tests-1.0-SNAPSHOT.jar src/test/groovy/tests/ExampleTest.groovy
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
/experiments/groovy-tests/src/test/groovy/tests/ExampleTest.groovy: -1: The method 'java.lang.String loadKeyStoreFrom(java.lang.String, [Ljava.lang.Object;)' has an incorrect modifier transient.
 @ line -1, column -1.
1 error
}}

 

This used to work in Groovy 3.0.9. It also works, as mentioned, if you compile the interface and the test at the same time.

 

Please notice that this error also happens when using {*}traits{*}, which is how I came across the problem.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)