Skip to content

Commit 57de2e0

Browse files
committed
Deprecate ClassUtils.isCglibProxy methods in favor of AOP-level checks
Closes gh-22706
1 parent f273fa9 commit 57de2e0

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 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.
@@ -166,7 +166,7 @@ public Object getProxy(@Nullable ClassLoader classLoader) {
166166
Assert.state(rootClass != null, "Target class must be available for creating a CGLIB proxy");
167167

168168
Class<?> proxySuperClass = rootClass;
169-
if (ClassUtils.isCglibProxyClass(rootClass)) {
169+
if (rootClass.getName().contains(ClassUtils.CGLIB_CLASS_SEPARATOR)) {
170170
proxySuperClass = rootClass.getSuperclass();
171171
Class<?>[] additionalInterfaces = rootClass.getInterfaces();
172172
for (Class<?> additionalInterface : additionalInterfaces) {

spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 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.
@@ -66,8 +66,8 @@ public abstract class AopUtils {
6666
* @see #isCglibProxy
6767
*/
6868
public static boolean isAopProxy(@Nullable Object object) {
69-
return (object instanceof SpringProxy &&
70-
(Proxy.isProxyClass(object.getClass()) || ClassUtils.isCglibProxyClass(object.getClass())));
69+
return (object instanceof SpringProxy && (Proxy.isProxyClass(object.getClass()) ||
70+
object.getClass().getName().contains(ClassUtils.CGLIB_CLASS_SEPARATOR)));
7171
}
7272

7373
/**
@@ -91,7 +91,8 @@ public static boolean isJdkDynamicProxy(@Nullable Object object) {
9191
* @see ClassUtils#isCglibProxy(Object)
9292
*/
9393
public static boolean isCglibProxy(@Nullable Object object) {
94-
return (object instanceof SpringProxy && ClassUtils.isCglibProxy(object));
94+
return (object instanceof SpringProxy &&
95+
object.getClass().getName().contains(ClassUtils.CGLIB_CLASS_SEPARATOR));
9596
}
9697

9798
/**

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,9 @@ public static boolean isInnerClass(Class<?> clazz) {
841841
* @param object the object to check
842842
* @see #isCglibProxyClass(Class)
843843
* @see org.springframework.aop.support.AopUtils#isCglibProxy(Object)
844+
* @deprecated as of 5.2, in favor of custom (possibly narrower) checks
844845
*/
846+
@Deprecated
845847
public static boolean isCglibProxy(Object object) {
846848
return isCglibProxyClass(object.getClass());
847849
}
@@ -850,15 +852,19 @@ public static boolean isCglibProxy(Object object) {
850852
* Check whether the specified class is a CGLIB-generated class.
851853
* @param clazz the class to check
852854
* @see #isCglibProxyClassName(String)
855+
* @deprecated as of 5.2, in favor of custom (possibly narrower) checks
853856
*/
857+
@Deprecated
854858
public static boolean isCglibProxyClass(@Nullable Class<?> clazz) {
855859
return (clazz != null && isCglibProxyClassName(clazz.getName()));
856860
}
857861

858862
/**
859863
* Check whether the specified class name is a CGLIB-generated class.
860864
* @param className the class name to check
865+
* @deprecated as of 5.2, in favor of custom (possibly narrower) checks
861866
*/
867+
@Deprecated
862868
public static boolean isCglibProxyClassName(@Nullable String className) {
863869
return (className != null && className.contains(CGLIB_CLASS_SEPARATOR));
864870
}

0 commit comments

Comments
 (0)