Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor} [v6]

2024-06-03 Thread Aleksey Shipilev
On Fri, 31 May 2024 18:39:33 GMT, jengebr wrote: >> Improve `java/lang/reflect/Method.java` by eliminating needless cloning of >> Class[0] instances. This cloning is intended to prevent callers from >> changing array contents, but many Methods have zero exceptions or zero >> parameters, and

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor} [v6]

2024-05-31 Thread Roger Riggs
On Fri, 31 May 2024 18:39:33 GMT, jengebr wrote: >> Improve `java/lang/reflect/Method.java` by eliminating needless cloning of >> Class[0] instances. This cloning is intended to prevent callers from >> changing array contents, but many Methods have zero exceptions or zero >> parameters, and

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor} [v6]

2024-05-31 Thread Chen Liang
On Fri, 31 May 2024 18:39:33 GMT, jengebr wrote: >> Improve `java/lang/reflect/Method.java` by eliminating needless cloning of >> Class[0] instances. This cloning is intended to prevent callers from >> changing array contents, but many Methods have zero exceptions or zero >> parameters, and

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor} [v6]

2024-05-31 Thread Aleksey Shipilev
On Fri, 31 May 2024 18:39:33 GMT, jengebr wrote: >> Improve `java/lang/reflect/Method.java` by eliminating needless cloning of >> Class[0] instances. This cloning is intended to prevent callers from >> changing array contents, but many Methods have zero exceptions or zero >> parameters, and

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor} [v5]

2024-05-31 Thread jengebr
On Fri, 31 May 2024 17:59:18 GMT, jengebr wrote: >> Improve `java/lang/reflect/Method.java` by eliminating needless cloning of >> Class[0] instances. This cloning is intended to prevent callers from >> changing array contents, but many Methods have zero exceptions or zero >> parameters, and

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor} [v6]

2024-05-31 Thread jengebr
> Improve `java/lang/reflect/Method.java` by eliminating needless cloning of > Class[0] instances. This cloning is intended to prevent callers from > changing array contents, but many Methods have zero exceptions or zero > parameters, and returning the original `Class[0]` is sufficient. > > R

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor} [v5]

2024-05-31 Thread Aleksey Shipilev
On Fri, 31 May 2024 17:59:18 GMT, jengebr wrote: >> Improve `java/lang/reflect/Method.java` by eliminating needless cloning of >> Class[0] instances. This cloning is intended to prevent callers from >> changing array contents, but many Methods have zero exceptions or zero >> parameters, and

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor} [v5]

2024-05-31 Thread jengebr
> Improve `java/lang/reflect/Method.java` by eliminating needless cloning of > Class[0] instances. This cloning is intended to prevent callers from > changing array contents, but many Methods have zero exceptions or zero > parameters, and returning the original `Class[0]` is sufficient. > > R

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor} [v4]

2024-05-31 Thread jengebr
> Improve `java/lang/reflect/Method.java` by eliminating needless cloning of > Class[0] instances. This cloning is intended to prevent callers from > changing array contents, but many Methods have zero exceptions or zero > parameters, and returning the original `Class[0]` is sufficient. > > R

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor} [v3]

2024-05-31 Thread jengebr
On Fri, 31 May 2024 16:53:36 GMT, jengebr wrote: >> Improve `java/lang/reflect/Method.java` by eliminating needless cloning of >> Class[0] instances. This cloning is intended to prevent callers from >> changing array contents, but many Methods have zero exceptions or zero >> parameters, and

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor} [v3]

2024-05-31 Thread jengebr
> Improve `java/lang/reflect/Method.java` by eliminating needless cloning of > Class[0] instances. This cloning is intended to prevent callers from > changing array contents, but smany Methods have zero exceptions or zero > parameters, and returning the original `Class[0]` is sufficient. jeng

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor} [v2]

2024-05-31 Thread Aleksey Shipilev
On Fri, 31 May 2024 16:21:36 GMT, jengebr wrote: >> Improve `java/lang/reflect/Method.java` by eliminating needless cloning of >> Class[0] instances. This cloning is intended to prevent callers from >> changing array contents, but smany Methods have zero exceptions or zero >> parameters, and

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor}

