Home > Back-end >  Bytecode file about this and super problem, consult bosses to reassure
Bytecode file about this and super problem, consult bosses to reassure

Time:01-20

1. Yesterday and found a instance methods (with no parameters args_size=1, and the static method and no extra args_size, wonder whether instance methods extra properties is this? Then check books (deep understanding of the JVM section 6.3.7) found that's true, then this is a simple local variables, rather than I used to understand a special special existence of tall?
 void m (); 
Descriptor: (a) V
Flags:
Code:
Stack=0, locals=1, args_size=1

2. I found this after I wonder if super also have the treatment again? But after simple experiment found that the treatment of only this one:
 class Father {
Void m () {}
}

The class Son extends Father {
Void m2 () {}
}
 class JVM. Son extends the JVM. Father 
Minor version: 0
Major version: 52
Flags: ACC_SUPER
Constant pool:
# 1=Methodref # 3. # 14//JVM/Father. "& lt; Init>" (V)
# 2=Class # 15//JVM/Son
# 3=Class # 16//JVM/Father
# 4=Utf8 & lt; Init>
# 5=Utf8 (V)
# 6=Utf8 Code
# 7=Utf8 LineNumberTable
# 8=Utf8 LocalVariableTable
# 9=Utf8 this
# 10=Utf8 Ljvm/Son;
# 11=Utf8 m2
# 12=Utf8 SourceFile
# 13=Utf8 Demo2. Java
# 14=NameAndType # 4: # 5//"& lt; Init>" (V)
# 15=Utf8 JVM/Son
# 16=Utf8 JVM/Father
{
The JVM. Son ();
Descriptor: (a) V
Flags:
Code:
Stack=1, locals=1, args_size=1
0: aload_0
1: invokespecial # 1/Method/JVM/Father "& lt; Init>" (V)
4: return
LineNumberTable:
Line 13:0
LocalVariableTable:
Start Length Slot Name Signature
0 5 0 this Ljvm/Son;

Void m2 ();
Descriptor: (a) V
Flags:
Code:
Stack=0, locals=1, args_size=1
0: return
LineNumberTable:
Line 14:0
LocalVariableTable:
Start Length Slot Name Signature
1 0 0 this Ljvm/Son;
}
so what is the super constants (instance or local variables or other)?

CodePudding user response:

The
refer to the original poster 枠 generic response:
so what is the super constants (instance or local variables or other)?



This according to the current instance, super said the father, tell you the local variables and constants it doesn't matter, they are all key words,

CodePudding user response:

Super said the current class of the parent class, super () said the current class of the parent class constructor

CodePudding user response:

1 this is a special pointer points to the current memory area, it can point to the object itself, can also point to the method, the constructor), call member method is will take this method as a parameter to members, non-static code block can use this as well, the inner class can also use this outside class, so it is not what you see, is a local variable,
2 super ditto, just super limit for the pointer to the parent class memory area

  • Related