/**
   * Parses a field type definition
   *
   * @param docField
   * @return
   */
  protected static Field ParseField(FieldDoc docField) {
    assert (docField != null);

    Field xmlField = new Field();

    xmlField.name = docField.name();
    xmlField.comment = docField.commentText();
    xmlField.type = ParseType(docField.type());
    xmlField.isFinal = docField.isFinal();
    if (xmlField.isFinal) {
      xmlField.finalExpression = docField.constantValueExpression();
    } else if (docField.constantValueExpression() != null) {
      // how would a non-final field have a constant value expression?
      // my understanding is that this field is only != null when is not final
      assert (false);
    }
    xmlField.isStatic = docField.isStatic();
    xmlField.isVolatile = docField.isVolatile();
    xmlField.isTransient = docField.isTransient();
    xmlField.scope = DetermineScope(docField);

    // parse annotations from the field
    xmlField.annotationInstances =
        ParseAnnotationInstances(docField.annotations(), docField.qualifiedName());

    return xmlField;
  }
  private void importField(DbJVClass dbClaz, Field field) throws DbException {
    if (dbClaz == null) {
      return;
    }

    DbJVDataMember member = new DbJVDataMember(dbClaz);
    member.setName(field.getName());

    // set field type
    Type type = field.getType();
    member.setType(toAdt(type));
    member.setTypeUse(toTypeUse(type));

    // set field modifiers
    member.setFinal(field.isFinal());
    member.setStatic(field.isStatic());
    member.setTransient(field.isTransient());
    member.setVisibility(toVisibility(field));
    member.setVolatile(field.isVolatile());
  }
示例#3
0
  public void setValue(Field field, Value value)
      throws InvalidTypeException, ClassNotLoadedException {

    validateMirror(field);
    validateMirrorOrNull(value);
    validateFieldSet(field);

    // More validation specific to setting from a ClassType
    if (!field.isStatic()) {
      throw new IllegalArgumentException("Must set non-static field through an instance");
    }

    try {
      JDWP.ClassType.SetValues.FieldValue[] values = new JDWP.ClassType.SetValues.FieldValue[1];
      values[0] =
          new JDWP.ClassType.SetValues.FieldValue(
              ((FieldImpl) field).ref(),
              // validate and convert if necessary
              ValueImpl.prepareForAssignment(value, (FieldImpl) field));

      try {
        JDWP.ClassType.SetValues.process(vm, this, values);
      } catch (JDWPException exc) {
        throw exc.toJDIException();
      }
    } catch (ClassNotLoadedException e) {
      /*
       * Since we got this exception,
       * the field type must be a reference type. The value
       * we're trying to set is null, but if the field's
       * class has not yet been loaded through the enclosing
       * class loader, then setting to null is essentially a
       * no-op, and we should allow it without an exception.
       */
      if (value != null) {
        throw e;
      }
    }
  }