Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java bytecode difference between "FRAME FULL" and "FRAME APPEND"

Tags:

java

bytecode

What's a difference between "FRAME FULL" and "FRAME APPEND"? I check 2 ways to use iterators:

int size = 0;
Iterator<String> it = l.iterator();
while (it.hasNext()) {
    String s = it.next();
    int length = s.length();
    size += length;
}

int size = 0;
for (String s : l) {
        int length = s.length();
        size += length;
}

they both use iterators, but bytecode is a bit different.

like image 400
Dainius Avatar asked Dec 30 '25 18:12

Dainius


2 Answers

The frame type append_frame is used when the operand stack is empty and the current locals are the same as the locals in the previous frame, except that k additional locals are defined. Frame type full_frame is used when all other types are not applicably, it is also less compact one.

like image 106
Eugene Kuleshov Avatar answered Jan 02 '26 09:01

Eugene Kuleshov


The first version has an explicit iterator name, i.e. one more local variable. The frames show the start and end of groups of local variables. I assume full means it is describing all local variables, append means it is adding additional local variables.

like image 27
Peter Lawrey Avatar answered Jan 02 '26 09:01

Peter Lawrey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!