#include <JniUtil.h>
Static Public Member Functions | |
static void | initDebug (char const *envVarName) |
Initializes JNI debugging. | |
static jint | init (JavaVM *pVm) |
Initializes our JNI support. | |
static void | configure (const JniUtilParams ¶ms) |
Configure run-time JNI features, such as whether or not JNI handles are traced. | |
static void | shutdown () |
Shutdown run-time JNI features, such as JNI handle tracking. | |
static std::string | getClassName (jclass jClass) |
Calls java.lang.Class.getName(). | |
static std::string | getFirstPublicInterfaceName (jclass jClass) |
Calls java.lang.Class.getInterfaces() and returns result of java.lang.Class.getClassName() for the first public interface returned. | |
static std::string | toStdString (JniEnvRef pEnv, jstring jString) |
Converts a Java string to a C++ string. | |
static jstring | toString (JniEnvRef pEnv, jobject jObject) |
Calls toString() on a Java object. | |
static jobject | getIter (JniEnvRef pEnv, jobject jCollection) |
Calls java.util.Collection.iterator(). | |
static jobject | getNextFromIter (JniEnvRef pEnv, jobject jIter) |
Calls java.util.Iterator.hasNext/next(). | |
static uint | lookUpEnum (std::string *pSymbols, std::string const &symbol) |
Looks up an enum value. | |
static void | detachJavaEnv () |
Detaches the JNIEnv for the current thread (undoes effect of getAttachedJavaEnv in the case where needDetach received true). | |
static void | incrementHandleCount (const char *pType, const void *pHandle) |
Increment the handle count. | |
static void | decrementHandleCount (const char *pType, const void *pHandle) |
Decrement the handle count. | |
static int | getHandleCount () |
Retrieve the current handle count. | |
static std::string | getXmi (const TupleDescriptor &tupleDesc) |
Constructs a FemTupleDescriptor xmi string. | |
static ThreadTracker & | getThreadTracker () |
| |
Static Public Attributes | |
static const jint | jniVersion = JNI_VERSION_1_2 |
Required JNI version. | |
static jmethodID | methGetJavaStreamHandle |
Java method FennelJavaStreamMap.getJavaStreamHandle. | |
static jmethodID | methGetIndexRoot |
Java method FennelJavaStreamMap.getIndexRoot. | |
static jmethodID | methBase64Decode |
Java method RhBase64.decode. | |
static jclass | classRhBase64 |
static jmethodID | methRandomUUID |
Java method UUID.randomUUID. | |
static jclass | classUUID |
static jmethodID | methFarragoTransformInit |
Java method FarragoTransform.init. | |
static jmethodID | methFarragoTransformExecute |
Java method FarragoTransform.execute. | |
static jmethodID | methFarragoTransformSetInputFetchTimeout |
Java method FarragoTransform.setInputFetchTimeout. | |
static jmethodID | methFarragoTransformRestart |
Java method FarragoTransform.restart. | |
static jclass | classFarragoTransformInputBinding |
Java class FarragoTransform.InputBinding. | |
static jmethodID | methFarragoTransformInputBindingCons |
Java constructor FarragoTransform.InputBinding.InputBinding. | |
static jmethodID | methFarragoRuntimeContextStatementClassForName |
Java method FarragoRuntimeContext.statementClassForName. | |
static jmethodID | methFarragoRuntimeContextFindFarragoTransform |
Java method FarragoRuntimeContext.findFarragoTransform. | |
static jclass | classUtil |
Java class org.eigenbase.util.Util. | |
static jmethodID | methUtilGetStackTrace |
Java method org.eigenbase.util.Util.getStackTrace(Throwable). | |
static jclass | classLong |
java.lang.Long | |
static jclass | classInteger |
java.lang.Integer | |
static jclass | classShort |
java.lang.Short | |
static jclass | classDouble |
java.lang.Double | |
static jclass | classFloat |
java.lang.Float | |
static jclass | classBoolean |
java.lang.Boolean | |
static jmethodID | methLongValueOf |
java.lang.Long.valueOf(long) | |
static jmethodID | methIntegerValueOf |
java.lang.Integer.valueOf(int) | |
static jmethodID | methShortValueOf |
java.lang.Short.valueOf(short) | |
static jmethodID | methDoubleValueOf |
java.lang.Double.valueOf(double) | |
static jmethodID | methFloatValueOf |
java.lang.Float.valueOf(float) | |
static jmethodID | methBooleanValueOf |
java.lang.Boolean.valueOf(boolean) | |
static jmethodID | methLongValue |
java.lang.Long.longValue() | |
static jmethodID | methIntValue |
java.lang.Integer.intValue() | |
static jmethodID | methShortValue |
java.lang.Short.shortValue() | |
static jmethodID | methDoubleValue |
java.lang.Double.doubleValue() | |
static jmethodID | methFloatValue |
java.lang.Float.floatValue() | |
static jmethodID | methBooleanValue |
java.lang.Boolean.booleanValue() | |
Static Private Member Functions | |
static JNIEnv * | getAttachedJavaEnv (bool &needDetach) |
Attaches a JNIEnv for the current thread. | |
static void | traceHandleCount (const char *pAction, const char *pType, const void *pHandle) |
JNI handle tracing method. | |
Static Private Attributes | |
static JavaVM * | pVm |
Loaded JavaVM instance. | |
static jmethodID | methGetClassName |
java.lang.Class.getName() | |
static jmethodID | methGetInterfaces |
java.lang.Class.getInterfaces() | |
static jmethodID | methGetModifiers |
java.lang.Class.getModifiers() | |
static jclass | classModifier |
class java.lang.Modifier | |
static jmethodID | methIsPublic |
java.lang.reflect.Modifier.isPublic() | |
static jmethodID | methIterator |
java.util.Collection.iterator() | |
static jmethodID | methHasNext |
java.util.Iterator.hasNext() | |
static jmethodID | methNext |
java.util.Iterator.next() | |
static jmethodID | methToString |
java.lang.Object.toString() | |
static AtomicCounter | handleCount |
Counter for all handles opened by Farrago. | |
static bool | traceHandleCountEnabled |
Flag indicating whether tracing of handles is enabled. | |
static bool | closeHandleCountTraceOnZero |
Flag indicating that the JNI handle trace stream should be closed when the handle count reaches 0. | |
static std::ofstream | handleCountTraceStream |
Stream for tracing handles opened by Farrago. | |
static JavaThreadTracker | threadTracker |
Tracker for JNI thread attach/detach. | |
Friends | |
class | JniEnvAutoRef |
Definition at line 196 of file JniUtil.h.
JNIEnv * JniUtil::getAttachedJavaEnv | ( | bool & | needDetach | ) | [static, private] |
Attaches a JNIEnv for the current thread.
Can be used in contexts where the JNIEnv hasn't been passed down from the native entry point.
needDetach | receives true if thread needs to be detached; false if it was already attached on entry |
Definition at line 340 of file JniUtil.cpp.
References jniVersion, and pVm.
00341 { 00342 void *pEnv = NULL; 00343 jint rc = pVm->GetEnv(&pEnv,jniVersion); 00344 if (rc == JNI_OK) { 00345 // previously attached, so it would be wrong to detach in destructor 00346 needDetach = false; 00347 return static_cast<JNIEnv *>(pEnv); 00348 } 00349 needDetach = true; 00350 rc = pVm->AttachCurrentThread(&pEnv,NULL); 00351 assert(rc == 0); 00352 assert(pEnv); 00353 return static_cast<JNIEnv *>(pEnv); 00354 }
void JniUtil::traceHandleCount | ( | const char * | pAction, | |
const char * | pType, | |||
const void * | pHandle | |||
) | [static, private] |
JNI handle tracing method.
Definition at line 455 of file JniUtil.cpp.
References closeHandleCountTraceOnZero, handleCount, handleCountTraceStream, and traceHandleCountEnabled.
Referenced by decrementHandleCount(), and incrementHandleCount().
00457 { 00458 if (traceHandleCountEnabled) { 00459 handleCountTraceStream 00460 << pAction << " " << pType << ": " << pHandle << std::endl; 00461 00462 if (handleCount == 0 && closeHandleCountTraceOnZero && 00463 strcmp(pAction, "DEC") == 0) { 00464 traceHandleCountEnabled = false; 00465 closeHandleCountTraceOnZero = false; 00466 00467 handleCountTraceStream.flush(); 00468 handleCountTraceStream.close(); 00469 } 00470 } 00471 }
void JniUtil::initDebug | ( | char const * | envVarName | ) | [static] |
Initializes JNI debugging.
envVarName | name of environment variable used to trigger debugging |
Definition at line 115 of file JniUtil.cpp.
References debugger_signalHandler().
Referenced by JNI_OnLoad().
00116 { 00117 char *pDebug = getenv(envVarName); 00118 if (pDebug && (atoi(pDebug) >= 1)) { 00119 char pidstr[32]; 00120 snprintf(pidstr, 32, "%d", getpid()); 00121 std::cout << "Waiting for debugger; pid=" << pidstr << std::endl; 00122 std::cout.flush(); 00123 #ifdef __MSVC__ 00124 // A "cont" in gdb will wake this sleep up immediately, which 00125 // is disturbing but useful. 00126 _sleep(600000); 00127 #else 00128 // On older versions of Linux, a "cont" in gdb will wake this 00129 // sleep up immediately, which is disturbing but useful. 00130 // On newer versions, the continue command resumes 00131 // the sleep(). So, if $envVarName > 1, wait for SIGHUP. 00132 // Use the "signal 1" command to wake the pause up. 00133 if (atoi(pDebug) == 1) { 00134 sleep(60000); 00135 } else { 00136 struct sigaction act; 00137 struct sigaction oldact; 00138 00139 act.sa_handler = debugger_signalHandler; 00140 sigemptyset(&act.sa_mask); 00141 act.sa_flags = 0; 00142 00143 if (!sigaction(SIGHUP, &act, &oldact)) { 00144 // Signal handler installed properly. Wait for signal. 00145 pause(); 00146 00147 // Restore the old signal handler. 00148 sigaction(SIGHUP, &oldact, NULL); 00149 } else { 00150 // Fall back on sleeping. 00151 sleep(60000); 00152 } 00153 } 00154 #endif 00155 } 00156 }
jint JniUtil::init | ( | JavaVM * | pVm | ) | [static] |
Initializes our JNI support.
pVm | the VM in which we're loaded |
Definition at line 200 of file JniUtil.cpp.
References classBoolean, classDouble, classFarragoTransformInputBinding, classFloat, classInteger, classLong, classModifier, classRhBase64, classShort, classUtil, classUUID, AutoBacktrace::install(), jniVersion, methBase64Decode, methBooleanValue, methBooleanValueOf, methDoubleValue, methDoubleValueOf, methFarragoRuntimeContextFindFarragoTransform, methFarragoRuntimeContextStatementClassForName, methFarragoTransformExecute, methFarragoTransformInit, methFarragoTransformInputBindingCons, methFarragoTransformRestart, methFarragoTransformSetInputFetchTimeout, methFloatValue, methFloatValueOf, methGetClassName, methGetIndexRoot, methGetInterfaces, methGetJavaStreamHandle, methGetModifiers, methHasNext, methIntegerValueOf, methIntValue, methIsPublic, methIterator, methLongValue, methLongValueOf, methNext, methRandomUUID, methShortValue, methShortValueOf, methToString, methUtilGetStackTrace, and pVm.
Referenced by JNI_OnLoad().
00201 { 00202 // Install handler to print backtrace on fatal error. Note that 00203 // we pass false to suppress handling of SIGSEGV, because Java 00204 // raises this spuriously. Instead, if a real SIGSEGV occurs 00205 // in native code, Java will abort, raising SIGABRT from the same 00206 // stack frame, so we'll catch that and backtrace it instead. 00207 AutoBacktrace::install(false); 00208 pVm = pVmInit; 00209 JniEnvAutoRef pEnv; 00210 jclass classClass = pEnv->FindClass("java/lang/Class"); 00211 jclass classObject = pEnv->FindClass("java/lang/Object"); 00212 jclass classCollection = pEnv->FindClass("java/util/Collection"); 00213 jclass classIterator = pEnv->FindClass("java/util/Iterator"); 00214 00215 // Make sure this jclass is a global ref or the JVM might move it on us. 00216 // This is only required for classes on which we need to invoke 00217 // static methods. 00218 classRhBase64 = pEnv->FindClass("org/eigenbase/util/RhBase64"); 00219 classRhBase64 = (jclass) pEnv->NewGlobalRef(classRhBase64); 00220 classUUID = pEnv->FindClass("java/util/UUID"); 00221 classUUID = (jclass) pEnv->NewGlobalRef(classUUID); 00222 00223 jclass classFennelJavaStreamMap = pEnv->FindClass( 00224 "net/sf/farrago/fennel/FennelJavaStreamMap"); 00225 jclass classFarragoTransform = pEnv->FindClass( 00226 "net/sf/farrago/runtime/FarragoTransform"); 00227 00228 // Make sure this jclass is a global ref of the JVM might move it on us. 00229 jclass tempInputBinding = 00230 pEnv->FindClass( 00231 "net/sf/farrago/runtime/FarragoTransform$InputBinding"); 00232 classFarragoTransformInputBinding = 00233 (jclass)pEnv->NewGlobalRef(tempInputBinding); 00234 00235 jclass classFarragoRuntimeContext = pEnv->FindClass( 00236 "net/sf/farrago/runtime/FarragoRuntimeContext"); 00237 methGetClassName = pEnv->GetMethodID( 00238 classClass,"getName","()Ljava/lang/String;"); 00239 methGetInterfaces = pEnv->GetMethodID( 00240 classClass,"getInterfaces","()[Ljava/lang/Class;"); 00241 methGetModifiers = pEnv->GetMethodID( 00242 classClass,"getModifiers","()I"); 00243 00244 jclass tempClassModifier = pEnv->FindClass("java/lang/reflect/Modifier"); 00245 classModifier = (jclass)pEnv->NewGlobalRef(tempClassModifier); 00246 methIsPublic = pEnv->GetStaticMethodID(classModifier, "isPublic", "(I)Z"); 00247 00248 methIterator = pEnv->GetMethodID( 00249 classCollection,"iterator","()Ljava/util/Iterator;"); 00250 methHasNext = pEnv->GetMethodID( 00251 classIterator,"hasNext","()Z"); 00252 methNext = pEnv->GetMethodID( 00253 classIterator,"next","()Ljava/lang/Object;"); 00254 methGetJavaStreamHandle = pEnv->GetMethodID( 00255 classFennelJavaStreamMap,"getJavaStreamHandle", 00256 "(I)J"); 00257 methGetIndexRoot = pEnv->GetMethodID( 00258 classFennelJavaStreamMap,"getIndexRoot", 00259 "(J)J"); 00260 methToString = pEnv->GetMethodID( 00261 classObject,"toString","()Ljava/lang/String;"); 00262 00263 jclass tempClassLong = pEnv->FindClass("java/lang/Long"); 00264 classLong = (jclass)pEnv->NewGlobalRef(tempClassLong); 00265 methLongValueOf = 00266 pEnv->GetStaticMethodID(classLong, "valueOf", "(J)Ljava/lang/Long;"); 00267 methLongValue = pEnv->GetMethodID(classLong, "longValue", "()J"); 00268 00269 jclass tempClassInteger = pEnv->FindClass("java/lang/Integer"); 00270 classInteger = (jclass)pEnv->NewGlobalRef(tempClassInteger); 00271 methIntegerValueOf = 00272 pEnv->GetStaticMethodID( 00273 classInteger, "valueOf", "(I)Ljava/lang/Integer;"); 00274 methIntValue = pEnv->GetMethodID(classInteger, "intValue", "()I"); 00275 00276 jclass tempClassShort = pEnv->FindClass("java/lang/Short"); 00277 classShort = (jclass)pEnv->NewGlobalRef(tempClassShort); 00278 methShortValueOf = 00279 pEnv->GetStaticMethodID(classShort, "valueOf", "(S)Ljava/lang/Short;"); 00280 methShortValue = pEnv->GetMethodID(classShort, "shortValue", "()S"); 00281 00282 jclass tempClassDouble = pEnv->FindClass("java/lang/Double"); 00283 classDouble = (jclass)pEnv->NewGlobalRef(tempClassDouble); 00284 methDoubleValueOf = 00285 pEnv->GetStaticMethodID( 00286 classDouble, "valueOf", "(D)Ljava/lang/Double;"); 00287 methDoubleValue = pEnv->GetMethodID(classDouble, "doubleValue", "()D"); 00288 00289 jclass tempClassFloat = pEnv->FindClass("java/lang/Float"); 00290 classFloat = (jclass)pEnv->NewGlobalRef(tempClassFloat); 00291 methFloatValueOf = 00292 pEnv->GetStaticMethodID(classFloat, "valueOf", "(F)Ljava/lang/Float;"); 00293 methFloatValue = pEnv->GetMethodID(classFloat, "floatValue", "()F"); 00294 00295 jclass tempClassBoolean = pEnv->FindClass("java/lang/Boolean"); 00296 classBoolean = (jclass)pEnv->NewGlobalRef(tempClassBoolean); 00297 methBooleanValueOf = 00298 pEnv->GetStaticMethodID( 00299 classBoolean, "valueOf", "(Z)Ljava/lang/Boolean;"); 00300 methBooleanValue = pEnv->GetMethodID(classBoolean, "booleanValue", "()Z"); 00301 00302 methBase64Decode = pEnv->GetStaticMethodID( 00303 classRhBase64,"decode","(Ljava/lang/String;)[B"); 00304 methRandomUUID = pEnv->GetStaticMethodID( 00305 classUUID,"randomUUID","()Ljava/util/UUID;"); 00306 00307 methFarragoTransformInit = pEnv->GetMethodID( 00308 classFarragoTransform, "init", 00309 "(Lnet/sf/farrago/runtime/FarragoRuntimeContext;Ljava/lang/String;[Lnet/sf/farrago/runtime/FarragoTransform$InputBinding;)V"); 00310 methFarragoTransformExecute = pEnv->GetMethodID( 00311 classFarragoTransform, "execute", "(Ljava/nio/ByteBuffer;J)I"); 00312 methFarragoTransformRestart = pEnv->GetMethodID( 00313 classFarragoTransform, "restart", "()V"); 00314 methFarragoTransformSetInputFetchTimeout = pEnv->GetMethodID( 00315 classFarragoTransform, "setInputFetchTimeout", "(J)V"); 00316 methFarragoTransformInputBindingCons = 00317 pEnv->GetMethodID( 00318 classFarragoTransformInputBinding, "<init>", 00319 "(Ljava/lang/String;I)V"); 00320 methFarragoRuntimeContextStatementClassForName = 00321 pEnv->GetMethodID( 00322 classFarragoRuntimeContext, 00323 "statementClassForName", 00324 "(Ljava/lang/String;)Ljava/lang/Class;"); 00325 methFarragoRuntimeContextFindFarragoTransform = 00326 pEnv->GetMethodID( 00327 classFarragoRuntimeContext, 00328 "findFarragoTransform", 00329 "(Ljava/lang/String;)Lnet/sf/farrago/runtime/FarragoTransform;"); 00330 00331 jclass tempClassUtil = pEnv->FindClass("org/eigenbase/util/Util"); 00332 classUtil = (jclass) pEnv->NewGlobalRef(tempClassUtil); 00333 methUtilGetStackTrace = pEnv->GetStaticMethodID( 00334 classUtil, "getStackTrace", 00335 "(Ljava/lang/Throwable;)Ljava/lang/String;"); 00336 00337 return jniVersion; 00338 }
void JniUtil::configure | ( | const JniUtilParams & | params | ) | [static] |
Configure run-time JNI features, such as whether or not JNI handles are traced.
JniUtil | configuration parameters |
Definition at line 158 of file JniUtil.cpp.
References closeHandleCountTraceOnZero, handleCountTraceStream, JniUtilParams::jniHandleTraceFile, and traceHandleCountEnabled.
Referenced by CmdInterpreter::visit().
00159 { 00160 // Check if the stream is already open. During unit tests Fennel is 00161 // sometimes stopped and restarted in a single process. Flag an error 00162 // if this happens, it means the previous shutdown failed. 00163 if (handleCountTraceStream.is_open()) { 00164 assert(false); 00165 00166 // Non-debug builds: clean up 00167 handleCountTraceStream 00168 << "ERROR: trace stream already open" << std::endl; 00169 handleCountTraceStream.flush(); 00170 handleCountTraceStream.close(); 00171 traceHandleCountEnabled = false; 00172 closeHandleCountTraceOnZero = false; 00173 } 00174 00175 if (params.jniHandleTraceFile.length() > 0) { 00176 handleCountTraceStream.open( 00177 params.jniHandleTraceFile.c_str(), std::ios::app); 00178 00179 handleCountTraceStream 00180 << "# Fennel JNI Handle Trace (see //open/util/bin/checkJniHandleTrace.pl)" 00181 << std::endl; 00182 00183 assert(handleCountTraceStream.good()); 00184 00185 traceHandleCountEnabled = true; 00186 closeHandleCountTraceOnZero = false; 00187 } 00188 }
void JniUtil::shutdown | ( | ) | [static] |
Shutdown run-time JNI features, such as JNI handle tracking.
Definition at line 190 of file JniUtil.cpp.
References closeHandleCountTraceOnZero, and traceHandleCountEnabled.
Referenced by CmdInterpreter::DbHandle::~DbHandle().
00191 { 00192 // JavaTraceTarget decrements after DbHandle. Set a flag to close the 00193 // trace stream when the counter hits zero. 00194 if (traceHandleCountEnabled) { 00195 closeHandleCountTraceOnZero = true; 00196 } 00197 }
std::string JniUtil::getClassName | ( | jclass | jClass | ) | [static] |
Calls java.lang.Class.getName().
jClass | the Class of interest |
Definition at line 362 of file JniUtil.cpp.
References methGetClassName, and toStdString().
Referenced by JniProxyVisitTableBase::addMethod(), and getFirstPublicInterfaceName().
00363 { 00364 JniEnvAutoRef pEnv; 00365 jstring jString = reinterpret_cast<jstring>( 00366 pEnv->CallObjectMethod(jClass,methGetClassName)); 00367 assert(jString); 00368 return toStdString(pEnv,jString); 00369 }
std::string JniUtil::getFirstPublicInterfaceName | ( | jclass | jClass | ) | [static] |
Calls java.lang.Class.getInterfaces() and returns result of java.lang.Class.getClassName() for the first public interface returned.
jClass | the Class of interest |
Definition at line 371 of file JniUtil.cpp.
References classModifier, getClassName(), methGetInterfaces, methGetModifiers, and methIsPublic.
Referenced by JniProxy::getInterfaceName().
00372 { 00373 JniEnvAutoRef pEnv; 00374 00375 jobjectArray ifaces = 00376 reinterpret_cast<jobjectArray>( 00377 pEnv->CallObjectMethod(jClass, methGetInterfaces)); 00378 assert(ifaces); 00379 00380 for (jsize i = 0, len = pEnv->GetArrayLength(ifaces); i < len; i++) { 00381 jclass iface = 00382 reinterpret_cast<jclass>( 00383 pEnv->GetObjectArrayElement(ifaces, i)); 00384 assert(iface); 00385 00386 jint modifiers = 00387 pEnv->CallIntMethod(iface, methGetModifiers); 00388 00389 jboolean isPublic = 00390 pEnv->CallStaticBooleanMethod( 00391 classModifier, methIsPublic, modifiers); 00392 00393 if (isPublic) { 00394 return getClassName(iface); 00395 } 00396 } 00397 00398 return std::string("(none)"); 00399 }
std::string JniUtil::toStdString | ( | JniEnvRef | pEnv, | |
jstring | jString | |||
) | [static] |
Converts a Java string to a C++ string.
pEnv | the current thread's JniEnvRef | |
jString | the Java string |
Definition at line 401 of file JniUtil.cpp.
Referenced by JniProxy::constructString(), JniPseudoUuidGenerator::generateUuid(), getClassName(), Java_net_sf_farrago_fennel_FennelStorage_tupleStreamGraphGetInputStreams(), and JavaExcn::JavaExcn().
00402 { 00403 const char *pChars = pEnv->GetStringUTFChars(jString,NULL); 00404 assert(pChars); 00405 std::string str(pChars,pEnv->GetStringUTFLength(jString)); 00406 pEnv->ReleaseStringUTFChars(jString,pChars); 00407 return str; 00408 }
jstring JniUtil::toString | ( | JniEnvRef | pEnv, | |
jobject | jObject | |||
) | [static] |
Calls toString() on a Java object.
pEnv | the current thread's JniEnvRef | |
jObject | object on which to call toString() |
Definition at line 410 of file JniUtil.cpp.
References methToString.
Referenced by JniPseudoUuidGenerator::generateUuid(), ProxyReshapeStreamDef::getCompareOp(), ProxySortingStreamDef::getDistinctness(), ProxyIndexWriterDef::getDistinctness(), ProxyIndexLoaderDef::getDistinctness(), ProxyAggInvocation::getFunction(), ProxyBarrierStreamDef::getReturnMode(), and ProxyLcsRowScanStreamDef::getSamplingMode().
00411 { 00412 return reinterpret_cast<jstring>( 00413 pEnv->CallObjectMethod(jObject,methToString)); 00414 }
jobject JniUtil::getIter | ( | JniEnvRef | pEnv, | |
jobject | jCollection | |||
) | [static] |
Calls java.util.Collection.iterator().
pEnv | the JniEnvRef for the current thread | |
jCollection | the Java collection |
Definition at line 426 of file JniUtil.cpp.
References methIterator.
Referenced by ProxyAggStreamDef::getAggInvocation(), ProxyTupleAccessor::getAttrAccessor(), ProxyTupleDescriptor::getAttrDescriptor(), ProxyTupleProjection::getAttrProjection(), ProxyLcsRowScanStreamDef::getClusterScan(), ProxyFlatFileTupleStreamDef::getColumn(), ProxyCorrelationJoinStreamDef::getCorrelations(), ProxyBarrierStreamDef::getDynamicParameter(), ProxyExecutionStreamDef::getDynamicParamUse(), ProxyLbmSplicerStreamDef::getIndexAccessor(), ProxyTableWriterDef::getIndexWriter(), ProxyExecutionStreamDef::getInputFlow(), ProxyNestedLoopJoinStreamDef::getLeftJoinKey(), ProxyExecutionStreamDef::getOutputFlow(), ProxyCmdOpenDatabase::getParams(), ProxyWindowDef::getPartition(), ProxyReshapeStreamDef::getReshapeParameter(), ProxyIndexSearchDef::getSearchKeyParameter(), ProxyCmdPrepareExecutionStreamGraph::getStreamDefs(), and ProxyWindowStreamDef::getWindow().
00427 { 00428 return pEnv->CallObjectMethod(jCollection,methIterator); 00429 }
jobject JniUtil::getNextFromIter | ( | JniEnvRef | pEnv, | |
jobject | jIter | |||
) | [static] |
Calls java.util.Iterator.hasNext/next().
pEnv | the JniEnvRef for the current thread | |
jIter | the iterator to advance |
Definition at line 431 of file JniUtil.cpp.
References methHasNext, and methNext.
Referenced by JniProxyIter< T >::operator++().
00432 { 00433 if (!pEnv->CallBooleanMethod(jIter,methHasNext)) { 00434 return NULL; 00435 } 00436 return pEnv->CallObjectMethod(jIter,methNext); 00437 }
uint JniUtil::lookUpEnum | ( | std::string * | pSymbols, | |
std::string const & | symbol | |||
) | [static] |
Looks up an enum value.
pSymbols | array of enum symbols, terminated by empty string | |
symbol | symbol to look up |
Definition at line 416 of file JniUtil.cpp.
Referenced by ProxyReshapeStreamDef::getCompareOp(), ProxySortingStreamDef::getDistinctness(), ProxyIndexWriterDef::getDistinctness(), ProxyIndexLoaderDef::getDistinctness(), ProxyAggInvocation::getFunction(), ProxyBarrierStreamDef::getReturnMode(), and ProxyLcsRowScanStreamDef::getSamplingMode().
00417 { 00418 for (uint i = 0; ; ++i) { 00419 assert(pSymbols[i].size()); 00420 if (pSymbols[i] == symbol) { 00421 return i; 00422 } 00423 } 00424 }
void JniUtil::detachJavaEnv | ( | ) | [static] |
Detaches the JNIEnv for the current thread (undoes effect of getAttachedJavaEnv in the case where needDetach received true).
Definition at line 356 of file JniUtil.cpp.
References pVm.
Referenced by JavaTraceTarget::onThreadEnd(), JavaThreadTracker::onThreadEnd(), and JniEnvAutoRef::~JniEnvAutoRef().
00357 { 00358 jint rc = pVm->DetachCurrentThread(); 00359 assert(rc == 0); 00360 }
void JniUtil::incrementHandleCount | ( | const char * | pType, | |
const void * | pHandle | |||
) | [static] |
Increment the handle count.
The handle type is used for JNI handle tracing. It indicates the type of handle that was created and must match the corresponding call to decrementHandleCount. Use a string constant whenever possible to avoid degrading performance.
pType | handle type description | |
pHandle | handle's memory location |
Definition at line 439 of file JniUtil.cpp.
References handleCount, and traceHandleCount().
Referenced by CmdInterpreter::beginTxn(), Java_net_sf_farrago_fennel_FennelStorage_newExecutionHandle(), Java_net_sf_farrago_fennel_FennelStorage_newObjectHandle(), JavaErrorTarget::JavaErrorTarget(), JavaTraceTarget::JavaTraceTarget(), and CmdInterpreter::visit().
00440 { 00441 ++handleCount; 00442 00443 traceHandleCount("INC", pType, pHandle); 00444 }
void JniUtil::decrementHandleCount | ( | const char * | pType, | |
const void * | pHandle | |||
) | [static] |
Decrement the handle count.
The handle type is used for JNI handle tracing. It indicates the type of handle that was destroyed and must match the value used in the corresponding call to incrementHandleCount. Use a string constant for the type whenever possible to avoid degrading performance.
pType | handle type description | |
pHandle | handle's memory location |
Definition at line 446 of file JniUtil.cpp.
References handleCount, and traceHandleCount().
Referenced by Java_net_sf_farrago_fennel_FennelStorage_deleteExecutionHandle(), Java_net_sf_farrago_fennel_FennelStorage_deleteObjectHandle(), CmdInterpreter::DbHandle::~DbHandle(), JavaErrorTarget::~JavaErrorTarget(), JavaTraceTarget::~JavaTraceTarget(), CmdInterpreter::StreamGraphHandle::~StreamGraphHandle(), and CmdInterpreter::TxnHandle::~TxnHandle().
00447 { 00448 --handleCount; 00449 00450 assert(handleCount >= 0); 00451 00452 traceHandleCount("DEC", pType, pHandle); 00453 }
static int JniUtil::getHandleCount | ( | ) | [inline, static] |
Retrieve the current handle count.
Definition at line 565 of file JniUtil.h.
Referenced by Java_net_sf_farrago_fennel_FennelStorage_getHandleCount().
00566 { 00567 return handleCount; 00568 }
std::string JniUtil::getXmi | ( | const TupleDescriptor & | tupleDesc | ) | [static] |
Constructs a FemTupleDescriptor xmi string.
Definition at line 473 of file JniUtil.cpp.
00474 { 00475 std::ostringstream oss; 00476 oss << "<XMI xmi.version = '1.2' " 00477 << "xmlns:FEMFennel = 'org.omg.xmi.namespace.FEMFennel'>" << std::endl; 00478 oss << "<XMI.content>" << std::endl; 00479 oss << "<FEMFennel:TupleDescriptor>" << std::endl; 00480 for (uint i = 0; i < tupleDescriptor.size(); ++i) { 00481 TupleAttributeDescriptor const &attrDescriptor = 00482 tupleDescriptor[i]; 00483 oss << "<FEMFennel:TupleDescriptor.AttrDescriptor>"; 00484 oss << "<FEMFennel:TupleAttrDescriptor "; 00485 oss << "typeOrdinal='"; 00486 oss << attrDescriptor.pTypeDescriptor->getOrdinal(); 00487 oss << "' "; 00488 oss << "isNullable='"; 00489 oss << (attrDescriptor.isNullable ? "true" : "false"); 00490 oss << "' "; 00491 oss << "byteLength='"; 00492 oss << attrDescriptor.cbStorage; 00493 oss << "' "; 00494 oss << "/>" << std::endl; 00495 oss << "</FEMFennel:TupleDescriptor.AttrDescriptor>"; 00496 } 00497 oss << "</FEMFennel:TupleDescriptor>" << std::endl; 00498 oss << "</XMI.content>" << std::endl; 00499 oss << "</XMI>" << std::endl; 00500 std::string s = oss.str(); 00501 return s; 00502 }
ThreadTracker & JniUtil::getThreadTracker | ( | ) | [static] |
Definition at line 504 of file JniUtil.cpp.
References threadTracker.
Referenced by CmdInterpreter::visit().
00505 { 00506 return threadTracker; 00507 }
friend class JniEnvAutoRef [friend] |
JavaVM * JniUtil::pVm [static, private] |
Loaded JavaVM instance.
For now we can only deal with one at a time.
Definition at line 203 of file JniUtil.h.
Referenced by detachJavaEnv(), getAttachedJavaEnv(), and init().
jmethodID JniUtil::methGetClassName [static, private] |
java.lang.Class.getName()
Definition at line 208 of file JniUtil.h.
Referenced by getClassName(), and init().
jmethodID JniUtil::methGetInterfaces [static, private] |
java.lang.Class.getInterfaces()
Definition at line 213 of file JniUtil.h.
Referenced by getFirstPublicInterfaceName(), and init().
jmethodID JniUtil::methGetModifiers [static, private] |
java.lang.Class.getModifiers()
Definition at line 218 of file JniUtil.h.
Referenced by getFirstPublicInterfaceName(), and init().
jclass JniUtil::classModifier [static, private] |
class java.lang.Modifier
Definition at line 223 of file JniUtil.h.
Referenced by getFirstPublicInterfaceName(), and init().
jmethodID JniUtil::methIsPublic [static, private] |
java.lang.reflect.Modifier.isPublic()
Definition at line 228 of file JniUtil.h.
Referenced by getFirstPublicInterfaceName(), and init().
jmethodID JniUtil::methIterator [static, private] |
jmethodID JniUtil::methHasNext [static, private] |
java.util.Iterator.hasNext()
Definition at line 238 of file JniUtil.h.
Referenced by getNextFromIter(), and init().
jmethodID JniUtil::methNext [static, private] |
java.util.Iterator.next()
Definition at line 243 of file JniUtil.h.
Referenced by getNextFromIter(), and init().
jmethodID JniUtil::methToString [static, private] |
java.lang.Object.toString()
Definition at line 248 of file JniUtil.h.
Referenced by init(), and toString().
AtomicCounter JniUtil::handleCount [static, private] |
Counter for all handles opened by Farrago.
Definition at line 264 of file JniUtil.h.
Referenced by decrementHandleCount(), incrementHandleCount(), and traceHandleCount().
bool JniUtil::traceHandleCountEnabled [static, private] |
Flag indicating whether tracing of handles is enabled.
Should only be set as JniUtil is being initialized.
Definition at line 270 of file JniUtil.h.
Referenced by configure(), shutdown(), and traceHandleCount().
bool JniUtil::closeHandleCountTraceOnZero [static, private] |
Flag indicating that the JNI handle trace stream should be closed when the handle count reaches 0.
Definition at line 276 of file JniUtil.h.
Referenced by configure(), shutdown(), and traceHandleCount().
std::ofstream JniUtil::handleCountTraceStream [static, private] |
Stream for tracing handles opened by Farrago.
Definition at line 281 of file JniUtil.h.
Referenced by configure(), and traceHandleCount().
JavaThreadTracker JniUtil::threadTracker [static, private] |
Tracker for JNI thread attach/detach.
Definition at line 286 of file JniUtil.h.
Referenced by getThreadTracker().
const jint JniUtil::jniVersion = JNI_VERSION_1_2 [static] |
Required JNI version.
Definition at line 298 of file JniUtil.h.
Referenced by getAttachedJavaEnv(), init(), and JNI_OnLoad().
jmethodID JniUtil::methGetJavaStreamHandle [static] |
Java method FennelJavaStreamMap.getJavaStreamHandle.
Definition at line 303 of file JniUtil.h.
Referenced by init(), and JavaSinkExecStream::open().
jmethodID JniUtil::methGetIndexRoot [static] |
Java method FennelJavaStreamMap.getIndexRoot.
Definition at line 308 of file JniUtil.h.
Referenced by CmdInterpreter::StreamGraphHandle::getRoot(), and init().
jmethodID JniUtil::methBase64Decode [static] |
Java method RhBase64.decode.
Definition at line 313 of file JniUtil.h.
Referenced by init(), and ExecStreamFactory::visit().
jclass JniUtil::classRhBase64 [static] |
jmethodID JniUtil::methRandomUUID [static] |
Java method UUID.randomUUID.
Definition at line 319 of file JniUtil.h.
Referenced by JniPseudoUuidGenerator::generateUuid(), and init().
jclass JniUtil::classUUID [static] |
Definition at line 320 of file JniUtil.h.
Referenced by JniPseudoUuidGenerator::generateUuid(), and init().
jmethodID JniUtil::methFarragoTransformInit [static] |
jmethodID JniUtil::methFarragoTransformExecute [static] |
Java method FarragoTransform.execute.
Definition at line 330 of file JniUtil.h.
Referenced by JavaTransformExecStream::execute(), and init().
jmethodID JniUtil::methFarragoTransformSetInputFetchTimeout [static] |
jmethodID JniUtil::methFarragoTransformRestart [static] |
Java method FarragoTransform.restart.
Definition at line 340 of file JniUtil.h.
Referenced by init(), and JavaTransformExecStream::open().
jclass JniUtil::classFarragoTransformInputBinding [static] |
jmethodID JniUtil::methFarragoTransformInputBindingCons [static] |
jmethodID JniUtil::methFarragoRuntimeContextStatementClassForName [static] |
jmethodID JniUtil::methFarragoRuntimeContextFindFarragoTransform [static] |
Java method FarragoRuntimeContext.findFarragoTransform.
Definition at line 360 of file JniUtil.h.
Referenced by init(), and JavaTransformExecStream::open().
jclass JniUtil::classUtil [static] |
Java class org.eigenbase.util.Util.
Definition at line 365 of file JniUtil.h.
Referenced by init(), and JavaExcn::JavaExcn().
jmethodID JniUtil::methUtilGetStackTrace [static] |
Java method org.eigenbase.util.Util.getStackTrace(Throwable).
Definition at line 370 of file JniUtil.h.
Referenced by init(), and JavaExcn::JavaExcn().
jclass JniUtil::classLong [static] |
java.lang.Long
Definition at line 373 of file JniUtil.h.
Referenced by JniProxy::constructJavaLong(), and init().
jclass JniUtil::classInteger [static] |
java.lang.Integer
Definition at line 376 of file JniUtil.h.
Referenced by JniProxy::constructJavaInteger(), and init().
jclass JniUtil::classShort [static] |
java.lang.Short
Definition at line 379 of file JniUtil.h.
Referenced by JniProxy::constructJavaShort(), and init().
jclass JniUtil::classDouble [static] |
java.lang.Double
Definition at line 382 of file JniUtil.h.
Referenced by JniProxy::constructJavaDouble(), and init().
jclass JniUtil::classFloat [static] |
java.lang.Float
Definition at line 385 of file JniUtil.h.
Referenced by JniProxy::constructJavaFloat(), and init().
jclass JniUtil::classBoolean [static] |
java.lang.Boolean
Definition at line 388 of file JniUtil.h.
Referenced by JniProxy::constructJavaBoolean(), and init().
jmethodID JniUtil::methLongValueOf [static] |
java.lang.Long.valueOf(long)
Definition at line 391 of file JniUtil.h.
Referenced by JniProxy::constructJavaLong(), and init().
jmethodID JniUtil::methIntegerValueOf [static] |
java.lang.Integer.valueOf(int)
Definition at line 394 of file JniUtil.h.
Referenced by JniProxy::constructJavaInteger(), and init().
jmethodID JniUtil::methShortValueOf [static] |
java.lang.Short.valueOf(short)
Definition at line 397 of file JniUtil.h.
Referenced by JniProxy::constructJavaShort(), and init().
jmethodID JniUtil::methDoubleValueOf [static] |
java.lang.Double.valueOf(double)
Definition at line 400 of file JniUtil.h.
Referenced by JniProxy::constructJavaDouble(), and init().
jmethodID JniUtil::methFloatValueOf [static] |
java.lang.Float.valueOf(float)
Definition at line 403 of file JniUtil.h.
Referenced by JniProxy::constructJavaFloat(), and init().
jmethodID JniUtil::methBooleanValueOf [static] |
java.lang.Boolean.valueOf(boolean)
Definition at line 406 of file JniUtil.h.
Referenced by JniProxy::constructJavaBoolean(), and init().
jmethodID JniUtil::methLongValue [static] |
java.lang.Long.longValue()
Definition at line 409 of file JniUtil.h.
Referenced by init(), and JniProxy::int64Value().
jmethodID JniUtil::methIntValue [static] |
java.lang.Integer.intValue()
Definition at line 412 of file JniUtil.h.
Referenced by init(), and JniProxy::int32Value().
jmethodID JniUtil::methShortValue [static] |
java.lang.Short.shortValue()
Definition at line 415 of file JniUtil.h.
Referenced by init(), and JniProxy::int16Value().
jmethodID JniUtil::methDoubleValue [static] |
java.lang.Double.doubleValue()
Definition at line 418 of file JniUtil.h.
Referenced by JniProxy::doubleValue(), and init().
jmethodID JniUtil::methFloatValue [static] |
java.lang.Float.floatValue()
Definition at line 421 of file JniUtil.h.
Referenced by JniProxy::floatValue(), and init().
jmethodID JniUtil::methBooleanValue [static] |
java.lang.Boolean.booleanValue()
Definition at line 424 of file JniUtil.h.
Referenced by JniProxy::boolValue(), and init().