From b25a5323586a130121237aa1a9da7ca5aa33468e Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Wed, 21 Jun 2017 14:40:12 +0100 Subject: [PATCH] Rename Binder.destroy() to Binder.destroyBinder(). There are a few AIDL-generated stubs that perform "destroy" transactions and call "this.destroy()". Previously, this resolved to the "destroy()" method from their interface on ART while resolving to Binder.destroy() on the RI, though this is a subject of a bug report against the JDK, http://bugs.java.com/bugdatabase/view_bug.do?bug_id=8021581 . Resolving to the private Binder.destroy, inaccessible to the Stub, would lead to throwing IllegalAccessErrror. As we're changing the method lookup to be closer to RI, see https://android-review.googlesource.com/413119 , we should stay clear of the problematic cases whether we make a decision to follow the RI precisely or not. Therefore we rename the Binder.destroy() to Binder.destroyBinder(). Test: Nexus 6P boots. Bug: 62855082 Change-Id: I43baf76b6f3c681d93b411cecf2bc00fccafecac --- core/java/android/os/Binder.java | 4 ++-- core/jni/android_util_Binder.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/java/android/os/Binder.java b/core/java/android/os/Binder.java index 50a3f4c010510..65d05a804c31e 100644 --- a/core/java/android/os/Binder.java +++ b/core/java/android/os/Binder.java @@ -529,7 +529,7 @@ public class Binder implements IBinder { protected void finalize() throws Throwable { try { - destroy(); + destroyBinder(); } finally { super.finalize(); } @@ -559,7 +559,7 @@ public class Binder implements IBinder { } private native final void init(); - private native final void destroy(); + private native final void destroyBinder(); // Entry point from android_util_Binder.cpp's onTransact private boolean execTransact(int code, long dataObj, long replyObj, diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp index 26b00344b789d..e2aa17b32d0b4 100644 --- a/core/jni/android_util_Binder.cpp +++ b/core/jni/android_util_Binder.cpp @@ -836,7 +836,7 @@ static void android_os_Binder_init(JNIEnv* env, jobject obj) env->SetLongField(obj, gBinderOffsets.mObject, (jlong)jbh); } -static void android_os_Binder_destroy(JNIEnv* env, jobject obj) +static void android_os_Binder_destroyBinder(JNIEnv* env, jobject obj) { JavaBBinderHolder* jbh = (JavaBBinderHolder*) env->GetLongField(obj, gBinderOffsets.mObject); @@ -847,7 +847,7 @@ static void android_os_Binder_destroy(JNIEnv* env, jobject obj) } else { // Encountering an uninitialized binder is harmless. All it means is that // the Binder was only partially initialized when its finalizer ran and called - // destroy(). The Binder could be partially initialized for several reasons. + // destroyBinder(). The Binder could be partially initialized for several reasons. // For example, a Binder subclass constructor might have thrown an exception before // it could delegate to its superclass's constructor. Consequently init() would // not have been called and the holder pointer would remain NULL. @@ -872,7 +872,7 @@ static const JNINativeMethod gBinderMethods[] = { { "getThreadStrictModePolicy", "()I", (void*)android_os_Binder_getThreadStrictModePolicy }, { "flushPendingCommands", "()V", (void*)android_os_Binder_flushPendingCommands }, { "init", "()V", (void*)android_os_Binder_init }, - { "destroy", "()V", (void*)android_os_Binder_destroy }, + { "destroyBinder", "()V", (void*)android_os_Binder_destroyBinder }, { "blockUntilThreadAvailable", "()V", (void*)android_os_Binder_blockUntilThreadAvailable } };