ClassFileAnalyzer (Can)
Home

 

Example: TestCanInner2

Test directives .inner and .enclosing method

 

/* TestCanInner2.java */

public abstract class TestCanInner2 {
  
  public abstract int multi2(int a);
  
  public static void method1(TestCanInner2 tci2) {
    int c = tci2.multi2(3);
    System.out.println(c);
  }

  public static void main(String[] args) {
    method1(new TestCanInner2() {
                public int multi2(int a) {
                  int b = a * 2;
                  return b;
                }
            });
  }
}

 

> javac TestCanInner2.java
  --> TestCanInner2.class, TestCanInner2$1.class
  
> java ClassFileAnalyzer TestCanInner2.class
> java ClassFileAnalyzer TestCanInner2$1.class

 

; TestCanInner2.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 TestCanInner2.java
.class public abstract TestCanInner2
.super java/lang/Object
.inner class static final inner TestCanInner2$1 ; <anonymous> <not a member>

.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 abstract multi2(I)I
.end method

.method public static method1(LTestCanInner2;)V
  .limit stack 2
  .limit locals 2
  .line 8
  0: aload_0
  1: iconst_3
  2: invokevirtual TestCanInner2/multi2(I)I
  5: istore_1
  .line 9
  6: getstatic java/lang/System/out Ljava/io/PrintStream;
  9: iload_1
  10: invokevirtual java/io/PrintStream/println(I)V
  .line 10
  13: return
.end method

.method public static main([Ljava/lang/String;)V
  .limit stack 2
  .limit locals 1
  .line 13
  0: new TestCanInner2$1
  3: dup
  4: invokespecial TestCanInner2$1/<init>()V
  7: invokestatic TestCanInner2/method1(LTestCanInner2;)V
  .line 19
  10: return
.end method

 

; TestCanInner2$1.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 TestCanInner2.java
.class final TestCanInner2$1
.super TestCanInner2
.enclosing method TestCanInner2/main([Ljava/lang/String;)V
.inner class static final inner TestCanInner2$1 ; <anonymous> <not a member>

.method <init>()V
  .limit stack 1
  .limit locals 1
  .line 13
  0: aload_0
  1: invokespecial TestCanInner2/<init>()V
  4: return
.end method

.method public multi2(I)I
  .limit stack 2
  .limit locals 3
  .line 15
  0: iload_1
  1: iconst_2
  2: imul
  3: istore_2
  .line 16
  4: iload_2
  5: ireturn
.end method