[prev in list] [next in list] [prev in thread] [next in thread] 

List:       bcel-dev
Subject:    Statement v/s Line
From:       "Nikhil C. Khedkar" <nikhilckhedkar () yahoo ! com>
Date:       2004-02-02 15:54:50
Message-ID: 20040202155450.49089.qmail () web13602 ! mail ! yahoo ! com
[Download RAW message or body]

Hi,
  I have posted the query few days back about putting
in a StringBuffer variable in a class. Here's the code
I could finally manage (though i am still not able to
initialize the static variable at the start only, but
instead I am doing it in every method).
I must say it was a pretty painful process. The APIs
are most of the times NOT documented, which makes the
use of this library totally based on the personal
intution (No kidding, I used to search the
functionality from their names). It doesn't have any
examples. This part should be improved a lot.

//StringBuffer initialization start
InstructionList instrumentedInitList = new
InstructionList();
InstructionFactory iFactory = new
InstructionFactory(cp);
instrumentedInitList.append(iFactory.createNew("java.lang.StringBuffer"));
instrumentedInitList.append(InstructionConstants.DUP);
instrumentedInitList.append(new PUSH(cp, ""));
instrumentedInitList.append(iFactory.createInvoke("java.lang.StringBuffer",
"<init>", Type.VOID,
			   new Type[] { Type.VOID },
Constants.INVOKESPECIAL));

instrumentedInitList.append(iFactory.createPutStatic(java_class.getClassName(),
sFieldName, new
ObjectType("java.lang.StringBuffer")));

instrumentedPatchList.append(instrumentedInitList);
//StringBuffer initialization end

  Ok, now I have one more question, can I get the
statements from the class files? I know we can get the
line numbers, but let's say I want to do something
after every statement is executed
  
  int i = 0;
  int j = 9;
  
  is equal to
  
  int i = 0;int j = 9;
  
If I use the line numbers approach, then both of them
will be treated differently. I basically want to know,
how to get statements from the code fragment

Thanks,
  Nikhil



__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-dev-help@jakarta.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic