FSInfo#getJarClassPath throws an exception not declared in its throws clause

Jaikiran Pai jai.forums2013 at gmail.com
Fri Oct 11 14:26:00 UTC 2019

In recent versions of JDK (I think after JDK 8), the
com.sun.tools.javac.file.FSInfo#getJarClassPath(...) is throwing a
java.nio.file.InvalidPathException in certain cases when the classpath
entry it is parsing isn't a valid one. This is because of its usage of
the java.nio.file.Path APIs, specifically

The throws clause of this FSInfo#getJarClassPath API lists IOException,
so this method is now throwing an exception which isn't listed in its
throws clause. As a result, callers, like the
are no longer able to catch this exception and log it and move on.
Instead it gets propagated all the way back to the top level callers,
thus breaking applications which are trying to compile java files

Would this be considered a bug? If so, I can create a JBS issue and
provide a patch (and will try a jtreg test case too) for review.

Although these classes are internal and not public API, the calling code
is actually using public APIs (which internally end up calling these
APIs). Like here

For a lengthy discussion/context - please read the comments in this
issue https://github.com/quarkusio/quarkus/issues/3592


More information about the compiler-dev mailing list