Home
last modified time | relevance | path

Searched refs:env (Results 1 – 25 of 29) sorted by relevance

12

/libnativehelper/
DJNIHelp.c53 static jmethodID FindMethod(JNIEnv* env, in FindMethod() argument
59 jclass clazz = (*env)->FindClass(env, className); in FindMethod()
60 jmethodID methodId = (*env)->GetMethodID(env, clazz, methodName, descriptor); in FindMethod()
61 (*env)->DeleteLocalRef(env, clazz); in FindMethod()
65 static bool AppendJString(JNIEnv* env, jstring text, struct ExpandableString* dst) { in AppendJString() argument
66 const char* utfText = (*env)->GetStringUTFChars(env, text, NULL); in AppendJString()
71 (*env)->ReleaseStringUTFChars(env, text, utfText); in AppendJString()
80 static bool GetExceptionSummary(JNIEnv* env, jthrowable thrown, struct ExpandableString* dst) { in GetExceptionSummary() argument
82 jclass exceptionClass = (*env)->GetObjectClass(env, thrown); // Always succeeds in GetExceptionSummary()
83 jmethodID getName = FindMethod(env, "java/lang/Class", "getName", "()Ljava/lang/String;"); in GetExceptionSummary()
[all …]
DJNIPlatformHelp.c23 static int GetBufferPosition(JNIEnv* env, jobject nioBuffer) { in GetBufferPosition() argument
24 return(*env)->GetIntField(env, nioBuffer, JniConstants_NioBuffer_position(env)); in GetBufferPosition()
27 static int GetBufferLimit(JNIEnv* env, jobject nioBuffer) { in GetBufferLimit() argument
28 return(*env)->GetIntField(env, nioBuffer, JniConstants_NioBuffer_limit(env)); in GetBufferLimit()
31 static int GetBufferElementSizeShift(JNIEnv* env, jobject nioBuffer) { in GetBufferElementSizeShift() argument
32 return(*env)->GetIntField(env, nioBuffer, JniConstants_NioBuffer__elementSizeShift(env)); in GetBufferElementSizeShift()
35 jarray jniGetNioBufferBaseArray(JNIEnv* env, jobject nioBuffer) { in jniGetNioBufferBaseArray() argument
36 jclass nioAccessClass = JniConstants_NIOAccessClass(env); in jniGetNioBufferBaseArray()
37 jmethodID getBaseArrayMethod = JniConstants_NIOAccess_getBaseArray(env); in jniGetNioBufferBaseArray()
38 jobject object = (*env)->CallStaticObjectMethod(env, in jniGetNioBufferBaseArray()
[all …]
Dfile_descriptor_jni.c26 static void EnsureArgumentIsFileDescriptor(JNIEnv* env, jobject instance) { in EnsureArgumentIsFileDescriptor() argument
28 jclass jifd = JniConstants_FileDescriptorClass(env); in EnsureArgumentIsFileDescriptor()
29 ALOG_ALWAYS_FATAL_IF(!(*env)->IsInstanceOf(env, instance, jifd), in EnsureArgumentIsFileDescriptor()
33 JNIEXPORT _Nullable jobject AFileDescriptor_create(JNIEnv* env) { in AFileDescriptor_create() argument
34 return (*env)->NewObject(env, in AFileDescriptor_create()
35 JniConstants_FileDescriptorClass(env), in AFileDescriptor_create()
36 JniConstants_FileDescriptor_init(env)); in AFileDescriptor_create()
39 JNIEXPORT int AFileDescriptor_getFd(JNIEnv* env, jobject fileDescriptor) { in AFileDescriptor_getFd() argument
40 EnsureArgumentIsFileDescriptor(env, fileDescriptor); in AFileDescriptor_getFd()
41 return (*env)->GetIntField(env, fileDescriptor, JniConstants_FileDescriptor_descriptor(env)); in AFileDescriptor_getFd()
[all …]
DJniConstants.h31 jclass JniConstants_FileDescriptorClass(JNIEnv* env);
32 jclass JniConstants_NIOAccessClass(JNIEnv* env);
33 jclass JniConstants_NioBufferClass(JNIEnv* env);
41 jmethodID JniConstants_FileDescriptor_init(JNIEnv* env);
42 jmethodID JniConstants_FileDescriptor_setInt$(JNIEnv* env);
43 jmethodID JniConstants_NIOAccess_getBaseArray(JNIEnv* env);
44 jmethodID JniConstants_NIOAccess_getBaseArrayOffset(JNIEnv* env);
45 jmethodID JniConstants_NioBuffer_array(JNIEnv* env);
46 jmethodID JniConstants_NioBuffer_arrayOffset(JNIEnv* env);
54 jfieldID JniConstants_FileDescriptor_descriptor(JNIEnv* env);
[all …]
DJniConstants.c81 static jclass FindClass(JNIEnv* env, const char* signature, bool androidOnly) {
82 jclass cls = (*env)->FindClass(env, signature);
87 return (*env)->NewGlobalRef(env, cls);
90 static jmethodID FindMethod(JNIEnv* env, jclass cls, in FindMethod() argument
94 method = (*env)->GetStaticMethodID(env, cls, name, signature); in FindMethod()
96 method = (*env)->GetMethodID(env, cls, name, signature); in FindMethod()
102 static jfieldID FindField(JNIEnv* env, jclass cls, in FindField() argument
106 field = (*env)->GetStaticFieldID(env, cls, name, signature); in FindField()
108 field = (*env)->GetFieldID(env, cls, name, signature); in FindField()
139 void EnsureInitialized(JNIEnv* env) { in EnsureInitialized() argument
[all …]
Dlibnativehelper_lazy.c164 jobject AFileDescriptor_create(JNIEnv* env) { in AFileDescriptor_create() argument
166 INVOKE_METHOD(AFileDescriptor_create, M, env); in AFileDescriptor_create()
169 int AFileDescriptor_getFd(JNIEnv* env, jobject fileDescriptor) { in AFileDescriptor_getFd() argument
171 INVOKE_METHOD(AFileDescriptor_getFd, M, env, fileDescriptor); in AFileDescriptor_getFd()
174 void AFileDescriptor_setFd(JNIEnv* env, jobject fileDescriptor, int fd) { in AFileDescriptor_setFd() argument
176 INVOKE_VOID_METHOD(AFileDescriptor_setFd, M, env, fileDescriptor, fd); in AFileDescriptor_setFd()
226 jarray jniGetNioBufferBaseArray(JNIEnv* env, jobject nioBuffer) { in jniGetNioBufferBaseArray() argument
228 INVOKE_METHOD(jniGetNioBufferBaseArray, M, env, nioBuffer); in jniGetNioBufferBaseArray()
231 int jniGetNioBufferBaseArrayOffset(JNIEnv* env, jobject nioBuffer) { in jniGetNioBufferBaseArrayOffset() argument
233 INVOKE_METHOD(jniGetNioBufferBaseArrayOffset, M, env, nioBuffer); in jniGetNioBufferBaseArrayOffset()
[all …]
/libnativehelper/include/nativehelper/
DJNIHelp.h107 [[maybe_unused]] static jmethodID FindMethod(JNIEnv* env, const char* className, in FindMethod() argument
111 jclass clazz = env->FindClass(className); in FindMethod()
112 jmethodID methodId = env->GetMethodID(clazz, methodName, descriptor); in FindMethod()
113 env->DeleteLocalRef(clazz); in FindMethod()
117 [[maybe_unused]] static bool AppendJString(JNIEnv* env, jstring text, in AppendJString() argument
119 const char* utfText = env->GetStringUTFChars(text, NULL); in AppendJString()
124 env->ReleaseStringUTFChars(text, utfText); in AppendJString()
133 [[maybe_unused]] static bool GetExceptionSummary(JNIEnv* env, jthrowable thrown, in GetExceptionSummary() argument
136 jclass exceptionClass = env->GetObjectClass(thrown); // Always succeeds in GetExceptionSummary()
137 jmethodID getName = FindMethod(env, "java/lang/Class", "getName", "()Ljava/lang/String;"); in GetExceptionSummary()
[all …]
DtoStringArray.h28 jobjectArray toStringArray(JNIEnv* env, size_t count, StringVisitor&& visitor) { in toStringArray() argument
29 jclass stringClass = env->FindClass("java/lang/String"); in toStringArray()
30 ScopedLocalRef<jobjectArray> result(env, env->NewObjectArray(count, stringClass, NULL)); in toStringArray()
31 env->DeleteLocalRef(stringClass); in toStringArray()
36 ScopedLocalRef<jstring> s(env, env->NewStringUTF(visitor(i))); in toStringArray()
37 if (env->ExceptionCheck()) { in toStringArray()
40 env->SetObjectArrayElement(result.get(), i, s.get()); in toStringArray()
41 if (env->ExceptionCheck()) { in toStringArray()
48 inline jobjectArray toStringArray(JNIEnv* env, const std::vector<std::string>& strings) { in toStringArray() argument
49 return toStringArray(env, strings.size(), [&strings](size_t i) { return strings[i].c_str(); }); in toStringArray()
[all …]
/libnativehelper/tests_mts/jni/
Djni_helper_jni.cpp33 static void throwException(JNIEnv* env, jclass /*clazz*/, jstring className, jstring message) { in throwException() argument
34 ScopedUtfChars c(env, className); in throwException()
35 ScopedUtfChars m(env, message); in throwException()
36 jniThrowException(env, c.c_str(), m.c_str()); in throwException()
39 static void throwExceptionWithIntFormat(JNIEnv* env, in throwExceptionWithIntFormat() argument
44 ScopedUtfChars c(env, className); in throwExceptionWithIntFormat()
45 ScopedUtfChars f(env, format); in throwExceptionWithIntFormat()
46 jniThrowExceptionFmt(env, c.c_str(), f.c_str(), value); in throwExceptionWithIntFormat()
49 static void throwNullPointerException(JNIEnv* env, in throwNullPointerException() argument
52 ScopedUtfChars m(env, message); in throwNullPointerException()
[all …]
/libnativehelper/include_platform/nativehelper/
DJNIPlatformHelp.h40 jarray jniGetNioBufferBaseArray(C_JNIEnv* env, jobject nioBuffer);
50 jint jniGetNioBufferBaseArrayOffset(C_JNIEnv* env, jobject nioBuffer);
60 jlong jniGetNioBufferFields(C_JNIEnv* env,
74 jlong jniGetNioBufferPointer(C_JNIEnv* env, jobject nioBuffer);
92 inline jobject jniCreateFileDescriptor(JNIEnv* env, int fd) { in jniCreateFileDescriptor() argument
93 jobject fileDescriptor = AFileDescriptor_create(env); in jniCreateFileDescriptor()
95 AFileDescriptor_setFd(env, fileDescriptor, fd); in jniCreateFileDescriptor()
100 inline int jniGetFDFromFileDescriptor(JNIEnv* env, jobject fileDescriptor) { in jniGetFDFromFileDescriptor() argument
104 return AFileDescriptor_getFd(env, fileDescriptor); in jniGetFDFromFileDescriptor()
107 inline void jniSetFileDescriptorOfFD(JNIEnv* env, jobject fileDescriptor, int value) { in jniSetFileDescriptorOfFD() argument
[all …]
/libnativehelper/header_only_include/nativehelper/
Dnativehelper_utils.h34 static inline int jniThrowNullPointerException(JNIEnv* env) { in jniThrowNullPointerException() argument
35 if (env->ExceptionCheck()) { in jniThrowNullPointerException()
37 env->ExceptionClear(); in jniThrowNullPointerException()
40 jclass e_class = env->FindClass("java/lang/NullPointerException"); in jniThrowNullPointerException()
45 if (env->ThrowNew(e_class, nullptr) != JNI_OK) { in jniThrowNullPointerException()
46 env->DeleteLocalRef(e_class); in jniThrowNullPointerException()
50 env->DeleteLocalRef(e_class); in jniThrowNullPointerException()
Dutils.h100 #define GET_UTF_OR_RETURN(env, expr) \ argument
101 GET_UTF_OR_RETURN_IMPL_((env), (expr), android::jnihelp::JniDefaultValue())
102 #define GET_UTF_OR_RETURN_VOID(env, expr) GET_UTF_OR_RETURN_IMPL_((env), (expr)) argument
104 #define GET_UTF_OR_RETURN_IMPL_(env, expr, ...) \ argument
106 ScopedUtfChars __or_return_scoped_utf_chars(env, expr); \
136 #define CREATE_UTF_OR_RETURN(env, expr) \ argument
137 CREATE_UTF_OR_RETURN_IMPL_((env), (expr), android::jnihelp::JniDefaultValue())
138 #define CREATE_UTF_OR_RETURN_VOID(env, expr) CREATE_UTF_OR_RETURN_IMPL_((env), (expr)) argument
140 #define CREATE_UTF_OR_RETURN_IMPL_(env, expr, ...) \ argument
144 env, \
[all …]
Dscoped_string_chars.h36 ScopedStringChars(JNIEnv* env, jstring s) : env_(env), string_(s), size_(0) { in ScopedStringChars() argument
39 jniThrowNullPointerException(env); in ScopedStringChars()
41 chars_ = env->GetStringChars(string_, nullptr); in ScopedStringChars()
43 size_ = env->GetStringLength(string_); in ScopedStringChars()
Dscoped_local_ref.h31 ScopedLocalRef(JNIEnv* env, T localRef) : mEnv(env), mLocalRef(localRef) { in ScopedLocalRef() argument
37 explicit ScopedLocalRef(JNIEnv* env) : mEnv(env), mLocalRef(nullptr) { in ScopedLocalRef() argument
Dscoped_primitive_array.h44 explicit Scoped ## NAME ## ArrayRO(JNIEnv* env) \
45 : mEnv(env), mJavaArray(nullptr), mRawArray(nullptr), mSize(0) {} \
46 Scoped ## NAME ## ArrayRO(JNIEnv* env, PRIMITIVE_TYPE ## Array javaArray) \
47 : mEnv(env) { \
104 explicit Scoped ## NAME ## ArrayRW(JNIEnv* env) \
105 : mEnv(env), mJavaArray(nullptr), mRawArray(nullptr) {} \
106 Scoped ## NAME ## ArrayRW(JNIEnv* env, PRIMITIVE_TYPE ## Array javaArray) \
107 : mEnv(env), mJavaArray(javaArray), mRawArray(nullptr) { \
Dscoped_utf_chars.h44 ScopedUtfChars(JNIEnv* env, jstring s) : env_(env), string_(s) { in ScopedUtfChars() argument
47 jniThrowNullPointerException(env); in ScopedUtfChars()
49 utf_chars_ = env->GetStringUTFChars(s, nullptr); in ScopedUtfChars()
Dscoped_local_frame.h25 explicit ScopedLocalFrame(JNIEnv* env) : mEnv(env) { in ScopedLocalFrame() argument
/libnativehelper/tests/
Dlibnativehelper_test.cpp45 jint ret = [&](JNIEnv* env) -> jint { in TEST_F() argument
46 ScopedUtfChars str = GET_UTF_OR_RETURN(env, j_str.get()); in TEST_F()
60 [&](JNIEnv* env) -> void { in TEST_F() argument
61 ScopedUtfChars str = GET_UTF_OR_RETURN_VOID(env, j_str.get()); in TEST_F()
70 jint ret = [&](JNIEnv* env) -> jint { in TEST_F() argument
71 ScopedUtfChars str = GET_UTF_OR_RETURN(env, nullptr); in TEST_F()
84 [&](JNIEnv* env) -> void { in TEST_F() argument
85 ScopedUtfChars str = GET_UTF_OR_RETURN_VOID(env, nullptr); in TEST_F()
98 jint ret = [&](JNIEnv* env) -> jint { in TEST_F() argument
99 ScopedLocalRef<jstring> j_str = CREATE_UTF_OR_RETURN(env, "foo"); in TEST_F()
[all …]
Dlibnativehelper_lazy_test.cpp39 C_JNIEnv* env = NULL; in TEST_F() local
40 EXPECT_DEATH(jniGetNioBufferBaseArray(env, NULL), kLoadFailed); in TEST_F()
41 EXPECT_DEATH(jniGetNioBufferBaseArrayOffset(env, NULL), kLoadFailed); in TEST_F()
42 EXPECT_DEATH(jniGetNioBufferFields(env, NULL, NULL, NULL, NULL), kLoadFailed); in TEST_F()
43 EXPECT_DEATH(jniGetNioBufferPointer(env, NULL), kLoadFailed); in TEST_F()
58 JNIEnv* env = NULL; in TEST_F() local
62 EXPECT_DEATH(JNI_CreateJavaVM(&vm, &env, NULL), kLoadFailed); in TEST_F()
Dscoped_primitive_array_test.cpp21 void TestScopedPrimitiveArrayRO(JNIEnv* env, jbooleanArray array) { in TestScopedPrimitiveArrayRO() argument
22 ScopedBooleanArrayRO sba(env, array); in TestScopedPrimitiveArrayRO()
28 void TestCompilationRW(JNIEnv* env, jintArray array) { in TestCompilationRW() argument
29 ScopedIntArrayRW sba(env, array); in TestCompilationRW()
Dscoped_local_frame_test.cpp21 void TestScopedLocalFrame(JNIEnv* env) { in TestScopedLocalFrame() argument
22 ScopedLocalFrame slf(env); in TestScopedLocalFrame()
Dscoped_utf_chars_test.cpp21 void TestCompilationScopedUtfChars(JNIEnv* env, jstring s) { in TestCompilationScopedUtfChars() argument
22 ScopedUtfChars suc(env, s); in TestCompilationScopedUtfChars()
Dscoped_local_ref_test.cpp21 void TestScopedLocalRef(JNIEnv* env) { in TestScopedLocalRef() argument
22 ScopedLocalRef<jarray> slr1(env); in TestScopedLocalRef()
/libnativehelper/include/android/
Dfile_descriptor_jni.h52 jobject AFileDescriptor_create(JNIEnv* env) __INTRODUCED_IN(31);
67 int AFileDescriptor_getFd(JNIEnv* env, jobject fileDescriptor) __INTRODUCED_IN(31);
84 void AFileDescriptor_setFd(JNIEnv* env, jobject fileDescriptor, int fd) __INTRODUCED_IN(31);
/libnativehelper/tests/jni_gtest/base/nativehelper/
Djni_gtest.h102 void DestroyJNIEnv(JNIEnv* env) { in DestroyJNIEnv() argument
103 delete env->functions; in DestroyJNIEnv()
104 delete env; in DestroyJNIEnv() local

12