标签:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
public synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException { Class clazz = null ; // (0) Check our previously loaded local class cache clazz = findLoadedClass0(name); if (clazz != null ) { if (log.isDebugEnabled()) log.debug( " Returning class from cache" ); if (resolve) resolveClass(clazz); return (clazz); } // (0.1) Check our previously loaded class cache clazz = findLoadedClass(name); if (clazz != null ) { if (log.isDebugEnabled()) log.debug( " Returning class from cache" ); if (resolve) resolveClass(clazz); return (clazz); } // (0.2) Try loading the class with the system class loader, to prevent // the webapp from overriding J2SE classes try { clazz = system.loadClass(name); if (clazz != null ) { if (resolve) resolveClass(clazz); return (clazz); } } catch (ClassNotFoundException e) { // Ignore } boolean delegateLoad = delegate || filter(name); // (1) Delegate to our parent if requested if (delegateLoad) { if (log.isDebugEnabled()) log.debug( " Delegating to parent classloader1 " + parent); ClassLoader loader = parent; if (loader == null ) loader = system; try { clazz = loader.loadClass(name); if (clazz != null ) { if (log.isDebugEnabled()) log.debug( " Loading class from parent" ); if (resolve) resolveClass(clazz); return (clazz); } } catch (ClassNotFoundException e) { ; } } // (2) Search local repositories if (log.isDebugEnabled()) log.debug( " Searching local repositories" ); try { clazz = findClass(name); if (clazz != null ) { if (log.isDebugEnabled()) log.debug( " Loading class from local repository" ); if (resolve) resolveClass(clazz); return (clazz); } } catch (ClassNotFoundException e) { ; } // (3) Delegate to parent unconditionally if (!delegateLoad) { if (log.isDebugEnabled()) log.debug( " Delegating to parent classloader at end: " + parent); ClassLoader loader = parent; if (loader == null ) loader = system; try { clazz = loader.loadClass(name); if (clazz != null ) { if (log.isDebugEnabled()) log.debug( " Loading class from parent" ); if (resolve) resolveClass(clazz); return (clazz); } } catch (ClassNotFoundException e) { ; } } throw new ClassNotFoundException(name); } |
标签:
原文地址:http://www.cnblogs.com/kabi/p/5198961.html