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 #include "base/android/linker/linker_jni.h" 13 14 namespace chromium_android_linker { 15 16 // JNI_OnLoad() is called when the linker library is loaded through the regular 17 // System.LoadLibrary) API. This shall save the Java VM handle and initialize 18 // LibInfo field accessors. JNI_OnLoad(JavaVM * vm,void * reserved)19jint JNI_OnLoad(JavaVM* vm, void* reserved) { 20 LOG_INFO("Entering"); 21 JNIEnv* env; 22 if (JNI_OK != vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_4)) { 23 LOG_ERROR("Could not create JNIEnv"); 24 return -1; 25 } 26 if (!LinkerJNIInit(vm, env)) 27 return -1; 28 LOG_INFO("Done"); 29 return JNI_VERSION_1_4; 30 } 31 32 } // namespace chromium_android_linker 33 JNI_OnLoad(JavaVM * vm,void * reserved)34jint JNI_OnLoad(JavaVM* vm, void* reserved) { 35 return chromium_android_linker::JNI_OnLoad(vm, reserved); 36 } 37