summaryrefslogtreecommitdiff
path: root/include/ScopedJavaUnicodeString.h
diff options
context:
space:
mode:
authorPrzemyslaw Szczepaniak <pszczepaniak@google.com>2017-06-02 13:11:05 +0100
committerPrzemyslaw Szczepaniak <pszczepaniak@google.com>2017-06-27 09:37:04 +0100
commit1a6436a8de0d3dd8e1ec0c6a3a54529468dc298d (patch)
treebc20db791dc112b8643c57855eaebdbabbb6cda3 /include/ScopedJavaUnicodeString.h
parentb5fbb94412be77e84aa910b612b3f608adeb911a (diff)
Fix phantom reference based cleanup of JNI-created buffer
This change allows to safely use PhantomReference to detect if the memory wrapped by buffer created by JNI NewDirectByteBuffer is no longer referenced (and therfore safe to free/reuse/alter). Previously it was not possible without reflection because the buffer could be collected by GC while the MemoryRef that is actually wrapping the memory could be still used in derived buffer (for example, result of asReadOnlyBuffer()). This is mittigated by adding a reference to orinal DirectByteBuffer in the MemoryRef, forcing GC to keep the buffer alive as long as MemoryRef is alive. Test: BufferTest in CtsLibcoreTestCases Bug: 62133955 Change-Id: I06601d8b6b6157114a448d3623c35fbb9d4633a2
Diffstat (limited to 'include/ScopedJavaUnicodeString.h')
0 files changed, 0 insertions, 0 deletions