2024-05-31 Thread jengebr
On Wed, 22 May 2024 09:44:18 GMT, Aleksey Shipilev wrote: >> Improve `java/lang/reflect/Method.java` by eliminating needless cloning of >> Class[0] instances. This cloning is intended to prevent callers from >> changing array contents, but smany Methods have zero exceptions or zero >> parame

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor} [v2]

2024-05-31 Thread Chen Liang
On Fri, 31 May 2024 16:18:01 GMT, jengebr wrote: >> Improve `java/lang/reflect/Method.java` by eliminating needless cloning of >> Class[0] instances. This cloning is intended to prevent callers from >> changing array contents, but smany Methods have zero exceptions or zero >> parameters, and

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor} [v2]

2024-05-31 Thread jengebr
> Improve `java/lang/reflect/Method.java` by eliminating needless cloning of > Class[0] instances. This cloning is intended to prevent callers from > changing array contents, but smany Methods have zero exceptions or zero > parameters, and returning the original `Class[0]` is sufficient. jeng

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor}

2024-05-30 Thread Joe Darcy
On Tue, 21 May 2024 13:49:18 GMT, jengebr wrote: > Improve `java/lang/reflect/Method.java` by eliminating needless cloning of > Class[0] instances. This cloning is intended to prevent callers from > changing array contents, but smany Methods have zero exceptions or zero > parameters, and ret

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor}

2024-05-30 Thread Roger Riggs
On Tue, 21 May 2024 13:49:18 GMT, jengebr wrote: > Improve `java/lang/reflect/Method.java` by eliminating needless cloning of > Class[0] instances. This cloning is intended to prevent callers from > changing array contents, but smany Methods have zero exceptions or zero > parameters, and ret

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor}

2024-05-30 Thread Aleksey Shipilev
On Tue, 21 May 2024 13:49:18 GMT, jengebr wrote: > Improve `java/lang/reflect/Method.java` by eliminating needless cloning of > Class[0] instances. This cloning is intended to prevent callers from > changing array contents, but smany Methods have zero exceptions or zero > parameters, and ret

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor}

2024-05-30 Thread Aleksey Shipilev
On Wed, 22 May 2024 14:32:23 GMT, Chen Liang wrote: >> Thanks. Unfortunately the variable `cloneArray` is actually a method >> parameter, and most of the callers pass in `false` - so using this utility >> method to control cloning would actually introduce cloning in several places >> where it

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor}

2024-05-30 Thread Chen Liang
On Wed, 22 May 2024 14:33:31 GMT, Aleksey Shipilev wrote: >> Why can't you do something like this: >> >> return cloneArray ? ReflectionFactory.copyClasses(interfaces) : interfaces; >> >> >> Alternatively, your proposal is a good one too; we can rename this >> `getInterfaces(boolean)` to `getI

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor}

2024-05-30 Thread Chen Liang
On Wed, 22 May 2024 09:39:50 GMT, Aleksey Shipilev wrote: >> Improve `java/lang/reflect/Method.java` by eliminating needless cloning of >> Class[0] instances. This cloning is intended to prevent callers from >> changing array contents, but smany Methods have zero exceptions or zero >> parame

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor}

2024-05-30 Thread jengebr
On Wed, 22 May 2024 13:44:59 GMT, Chen Liang wrote: >> @liach I see such an opportunity in `Proxy.getProxyConstructor`, is that >> what you have in mind? > > No, I mean here: > https://github.com/openjdk/jdk/blob/4f1a10f84bcfadef263a0890b6834ccd3d5bb52f/src/java.base/share/classes/java/lang/Cla

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor}

2024-05-30 Thread Chen Liang
On Wed, 22 May 2024 12:58:40 GMT, jengebr wrote: >> Can't this be used by class cloning interfaces too? > > @liach I see such an opportunity in `Proxy.getProxyConstructor`, is that what > you have in mind? No, I mean here: https://github.com/openjdk/jdk/blob/4f1a10f84bcfadef263a0890b6834ccd3d5

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor}

