title: Error calling updateStateByKey in Spark Streaming
body: <p>I have this generic method in Scala</p>
  <pre><code>def updateStateByKey[S](updateFunc: JFunction2[JList[V], Optional[S],
  Optional[S]])   : JavaPairDStream[K, S] = { ... }
  </code></pre>
  <p>When I call it in Java, both of these does not compile:</p>
  <h1>1</h1>
  <pre><code>JavaPairDStream&lt;String, Integer&gt; stateDstream =
  pairs.&lt;Integer&gt;updateStateByKey(...);
  </code></pre>
  <h1>2</h1>
  <pre><code>JavaPairDStream&lt;String, Integer&gt; stateDstream =
  pairs.updateStateByKey(...);
  </code></pre>
  <p>How do I invoke the method correctly?</p>
  <p>Error messages:</p>
  <pre class="lang-none prettyprint-override"><code>The method updateStateByKey(Function2&lt;List&lt;Integer&gt;,Optional&lt;S&gt;,Optional&lt;S&gt;&gt;,
  int) in the type JavaPairDStream&lt;String,Integer&gt; is not applicable for
  the arguments
  (Function2&lt;List&lt;Integer&gt;,Optional&lt;Integer&gt;,Optional&lt;Integer&gt;&gt;,
  HashPartitioner, JavaPairRDD&lt;String,Integer&gt;)
  </code></pre>
  <p>Edited:
  The whole function call (Java 8):</p>
  <pre><code>final Function2&lt;List&lt;Integer&gt;, Optional&lt;Integer&gt;, Optional&lt;Integer&gt;&gt; updateFunction =
      (values, state) -&gt; {
        Integer newSum = state.or(0);
        for (Integer value : values) {
          newSum += value;
        }
        return Optional.of(newSum);
      };
  
  
  
  JavaPairDStream&lt;String, Integer&gt; stateDstream = pairs.updateStateByKey(
      updateFunction
      ,
      new HashPartitioner(context.defaultParallelism()), initialRDD);
  </code></pre>
  <p>Edited:
  It turned out that generics is not the issue, but the parameters do not match the method signature.</p>