From 4effc4b64a1070279acc2e97c5c6f85b88dbd476 Mon Sep 17 00:00:00 2001 From: Tobias Thierer Date: Thu, 9 Jan 2020 23:52:21 +0000 Subject: [PATCH] Make extract_package() work for toplevel classes. Before this CL, classes in the unnamed package, such as L$r8$backportedMethods$utility$Objects$2$checkIndex (which looks like it is generated by R8 for Objects.checkIndex() calls) were breaking the build because extract_package was incorrectly assuming that there would always be a '/' in the identifier string. Test: Build that previously broke is now working. Change-Id: Ice78d6b31c4f38a3c9d529bc6156d625d19bcacf --- tools/hiddenapi/generate_hiddenapi_lists.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/hiddenapi/generate_hiddenapi_lists.py b/tools/hiddenapi/generate_hiddenapi_lists.py index 46105f4d66b07..0b2077d9bba03 100755 --- a/tools/hiddenapi/generate_hiddenapi_lists.py +++ b/tools/hiddenapi/generate_hiddenapi_lists.py @@ -149,7 +149,12 @@ def extract_package(signature): The package name of the class containing the field/method. """ full_class_name = signature.split(";->")[0] - package_name = full_class_name[1:full_class_name.rindex("/")] + # Example: Landroid/hardware/radio/V1_2/IRadio$Proxy + if (full_class_name[0] != "L"): + raise ValueError("Expected to start with 'L': %s" % full_class_name) + full_class_name = full_class_name[1:] + # If full_class_name doesn't contain '/', then package_name will be ''. + package_name = full_class_name.rpartition("/")[0] return package_name.replace('/', '.') class FlagsDict: