ClassFileAnalyzer (Can)
Home

 

Example: TestCanVar

Test directive .var

 

/* TestCanVar.java */

import java.util.*;

public class TestCanVar {
  
  public static void main(String[] args) {
    Vector<Integer> v = new Vector<Integer>();
    v.add(new Integer(3)); 
    Integer i = v.get(0);
    System.out.println(i.toString());
  }  
}

 

> javac -g TestCanVar.java
  --> TestCanVar.class

> java ClassFileAnalyzer TestCanVar.class
  --> TestCanVar.j

 

; TestCanVar.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 TestCanVar.java
.class public TestCanVar
.super java/lang/Object

.method public <init>()V
  .limit stack 1
  .limit locals 1
  .var 0 is this LTestCanVar; from Label0 to Label4
Label0:
  .line 5
  0: aload_0
  1: invokespecial java/lang/Object/<init>()V
Label4:
  4: return
.end method

.method public static main([Ljava/lang/String;)V
  .limit stack 4
  .limit locals 3
  .var 0 is args [Ljava/lang/String; from Label0 to Label40
  ; one line
  .var 1 is v Ljava/util/Vector; signature "Ljava/util/Vector<Ljava/lang/Integer;>;"
          from Label8 to Label40
  .var 2 is i Ljava/lang/Integer; from Label30 to Label40
Label0:
  .line 8
  0: new java/util/Vector
  3: dup
  4: invokespecial java/util/Vector/<init>()V
  7: astore_1
Label8:
  .line 9
  8: aload_1
  9: new java/lang/Integer
  12: dup
  13: iconst_3
  14: invokespecial java/lang/Integer/<init>(I)V
  17: invokevirtual java/util/Vector/add(Ljava/lang/Object;)Z
  20: pop
  .line 10
  21: aload_1
  22: iconst_0
  23: invokevirtual java/util/Vector/get(I)Ljava/lang/Object;
  26: checkcast java/lang/Integer
  29: astore_2
Label30:
  .line 11
  30: getstatic java/lang/System/out Ljava/io/PrintStream;
  33: aload_2
  34: invokevirtual java/lang/Integer/toString()Ljava/lang/String;
  37: invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
Label40:
  .line 12
  40: return
.end method

 

 

 

 

> java Jasmin TestCanVar.j
  --> TestCanVar.class

  

Attributes LocalVariableTable and LocalVariableTypeTabel 
within TestCanVar.class:



method <init>

    (Code_attribute): LocalVariableTable_attribute = 
    0 41 0 0 0 12 0 1 0 0 0 4 0 8 0 49 
    0 0   

    

method main

    (Code_attribute): LocalVariableTable_attribute = 
    0 41 0 0 0 32 0 3 0 0 0 40 0 47 0 25 
    0 0 0 8 0 32 0 45 0 21 0 1 0 30 0 10 
    0 50 0 10 0 2 
    
    (Code_attribute): LocalVariableTypeTable_attribute = 
    0 24 0 0 0 12 0 1 0 8 0 32 0 45 0 14 
    0 1 



Class File Format - Java 6:
    The LocalVariableTypeTable attribute differs from the LocalVariableTable
    attribute in that it provides signature information rather than descriptor 
    information.
    This difference is only significant for variables whose type is a generic 
    reference type. Such variables will appear in both tables, while variables
    of other types will appear only in LocalVariableTable.