[graalvm-users] help for native images
rvjansen at xs4all.nl
Sun Jan 26 18:49:22 PST 2020
Hi All, I am trying to get some pointers here to help my understanding. I am the current maintainer of the NetRexx translator - see netrexx.org <https://urldefense.proofpoint.com/v2/url?u=http-3A__netrexx.org_&d=DwIFaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=CUkXBxBNT_D5N6HMJ5T9Z6rmvNKYsqupcbk72K0lcoQ&m=awrBOl-16XpR9k6x9xAmymgZ05tQOpSPqnxbG0G6H6w&s=74T-W3THg4OWqMNDCfe3mc8m0rr6gOcqEiQC0nzFeUA&e= > - and I am struggling with some concepts. NetRexx is a translator and interpreter that either interprets NetRexx or compiles it to class files, with generated java source as an intermediate. It was thoroughly broken by Java 9 and its modules - being from 1996, NetRexx scans all jars and zips on the classpath in order to make decisions over linking which methods for which classes. It cannot find stuff in modules at the moment.
I need to fix this, of course, but I first have implemented some stopgaps to keep NetRexx usable on current JVMs. The first is a Docker image that contains everything to compile classes. My demography, most are older mainframe programmers, makes this rather hard to support, and some refuse outright to try it. Plan B was the GraalVM and a native image for the compiler, which, to my great relief, works! That is, it works for me, but I do not want to release before I understand it better than I do now.
I have made native images for the needed entrypoints. The native-image process complains that not everything is supported and generates fallback images, which need a JVM to back it up. This is fine with me, because making programs in NetRexx entails using Java classlibraries from different sources - one of the main advantages of NetRexx is the very well working Java integration.
Then everything works as designed. I can install a JDK 13 and run NetRexx, which thinks it runs on Java 8 and can suddenly find all needed signatures. But, now comes the but:
I cannot move this executable without moving the NetRexxC.jar file in a corresponding move with it. If you want to try: git clone git://git.code.sf.net/p/netrexx/code , then run make. This works everywhere and even on a JRE because we include the Eclipse compiler. Well, everywhere that is Java 8.
Now there are some jars in build/lib. These are apparently needed for execution, and if I move the nrc executable to ~/bin , I have to make a ~/bin/build/lib/NetRexxC.jar for it to find, otherwise it will not find the org.netrexx.process.NetRexxC class, which is the entrypoint for the translator. Moreover, I thought it prudent to change the compiler logo line, to make sure I know what I am running, the native executable or the java class. Now I found out that without regenerating the native executable, the changes (in the org.netrexx.rocess.NrVersion class) were picked up. So when starting a native ‘se;lf-contained’ executable, I am actually branching quite fast to a class in a jar.
I have tried reading the documentation. It might be me, but I could not quickly find the technical details that explain this. So to recap:
1) what is actually executed from a native-image generated executable fallback image. Not my classes?
2) how to go about generating a fully self-contained image - that error message does not exactly pinpoint (at all) what the problem is doing this;
3) can I somehow list the symbols in the executable - I did an objdump but I see generic C-library functions and none of my own classes - but a System.getProperty(“java.version”) tells me 8 - while running on a Java 13 JVM.
4) how can the runtime know it is a native executable and no class running in a conventional JVM - this would probably be enough for me to differentiate
5) I see one can make shared object libraries. That would be great, because I have a few entrypoints (nrc, pipe, pipc, nrws) that all uses the same classes. But how to use this? Is there an example?
6) (bonus points) I miss an aarch64 native-image version of JVM8 - is there any chance of this? I am fine with 64-bit only and Raspbian should catch up quickly, but NetRexx on Ubuntu on the Raspi 4 with Java 11 would be great - need a Graal native-image 8 for that. Or do I?
thank you very much in advance,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the GraalVM-Users