Fennel: JniEnvAutoRef Class Reference (original) (raw)

An implementation of JniEnvRef which can be used in contexts where no JNIEnv is available yet. More...

#include <[JniUtil.h](JniUtil%5F8h-source.html)>

Inheritance diagram for JniEnvAutoRef:

List of all members.

Public Member Functions
JniEnvAutoRef ()
Uses GetEnv to access current thread's JNIEnv pointer.
void suppressDetach ()
Suppresses default detach-on-destruct behavior.
~JniEnvAutoRef ()
JniExceptionChecker operator-> () const
JNIEnv * get ()
void handleExcn (std::exception &ex)
Private Attributes
bool needDetach

Detailed Description

An implementation of JniEnvRef which can be used in contexts where no JNIEnv is available yet.

When an environment is already available, it is used automatically, but when unavailable, this class takes care of attaching the thread (in the constructor) and detaching it (in the destructor). For threads created within Fennel, attach/detach can be optimized by allocating a JniEnvAutoRef on a thread's initial stack frame so that it will be available to all methods called.

Definition at line 113 of file JniUtil.h.


Constructor & Destructor Documentation

| JniEnvAutoRef::JniEnvAutoRef | ( | | ) | [explicit] | | ---------------------------- | - | | - | ------------ |

Uses GetEnv to access current thread's JNIEnv pointer.

Definition at line 523 of file JniUtil.cpp.

| JniEnvAutoRef::~JniEnvAutoRef | ( | | ) | | ------------------------------ | - | | - |


Member Function Documentation

| void JniEnvAutoRef::suppressDetach | ( | | ) | | ---------------------------------- | - | | - |

| JNIEnv* JniEnvRef::get | ( | | ) | [inline, inherited] | | ----------------------- | - | | - | --------------------- |

void JniEnvRef::handleExcn ( std::exception & ex ) [inherited]

Definition at line 540 of file JniUtil.cpp.

References JavaExcn::getJavaException(), FennelExcn::getMessage(), and JniEnvRef::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
00556
00557 what = FennelResource::instance().internalError("malloc failed"); 00558 } else { 00559 what = FennelResource::instance().internalError(ex.what()); 00560 } 00561 } 00562
00563 jclass classSQLException = pEnv->FindClass("java/sql/SQLException"); 00564 jstring jMessage = pEnv->NewStringUTF(what.c_str()); 00565 jmethodID constructor = pEnv->GetMethodID( 00566 classSQLException,"","(Ljava/lang/String;)V"); 00567 jthrowable t = (jthrowable) 00568 pEnv->NewObject(classSQLException,constructor,jMessage); 00569 pEnv->Throw(t); 00570 }


Member Data Documentation


The documentation for this class was generated from the following files:


Generated on Mon Jun 22 04:00:33 2009 for Fennel by doxygen 1.5.1