简体   繁体   中英

Using javassist on oracle weblogic

I've done plenty research on this topic but there's not much on it so this board is my only hope.

I've got a few deplyoments running on oracle weblogic 11c, there's a few things that need to be changed in the deployments code but the catch is that I'm not allowed to change the code I can only use some kind of injection preferably javassist.

I have access to the deployments code, I exactly know which line needs to be changed. What's the best approach, is there any syntax in javassist that allows you to replace a certain line in code?

Have a look here :

Inserting a code fragment at the position specified by a line number is also possible (if the line number table is contained in the class file). insertAt() in CtMethod and CtConstructor takes source text and a line number in the source file of the original class definition. It compiles the source text and inserts the compiled code at the line number.

In other words: the framework you are looking to use seems to support your requirement; the rest is just sitting down and making experiments.

Regarding your comment: then you probably have to bit the bullet and forget about changing a single line; instead, you follow these instructions:

CtMethod and CtConstructor provide setBody() for substituting a whole method body.

Meaning: the frameworks supports adding content to a method; or replacing the whole method; but not replacing parts of the method body.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM