Make inner classes static when feasible (on main)
A static nested 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. Closes gh-28433
This commit is contained in:
parent
d45b5f6e8a
commit
7cb6ac0a02
|
|
@ -654,7 +654,7 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA
|
|||
/**
|
||||
* Base class representing injection information.
|
||||
*/
|
||||
private abstract class AutowiredElement extends InjectionMetadata.InjectedElement {
|
||||
private abstract static class AutowiredElement extends InjectionMetadata.InjectedElement {
|
||||
|
||||
protected final boolean required;
|
||||
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ class BeanDefinitionPropertyValueCodeGenerator {
|
|||
/**
|
||||
* {@link Delegate} for {@code primitive} types.
|
||||
*/
|
||||
private class PrimitiveDelegate implements Delegate {
|
||||
private static class PrimitiveDelegate implements Delegate {
|
||||
|
||||
private static final Map<Character, String> CHAR_ESCAPES;
|
||||
|
||||
|
|
@ -177,7 +177,7 @@ class BeanDefinitionPropertyValueCodeGenerator {
|
|||
/**
|
||||
* {@link Delegate} for {@link String} types.
|
||||
*/
|
||||
private class StringDelegate implements Delegate {
|
||||
private static class StringDelegate implements Delegate {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
|
|
@ -194,7 +194,7 @@ class BeanDefinitionPropertyValueCodeGenerator {
|
|||
/**
|
||||
* {@link Delegate} for {@link Enum} types.
|
||||
*/
|
||||
private class EnumDelegate implements Delegate {
|
||||
private static class EnumDelegate implements Delegate {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
|
|
@ -212,7 +212,7 @@ class BeanDefinitionPropertyValueCodeGenerator {
|
|||
/**
|
||||
* {@link Delegate} for {@link Class} types.
|
||||
*/
|
||||
private class ClassDelegate implements Delegate {
|
||||
private static class ClassDelegate implements Delegate {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
|
|
@ -229,7 +229,7 @@ class BeanDefinitionPropertyValueCodeGenerator {
|
|||
/**
|
||||
* {@link Delegate} for {@link ResolvableType} types.
|
||||
*/
|
||||
private class ResolvableTypeDelegate implements Delegate {
|
||||
private static class ResolvableTypeDelegate implements Delegate {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
|
|
@ -512,7 +512,7 @@ class BeanDefinitionPropertyValueCodeGenerator {
|
|||
/**
|
||||
* {@link Delegate} for {@link BeanReference} types.
|
||||
*/
|
||||
private class BeanReferenceDelegate implements Delegate {
|
||||
private static class BeanReferenceDelegate implements Delegate {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
|
|
|
|||
|
|
@ -509,7 +509,7 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
|
|||
}
|
||||
|
||||
|
||||
private class AotContribution implements BeanFactoryInitializationAotContribution {
|
||||
private static class AotContribution implements BeanFactoryInitializationAotContribution {
|
||||
|
||||
private static final String BEAN_FACTORY_VARIABLE = BeanFactoryInitializationCode.BEAN_FACTORY_VARIABLE;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue