(
class: &ClassInfo,
class_loader: &dyn Fn(&str) -> Option<Arc<ClassInfo>>,
visited: &mut HashSet<String>,
)
| 362 | } |
| 363 | |
| 364 | fn is_throwable_inner( |
| 365 | class: &ClassInfo, |
| 366 | class_loader: &dyn Fn(&str) -> Option<Arc<ClassInfo>>, |
| 367 | visited: &mut HashSet<String>, |
| 368 | ) -> bool { |
| 369 | let fqn = class.fqn().to_string(); |
| 370 | if !visited.insert(fqn.clone()) { |
| 371 | return false; |
| 372 | } |
| 373 | |
| 374 | // Direct match on well-known throwable types. |
| 375 | let fqn_lower = fqn.to_lowercase(); |
| 376 | if fqn_lower == "throwable" |
| 377 | || fqn_lower == "exception" |
| 378 | || fqn_lower == "error" |
| 379 | || fqn_lower == "runtimeexception" |
| 380 | || fqn_lower == "logicexception" |
| 381 | { |
| 382 | return true; |
| 383 | } |
| 384 | |
| 385 | // Check interfaces. |
| 386 | for iface_name in &class.interfaces { |
| 387 | let iface_lower = iface_name.to_lowercase(); |
| 388 | let iface_short = short_name(&iface_lower); |
| 389 | if iface_short == "throwable" { |
| 390 | return true; |
| 391 | } |
| 392 | if let Some(iface) = class_loader(iface_name) |
| 393 | && is_throwable_inner(&iface, class_loader, visited) |
| 394 | { |
| 395 | return true; |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | // Check parent class. |
| 400 | if let Some(ref parent_name) = class.parent_class { |
| 401 | let parent_lower = parent_name.to_lowercase(); |
| 402 | let parent_short = short_name(&parent_lower); |
| 403 | if parent_short == "exception" |
| 404 | || parent_short == "error" |
| 405 | || parent_short == "throwable" |
| 406 | || parent_short == "runtimeexception" |
| 407 | || parent_short == "logicexception" |
| 408 | { |
| 409 | return true; |
| 410 | } |
| 411 | if let Some(parent) = class_loader(parent_name) |
| 412 | && is_throwable_inner(&parent, class_loader, visited) |
| 413 | { |
| 414 | return true; |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | false |
| 419 | } |
| 420 | |
| 421 | /// Extract the short name from a potentially namespaced class name. |
no test coverage detected