android code javaShort Bytes: Do you know about the famous 9 lines of code that Oracle claimed that Google copied from its copyrighted Java code? It dates back to 2012 when this court case made headlines as a Google developer used a small portion of copyrighted code in Android. At last, Oracle agreed the zero damage result. However, this case is again in the news these days and Oracle is demanding $9 billion compensation.

The legal battle between Google and Oracle dates way back to 2010. This battle revolves around the allegation that Google improperly used Oracle’s Java APIs in Android operating system.

Now, this battle has turned ugly and Oracle is demanding almost $9 billion in damages in the court trials. While Google argues that it used Java under the fair use policy and the pieces it put in Android can’t be copyright protected, Oracle has a different story to tell.

Here, I’ll be telling how this legal battle started and why is Oracle so mad.

I don’t need to remind you that Java, invented by James Gosling, is one of the most popular programming languages in the world that works on any kind of computer and is known for its reliability and stability.

While many call Java an old-fashioned language, they accept that it’s a language that’s suitable for building big things and at a large scale.

The trouble for Google began after Oracle bought Sun Microsystems in 2009. Few years back, in 2005, Google bought Android and gathered a team to build a mobile operating system that would rule the smartphone market in the upcoming years.

Google took the wise decision to use Java and Linux kernel to develop Android because lots of developers already knew these technologies very well and they didn’t need to learn anything new to learn how to write apps in Java.

Back then, Google tried to pay Sun $40 million to license Java for Android but talks fell apart. So, Google wrote the open source code from scratch and replicated whatever it couldn’t license from Sun.

Things changed when Sun was bought by Oracle and it decided to label Google’s efforts as illegal. While this battle has many finer details including the 37 Java API packages, here, I’ll be telling about the portion of code Oracle claimed to be stolen and used as a base to accuse Google.

This code deals with rangeCheck that any general programmer can write in a few minutes and any developer would find it difficult to write a rangeCheck method different than these 9 lines of code mentioned ahead.

According to Google, it tried to make sure that no literal copies of Oracle’s Java code slipped into Android implementation. Somehow, one developer used Oracle’s code as a temporary measure.

This developer, Joshua Bloch, worked at Sun on Java’s APIs before he moved to Google in 2008 and worked on Android. During this period of time, he still contributed to OpenJDK. Somehow, one of his contributions to Sun-controlled OpenJDK, his much faster implementation of sorting array that used the rangeCheck method, based on TimSort in Python, ended up in Android.

While Bloch didn’t recall accessing any copyrighted code while working on Android, he admitted that he wrote the same code, then, he is willing to believe it. “If I did, it was a mistake,” Bloch said, “and I’m sorry I did it.”

Well, these nine lines of code were removed from Android 4.0. Here are those famous 9 lines of code:

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);

How to become a Java & Android developer? Here’s the secret recipe.