java - ClassFileTransformer.transform won't execute -


i'm trying transform class @ runtime using java agent-/instrumentation-api. works fine point of transforming, there doesn't invoke transform-method in custom classfiletransformer.

here's of code:

agent.java

public static void agentmain(string args, instrumentation inst) throws exception {      (class c : getclasses(inst)) {          switch (c.getname()) {              //this block excuted             case "avo":                 customtransformer t = new customtransformer();                 inst.addtransformer(t);                 inst.retransformclasses(c);                 inst.removetransformer(t);                 break;          }      }  } 

customtransformer.java

@override public byte[] transform(classloader loader, string classname, class<?> classbeingredefined, protectiondomain protectiondomain, byte[] classfilebuffer) throws illegalclassformatexception {      try {         system.exit(0); //test if block executed          classpool classpool = new classpool();         classpool.appendclasspath(new loaderclasspath(loader));         ctclass cc = classpool.makeclass(new bytearrayinputstream(classfilebuffer));          ctmethod m = cc.getdeclaredmethod("a", new ctclass[] {ctclass.floattype});         m.insertafter("{ f().a(\"test\", 2, 2, -1); }");         return cc.tobytecode();     } catch (exception e) { }      return classfilebuffer; 

}

the can-retransform-classes: true in manifest too.

but application @ try transform doesn't close @ transform, know why transform isn't executed?

thank you


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -