#include <JniUtil.h>
Inheritance diagram for JniEnvRef:
Public Member Functions | |
JniEnvRef (JNIEnv *pEnvInit) | |
Explicit constructor: use supplied JNIEnv pointer. | |
void | operator= (JniEnvRef const &other) |
JniExceptionChecker | operator-> () const |
JNIEnv * | get () |
void | handleExcn (std::exception &ex) |
Private Attributes | |
JNIEnv * | pEnv |
This allows us to automatically progagate exceptions from all calls to JNIEnv by using the call wrapper technique (except without the shared_ptrs, because they're too slow!).
Definition at line 73 of file JniUtil.h.
JniEnvRef::JniEnvRef | ( | JNIEnv * | pEnvInit | ) | [inline, explicit] |
void JniEnvRef::operator= | ( | JniEnvRef const & | other | ) | [inline] |
JniExceptionChecker JniEnvRef::operator-> | ( | ) | const [inline] |
JNIEnv* JniEnvRef::get | ( | ) | [inline] |
Definition at line 96 of file JniUtil.h.
Referenced by JniLocalRefReaper::JniLocalRefReaper().
00097 { 00098 return pEnv; 00099 }
void JniEnvRef::handleExcn | ( | std::exception & | ex | ) |
Definition at line 540 of file JniUtil.cpp.
References JavaExcn::getJavaException(), FennelExcn::getMessage(), and pEnv.
Referenced by Java_com_lucidera_farrago_fennel_LucidEraJni_registerStreamFactory(), Java_net_sf_farrago_fennel_FennelStorage_executeJavaCmd(), Java_net_sf_farrago_fennel_FennelStorage_tupleStreamFetch(), Java_net_sf_farrago_fennel_FennelStorage_tupleStreamGraphClose(), Java_net_sf_farrago_fennel_FennelStorage_tupleStreamGraphGetInputStreams(), Java_net_sf_farrago_fennel_FennelStorage_tupleStreamGraphOpen(), Java_net_sf_farrago_fennel_FennelStorage_tupleStreamRestart(), Java_net_sf_farrago_fennel_FennelStorage_tupleStreamTransformFetch(), and JNI_OnLoad().
00541 { 00542 JavaExcn *pJavaExcn = dynamic_cast<JavaExcn *>(&ex); 00543 if (pJavaExcn) { 00544 pEnv->Throw(pJavaExcn->getJavaException()); 00545 return; 00546 } 00547 std::string what; 00548 FennelExcn *pFennelExcn = dynamic_cast<FennelExcn *>(&ex); 00549 if (pFennelExcn) { 00550 what = pFennelExcn->getMessage(); 00551 } else { 00552 std::bad_alloc *pBadAllocExcn = 00553 dynamic_cast<std::bad_alloc *>(&ex); 00554 if (pBadAllocExcn) { 00555 // Convert bad_alloc's terrible error mesage into something fit for 00556 // human consumption. 00557 what = FennelResource::instance().internalError("malloc failed"); 00558 } else { 00559 what = FennelResource::instance().internalError(ex.what()); 00560 } 00561 } 00562 // TODO: need special-case handling for out-of-memory here 00563 jclass classSQLException = pEnv->FindClass("java/sql/SQLException"); 00564 jstring jMessage = pEnv->NewStringUTF(what.c_str()); 00565 jmethodID constructor = pEnv->GetMethodID( 00566 classSQLException,"<init>","(Ljava/lang/String;)V"); 00567 jthrowable t = (jthrowable) 00568 pEnv->NewObject(classSQLException,constructor,jMessage); 00569 pEnv->Throw(t); 00570 }
JNIEnv* JniEnvRef::pEnv [private] |