3.12 Just Biding Your Time

If you've got time to kill, there's always the nop instruction. It takes no arguments, and it doesn't do anything at all:

 nop                 ; Do nothing 

It is useful as a spacefiller during the code-generation process when writing bytecodes directly rather than using Oolong. Because the operation doesn't do anything, you can reserve space in the class file you are building with a number of nops. Later, you can go back and replace the nops with operations that actually do something. If you don't replace them, then the correctness of your program is not affected, because the nops do nothing.

Of course, this works only when you are assembling class files. Once the class has been loaded into memory, it cannot be changed.

Programming for the Java Virtual Machine
Programming for the Javaв„ў Virtual Machine
ISBN: 0201309726
EAN: 2147483647
Year: 1998
Pages: 158
Authors: Joshua Engel

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net