Can I modify the byte code of a Java method in the runtime?

后端 未结 4 945
花落未央
花落未央 2021-01-03 01:18

I am writing a plugin of another large java program .

I want to modify some byte code of some java method of the java program during runtime, so that I can intercept

4条回答
  •  孤街浪徒
    2021-01-03 01:38

    Sorry, but this is not possible. First off, bytecode is immutable after classloading. The JVM provides several APIs that can be used to do something like this, but they are obviously highly privileged.

    If you're running in a low privilege environment like a browser Applet, then you're obviously not going to be allowed to do this, and any method you could should be considered a security vulnerability.

    But the question is why you are using applets in the first place, and why you want to modify code after loading. There's almost certainly a better way to do what you're trying to do.

提交回复
热议问题