Skip to content

Commit c2fdd56

Browse files
committed
Polishing
1 parent 98536e1 commit c2fdd56

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -201,15 +201,13 @@ public Object getProxy(ClassLoader classLoader) {
201201
return createProxyClassAndInstance(enhancer, callbacks);
202202
}
203203
catch (CodeGenerationException ex) {
204-
throw new AopConfigException("Could not generate CGLIB subclass of class [" +
205-
this.advised.getTargetClass() + "]: " +
206-
"Common causes of this problem include using a final class or a non-visible class",
204+
throw new AopConfigException("Could not generate CGLIB subclass of " + this.advised.getTargetClass() +
205+
": Common causes of this problem include using a final class or a non-visible class",
207206
ex);
208207
}
209208
catch (IllegalArgumentException ex) {
210-
throw new AopConfigException("Could not generate CGLIB subclass of class [" +
211-
this.advised.getTargetClass() + "]: " +
212-
"Common causes of this problem include using a final class or a non-visible class",
209+
throw new AopConfigException("Could not generate CGLIB subclass of " + this.advised.getTargetClass() +
210+
": Common causes of this problem include using a final class or a non-visible class",
213211
ex);
214212
}
215213
catch (Throwable ex) {
@@ -259,7 +257,7 @@ private void doValidateClass(Class<?> proxySuperClass, ClassLoader proxyClassLoa
259257
Method[] methods = proxySuperClass.getDeclaredMethods();
260258
for (Method method : methods) {
261259
int mod = method.getModifiers();
262-
if (!Modifier.isStatic(mod)) {
260+
if (!Modifier.isStatic(mod) && !Modifier.isPrivate(mod)) {
263261
if (Modifier.isFinal(mod)) {
264262
if (implementsInterface(method, ifcs)) {
265263
logger.warn("Unable to proxy interface-implementing method [" + method + "] because " +
@@ -269,7 +267,7 @@ private void doValidateClass(Class<?> proxySuperClass, ClassLoader proxyClassLoa
269267
"Calls to this method will NOT be routed to the target instance and " +
270268
"might lead to NPEs against uninitialized fields in the proxy instance.");
271269
}
272-
else if (!Modifier.isPublic(mod) && !Modifier.isProtected(mod) && !Modifier.isPrivate(mod) &&
270+
else if (!Modifier.isPublic(mod) && !Modifier.isProtected(mod) &&
273271
proxyClassLoader != null && proxySuperClass.getClassLoader() != proxyClassLoader) {
274272
logger.info("Method [" + method + "] is package-visible across different ClassLoaders " +
275273
"and cannot get proxied via CGLIB: Declare this method as public or protected " +

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ public Class<?> enhance(Class<?> configClass, ClassLoader classLoader) {
118118
/**
119119
* Creates a new CGLIB {@link Enhancer} instance.
120120
*/
121-
private Enhancer newEnhancer(Class<?> superclass, ClassLoader classLoader) {
121+
private Enhancer newEnhancer(Class<?> configSuperClass, ClassLoader classLoader) {
122122
Enhancer enhancer = new Enhancer();
123-
enhancer.setSuperclass(superclass);
123+
enhancer.setSuperclass(configSuperClass);
124124
enhancer.setInterfaces(new Class<?>[] {EnhancedConfiguration.class});
125125
enhancer.setUseFactory(false);
126126
enhancer.setNamingPolicy(SpringNamingPolicy.INSTANCE);

0 commit comments

Comments
 (0)