Skip to content

Commit 1b18928

Browse files
committed
Explicitly set custom ClassLoader on CGLIB Enhancer
Closes gh-34274
1 parent 8c2b44b commit 1b18928

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 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.
@@ -129,6 +129,9 @@ public Class<?> enhance(Class<?> configClass, @Nullable ClassLoader classLoader)
129129
*/
130130
private Enhancer newEnhancer(Class<?> configSuperClass, @Nullable ClassLoader classLoader) {
131131
Enhancer enhancer = new Enhancer();
132+
if (classLoader != null) {
133+
enhancer.setClassLoader(classLoader);
134+
}
132135
enhancer.setSuperclass(configSuperClass);
133136
enhancer.setInterfaces(new Class<?>[] {EnhancedConfiguration.class});
134137
enhancer.setUseFactory(false);

0 commit comments

Comments
 (0)