src/share/native/common/jni_util.h

Print this page




 280 
 281 /************************************************************************
 282  * Miscellaneous utilities used by the class libraries to return from
 283  * a function if a value is NULL or an exception is pending.
 284  */
 285 
 286 #define CHECK_NULL(x)                           \
 287     do {                                        \
 288         if ((x) == NULL) {                      \
 289             return;                             \
 290         }                                       \
 291     } while (0)                                 \
 292 
 293 #define CHECK_NULL_RETURN(x, y)                 \
 294     do {                                        \
 295         if ((x) == NULL) {                      \
 296             return (y);                         \
 297         }                                       \
 298     } while (0)                                 \
 299 















 300 #define JNU_CHECK_EXCEPTION(env)                \
 301     do {                                        \
 302         if ((*env)->ExceptionCheck(env)) {      \
 303             return;                             \
 304         }                                       \
 305     } while (0)                                 \
 306 
 307 #define JNU_CHECK_EXCEPTION_RETURN(env, y)      \
 308     do {                                        \
 309         if ((*env)->ExceptionCheck(env)) {      \
 310             return (y);                         \
 311         }                                       \
 312     } while (0)
 313 
 314 /************************************************************************
 315  * Debugging utilities
 316  */
 317 
 318 JNIEXPORT void JNICALL
 319 JNU_PrintString(JNIEnv *env, char *hdr, jstring string);
 320 
 321 JNIEXPORT void JNICALL
 322 JNU_PrintClass(JNIEnv *env, char *hdr, jobject object);
 323 
 324 JNIEXPORT jstring JNICALL
 325 JNU_ToString(JNIEnv *env, jobject object);
 326 
 327 /*
 328  * Package shorthand for use by native libraries
 329  */
 330 #define JNU_JAVAPKG         "java/lang/"
 331 #define JNU_JAVAIOPKG       "java/io/"
 332 #define JNU_JAVANETPKG      "java/net/"
 333 




 280 
 281 /************************************************************************
 282  * Miscellaneous utilities used by the class libraries to return from
 283  * a function if a value is NULL or an exception is pending.
 284  */
 285 
 286 #define CHECK_NULL(x)                           \
 287     do {                                        \
 288         if ((x) == NULL) {                      \
 289             return;                             \
 290         }                                       \
 291     } while (0)                                 \
 292 
 293 #define CHECK_NULL_RETURN(x, y)                 \
 294     do {                                        \
 295         if ((x) == NULL) {                      \
 296             return (y);                         \
 297         }                                       \
 298     } while (0)                                 \
 299 
 300 #ifdef __cplusplus
 301 #define JNU_CHECK_EXCEPTION(env)                \
 302     do {                                        \
 303         if ((env)->ExceptionCheck()) {          \
 304             return;                             \
 305         }                                       \
 306     } while (0)                                 \
 307 
 308 #define JNU_CHECK_EXCEPTION_RETURN(env, y)      \
 309     do {                                        \
 310         if ((env)->ExceptionCheck()) {          \
 311             return (y);                         \
 312         }                                       \
 313     } while (0)
 314 #else
 315 #define JNU_CHECK_EXCEPTION(env)                \
 316     do {                                        \
 317         if ((*env)->ExceptionCheck(env)) {      \
 318             return;                             \
 319         }                                       \
 320     } while (0)                                 \
 321 
 322 #define JNU_CHECK_EXCEPTION_RETURN(env, y)      \
 323     do {                                        \
 324         if ((*env)->ExceptionCheck(env)) {      \
 325             return (y);                         \
 326         }                                       \
 327     } while (0)
 328 #endif /* __cplusplus */
 329 /************************************************************************
 330  * Debugging utilities
 331  */
 332 
 333 JNIEXPORT void JNICALL
 334 JNU_PrintString(JNIEnv *env, char *hdr, jstring string);
 335 
 336 JNIEXPORT void JNICALL
 337 JNU_PrintClass(JNIEnv *env, char *hdr, jobject object);
 338 
 339 JNIEXPORT jstring JNICALL
 340 JNU_ToString(JNIEnv *env, jobject object);
 341 
 342 /*
 343  * Package shorthand for use by native libraries
 344  */
 345 #define JNU_JAVAPKG         "java/lang/"
 346 #define JNU_JAVAIOPKG       "java/io/"
 347 #define JNU_JAVANETPKG      "java/net/"
 348