Morally speaking, Google is on firm ground. Legally speaking, not so much. I'm not a lawyer and I don't like software patents so I hope that I'm mistaken here.

First, Oracle's sudden reversal of course following the takeover is a distraction. Oracle says it were unaware of key facts until after it had bought Sun, like a groom who discovers on his wedding night that the bride had been in an abusive relationship with the best man. Bogus? Maybe, but that's for a court to decide - the claim is plausible enough to justify conducting a trial, rather than dismissing the suit on the mere say-so of Google. Oracle only needs to demonstrate that what they learned after the acquisition altered their view.

That might sound trite, but suppose Sun had accepted Oracle's advice in February 2009 and said 'OK, Java is free to anyone for anything forever, just don't forget how nice we are,' and there was no basis for this suit as a result. If Oracle secretly thought the patents were worth billion$ at the time, why urge Sun to give them away? It was a surprise when Oracle sued Google, not least because nobody expected a patent challenge to Android from Sun. So lifting the licensing restrictions would not have damaged Sun's already-low stock price (about $4) in 2009. If it had, Oracle could have purchased the company for less money.

See, Oracle paid about $7.5bn for Sun and is now suing Google for ~$10bn, and the first reaction is 'they only bought Sun so they could sue Google for $$$.' But if Sun had gone the last mile in making Java open source as Oracle urged them to do, there would be no basis for filing a lawsuit. If Oracle had defended Sun's refusal to OS Java and then bought the company, it'd make sense - they'd have been protecting their intended investment. But Oracle's benefit from a fully open source Java SE would have been...$0. It's not as if Oracle was trying to launch a Java-derived mobile platform of its own, and being obstructed by Sun. To prove Oracle had unclean hands, Google would have to show that Oracle knew Sun would reject Oracle's suggestions and committee vote, and that Oracle was only pretending to support the idea.

On the technical level, Sun never issued a license that would allow the full use of Apache's Harmony on mobile devices. No license = no Java on mobile. You can, perhaps, make something of your own that does the same thing, but as soon as you say the word 'Java' it becomes Sun's business. Before going on, I know Android does not align with the Java SE. I will argue that legally, it shouldn't reference Java at all.

Google used some of the Harmony class libraries for Dalvik. That was source code, and not software, but the Harmony license (= the Apache 2.0 license) treats them the same way (see 'Definitions' in http://harmony.apache.org/license.html). So using Harmony source code = using Harmony. This license says nothing about mobile devices, but clause 5 acknowledges the precedence of other conditions in other license agreements, saying that 'nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.' In other words, Sun retains the rights it reserved when it made Java available. Some rights were never licensable.

At the time the Apache license was crafted, the license governing further development of Java was v2.8 of the Sun Community Source License (2001; http://java.sun.com/javase/6/scsl_6-license.txt). It makes specific claims, which are not superseded by the Harmony license: the important ones being that you can't use any parts of Java, or even offer a Java-compatible API, for any purposes other than non-commercial research unless you first sign a fee-paying license agreement with Sun. Since then, Sun released a simplified Java Research License (2005, http://java.net/jrl.csp) with essentially the same limitations. That's not a problem for Apache, because it's a non-profit organization.

There might be arguments about whether Google should have relied on the terms of the 2001 SCSL or the 2005 JRL when evaluating their rights under the Harmony license, because the earlier one is more explicit about what uses of the tools and technology are permissible. The JRL says simply that it 'is not intended to permit or enable access to the Technology for active consultation as part of creating an independent implementation of the Technology' - where 'Technology' includes any Java source code ever put out by Sun. The SCSL says you can develop your own stuff from Java for purposes other than research, but at the very least you have to validate what's Java-compatible or not before you deploy it anywhere, using sun's TCK, and you are not allowed to use the TCK for the purposes of building your own compatibility testing software. Also, mobile platform validation is explicitly excluded. Also, here's a non-legalese 2005 note from Sun clarifying what their position was when they released the JRL in 2005: https://jdk.dev.java.net/javase_ip_issues.html

Sure, Google are giving away Android, but they are doing so to be competitive in the smartphone market. They even commissioned and sold their own phone to promote the Android platform, and price their advertising services to reflect their brand strength across all internet access platforms. To the extent that Google has a financial interest in uptake of Android, it's commercial activity. The upshot of this is that by offering even a partial Java SE API in Android under authority of the Harmony license, Google has gone way past anything that could be called 'research.'

Google argues that in any case, Dalvik is not a Java VM, and Android is a system for producing Dalvik bytecode, which is nothing like Java bytecode. The obvious response to this is to ask why, then, they're using a subset of the Java SE API in Dalvik. Why have classes called 'Java' and 'Javax' which behave like the Java API does? Why not just start from scratch, rather than touting the possibility of writing code for Android in 'Java'? Let's face it, before this lawsuit began if you went up to any random developer and said 'Quick, what is this Android thing everyone is talking about?' the reply would have been 'Oh, it's a cellphone development platform based on Java.' Why didn't Sun make a fuss about this earlier? Oracle's position seems to be that they should have, and now that they are the new assignees of all Sun's IP, they are moving quickly to enforce the very same rights that Sun's management so carelessly failed to protect.

But, Google says, even if it emulates Java in many respects and incorporates bits of Harmony derived from Java, Dalvik only links to those libraries and linking is explicitly allowed by the Apache license agreement, and does not constitute a 'derivative work.' But that only applies to those parts of Harmony which were created by Apache. It does not confer retroactive rights to the Java SE, or remove the conditions which apply to redistribution of the Java SE - ie that noncommercial use is prohibited without payment of a license fee to Sun. So again, they shouldn't be offering an API that bears a strong resemblance to Sun's work, albeit a partial one. If you had never used Harmony and went straight from JDK to Android, your first thought would be 'oh, looks quite similar to Java SE.' Not permissible, under the license terms.

Everyone has assumed that when they implemented Android on their hardware using the Android SDK, they did so under license from Google; and that Google are in turn authorized to give away Android under the terms of the Apache license, and that Apache are in turn authorized to give away Harmony under the terms of the Java license from Sun. But the grant of rights by Sun specifically excluded deployment of Java SE or any of its parts onto completely new platforms unless a license was first obtained from Sun, and they had never issued any such license despite the urging of other interested parties.

Nor do I think that Google's argument of Dalvik being something fundamentally different because it produces its own bytecode is very strong. In practice, the way it is used is to read in Java source code, spit out some object code, and run it on a VM. The Apache license doesn't distinguish, though; and while the SCSL does allow you to build and distribute your own binaries of things like VMs and compilers (albeit only for research purposes), that same license is the one that specifically limits any kind of reuse on other platforms without an appropriate license...including mobile platforms.

So to wrap up, it seems to me that Google is relying on a certain construction of the SCSL which provides a loophole for them to distribute Dalvik because it is an entirely new product, but the very same license which allows this precludes them from even using the same class names. Referring to the Apache license's exclusion of linked libraries from 'derivative works' is no good, because the same document is pendant on the terms of the underlying agreement between Apache and Sun. Google's argument, when you strip away everything else, appears to contain a scope bug.