On Wed, 22 May 2024 14:24:40 GMT, jengebr <d...@openjdk.org> 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 >> instead of AccessibleObject or Executable) >> >> `Proxy` is meaningless with an empty list of interfaces, as it's solely for >> implementing interfaces and delegating method calls to the given >> InvocationHandler. So I would ignore that scenario. > > 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 is explicitly avoided. We may get a performance gain by modifying > `Class.getInterfaces()` directly (the sole caller that passes `true`) then > eliminating the parameter, then modifying each caller, etc. but that feels > like a separate change inspired by this one. > > Thoughts?
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 `getInterfacesShared()` (like `getSharedEnumConstants()`) and move this copy operation to `getInterfaces()` as you suggest. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/19327#discussion_r1610109601