decoration decoration
Stories

GROKLAW
When you want to know more...
decoration
For layout only
Home
Archives
Site Map
Search
About Groklaw
Awards
Legal Research
Timelines
ApplevSamsung
ApplevSamsung p.2
ArchiveExplorer
Autozone
Bilski
Cases
Cast: Lawyers
Comes v. MS
Contracts/Documents
Courts
DRM
Gordon v MS
GPL
Grokdoc
HTML How To
IPI v RH
IV v. Google
Legal Docs
Lodsys
MS Litigations
MSvB&N
News Picks
Novell v. MS
Novell-MS Deal
ODF/OOXML
OOXML Appeals
OraclevGoogle
Patents
ProjectMonterey
Psystar
Quote Database
Red Hat v SCO
Salus Book
SCEA v Hotz
SCO Appeals
SCO Bankruptcy
SCO Financials
SCO Overview
SCO v IBM
SCO v Novell
SCO:Soup2Nuts
SCOsource
Sean Daly
Software Patents
Switch to Linux
Transcripts
Unix Books

Gear

Groklaw Gear

Click here to send an email to the editor of this weblog.


You won't find me on Facebook


Donate

Donate Paypal


No Legal Advice

The information on Groklaw is not intended to constitute legal advice. While Mark is a lawyer and he has asked other lawyers and law students to contribute articles, all of these articles are offered to help educate, not to provide specific legal advice. They are not your lawyers.

Here's Groklaw's comments policy.


What's New

STORIES
No new stories

COMMENTS last 48 hrs
No new comments


Sponsors

Hosting:
hosted by ibiblio

On servers donated to ibiblio by AMD.

Webmaster
Example of range of variation that is possible | 152 comments | Create New Account
Comments belong to whoever posts them. Please notify us of inappropriate comments.
As a programmer, I can confirm that there is nothing remotely creative here
Authored by: Anonymous on Thursday, April 19 2012 @ 11:32 AM EDT
In my opinion.

It doesn't even do anything significantly functional, merely
checks that the supplied values are reasonable, and within
the bounds of the array, and causes an exception condition
if they are not. It doesn't handle the exception, or decide
what to do with it, merely reports to the application that
the error has occurred (and the application then decided wht
to do, depending on the context, but that's out of the scope
of this.)

As an analogy with a filing cabinet, this would be like you
holding up a piece of paper next to a filing cabinet, and if
the paper is wider, you say "It won't fit".

There is literally nothing to this, it's boilerplate code
and contains no creativity, and almost no meaningful
functionality (though the checks are important in some
applications, they are extremely basic in scope).

Code like this appears in every significant application in
every language.

[ Reply to This | Parent | # ]

Would posting the rangeCheck function here be fair use, or would the legal army of doom descend?
Authored by: Anonymous on Thursday, April 19 2012 @ 11:40 AM EDT
It would be helpful to know what we are talking about.

[ Reply to This | Parent | # ]

Some of our files is missing
Authored by: Anonymous on Thursday, April 19 2012 @ 11:55 AM EDT
Goodness me, I can find rangeCheck type SUBS that I wrote in Sinclair Basic
>30 years ago!

Sanity checks of input or results are as old as the hills and no more original.

Mac

[ Reply to This | Parent | # ]

Example of range of variation that is possible
Authored by: bugstomper on Thursday, April 19 2012 @ 01:19 PM EDT
I won't opine on how creative it is, but I can show what kinds of choices can be made in writing it.

Here are the nine lines of code, copied here from the OpenJDK 7 Arrays.java file (and repeated identically in the OpenJDK 7 TimSort.java file) which has to be a permitted use: If you can't copy nine lines of GPLd source code in a comment posted to a web site like this, of what use is the GPL?

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);
}
Here is what the API specification says about those thrown exceptions. The person writing this code would have worked from this specification (this is an excerpt):
* @throws IllegalArgumentException if {@code fromIndex > toIndex} or
*    (optional) if the comparator is found to violate the
*     {@link Comparator} contract
* @throws ArrayIndexOutOfBoundsException if {@code fromIndex < 0} or
*   {@code toIndex > a.length}
Note that the three if tests and their throw statements follow the order they are described in the specifications. The code in this version results in particular error messages when each of the three conditions are met. Someone implementing their own version of this would not only be following the API specification but might also want to make sure that the error messages look familiar to someone used to working with the Sun version. That would cause even a bit more similarity in how the code was written.

Here is the functionally equivalent private function that is in an older version of Android Arrays.java file. It is almost the same, but still follows the order that things are described in the API specification and produces similar but not identical error messages.

Note that this checkFillBounds function is not what is claimed to be copied even though it is very similar to rangeCheck in the JDK Arrays.java. This may show you just how close an independent naive implementation of the words in the API Specification would come to the nine lines of rangeCheck.

This older version of Android did literally copy the JDK Arrays.java rangeCheck function into TimSort.java. Here is the independent implementation in old Android Arrays.java:

private static void checkFillBounds(int arrLength, int start, int end) {
  if (start > end) {
    throw new IllegalArgumentException("start < end: " + start + " < " + end);
  }
  if (start < 0) {
    throw new ArrayIndexOutOfBoundsException("start < 0: " + start);
  }
  if (end > arrLength) {
    throw new ArrayIndexOutOfBoundsException("end > array length: " +
      end + " > " + arrLength);
  }
}
Finally here is what the function looks like in the current version of Android, after a change in December 2010. At that time the function in Arrays.java was written to be smaller instead of literally following the steps in the API Specification, while still producing the same functional result. Also it was changed from private to public so that it could be called from other classes, the name was changed from checkFillBounds to checkStartAndEnd, and the rangeCheck function in TimSort was removed, the calls to rangeCheck being replaced with calls to Arrays.checkStartAndEnd.
public static void checkStartAndEnd(int len, int start, int end) {
  if (start < 0 || end > len) {
    throw new ArrayIndexOutOfBoundsException("start < 0 || end > len."
      + " start=" + start + ", end=" + end + ", len=" + len);
  }
  if (start > end) {
    throw new IllegalArgumentException("start > end: " + start + " > " + end);
  }
}

[ Reply to This | Parent | # ]

Groklaw © Copyright 2003-2013 Pamela Jones.
All trademarks and copyrights on this page are owned by their respective owners.
Comments are owned by the individual posters.

PJ's articles are licensed under a Creative Commons License. ( Details )