diff --git a/java/java-impl/src/inspectionDescriptions/AnonymousInnerClassMayBeStatic.html b/java/java-impl/src/inspectionDescriptions/AnonymousInnerClassMayBeStatic.html index 1b4231a4fca1..ded72109cefa 100644 --- a/java/java-impl/src/inspectionDescriptions/AnonymousInnerClassMayBeStatic.html +++ b/java/java-impl/src/inspectionDescriptions/AnonymousInnerClassMayBeStatic.html @@ -7,8 +7,8 @@ A static inner class does not keep an implicit reference to its enc This prevents a common cause of memory leaks and uses less memory per class instance.

- Since Java 18, only serializable anonymous classes keep an implicit reference to its enclosing instance, - if this reference is not used. So, if module language level is Java 18 or higher, + Since Java 18, only serializable anonymous classes keep an implicit reference to their enclosing instance, + if this reference is not used. Therefore, when the module language level is Java 18 or higher, this inspection reports serializable classes only.

The quick-fix extracts the anonymous class into a named static inner class.

diff --git a/java/java-impl/src/inspectionDescriptions/DoubleBraceInitialization.html b/java/java-impl/src/inspectionDescriptions/DoubleBraceInitialization.html index 9de722ce8da9..02d16e0c2c86 100644 --- a/java/java-impl/src/inspectionDescriptions/DoubleBraceInitialization.html +++ b/java/java-impl/src/inspectionDescriptions/DoubleBraceInitialization.html @@ -1,12 +1,12 @@ Reports Double Brace Initialization. -

Double brace initialization may cause memory leaks when used in a non-static context because it creates an anonymous class - that will reference the surrounding object.

Compared to regular initialization, double brace initialization provides worse performance since it requires loading an additional class.

It may also cause failure of equals() comparisons if the equals() method doesn't accept subclasses as parameters.

+

Double brace initialization may cause memory leaks when used in a non-static context. This is because it defines an anonymous class + that will reference the surrounding object, when compiled with javac from before Java 18.

In addition, before Java 9, double brace initialization couldn't be combined with the diamond operator since it was incompatible with anonymous classes.

diff --git a/java/java-impl/src/inspectionDescriptions/InnerClassMayBeStatic.html b/java/java-impl/src/inspectionDescriptions/InnerClassMayBeStatic.html index 725180e4ac1f..e0fa1e930503 100644 --- a/java/java-impl/src/inspectionDescriptions/InnerClassMayBeStatic.html +++ b/java/java-impl/src/inspectionDescriptions/InnerClassMayBeStatic.html @@ -2,7 +2,8 @@ Reports inner classes that can be made static.

A static inner class does not keep an implicit reference to its enclosing instance. - This prevents a common cause of memory leaks and uses less memory per instance of the class.

+ When using Java 17 or before, + this prevents a common cause of memory leaks and uses less memory per instance of the class.

Example:


   public class Outer {