java - 错误 : Hash of java. xml (...) 与 java.base 中记录的预期哈希 (...) 不同

标签 java javafx java-11 javafx-11 jlink

创建简单的 javafx 11 “hello world”应用程序。
创建自定义 JRE 时出错。

user@user:~/Desktop/javafx/hellofx$ ./run.sh 
Error: Hash of java.xml (c043b4c28b897656e2a4d36c92ba2f5d52134bce79643236dd36295e14178be7) differs to expected hash (4e7db7fc941d9f316c4aafe02717b5809ee722be8433d283050365e7fd49331f) recorded in java.base

错误代码:
$JAVA_HOME/bin/jlink --module-path $PATH_TO_FX_MODS:mods --add-modules hellofx --output hellofx #error

操作系统:ubuntu 19.10

$java --版本
openjdk 11.0.6 2020-01-14
OpenJDK 运行时环境(build 11.0.6+10-post-Ubuntu-1ubuntu119.10.1)
OpenJDK 64-Bit Server VM (build 11.0.6+10-post-Ubuntu-1ubuntu119.10.1, 混合模式, 共享)

$javac --版本
javac 11.0.6
user@user:~/Desktop/javafx/hellofx$ tree
.
├── mods
│   └── hellofx
│       ├── hellofx
│       │   └── HelloFX.class
│       └── module-info.class
├── run.sh
└── src
    ├── hellofx
    │   └── HelloFX.java
    └── module-info.java

5 directories, 5 files


运行.sh:
user@user:~/Desktop/javafx/hellofx$ cat run.sh 
export PATH_TO_FX=/home/sameep/javafx-sdk-11.0.2/lib
export PATH_TO_FX_MODS=/home/sameep/javafx-jmods-11.0.2
javac --module-path $PATH_TO_FX -d mods/hellofx $(find src -name "*.java")

java --module-path $PATH_TO_FX:mods -m hellofx/hellofx.HelloFX

$JAVA_HOME/bin/jlink --module-path $PATH_TO_FX_MODS:mods --add-modules hellofx --output hellofx #error
#hellofx/bin/java -m hellofx/hellofx.HelloFX


模块信息.java:
user@user:~/Desktop/javafx/hellofx/src$ cat module-info.java 
module hellofx {
    requires javafx.controls;

    exports hellofx;
}

HelloFX.java:
user@user:~/Desktop/javafx/hellofx/src/hellofx$ cat HelloFX.java 
package hellofx;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;


public class HelloFX extends Application {

    @Override
    public void start(Stage stage) {
        String javaVersion = System.getProperty("java.version");
        String javafxVersion = System.getProperty("javafx.version");
        Label l = new Label("Hello, JavaFX " + javafxVersion + ", running on Java " + javaVersion + ".");
        Scene scene = new Scene(new StackPane(l), 640, 480);
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch();
    }

}

Screenshot of output window

最佳答案

正如您可以在 this 等链接中关注的那样, thisthis .更有可能是 JDK 构建问题并恢复到较旧的 java.version例如11.0.2 应该解决这个问题。

您可以同时订阅openjdk-build/issues/1214进一步更新。

When could this occur and what could cause this?



如果 jmod为模块创建的文件在生成哈希时不一致。您可以引用JMOD tool详细说明对此负责的论点之一的文档
--hash-modules regex-pattern

Determines the leaf modules and records the hashes of the dependencies directly and indirectly requiring them, based on the module graph of the modules matching the given regex-pattern. The hashes are recorded in the JMOD archive file being created, or a JMOD archive or modular JAR on the module path specified by the jmod hash command.



此外,在下沉部分中描述了

... This let’s you to allow a package to be exported to one or more specifically-named modules and to no others through qualified exports. The runtime verifies if the recorded hash of a module matches the one resolved at run time; if not, the runtime returns an error.

关于java - 错误 : Hash of java. xml (...) 与 java.base 中记录的预期哈希 (...) 不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60904135/

相关文章:

apache-zookeeper - zookeeper - [NIOServerCnxn@383] - 导致 session 0x0 : Len error 1195725856 关闭的异常

Java 11 不可变映射 : create Map. 条目

java - 在命令提示符下运行 java 代码时出现问题

java - 在 Java 程序中记录未捕获异常的最佳实践

java - SceneBuilder 看起来与 JavaFX 程序不同?

java - 创建具有常量值的 DoubleBinding

JavaFX - 如何在计算机系统时钟的准确当前时间开始播放 24 小时视频(使用 javafx 媒体)?

java - 如何在 Jetty 中禁用 SSLv3 协议(protocol)以防止 Poodle 攻击

java - JOOQ - getPrimaryKey()、getIdentity() 返回 null

java - JPA/Spring/Delete Entity,类型不匹配(int/long for id)