| Summary: | [compiler] Miscompilation when passing byte[] from generic return to varargs | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Martin Partel <mpartel> | ||||
| Component: | Core | Assignee: | Sasikanth Bharadwaj <sasikanth.bharadwaj> | ||||
| Status: | CLOSED WONTFIX | QA Contact: | |||||
| Severity: | major | ||||||
| Priority: | P3 | CC: | jarthana, stephan.herrmann | ||||
| Version: | 4.5.2 | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Linux | ||||||
| Whiteboard: | stalebug | ||||||
| Attachments: |
|
||||||
Reproduced on master. FWIW, this is - not caused by Java8 type inference, problem can be reproduced with 1.7 & 1.8 - not a recent regression, problem can be reproduced with ecj >= 3.7.1 This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |
Created attachment 259547 [details] Test case Let there be a method `void f(Object... args)`. Here's a case where I think Eclipse miscompiles: byte[] bytes = {1, 2, 3, 4}; ArrayList<byte[]> arrays = new ArrayList<>(); arrays.add(bytes); f(arrays.get(0)); // <-- problem occurs here The Eclipse compiler emits code that fails with a "ClassCastException: [B cannot be cast to [Ljava.lang.Object;". javac passes the byte array as a single argument, which I assume is the correct behaviour. The detour through ArrayList is necessary because the problem seems to only occur when the argument comes from a generic-returning expression. Looking at the bytecode, Eclipse emits a checkcast "[Ljava/lang/Object;" just after the invokevirtual on ArrayList.get, whereas javac does not. Full test case attached for convenience.