Fixes #1743. Fixes IndexOutOfBoundsException on Java warning with no position

Fixes #1743. Enbugged in #1702.
The `d.getPosition`, `d.getStartPosition` uses `-1` as `NOPOS` value, but they weren’t being checked.
Added `checkNoPos`.