title: Strange assignment, TextView to Bundle, after decompiling, why?
body: <p>I created a simple application, a counter app, that upon pressing a button increments a integer by one and updates a textview. The code can be seen below:</p>
  
  <pre><code>public class MainActivity extends Activity {
      public static int count = 0;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          final TextView textView = (TextView) findViewById(R.id.count);
          textView.setText(Integer.toString(count));
          final Button button = (Button) findViewById(R.id.button);
          button.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  count++;
                  textView.setText(Integer.toString(count));
              }
          });
      }
      ...
  }
  </code></pre>
  
  <p>After decompiling the same app with dex2jar and jd-gui i received the following code back:</p>
  
  <pre><code>public class MainActivity extends Activity {
      public static int count = 0;
  
      protected void onCreate(final Bundle paramBundle) {
          super.onCreate(paramBundle);
          setContentView(2130903040);
          paramBundle = (TextView)findViewById(2131296257);
          paramBundle.setText(Integer.toString(count));
          ((Button)findViewById(2131296256)).setOnClickListener(new View.OnClickListener() {
              public void onClick(View paramAnonymousView) {
                  MainActivity.count += 1;
                  paramBundle.setText(Integer.toString(MainActivity.count));
              }
          });
      }
      ...
  }
  </code></pre>
  
  <p>On the following line:</p>
  
  <pre><code>        paramBundle = (TextView)findViewById(2131296257);
          paramBundle.setText(Integer.toString(count));
  </code></pre>
  
  <p>How is it possible for the system to set the textview to the paramBundle? And why is this happening? paramBundle is of type Bundle and TextView is not a subclass of Bundle, further more Bundle is final according to the decompiled version. Did something go wrong upon decompiling? Is the information from the decompiler wrong or why do we get this result?</p>
  
  <hr>
  
  <p>Edit:</p>
  
  <pre><code># virtual methods
  .method protected onCreate(Landroid/os/Bundle;)V
      .locals 3
      .param p1, "savedInstanceState"    # Landroid/os/Bundle;
  
      .prologue
      .line 17
      invoke-super {p0, p1}, Landroid/app/Activity;-&gt;onCreate(Landroid/os/Bundle;)V
  
      .line 18
      const/high16 v2, 0x7f030000
  
      invoke-virtual {p0, v2}, Lcom/example/rawa/helloworld/MainActivity;-&gt;setContentView(I)V
  
      .line 20
      const v2, 0x7f090001
  
      invoke-virtual {p0, v2}, Lcom/example/rawa/helloworld/MainActivity;-&gt;findViewById(I)Landroid/view/View;
  
      move-result-object v1
  
      check-cast v1, Landroid/widget/TextView;
  
      .line 21
      .local v1, "textView":Landroid/widget/TextView;
      sget v2, Lcom/example/rawa/helloworld/MainActivity;-&gt;count:I
  
      invoke-static {v2}, Ljava/lang/Integer;-&gt;toString(I)Ljava/lang/String;
  
      move-result-object v2
  
      invoke-virtual {v1, v2}, Landroid/widget/TextView;-&gt;setText(Ljava/lang/CharSequence;)V
  
      .line 22
      const/high16 v2, 0x7f090000
  
      invoke-virtual {p0, v2}, Lcom/example/rawa/helloworld/MainActivity;-&gt;findViewById(I)Landroid/view/View;
  
      move-result-object v0
  
      check-cast v0, Landroid/widget/Button;
  
      .line 23
      .local v0, "button":Landroid/widget/Button;
      new-instance v2, Lcom/example/rawa/helloworld/MainActivity$1;
  
      invoke-direct {v2, p0, v1}, Lcom/example/rawa/helloworld/MainActivity$1;-&gt;&lt;init&gt;(Lcom/example/rawa/helloworld/MainActivity;Landroid/widget/TextView;)V
  
      invoke-virtual {v0, v2}, Landroid/widget/Button;-&gt;setOnClickListener(Landroid/view/View$OnClickListener;)V
  
      .line 30
      return-void
  .end method
  </code></pre>
  
  <p>I'm definitely no smali expert, only a novice. But i decoded the application using apktool as well and received the smali code above. From my understanding, the savedinstance (paramBundle) is loaded in to p1(=v3) and used in onCreate, and it is not used in any way in line 20 or 21. To me this point towards a decompling error? Keep in mind that apktool allows for building the application again and thus no data may be lost when decompiling.</p>