|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2012 the original author or authors. |
| 2 | + * Copyright 2002-2017 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -60,14 +60,28 @@ public class ShadowingClassLoader extends DecoratingClassLoader {
|
60 | 60 |
|
61 | 61 |
|
62 | 62 | /**
|
63 |
| - * Create a new ShadowingClassLoader, decorating the given ClassLoader. |
| 63 | + * Create a new ShadowingClassLoader, decorating the given ClassLoader, |
| 64 | + * applying {@link #DEFAULT_EXCLUDED_PACKAGES}. |
64 | 65 | * @param enclosingClassLoader the ClassLoader to decorate
|
| 66 | + * @see #ShadowingClassLoader(ClassLoader, boolean) |
65 | 67 | */
|
66 | 68 | 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) { |
67 | 79 | Assert.notNull(enclosingClassLoader, "Enclosing ClassLoader must not be null");
|
68 | 80 | 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 | + } |
71 | 85 | }
|
72 | 86 | }
|
73 | 87 |
|
|
0 commit comments