Fix cross-JDK issues around invalid URIs in JDK6