OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_ANDROID_JNI_ANDROID_H_ | 5 #ifndef BASE_ANDROID_JNI_ANDROID_H_ |
6 #define BASE_ANDROID_JNI_ANDROID_H_ | 6 #define BASE_ANDROID_JNI_ANDROID_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 const JavaRef<jclass>& clazz, | 64 const JavaRef<jclass>& clazz, |
65 const char* method_name, | 65 const char* method_name, |
66 const char* jni_signature); | 66 const char* jni_signature); |
67 | 67 |
68 // Similar to GetMethodID, but takes a raw jclass. | 68 // Similar to GetMethodID, but takes a raw jclass. |
69 jmethodID GetMethodID(JNIEnv* env, | 69 jmethodID GetMethodID(JNIEnv* env, |
70 jclass clazz, | 70 jclass clazz, |
71 const char* method_name, | 71 const char* method_name, |
72 const char* jni_signature); | 72 const char* jni_signature); |
73 | 73 |
| 74 // Unlike GetMethodID, returns NULL if the method could not be found. |
| 75 jmethodID GetMethodIDOrNull(JNIEnv* env, |
| 76 jclass clazz, |
| 77 const char* method_name, |
| 78 const char* jni_signature); |
| 79 |
74 // Returns the method ID for the static method with the specified name and | 80 // Returns the method ID for the static method with the specified name and |
75 // signature. | 81 // signature. |
76 // This method triggers a fatal assertion if the method could not be found. | 82 // This method triggers a fatal assertion if the method could not be found. |
77 // Use HasMethod if you need to check whether a method exists. | 83 // Use HasMethod if you need to check whether a method exists. |
78 jmethodID GetStaticMethodID(JNIEnv* env, | 84 jmethodID GetStaticMethodID(JNIEnv* env, |
79 const JavaRef<jclass>& clazz, | 85 const JavaRef<jclass>& clazz, |
80 const char* method_name, | 86 const char* method_name, |
81 const char* jni_signature); | 87 const char* jni_signature); |
82 | 88 |
83 // Similar to the GetStaticMethodID, but takes a raw jclass. | 89 // Similar to the GetStaticMethodID, but takes a raw jclass. |
84 jmethodID GetStaticMethodID(JNIEnv* env, | 90 jmethodID GetStaticMethodID(JNIEnv* env, |
85 jclass clazz, | 91 jclass clazz, |
86 const char* method_name, | 92 const char* method_name, |
87 const char* jni_signature); | 93 const char* jni_signature); |
88 | 94 |
| 95 // Unlike GetStaticMethodID, returns NULL if the method could not be found. |
| 96 jmethodID GetStaticMethodIDOrNull(JNIEnv* env, |
| 97 jclass clazz, |
| 98 const char* method_name, |
| 99 const char* jni_signature); |
89 | 100 |
90 // Returns true iff |clazz| has a method with the specified name and signature. | 101 // Returns true iff |clazz| has a method with the specified name and signature. |
91 bool HasMethod(JNIEnv* env, | 102 bool HasMethod(JNIEnv* env, |
92 const JavaRef<jclass>& clazz, | 103 const JavaRef<jclass>& clazz, |
93 const char* method_name, | 104 const char* method_name, |
94 const char* jni_signature); | 105 const char* jni_signature); |
95 | 106 |
96 // Gets the method ID from the class name. Clears the pending Java exception | 107 // Gets the method ID from the class name. Clears the pending Java exception |
97 // and returns NULL if the method is not found. Caches results. Note that | 108 // and returns NULL if the method is not found. Caches results. Note that |
98 // GetMethodID() below avoids a class lookup, but does not cache results. | 109 // GetMethodID() below avoids a class lookup, but does not cache results. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 // and returns true. | 144 // and returns true. |
134 bool ClearException(JNIEnv* env); | 145 bool ClearException(JNIEnv* env); |
135 | 146 |
136 // This function will call CHECK() macro if there's any pending exception. | 147 // This function will call CHECK() macro if there's any pending exception. |
137 void CheckException(JNIEnv* env); | 148 void CheckException(JNIEnv* env); |
138 | 149 |
139 } // namespace android | 150 } // namespace android |
140 } // namespace base | 151 } // namespace base |
141 | 152 |
142 #endif // BASE_ANDROID_JNI_ANDROID_H_ | 153 #endif // BASE_ANDROID_JNI_ANDROID_H_ |
OLD | NEW |