Re: RFR: 8312630: java/security should not create unmodifiable collections with redundant wrapping [v2]

2023-07-26 Thread John Jiang
On Wed, 26 Jul 2023 16:52:20 GMT, Sean Mullan wrote: > The latter part is true (prevented from subsequent modification) but, unless > I am mistaken, the former (making a clone/copy) is not. For example, before > your change, this assert would pass: > > ``` > Map m = Collections.unmodifiableMap

Re: RFR: 8312630: java/security should not create unmodifiable collections with redundant wrapping [v2]

2023-07-26 Thread Sean Mullan
On Wed, 26 Jul 2023 16:03:31 GMT, John Jiang wrote: > > it says "It is cloned to prevent subsequent modification." > > Now, if the set passed in is unmodifiable, that is no longer true. > > My understanding: The parameter `protectionParams` is cloned as > `this.protectionParams`, and `this.prot

Re: RFR: 8312630: java/security should not create unmodifiable collections with redundant wrapping [v2]

2023-07-26 Thread Sean Mullan
On Wed, 26 Jul 2023 09:28:46 GMT, John Jiang wrote: >> Some java/security classes apply the below coding style, >> >> Set set = ...; >> Set unmodifiableSet = Collections.unmodifiableSet(new HashSet<>(set)); >> >> It may be unnecessary to wrap that `set` with HashSet before creating >> `unmodif

Re: RFR: 8312630: java/security should not create unmodifiable collections with redundant wrapping [v2]

2023-07-26 Thread John Jiang
On Wed, 26 Jul 2023 14:41:16 GMT, Sean Mullan wrote: > it says "It is cloned to prevent subsequent modification." > Now, if the set passed in is unmodifiable, that is no longer true. My understanding: The parameter `protectionParams` is cloned as `this.protectionParams`, and `this.protectionPar

Re: RFR: 8312630: java/security should not create unmodifiable collections with redundant wrapping [v2]

2023-07-26 Thread Sean Mullan
On Wed, 26 Jul 2023 09:28:46 GMT, John Jiang wrote: >> Some java/security classes apply the below coding style, >> >> Set set = ...; >> Set unmodifiableSet = Collections.unmodifiableSet(new HashSet<>(set)); >> >> It may be unnecessary to wrap that `set` with HashSet before creating >> `unmodif

Re: RFR: 8312630: java/security should not create unmodifiable collections with redundant wrapping [v2]

2023-07-26 Thread John Jiang
> Some java/security classes apply the below coding style, > > Set set = ...; > Set unmodifiableSet = Collections.unmodifiableSet(new HashSet<>(set)); > > It may be unnecessary to wrap that `set` with HashSet before creating > `unmodifiableSet`. > Some usages on `Collections.unmodifiableList` an