private Object evaluateField(Object object, EvaluationContextImpl context) throws EvaluateException {
    if (object instanceof ReferenceType refType) {
      Field field = findField(refType);
      if (field == null || !field.isStatic()) {
        field = refType.fieldByName(myFieldName);
      }
      if (field == null || !field.isStatic()) {
        throw EvaluateExceptionUtil.createEvaluateException(JavaDebuggerBundle.message("evaluation.error.no.static.field", myFieldName));
      }
      myEvaluatedField = field;
      myEvaluatedQualifier = refType;
      return refType.getValue(field);
    }

    if (object instanceof ObjectReference objRef) {
      ReferenceType refType = objRef.referenceType();
      if (!(refType instanceof ClassType || refType instanceof ArrayType)) {
        throw EvaluateExceptionUtil.createEvaluateException(
          JavaDebuggerBundle.message("evaluation.error.class.or.array.expected", myFieldName));
      }

      // expressions like 'array.length' must be treated separately
      if (objRef instanceof ArrayReference && "length".equals(myFieldName)) {
        return context.getSuspendContext().getVirtualMachine().mirrorOf(((ArrayReference)objRef).length());
      }

      Field field = findField(refType);
      if (field == null) {
        field = refType.fieldByName(myFieldName);
      }

      if (field == null) {
        throw EvaluateExceptionUtil.createEvaluateException(JavaDebuggerBundle.message("evaluation.error.no.instance.field", myFieldName));
      }
      myEvaluatedQualifier = field.isStatic() ? refType : objRef;
      myEvaluatedField = field;
      return field.isStatic() ? refType.getValue(field) : objRef.getValue(field);
    }

    if (object == null) {
      throw EvaluateExceptionUtil.createEvaluateException(new NullPointerException());
    }

    throw EvaluateExceptionUtil.createEvaluateException(JavaDebuggerBundle.message("evaluation.error.evaluating.field", myFieldName));
  }
private Object evaluateField(Object object, EvaluationContextImpl context)