diff options
| author | 2020-09-22 09:28:58 +0100 | |
|---|---|---|
| committer | 2020-09-22 09:57:10 +0000 | |
| commit | fdb81da69234b482ddcf5089d6821bb60dc93868 (patch) | |
| tree | 0344db14e014d49178e41fe4616caa7fe23c9bba | |
| parent | 6edcc087ac793ab5d22846854c84df5320b6d75f (diff) | |
Dedupe some code in hiddenapi.cc
This makes the CHECK message for superclasses also be printed
for interfaces, which is useful for debugging.
Test: invoke hiddenapi encode with incorrect classpath
Change-Id: I77e99d57c90eb6ff6b75c69c80bafba45ba5b82b
| -rw-r--r-- | tools/hiddenapi/hiddenapi.cc | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/tools/hiddenapi/hiddenapi.cc b/tools/hiddenapi/hiddenapi.cc index 5dbbaee57e..a14b92cf90 100644 --- a/tools/hiddenapi/hiddenapi.cc +++ b/tools/hiddenapi/hiddenapi.cc @@ -525,18 +525,19 @@ class Hierarchy final { continue; } - HierarchyClass* superclass = FindClass(dex_klass.GetSuperclassDescriptor()); - CHECK(superclass != nullptr) - << "Superclass " << dex_klass.GetSuperclassDescriptor() + auto add_extends = [&](const std::string_view& extends_desc) { + HierarchyClass* extends = FindClass(extends_desc); + CHECK(extends != nullptr) + << "Superclass/interface " << extends_desc << " of class " << dex_klass.GetDescriptor() << " from dex file \"" << dex_klass.GetDexFile().GetLocation() << "\" was not found. " - << "Either the superclass is missing or it appears later in the classpath spec."; - klass.AddExtends(*superclass); + << "Either it is missing or it appears later in the classpath spec."; + klass.AddExtends(*extends); + }; + add_extends(dex_klass.GetSuperclassDescriptor()); for (const std::string_view& iface_desc : dex_klass.GetInterfaceDescriptors()) { - HierarchyClass* iface = FindClass(iface_desc); - CHECK(iface != nullptr); - klass.AddExtends(*iface); + add_extends(iface_desc); } } } |