theKernel 10.0
Loading...
Searching...
No Matches
MkExceptionC_jv.c
Go to the documentation of this file.
1
9/* LABEL-NO */
10#define META_FILE_NAME "MkExceptionC_jv.c"
11
12#include <jni.h>
13#include "LibMkKernel_jv.h"
14
15/* LABEL-END */
16
17void NS(MkExceptionC_Raise) (
18 JNIEnv * env,
19 MK_MNGN mng,
20 MK_STRN const doc,
21 MK_STRN const file,
22 MK_I32 const line
23)
24{
25 MK_ERR err = MkErrorFORMAT_1M(mng);
26 MkRtSetup_XN(err);
27 MkErrorStackFormat(err,doc,file,line);
28 NS(pGetCallerStack)(MK_RT_CALL env, err);
29 MK_ERR newerr = MkErrCheck(mng) && mng != err ? (MK_ERR)mng : MkErrorDup(err);
30 MkRefIncr_1X(newerr);
31
32 jthrowable exp = (*env)->NewObject(env, NS(Class_MkExceptionC), NS(MID_MkExceptionC_INIT),
33 (jlong) newerr, JC2O(env, (MK_STRN)MkErrorGetTextI(err)));
34
35 (*env)->Throw(env, exp);
36
37 MkErrorReset_1(err);
38}
39
40JNIEXPORT void JNICALL Java_jvmkkernel_MkExceptionC_Dispose (JNIEnv *env, jobject self)
41{
42 MK_ERR hdl = MkErr((MK_MNG)(*env)->GetLongField(env,self,NS(FID_MkExceptionC_hdl)));
43 MkRtSetup_X(hdl);
44 if (hdl) MkRefDecr_X(hdl);
45 (*env)->SetLongField(env,self,NS(FID_MkExceptionC_hdl),0);
46 return;
47}
48
49MK_ERR NS(MkExceptionC_Catch) (
50 JNIEnv *env,
51 MK_MNGN mng,
52 jthrowable ex,
53 MK_STRN const proc,
54 MK_STRN const stop
55)
56{
57 if (ex == NULL) ex = (*env)->ExceptionOccurred(env);
58 MK_ERR const err = MkErrorFORMAT_1M(mng);
59 MkRtSetup_XN(err);
60
61 // is the ERROR from "java" or "jvmkkernel"
62 if (OT_LNG_OBJ_CLASS_IS(ex, NS(Class_MkExceptionC))) {
63 // error is from "jvmkkernel"
64 MK_ERR newerr = (MK_ERR) (*env)->GetLongField(env,ex,NS(FID_MkExceptionC_hdl));
65 if (newerr) {
66 MkErrorSetE(err, newerr);
67 (*env)->CallObjectMethod(env,ex,NS(MID_MkExceptionC_EXIT));
68 }
69
70 } else {
71 (*env)->CallStaticVoidMethod(
72 env, MK(Class_MkExceptionC), MK(MID_MkExceptionC_Catch),
73 MK(MkErrorC_ObjNew)(MK_RT_CALL env,err), ex, JC2O(env, proc), JC2O(env, stop)
74 );
75 }
76 (*env)->ExceptionClear(env);
77
78 return err;
79}
80
81
JNIEXPORT void JNICALL Java_jvmkkernel_MkExceptionC_Dispose(JNIEnv *env, jobject self)
struct MkErrorS * MK_ERR
class-shortcut for struct MkErrorS *, all shortcut using the XX_YYY syntax (only for public API) …
static bool MkErrCheck(MK_MNGN mng)
check MkErrorS -> MkObjectS::signature …
static MK_ERR MkErr(MK_MNG mng)
cast a unknown-object into an MkErrorS pointer or NULL if not possible
#define MkErrorGetTextI(e)
get the MkErrorS::text …
#define MkErrorReset_1(err)
#define MkErrorStackFormat(...)
#define MkErrorSetE(...)
#define MkErrorFORMAT_1M(m)
#define MkErrorDup(...)
const MK_PTRB * MK_MNGN
const - a managed object pointer, datatype will be checked at runtime
const MK_STRB * MK_STRN
constant string pointer data-type
MK_PTRB * MK_MNG
managed object pointer, datatype will be checked at runtime
signed int MK_I32
4 byte integer data-type
#define MkRefDecr_X(x)
#define MkRefIncr_1X(x)
#define MkRtSetup_XN(x)
#define MK_RT_CALL
#define MkRtSetup_X(x)
The data-type to store and handle the error-condition …