On Fri, 10 Mar 2023 16:56:20 GMT, Jonathan Gibbons <[email protected]> wrote:

>> We sure can, but that might complicate the patch even more.
>> 
>> The beauty of assertions is that you can make them anywhere you like. Here, 
>> it nicely pairs with the `get` method suggesting that `map.get(x) == null` 
>> is the same as `map.containsKey(x)`.
>> 
>> Also, please consider this commit as a big but still intermediate step: it 
>> sprinkles code with assertions to better capture what's going on (as far as 
>> we/I understand it), but eventually most structures, including 
>> `overriddenMethodTable`, will be replaced.
>
> Understood, but this is more about the general pattern for handling (any) bad 
> values in (any) collection.
> 
> Yes, you can check the values when you retrieve them, but then all you know 
> is that _someone_ added/put a bad value, but not _who_ or _when_. In general, 
> it is better to detect that bad value as early as possible so that you still 
> have the surrounding context of _who_ and _when_ to help determine _why_.

Let's not complicate it now; that code will go away pretty soon anyway.

-------------

PR: https://git.openjdk.org/jdk/pull/12887

Reply via email to