예제 #1
0
파일: GWTClass.java 프로젝트: wclaeys/errai
  @Override
  public MetaField getDeclaredField(final String name) {
    JClassType type = getEnclosedMetaObject().isClassOrInterface();
    if (type == null) {
      if ("length".equals(name) && getEnclosedMetaObject().isArray() != null) {
        return new MetaField.ArrayLengthMetaField(this);
      }
      return null;
    }

    JField field = type.findField(name);
    while (field == null
        && (type = type.getSuperclass()) != null
        && !type.getQualifiedSourceName().equals("java.lang.Object")) {
      JField superTypeField = type.findField(name);
      if (!superTypeField.isPrivate()) {
        field = superTypeField;
      }

      for (final JClassType interfaceType : type.getImplementedInterfaces()) {
        field = interfaceType.findField(name);
      }
    }

    if (field == null) {
      throw new RuntimeException("no such field: " + name + " in class: " + this);
    }

    return new GWTField(oracle, field);
  }