How do I replace a class with new one with Java instrumentation?
I need to create a java agent that when is enabled it gets the path to a jar file as argument and then it replaces any loaded class the the one inside the jar file if their names are matched. For example, we have an application with a class called com.something.ClassTest. Now if the mentioned jar (is not in the class path) has a class exactly the same name as com.something.ClassTest, I want to replace it with the one in the jar. I have this class transformer but not sure if that's correct or not. I get IOException with message Class not found. @Override public byte[] transform(ClassLoader