Graal: native-image -H:Name is ignored

Created on 8 Oct 2018  路  7Comments  路  Source: oracle/graal

Hello
I am using GraalVM 1.0.0-rc7. No matter what parameter I send for -H:Name, it gets constantly ignored, getting the name from the jar file instead.
You can see the project here:
https://github.com/apetrelli/scafa/tree/master/scafa-headless

The command line is:
/home/anpetrel/javadev/libs/graalvm-ce/bin/native-image --verbose -cp /home/anpetrel/.m2/repository-ispcasa/com/github/apetrelli/scafa/scafa-server/1.0.0-SNAPSHOT/scafa-server-1.0.0-SNAPSHOT.jar:/home/anpetrel/.m2/repository-ispcasa/jcifs/jcifs/1.3.17/jcifs-1.3.17.jar:/home/anpetrel/.m2/repository-ispcasa/org/ini4j/ini4j/0.5.4/ini4j-0.5.4.jar:/home/anpetrel/.m2/repository-ispcasa/commons-io/commons-io/2.4/commons-io-2.4.jar -H:ReflectionConfigurationFiles=src/etc/graal.json -H:EnableURLProtocols=http -H:Path=/home/anpetrel/git/scafa/scafa-headless/target/deb/usr/bin -H:Name="scafa-headless" --rerun-class-initialization-at-runtime=jcifs.ntlmssp.Type3Message --no-server -jar /home/anpetrel/git/scafa/scafa-headless/target/scafa-headless-1.0.0-SNAPSHOT-graalvm.jar

What I see at the start is:

Executing [
/home/anpetrel/javadev/libs/graalvm-ce/bin/java \
-Xbootclasspath/a:/home/anpetrel/javadev/libs/graalvm-ce/jre/lib/boot/graaljs-scriptengine.jar:/home/anpetrel/javadev/libs/graalvm-ce/jre/lib/boot/graal-sdk.jar \
-cp \
/home/anpetrel/javadev/libs/graalvm-ce/jre/lib/svm/builder/objectfile.jar:/home/anpetrel/javadev/libs/graalvm-ce/jre/lib/svm/builder/svm.jar:/home/anpetrel/javadev/libs/graalvm-ce/jre/lib/svm/builder/pointsto.jar:/home/anpetrel/javadev/libs/graalvm-ce/jre/lib/jvmci/jvmci-api.jar:/home/anpetrel/javadev/libs/graalvm-ce/jre/lib/jvmci/graal-management.jar:/home/anpetrel/javadev/libs/graalvm-ce/jre/lib/jvmci/jvmci-hotspot.jar:/home/anpetrel/javadev/libs/graalvm-ce/jre/lib/jvmci/graal.jar \
-server \
-d64 \
-noverify \
-XX:+UnlockExperimentalVMOptions \
-XX:+EnableJVMCI \
-XX:-UseJVMCIClassLoader \
-Dgraal.EagerSnippets=true \
-Xss10m \
-Xms1g \
-Xmx13368570672 \
-Duser.country=US \
-Duser.language=en \
-Dgraalvm.version=1.0.0-rc7 \
-Dorg.graalvm.version=1.0.0-rc7 \
-Dcom.oracle.graalvm.isaot=true \
-Djvmci.class.path.append=/home/anpetrel/javadev/libs/graalvm-ce/jre/lib/jvmci/graal.jar \
com.oracle.svm.hosted.NativeImageGeneratorRunner \
-imagecp \
/home/anpetrel/javadev/libs/graalvm-ce/jre/lib/boot/graaljs-scriptengine.jar:/home/anpetrel/javadev/libs/graalvm-ce/jre/lib/boot/graal-sdk.jar:/home/anpetrel/javadev/libs/graalvm-ce/jre/lib/svm/builder/objectfile.jar:/home/anpetrel/javadev/libs/graalvm-ce/jre/lib/svm/builder/svm.jar:/home/anpetrel/javadev/libs/graalvm-ce/jre/lib/svm/builder/pointsto.jar:/home/anpetrel/javadev/libs/graalvm-ce/jre/lib/jvmci/jvmci-api.jar:/home/anpetrel/javadev/libs/graalvm-ce/jre/lib/jvmci/graal-management.jar:/home/anpetrel/javadev/libs/graalvm-ce/jre/lib/jvmci/jvmci-hotspot.jar:/home/anpetrel/javadev/libs/graalvm-ce/jre/lib/jvmci/graal.jar:/home/anpetrel/javadev/libs/graalvm-ce/jre/lib/svm/library-support.jar:/home/anpetrel/git/scafa/scafa-headless/target/scafa-headless-1.0.0-SNAPSHOT-graalvm.jar:/home/anpetrel/.m2/repository-ispcasa/com/github/apetrelli/scafa/scafa-server/1.0.0-SNAPSHOT/scafa-server-1.0.0-SNAPSHOT.jar:/home/anpetrel/.m2/repository-ispcasa/jcifs/jcifs/1.3.17/jcifs-1.3.17.jar:/home/anpetrel/.m2/repository-ispcasa/org/ini4j/ini4j/0.5.4/ini4j-0.5.4.jar:/home/anpetrel/.m2/repository-ispcasa/commons-io/commons-io/2.4/commons-io-2.4.jar \
-watchpid \
21188 \
-H:RerunClassInitialization=jcifs.ntlmssp.Type3Message \
-H:Class=com.github.apetrelli.scafa.headless.ScafaMain \
-H:CLibraryPath=/home/anpetrel/javadev/libs/graalvm-ce/jre/lib/svm/clibraries/linux-amd64 \
-H:EnableURLProtocols=http \
-H:ReflectionConfigurationFiles=/home/anpetrel/git/scafa/scafa-headless/src/etc/graal.json \
-H:Path=/home/anpetrel/git/scafa/scafa-headless/target/deb/usr/bin \
-H:Name=scafa-headless-1.0.0-SNAPSHOT-graalvm
]

