Flutter Engine
jni_util.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter 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.
4 
5 #ifndef FLUTTER_FML_PLATFORM_ANDROID_JNI_UTIL_H_
6 #define FLUTTER_FML_PLATFORM_ANDROID_JNI_UTIL_H_
7 
8 #include <jni.h>
9 
10 #include <vector>
11 
12 #include "flutter/fml/macros.h"
13 #include "flutter/fml/platform/android/scoped_java_ref.h"
14 
15 namespace fml {
16 namespace jni {
17 
18 void InitJavaVM(JavaVM* vm);
19 
20 JNIEnv* AttachCurrentThread();
21 
22 void DetachFromVM();
23 
24 std::string JavaStringToString(JNIEnv* env, jstring string);
25 
26 ScopedJavaLocalRef<jstring> StringToJavaString(JNIEnv* env,
27  const std::string& str);
28 
29 std::vector<std::string> StringArrayToVector(JNIEnv* env, jobjectArray jargs);
30 
31 ScopedJavaLocalRef<jobjectArray> VectorToStringArray(
32  JNIEnv* env,
33  const std::vector<std::string>& vector);
34 
35 bool HasException(JNIEnv* env);
36 
37 bool ClearException(JNIEnv* env);
38 
39 std::string GetJavaExceptionInfo(JNIEnv* env, jthrowable java_throwable);
40 
41 } // namespace jni
42 } // namespace fml
43 
44 #endif // FLUTTER_FML_PLATFORM_ANDROID_JNI_UTIL_H_
bool HasException(JNIEnv *env)
Definition: jni_util.cc:127
bool ClearException(JNIEnv *env)
Definition: jni_util.cc:131
ScopedJavaLocalRef< jobjectArray > VectorToStringArray(JNIEnv *env, const std::vector< std::string > &vector)
Definition: jni_util.cc:110
ScopedJavaLocalRef< jstring > StringToJavaString(JNIEnv *env, const std::string &u8_string)
Definition: jni_util.cc:78
void InitJavaVM(JavaVM *vm)
Definition: jni_util.cc:21
Definition: ascii_trie.cc:9
std::string GetJavaExceptionInfo(JNIEnv *env, jthrowable java_throwable)
Definition: jni_util.cc:139
JNIEnv * AttachCurrentThread()
Definition: jni_util.cc:26
void DetachFromVM()
Definition: jni_util.cc:46
std::string JavaStringToString(JNIEnv *env, jstring str)
Definition: jni_util.cc:58
std::vector< std::string > StringArrayToVector(JNIEnv *env, jobjectArray array)
Definition: jni_util.cc:88