How many bytes of bytecode has a particular method in Java?

…衆ロ難τιáo~ 提交于 2019-11-30 16:03:35

问题


I recently read on Jon Masamitsu's Weblog that huge methods (8000 bytes of bytecode) are not JIT compiled with HotSpot.

So my question is: how do I find out (as a programmer) how many bytes of bytecode a particular method has?

The JIT compiler of course seems to know. Can I extract this piece of information from the .class file?


回答1:


You can use javap -c mypackage.MyClass to dump the bytecode of your class (and see the size of each method)

Generally speaking, you should know that a method is too large to read and understand before you hit this limit. IMHO its more a problem for generated code. BTW There is a hard limit of 65536 bytes in a method.



来源:https://stackoverflow.com/questions/11345034/how-many-bytes-of-bytecode-has-a-particular-method-in-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!