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
NullPointerExceptioncould be thrown when there are no classes found by the tool to compile in the specifiedsearchPathor thefiles(if specified in the--jararg).If you look at the code at Line#135 does a
where NPE could be thrown if
classesToCompileis 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.HelloWorldto a compiler, if I am not wrong to draw an analogy withjavachere, it would have required a complete path for either the compiled or source class.