@@ -309,6 +309,11 @@ public ClassSignature lookupRelatedClass(String internalName, String internalNam
309
309
}
310
310
} catch (IOException ioe ) {
311
311
throw new RelatedClassLoadingException (ioe , Type .getObjectType (internalNameOrig ).getClassName ());
312
+ } catch (RuntimeException re ) {
313
+ if (AsmUtils .isExceptionInAsmClassReader (re )) {
314
+ throw new RelatedClassLoadingException (re , Type .getObjectType (internalNameOrig ).getClassName ());
315
+ }
316
+ throw re ;
312
317
}
313
318
}
314
319
@@ -419,8 +424,23 @@ private int checkClass(final ClassReader reader, Pattern suppressAnnotationsPatt
419
424
}
420
425
msg .append (": " ).append (cause );
421
426
msg .append (" (while looking up details about referenced class '" ).append (rcle .getClassName ()).append ("')" );
422
- assert cause != null && (cause instanceof IOException || cause instanceof ClassNotFoundException );
427
+ assert cause != null && (cause instanceof IOException || cause instanceof ClassNotFoundException || cause instanceof RuntimeException );
423
428
throw new ForbiddenApiException (msg .toString (), cause );
429
+ } catch (RuntimeException re ) {
430
+ if (AsmUtils .isExceptionInAsmClassReader (re )) {
431
+ final StringBuilder msg = new StringBuilder ()
432
+ .append ("Failed to parse class '" )
433
+ .append (className )
434
+ .append ('\'' );
435
+ final String source = scanner .getSourceFile ();
436
+ if (source != null ) {
437
+ msg .append (" (" ).append (source ).append (')' );
438
+ }
439
+ msg .append (": " ).append (re );
440
+ throw new ForbiddenApiException (msg .toString (), re );
441
+ }
442
+ // else rethrow (it's occuring in our code):
443
+ throw re ;
424
444
}
425
445
final List <ForbiddenViolation > violations = scanner .getSortedViolations ();
426
446
final Pattern splitter = Pattern .compile (Pattern .quote (ForbiddenViolation .SEPARATOR ));
0 commit comments