1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.classic.spi;
15
16 import java.net.URL;
17 import java.net.URLClassLoader;
18
19
20
21
22
23
24
25 public class LocalFirstClassLoader extends URLClassLoader {
26
27 public LocalFirstClassLoader(URL[] urls) {
28 super(urls);
29 }
30
31 public LocalFirstClassLoader(URL[] urls, ClassLoader parent) {
32 super(urls, parent);
33 }
34
35 public void addURL(URL url) {
36 super.addURL(url);
37 }
38
39 public Class<?> loadClass(String name) throws ClassNotFoundException {
40 return loadClass(name, false);
41 }
42
43
44
45
46
47
48 protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
49
50
51 Class<?> c = findLoadedClass(name);
52
53
54 if (c == null) {
55 try {
56 c = findClass(name);
57 } catch (ClassNotFoundException cnfe) {
58
59 }
60 }
61
62
63
64 if (c == null) {
65 if (getParent() != null) {
66 c = getParent().loadClass(name);
67 } else {
68 c = getSystemClassLoader().loadClass(name);
69 }
70 }
71
72 if (resolve) {
73 resolveClass(c);
74 }
75
76 return c;
77 }
78 }