public JExpression doRebind(String clsName, ReflectionGeneratorContext params)
      throws UnableToCompleteException {
    // generate
    params.getLogger().log(Type.INFO, "Binding magic class for " + clsName);
    // JType type = params.getClazz().getRefType();
    JDeclaredType type =
        params.getAst().searchForTypeBySource(params.getClazz().getRefType().getName());

    StandardGeneratorContext ctx = params.getGeneratorContext();
    Class<? extends Generator> generator = MagicClassGenerator.class;

    String result =
        ctx.runGenerator(params.getLogger(), generator, SourceUtil.toSourceName(type.getName()));
    ctx.finish(params.getLogger());

    params.getLogger().log(Type.INFO, "Generated Class Enhancer: " + result);
    JDeclaredType success = params.getAst().searchForTypeBySource(result);

    // Okay, we've generated the correct magic class subtype;
    // Now pull off its static accessor method to grab our generated class.

    for (JMethod method : success.getMethods()) {
      if (method.isStatic() && method.getName().equals("enhanceClass")) {
        JMethodCall call = new JMethodCall(method.getSourceInfo(), null, method);
        call.addArg(params.getClazz().makeStatement().getExpr());
        return call;
      }
    }
    params.getLogger().log(Type.ERROR, "Unable to load " + result + ".enhanceClass()");
    throw new UnableToCompleteException();
  }
    @Override
    public JExpression get(String key, ReflectionGeneratorContext params) {
      // because we cache results, super dev mode recompiles need to skip the
      // cache if the magic class does not exist, so we test for that state on every get().

      JDeclaredType type =
          params.getAst().searchForTypeBySource(params.getClazz().getRefType().getName());
      String typeName = JGwtCreate.nameOf(type);
      String generatedName = ReflectionUtilJava.generatedMagicClassName(typeName);
      try {
        params.getAst().searchForTypeBySource(generatedName);
      } catch (NoClassDefFoundError e) {
        removeValue(key);
      }
      return super.get(key, params);
    }