That's clean room reverse engineering, a rigorous method to make absolutely sure that the results are legal so it can't be questioned later. It's not a legal requirement and it does not prevent lawsuits. It just makes it more likely that the legal battle will be won.
I think GP is referring to the DMCA, which forbids reverse-engineering unless it's to understand how to interface your own code with something (although I'm not a lawyer).
Yes, even under the DMCA it's totally legal to reverse engineer for the purposes of interoperability. Wine was created to make Windows applications work on Linux. I reverse engineered my laptop's crappy manufacturer software in order to make a Linux version.
reply