RFR: 8282701: Use Class.getInterfaces(false) where possible to reduce allocation pressure
Claes Redestad
redestad at openjdk.java.net
Mon May 2 18:24:29 UTC 2022
On Mon, 2 May 2022 16:19:07 GMT, Mandy Chung <mchung at openjdk.org> wrote:
>> `Class.getInterfaces(false)` does not clone underlying array and can be used in cases when the returned array is only read from.
>
> For the `checkPackageAccess` case, I don't think it worths fixing; not only that security manager is deprecated for removal but also when security manager is enabled, there are lots of allocations for other security checks.
>
> So the `getInterface(boolean)` method can be kept private.
I agree with @mlchung that the call site in `ClassLoader` is not particularly interesting and doesn't motivate a non-cloning, trusted method. There are a few other places in java.base where it's used and a trusted method could help, but not sure any of those are performance critical.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7714
More information about the core-libs-dev
mailing list