diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-07 05:23:45 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-07 05:23:45 +0000 |
commit | 9b7b7ae28ec32d5c6f47500896552c3d1f1028d0 (patch) | |
tree | 74e45a722ffd775127a136c27e0c2b8659adc7e9 /Interface.cpp | |
parent | 5c7e328078a3bb592fb73cd5a009bcf759c57c52 (diff) | |
parent | 5ba9115da292a2527e8aeac19cef35d468173f85 (diff) | |
download | hidl-9b7b7ae28ec32d5c6f47500896552c3d1f1028d0.tar.gz |
Snap for 10453563 from 5ba9115da292a2527e8aeac19cef35d468173f85 to mainline-uwb-releaseaml_uwb_341710010aml_uwb_341513070aml_uwb_341511050aml_uwb_341310300aml_uwb_341310030aml_uwb_341111010aml_uwb_341011000android14-mainline-uwb-release
Change-Id: I15efd9312f508313badef8743e620f6cd1614ca2
Diffstat (limited to 'Interface.cpp')
-rw-r--r-- | Interface.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Interface.cpp b/Interface.cpp index 9be88e9f..e9950d22 100644 --- a/Interface.cpp +++ b/Interface.cpp @@ -307,9 +307,15 @@ bool Interface::fillHashChainMethod(Method *method) const { } } }, /* cppImpl */ { { IMPL_INTERFACE, [this, digestType, chainType](auto &out) { std::vector<const Interface *> chain = typeChain(); - out << "return new " - << chainType->getJavaType(false /* forInitializer */) - << "(java.util.Arrays.asList(\n"; + out << "return new " << chainType->getJavaType(false /* forInitializer */); + if (chain.size() == 1) { + // https://errorprone.info/bugpattern/ArraysAsListPrimitiveArray + // To avoid an ArraysAsListPrimitiveArray errorprone error, use + // singletonList when there's only 1 element in the chain. + out << "(java.util.Collections.singletonList(\n"; + } else { + out << "(java.util.Arrays.asList(\n"; + } out.indent(2, [&] { // No need for dimensions when elements are explicitly provided. emitDigestChain(out, "new " + digestType->getJavaType(false /* forInitializer */), |