code: protected boolean findLine(int pos) {
          if (pos == Position.NOPOS)
              return false;
  
          try {
              // try and recover buffer from soft reference cache
              if (buf == null && refBuf != null)
                  buf = refBuf.get();
  
              if (buf == null) {
                  buf = initBuf(fileObject);
                  lineStart = 0;
                  line = 1;
              } else if (lineStart > pos) { // messages don't come in order
                  lineStart = 0;
                  line = 1;
              }
  
              int bp = lineStart;
              while (bp < bufLen && bp < pos) {
                  switch (buf[bp++]) {
                  case CR:
                      if (bp < bufLen && buf[bp] == LF) bp++;
                      line++;
                      lineStart = bp;
                      break;
                  case LF:
                      line++;
                      lineStart = bp;
                      break;
                  }
              }
              return bp <= bufLen;
          } catch (IOException e) {
              log.directError("source.unavailable");
              buf = new char[0];
              return false;
          }
      }
docs: Find the line in the buffer that contains the current position
  @param pos      Character offset into the buffer