code: public ApkAssetsCookie ResolveReference(ApkAssetsCookie cookie, Ref<Res_value> in_out_value,
        final Ref<ResTable_config> in_out_selected_config,
        final Ref<Integer> in_out_flags,
        final Ref<Integer> out_last_reference) {
      final int kMaxIterations = 20;
  
      for (int iteration = 0; in_out_value.get().dataType == Res_value.TYPE_REFERENCE &&
          in_out_value.get().data != 0 && iteration < kMaxIterations;
          iteration++) {
        out_last_reference.set(in_out_value.get().data);
        final Ref<Integer> new_flags = new Ref<>(0);
        cookie = GetResource(in_out_value.get().data, true /*may_be_bag*/, (short) 0 /*density_override*/,
            in_out_value, in_out_selected_config, new_flags);
        if (cookie.intValue() == kInvalidCookie) {
          return K_INVALID_COOKIE;
        }
        if (in_out_flags != null) {
          in_out_flags.set(in_out_flags.get() | new_flags.get());
        }
        if (out_last_reference.get() == in_out_value.get().data) {
          // This reference can't be resolved, so exit now and let the caller deal with it.
          return cookie;
        }
      }
      return cookie;
    }
docs: int* out_last_reference);