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

Eric Milles commented on GROOVY-11581:
--------------------------------------

When invoking the call "bar(val,'')" on the outer class, the arguments are 
packed into an array as part of the method missing MOP and are later spread 
back out.  The de-spread makes the conversion to a list: 
https://github.com/apache/groovy/blob/a3c59394977fd9feb5220812f62b6fd0b60a0739/src/main/java/org/codehaus/groovy/runtime/ScriptBytecodeAdapter.java#L952

> byte array casted to array list when calling parent method from nested class
> ----------------------------------------------------------------------------
>
>                 Key: GROOVY-11581
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11581
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 4.0.9, 4.0.26
>            Reporter: Wilson Leung
>            Priority: Minor
>
>  
> {code:java}
> class Foo {
>     void test() {
>         def byteArr = 'FOO'.bytes
>         new NestedFoo().printClass byteArr
>     }
>     
>     static bar(val, apple) {
>         println "bar class: ${val.getClass()}" // prints array list   
>     }
>     
>     static baz(val) {
>         println "baz class: ${val.getClass()}" // prints byte array
>     }    
>     static class NestedFoo {
>         def printClass(val) {
>             println "nestedFoo class: ${val.getClass()}"
>             bar val, ''
>             baz val
>         }
>     }
> }
> new Foo().test() {code}
> Byte arrays are being casted to an array list when calling a parent method 
> from a dynamically compiled nested class.  In the code above the call to bar 
> will cast the byte array to an array list. This does not happen in the call 
> to baz. It seems like this only happens when the method called takes more 
> than one arg. I was able to reproduce this in groovy 4.0.9, I have not tested 
> this in earlier versions.
> To reproduce
> 1) Nested class must be compiled dynamically
> 2) The parent method being called must take at least two arguments.  It does 
> not get casted when the method takes a single argument.
>  
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to