title: frida：java.lang.ClassCastException: java.lang.Object[] cannot be cast to android.content.Intent[]
body: <p>problem
  java.lang.ClassCastException: java.lang.Object[] cannot be cast to android.content.Intent[]</p>
  
  <p>code show as below：
  frida-js:</p>
  
  <pre class="lang-js prettyprint-override"><code>var ProcessManagerG = Java.use('com.xxx.xxx.processManager.g')
  var doInBackground = ProcessManagerG.doInBackground.overload('[Ljava.lang.Object;')
  doInBackground.implementation = function (intentArr) {
  
      doInBackground.call(this, intentArr)
  
  }
  </code></pre>
  
  <p>Not a few other ways.Here is all the code.Other code has been removed.</p>
  
  <ol>
  <li>Error: java.lang.ClassCastException: java.lang.Object[] cannot be cast to android.content.Intent[]</li>
  </ol>
  
  <pre class="lang-js prettyprint-override"><code>Java.perform(function () {
      Java.use('com.xxx.xxx.processManager.g').doInBackground.overload('[Ljava.lang.Object;').implementation = function (intentArr) {
          try {
              return this.doInBackground.apply(this, arguments);
          } catch (e) {
              console.log(e)
          }
      }
  })
  </code></pre>
  
  <ol start="2">
  <li>Error: doInBackground(): argument types do not match any of: .overload('[Ljava.lang.Object;')</li>
  </ol>
  
  <pre class="lang-js prettyprint-override"><code>Java.perform(function () {
      Java.use('com.xxx.xxx.processManager.g').doInBackground.overload('[Ljava.lang.Object;').implementation = function (intentArr) {
          try {
              var arr = [];
              for (var i = 0, len = intentArr.length; i &lt; len; i++) {
                  // console.log(arguments[i], Object.prototype.toString.call(arguments[i]))
                  send(intentArr[i]) // {'type': 'send', 'payload': ['&lt;instance: java.lang.Object, $className: android.content.Intent&gt;']}
                  arr.push(Java.cast(intentArr[i], Java.use('android.content.Intent')))
                  send(arr) // {'type': 'send', 'payload': ['&lt;instance: android.content.Intent&gt;']}
              }
              return this.doInBackground.apply(this, arr); // Error: doInBackground(): argument types do not match any of: .overload('[Ljava.lang.Object;')
          } catch (e) {
              console.log(e)
          }
      }
  })
  </code></pre>
  
  <ol start="3">
  <li>Error: doInBackground(): argument types do not match any of: .overload('[Ljava.lang.Object;')</li>
  </ol>
  
  <pre><code>Java.perform(function () {
      Java.use('com.xxx.xxx.processManager.g').doInBackground.overload('[Ljava.lang.Object;').implementation = function (intentArr) {
          try {
              send(intentArr) // {'type': 'send', 'payload': ['&lt;instance: java.lang.Object, $className: android.content.Intent&gt;']}
              var arr = Java.array('Landroid.content.Intent;', intentArr);
              send(arr) // {'type': 'send', 'payload': ['&lt;instance: android.content.Intent&gt;']}
              return this.doInBackground.apply(this, arr); // Error: doInBackground(): argument types do not match any of: .overload('[Ljava.lang.Object;')
          } catch (e) {
              console.log(e)
          }
      }
  })
  </code></pre>
  
  <ol start="4">
  <li>Error: doInBackground(): argument types do not match any of: .overload('[Ljava.lang.Object;')</li>
  </ol>
  
  <pre class="lang-js prettyprint-override"><code>Java.perform(function () {
      Java.use('com.xxx.xxx.processManager.g').doInBackground.overload('[Ljava.lang.Object;').implementation = function (intentArr) {
          try {
              var arr = [];
              for (var i = 0, len = intentArr.length; i &lt; len; i++) {
                  send(intentArr[i]) // {'type': 'send', 'payload': ['&lt;instance: java.lang.Object, $className: android.content.Intent&gt;']}
                  arr.push(Java.cast(intentArr[i], Java.use('android.content.Intent')))
                  send(arr) // {'type': 'send', 'payload': ['&lt;instance: android.content.Intent&gt;']}
              }
              return this.doInBackground(Java.array('java.lang.Object', arr));
          } catch (e) {
              console.log(e)
          }
      }
  })
  </code></pre>
  
  <p>java:</p>
  
  <pre class="lang-java prettyprint-override"><code>public Intent doInBackground(Intent... intentArr) {}
  </code></pre>
  
  <p>smali:</p>
  
  <pre><code>.method protected synthetic doInBackground([Ljava/lang/Object;)Ljava/lang/Object;
      .registers 2
  
      .line 61
      check-cast p1, [Landroid/content/Intent;
  
      invoke-virtual {p0, p1}, Lcom/xxx/xxx/processManager/g;-&gt;a([Landroid/content/Intent;)Landroid/content/Intent;
  
      move-result-object p1
  
      return-object p1
  .end method
  </code></pre>
  
  <p>Thanks for the answer</p>