I would like compile a Java 10 class file with jaotc
. While I am able to build a shared lib of an Java 10 module I am not able figure out how to compile a single class. The FQCN of my class is net.sweblog.jm18.aot.hw.HelloWorld
and its full path is target/classes/net/sweblog/jm18/aot/hw/HelloWorld.class
.
So tried to invoke jaotc
as follows:
$ jaotc --output output/helloworld.so \
--search-path helloworld/target/classes/ \
--class-name net.sweblog.jm18.aot.hw.HelloWorld
Error: Failed to find class file: net.sweblog.jm18.aot.hw.HelloWorld
java.lang.NullPointerException
at jdk.aot/jdk.tools.jaotc.Main.run(Main.java:135)
at jdk.aot/jdk.tools.jaotc.Main.run(Main.java:101)
at jdk.aot/jdk.tools.jaotc.Main.main(Main.java:80)
Does anyone know how to invoke jaotc
correctly to compile my class file?
The
NullPointerException
could be thrown when there are no classes found by the tool to compile in the specifiedsearchPath
or thefiles
(if specified in the--jar
arg).If you look at the code at Line#135 does a
where NPE could be thrown if
classesToCompile
is null which is the case only when the lookup for classes fails in the specified pathHence, I would recommend verifying the search path that you've specified. I also doubt specifying the class name
net.sweblog.jm18.aot.hw.HelloWorld
to a compiler, if I am not wrong to draw an analogy withjavac
here, it would have required a complete path for either the compiled or source class.