Bytecode features not available in the Java language

后端 未结 9 1479
北恋
北恋 2020-12-04 04:28

Are there currently (Java 6) things you can do in Java bytecode that you can\'t do from within the Java language?

I know both are Turing complete, so read \"can do\"

9条回答
  •  感动是毒
    2020-12-04 04:55

    I wrote a bytecode optimizer when I was a I-Play, (it was designed to reduce the code size for J2ME applications). One feature I added was the ability to use inline bytecode (similar to inline assembly language in C++). I managed to reduce the size of a function that was part of a library method by using the DUP instruction, since I need the value twice. I also had zero byte instructions (if you are calling a method that takes a char and you want to pass an int, that you know does not need to be cast I added int2char(var) to replace char(var) and it would remove the i2c instruction to reduce the size of the code. I also made it do float a = 2.3; float b = 3.4; float c = a + b; and that would be converted to fixed point (faster, and also some J2ME did not support floating point).

提交回复
热议问题