-
Enhancement
-
Resolution: Fixed
-
P4
-
None
-
b14
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8283418 | 11.0.16 | Christoph Langer | P4 | Resolved | Fixed | b01 |
We see some inconsistency of module-info.class in java.base.jmod across different builds.
$ jmod extract java.base.jmod
$ cd classes
$ javap -v module-info.class
$ diff old-class.info new-class.info
1c1
< Classfile /home/sunjianye/bep_compare/old/classes/module-info.class
---
> Classfile /home/sunjianye/bep_compare/new/classes/module-info.class
3c3
< MD5 checksum f76c99747727a55976dca003d1bc8faa
---
> MD5 checksum 701d2aee48a029f896f426dde5fd5cb3
1130,1132d1129
< #527 // java.transaction.xa
< hash_length: 32
< hash: [d3caeb7d503e86206fbfc08aa88f0a491eb2c3cd984575e3b8069575406c6af0]
1138a1136,1138
> #527 // java.transaction.xa
> hash_length: 32
> hash: [d3caeb7d503e86206fbfc08aa88f0a491eb2c3cd984575e3b8069575406c6af0]
Proposed fix:
diff -r 3437fb6311fd src/java.base/share/classes/jdk/internal/module/ModuleHashes.java
--- a/src/java.base/share/classes/jdk/internal/module/ModuleHashes.java Mon Mar 09 04:06:37 2020 -0400
+++ b/src/java.base/share/classes/jdk/internal/module/ModuleHashes.java Mon Mar 09 17:53:12 2020 +0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,7 @@
import java.security.NoSuchAlgorithmException;
import java.util.Collections;
import java.util.HashMap;
+import java.util.TreeMap;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
@@ -134,7 +135,7 @@
* @return ModuleHashes that encapsulates the hashes
*/
public static ModuleHashes generate(Map<String, Path> map, String algorithm) {
- Map<String, byte[]> nameToHash = new HashMap<>();
+ Map<String, byte[]> nameToHash = new TreeMap<>();
for (Map.Entry<String, Path> entry: map.entrySet()) {
String name = entry.getKey();
Path path = entry.getValue();
diff -r 3437fb6311fd src/java.base/share/classes/jdk/internal/module/ModuleHashesBuilder.java
--- a/src/java.base/share/classes/jdk/internal/module/ModuleHashesBuilder.java Mon Mar 09 04:06:37 2020 -0400
+++ b/src/java.base/share/classes/jdk/internal/module/ModuleHashesBuilder.java Mon Mar 09 17:53:12 2020 +0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,7 @@
import java.util.Collections;
import java.util.Deque;
import java.util.HashMap;
+import java.util.TreeMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -98,7 +99,7 @@
// the modules to record the hashes - it is the first matching
// module and has not been hashed during the traversal.
Set<String> mods = new HashSet<>();
- Map<String, ModuleHashes> hashes = new HashMap<>();
+ Map<String, ModuleHashes> hashes = new TreeMap<>();
builder.build()
.orderedNodes()
.filter(mn -> roots.contains(mn) && !mods.contains(mn))
$ jmod extract java.base.jmod
$ cd classes
$ javap -v module-info.class
$ diff old-class.info new-class.info
1c1
< Classfile /home/sunjianye/bep_compare/old/classes/module-info.class
---
> Classfile /home/sunjianye/bep_compare/new/classes/module-info.class
3c3
< MD5 checksum f76c99747727a55976dca003d1bc8faa
---
> MD5 checksum 701d2aee48a029f896f426dde5fd5cb3
1130,1132d1129
< #527 // java.transaction.xa
< hash_length: 32
< hash: [d3caeb7d503e86206fbfc08aa88f0a491eb2c3cd984575e3b8069575406c6af0]
1138a1136,1138
> #527 // java.transaction.xa
> hash_length: 32
> hash: [d3caeb7d503e86206fbfc08aa88f0a491eb2c3cd984575e3b8069575406c6af0]
Proposed fix:
diff -r 3437fb6311fd src/java.base/share/classes/jdk/internal/module/ModuleHashes.java
--- a/src/java.base/share/classes/jdk/internal/module/ModuleHashes.java Mon Mar 09 04:06:37 2020 -0400
+++ b/src/java.base/share/classes/jdk/internal/module/ModuleHashes.java Mon Mar 09 17:53:12 2020 +0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,7 @@
import java.security.NoSuchAlgorithmException;
import java.util.Collections;
import java.util.HashMap;
+import java.util.TreeMap;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
@@ -134,7 +135,7 @@
* @return ModuleHashes that encapsulates the hashes
*/
public static ModuleHashes generate(Map<String, Path> map, String algorithm) {
- Map<String, byte[]> nameToHash = new HashMap<>();
+ Map<String, byte[]> nameToHash = new TreeMap<>();
for (Map.Entry<String, Path> entry: map.entrySet()) {
String name = entry.getKey();
Path path = entry.getValue();
diff -r 3437fb6311fd src/java.base/share/classes/jdk/internal/module/ModuleHashesBuilder.java
--- a/src/java.base/share/classes/jdk/internal/module/ModuleHashesBuilder.java Mon Mar 09 04:06:37 2020 -0400
+++ b/src/java.base/share/classes/jdk/internal/module/ModuleHashesBuilder.java Mon Mar 09 17:53:12 2020 +0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,7 @@
import java.util.Collections;
import java.util.Deque;
import java.util.HashMap;
+import java.util.TreeMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -98,7 +99,7 @@
// the modules to record the hashes - it is the first matching
// module and has not been hashed during the traversal.
Set<String> mods = new HashSet<>();
- Map<String, ModuleHashes> hashes = new HashMap<>();
+ Map<String, ModuleHashes> hashes = new TreeMap<>();
builder.build()
.orderedNodes()
.filter(mn -> roots.contains(mn) && !mods.contains(mn))
- backported by
-
JDK-8283418 ModuleHashes attribute not reproducible between builds
- Resolved
- relates to
-
JDK-8240903 Add test to check that jmod hashes are reproducible
- Resolved