1 // Copyright 2020 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // The JNI_OnLoad() definition for the linker library is moved here to avoid a 6 // conflict with JNI_Onload() defined by the test library. The linker tests 7 // together with the linker internals are smashed into (=linked with) the test 8 // library. 9 10 #include <jni.h> 11 12 // Must come after all headers that specialize FromJniType() / ToJniType(). 13 #include "base/android/linker/linker_jni.h" 14 15 namespace chromium_android_linker { 16 17 // JNI_OnLoad() is called when the linker library is loaded through the regular 18 // System.LoadLibrary) API. This shall save the Java VM handle and initialize 19 // LibInfo field accessors. JNI_OnLoad(JavaVM * vm,void * reserved)20jint JNI_OnLoad(JavaVM* vm, void* reserved) { 21 LOG_INFO("Entering"); 22 JNIEnv* env; 23 if (JNI_OK != vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_4)) { 24 LOG_ERROR("Could not create JNIEnv"); 25 return -1; 26 } 27 if (!LinkerJNIInit(vm, env)) 28 return -1; 29 LOG_INFO("Done"); 30 return JNI_VERSION_1_4; 31 } 32 33 } // namespace chromium_android_linker 34 JNI_OnLoad(JavaVM * vm,void * reserved)35jint JNI_OnLoad(JavaVM* vm, void* reserved) { 36 return chromium_android_linker::JNI_OnLoad(vm, reserved); 37 } 38