Statement v/s Line

"Nikhil C. Khedkar" <[email protected]>
Newsgroups gmane.comp.jakarta.bcel.user,gmane.comp.jakarta.bcel.devel
Message-ID <[email protected]>
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/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.