[英]How many bytes of bytecode has a particular method in Java?
I recently read on Jon Masamitsu's Weblog that huge methods (8000 bytes of bytecode) are not JIT compiled with HotSpot. 我最近在Jon Masamitsu的Weblog上看到,大量的方法(8000字节的字节码)不是用HotSpot进行JIT编译的。
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. JIT编译器当然似乎知道。 Can I extract this piece of information from the
.class
file? 我可以从
.class
文件中提取这条信息吗?
You can use javap -c mypackage.MyClass
to dump the bytecode of your class (and see the size of each method) 您可以使用
javap -c mypackage.MyClass
转储类的字节码(并查看每个方法的大小)
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.
BTW方法中存在65536字节的硬限制。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.