History log of /art/test/004-JniTest/jni_test.cc
Revision Date Author Comments
ba17f458e20d82b197536d62e1d61c5300da4932 06-May-2016 Mathieu Chartier <mathieuc@google.com> Fix libarttest to be non debug

Previously both libarttest and libarttestd had debug enabled. This
made it hard to know which one was loaded (couldn't look at
kIsDebugBuild).

Fixes test 136 with ART_TEST_RUN_TEST_NDEBUG configuration.

Bug: 28406866

(cherry picked from commit 48b2b3e57e0510f549e9dc5c5a61f50eec697cf5)

Change-Id: I92983f71374b211f96f5b346fec326ea8543f876
3a29a019a885087c10ad10413b299329945d5f32 26-Feb-2016 Alex Light <allight@google.com> Add JNI tests for lambdas

(cherry picked from commit e9d2ca237620b0af28eed9fef52b09bddebdbc6f)

Bug: 27259142

Change-Id: I2a1b31db85dc487c1e6a62609d4497c3a4d4d3a6
e9d2ca237620b0af28eed9fef52b09bddebdbc6f 26-Feb-2016 Alex Light <allight@google.com> Add JNI tests for lambdas

Bug: 27259142

Change-Id: I2a1b31db85dc487c1e6a62609d4497c3a4d4d3a6
7ead0c009c64f1e10aa39e44ea10383dd859d332 22-Feb-2016 Alex Light <allight@google.com> Make JNI work correctly with default methods.

Also adds some tests for JNI and DefaultMethods.

Bug: 27259142
Bug: 24618811

(cherry picked from commit 3612149aee482ab7a17da68b0ef5fef3879729a2)

Change-Id: I31222e3e41059d803be1dbb0f40e1144ac4bf457
3612149aee482ab7a17da68b0ef5fef3879729a2 22-Feb-2016 Alex Light <allight@google.com> Make JNI work correctly with default methods.

Also adds some tests for JNI and DefaultMethods.

Bug: 27259142
Bug: 24618811

Change-Id: I31222e3e41059d803be1dbb0f40e1144ac4bf457
20a0be0299183b54be9643820294e011d3358823 20-Feb-2016 Hiroshi Yamauchi <yamauchi@google.com> Fix CC collector thread flip and JNI critical section deadlocks.

There's a bug in the synchronization between the CC collector's thread
flip and JNI critical sections where it incorrectly attempts to make
the synchronization scheme to be writer (GC) preference to avoid
starvation of GC in the presence of frequent JNI critical section
enter/exit. This could cause a deadlock between them if a thread
enters a nested JNI critical section after a thread flip occurs. This
is reproduced in the added test.

The fix is to use a thread local disable counter in addition to the
global counter to detect a nested enter by the same thread and avoid
waiting if nested.

Bug: 19235243
Bug: 12687968
Change-Id: Idf7720a6906c9ea508219935af3727f76680d2d8
a50f9cf85a3c72376a6f3e4d2e673c08169cffde 25-Sep-2015 Mathieu Chartier <mathieuc@google.com> Fix JIT for class unloading

Keep declaring class of method live to prevent unloading.
Wait for JIT to finish compiling before calling Runtime.gc(), this
prevents flaky failures due to classes not being unloaded.

Bug: 22720414

Change-Id: I9fe5e5e39d681bcd22acc2d2f34b0dbc9887708d
598302ac91fd3e990f50e1aa530c3ad61d6d946e 23-Sep-2015 Mathieu Chartier <mathieuc@google.com> Call JNI_OnUnload when class loaders get collected

Added test case to 141-class-unload.

Bug: 22720414
Change-Id: I0575fae72521520a17587e8b0088bf8112705ad8
997673870a487baa136f1b13f81ae26dd3005e14 11-Jul-2015 Mathieu Chartier <mathieuc@google.com> Fix proxy handling in FindDeclaredVirtualMethod

Added missing GetInterfaceMethodIfProxy and test.

Fixed formatting.

Bug: 22411819
https://code.google.com/p/android-developer-preview/issues/detail?id=2635

(cherry picked from commit 72156e28fd6bc72ac965b29446f8801b2e82f2fd)

