Why is the Java source code implementation for Android different from the regular Java implementation for the same classes?

It is all about copyright, licensing and big company's trying to protect their "turf".

The background is that Java was originally a proprietary codebase developed by Sun Microsystems. The Java class library source-code that was made available to developers was covered by a proprietary license.

In 2007, OpenJDK 6 was released as open source. Google looked at OpenJDK, and also negotiated with Sun about licensing, but they decided that they were better off doing a clean-room reimplementation based on the published Java Language specification and the Java SE javadocs. Among other things, this allowed Google to take a fresh look at the user interface framework, and other APIs that are critical to mobile platforms. The end was result was vastly superior to Sun's Java ME offering.

But relations between Sun and Google were still cordial.

Then Oracle merged with Sun and there was a change of corporate culture. There was a big lawsuit between Oracle and Google, and that scuppered any chance of significant cooperation between Oracle and Google in the Java ecosystem.

For more background, read these Wikipedia articles:

  • Java Programming Language: History.
  • Android: History.
  • Oracle America, Inc. v. Google, Inc.