ClassFileAnalyzer (Can)
Home

 

Example: TestCanStack2

Test directive .stack

 

/* TestCanStack2.java */

public class TestCanStack2 {
  
  public static void main(String[] args) {
    
    String[] s = new String[3];
    int[] radix = new int[3];
   
    s[0] = "0001100";
    s[1] = "10";
    s[2] = "ff";
    
    radix[0] = 2;
    radix[1] = 10;
    radix[2] = 16;
    
    try {
      for (int i = 0; i < s.length; i++) {
        int j = Integer.parseInt(s[i], radix[i]);
        System.out.println(s[i] + " radix " + radix[i] + " = " + j);
      }
    } catch (IndexOutOfBoundsException e1) {
      System.out.println(e1.toString());
    } catch (NumberFormatException e2) {
      System.out.println(e2.toString());
    }
  }
}

 

> javac TestCanStack2.java
> java ClassFileAnalyzer TestCanStack2.class

 

; TestCanStack2.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 TestCanStack2.java
.class public TestCanStack2
.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 4
  .limit locals 5
  .line 7
  0: iconst_3
  1: anewarray java/lang/String
  4: astore_1
  .line 8
  5: iconst_3
  6: newarray int
  8: astore_2
  .line 10
  9: aload_1
  10: iconst_0
  11: ldc "0001100"
  13: aastore
  .line 11
  14: aload_1
  15: iconst_1
  16: ldc "10"
  18: aastore
  .line 12
  19: aload_1
  20: iconst_2
  21: ldc "ff"
  23: aastore
  .line 14
  24: aload_2
  25: iconst_0
  26: iconst_2
  27: iastore
  .line 15
  28: aload_2
  29: iconst_1
  30: bipush 10
  32: iastore
  .line 16
  33: aload_2
  34: iconst_2
  35: bipush 16
  37: iastore
Label38:
  .line 19
  38: iconst_0
  39: istore_3
Label40:
  40: iload_3
  41: aload_1
  42: arraylength
  43: if_icmpge Label106
  .line 20
  46: aload_1
  47: iload_3
  48: aaload
  49: aload_2
  50: iload_3
  51: iaload
  52: invokestatic java/lang/Integer/parseInt(Ljava/lang/String;I)I
  55: istore 4
  .line 21
  57: getstatic java/lang/System/out Ljava/io/PrintStream;
  60: new java/lang/StringBuilder
  63: dup
  64: invokespecial java/lang/StringBuilder/<init>()V
  67: aload_1
  68: iload_3
  69: aaload
  ; one line
  70: invokevirtual java/lang/StringBuilder/append(Ljava/lang/String;)
      Ljava/lang/StringBuilder;
  73: ldc " radix "
  ; one line
  75: invokevirtual java/lang/StringBuilder/append(Ljava/lang/String;)
      Ljava/lang/StringBuilder;
  78: aload_2
  79: iload_3
  80: iaload
  81: invokevirtual java/lang/StringBuilder/append(I)Ljava/lang/StringBuilder;
  84: ldc " = "
  ; one line
  86: invokevirtual java/lang/StringBuilder/append(Ljava/lang/String;)
      Ljava/lang/StringBuilder;
  89: iload 4
  91: invokevirtual java/lang/StringBuilder/append(I)Ljava/lang/StringBuilder;
  94: invokevirtual java/lang/StringBuilder/toString()Ljava/lang/String;
  97: invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
  .line 19
  100: iinc 3 1
  103: goto Label40
Label106:
  .line 27
  106: goto Label134
Label109:
  .line 23
  109: astore_3
  .line 24
  110: getstatic java/lang/System/out Ljava/io/PrintStream;
  113: aload_3
  ; one line
  114: invokevirtual java/lang/IndexOutOfBoundsException/toString()
       Ljava/lang/String;
  117: invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
  .line 27
  120: goto Label134
Label123:
  .line 25
  123: astore_3
  .line 26
  124: getstatic java/lang/System/out Ljava/io/PrintStream;
  127: aload_3
  128: invokevirtual java/lang/NumberFormatException/toString()Ljava/lang/String;
  131: invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
Label134:
  .line 28
  134: return
  .catch java/lang/IndexOutOfBoundsException from Label38 to Label106 using Label109
  .catch java/lang/NumberFormatException from Label38 to Label106 using Label123
  ; append_frame (frameNumber = 0)
  ; frame_type = 254, offset_delta = 40
  ; frame bytes: 254 0 40 7 0 29 7 0 30 1 
  .stack 
    offset 40
    locals Object [Ljava/lang/String;
    locals Object [I
    locals Integer
    .end stack
  ; chop_frame (frameNumber = 1)
  ; frame_type = 250, offset_delta = 65
  ; frame bytes: 250 0 65 
  .stack 
    offset 106
    locals Object [Ljava/lang/String;
    locals Object [I
    .end stack
  ; same_locals_1_stack_item_frame (frameNumber = 2)
  ; frame_type = 66, offset_delta = 2
  ; frame bytes: 66 7 0 31 
  .stack 
    offset 109
    locals Object [Ljava/lang/String;
    locals Object [I
    stack Object java/lang/IndexOutOfBoundsException
    .end stack
  ; same_locals_1_stack_item_frame (frameNumber = 3)
  ; frame_type = 77, offset_delta = 13
  ; frame bytes: 77 7 0 32 
  .stack 
    offset 123
    locals Object [Ljava/lang/String;
    locals Object [I
    stack Object java/lang/NumberFormatException
    .end stack
  ; same_frame (frameNumber = 4)
  ; frame_type = 10, offset_delta = 10
  ; frame bytes: 10 
  .stack 
    offset 134
    locals Object [Ljava/lang/String;
    locals Object [I
    .end stack
.end method