summaryrefslogtreecommitdiff
path: root/runtime/native/dalvik_system_DexFile.cc
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2022-11-29 10:30:42 +0000
committer Vladimir Marko <vmarko@google.com> 2022-11-30 15:38:00 +0000
commit97de32773e20297125d4e35e5d7dcb3b6732e063 (patch)
tree0d1f79ef1a8b7f82f0b3d70311d0b2ed85707244 /runtime/native/dalvik_system_DexFile.cc
parent0110e952e488bc41429f6f33f36e8884f41a26d8 (diff)
Change well known method `String.charAt()` to `ArtMethod*`.
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: Idb34c5de408b98db746d385ae6e012a8997fcc96
Diffstat (limited to 'runtime/native/dalvik_system_DexFile.cc')
-rw-r--r--runtime/native/dalvik_system_DexFile.cc77
1 files changed, 20 insertions, 57 deletions
diff --git a/runtime/native/dalvik_system_DexFile.cc b/runtime/native/dalvik_system_DexFile.cc
index a9f380dfd5..21e7f777cb 100644
--- a/runtime/native/dalvik_system_DexFile.cc
+++ b/runtime/native/dalvik_system_DexFile.cc
@@ -28,6 +28,7 @@
#include "base/logging.h"
#include "base/os.h"
#include "base/stl_util.h"
+#include "base/transform_iterator.h"
#include "base/utils.h"
#include "base/zip_archive.h"
#include "class_linker.h"
@@ -53,7 +54,7 @@
#include "oat_file_manager.h"
#include "runtime.h"
#include "scoped_thread_state_change-inl.h"
-#include "well_known_classes.h"
+#include "string_array_utils.h"
namespace art {
@@ -508,23 +509,12 @@ static jobjectArray DexFile_getClassNameList(JNIEnv* env, jclass, jobject cookie
}
// Now create output array and copy the set into it.
- jobjectArray result = env->NewObjectArray(descriptors.size(),
- WellKnownClasses::java_lang_String,
- nullptr);
- if (result != nullptr) {
- auto it = descriptors.begin();
- auto it_end = descriptors.end();
- jsize i = 0;
- for (; it != it_end; it++, ++i) {
- std::string descriptor(DescriptorToDot(*it));
- ScopedLocalRef<jstring> jdescriptor(env, env->NewStringUTF(descriptor.c_str()));
- if (jdescriptor.get() == nullptr) {
- return nullptr;
- }
- env->SetObjectArrayElement(result, i, jdescriptor.get());
- }
- }
- return result;
+ ScopedObjectAccess soa(down_cast<JNIEnvExt*>(env)->GetSelf());
+ auto descriptor_to_dot = [](const char* descriptor) { return DescriptorToDot(descriptor); };
+ return soa.AddLocalReference<jobjectArray>(CreateStringArray(
+ soa.Self(),
+ descriptors.size(),
+ MakeTransformRange(descriptors, descriptor_to_dot)));
}
static jint GetDexOptNeeded(JNIEnv* env,
@@ -655,23 +645,11 @@ static jobjectArray DexFile_getDexFileOptimizationStatus(JNIEnv* env,
OatFileAssistant::GetOptimizationStatus(
filename.c_str(), target_instruction_set, &compilation_filter, &compilation_reason);
- ScopedLocalRef<jstring> j_compilation_filter(env, env->NewStringUTF(compilation_filter.c_str()));
- if (j_compilation_filter.get() == nullptr) {
- return nullptr;
- }
- ScopedLocalRef<jstring> j_compilation_reason(env, env->NewStringUTF(compilation_reason.c_str()));
- if (j_compilation_reason.get() == nullptr) {
- return nullptr;
- }
-
- // Now create output array and copy the set into it.
- jobjectArray result = env->NewObjectArray(2,
- WellKnownClasses::java_lang_String,
- nullptr);
- env->SetObjectArrayElement(result, 0, j_compilation_filter.get());
- env->SetObjectArrayElement(result, 1, j_compilation_reason.get());
-
- return result;
+ ScopedObjectAccess soa(down_cast<JNIEnvExt*>(env)->GetSelf());
+ return soa.AddLocalReference<jobjectArray>(CreateStringArray(soa.Self(), {
+ compilation_filter.c_str(),
+ compilation_reason.c_str()
+ }));
}
static jint DexFile_getDexOptNeeded(JNIEnv* env,
@@ -914,31 +892,16 @@ static jobjectArray DexFile_getDexFileOutputPaths(JNIEnv* env,
oat_filename = best_oat_file->GetLocation();
is_vdex_only = best_oat_file->IsBackedByVdexOnly();
}
- ScopedLocalRef<jstring> joatFilename(env, env->NewStringUTF(oat_filename.c_str()));
- if (joatFilename.get() == nullptr) {
- return nullptr;
- }
- if (is_vdex_only) {
- jobjectArray result = env->NewObjectArray(1,
- WellKnownClasses::java_lang_String,
- nullptr);
- env->SetObjectArrayElement(result, 0, joatFilename.get());
- return result;
- } else {
+ const char* filenames[] = { oat_filename.c_str(), nullptr };
+ ArrayRef<const char* const> used_filenames(filenames, 1u);
+ if (!is_vdex_only) {
vdex_filename = GetVdexFilename(oat_filename);
- ScopedLocalRef<jstring> jvdexFilename(env, env->NewStringUTF(vdex_filename.c_str()));
- if (jvdexFilename.get() == nullptr) {
- return nullptr;
- }
-
- jobjectArray result = env->NewObjectArray(2,
- WellKnownClasses::java_lang_String,
- nullptr);
- env->SetObjectArrayElement(result, 0, jvdexFilename.get());
- env->SetObjectArrayElement(result, 1, joatFilename.get());
- return result;
+ filenames[1] = vdex_filename.c_str();
+ used_filenames = ArrayRef<const char* const>(filenames, 2u);
}
+ ScopedObjectAccess soa(down_cast<JNIEnvExt*>(env)->GetSelf());
+ return soa.AddLocalReference<jobjectArray>(CreateStringArray(soa.Self(), used_filenames));
}
static jlong DexFile_getStaticSizeOfDexFile(JNIEnv* env, jclass, jobject cookie) {