@MJI
  public void setLength__J__V(MJIEnv env, int this_ptr, long len, FeatureExpr ctx) {
    long current_posn = env.getLongField(this_ptr, current_position).getValue();
    long current_len = env.getLongField(this_ptr, current_length).getValue();
    if (current_posn >= len && len < current_len) {

      env.setLongField(ctx, this_ptr, current_position, new One<>(len));
    }
    env.setLongField(ctx, this_ptr, current_length, new One<>(len));
    // update length in the mapped object if it exists
    env.setLongField(
        ctx, getMapping(env, this_ptr, ctx), current_length, new One<>(current_posn + 1));
  }
  private static int findDataChunk(
      MJIEnv env, int this_ptr, long position, int chunk_size, FeatureExpr ctx) {

    ClassInfo dataRep = getDataRepresentationClassInfo(env, ctx);
    if (dataRep == null) {
      // will be reexecuted
      return 0;
    }

    // check if the file data is mapped, use mapped this_ptr if it exists
    this_ptr = getMapping(env, this_ptr, ctx);
    int prev_obj = MJIEnv.NULL;
    int cur_obj = env.getReferenceField(ctx, this_ptr, data_root).getValue();
    long chunk_idx = position / chunk_size;
    while (cur_obj != MJIEnv.NULL
        && env.getLongField(cur_obj, chunk_index).getValue() < chunk_idx) {
      prev_obj = cur_obj;
      cur_obj = env.getReferenceField(ctx, cur_obj, next).getValue();
    }
    if (cur_obj != MJIEnv.NULL && env.getLongField(cur_obj, chunk_index).getValue() == chunk_idx) {
      return cur_obj;
    }
    int result = env.newObject(ctx, dataRep);
    int int_array = env.newIntArray(chunk_size / INT_SIZE);
    env.setReferenceField(ctx, result, data, int_array);
    env.setLongField(ctx, result, chunk_index, new One<>(chunk_idx));
    env.setReferenceField(ctx, result, next, cur_obj);
    if (prev_obj == MJIEnv.NULL) {
      env.setReferenceField(ctx, this_ptr, data_root, result);
    } else {
      env.setReferenceField(ctx, prev_obj, next, result);
    }
    return result;
  }
  @MJI
  public void writeByte__I__V(MJIEnv env, int this_ptr, int data, FeatureExpr ctx) {

    long current_posn = env.getLongField(this_ptr, current_position).getValue();
    long current_len = env.getLongField(this_ptr, current_length).getValue();
    int chunk_size = env.getStaticIntField(RandomAccessFile, CHUNK_SIZE);
    int chunk = findDataChunk(env, this_ptr, current_posn, chunk_size, ctx);
    setDataValue(env, chunk, current_posn, (byte) data, chunk_size, ctx);
    current_posn += 1;
    env.setLongField(ctx, this_ptr, current_position, new One<>(current_posn));
    if (current_posn >= current_len) {
      env.setLongField(ctx, this_ptr, current_length, new One<>(current_posn + 1));
      // update length in the mapped object if it exists
      env.setLongField(
          ctx, getMapping(env, this_ptr, ctx), current_length, new One<>(current_posn + 1));
    }
  }
 @MJI
 public byte readByte____B(MJIEnv env, int this_ptr, FeatureExpr ctx) {
   long current_posn = env.getLongField(this_ptr, current_position).getValue();
   long current_len = env.getLongField(this_ptr, current_length).getValue();
   int chunk_size = env.getStaticIntField(RandomAccessFile, CHUNK_SIZE);
   if (current_posn >= current_len) {
     env.throwException(ctx, EOFException);
   }
   int chunk = findDataChunk(env, this_ptr, current_posn, chunk_size, ctx);
   byte result = getDataValue(env, chunk, current_posn, chunk_size, ctx);
   env.setLongField(ctx, this_ptr, current_position, new One<>(current_posn + 1));
   return result;
 }