It's not illegal to implement a compatible piece of software. In fact, it's positively protected in law. The EU **ORDERED** Microsoft to allow compatible office suites and compatible file-sharing protocols. Enshrined in such law is that anyone can make a compatible product.
Google, et al, have not taken ANYTHING from Oracle that they weren't advertising publicly. In fact, they've implemented the ONLY POSSIBLE WAY to provide a Java substitute that could ever work. To reimplement millions of lines of code that interface with a handful of structure and function definitions that Java programs expect to exist. Those functions/structure HAVE to be named identically, HAVE to be in the correct order, HAVE to take the same datatypes. That's what Google "copied". But every single line of code that those functions have to actually DO their stated job is not Oracles. That would be prima facie copyright infringement.
It's like saying (but not exactly like this, because software patents are VERY different to hardware ones and don't even officially exist in the EU, for example) that you've built a computer that controls a piece of machinery. It issues up, down, left, right commands. Oracle are trying to claim that it's actually ILLEGAL to replace their control box with another control box that you've made yourself that issues those same up, down, left, right commands down the same cable. Not just that it would void your warranty, or they won't support it, but that you even trying is actually ILLEGAL.
Oracle are stupid. And "using" an API in this fashion isn't illegal at all. In fact, technically "using" an API is the absolute utter intent of creating one in the first place. This isn't "using" an API at all. It's creating a compatible API. Like making a computer than can run ARM binaries, for instance. Or, in this case, closer to making your own BASIC interpreter.
However, Oracle are not only trying to claim that me making a piece of software compatible with theirs is illegal, but that the API cannot even be used without their permission (copyrighted), and nobody can implement any program that replaces Java NOR interfaces with Java in any way without their permission.
They are so stupid, they are trying to argue that they should be allowed to destroy not just competitors but their own users. And the courts disagree.