According to JVM Specification:
The number of methods that may be declared by a class or interface is limited to 65535 by the size of the
methods_count
item of the ClassFile
structure (§4.1). Note that the value of the methods_count
item of the ClassFile
structure does not include methods that are inherited from superclasses or superinterfaces.
nice to know, hope we never see a class with methods_count methods in plain Java :) however for some dynamic JVM languages and some dynamic bytecode processing use cases this limitation might be very relevant.
ReplyDeleteActually, Ivan, each and every class you have seen has exactly methods_count number of methods. :P
ReplyDeleteAlso, which dynamic languages you refer to? I don't see how they could ever hit the limit, in the face of the invokedynamic bytecode. (It would still be hard to believe even without that).
It's also the max number of operations allowed in any one method.
ReplyDeleteHow do I know? Let's just say I've looked after some fairly awesome apps...
There is an limit for max count of statements per method. Don't know the excat limit any more, but i hit the limit some time ago. I tested a semantic loop-unrolling for a masked-based image-processing operation. The masked was controlling the loop-unrolling. And yes, my unrolling was quicker but i often hit this limit :-(
ReplyDelete