summaryrefslogtreecommitdiffstats
path: root/docs/jni-tips.html
diff options
context:
space:
mode:
authorAndy McFadden <fadden@android.com>2009-09-18 18:16:46 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2009-09-18 18:16:46 -0700
commit4d2cec327c91304574dd15bdb15d1f5c6c6b1c7a (patch)
tree31f00d902d2b204bef1f5e4d99b0aa9e9d932b60 /docs/jni-tips.html
parent87f9189e9da0e4a441c55df02c9028d4002ae3d4 (diff)
parent0f117a580d22e6f68a6fb821e6cbc8c67389e8de (diff)
downloadandroid_dalvik-4d2cec327c91304574dd15bdb15d1f5c6c6b1c7a.tar.gz
android_dalvik-4d2cec327c91304574dd15bdb15d1f5c6c6b1c7a.tar.bz2
android_dalvik-4d2cec327c91304574dd15bdb15d1f5c6c6b1c7a.zip
am 0f117a58: am c7659ec1: Various minor changes to Dalvik documentation.
Merge commit '0f117a580d22e6f68a6fb821e6cbc8c67389e8de' * commit '0f117a580d22e6f68a6fb821e6cbc8c67389e8de': Various minor changes to Dalvik documentation.
Diffstat (limited to 'docs/jni-tips.html')
-rw-r--r--docs/jni-tips.html16
1 files changed, 12 insertions, 4 deletions
diff --git a/docs/jni-tips.html b/docs/jni-tips.html
index 002fcb7e5..eb0ab2254 100644
--- a/docs/jni-tips.html
+++ b/docs/jni-tips.html
@@ -169,6 +169,13 @@ for example, the return values from consecutive calls to
you must use the <code>IsSameObject</code> function.</strong> Never compare
references with "==" in native code.
</p><p>
+One consequence of this is that you
+<strong>must not assume object references are constant</strong>
+in native code. The 32-bit value representing an object may be different
+from one invocation of a method to the next, and it's possible that two
+different objects could have the same 32-bit value at different times. Do
+not use jobjects as keys.
+</p><p>
Programmers are required to "not excessively allocate" local references. In practical terms this means
that if you're creating large numbers of local references, perhaps while running through an array of
Objects, you should free them manually with
@@ -312,10 +319,10 @@ We can accomplish the same thing with this:
</p><p>
This accomplishes the same thing, with several advantages:
<ul>
- <li>Requires one JNI call instead of 3, reducing overhead.
+ <li>Requires one JNI call instead of 2, reducing overhead.
<li>Doesn't require pinning or extra data copies.
- <li>Reduces the risk of programmer error -- no need to match up
- <code>Get</code> and <code>Release</code> calls.
+ <li>Reduces the risk of programmer error -- no risk of forgetting
+ to call <code>Release</code> after something fails.
</ul>
</p><p>
Similarly, you can use the <code>Set&lt;Type&gt;ArrayRegion</code> call
@@ -384,7 +391,7 @@ puts a different table of functions into the JavaVM and JNIEnv pointers. These
an extended series of checks before calling the standard implementation.
</p><p>
-Some things that may be verified:
+Some things that may be checked:
</p><p>
</p>
<ul>
@@ -427,6 +434,7 @@ flag. Currently supported values include:
are over-allocated and surrounded with a guard pattern to help identify
code writing outside the buffer, and the contents are erased before the
storage is freed to trip up code that uses the data after calling Release.
+This will have a noticeable performance impact on some applications.
<dt>warnonly
<dd>By default, JNI "warnings" cause the VM to abort. With this flag
it continues on.