static boolean canRewriteClass(String className, ClassLoader loader) {
    // There are two conditions under which we don't rewrite:
    //  1. If className was loaded by the bootstrap class loader and
    //  the agent wasn't (in which case the class being rewritten
    //  won't be able to call agent methods).
    //  2. If it is java.lang.ThreadLocal, which can't be rewritten because the
    //  JVM depends on its structure.
    if (((loader == null) && !canRewriteBootstrap)
        || className.startsWith("java/lang/ThreadLocal")) {
      return false;
    }
    // third_party/java/webwork/*/ognl.jar contains bad class files.  Ugh.
    if (className.startsWith("ognl/")) {
      return false;
    }

    return true;
  }
Instruments bytecodes that allocate heap memory to call a recording hook. This will add a static
invocation to a recorder function to any bytecode that looks like it will be allocating heap
memory allowing users to implement heap profiling schemes.
src/main/java/com/google/monitoring/runtime/instrumentation/AllocationInstrumenter.java