@@ -74,6 +74,10 @@ public static enum Option {
74
74
/** Cache of loaded classes: key is the binary name (dotted) */
75
75
final Map <String ,ClassMetadata > classpathClassCache = new HashMap <>();
76
76
77
+ /** Related classes (binary name, dotted) which were not found while looking up
78
+ * class metadata [referenced (super)classes, interfaces,...] */
79
+ final Set <String > missingClasses = new TreeSet <>();
80
+
77
81
final Signatures forbiddenSignatures ;
78
82
79
83
/** descriptors (not internal names) of all annotations that suppress */
@@ -305,10 +309,7 @@ public ClassMetadata lookupRelatedClass(String internalName, String internalName
305
309
if (options .contains (Option .FAIL_ON_MISSING_CLASSES )) {
306
310
throw new RelatedClassLoadingException (cnfe , origClassName );
307
311
} else {
308
- logger .warn (String .format (Locale .ENGLISH ,
309
- "Class '%s' cannot be loaded (while looking up details about referenced class '%s'). Please fix the classpath!" ,
310
- type .getClassName (), origClassName
311
- ));
312
+ missingClasses .add (type .getClassName ());
312
313
return null ;
313
314
}
314
315
} catch (IOException ioe ) {
@@ -464,6 +465,11 @@ public void run() throws ForbiddenApiException {
464
465
errors += checkClass (c , suppressAnnotationsPattern );
465
466
}
466
467
468
+ if (!missingClasses .isEmpty () ) {
469
+ logger .warn ("While scanning classes to check, the following referenced classes were not found on classpath (this may miss some violations):" );
470
+ logger .warn (AsmUtils .formatClassesAbbreviated (missingClasses ));
471
+ }
472
+
467
473
final String message = String .format (Locale .ENGLISH ,
468
474
"Scanned %d class file(s) for forbidden API invocations (in %.2fs), %d error(s)." ,
469
475
classesToCheck .size (), (System .currentTimeMillis () - start ) / 1000.0 , errors );
0 commit comments