RFR: 8261880: Change nested classes in java.base to static nested classes where possible

Claes Redestad redestad at openjdk.java.net
Wed Feb 17 16:27:40 UTC 2021


On Tue, 16 Feb 2021 14:30:58 GMT, Сергей Цыпанов <github.com+10835776+stsypanov at openjdk.org> wrote:

> Non-static classes hold a link to their parent classes, which in many cases can be avoided.

src/java.base/share/classes/java/lang/invoke/DelegatingMethodHandle.java line 192:

> 190: 
> 191:     /* Placeholder class for DelegatingMethodHandles generated ahead of time */
> 192:     static final class Holder {}

For the four `Holder` classes in `java.lang.invoke`, the class is generated when running jlink via `java.lang.invoke.GenerateJLIClassesHelper`. To stay in sync with the definition you'd have to update that code. Also, since these `Holder` classes will only contain static methods and are never instantiated then I'm not sure it matters whether the classes are static or not.

-------------

PR: https://git.openjdk.java.net/jdk/pull/2589



More information about the security-dev mailing list