You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-user@hadoop.apache.org by 李光谱 <cs...@gmail.com> on 2015/12/24 19:05:21 UTC

Using Java.lang.instrumentation to print all the classes

Dear All,

I want to print all the classes name executed in one job. But the result is
missing some important classes.
I used hadoop-0.23.1.
I even cannot find  MRAppMaster.
Is anyone here who met the same problem?

The source code is:
public static void premain (String agentArguments, Instrumentation
instrumentation){
        instrumentation.addTransformer(new
SimpleTransformer(agentArguments));

In SimpleTransformer.java:
public byte[] transform (ClassLoader loader, String className, Class
redefiningClass, ProtectionDomain domain, byte[] bytes) throws
IllegalClassFormatException {
            System.out.println("Loading " + className +" from
"+loader.toString());
            /////
            WORK
            /////
    }
Thanks a lot!

Best,
Guangpu