Add Scoped Local and Global Ref
Summary: Add ScopedLocalRef, ScopedGlobalRef and some common methods to be used later. Reviewed By: amir-shalem Differential Revision: D17711284 fbshipit-source-id: be43d5e246bc2406765057783be11854877c41f1
This commit is contained in:
committed by
Facebook Github Bot
parent
7c2683fe52
commit
b9b0217a07
51
java/jni/corefunctions.h
Normal file
51
java/jni/corefunctions.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <jni.h>
|
||||
#include <cstddef>
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
namespace vanillajni {
|
||||
|
||||
/**
|
||||
* This method has to be called before using the vanillajni library. This method
|
||||
* is typically called when doing initialization in the "on load" JNI hook of a
|
||||
* particular library.
|
||||
*
|
||||
* This method is thread safe, and after the first time it's called it has no
|
||||
* initialization effect.
|
||||
*
|
||||
* @param env use this output parameter to get a JNIEnv to use for things such
|
||||
* as registering native methods and such.
|
||||
* @param vm the VM instance passed by JNI. This is usually the VM instance
|
||||
* that is passed to the "on load" JNI hook.
|
||||
* @return an integer value to return from the "on load" hook.
|
||||
*/
|
||||
jint ensureInitialized(JNIEnv** env, JavaVM* vm);
|
||||
|
||||
/**
|
||||
* Returns a JNIEnv* suitable for the current thread. If the current thread is
|
||||
* not attached to the Java VM, this method aborts execution.
|
||||
*/
|
||||
JNIEnv* getCurrentEnv();
|
||||
|
||||
/**
|
||||
* Logs an error message and aborts the current process.
|
||||
*/
|
||||
void logErrorMessageAndDie(const char* message);
|
||||
|
||||
/**
|
||||
* Checks whether there is a pending JNI exception. If so, it logs an error
|
||||
* message and aborts the current process. Otherwise it does nothing.
|
||||
*/
|
||||
void assertNoPendingJniException(JNIEnv* env);
|
||||
|
||||
} // namespace vanillajni
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
Reference in New Issue
Block a user