Q. The rangecheck function: Did you copy the Sun code while working on Android?
A. I did that while working on Timsort, and it was during the period I was employed at Google, but not for Google. It was something I wrote on my own for OpenJDK.
[I had not heard of Timsort before; it's (apparently) a very efficient sort written by Tim Peters for Python (see Wikipedia), and ported by Bloch to Java.]
[Timsort will come up again later. I'm somewhat appalled by how much fuss is being made over the trivial "rangecheck" function.]
Q. Why did you copy the rangecheck function for Timsort?
A. It's good engineering to reuse the same function if possible [The context here was that he expected to fold Timsort into a public version of Java, and at that point it would make sense to call the existing rangecheck function from the new code rather than writing a different one.]
The takeaway is write it yourself - don't copy it without permission, even if it's so obvious. (And if it's so obvious then there really is hardly a reason to even copy it in the first place.)
The OpenJDK is GPL'd after all, and well, an argument could be made that Google are infringing by distributing GPLd rangeCheck with the Apache license, Oracle aren't doing that afaik.
(ignoring that the guy seems to have said he copy-pasted here.)
private static void rangeCheck(int arrayLen, int fromIndex, int toIndex) {
From Google:private static void rangeCheck(int arrayLen, int fromIndex, int toIndex) {
}Open and shut case. /s