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

Reply via email to