codeconsole opened a new pull request, #3316: URL: https://github.com/apache/groovy/pull/3316
https://issues.apache.org/jira/browse/GROOVY-12793 A statically compiled call to a method declared with an array of a bounded type variable was written with `Object[]` in its descriptor and failed at run time: ```groovy @groovy.transform.CompileStatic void test() { Class<?> type = String Deprecated[] annotations = type.getAnnotationsByType(Deprecated) } ``` ``` java.lang.NoSuchMethodError: 'java.lang.Object[] java.lang.Class.getAnnotationsByType(java.lang.Class)' ``` The JVM descriptor of an array is built from its innermost component, which for `A[]` is the type-variable placeholder. Only the array node was redirected to the erasure, so the placeholder kept `Object`: - `Java8#makeClassNode`, used for `ClassHelper`'s predefined types such as `java.lang.Class` and for every class when asmResolving is off, never redirected the component, for return and parameter types of any dimension. - `TypeSignatureParser#applyErasure`, used for classes read from their class file, did it for one dimension only, so a `T[][]` from a jar was written as `Object[][]`. Both now redirect every component level of an array of a type variable to the matching level of its erasure. An array of any other type is left alone. `Groovy12793` calls `Class#getAnnotationsByType` and `getDeclaredAnnotationsByType`, and methods of a Java support class that return and take `T[]` and `T[][]` with `T extends Number`. It runs with asmResolving on and off (`Groovy12793_AsmResolveOff`); 7 of its 10 tests fail without the fix. The bug is in 4.0.x, 5.0.x and 6.0.0. Please backport to `GROOVY_6_0_X`, where the change applies cleanly. `GROOVY_5_0_X` conflicts in both files and would need the change ported by hand. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
