Search for code and inserting code into a Java bytestream

Huw Evans <[email protected]>
Newsgroups gmane.comp.jakarta.bcel.devel
Message-ID <[email protected]>
Hello,  I am new to BCEL and have a question about searching for code in a 
bytestream and adding code once something has been found.

I would like to search for instances of new for a given type, for example:

  T t = new T();

and substitute the following:

  T t = (T) Utility.create(T.class); // simple case

In the end I would like to be able to handle all cases, e.g., T() takes 
arguments to the constructor, and so will need to be able to pass them to 
create.

However, at the moment, I am finding it difficult to know where to start with 
BCEL to find the point where I should start the bytecode manipulation.

If anyone could point me in the right direction, that would be appreciated.

Thanks

Huw Evans
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.