The ClassFileTransformer gets invoked by the ClassLoader. A little modification of the transformer from the article you linked, to look like this:
public byte[] transform(ClassLoader loader, String className,
Class redefiningClass, ProtectionDomain domain, byte[] bytes)
throws IllegalClassFormatException {
new RuntimeException("Transformer to Transform Class: " + className)
.printStackTrace(System.out);
return bytes;
}
yields this output:
java.lang.RuntimeException: Transformer to Transform Class: MyMain
at com.javalobby.tnt.instrument.SimpleTransformer.transform(SimpleTransformer.java:14)
at sun.instrument.TransformerManager.transform(Unknown Source)
at sun.instrument.InstrumentationImpl.transform(Unknown Source)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)