Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8152545

Use preprocessor instead of compiling a program to generate native nio constants

XMLWordPrintable

    • b112

        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 would like to fix 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 a constant, 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.

              erikj Erik Joelsson
              erikj Erik Joelsson
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: