title: How does DalvikVM handle switch and try smali code
body: <p>I am trying to learn smali and I have a few question that I couldn't find by googling them.</p>
  
  <p>1) I created a simple test case to better explain myself</p>
  
  <pre><code>const-string v1, "Start"
  :try_start_0
  const-string v1, "Try Block"
  invoke-static {v1}, Lcom/example/test/Main;-&gt;print(Ljava/lang/String;)V
  :try_end_0
  .catchall {:try_start_0 .. :try_end_0} :catchall_0
  </code></pre>
  
  <p>The .catch statement: does the two arguments mean take from that label to that label and catch it (the code between the two label) or does it mean start executing the try from :try_start_0 up until it reaches :try_end_0 (allows a goto jump to execute code not within the two labels)?</p>
  
  <p>Is the labels for try always in the format try_start_%d or can they be any label?</p>
  
  <p>2)Another case</p>
  
  <pre><code>packed-switch v0, :pswitch_data_0
  
  const-string v1, "Default Case"
  
  invoke-static {v1}, Lcom/example/test/Main;-&gt;print(Ljava/lang/String;)V
  
  :goto_0
  
  const-string v1, "The End"
  
  invoke-static {v1}, Lcom/example/test/Main;-&gt;print(Ljava/lang/String;)V
  
  return-void
  
  :pswitch_0
  const-string v1, "Case 1"
  
  invoke-static {v1}, Lcom/example/test/Main;-&gt;print(Ljava/lang/String;)V
  
  goto :goto_0
  
  :pswitch_data_0
  .packed-switch 0x1
  :pswitch_0
  .end packed-switch
  </code></pre>
  
  <p>The switch statement: Does it require that the switch statements lie between the switch data and the switch call? and also again the naming of the labels fixed or just that for convenience?</p>
  
  <p>3)If the labels can be different, would baksmali ever produce smali code with different labels?</p>
  
  <p>4)What are the optional lines that aren't always shown when decompiling a dex?</p>
  
  <p>I know .parameter and .line are optional, but what are all the ones that might not be there?</p>
  
  <p>Thank you in advance.</p>