Add class reference in modified method

"P S" <[email protected]> Sat, 2 Feb 2008 12:01:58 -0800
Newsgroups gmane.comp.jakarta.bcel.user
Message-ID <[email protected]>
------=_Part_147_32940717.1201982518157
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

First time BCEL user here, I tried an example from the web where you add a "
System.out.println" to a method.
I was successfully able to build that and it worked fine. Now i want to
modify a bit ... to fetch another static object (like System.out)

I am using BCEL to add an extra like in method. In the code that I am
adding, i have to get a static field from one of my classes (so basically a
static String from com.foo.Myclass)

The specific line of code  is:
instList.append(instructionFactory.createFieldAccess("com.foo.Myclass",
"constString", stringType, Constants.GETSTATIC));

When the modified code is executed at run time, I get a "
java.lang.NoClassDefFoundError: com/foo/Myclass"

I know that my class is in the class path, because it used in some other
class in the code and that works fine.

I even tried adding the class reference to the constantPool
constantPoolGen.addClass(new ObjectType("com.foo.Myclass"));

I close the constant pool and  set it properly (as i did with the
system.outexample which worked fine)

What am I missing? What could be wrong?


Thanks,
Pi

------=_Part_147_32940717.1201982518157--