1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "jni.h"
18 
19 #include "class_linker-inl.h"
20 #include "dex/dex_file-inl.h"
21 #include "mirror/class-inl.h"
22 #include "mirror/dex_cache-inl.h"
23 #include "runtime.h"
24 #include "scoped_thread_state_change-inl.h"
25 
26 namespace art {
27 namespace {
28 
Java_Main_isAotVerified(JNIEnv * env,jclass,jclass cls)29 extern "C" JNIEXPORT jboolean JNICALL Java_Main_isAotVerified(JNIEnv* env, jclass, jclass cls) {
30   ScopedObjectAccess soa(env);
31   Runtime* rt = Runtime::Current();
32 
33   ObjPtr<mirror::Class> klass = soa.Decode<mirror::Class>(cls);
34   const DexFile& dex_file = *klass->GetDexCache()->GetDexFile();
35   ClassStatus oat_file_class_status(ClassStatus::kNotReady);
36   bool ret = rt->GetClassLinker()->VerifyClassUsingOatFile(dex_file, klass, oat_file_class_status);
37   return ret;
38 }
39 
40 }  // namespace
41 }  // namespace art
42