Is java actually doing something with empty statements?
•
Java
The official documents just say
( https://docs.oracle.com/javase/specs/jls/se7/html/jls-14.html#jls -14.6)
Declaration such as;;;;;;;;;;; Actually compiled by the java compiler? If so, do these statements take time to execute, like a NOP? In short: is an empty statement really "doesn't matter"?
Solution
The java compiler does nothing with these statements Therefore, they were ignored
public static void test(){
;;;;;;;;
}
Just compile to the following bytecode:
public static void test();
descriptor: ()V
flags: ACC_PUBLIC,ACC_STATIC
Code:
stack=0,locals=0,args_size=0
0: return
LineNumberTable:
line 39: 0
The compiler uses NOP only in some compilation strategies
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
