结合多个java方法字节码序列 [英] combine multiple java method bytecode sequence

查看:73
本文介绍了结合多个java方法字节码序列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以将多个java方法字节码序列组合为一个方法。假设我们有一个方法A,它调用了另外两个方法B1和B2。

I am wondering whether it is possible to combine multiple java method bytecode sequences into one method. Assume we have a method A, which invokes another two method B1, and B2.

A bytecode sequences: 

.....
invokevirtual B1 
iload ..
....
invokevirtual B2 
.... 

在运行时,B1和B2可能紧密相关,我们希望将B1字节码和B2字节码以及 invokevirtul B1和 invokevirtual B2之间的字节码组合为一种方法。

At runtime, B1 and B2 may be close correlated and we want to combine B1 bytecodes and B2 bytecodes, together with bytecodes between "invokevirtul B1" and "invokevirtual B2", into one method.

我不确定是否可以实施,如果能提供一些线索,我将不胜感激。谢谢。

I am not sure whether it is possible to implement, I would appreciate if some clue can be provided. THanks.

推荐答案

是的,有一些小的限制是可能的。主要限制是单个方法的字节码限制为65535个字节,但实际上您不太可能遇到此限制。单个方法中异常处理程序的数量,局部变量槽和操作数堆栈的大小也受到限制,尽管这些可能性甚至更低。

Yes, it is possible, with a few minor restrictions. The main restriction is that a single method's bytecode is limited to 65535 bytes, but you're unlikely to run into this restriction in practice. The number of exception handlers, local variable slots, and operand stack size in a single method are also limited, though these are even less likely to be reached.

这篇关于结合多个java方法字节码序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