Hi I have follwoing java code,
public class A{
private String B="test_string";
private int AA;
public int C;
private int method1()
{
int a;
a=0;
return a;
}
private int method1(int c, String d)
{
int a;
a=c;
return a;
}
}
but when I used javap -c command to get equivalent byte code I get,
Compiled from "A.java"
public class A extends java.lang.Object{
public int C;
public A();
Code:
0: aload_0
1: invokespecial #1; //Method java/lang/Object."<init>":()V
4: aload_0
5: ldc #2; //String test_string
7: putfield #3; //Field B:Ljava/lang/String;
10: return
}
I am not clear about the byte code here, because where is the private variable and method declarations?
Can anyone explain this to me?
You need the -p
option to show private members:
javap -c -p A
You'll then see everything:
Compiled from "A.java"
public class A {
private java.lang.String B;
private int AA;
public int C;
public A();
Code:
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: aload_0
5: ldc #2 // String test_string
7: putfield #3 // Field B:Ljava/lang/String;
10: return
private int method1();
Code:
0: iconst_0
1: istore_1
2: iload_1
3: ireturn
private int method1(int, java.lang.String);
Code:
0: iload_1
1: istore_3
2: iload_3
3: ireturn
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With