Skip to content

Commit ac94d2b

Browse files
committed
Polishing
(cherry picked from commit f19433f)
1 parent 16fd70a commit ac94d2b

File tree

5 files changed

+18
-29
lines changed

5 files changed

+18
-29
lines changed

spring-context/src/main/java/org/springframework/context/annotation/LoadTimeWeavingConfigurer.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,8 +21,8 @@
2121
/**
2222
* Interface to be implemented by
2323
* {@link org.springframework.context.annotation.Configuration @Configuration}
24-
* classes annotated with {@link EnableLoadTimeWeaving @EnableLoadTimeWeaving} that wish to
25-
* customize the {@link LoadTimeWeaver} instance to be used.
24+
* classes annotated with {@link EnableLoadTimeWeaving @EnableLoadTimeWeaving}
25+
* that wish to customize the {@link LoadTimeWeaver} instance to be used.
2626
*
2727
* <p>See {@link org.springframework.scheduling.annotation.EnableAsync @EnableAsync}
2828
* for usage examples and information on how a default {@code LoadTimeWeaver}
@@ -36,9 +36,9 @@
3636
public interface LoadTimeWeavingConfigurer {
3737

3838
/**
39-
* Create, configure and return the {@code LoadTimeWeaver} instance to be used. Note
40-
* that it is unnecessary to annotate this method with {@code @Bean}, because the
41-
* object returned will automatically be registered as a bean by
39+
* Create, configure and return the {@code LoadTimeWeaver} instance to be used.
40+
* Note that it is unnecessary to annotate this method with {@code @Bean}
41+
* because the object returned will automatically be registered as a bean by
4242
* {@link LoadTimeWeavingConfiguration#loadTimeWeaver()}
4343
*/
4444
LoadTimeWeaver getLoadTimeWeaver();

spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,8 @@ protected void invokeBeanFactoryPostProcessors(ConfigurableListableBeanFactory b
749749

750750
// Detect a LoadTimeWeaver and prepare for weaving, if found in the meantime
751751
// (e.g. through an @Bean method registered by ConfigurationClassPostProcessor)
752-
if (!NativeDetector.inNativeImage() && beanFactory.getTempClassLoader() == null && beanFactory.containsBean(LOAD_TIME_WEAVER_BEAN_NAME)) {
752+
if (!NativeDetector.inNativeImage() && beanFactory.getTempClassLoader() == null &&
753+
beanFactory.containsBean(LOAD_TIME_WEAVER_BEAN_NAME)) {
753754
beanFactory.addBeanPostProcessor(new LoadTimeWeaverAwareProcessor(beanFactory));
754755
beanFactory.setTempClassLoader(new ContextTypeMatchClassLoader(beanFactory.getBeanClassLoader()));
755756
}

spring-context/src/test/java/org/springframework/context/annotation/EnableLoadTimeWeavingTests.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void enableLTW_withAjWeavingEnabled() {
7979

8080

8181
@Configuration
82-
@EnableLoadTimeWeaving(aspectjWeaving=AspectJWeaving.DISABLED)
82+
@EnableLoadTimeWeaving(aspectjWeaving = AspectJWeaving.DISABLED)
8383
static class EnableLTWConfig_withAjWeavingDisabled implements LoadTimeWeavingConfigurer {
8484

8585
@Override
@@ -88,8 +88,9 @@ public LoadTimeWeaver getLoadTimeWeaver() {
8888
}
8989
}
9090

91+
9192
@Configuration
92-
@EnableLoadTimeWeaving(aspectjWeaving=AspectJWeaving.AUTODETECT)
93+
@EnableLoadTimeWeaving(aspectjWeaving = AspectJWeaving.AUTODETECT)
9394
static class EnableLTWConfig_withAjWeavingAutodetect implements LoadTimeWeavingConfigurer {
9495

9596
@Override
@@ -98,8 +99,9 @@ public LoadTimeWeaver getLoadTimeWeaver() {
9899
}
99100
}
100101

102+
101103
@Configuration
102-
@EnableLoadTimeWeaving(aspectjWeaving=AspectJWeaving.ENABLED)
104+
@EnableLoadTimeWeaving(aspectjWeaving = AspectJWeaving.ENABLED)
103105
static class EnableLTWConfig_withAjWeavingEnabled implements LoadTimeWeavingConfigurer {
104106

105107
@Override

spring-context/src/test/java/org/springframework/instrument/classloading/ReflectiveLoadTimeWeaverTests.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -85,35 +85,29 @@ public static class JustAddTransformerClassLoader extends ClassLoader {
8585

8686
private int numTimesAddTransformerCalled = 0;
8787

88-
8988
public int getNumTimesGetThrowawayClassLoaderCalled() {
9089
return this.numTimesAddTransformerCalled;
9190
}
9291

93-
9492
public void addTransformer(ClassFileTransformer transformer) {
9593
++this.numTimesAddTransformerCalled;
9694
}
97-
9895
}
9996

10097

10198
public static final class TotallyCompliantClassLoader extends JustAddTransformerClassLoader {
10299

103100
private int numTimesGetThrowawayClassLoaderCalled = 0;
104101

105-
106102
@Override
107103
public int getNumTimesGetThrowawayClassLoaderCalled() {
108104
return this.numTimesGetThrowawayClassLoaderCalled;
109105
}
110106

111-
112107
public ClassLoader getThrowawayClassLoader() {
113108
++this.numTimesGetThrowawayClassLoaderCalled;
114109
return getClass().getClassLoader();
115110
}
116-
117111
}
118112

119113
}

spring-core/src/main/java/org/springframework/util/ReflectionUtils.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -509,24 +509,16 @@ private static List<Method> findConcreteMethodsOnInterfaces(Class<?> clazz) {
509509
* @see java.lang.Object#equals(Object)
510510
*/
511511
public static boolean isEqualsMethod(@Nullable Method method) {
512-
if (method == null) {
513-
return false;
514-
}
515-
if (method.getParameterCount() != 1) {
516-
return false;
517-
}
518-
if (!method.getName().equals("equals")) {
519-
return false;
520-
}
521-
return method.getParameterTypes()[0] == Object.class;
512+
return (method != null && method.getParameterCount() == 1 && method.getName().equals("equals") &&
513+
method.getParameterTypes()[0] == Object.class);
522514
}
523515

524516
/**
525517
* Determine whether the given method is a "hashCode" method.
526518
* @see java.lang.Object#hashCode()
527519
*/
528520
public static boolean isHashCodeMethod(@Nullable Method method) {
529-
return method != null && method.getParameterCount() == 0 && method.getName().equals("hashCode");
521+
return (method != null && method.getParameterCount() == 0 && method.getName().equals("hashCode"));
530522
}
531523

532524
/**

0 commit comments

Comments
 (0)