diff options
| -rw-r--r-- | runtime/oat_file.cc | 8 | ||||
| -rw-r--r-- | test/692-vdex-inmem-loader/src/Main.java | 8 | ||||
| -rw-r--r-- | test/common/runtime_state.cc | 18 |
3 files changed, 32 insertions, 2 deletions
diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc index 05015e371b..54dae10830 100644 --- a/runtime/oat_file.cc +++ b/runtime/oat_file.cc @@ -1425,13 +1425,17 @@ class OatFileBackedByVdex final : public OatFileBase { // SetVdex will take ownership of the VdexFile. SetVdex(vdex_file.release()); - // Create a dummy OatHeader. + // Create a dummy OatHeader with a key store containing only the compiler + // filter (it helps debugging and is required by + // OatHeader::GetCompilerFilter). std::unique_ptr<const InstructionSetFeatures> isa_features = InstructionSetFeatures::FromCppDefines(); + SafeMap<std::string, std::string> store; + store.Put(OatHeader::kCompilerFilter, CompilerFilter::NameOfFilter(CompilerFilter::kVerify)); oat_header_.reset(OatHeader::Create(kRuntimeISA, isa_features.get(), dex_files.size(), - nullptr)); + &store)); const uint8_t* begin = reinterpret_cast<const uint8_t*>(oat_header_.get()); SetBegin(begin); SetEnd(begin + oat_header_->GetHeaderSize()); diff --git a/test/692-vdex-inmem-loader/src/Main.java b/test/692-vdex-inmem-loader/src/Main.java index 53f4c3608b..3ebe2c1cda 100644 --- a/test/692-vdex-inmem-loader/src/Main.java +++ b/test/692-vdex-inmem-loader/src/Main.java @@ -57,6 +57,13 @@ public class Main { if (invokeMethod) { loader.loadClass("art.ClassB").getDeclaredMethod("printHello").invoke(null); + + if (expectedBackedByOat) { + String filter = getCompilerFilter(loader.loadClass("art.ClassB")); + if (!("verify".equals(filter))) { + throw new Error("Expected verify, got " + filter); + } + } } } @@ -118,6 +125,7 @@ public class Main { private static native boolean hasVdexFile(ClassLoader loader); private static native boolean isBackedByOatFile(ClassLoader loader); private static native boolean areClassesPreverified(ClassLoader loader); + private static native String getCompilerFilter(Class cls); // Defined in 674-hiddenapi. private static native void appendToBootClassLoader(String dexPath, boolean isCorePlatform); diff --git a/test/common/runtime_state.cc b/test/common/runtime_state.cc index a0b2f1ea72..ba2d46e155 100644 --- a/test/common/runtime_state.cc +++ b/test/common/runtime_state.cc @@ -66,6 +66,24 @@ extern "C" JNIEXPORT jboolean JNICALL Java_Main_hasOatFile(JNIEnv* env, jclass c return (oat_dex_file != nullptr) ? JNI_TRUE : JNI_FALSE; } +extern "C" JNIEXPORT jobject JNICALL Java_Main_getCompilerFilter(JNIEnv* env, + jclass caller ATTRIBUTE_UNUSED, + jclass cls) { + ScopedObjectAccess soa(env); + + ObjPtr<mirror::Class> klass = soa.Decode<mirror::Class>(cls); + const DexFile& dex_file = klass->GetDexFile(); + const OatDexFile* oat_dex_file = dex_file.GetOatDexFile(); + if (oat_dex_file == nullptr) { + return nullptr; + } + + std::string filter = + CompilerFilter::NameOfFilter(oat_dex_file->GetOatFile()->GetCompilerFilter()); + return soa.AddLocalReference<jobject>( + mirror::String::AllocFromModifiedUtf8(soa.Self(), filter.c_str())); +} + // public static native boolean runtimeIsSoftFail(); extern "C" JNIEXPORT jboolean JNICALL Java_Main_runtimeIsSoftFail(JNIEnv* env ATTRIBUTE_UNUSED, |