6 ms·
From OpenJDK: private static void rangeCheck(int arrayLen, int fromIndex, int toIndex) { if (fromIndex > toIndex) throw new IllegalArgume
by thereallurch 14y ago
From OpenJDK:
private static void rangeCheck(int arrayLen, int fromIndex, int toIndex) {
if (fromIndex > toIndex)
throw new IllegalArgumentException("fromIndex(" + fromIndex +
") > toIndex(" + toIndex+")");
if (fromIndex < 0)
throw new ArrayIndexOutOfBoundsException(fromIndex);
if (toIndex > arrayLen)
throw new ArrayIndexOutOfBoundsException(toIndex);
}
From Google:
private static void rangeCheck(int arrayLen, int fromIndex, int toIndex) {
if (fromIndex > toIndex)
throw new IllegalArgumentException("fromIndex(" + fromIndex +
") > toIndex(" + toIndex+")");
if (fromIndex < 0)
throw new ArrayIndexOutOfBoundsException(fromIndex);
if (toIndex > arrayLen)
throw new ArrayIndexOutOfBoundsException(toIndex);
}
}
Open and shut case. /s
- gouranga 14y agoTo be blatantly honest, that is exactly what I'd write. The implementation is trivial and obvious therefore the probability of them being the same is high.
- dminor 14y agoThey were both written by Joshua Bloch, while working at Google. The first was for TimSort, which he donated to Sun/OpenJDK. He then reused the rangeCheck code in Android.
- krakensden 14y agoThis sort of thing is a little scary. We can't know for certain whether he wrote the same code the same way twice, or if he copied and pasted it, but I can certainly imagine doing the former.
- duaneb 14y agoHe copied and pasted: 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.]
- cullen 14y agoOracle is claiming infringement and damages for something they (Sun) didn't even pay for? That's a lot of gall.
- ars 14y agoThat's not the legal measure. If in fact they were both written identically, but independently there is no infringement. If it's totally obvious, but it was copied then there is infringement. 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.)
- polshaw 14y agoand how, generally, is this provable? (at least, to produce 'reasonable doubt' to a layman) (ignoring that the guy seems to have said he copy-pasted here.)
- ars 14y agoWhy ignore it? That's exactly how.
- myko 14y agoOf course in this case the person who wrote it is also the same person who copied it.
- __alexs 14y agoI thought the case was not even about copyright infringement of code but of the APIs i.e. the function names and arguments? 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.
- ars 14y agoThere is more than one issue. The big one of the API's, and a smaller issue of a very small amount of outright copying already admitted to by google.
- __alexs 14y agoIf the Java APIs are copyrightable, which part of the OpenJDK GPL release doesn't provide Google with a GPL copyright license to them then?
- emeraldd 14y agoGiven a method signature, especially one with the parameter names, and a listing of the exceptions it could throw, I think the only thing I would do different would be comments and {} on the if's. I hate if's without braces, that's just asking for trouble in the future ;)
- grandpoobah 14y agoBut it makes the code prettier
- fulafel 14y agoHow can this snippet be copyrightable? Is there no requirement/threshold of originality in the US?