错误:java.xml的哈希(...)与java.base中记录的预期哈希(...)不同 [英] Error: Hash of java.xml (...) differs to expected hash (...) recorded in java.base

查看:147
本文介绍了错误:java.xml的哈希(...)与java.base中记录的预期哈希(...)不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Creating simple javafx 11 "hello world" application. Getting error while creating custom 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

OS: ubuntu 19.10

$ java --version openjdk 11.0.6 2020-01-14 OpenJDK运行时环境(内部版本11.0.6 + 10-post-Ubuntu-1ubuntu119.10.1) OpenJDK 64位服务器VM(版本11.0.6 + 10-post-Ubuntu-1ubuntu119.10.1,混合模式,共享)

$java --version openjdk 11.0.6 2020-01-14 OpenJDK Runtime Environment (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, mixed mode, sharing)

$ javac-版本 javac 11.0.6

$javac --version 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

run.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

module-info.java:

module-info.java:

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

    exports hellofx;
}

HelloFX.java:

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();
    }

}

输出窗口的屏幕截图

推荐答案

您可以在诸如.很可能是JDK构建问题,并恢复到较旧的java.version,例如11.0.2应该可以解决此问题.

As you could follow in the links such as this, this and this. It is more likely a JDK build issue and reverting to an older java.version e.g. 11.0.2 should fix this.

与此同时,您可以订阅 openjdk-build/issues/1214 以获取进一步的更新.

You can subscribe in the meanwhile to openjdk-build/issues/1214 for further updates.

什么时候会发生?什么原因可能导致这种情况?

When could this occur and what could cause this?

如果为模块创建的jmod文件在生成哈希时不一致,则可能会发生这种情况.您可以参考 JMOD工具文档,其中详细说明了引起此问题的一个参数

This could occur if the jmod files created for a module are not consistent in generating the hash. You can refer to the JMOD tool documentation which elaborates on one of the arguments responsible for this

--hash-modules regex-pattern

确定叶子模块并记录依赖项的哈希值 根据...的模块图直接或间接地要求它们 匹配给定正则表达式模式的模块.记录哈希 在要创建的JMOD归档文件文件中,或者是 JMOD归档文件或模块化文件中 由jmod hash命令指定的模块路径上的JAR.

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.

并且在一个辅助小节中进行了描述

and furthermore in a subsided section describes

...这使您可以将软件包导出到一个或多个 专门命名的模块,并且通过合格的出口没有其他模块. 运行时验证模块记录的哈希值是否与该哈希值匹配 在运行时解决;如果不是,则运行时返回错误 .

... 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.xml的哈希(...)与java.base中记录的预期哈希(...)不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