On Mon, 23 Jun 2025 14:38:08 GMT, Kevin Walls <kev...@openjdk.org> wrote:

>> My question was because there are checks for `null` in this class:
>> 
>> public void add(Role role)
>>         throws IllegalArgumentException {
>> 
>>         if (role == null) {
>>             throw new IllegalArgumentException("Invalid parameter");
>>         }
>>         checkTypeSafe(role);
>>         super.add(role);
>>     }
>> 
>> It is kind of confusing and not clear where `null` is allowed and where it 
>> is not.
>> Should it be more consistent?
>
> Sorry, to be clearer:
> 
> javax/management/AttributeList does accept nulls being added, and should 
> continue to do so because it might be a disruptive change.
> 
> RoleList and RoleUnresolvedList do not accept null Role/RoleUnresolved 
> objects: they document that the add() method throws if given a null.
> 
> We don't have a need to change either behaviour about accepting nulls.
> It should be clear when reading the api docs.  It might be unclear as I am 
> grouping together somewhat unrelated classes here.   There is no reason for a 
> user of AttributeList to expect it behaves the same way as a RoleList.
> 
> But we do want to stop accepting alien Objects!

Okay, thanks!

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25856#discussion_r2165819639

Reply via email to