Yeah, a cleanroom re-write, or even "just" a copy of the API spec is something to raise as a defense during a trial (along with all other evidence), it's not a categorical exemption from the law.
Also, I find it important that here the API is really minimal (compared to the Java std lib), the real value of the library is in the internal detection logic.