如何配置 openJDK11 以从源构建?

How to configure openJDK11 for build from sources?

我需要从源代码交叉编译这个 OpenJava 分支 https://gitlab.com/gosjava/11/openjdk/-/tree/master/ - 对于 aarch64-linux-gnu devkit 目标: 为此,我安装了 java 10.0.2 作为主机 JDK 然后 运行 "./configure"

└─$ ./configure    
...
configure: Potential Boot JDK found at /home/katya/java is incorrect JDK version (Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true); ignoring
configure: (Your Boot JDK version must be one of: 10 11)
checking for javac... /home/katya/java/bin/javac
checking for java... /home/katya/java/bin/java
configure: Found potential Boot JDK using java(c) in PATH
configure: Potential Boot JDK found at /home/katya/java is incorrect JDK version (Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true); ignoring
configure: (Your Boot JDK version must be one of: 10 11)
configure: Could not find a valid Boot JDK. You might be able to fix this by running 'sudo apt-get install openjdk-8-jdk'.
configure: This might be fixed by explicitly setting --with-boot-jdk
configure: error: Cannot continue
configure exiting with result code 1

这里有完整日志https://gist.github.com/iva-nova-e-katerina/3061b865beb48dc25594bc360508d6a3 你能告诉我为什么配置说我使用错误JDK吗?

该消息由 BOOTJDK_DO_CHECK autoconf 宏生成,其定义在“jdk11u/make/autoconf/boot-jdk.m4”中。如果您查看该文件,您将看到以下内容:

      BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $HEAD -n 1`

      # Extra M4 quote needed to protect [] in grep expression.
      [FOUND_CORRECT_VERSION=`$ECHO $BOOT_JDK_VERSION \
          | $EGREP "\"(${DEFAULT_ACCEPTABLE_BOOT_VERSIONS// /|})([\.+-].*)?\""`]
      if test "x$FOUND_CORRECT_VERSION" = x; then
        AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK is incorrect
                       JDK version ($BOOT_JDK_VERSION); ignoring])
        AC_MSG_NOTICE([(Your Boot JDK version must be one of:
                       $DEFAULT_ACCEPTABLE_BOOT_VERSIONS)])
        BOOT_JDK_FOUND=no

(为了便于阅读,我添加了几个换行符...)

如果我们将其与实际错误消息进行比较:

configure: Potential Boot JDK found at /home/katya/java is incorrect JDK version 
(Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true); 
ignoring

所以...看起来像:

  1. 您已经(或某些东西)在您 运行 configure.
  2. 时生效的环境中设置了 _JAVA_OPTIONS 环境变量
  3. java 命令警告您 _JAVA_OPTIONS 已生效(出于安全原因!)。大概是真正的版本字符串作为下一行输出。
  4. 宏仅捕获第一行 (head -n 1) ... 然后使用警告消息,就好像它是真实版本字符串一样。
  5. 此伪造版本导致启动 Java 版本检查逻辑失败。

您可能有一个有效的引导 JDK ...但是 configure 被警告消息弄糊涂了,认为您没有。

可能的解决方案:

  • 刚刚取消设置 _JAVA_OPTIONS。这些选项看起来与您正在做的事情无关。

  • 如果与建筑相关,请在 运行 configure 时取消设置 _JAVA_OPTIONS。然后重新设置。

  • 如果由于某种原因取消设置_JAVA_OPTIONS不起作用,您可以修改上面的“.m4”文件以跳过版本检查。 (呃……)


您可以在以下位置阅读更多关于 _JAVA_OPTIONS 这种不需要的(尽管实际上是必要的)行为的信息:

  • Suppressing the "Picked up _JAVA_OPTIONS" message

(简短的回答是“你不能”...除了取消设置环境变量。)