Community
Participate
Working Groups
Created attachment 255478 [details] Examples reproducing the issue This issue appears when we are passing a result of a type-parameterized method directly to a varargs method. The behavior is different when compiling with javac and with ajc. When I compile and run the attached file with javac (1.8.0_40) everything works fine. But when I compile it with ajc: java -jar /path/to/aspectjtools-1.8.5.jar GenericVarargsBug.java -1.8 I'm getting ClassCastException: Exception in thread "main" java.lang.ClassCastException: [B cannot be cast to [Ljava.lang.Object; at GenericVarargsBug.main(GenericVarargsBug.java:9) It seems that while javac treats the byte array as a single Object argument to the varargs method, ajc tries to cast it to Object array. The issue does not appear when the result of sth.get(0) is saved to an intermediary variable, e.g.: byte[] first = sth.get(0); isItWorking(first); I'm also attaching two more examples of how to reproduce this issue.
I just tried your snippet in pure Eclipse and it seems to be a bug there (The AspectJ compiler piece is based on the eclipse compiler). I've raised bug 474355 to track it in JDT. Possibly it is already fixed in JDT master but I haven't checked that, I only checked the mars (4.5.0) release. Once there is a fix and we know where it is I will pick it up when I fold the new compiler version from eclipse into AspectJ. Thanks for the small code snippet, they are so useful.