FSInfo#getJarClassPath throws an exception not declared in its throws clause
David Lloyd
david.lloyd at redhat.com
Fri Oct 11 14:30:44 UTC 2019
In the Quarkus issue, the class path entry is actually valid. But the
FSInfo class appears to fail to account for the fact that class-path
entries in a JAR are specified as relative URLs, not as file paths, so
passing the string directly into getPath() is incorrect. At the very
least the string would have to be URL decoded.
On Fri, Oct 11, 2019 at 9:27 AM Jaikiran Pai <jai.forums2013 at gmail.com> wrote:
>
> 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
> https://github.com/openjdk/jdk/blob/4ad3d82c76936a8927ed8a505689a3683144ad98/src/jdk.compiler/share/classes/com/sun/tools/javac/file/FSInfo.java#L112.
>
> 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
> com.sun.tools.javac.file.Locations.SearchPath#addJarClassPath(...)
> https://github.com/openjdk/jdk/blob/4ad3d82c76936a8927ed8a505689a3683144ad98/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java#L425
> 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
> programmatically.
>
> 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
> https://github.com/quarkusio/quarkus/blob/master/core/devmode/src/main/java/io/quarkus/dev/JavaCompilationProvider.java#L48.
>
> For a lengthy discussion/context - please read the comments in this
> issue https://github.com/quarkusio/quarkus/issues/3592
>
> -Jaikiran
>
>
>
--
- DML
More information about the compiler-dev
mailing list