I have the following sample java class that I want to convert to jasmin:
public class JavaModel {
public int main() {
int a = 0;
int b = 5;
if(a < b || a < b || a < b || a < b) {
System.out.println("Hi");
}
return 0;
}
}
When I convert it to jasmin with:
javac src/test/java/JavaModel.java
javap -c src/test/java/JavaModel.class > src/test/java/JavaModelOutput
I get the following output:
Compiled from "JavaModel.java"
public class JavaModel {
public JavaModel();
Code:
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return
public int main();
Code:
0: iconst_0
1: istore_1
2: iconst_5
3: istore_2
4: iload_1
5: iload_2
6: if_icmplt 24
9: iload_1
10: iload_2
11: if_icmplt 24
14: iload_1
15: iload_2
16: if_icmplt 24
19: iload_1
20: iload_2
21: if_icmpge 32
24: getstatic
27: ldc
29: invokevirtual
32: iconst_0
33: ireturn
}
Why is line 21 converted like this? Shouldn't it be the same as 6,11,16?
If this line were instead:
then it would jump to line 24 if the
icmpltis true, but it would do the same if it were false. Effectively, it would be a no-op.