Google not buying Sun may go down as one of their poorest decisions. I mean rumor has it, Google offered $6 billion to buy GroupOn (which they turned down). If GroupOn is worth $6B (it isn't) then owning Java is worth $7.5B.
I suspect Google believed they had an implicit license from Sun to use Java on Android, otherwise this was a massive licensing failure. While Sun still existed, even buying a token license would've been cheap.
Now Google ultimately prevailed in their lawsuit setting an important precedent but at what cost? It was over a decade of uncertainty and cost who knows how much in legal fees. And while it was ongoing, Android was under a cloud and Google had to abandon a bunch of things it was otherwise doing with Java.
Oracle is just the worst.