Hi, Andrew, How about this? I can use awk to capture java -version. There're 2 cases.
I) openjdk openjdk version "14.0.1" 2020-04-14 2) oraclejdk java 14.0.1 2020-04-14 if somehow java displays some error/warning messages, awk can filter them out and capture the version 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) $ ~/builds/jdk-14.0.1+7/bin/java -version 2>&1 | awk '/^(openjdk version|java)/ {print $0}' openjdk version "14.0.1" 2020-04-14 I think this awk stmt is portable, but it's always good to ask experts to review it, so I cc build-dev. Hers is the change. diff --git a/make/autoconf/boot-jdk.m4 b/make/autoconf/boot-jdk.m4 --- a/make/autoconf/boot-jdk.m4 +++ b/make/autoconf/boot-jdk.m4 @@ -74,7 +74,7 @@ BOOT_JDK_FOUND=no else # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version? - BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java$EXE_SUFFIX" $USER_BOOT_JDK_OPTIONS -version 2>&1 | $HEAD -n 1` + BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java$EXE_SUFFIX" $USER_BOOT_JDK_OPTIONS -version 2>&1 | $AWK '/^(openjdk version|java)/ {print [$]0}'` if [ [[ "$BOOT_JDK_VERSION" =~ "Picked up" ]] ]; then AC_MSG_NOTICE([You have _JAVA_OPTIONS or JAVA_TOOL_OPTIONS set. This can mess up the build. Please use --with-boot-jdk-jvmargs instead.]) AC_MSG_NOTICE([Java reports: "$BOOT_JDK_VERSION".]) @@ -529,7 +529,7 @@ BUILD_JDK_FOUND=no else # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version? - BUILD_JDK_VERSION=`"$BUILD_JDK/bin/java" -version 2>&1 | $HEAD -n 1` + BUILD_JDK_VERSION=`"$BUILD_JDK/bin/java" -version 2>&1 | $AWK '/^(openjdk version|java)/ {print [$]0}'` # Extra M4 quote needed to protect [] in grep expression. [FOUND_CORRECT_VERSION=`echo $BUILD_JDK_VERSION | $EGREP "\"$VERSION_FEATURE([\.+-].*)?\""`] On 4/30/20, 2:52 PM, "aarch64-port-dev on behalf of Liu, Xin" <aarch64-port-dev-boun...@openjdk.java.net on behalf of xxin...@amazon.com> wrote: Hi, Andrew, That's a hack. A general way should use grep or sed to capture the needed line instead of hardcoding first or second line. Okay, Let me try to do that. Thanks, --lx On 4/30/20, 1:19 AM, "a...@redhat.com" <a...@redhat.com> wrote: CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe. On 4/30/20 12:43 AM, Liu, Xin wrote: > One trick here. It's very easy to cheat configure by hacking the boot-jdk.m4 to "$HEAD -n 2". Everything looks fine then. The fix should be submitted to build-dev. -- Andrew Haley (he/him) Java Platform Lead Engineer Red Hat UK Ltd. <https://www.redhat.com> https://keybase.io/andrewhaley EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671