@Override
  public byte[] transform(
      ClassLoader loader,
      String className,
      Class<?> classBeingRedefined,
      ProtectionDomain protectionDomain,
      byte[] origBytes) {
    if (!canRewriteClass(className, loader)) {
      return null;
    }

    return instrument(origBytes, loader);
  }
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