Even if I remove the " around the name, -H:Name gets ignored anyway.

native-image

Most helpful comment

OK this way I demonstrated that I am a newbie in native compilation. Thank you and have a nice day!

All 7 comments

@apetrelli please put -H:Name="scafa-headless" after -jar /home/anpetrel/git/scafa/scafa-headless/target/scafa-headless-1.0.0-SNAPSHOT-graalvm.jar.

Ok thank you, this worked!
But anyway it probably needs documentation if it works this way.

Some more details:

Using -jar instructs native-image to name the image after the jar-file name. (Which often makes sense). If you want to override that behavior you have to place -H:Name="my-native-image-exe-name" after the -jar option. That's a general principle of native-image option handling. To provide defaults/fallbacks put options before other affecting options. To override decided options put them after the other affecting options. This is the same principle that is used by most compiler-drivers. See e.g. https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#Optimize-Options

If you use multiple -O options, with or without level numbers, the last such option is the one that is effective. 

OK this way I demonstrated that I am a newbie in native compilation. Thank you and have a nice day!

@olpaw this issue caught me out as well! I think a line in the docs is justified for this.

https://www.graalvm.org/reference-manual/native-image/Options

The reference manual currently doesn't state anything about argument/option ordering, it simply states

native-image [options] -jar jarfile

Which would make one think that any -H:Name=myname option would need to go before the -jar argument, not after.

Thanks 馃檪

@alzadude we have that under https://www.graalvm.org/reference-manual/native-image/Configuration/#order-of-arguments-evaluation. Maybe that should be linked to also from https://www.graalvm.org/reference-manual/native-image/Options
@olyagpl please add something like

The arguments passed to native-image are evaluated left-to-right. For more info see.

to https://www.graalvm.org/reference-manual/native-image/Options

@olpaw, done!

Was this page helpful?
0 / 5 - 0 ratings