File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
src/main/java/org/scijava/annotations Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -191,7 +191,7 @@ else if (expectedType == Class.class) {
191191 return loader .loadClass ((String ) o );
192192 }
193193 catch (Throwable t ) {
194- throw new ClassCastException ( t . getMessage () );
194+ throw cce ( t );
195195 }
196196 }
197197 else if (expectedType .isArray ()) {
@@ -214,7 +214,7 @@ else if (Enum.class.isAssignableFrom(expectedType)) {
214214 return loader .loadClass (enumName ).getField (constName ).get (null );
215215 }
216216 catch (Throwable t ) {
217- throw new ClassCastException ( t . getMessage () );
217+ throw cce ( t );
218218 }
219219 }
220220 else if (Annotation .class .isAssignableFrom (expectedType )) {
@@ -227,4 +227,10 @@ else if (Annotation.class.isAssignableFrom(expectedType)) {
227227 throw new ClassCastException ("Cannot cast object of type " +
228228 o .getClass ().getName () + " to " + expectedType .getName ());
229229 }
230+
231+ private static ClassCastException cce (final Throwable cause ) {
232+ final ClassCastException cce = new ClassCastException ();
233+ cce .initCause (cause );
234+ return cce ;
235+ }
230236}
You can’t perform that action at this time.
0 commit comments