2024-05-30 Thread jengebr
On Thu, 23 May 2024 09:05:09 GMT, Aleksey Shipilev wrote: >> Alternatively, if a utility method is overkill, we can inline these to >> `Executable`: >> >> public Class[] getParameterTypes() { >> var shared = getSharedParameterTypes(); >> return shared.length == 0 ? shared : shared.clone

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor}

2024-05-30 Thread Aleksey Shipilev
On Wed, 22 May 2024 19:48:49 GMT, Chen Liang wrote: >> I really see no reason to try and save on re-use of this one-line method for >> _everything_. In fact, I do not quite see a very compelling reason to even >> have the utility method. Sharing the code between `Method` and `Constructor` >> i

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor}

2024-05-30 Thread Chen Liang
On Wed, 22 May 2024 14:24:40 GMT, jengebr wrote: >> No, I mean here: >> https://github.com/openjdk/jdk/blob/4f1a10f84bcfadef263a0890b6834ccd3d5bb52f/src/java.base/share/classes/java/lang/Class.java#L1329 >> >> (That's also why I suggest putting the utiltiy method in ReflectionFactory >> instea

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor}

2024-05-30 Thread jengebr
On Wed, 22 May 2024 10:27:16 GMT, Chen Liang wrote: >> src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java line >> 249: >> >>> 247: * the original can safely be reused. >>> 248: */ >>> 249: public Class[] copyClasses(Class[] classes) { >> >> There is no need t

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor}

2024-05-30 Thread jengebr
On Fri, 24 May 2024 21:59:58 GMT, Chen Liang wrote: > Can you update the ending copyright years from 2023 to 2024 on the 2nd line > of the 2 modified files? Done, thank you. - PR Comment: https://git.openjdk.org/jdk/pull/19327#issuecomment-2135215681

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor}

2024-05-30 Thread jengebr
On Wed, 22 May 2024 09:44:18 GMT, Aleksey Shipilev wrote: > Please also enable GHA testing: https://github.com/jengebr/jdk/actions. You > may need to trigger the test run manually after this, since the PR hook have > already missed it. Go to "OpenJDK Sanity Checks" on the left on that page, >

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor}

2024-05-30 Thread Aleksey Shipilev
On Tue, 21 May 2024 13:49:18 GMT, jengebr wrote: > Improve `java/lang/reflect/Method.java` by eliminating needless cloning of > Class[0] instances. This cloning is intended to prevent callers from > changing array contents, but smany Methods have zero exceptions or zero > parameters, and ret

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor}

2024-05-30 Thread Chen Liang
On Tue, 21 May 2024 14:07:29 GMT, jengebr wrote: > Any suggestions? I would recommend a new method `copyClasses`/`copyTypes` in `jdk.internal.reflect.ReflectionFactory`, as it already has related `copyConstructor` and `getExecutableSharedParameterTypes` methods. Also, can you rename your PR's

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor}

2024-05-30 Thread Chen Liang
On Tue, 21 May 2024 13:49:18 GMT, jengebr wrote: > Improve `java/lang/reflect/Method.java` by eliminating needless cloning of > Class[0] instances. This cloning is intended to prevent callers from > changing array contents, but smany Methods have zero exceptions or zero > parameters, and ret

RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor}

2024-05-30 Thread jengebr
Improve `java/lang/reflect/Method.java` by eliminating needless cloning of Class[0] instances. This cloning is intended to prevent callers from changing array contents, but smany Methods have zero exceptions or zero parameters, and returning the original `Class[0]` is sufficient.

Re: RFR: 8332586: Avoid cloning empty arrays in java.lang.reflect.{Method,Constructor}

2024-05-30 Thread jengebr
On Tue, 21 May 2024 13:49:18 GMT, jengebr wrote: > Improve `java/lang/reflect/Method.java` by eliminating needless cloning of > Class[0] instances. This cloning is intended to prevent callers from > changing array contents, but smany Methods have zero exceptions or zero > parameters, and ret