clojure.core/throw-if creates an array to call Exception.setStracktrace() without specifying the array type. This works fine when passed at least one StackTraceElement, but in the case where passed no stack trace elements (all are filtered or stack traces are being elided by the JVM), this will be an Object which results in a ClassCastException:
This is tricky to reproduce because it involves stack trace filtering so there is no reproducing case here.
Prescreened by: Alex Miller
into-array will create a typed array based on the first element of the seq it is passed, so generally you should see a StackTraceElement here. I think the only time this would fail is if it was passed no stack trace elements.
I'm trying to reproduce this in a way that can be presented here, but I got the compile error just after doing some serious package renaming, and can't reproduce it outside of the project itself.
I've created a new patch based on the guidelines, attached as file: CLJ-2048-b.patch.
Just to summarise:
The into-array returns the correct type if its provided with a none empty sequence, but if the sequence is empty it cannot know the type and then returns an object array. Because we set the array here to a java method Exception::setStackTrace passing it an object array causes a ClassCastException. One fix is to check for an empty sequence, but a less verbose way is just to pass the type which is known as part of the call to into-array, this is what is done in the patch CLJ-2048-b.patch.