News for hackers. Stuff that matters.
Re:State of Valhalla by kaba0 on Friday December 24, 2021 @07:05AM (#29672924)
Yeah, java can change the variance model used by generics, but my point is that it is a language-level feature, not something fundamental at a JVM level, which is imo the correct decision.

Also, unfortunately arrays are covariant so Cat[] is a subclass of Animal[] (both in Java and C# actually), where your mentioned example indeed introduces a “poisoned” value, waiting for a classcastexception.

There are no comments on this comment yet.