Yeah. That’s copyright law, and the way it interacts with monomorphization (templates/generics).
It’s even worse than that though because “Copyright” and “Patent” law is never settled really. It was always considered a given that API’s were not Copyrightable (by everyone in the industry); however, because Oracle spent enough money on lawyers, that is not longer the case. In actuality, if someone wants to spend enough money litigating an issue and paying off the right politicians, judges, etc. it’s all a crap-shoot.
This applies in the US.
US law is not EU law and US law does not apply anywhere but in the US.
Due to Globalism and things like the “Berne Convention” and other various “Treaties” this isn’t exactly as clear-cut as it would first seem. Both for how U.S. laws effect outside the U.S. and how laws of other countries can have an impact in the U.S.
Also, it would be a mistake to think that the same large “Global” corporations won’t and aren’t pulling the same shenanigans in other countries.
I’m aware of the Berne convention but it does not entail that a company not selling anything in the US has to comply with US copyright law. As far as I know, the convention says nothing about whether APIs are copyrightable and so a Swedish court may make a different interpretation than a US court.