code: public static void instrumentClass(Class<?> c, ConstructorCallback<?> sampler)
        throws UnmodifiableClassException {
      // IMPORTANT: Don't forget that other threads may be accessing this
      // class while this code is running.  Specifically, the class may be
      // executed directly after the retransformClasses is called.  Thus, we need
      // to be careful about what happens after the retransformClasses call.
      synchronized (samplerPutAtomicityLock) {
        List<ConstructorCallback<?>> list = samplerMap.get(c);
        if (list == null) {
          CopyOnWriteArrayList<ConstructorCallback<?>> samplerList =
              new CopyOnWriteArrayList<ConstructorCallback<?>>();
          samplerList.add(sampler);
          samplerMap.put(c, samplerList);
          Instrumentation inst = AllocationRecorder.getInstrumentation();
          Class<?>[] cs = new Class<?>[1];
          cs[0] = c;
          inst.retransformClasses(c);
        } else {
          list.add(sampler);
        }
      }
    }
docs: Ensures that the given sampler will be invoked every time a constructor for class c is invoked.
  
  @param c The class to be tracked
  @param sampler the code to be invoked when an instance of c is constructed
  @throws UnmodifiableClassException if c cannot be modified.