@@ -253,20 +253,24 @@ private void validateClassIfNecessary(Class<?> proxySuperClass, @Nullable ClassL
253
253
*/
254
254
private void doValidateClass (Class <?> proxySuperClass , @ Nullable ClassLoader proxyClassLoader , Set <Class <?>> ifcs ) {
255
255
if (proxySuperClass != Object .class ) {
256
+ final boolean infoEnabled = logger .isInfoEnabled ();
257
+ final boolean debugEnabled = logger .isDebugEnabled ();
256
258
Method [] methods = proxySuperClass .getDeclaredMethods ();
257
259
for (Method method : methods ) {
258
260
int mod = method .getModifiers ();
259
261
if (!Modifier .isStatic (mod ) && !Modifier .isPrivate (mod )) {
260
262
if (Modifier .isFinal (mod )) {
261
- if (implementsInterface (method , ifcs )) {
263
+ if (infoEnabled && implementsInterface (method , ifcs )) {
262
264
logger .info ("Unable to proxy interface-implementing method [" + method + "] because " +
263
265
"it is marked as final: Consider using interface-based JDK proxies instead!" );
264
266
}
265
- logger .debug ("Final method [" + method + "] cannot get proxied via CGLIB: " +
266
- "Calls to this method will NOT be routed to the target instance and " +
267
- "might lead to NPEs against uninitialized fields in the proxy instance." );
267
+ if (debugEnabled ) {
268
+ logger .debug ("Final method [" + method + "] cannot get proxied via CGLIB: " +
269
+ "Calls to this method will NOT be routed to the target instance and " +
270
+ "might lead to NPEs against uninitialized fields in the proxy instance." );
271
+ }
268
272
}
269
- else if (!Modifier .isPublic (mod ) && !Modifier .isProtected (mod ) &&
273
+ else if (debugEnabled && !Modifier .isPublic (mod ) && !Modifier .isProtected (mod ) &&
270
274
proxyClassLoader != null && proxySuperClass .getClassLoader () != proxyClassLoader ) {
271
275
logger .debug ("Method [" + method + "] is package-visible across different ClassLoaders " +
272
276
"and cannot get proxied via CGLIB: Declare this method as public or protected " +
@@ -526,7 +530,7 @@ public Object intercept(Object proxy, Method method, Object[] args, MethodProxy
526
530
private static class StaticDispatcher implements Dispatcher , Serializable {
527
531
528
532
@ Nullable
529
- private Object target ;
533
+ private final Object target ;
530
534
531
535
public StaticDispatcher (@ Nullable Object target ) {
532
536
this .target = target ;
@@ -552,7 +556,7 @@ public AdvisedDispatcher(AdvisedSupport advised) {
552
556
}
553
557
554
558
@ Override
555
- public Object loadObject () throws Exception {
559
+ public Object loadObject () {
556
560
return this .advised ;
557
561
}
558
562
}
@@ -959,11 +963,11 @@ public boolean equals(@Nullable Object other) {
959
963
return true ;
960
964
}
961
965
962
- private boolean equalsAdviceClasses (Advisor a , Advisor b ) {
966
+ private static boolean equalsAdviceClasses (Advisor a , Advisor b ) {
963
967
return (a .getAdvice ().getClass () == b .getAdvice ().getClass ());
964
968
}
965
969
966
- private boolean equalsPointcuts (Advisor a , Advisor b ) {
970
+ private static boolean equalsPointcuts (Advisor a , Advisor b ) {
967
971
// If only one of the advisor (but not both) is PointcutAdvisor, then it is a mismatch.
968
972
// Takes care of the situations where an IntroductionAdvisor is used (see SPR-3959).
969
973
return (!(a instanceof PointcutAdvisor ) ||
0 commit comments