Re-added the obsolete `updateFramework` signature into libmesos-java.so.

This patch converts the implementation of the obsolete 2-parameter
`SchedulerDriver.updateFramework(frameworkInfo, suppressedRoles)`
from a wrapper around the new signature back into a JNI method
that 930c7e98d17e71192dae1d49b4b2217cc2dbd8b2 attempted to remove.

This is needed to keep compatibility between older versions of
`mesos.jar` and newer versions of `libmesos-java.so`.

Review: https://reviews.apache.org/r/72922
diff --git a/src/java/jni/org_apache_mesos_MesosSchedulerDriver.cpp b/src/java/jni/org_apache_mesos_MesosSchedulerDriver.cpp
index 4efde30..afdaa3b 100644
--- a/src/java/jni/org_apache_mesos_MesosSchedulerDriver.cpp
+++ b/src/java/jni/org_apache_mesos_MesosSchedulerDriver.cpp
@@ -21,6 +21,7 @@
 #include <mesos/scheduler.hpp>
 
 #include <stout/foreach.hpp>
+#include <stout/option.hpp>
 #include <stout/result.hpp>
 #include <stout/try.hpp>
 
@@ -1066,17 +1067,12 @@
   return convert<Status>(env, status);
 }
 
-/* Class:     org_apache_mesos_MesosSchedulerDriver
- * Method:    updateFramework
- * Signature: (Lorg/apache/mesos/Protos/FrameworkInfo;Ljava/util/Collection;Lorg/apache/mesos/scheduler/Protos/OfferConstraints;)Lorg/apache/mesos/Protos/Status;
- */
-JNIEXPORT jobject JNICALL
-Java_org_apache_mesos_MesosSchedulerDriver_updateFramework(
+static jobject updateFramework(
     JNIEnv* env,
     jobject thiz,
     jobject jframeworkInfo,
     jobject jsuppressedRoles,
-    jobject jofferConstraints)
+    Option<jobject> jofferConstraints)
 {
   using ::mesos::scheduler::OfferConstraints;
 
@@ -1086,8 +1082,9 @@
   const vector<string> suppressedRoles =
     constructFromIterable<string>(env, jsuppressedRoles);
 
-  ::mesos::scheduler::OfferConstraints offerConstraints =
-    construct<OfferConstraints>(env, jofferConstraints);
+  OfferConstraints offerConstraints = jofferConstraints.isSome()
+      ? construct<OfferConstraints>(env, *jofferConstraints)
+      : OfferConstraints();
 
   jclass clazz = env->GetObjectClass(thiz);
 
@@ -1101,4 +1098,31 @@
   return convert<Status>(env, status);
 }
 
+/* Class:     org_apache_mesos_MesosSchedulerDriver
+ * Method:    updateFramework
+ * Signature: (Lorg/apache/mesos/Protos/FrameworkInfo;Ljava/util/Collection;)Lorg/apache/mesos/Protos/Status;
+ */
+JNIEXPORT jobject JNICALL
+Java_org_apache_mesos_MesosSchedulerDriver_updateFramework(
+    JNIEnv* env, jobject thiz, jobject jframeworkInfo, jobject jsuppressedRoles)
+{
+  return updateFramework(env, thiz, jframeworkInfo, jsuppressedRoles, None());
+}
+
+/* Class:     org_apache_mesos_MesosSchedulerDriver
+ * Method:    updateFrameworkWithConstraints
+ * Signature: (Lorg/apache/mesos/Protos/FrameworkInfo;Ljava/util/Collection;Lorg/apache/mesos/scheduler/Protos/OfferConstraints;)Lorg/apache/mesos/Protos/Status;
+ */
+JNIEXPORT jobject JNICALL
+Java_org_apache_mesos_MesosSchedulerDriver_updateFrameworkWithConstraints(
+    JNIEnv* env,
+    jobject thiz,
+    jobject jframeworkInfo,
+    jobject jsuppressedRoles,
+    jobject jofferConstraints)
+{
+  return updateFramework(
+      env, thiz, jframeworkInfo, jsuppressedRoles, jofferConstraints);
+}
+
 } // extern "C" {
diff --git a/src/java/src/org/apache/mesos/MesosSchedulerDriver.java b/src/java/src/org/apache/mesos/MesosSchedulerDriver.java
index 4fdae33..9be0ec1 100644
--- a/src/java/src/org/apache/mesos/MesosSchedulerDriver.java
+++ b/src/java/src/org/apache/mesos/MesosSchedulerDriver.java
@@ -408,16 +408,34 @@
 
   public native Status reconcileTasks(Collection<TaskStatus> statuses);
 
+  /**
+   * @deprecated Replaced by
+   * {@link #updateFramework(FrameworkInfo, Collection<String>, OfferConstraints)}
+   *
+   * NOTE: The underlying JNI method exists only to maintain compatibility
+   * of newer versions of libmesos-java.so with older versions of mesos.jar
+   */
+  @Deprecated
   public native Status updateFramework(FrameworkInfo frameworkInfo,
-                                       Collection<String> suppressedRoles,
-                                       OfferConstraints offerConstraints);
+                                       Collection<String> suppressedRoles);
 
   public Status updateFramework(FrameworkInfo frameworkInfo,
-                                Collection<String> suppressedRoles) {
-    return updateFramework(
-        frameworkInfo, suppressedRoles, OfferConstraints.getDefaultInstance());
+                                Collection<String> suppressedRoles,
+                                OfferConstraints offerConstraints) {
+    return updateFrameworkWithConstraints(
+        frameworkInfo, suppressedRoles, offerConstraints);
   }
 
+  /*
+   * NOTE: This method exists only because an `updateFramework()` signature
+   * with added offer constraints needs to have a different name, due to the
+   * `extern "C"` linkage of JNI method implementations.
+   */
+  private native Status updateFrameworkWithConstraints(
+      FrameworkInfo frameworkInfo,
+      Collection<String> suppressedRoles,
+      OfferConstraints offerConstraints);
+
   protected native void initialize();
   protected native void finalize();