In the gensrc step for java.base, we generate a couple of java classes
with the purpose of extracting native constants from the system. We
currently do this by compiling a C program that when run, generates the
java source file. The problem with this approach is that when cross
compiling, we can't do it, so we have to provide pregenerated versions
of the java source files for each cross compiled platform.
I have fixed this by changing the method to instead just run the C
preprocessor to extract the constants into java source files. This works
fine for most of the constants. There are however 3 that, at least on
Linux, are defined as an enum and not constants, which makes them
unavailable to the preprocessor. These are:
IPPROTO_TCP = 6
IPPROTO_IP = 0
IPPROTO_PV6 = 41
I would say that this is fine. They have the same value on all our
supported platforms and are actually part of the IP spec. I cannot
imagine a reason for ever defining them differently. So the solution is
to simply define these as constants in the java source.
By fixing this, cross compiling new or existing platforms becomes much
easier.
I have verified this patch by manually comparing the output and by
running the jdk_nio tests in JPRT.
Bug: https://bugs.openjdk.java.net/browse/JDK-8152545
Webrev: http://cr.openjdk.java.net/~erikj/8152545/webrev.jdk.01/
/Erik