@@ -88,21 +88,39 @@ public Class<?> loadClass(String clazzName) throws ClassNotFoundException {
88
88
}
89
89
}
90
90
if (contains ) {
91
+ Exception ex = null ;
91
92
synchronized (mutex ) {
92
93
clazz = loadedClasses .get (clazzName );
93
- if (clazz == null ) {
94
- // The following two lines are IO sensitive
95
- byte [] bytes = null ;
96
- // The following lines are IO sensitive
97
- try {
98
- bytes = loadClassData (clazzName );
99
- } catch (IOException e ) {
100
- throw new ClassNotFoundException (e .getMessage (), e );
101
- }
102
- clazz = defineClass (clazzName , bytes , 0 , bytes .length );
103
- loadedClasses .put (clazzName , clazz );
104
- }
105
- return clazz ;
94
+ if (clazz != null ) {
95
+ return clazz ;
96
+ }
97
+ byte [] bytes = null ;
98
+ // The following lines are IO sensitive
99
+ try {
100
+ bytes = loadClassData (clazzName );
101
+ } catch (IOException e ) {
102
+ ex = e ;
103
+ }
104
+ if (bytes != null ) {
105
+ clazz = defineClass (clazzName , bytes , 0 , bytes .length );
106
+ loadedClasses .put (clazzName , clazz );
107
+ return clazz ;
108
+ }
109
+ }
110
+ // continue to load class by super class loader
111
+ ClassLoader parent = getParent ();
112
+ if (parent != null ) {
113
+ clazz = parent .loadClass (clazzName );
114
+ synchronized (mutex ) {
115
+ loadedClasses .put (clazzName , clazz );
116
+ }
117
+ return clazz ;
118
+ } else {
119
+ if (ex != null ) {
120
+ throw new ClassNotFoundException (ex .getMessage (), ex );
121
+ } else {
122
+ throw new ClassNotFoundException ();
123
+ }
106
124
}
107
125
}
108
126
/*
0 commit comments