[jboss-user] [Javassist user questions] - How to insrert code directly before/after expression.

solarwind__ do-not-reply at jboss.com
Sat Jun 30 16:28:12 EDT 2007


Hey all, I have a quick question regarding Javassist.

How do I insert an expression directly before/after an expression?

For example, I have a HelloWorld class with a log method that prints out the numbers to screen like this:

1
2
3
5
6

Notice number 4 is missing. I want to be able to insert a log("4"); statement between log("3"); and log("5");

How do I do this?

HelloWorld.java:

public class HelloWorld {
  | 	public static void main(String[] args) {
  | 		log("1");
  | 		log("2");
  | 		log("3");
  | 		log("5");
  | 		log("6");
  | 	}
  | 
  | 	private static void log(Object o) {
  | 		System.out.println(o);
  | 	}
  | }
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4059405#4059405

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4059405



More information about the jboss-user mailing list