如何配置 openJDK11 以从源代码构建?

Cat*_*ine 0 java java-11 openjdk-11

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

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

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

\n

Ste*_*n C 5

该消息由 autoconf 宏生成BOOTJDK_DO_CHECK,其定义位于“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
Run Code Online (Sandbox Code Playgroud)

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

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

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

所以......它看起来像:

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

您可能有一个有效的 Boot JDK ...但configure对警告消息感到困惑,并认为您没有。

可能的解决方案:

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

  • 如果与构建相关,请_JAVA_OPTIONS在运行时取消设置configure。然后再次设置。

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


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

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