History log of /dalvik/vm/Native.cpp
Revision Date Author Comments
d1839748820ad0766d31ee5a20d190ed07315d23 03-Aug-2013 Elliott Hughes <enh@google.com> Not all shared libraries have a JNI_OnLoad.

Change-Id: Iace5d33cbeafbf8b840bebb4bb709e32053f142d
d04ecb0b450c0c7a059ee355f6aed7c9f65b671e 03-Aug-2013 Elliott Hughes <enh@google.com> Returning JNI_ERR from JNI_OnLoad is still an error!

Fixes a bug introduced in the previous patch.

Change-Id: I34ea63d323a0125c3c4ae140a2ae9b8e9ed3e1df
ff7ff110d17428732a97c37bf31f7f49d194f638 03-Aug-2013 Elliott Hughes <enh@google.com> Check JNI versions handed to JNI and JII functions.

Bug: https://code.google.com/p/android/issues/detail?id=58012
Change-Id: I7b062564573107df54f9e8d71df0e1583d83d421
bab2237924fa26e16f732965657f8ff93ab27f37 27-Sep-2012 Elliott Hughes <enh@google.com> Log if dlopen(3) fails.

It turns out that some apps swallow the UnsatisfiedLinkError, making it
really hard to work out why they failed to launch.

Before:
D dalvikvm: Trying to load lib /data/app-lib/com.adobe.air-1/libCore.so 0x415be8a8
W dalvikvm: No implementation found for native Lcom/adobe/air/AIRWindowSurfaceView;.nativeSurfaceCreated:()V

After:
D dalvikvm: Trying to load lib /data/app-lib/com.adobe.air-1/libCore.so 0x415be8a8
E dalvikvm: dlopen("/data/app-lib/com.adobe.air-1/libCore.so") failed: Cannot load library: soinfo_relocate(linker.cpp:975): cannot locate symbol "_ZN7android10VectorImpl19reservedVectorImpl1Ev" referenced by "libCore.so"...
W dalvikvm: No implementation found for native Lcom/adobe/air/AIRWindowSurfaceView;.nativeSurfaceCreated:()V

(cherry-pick of 6567510ba1470bba6036d2b0b042425bdd03cf2b.)

Bug: 7093208
Change-Id: I4dcdff2ffe49a4897d8f5279d09a0dcc3de70db6
6567510ba1470bba6036d2b0b042425bdd03cf2b 27-Sep-2012 Elliott Hughes <enh@google.com> Log if dlopen(3) fails.

It turns out that some apps swallow the UnsatisfiedLinkError, making it
really hard to work out why they failed to launch.

Before:
D dalvikvm: Trying to load lib /data/app-lib/com.adobe.air-1/libCore.so 0x415be8a8
W dalvikvm: No implementation found for native Lcom/adobe/air/AIRWindowSurfaceView;.nativeSurfaceCreated:()V

After:
D dalvikvm: Trying to load lib /data/app-lib/com.adobe.air-1/libCore.so 0x415be8a8
E dalvikvm: dlopen("/data/app-lib/com.adobe.air-1/libCore.so") failed: Cannot load library: soinfo_relocate(linker.cpp:975): cannot locate symbol "_ZN7android10VectorImpl19reservedVectorImpl1Ev" referenced by "libCore.so"...
W dalvikvm: No implementation found for native Lcom/adobe/air/AIRWindowSurfaceView;.nativeSurfaceCreated:()V

Bug: 7093208
Change-Id: Ib751fb959d49cb872d586f299e62ed6aae783de9
5cc74502e62d99d40f5c7a841a57fafde5e7ed33 20-Jan-2012 Andy McFadden <fadden@android.com> Tweak UnsatisfiedLinkError

Change this:

java.lang.UnsatisfiedLinkError: getSuperclass

to this:

java.lang.UnsatisfiedLinkError: Native method not found:
java.lang.Class.getSuperclass:()Ljava/lang/Class;

Change-Id: I23bd4350caf743ad9ba3524da0a10107c63af56a
c1a4ab9c313d8a3d12007f2dbef7b5a6fa4ac2ef 06-Jan-2012 Steve Block <steveblock@google.com> Rename (IF_)LOGE(_IF) to (IF_)ALOGE(_IF) DO NOT MERGE

See https://android-git.corp.google.com/g/#/c/157220

Also fix an occurrence of LOGW missed in an earlier change.

Bug: 5449033
Change-Id: I2e3b23839e6dcd09015d6402280e9300c75e3406
e8e1ddccd616e8226b7cc1e4e9fdb327429249e8 06-Jan-2012 Steve Block <steveblock@google.com> Rename (IF_)LOGW(_IF) to (IF_)ALOGW(_IF) DO NOT MERGE

See https://android-git.corp.google.com/g/157065

Bug: 5449033
Change-Id: Ia5d301248024df26c2a29dabdfe738e39ec87c82
4308417beec548c2b2c06ecec4f7f4a965b09fb2 04-Jan-2012 Steve Block <steveblock@google.com> Rename (IF_)LOGI(_IF) to (IF_)ALOGI(_IF) DO NOT MERGE

See https://android-git.corp.google.com/g/156801

Bug: 5449033
Change-Id: Ic558031c75b3702d90eb78bd730501ae5d3c077b
062bf509a77fce9dfcb7e7b2e401cf2a124d83d5 20-Dec-2011 Steve Block <steveblock@google.com> Rename (IF_)LOGD(_IF) to (IF_)ALOGD(_IF) DO NOT MERGE

See https://android-git.corp.google.com/g/156016

Bug: 5449033
Change-Id: Ic663376d1ad6a6cb14bf81405ad9afd247cf2f60
92c1f6f1b4249e4e379452ee7b49f027052bf4ce 20-Oct-2011 Steve Block <steveblock@google.com> Rename (IF_)LOGV(_IF) to (IF_)ALOGV(_IF) DO NOT MERGE

See https://android-git.corp.google.com/g/#/c/143865

Bug: 5449033
Change-Id: I8bd96961e369a08e86ff78b82d90f20f42787eb1
a6e94ff55517438569d207e3ed552c8c127bcac9 30-Jun-2011 Elliott Hughes <enh@google.com> Fix native method logging to show local references rather than direct pointers.

This is necessary (but not sufficient) for debugging third-party JNI bugs.
It's the second half of the logging story, but still doesn't address the
question of "how does the developer turn on the logging?".

This removes the variant JNI bridges at the cost of adding a couple of
booleans to struct Method. Performance is about the same, except synchronized
native methods are quite a bit faster after the change.

Before:
benchmark ns linear runtime
_emptyJniMethod0 333 ==========
_emptyJniMethod6 367 ===========
_emptyJniMethod6L 921 ==============================
_emptyJniStaticMethod0 259 ========
_emptyJniStaticMethod6 287 =========
_emptyJniStaticMethod6L 873 ============================
_emptyJniStaticSynchronizedMethod0 404 =============
_emptyJniSynchronizedMethod0 452 ==============

After:
benchmark ns linear runtime
_emptyJniMethod0 344 ==========
_emptyJniMethod6 348 ==========
_emptyJniMethod6L 969 ==============================
_emptyJniStaticMethod0 265 ========
_emptyJniStaticMethod6 293 =========
_emptyJniStaticMethod6L 968 =============================
_emptyJniStaticSynchronizedMethod0 265 ========
_emptyJniSynchronizedMethod0 323 ==========

A better optimization for the case where there are reference arguments
would be to keep a list of argument indexes in the struct Method, so we
could iterate directly over those arguments that need converting to
local references. That would also let us do something about the overhead
of repeatedly looking up which local reference table and cookie to use.

But now is not the time.

Change-Id: Ie32daca1b31be057a44f1ed4b5d28d1634380e1d
5719d5c79558ffdbbb863ddcf61836221aba922d 22-Jun-2011 Elliott Hughes <enh@google.com> Improve -verbose:jni.

The old output just told you what functions were being called and made no
attempt to show you their arguments. The new output was sufficient to debug
an actual problem with an app we don't have the source to.

Still to do:
0. an easier way for third-party developers to enable this.
1. the primitive type arguments to SetIntField and so forth.
2. return values.

A few examples of the new output...

A decoded jclass:
JNI: libcore.io.Posix.readBytes called IsInstanceOf((JNIEnv*)0x9618470, 0x28100015, java.lang.Class<byte[]>)

A decoded jfieldID:
JNI: libcore.io.Posix.ioctlInt called GetIntField((JNIEnv*)0x9618470, 0x5cb00011, java.io.FileDescriptor.descriptor)

A decoded jmethodID (the FileDescriptor constructor):
JNI: libcore.io.Posix.open called NewObject((JNIEnv*)0x9780480, java.lang.Class<java.io.FileDescriptor>, java.io.FileDescriptor.<init>()V, ...)

A const char*:
JNI: libcore.io.Posix.getsockoptLinger called NewStringUTF((JNIEnv*)0x9618470, "getsockopt")

A jint release mode:
JNI: libcore.io.Posix.writeBytes called ReleaseByteArrayElements((JNIEnv*)0x9780480, 0x2700009, (void*) 0xf5f623c4, JNI_ABORT)

The -verbose:jni option now turns on a bit more output about JNI_OnLoad calls
but no longer causes any logging of calls to JNIEnv or JavaVM functions. The
old -Xjnitrace: option has been extended to enable this new tracing for the
native methods that it covers. They go very well together for debugging
purposes.

I've also made us a bit more verbose if we fail to initialize. In the longer
term I think we want to just abort if we hit any failure during startup, but
my extra logging will save us a bit of time next time we have one of these
failures (this one was caused for me by only having one half of the finalizer
watchdog change; I was missing the libcore side).

(Cherry pick of 6734b8224fb869c94e42e704ec03f2ce8483af2b from dalvik-dev.)

Change-Id: I69b7620b20620e9f06576da244520d9d83f89ab8
b08e2b6017770e887f6072c1520b2d7f2ef6916c 07-Jun-2011 Elliott Hughes <enh@google.com> Switch dvmHumanReadableDescriptor over to std::string.

(Prep work before making a change to stack dumps.)

Change-Id: I0af49b920f450fd2611e4b96e717a637483122d6
291c84f60853d30e1c0d79dd08c5e5164f588e26 26-May-2011 Dan Bornstein <danfuzz@android.com> Prefer printf format "%#x" over "0x%x".

I exist to serve.

Change-Id: I8e2880b20eefd466da8515d5b6b0c5cb75d56169
60fc806b679a3655c228b4093058c59941a49cfe 26-May-2011 Dan Bornstein <danfuzz@android.com> Further conservation of newlines.

Friends don't let friends end LOG() strings with newlines.

Change-Id: I5a18c766c90c4ab5f03caa6acd601d34d91beb00
d862faa2ceae186da5518607505eb942d634ced9 28-Apr-2011 Carl Shapiro <cshapiro@google.com> Get rid of uneeded extern, enum, typedef and struct qualifiers.

Change-Id: I236c5a1553a51f82c9bc3eaaab042046c854d3b4
d5c80e06a771bb34336c1ec5b0d9ce8a47ec4244 27-Apr-2011 Elliott Hughes <enh@google.com> Remove the old forcecopy in favor of the new.

Also remove some more half-baked multi-VM cruft, fix command-line
parsing (so -Xforcecopy-fuck-yeah won't work any more), and remove
an unused #define.

Bug: 3412449
Change-Id: If914e23dd3bbcf0ac113a445777e0f550ca05703
1e1433e78f560a01744e870c19c162ab88df9dc1 21-Apr-2011 Carl Shapiro <cshapiro@google.com> Remove unneeded void argument list declarations.

Change-Id: Ica749f6defa890363ec531b29e25bc415dc2cbb9
d5c36b9040bd26a81219a7f399513526f9b46324 16-Apr-2011 Carl Shapiro <cshapiro@google.com> Move the remaining non-compiler VM code into C++.

Change-Id: Id8693208d2741c55a7b0474d1264f2112019d11f