3 ms·
This would break the invariant that x instanceof Object is true for all non-primitive values x. This assumption is baked into too much code and too many APIs.
by layer8 2y ago
This would break the invariant that x instanceof Object is true for all non-primitive values x. This assumption is baked into too much code and too many APIs.
For example, you couldn’t add a NakedObject-but-not-Object to a java.util.List, because what Object would List::get(index) then return for it? (Note that the List’s type parameter doesn’t exist at runtime and may also not exist at compile time.)
- masklinn 2y agojava.util.List can't deal with value types in the first place, they have to be boxed. I would assume "naked objects" would have to be bridged similarly. Either that, or java would have to gain some form of partial reification such that collections would be able to work with unboxed values. IIRC project valhalla includes the latter, or it did at one point.