@@ -72,28 +72,21 @@ class ClassLoaderIClassLoader extends IClassLoader {
72
72
73
73
Class <?> clazz ;
74
74
try {
75
-
76
- //
77
- // See also [ 931385 ] Janino 2.0 throwing exception on arrays of java.io.File:
78
- //
79
- // "ClassLoader.loadClass()" and "Class.forName()" should be identical,
80
- // but "ClassLoader.loadClass("[Ljava.lang.Object;")" throws a
81
- // ClassNotFoundException under JDK 1.5.0 beta.
82
- // Unclear whether this a beta version bug and SUN will fix this in the final
83
- // release, but "Class.forName()" seems to work fine in all cases, so we
84
- // use that.
85
- //
86
-
87
- // clazz = this.classLoader.loadClass(Descriptor.toClassName(descriptor));
88
- clazz = Class .forName (Descriptor .toClassName (descriptor ), false , this .classLoader );
75
+ clazz = this .classLoader .loadClass (Descriptor .toClassName (descriptor ));
89
76
} catch (ClassNotFoundException e ) {
90
- if (e .getException () == null ) {
91
- return null ;
92
- } else
77
+
78
+ // Determine whether the class DOES NOT EXIST, or whether there were problems loading it. That's easier
79
+ // said than done... the following seems to work:
80
+ // (See also https://github.com/janino-compiler/janino/issues/104).
93
81
{
94
- throw e ;
82
+ Throwable t = e .getCause ();
83
+ while (t instanceof ClassNotFoundException ) t = t .getCause ();
84
+ if (t == null ) return null ;
95
85
}
86
+
87
+ throw e ;
96
88
}
89
+
97
90
ClassLoaderIClassLoader .LOGGER .log (Level .FINE , "clazz={0}" , clazz );
98
91
99
92
IClass result = new ReflectionIClass (clazz , this );
0 commit comments