Change-Id: I3eece9c72091bb9d0262aacf0a75ec6908b5f4d2
72156e28fd6bc72ac965b29446f8801b2e82f2fd 11-Jul-2015 Mathieu Chartier <mathieuc@google.com> Fix proxy handling in FindDeclaredVirtualMethod

Added missing GetInterfaceMethodIfProxy and test.

Fixed formatting.

Bug: 22411819
https://code.google.com/p/android-developer-preview/issues/detail?id=2635

Change-Id: I3eece9c72091bb9d0262aacf0a75ec6908b5f4d2
22c1caa6fad7846cdf7de30323c6c7dc860b9b03 02-Jun-2015 Mathieu Chartier <mathieuc@google.com> Add more info for attempting to delete non-JNI local reference

Now we print the stack trace of the method which tried to remove the
non-JNI local reference.

Added test, example output:
Attempt to remove non-JNI local reference, dumping thread
"main" prio=5 tid=1 Runnable
| group="main" sCount=0 dsCount=0 obj=0x12c2b400 self=0xf878af28
| sysTid=32662 nice=0 cgrp=default sched=0/0 handle=0xf73df700
| state=R schedstat=( 154297228 636505 121 ) utm=5 stm=10 core=11 HZ=100
| stack=0xff6f2000-0xff6f4000 stackSize=7MB
| held mutexes= "mutator lock"(shared held)
native: #00 pc 00455a7f /out/host/linux-x86/lib/libartd.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::ArtMethod*, void*)+191)
native: #01 pc 00425d79 /out/host/linux-x86/lib/libartd.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+473)
native: #02 pc 0028c555 /out/host/linux-x86/lib/libartd.so (art::IndirectReferenceTable::Remove(unsigned int, void*)+421)
native: #03 pc 003319c8 /out/host/linux-x86/lib/libartd.so (art::JNI::DeleteLocalRef(_JNIEnv*, _jobject*)+56)
native: #04 pc 0012db14 /out/host/linux-x86/lib/libartd.so (art::CheckJNI::DeleteRef(char const*, _JNIEnv*, _jobject*, art::IndirectRefKind)+292)
native: #05 pc 00122176 /out/host/linux-x86/lib/libartd.so (art::CheckJNI::DeleteLocalRef(_JNIEnv*, _jobject*)+54)
native: #06 pc 00005724 /out/host/linux-x86/lib/libarttest.so (Java_Main_removeLocalObject+36)
native: #07 pc 00004d6e /tmp/test-32506/dalvik-cache/x86/tmp@mathieuc@test-32506@004-JniTest.jar@classes.dex (void Main.removeLocalObject(java.lang.Object)+130)
at Main.removeLocalObject(Native method)
at Main.testRemoveLocalObject(Main.java:118)
at Main.main(Main.java:37)

(cherry picked from commit ff6d8cffb7c14eee56df16d1422b1fcc180decde)

Bug: 20683465
Change-Id: I56b99c77ae7020cabf1aaeb1d5317b1d5ba940e5
ff6d8cffb7c14eee56df16d1422b1fcc180decde 02-Jun-2015 Mathieu Chartier <mathieuc@google.com> Add more info for attempting to delete non-JNI local reference

Now we print the stack trace of the method which tried to remove the
non-JNI local reference.

Added test, example output:
Attempt to remove non-JNI local reference, dumping thread
"main" prio=5 tid=1 Runnable
| group="main" sCount=0 dsCount=0 obj=0x12c2b400 self=0xf878af28
| sysTid=32662 nice=0 cgrp=default sched=0/0 handle=0xf73df700
| state=R schedstat=( 154297228 636505 121 ) utm=5 stm=10 core=11 HZ=100
| stack=0xff6f2000-0xff6f4000 stackSize=7MB
| held mutexes= "mutator lock"(shared held)
native: #00 pc 00455a7f /out/host/linux-x86/lib/libartd.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::ArtMethod*, void*)+191)
native: #01 pc 00425d79 /out/host/linux-x86/lib/libartd.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+473)
native: #02 pc 0028c555 /out/host/linux-x86/lib/libartd.so (art::IndirectReferenceTable::Remove(unsigned int, void*)+421)
native: #03 pc 003319c8 /out/host/linux-x86/lib/libartd.so (art::JNI::DeleteLocalRef(_JNIEnv*, _jobject*)+56)
native: #04 pc 0012db14 /out/host/linux-x86/lib/libartd.so (art::CheckJNI::DeleteRef(char const*, _JNIEnv*, _jobject*, art::IndirectRefKind)+292)
native: #05 pc 00122176 /out/host/linux-x86/lib/libartd.so (art::CheckJNI::DeleteLocalRef(_JNIEnv*, _jobject*)+54)
native: #06 pc 00005724 /out/host/linux-x86/lib/libarttest.so (Java_Main_removeLocalObject+36)
native: #07 pc 00004d6e /tmp/test-32506/dalvik-cache/x86/tmp@mathieuc@test-32506@004-JniTest.jar@classes.dex (void Main.removeLocalObject(java.lang.Object)+130)
at Main.removeLocalObject(Native method)
at Main.testRemoveLocalObject(Main.java:118)
at Main.main(Main.java:37)

Bug: 20683465
Change-Id: I56b99c77ae7020cabf1aaeb1d5317b1d5ba940e5
450c62b25f1cd1d1590691902bca30cd844d4844 28-May-2015 Jeff Hao <jeffhao@google.com> Add JNI String.<init> test for global and weak global refs.

Test for change:
https://android-review.googlesource.com/#/c/152265/

(cherry picked from commit 7be83025b62ab499ed8b2b59521f8fbe8e2b13ab)

Change-Id: If10a5fcf7a554d798d2bb21d493e5a7266ed0079
7be83025b62ab499ed8b2b59521f8fbe8e2b13ab 28-May-2015 Jeff Hao <jeffhao@google.com> Add JNI String.<init> test for global and weak global refs.

Test for change:
https://googleplex-android-review.git.corp.google.com/#/c/698642/

Change-Id: I3e1182d42f9e24448d8616000de58ebfe1e50fb8
39b6c24ce68cf05db0f82f454b4401cfb03d675f 20-May-2015 Jeff Hao <jeffhao@google.com> Intercept JNI invocation of String.<init> methods.

libmono uses JNI AllocObject and CallNonvirtualVoidMethod to create and
initialize a string instead of using the recommended NewObject. This
change adds an intercept to change the String.<init> call to a
StringFactory call instead. Then, it uses the object id of the original
string object referrer and maps it to the result of the StringFactory.

Bug: 21288130

(cherry picked from commit 15e9ad1d028d7f12cb598b075453173532a00d91)

Change-Id: I3421c43722c07397da4a398c2ca9110e1d40bcfa
15e9ad1d028d7f12cb598b075453173532a00d91 20-May-2015 Jeff Hao <jeffhao@google.com> Intercept JNI invocation of String.<init> methods.

libmono uses JNI AllocObject and CallNonvirtualVoidMethod to create and
initialize a string instead of using the recommended NewObject. This
change adds an intercept to change the String.<init> call to a
StringFactory call instead. Then, it uses the object id of the original
string object referrer and maps it to the result of the StringFactory.

Bug: 21288130
Change-Id: Ib4db402c178bc37188d5c5faf30b6e4fdc747b17
848f70a3d73833fc1bf3032a9ff6812e429661d9 15-Jan-2014 Jeff Hao <jeffhao@google.com> Replace String CharArray with internal uint16_t array.

Summary of high level changes:
- Adds compiler inliner support to identify string init methods
- Adds compiler support (quick & optimizing) with new invoke code path
that calls method off the thread pointer
- Adds thread entrypoints for all string init methods
- Adds map to verifier to log when receiver of string init has been
copied to other registers. used by compiler and interpreter

Change-Id: I797b992a8feb566f9ad73060011ab6f51eb7ce01
2cebb24bfc3247d3e9be138a3350106737455918 22-Apr-2015 Mathieu Chartier <mathieuc@google.com> Replace NULL with nullptr

Also fixed some lines that were too long, and a few other minor
details.

