Skip to content

Commit 80fa3ac

Browse files
committed
ShadowingClassLoader can be constructed without default excludes
Issue: SPR-15439 (cherry picked from commit 1735ba2)
1 parent 54180f9 commit 80fa3ac

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

spring-context/src/main/java/org/springframework/instrument/classloading/ShadowingClassLoader.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2017 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.
@@ -60,14 +60,28 @@ public class ShadowingClassLoader extends DecoratingClassLoader {
6060

6161

6262
/**
63-
* Create a new ShadowingClassLoader, decorating the given ClassLoader.
63+
* Create a new ShadowingClassLoader, decorating the given ClassLoader,
64+
* applying {@link #DEFAULT_EXCLUDED_PACKAGES}.
6465
* @param enclosingClassLoader the ClassLoader to decorate
66+
* @see #ShadowingClassLoader(ClassLoader, boolean)
6567
*/
6668
public ShadowingClassLoader(ClassLoader enclosingClassLoader) {
69+
this(enclosingClassLoader, true);
70+
}
71+
72+
/**
73+
* Create a new ShadowingClassLoader, decorating the given ClassLoader.
74+
* @param enclosingClassLoader the ClassLoader to decorate
75+
* @param defaultExcludes whether to apply {@link #DEFAULT_EXCLUDED_PACKAGES}
76+
* @since 4.3.8
77+
*/
78+
public ShadowingClassLoader(ClassLoader enclosingClassLoader, boolean defaultExcludes) {
6779
Assert.notNull(enclosingClassLoader, "Enclosing ClassLoader must not be null");
6880
this.enclosingClassLoader = enclosingClassLoader;
69-
for (String excludedPackage : DEFAULT_EXCLUDED_PACKAGES) {
70-
excludePackage(excludedPackage);
81+
if (defaultExcludes) {
82+
for (String excludedPackage : DEFAULT_EXCLUDED_PACKAGES) {
83+
excludePackage(excludedPackage);
84+
}
7185
}
7286
}
7387

0 commit comments

Comments
 (0)