jclass GetClassRef(JNIEnv* aEnv, const char* aClassName) { // First try the default class loader. auto classRef = Class::LocalRef::Adopt(aEnv, aEnv->FindClass(aClassName)); if ((!classRef || aEnv->ExceptionCheck()) && sClassLoader) { // If the default class loader failed but we have an app class loader, try that. // Clear the pending exception from failed FindClass call above. aEnv->ExceptionClear(); classRef = Class::LocalRef::Adopt(aEnv, jclass( aEnv->CallObjectMethod(sClassLoader, sClassLoaderLoadClass, StringParam(aClassName, aEnv).Get()))); } if (classRef && !aEnv->ExceptionCheck()) { return classRef.Forget(); } __android_log_print( ANDROID_LOG_ERROR, "Gecko", ">>> FATAL JNI ERROR! FindClass(\"%s\") failed. " "Does the class require a newer API version? " "Or did ProGuard optimize away something it shouldn't have?", aClassName); aEnv->ExceptionDescribe(); MOZ_CRASH("Cannot find JNI class"); return nullptr; }
//----------------------------------------------------------------------------- bool TestCommandHandle::Parse(const char* params) { static const std::string argCount = "count"; static const std::string argDepth = "depth"; static const std::string argFile = "file"; static const std::string argGain = "gain"; static const std::string argNoClear = "noclear"; static const std::string argPrint = "print"; static const std::string argSkip = "skip"; static const std::string argTime = "time"; noClear = false; printBoard = false; maxCount = 0; maxDepth = 0; minGain = 0; skipCount = 0; maxTime = 0; fileName = ""; bool invalid = false; while (!invalid && params && *NextWord(params)) { if (HasParam(argNoClear, noClear, params) || HasParam(argPrint, printBoard, params) || NumberParam(argCount, maxCount, params, invalid) || NumberParam(argDepth, maxDepth, params, invalid) || NumberParam(argGain, minGain, params, invalid) || NumberParam(argSkip, skipCount, params, invalid) || NumberParam(argTime, maxTime, params, invalid) || StringParam(argFile, fileName, params, invalid)) { continue; } Output() << "Unexpected token: " << params; return false; } if (invalid) { Output() << "usage: " << Usage(); return false; } if (fileName.empty()) { fileName = _TEST_FILE; } return true; }
//----------------------------------------------------------------------------- bool PerftCommandHandle::Parse(const char* params) { static const std::string argCount = "count"; static const std::string argDepth = "depth"; static const std::string argEpd = "epd"; static const std::string argFile = "file"; static const std::string argLeafs = "leafs"; static const std::string argSkip = "skip"; count = 0; skip = 0; maxDepth = 0; maxLeafs = 0; fileName = ""; bool epd = false; bool invalid = false; while (!invalid && params && *NextWord(params)) { if (HasParam(argEpd, epd, params) || NumberParam(argCount, count, params, invalid) || NumberParam(argSkip, skip, params, invalid) || NumberParam(argDepth, maxDepth, params, invalid) || NumberParam(argLeafs, maxLeafs, params, invalid) || StringParam(argFile, fileName, params, invalid)) { continue; } Output() << "Unexpected token: " << params; return false; } if (invalid) { Output() << "usage: " << Usage(); return false; } if (epd && fileName.empty()) { fileName = _TEST_FILE; } return true; }