New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore non-existent classpath entries #456

johnzeringue opened this Issue Jun 7, 2018 · 2 comments


3 participants

johnzeringue commented Jun 7, 2018

Running native-image with non-existent classpath entries (i.e. native-image Main -cp /not/a/real/dir) causes an error like

Error: Invalid Path entry /not/a/real/dir
Caused by: java.nio.file.NoSuchFileException: /not/a/real/dir

However, the java binary doesn't care about these types of classpath entries. Something like java Main -cp /real/file.jar:/not/a/real/file.jar:/real/dir:/not/a/real/dir is fine as long as Main doesn't end up missing classes it needs.

I only care because better conformance to java's behavior would ease tooling integration. For example, you can reuse Gradle's JavaExec(!) task to easily integrate GraalVM:

task buildNativeImage(type: JavaExec) {
    classpath = sourceSets.main.runtimeClasspath
    main = "com.example.Main"
    executable = "native-image"
    jvmArgs "--static", "-H:+ReportUnsupportedElementsAtRuntime"

This automatically generates complicated classpaths from project and Maven dependencies and works nicely. However, it breaks if you don't have any resources. In that case, it doesn't create the output directory for resources but will still list it in the classpath, breaking native-image.

In general, using native-image should be simpler for many scripts/tools if they're not responsible for making sure all directories on the classpath exist.


This comment has been minimized.


olpaw commented Jun 7, 2018

@johnzeringue I agree. I will turn non-existent image classpath entries into warning messages instead. Thanks for reporting!


This comment has been minimized.


olpaw commented Jun 7, 2018

Fixed in e028d63

@olpaw olpaw closed this Jun 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment