Example #1
0
    @CallerSensitive
    public <T> Prop<T> type() {

      Prop on = this;
      if (!isCannon()) {
        Prop<T> already = (Prop<T>) findCannon();
        if (already == null) {
          toCannon();
          on.setCannon();
        } else {
          on = already;
        }
      }

      Class c = sun.reflect.Reflection.getCallerClass(2);

      on.definedInClass = c;

      Field f = null;
      try {
        f = c.getField(name);
      } catch (NoSuchFieldException e) {

        try {
          f = c.getField("_" + name);
        } catch (NoSuchFieldException e3) {
          if (name.startsWith("_"))
            try {
              f = c.getField(name.substring(1));
            } catch (NoSuchFieldException e1) {
              if (name.startsWith("__"))
                try {
                  f = c.getField(name.substring(1));
                } catch (NoSuchFieldException e2) {
                }
            }
        }
      }
      if (f == null)
        throw new IllegalStateException(
            " cannot type a Dict.Prop<T> that we can't find. Name is :" + name + " class is :" + c);

      on.typeInformation = Conversions.linearize(f.getGenericType());

      on.typeInformation.remove(0);

      return (Prop<T>) on;
    }