Re: NPE throwing behavior of immutable collections

2023-01-29 Thread David Holmes
On 30/01/2023 3:37 am, Glavo wrote: I quite agree with you. I think the collection framework is in a very puzzling state. The hostility of the new collection factory method introduced by Java 9 to null has brought us trouble. I can understand that this is to expect users to explicitly decla

Re: Circular initialization between EmptyNavigableMap and UnmodifiableNavigableMap

2023-01-29 Thread David Holmes
On 26/01/2023 7:49 pm, Tagir Valeev wrote: Hello! Not sure if this should be considered as a problem that requires attention but there's an initialization loop between There are probably still quite a number of "initialization loops" in the core libraries. But they can only trigger if you exp

Re: RFR: 8293198: [vectorapi] Improve the implementation of VectorMask.indexInRange()

2023-01-29 Thread Xiaohong Gong
On Wed, 18 Jan 2023 08:58:42 GMT, Xiaohong Gong wrote: > The Vector API `"indexInRange(int offset, int limit)"` is used > to compute a vector mask whose lanes are set to true if the > index of the lane is inside the range specified by the `"offset"` > and `"limit"` arguments, otherwise the lanes

Re: RFR: 8301220: Return value of toArray() of Сollection types from java.base should be trusted [v3]

2023-01-29 Thread Glavo
On Mon, 30 Jan 2023 03:09:53 GMT, Tingjun Yuan wrote: >>> Why not use set of classes? >> >> Because some classes are not visible here (such as `Arrays.ArrayList`). >> >> I'm not sure what the best choice is, so I'm trying to explore the >> implementation plan. > >> > Why not use set of classe

Re: RFR: 8301220: Return value of toArray() of Сollection types from java.base should be trusted [v3]

2023-01-29 Thread Tingjun Yuan
On Mon, 30 Jan 2023 03:02:33 GMT, Glavo wrote: > > Why not use set of classes? > > Because some classes are not visible here (such as `Arrays.ArrayList`). > > I'm not sure what the best choice is, so I'm trying to explore the > implementation plan. Only `Arrays.ArrayList` is not visible here.

Re: RFR: JDK-8262994: Refactor String.split to help method inlining [v2]

2023-01-29 Thread Christian Wimmer
On Sun, 29 Jan 2023 16:07:08 GMT, Peter Levart wrote: >> Christian Wimmer has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Add comment about method inlining > > Hi Christian, I can sponsor to pull this change if you like. @plevart yes p

Re: RFR: 8301220: Return value of toArray() of Сollection types from java.base should be trusted [v3]

2023-01-29 Thread Glavo
On Mon, 30 Jan 2023 02:57:52 GMT, Tingjun Yuan wrote: > Why not use set of classes? Because some classes are not visible here (such as `Arrays.ArrayList`). I'm not sure what the best choice is, so I'm trying to explore the implementation plan. - PR: https://git.openjdk.org/jdk/p

Re: RFR: 8301220: Return value of toArray() of Сollection types from java.base should be trusted [v3]

2023-01-29 Thread Tingjun Yuan
On Mon, 30 Jan 2023 02:55:24 GMT, Glavo wrote: >> I checked the `java.base` module, and all the `Collection#toArray()` method >> of collections be implemented correctly. >> >> Their return values can be trusted, so many unnecessary array duplication >> can be eliminated. > > Glavo has updated

Re: RFR: 8301220: Return value of toArray() of Сollection types from java.base should be trusted [v3]

2023-01-29 Thread Glavo
> I checked the `java.base` module, and all the `Collection#toArray()` method > of collections be implemented correctly. > > Their return values can be trusted, so many unnecessary array duplication can > be eliminated. Glavo has updated the pull request incrementally with one additional commit

Re: RFR: 8299807: newStringNoRepl should avoid copying arrays for ASCII compatible charsets [v4]

2023-01-29 Thread Glavo
On Sat, 28 Jan 2023 19:54:32 GMT, Glavo wrote: >> This is the javadoc of `JavaLangAccess::newStringNoRepl`: >> >> >> /** >> * Constructs a new {@code String} by decoding the specified subarray of >> * bytes using the specified {@linkplain java.nio.charset.Charset >> charset}. >>

Re: RFR: 8301043: Super-interface for PrintStream and PrintWriter [v2]

2023-01-29 Thread Tingjun Yuan
On Sun, 29 Jan 2023 07:11:26 GMT, Tingjun Yuan wrote: >> Add `java.io.PrintOutput` to represent print operations, and modify >> `java.io.PrintStream` and `java.io.PrintWriter` to implement it. > > Tingjun Yuan has updated the pull request incrementally with one additional > commit since the las

Re: RFR: 8301042: Need methods to check null elements in an array or a collection [v5]

2023-01-29 Thread Stuart Marks
On Sun, 29 Jan 2023 10:39:22 GMT, Tingjun Yuan wrote: >> Adding the following methods to check the nullity of elements of an array or >> a collection: >> >> >> java.util.Arrays: >> public static E[] requireNoNulls(E[] array) >> public static E[] requireNoNulls(E[] array, String message) >> p

Re: NPE throwing behavior of immutable collections

2023-01-29 Thread Glavo
I quite agree with you. I think the collection framework is in a very puzzling state. The hostility of the new collection factory method introduced by Java 9 to null has brought us trouble. I can understand that this is to expect users to explicitly declare that the elements of the list cannot be

Re: NPE throwing behavior of immutable collections

2023-01-29 Thread Alan Snyder
I tend to agree. Presumably it is similar reasoning that led to Collection.contains() to take Object rather than E. > On Jan 29, 2023, at 7:28 AM, John Hendrikx wrote: > > TLDR; why does contains(null) not just return false for collections that > don't allow nulls. Just because the interface

Re: RFR: JDK-8262994: Refactor String.split to help method inlining [v2]

2023-01-29 Thread Peter Levart
On Mon, 9 Jan 2023 20:04:34 GMT, Christian Wimmer wrote: >> The method `String.split` contains a fast-path when the regular expression >> parameter is not really a regular expression, but just a single split >> character. >> This fast path vs. slow path check can be constant folded when the reg

NPE throwing behavior of immutable collections

2023-01-29 Thread John Hendrikx
TLDR; why does contains(null) not just return false for collections that don't allow nulls. Just because the interface allows it, does not mean it should do it as it devalues the usefulness of the abstraction provided by the interface. Background: I'm someone that likes to check correctness o

Re: RFR: 8301042: Need methods to check null elements in an array or a collection [v5]

2023-01-29 Thread Tingjun Yuan
> Adding the following methods to check the nullity of elements of an array or > a collection: > > > java.util.Arrays: > public static E[] requireNoNulls(E[] array) > public static E[] requireNoNulls(E[] array, String message) > public static E[] requireNoNulls(E[] array, IntFunction > messa