1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // A simple library that provides JNI_OnLoad() and JNI_OnUnload() hooks.
6 // Used by test_java_vm.cpp
12 #define VARNAME "TEST_VAR"
14 extern "C" int JNI_OnLoad(JavaVM
* vm
, void* reserved
) {
15 printf("%s: Entering\n", __FUNCTION__
);
16 const char* env
= getenv(VARNAME
);
17 if (!env
|| strcmp(env
, "INIT")) {
19 "%s: Env variable %s has invalid value: %s (expected INIT)\n",
25 setenv(VARNAME
, "LOADED", 1);
26 printf("%s: Exiting\n", __FUNCTION__
);
27 return JNI_VERSION_1_4
;
30 extern "C" void JNI_OnUnload(JavaVM
* vm
, void* reserved
) {
31 printf("%s: Entering\n", __FUNCTION__
);
32 const char* env
= getenv(VARNAME
);
33 if (!env
|| strcmp(env
, "LOADED")) {
35 "%s: Env variable %s has invalid value: %s (expected LOADED)\n",
41 setenv(VARNAME
, "UNLOADED", 1);
42 printf("%s: Exiting\n", __FUNCTION__
);