free(desc);
}
if (dvmIsSynchronizedMethod(method)) {
- LOGE("ERROR: internal-native can't be declared 'synchronized'");
- LOGE("Failing on %s.%s", method->clazz->descriptor, method->name);
+ ALOGE("ERROR: internal-native can't be declared 'synchronized'");
+ ALOGE("Failing on %s.%s", method->clazz->descriptor, method->name);
dvmAbort(); // harsh, but this is VM-internal problem
}
DalvikBridgeFunc dfunc = (DalvikBridgeFunc) infunc;
return;
}
- IF_LOGW() {
+ IF_ALOGW() {
char* desc = dexProtoCopyMethodDescriptor(&method->prototype);
- LOGW("No implementation found for native %s.%s %s",
+ ALOGW("No implementation found for native %s.%s:%s",
clazz->descriptor, method->name, desc);
free(desc);
}
- dvmThrowUnsatisfiedLinkError(method->name);
+ dvmThrowUnsatisfiedLinkError("Native method not found", method);
}
const SharedLib* pLib = (const SharedLib*) ventry;
const SharedLib* pNewLib = (const SharedLib*) vnewEntry;
- LOGD("--- comparing %p '%s' %p '%s'",
+ ALOGD("--- comparing %p '%s' %p '%s'",
pLib, pLib->pathName, pNewLib, pNewLib->pathName);
return strcmp(pLib->pathName, pNewLib->pathName);
}
* Check this so we don't end up waiting for ourselves. We need
* to return "true" so the caller can continue.
*/
- LOGI("threadid=%d: recursive native library load attempt (%s)",
+ ALOGI("threadid=%d: recursive native library load attempt (%s)",
self->threadId, pEntry->pathName);
return true;
}
dvmLockMutex(&pEntry->onLoadLock);
while (pEntry->onLoadResult == kOnLoadPending) {
- LOGD("threadid=%d: waiting for %s OnLoad status",
+ ALOGD("threadid=%d: waiting for %s OnLoad status",
self->threadId, pEntry->pathName);
ThreadStatus oldStatus = dvmChangeStatus(self, THREAD_VMWAIT);
pthread_cond_wait(&pEntry->onLoadCond, &pEntry->onLoadLock);
verbose = verbose && !!strncmp(pathName, "/vendor", sizeof("/vendor")-1);
if (verbose)
- LOGD("Trying to load lib %s %p", pathName, classLoader);
+ ALOGD("Trying to load lib %s %p", pathName, classLoader);
*detail = NULL;
pEntry = findSharedLibEntry(pathName);
if (pEntry != NULL) {
if (pEntry->classLoader != classLoader) {
- LOGW("Shared lib '%s' already opened by CL %p; can't open in %p",
+ ALOGW("Shared lib '%s' already opened by CL %p; can't open in %p",
pathName, pEntry->classLoader, classLoader);
return false;
}
if (verbose) {
- LOGD("Shared lib '%s' already loaded in same CL %p",
+ ALOGD("Shared lib '%s' already loaded in same CL %p",
pathName, classLoader);
}
if (!checkOnLoadResult(pEntry))
if (handle == NULL) {
*detail = strdup(dlerror());
+ ALOGE("dlopen(\"%s\") failed: %s", pathName, *detail);
return false;
}
SharedLib* pActualEntry = addSharedLibEntry(pNewEntry);
if (pNewEntry != pActualEntry) {
- LOGI("WOW: we lost a race to add a shared lib (%s CL=%p)",
+ ALOGI("WOW: we lost a race to add a shared lib (%s CL=%p)",
pathName, classLoader);
freeSharedLibEntry(pNewEntry);
return checkOnLoadResult(pActualEntry);
} else {
if (verbose)
- LOGD("Added shared lib %s %p", pathName, classLoader);
+ ALOGD("Added shared lib %s %p", pathName, classLoader);
- bool result = true;
+ bool result = false;
void* vonLoad;
int version;
vonLoad = dlsym(handle, "JNI_OnLoad");
if (vonLoad == NULL) {
- LOGD("No JNI_OnLoad found in %s %p, skipping init",
- pathName, classLoader);
+ ALOGD("No JNI_OnLoad found in %s %p, skipping init", pathName, classLoader);
+ result = true;
} else {
/*
* Call JNI_OnLoad. We have to override the current class
self->classLoaderOverride = classLoader;
oldStatus = dvmChangeStatus(self, THREAD_NATIVE);
if (gDvm.verboseJni) {
- LOGI("[Calling JNI_OnLoad for \"%s\"]", pathName);
+ ALOGI("[Calling JNI_OnLoad for \"%s\"]", pathName);
}
version = (*func)(gDvmJni.jniVm, NULL);
dvmChangeStatus(self, oldStatus);
self->classLoaderOverride = prevOverride;
- if (version != JNI_VERSION_1_2 && version != JNI_VERSION_1_4 &&
- version != JNI_VERSION_1_6)
- {
- LOGW("JNI_OnLoad returned bad version (%d) in %s %p",
- version, pathName, classLoader);
+ if (version == JNI_ERR) {
+ *detail = strdup(StringPrintf("JNI_ERR returned from JNI_OnLoad in \"%s\"",
+ pathName).c_str());
+ } else if (dvmIsBadJniVersion(version)) {
+ *detail = strdup(StringPrintf("Bad JNI version returned from JNI_OnLoad in \"%s\": %d",
+ pathName, version).c_str());
/*
* It's unwise to call dlclose() here, but we can mark it
* as bad and ensure that future load attempts will fail.
* newly-registered native method calls. We could try to
* unregister them, but that doesn't seem worthwhile.
*/
- result = false;
} else {
- if (gDvm.verboseJni) {
- LOGI("[Returned from JNI_OnLoad for \"%s\"]", pathName);
- }
+ result = true;
+ }
+ if (gDvm.verboseJni) {
+ ALOGI("[Returned %s from JNI_OnLoad for \"%s\"]",
+ (result ? "successfully" : "failure"), pathName);
}
}
* anything.
*/
- LOGD("Unregistering JNI method %s.%s:%s",
+ ALOGD("Unregistering JNI method %s.%s:%s",
meth->clazz->descriptor, meth->name, meth->shorty);
dvmSetNativeFunc(meth, dvmResolveNativeMethod, NULL);
}
*/
static char* mangleString(const char* str, int len)
{
- //LOGI("mangling '%s' %d", str, len);
+ //ALOGI("mangling '%s' %d", str, len);
assert(str[len] == '\0');
static void* lookupSharedLibMethod(const Method* method)
{
if (gDvm.nativeLibs == NULL) {
- LOGE("Unexpected init state: nativeLibs not ready");
+ ALOGE("Unexpected init state: nativeLibs not ready");
dvmAbort();
}
return (void*) dvmHashForeach(gDvm.nativeLibs, findMethodInLib,