File tree 1 file changed +35
-3
lines changed
src/main/java/org/apache/maven/shared/scriptinterpreter
1 file changed +35
-3
lines changed Original file line number Diff line number Diff line change 40
40
*/
41
41
class BeanShellScriptInterpreter implements ScriptInterpreter {
42
42
43
- private static class AppendableURLClassLoader extends URLClassLoader {
44
- AppendableURLClassLoader () {
43
+ private static class ChildFirstURLClassLoader extends URLClassLoader {
44
+ ChildFirstURLClassLoader () {
45
45
super (new URL [] {}, Thread .currentThread ().getContextClassLoader ());
46
46
}
47
47
48
48
@ Override
49
49
public void addURL (URL url ) {
50
50
super .addURL (url );
51
51
}
52
+
53
+ @ Override
54
+ protected synchronized Class <?> loadClass (final String name , final boolean resolve )
55
+ throws ClassNotFoundException {
56
+
57
+ Class <?> c = findLoadedClass (name );
58
+ if (c != null ) {
59
+ return c ;
60
+ }
61
+
62
+ try {
63
+ c = super .findClass (name );
64
+ } catch (ClassNotFoundException e ) {
65
+ // ignore
66
+ }
67
+
68
+ if (c == null ) {
69
+ c = super .loadClass (name , resolve );
70
+ }
71
+
72
+ if (resolve ) {
73
+ resolveClass (c );
74
+ }
75
+
76
+ return c ;
77
+ }
78
+
79
+ @ Override
80
+ public URL getResource (final String name ) {
81
+ URL url = findResource (name );
82
+ return url != null ? url : super .getResource (name );
83
+ }
52
84
}
53
85
54
- private final AppendableURLClassLoader classLoader = new AppendableURLClassLoader ();
86
+ private final ChildFirstURLClassLoader classLoader = new ChildFirstURLClassLoader ();
55
87
56
88
@ Override
57
89
public void setClassPath (List <String > classPath ) {
You can’t perform that action at this time.
0 commit comments