Of course this is not guaranteed and just a common interpretation of trademark law by judges in trademark related cases. In case of conflicts, the trademark owner would be unlikely to win for this reason if a defendent can argue that the trademark was abandoned for years.
Oracle is in the same boat with Javascript. Technically they own the trademark. But world+dog has been using that trademark freely without them doing anything about it. So, their claims to the trademark are weak at this point. Hence the recent articles about e.g. Deno wanting to challenge their ownership of that trademark.
And you are right to call out the jurisdiction. Because interpretations and laws vary between countries and even between states inside the US. This stuff is complicated.