I am trying to instrument a jar file (main.jar) with javaagent.jar using BCEL. basically where ever I find any aload in bytecode, I m trying to insert a function call to a static function called Fun() in class "someclass" using
if (opcode instanceof aload) {
iFactory.createInvoke("someclass", "fun", Type.VOID, new Type[]{}, Constants.INVOKESTATIC);
my "someclass" class reside in javaagent.jar
on executing
java -javaagent:javaagent.jar -jar main.jar
or
java -javaagent:javaagent.jar -jar main.jar javaagent.jar
or (I created a separate jar for my "someclass" called someclasscontained.jar)
java -cp someclasscontained.jar -javaagent:javaagent.jar -jar main.jar
I am getting
Exception in thread "main" java.lang.NoClassDefFoundError: someclass
error. i tried with -bootclasspath/p option but still not working. does anyone has any clue?
(1) all jar resides in same folder 2) this question may be similar to one question but solution is not correct/satisfactory for that question so please don't mark it duplicate )