Disable can_redefine_classes capability on 'Dalvik' hosts. am: f0f71b9e4d
am: e3361f446a
Change-Id: I59d2d7bde6d9c96f617da0034bd64fe377d30e92
diff --git a/src/share/back/VirtualMachineImpl.c b/src/share/back/VirtualMachineImpl.c
index e856392..dfcdfb2 100644
--- a/src/share/back/VirtualMachineImpl.c
+++ b/src/share/back/VirtualMachineImpl.c
@@ -713,6 +713,9 @@
return JNI_TRUE;
}
+ // ANDROID-CHANGED: We want to adjust the capabilities slightly if we are on android.
+ jboolean is_android_runtime = strcmp(gdata->property_java_vm_name, "Dalvik") == 0;
+
(void)outStream_writeBoolean(out, (jboolean)caps.can_generate_field_modification_events);
(void)outStream_writeBoolean(out, (jboolean)caps.can_generate_field_access_events);
(void)outStream_writeBoolean(out, (jboolean)caps.can_get_bytecodes);
@@ -722,7 +725,11 @@
(void)outStream_writeBoolean(out, (jboolean)caps.can_get_monitor_info);
/* new since JDWP version 1.4 */
- (void)outStream_writeBoolean(out, (jboolean)caps.can_redefine_classes);
+ /* ANDROID-CHANGED: some jdwp clients will send us class files for redefineClasses which we do
+ * not support. Set this capability to false and set reserved32 instead to indicate that we do
+ * support .dex file class redefinition.
+ */
+ (void)outStream_writeBoolean(out, (jboolean)caps.can_redefine_classes && !is_android_runtime);
(void)outStream_writeBoolean(out, (jboolean)JNI_FALSE /* can_add_method */ );
(void)outStream_writeBoolean(out, (jboolean)JNI_FALSE /* can_unrestrictedly_redefine_classes */ );
/* 11: canPopFrames */
@@ -757,7 +764,10 @@
(void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 29 */
(void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 30 */
(void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 31 */
- (void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 32 */
+ /* ANDROID-CHANGED: Use the reserved32 capability to notify clients that we can support dex
+ * class redefinition.
+ */
+ (void)outStream_writeBoolean(out, (jboolean)caps.can_redefine_classes && is_android_runtime);
return JNI_TRUE;
}