Browse Source

Explicitly set custom ClassLoader on CGLIB Enhancer

Closes gh-34274

(cherry picked from commit 1b18928bf0)
6.1.x
Juergen Hoeller 11 months ago
parent
commit
a4fc68b8e8
  1. 5
      spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2024 the original author or authors. * Copyright 2002-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -129,6 +129,9 @@ class ConfigurationClassEnhancer {
*/ */
private Enhancer newEnhancer(Class<?> configSuperClass, @Nullable ClassLoader classLoader) { private Enhancer newEnhancer(Class<?> configSuperClass, @Nullable ClassLoader classLoader) {
Enhancer enhancer = new Enhancer(); Enhancer enhancer = new Enhancer();
if (classLoader != null) {
enhancer.setClassLoader(classLoader);
}
enhancer.setSuperclass(configSuperClass); enhancer.setSuperclass(configSuperClass);
enhancer.setInterfaces(new Class<?>[] {EnhancedConfiguration.class}); enhancer.setInterfaces(new Class<?>[] {EnhancedConfiguration.class});
enhancer.setUseFactory(false); enhancer.setUseFactory(false);

Loading…
Cancel
Save