14fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray/* 24fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray * Copyright (C) 2014 The Android Open Source Project 34fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray * 44fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray * Licensed under the Apache License, Version 2.0 (the "License"); 54fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray * you may not use this file except in compliance with the License. 64fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray * You may obtain a copy of the License at 74fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray * 84fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray * http://www.apache.org/licenses/LICENSE-2.0 94fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray * 104fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray * Unless required by applicable law or agreed to in writing, software 114fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray * distributed under the License is distributed on an "AS IS" BASIS, 124fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 134fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray * See the License for the specific language governing permissions and 144fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray * limitations under the License. 154fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray */ 164fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray 174fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray#include "class_linker.h" 184fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray#include "dex_file-inl.h" 194fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray#include "mirror/class-inl.h" 204fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray#include "scoped_thread_state_change.h" 214fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray#include "thread.h" 224fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray 234fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffraynamespace art { 244fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray 254fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffrayclass NoDex2OatTest { 264fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray public: 274fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray static bool hasOat(jclass cls) { 284fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray ScopedObjectAccess soa(Thread::Current()); 294fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray mirror::Class* klass = soa.Decode<mirror::Class*>(cls); 304fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray const DexFile& dex_file = klass->GetDexFile(); 3107b3c2351bb527ea91c084dc19434600af9ae66bRichard Uhler const OatFile::OatDexFile* oat_dex_file = dex_file.GetOatDexFile(); 32aa4497db59f1eeec954f2ba5da6d458fcdf9b3a4Vladimir Marko return oat_dex_file != nullptr; 334fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray } 344fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray}; 354fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray 364fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffrayextern "C" JNIEXPORT jboolean JNICALL Java_Main_hasOat(JNIEnv*, jclass cls) { 374fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray return NoDex2OatTest::hasOat(cls); 384fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray} 394fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray 406a3c1fcb4ba42ad4d5d142c17a3712a6ddd3866fIan Rogersextern "C" JNIEXPORT jboolean JNICALL Java_Main_isDex2OatEnabled(JNIEnv*, jclass) { 414fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray return Runtime::Current()->IsDex2OatEnabled(); 424fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray} 434fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray 444fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray} // namespace art 45