diff options
author | 2023-08-09 14:58:30 +0100 | |
---|---|---|
committer | 2023-10-10 19:01:06 +0000 | |
commit | 07b3996128bcc5f6cdc6421f72d89c12cbdabd7a (patch) | |
tree | e028bb55cb112175ef381c5fce6ba9c64a68073c | |
parent | 803a8861442c2ce859606d8bc03247e591d0e8c0 (diff) |
Support a dex file without an extension.
For such a dex file, just append ".odex" to the filename.
Bug: 295161587
Test: atest art_standalone_runtime_tests
Test: atest CtsCompilationTestCases
Change-Id: Ibf07811d18105197818aa36ccae7588f9713c142
Merged-In: Ibf07811d18105197818aa36ccae7588f9713c142
-rw-r--r-- | runtime/oat_file_assistant.cc | 6 | ||||
-rw-r--r-- | runtime/oat_file_assistant_test.cc | 14 |
2 files changed, 10 insertions, 10 deletions
diff --git a/runtime/oat_file_assistant.cc b/runtime/oat_file_assistant.cc index ed36df4091..1087ae7888 100644 --- a/runtime/oat_file_assistant.cc +++ b/runtime/oat_file_assistant.cc @@ -651,11 +651,7 @@ bool OatFileAssistant::DexLocationToOdexFilename(const std::string& location, // Get the base part of the file without the extension. std::string file = location.substr(pos + 1); pos = file.rfind('.'); - if (pos == std::string::npos) { - *error_msg = "Dex location " + location + " has no extension."; - return false; - } - std::string base = file.substr(0, pos); + std::string base = pos != std::string::npos ? file.substr(0, pos) : file; *odex_filename = dir + "/" + base + ".odex"; return true; diff --git a/runtime/oat_file_assistant_test.cc b/runtime/oat_file_assistant_test.cc index c1f2d3e674..03306a9fe4 100644 --- a/runtime/oat_file_assistant_test.cc +++ b/runtime/oat_file_assistant_test.cc @@ -1643,17 +1643,21 @@ TEST(OatFileAssistantUtilsTest, DexLocationToOdexFilename) { std::string odex_file; EXPECT_TRUE(OatFileAssistant::DexLocationToOdexFilename( - "/foo/bar/baz.jar", InstructionSet::kArm, &odex_file, &error_msg)) << error_msg; + "/foo/bar/baz.jar", InstructionSet::kArm, &odex_file, &error_msg)) + << error_msg; EXPECT_EQ("/foo/bar/oat/arm/baz.odex", odex_file); EXPECT_TRUE(OatFileAssistant::DexLocationToOdexFilename( - "/foo/bar/baz.funnyext", InstructionSet::kArm, &odex_file, &error_msg)) << error_msg; + "/foo/bar/baz.funnyext", InstructionSet::kArm, &odex_file, &error_msg)) + << error_msg; EXPECT_EQ("/foo/bar/oat/arm/baz.odex", odex_file); EXPECT_FALSE(OatFileAssistant::DexLocationToOdexFilename( - "nopath.jar", InstructionSet::kArm, &odex_file, &error_msg)); - EXPECT_FALSE(OatFileAssistant::DexLocationToOdexFilename( - "/foo/bar/baz_noext", InstructionSet::kArm, &odex_file, &error_msg)); + "nopath.jar", InstructionSet::kArm, &odex_file, &error_msg)); + + EXPECT_TRUE(OatFileAssistant::DexLocationToOdexFilename( + "/foo/bar/baz_noext", InstructionSet::kArm, &odex_file, &error_msg)); + EXPECT_EQ("/foo/bar/oat/arm/baz_noext.odex", odex_file); } // Verify the dexopt status values from dalvik.system.DexFile |