class DCRContextImplementation implements DCRContext {

  public static DCRContextImplementation create(Logger logger) {
    final Instrumentation instrumentation =
      ExposeInstrumentation.getInstrumentation();

    try {
      final Method m =
        Instrumentation.class.getMethod("isRetransformClassesSupported");

      if (!(Boolean)m.invoke(instrumentation)) {
        logger.info(
          "Java VM does not support class retransformation, DCR unavailable");

        return null;
      }
    }
    catch (Exception e1) {
      // Also catches case where instrumentation == null.
      logger.info("Java VM does not support instrumentation, DCR unavailable");

      return null;
    }

    return new DCRContextImplementation(instrumentation,
                                        RecorderLocator.class,
                                        RecorderLocator.getRecorderRegistry());
  }

    DCRContextImplementation(Instrumentation instrumentation,
                           Class<?> recorderLocatorClass,
                           RecorderRegistry recorderRegistry);

}