Пример #1
0
  protected boolean shouldDisplay(
      EvaluationContext context, @NotNull ObjectReference objInstance, @NotNull Field field) {
    final boolean isSynthetic = DebuggerUtils.isSynthetic(field);
    if (!SHOW_SYNTHETICS && isSynthetic) {
      return false;
    }
    if (SHOW_VAL_FIELDS_AS_LOCAL_VARIABLES && isSynthetic) {
      try {
        final StackFrameProxy frameProxy = context.getFrameProxy();
        if (frameProxy != null) {
          final Location location = frameProxy.location();
          if (location != null
              && objInstance.equals(context.getThisObject())
              && Comparing.equal(objInstance.referenceType(), location.declaringType())
              && StringUtil.startsWith(
                  field.name(), FieldDescriptorImpl.OUTER_LOCAL_VAR_FIELD_PREFIX)) {
            return false;
          }
        }
      } catch (EvaluateException ignored) {
      }
    }
    if (!SHOW_STATIC && field.isStatic()) {
      return false;
    }

    if (!SHOW_STATIC_FINAL && field.isStatic() && field.isFinal()) {
      return false;
    }

    return true;
  }
 public FieldDescriptorImpl(Project project, ObjectReference objRef, @NotNull Field field) {
   super(project);
   myObject = objRef;
   myField = field;
   myIsStatic = field.isStatic();
   setLvalue(!field.isFinal());
 }
Пример #3
0
 @Override
 public String getName() {
   String name = myField.name();
   if (myField.isStatic()
       && !(myField.declaringType().name().equals(myParent.referenceType().name()))) {
     name = name + " (" + myField.declaringType().name() + ")";
   }
   return name;
 }
Пример #4
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;
      }
    }
  }