ClassFileAnalyzer (Can)
Home

 

Example: TestCanLookupswitch

Test jvm instruction lookupswitch

 

/* TestCanLookupswitch.java */

public class TestCanLookupswitch {
  
  public static void main(String[] args)   {
    int a = 2;
    int b = 0;
    switch (a) {
      case -50: b++; 
                break;
      case 230: b += 2; 
                break;
      case   2: b += 3; 
                break;
      default: b += 5;
    }  
    b--;
  }
}

 

> javac TestCanLookupswitch.java
> java ClassFileAnalyzer TestCanLookupswitch.class

 

; TestCanLookupswitch.j

; Generated by ClassFileAnalyzer (Can)
; Analyzer and Disassembler for Java class files
; (Jasmin syntax 2, http://jasmin.sourceforge.net)
;
; ClassFileAnalyzer, version 0.7.0 


.bytecode 50.0
.source TestCanLookupswitch.java
.class public TestCanLookupswitch
.super java/lang/Object

.method public <init>()V
  .limit stack 1
  .limit locals 1
  .line 3
  0: aload_0
  1: invokespecial java/lang/Object/<init>()V
  4: return
.end method

.method public static main([Ljava/lang/String;)V
  .limit stack 1
  .limit locals 3
  .line 6
  0: iconst_2
  1: istore_1
  .line 7
  2: iconst_0
  3: istore_2
  .line 8
  4: iload_1
  5: lookupswitch
         -50 : Label40
         2 : Label52
         230 : Label46
         default : Label58
Label40:
  .line 9
  40: iinc 2 1
  .line 10
  43: goto Label61
Label46:
  .line 11
  46: iinc 2 2
  .line 12
  49: goto Label61
Label52:
  .line 13
  52: iinc 2 3
  .line 14
  55: goto Label61
Label58:
  .line 15
  58: iinc 2 5
Label61:
  .line 17
  61: iinc 2 -1
  .line 18
  64: return
  ; append_frame (frameNumber = 0)
  ; frame_type = 253, offset_delta = 40
  ; frame bytes: 253 0 40 1 1 
  .stack 
    offset 40
    locals Integer
    locals Integer
    .end stack
  ; same_frame (frameNumber = 1)
  ; frame_type = 5, offset_delta = 5
  ; frame bytes: 5 
  .stack 
    offset 46
    locals Integer
    locals Integer
    .end stack
  ; same_frame (frameNumber = 2)
  ; frame_type = 5, offset_delta = 5
  ; frame bytes: 5 
  .stack 
    offset 52
    locals Integer
    locals Integer
    .end stack
  ; same_frame (frameNumber = 3)
  ; frame_type = 5, offset_delta = 5
  ; frame bytes: 5 
  .stack 
    offset 58
    locals Integer
    locals Integer
    .end stack
  ; same_frame (frameNumber = 4)
  ; frame_type = 2, offset_delta = 2
  ; frame bytes: 2 
  .stack 
    offset 61
    locals Integer
    locals Integer
    .end stack
.end method