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

boot-jdk.m4 captures the version line using regex

XMLWordPrintable

    • b23
    • generic

      boot-jdk.m4 uses java -version 2>&1 | head -n1 to capture the version line.

      ostream and other JVM initialization happen before PrintJavaVersion(java.c).
      if any of them emits an error or warning log, it breaks the first line promise.

          private static void print(boolean err, boolean newln) {
              PrintStream ps = err ? System.err : System.out;

              /* First line: platform version. */
              if (err) {
                  ps.println(launcher_name + " version \"" + java_version + "\""
                             + " " + java_version_date
                             + (isLTS ? " LTS" : ""));

      a tainted jdk will fail to be a boot-jdk if boot-jdk.m4 only captures the 1st line.
      eg.
      $ ~/builds/jdk-14.0.1+7/bin/java -version
      [0.009s][error][cds] Unable to map CDS archive -- os::vm_allocation_granularity() expected: 65536 actual: 4096
      openjdk version "14.0.1" 2020-04-14
      OpenJDK Runtime Environment AdoptOpenJDK (build 14.0.1+7)
      OpenJDK 64-Bit Server VM AdoptOpenJDK (build 14.0.1+7, mixed mode)

      if we use a portable regex version to capture the version line, it would make the building logic more robust.

            xliu Xin Liu
            xliu Xin Liu
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: