OSDN Git Service

Don't mutate input in OSMemory.setIntArray/setShortArray.
authorElliott Hughes <enh@google.com>
Wed, 26 Aug 2009 16:37:48 +0000 (09:37 -0700)
committerElliott Hughes <enh@google.com>
Fri, 28 Aug 2009 01:05:55 +0000 (18:05 -0700)
commit5de096c8cc421c89ad36fb1fca0185281b6a04a8
tree472dd8b7d9ea8ecad31f2f758a57b22956950ba9
parent9b44ccfc38c2fc2a6cf2c3cc39a13cc5bce635ba
Don't mutate input in OSMemory.setIntArray/setShortArray.

We now take a copy and then swap bytes in the copy if necessary,
rather than swapping the input, copying, and swapping the input
back.

I've switched to GetShortArrayRegion/GetIntArrayRegion instead
of GetPrimitiveArrayCritical because the latter makes life
unnecessarily hard for the VM/GC, and requires a second JNI call
to undo.

I've also renamed the native functions to match the Java methods
they implement.

(Tested by running the nio tests on the emulator, with added
logging to check that all four variants are called.)

Bug: 2019584
libcore/luni/src/main/native/org_apache_harmony_luni_platform_OSMemory.cpp
libcore/luni/src/test/java/org/apache/harmony/luni/platform/AllTests.java [new file with mode: 0644]
libcore/luni/src/test/java/org/apache/harmony/luni/platform/OSMemoryTest.java [new file with mode: 0644]
libcore/luni/src/test/java/tests/AllTests.java