4 * Various JNI helper functions
6 * Copyright 2006,2007 Martin Quinson, Malek Cherier All right reserved.
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the license (GNU LGPL) which comes with this package.
13 #ifndef JXBT_UTILITY_H
14 #define JXBT_UTILITY_H
17 #include "jxbt_utilities.h"
23 /* Search a class and throw an exception if not found */
24 jclass jxbt_get_class(JNIEnv * env, const char *name);
26 /* Search a method in a class and throw an exception if not found
27 (it's ok to to pass a NULL class: it's a noop) */
28 jmethodID jxbt_get_jmethod(JNIEnv * env, jclass class,
29 const char *name, const char *signature);
31 /* Like the jxbt_get_class() but get a static method */
32 jmethodID jxbt_get_static_jmethod(JNIEnv * env, jclass cls,
33 const char *name, const char *signature);
35 /* Search a field in a class and throw an exception if not found
36 (it's ok to to pass a NULL class: it's a noop) */
37 jfieldID jxbt_get_jfield(JNIEnv * env, jclass class,
38 const char *name, const char *signature);
41 /* Search a method in a class and throw an exception if not found
42 (it's ok to to pass a NULL class: it's a noop) */
43 jmethodID jxbt_get_smethod(JNIEnv * env, const char *classname,
44 const char *name, const char *signature);
46 /* Like the jxbt_get_smethod() but get a static method */
47 jmethodID jxbt_get_static_smethod(JNIEnv * env, const char *classname,
48 const char *name, const char *signature);
50 /* Search a field in a class and throw an exception if not found
51 (it's ok to to pass a NULL class: it's a noop) */
52 jfieldID jxbt_get_sfield(JNIEnv * env, const char *classname,
53 const char *name, const char *signature);
56 /* ***************** */
57 /* EXCEPTION RAISING */
58 /* ***************** */
61 /** Thrown on internal error of this layer, or on problem with JNI */
62 void jxbt_throw_jni(JNIEnv * env, const char *msg);
63 /** Thrown when using an object not bound to a native one where it should, or reverse (kinda JNI issue) */
64 void jxbt_throw_notbound(JNIEnv * env, const char *kind, void *pointer);
66 /** Thrown on error in native MSG code */
67 void jxbt_throw_native(JNIEnv * env, char *msg);
69 /** Thrown if NULL gets used */
70 void jxbt_throw_null(JNIEnv * env, char *msg);
72 /** Thrown on illegal arguments */
73 void jxbt_throw_illegal(JNIEnv * env, char *msg);
74 /** Thrown when looking for an host from name does not lead to anything */
75 void jxbt_throw_host_not_found(JNIEnv * env, const char *invalid_name);
76 /** Thrown when looking for an host from name does not lead to anything */
77 void jxbt_throw_process_not_found(JNIEnv * env, const char *invalid_name);
79 #endif /* ! JXBT_UTILITY_H */