Change-Id: I6efba5fb6e03eb5d0a300fddb2a75bf8e2f175cb
005f6978d34a3d431193d72fe1cfdd5d0911e8ec 03-Dec-2014 Nicolas Geoffray <ngeoffray@google.com> Don't re-use arttest when calling loadLibrary.

When Android's build environment variables are set with envsetup.sh,
the test "works" ok, by getting a LinkageError because two class loaders
try to load the same library. I guess that is the reason for the
if (ExceptionCheck()) after the loading.

However, if the environment variables are set manually, there are
cases where the paths provided between a Java loadLibrary, and a
native loadLibrary are different, so we end up loading the library twice.
This makes the assertion line 32 fail on the second JNI_OnLoad call.
In my particular environment, ANDROID_BUILD_TOP was something lie
/foo/bar/..//.

This change stops re-using the same library, and makes the expected
outcome constant: the native call of loadLibrary with a non exist
library must throw a LinkageError.

Change-Id: I8721a03715e099c55fb8b2b87813f1e772c8e83d
6a3c1fcb4ba42ad4d5d142c17a3712a6ddd3866f 31-Oct-2014 Ian Rogers <irogers@google.com> Remove -Wno-unused-parameter and -Wno-sign-promo from base cflags.

Fix associated errors about unused paramenters and implict sign conversions.
For sign conversion this was largely in the area of enums, so add ostream
operators for the effected enums and fix tools/generate-operator-out.py.
Tidy arena allocation code and arena allocated data types, rather than fixing
new and delete operators.
Remove dead code.

Change-Id: I5b433e722d2f75baacfacae4d32aef4a828bfe1b
58e5e5d12d5dc55e09088d6bf8d51e4313248a13 08-Sep-2014 Brian Carlstrom <bdc@google.com> Add CallNonvirtual test

Change-Id: If0cbfc587cb8fe5d47fda1149629954080dd0f6f
ab61295e55c38072095e498053b8f5bebf46ad63 14-Aug-2014 Andreas Gampe <agampe@google.com> ART: Fix another potential N-th visitor issue

Bug: 16867274
Change-Id: I5466af563032041ef4a547894f40f303871302c6
61bf6a1c80bf797af5d7911ff71fc367fdb36742 12-Aug-2014 Andreas Gampe <agampe@google.com> ART: Tolerate shallow call stack in VMStack_getCallingClassLoader

When the call stack does not have the three methods we expect,
the visitor will return a nullptr value.

Add a test to JniTest (and refactor the test a little for code reuse).

Bug: 16867274
Change-Id: I5fb8f91f372a41e0bc11ef9f70640834591afa53
0d334ce54efd791da14536b6a16f61d9085b8785 14-Aug-2014 Andreas Gampe <agampe@google.com> ART: Fix another potential N-th visitor issue

Bug: 16867274

(cherry picked from commit ab61295e55c38072095e498053b8f5bebf46ad63)

Change-Id: I5466af563032041ef4a547894f40f303871302c6
718ac65aa78403124c2269f0dcadd341a18b8efe 12-Aug-2014 Andreas Gampe <agampe@google.com> ART: Tolerate shallow call stack in VMStack_getCallingClassLoader

When the call stack does not have the three methods we expect,
the visitor will return a nullptr value.

Add a test to JniTest (and refactor the test a little for code reuse).

Bug: 16867274

(cherry picked from commit 61bf6a1c80bf797af5d7911ff71fc367fdb36742)

Change-Id: I5fb8f91f372a41e0bc11ef9f70640834591afa53
1268b742c8cff7318dc0b5b283cbaeabfe0725ba 11-Jul-2014 Narayan Kamath <narayan@google.com> Fix broken JNI IsAssignableFrom.

The expected argument order was the opposite of what the spec
dictated.

Reported-By: Mikhail Naganov <mnaganov@google.com>
bug: 16531674

Change-Id: I1ebc6d5814ebb4feeb96f3ecdf1a4602da4ba7ce
1c83cbc4a817acbd7f9abb5b29a2d418a958e6a1 23-Jul-2014 Andreas Gampe <agampe@google.com> ART: Make run tests out of oat tests

Transforms all former oat tests into run tests.

Change-Id: I190dd39456454c36e5538a2c044d993965a67533