changeset 55420:bc5a0508253c

8225748: Use SHA-256 for javap classfile checksum Reviewed-by: mchung
author jjg
date Tue, 18 Jun 2019 11:52:57 -0700
parents 3e08fa647eea
children 688a2a361e14 afc6c25c2f4a
files src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java src/jdk.jdeps/share/classes/com/sun/tools/javap/JavapTask.java src/jdk.jdeps/share/classes/com/sun/tools/javap/resources/javap.properties test/langtools/tools/javac/T6942649.java test/langtools/tools/javap/T4884240.java
diffstat 5 files changed, 11 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java	Tue Jun 18 12:39:29 2019 -0500
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java	Tue Jun 18 11:52:57 2019 -0700
@@ -477,7 +477,7 @@
         }
 
         try (InputStream in = getClass().getResourceAsStream('/' + className.replace('.', '/') + ".class")) {
-            final String algorithm = "MD5";
+            final String algorithm = "SHA-256";
             byte[] digest;
             MessageDigest md = MessageDigest.getInstance(algorithm);
             try (DigestInputStream din = new DigestInputStream(in, md)) {
--- a/src/jdk.jdeps/share/classes/com/sun/tools/javap/JavapTask.java	Tue Jun 18 12:39:29 2019 -0500
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/javap/JavapTask.java	Tue Jun 18 11:52:57 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2019, 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
@@ -808,7 +808,7 @@
             MessageDigest md  = null;
             if (options.sysInfo || options.verbose) {
                 try {
-                    md = MessageDigest.getInstance("MD5");
+                    md = MessageDigest.getInstance("SHA-256");
                 } catch (NoSuchAlgorithmException ignore) {
                 }
                 in = new DigestInputStream(in, md);
@@ -829,7 +829,7 @@
         if (options.sysInfo || options.verbose) {
             classWriter.setFile(info.fo.toUri());
             classWriter.setLastModified(info.fo.getLastModified());
-            classWriter.setDigest("MD5", info.digest);
+            classWriter.setDigest("SHA-256", info.digest);
             classWriter.setFileSize(info.size);
         }
 
--- a/src/jdk.jdeps/share/classes/com/sun/tools/javap/resources/javap.properties	Tue Jun 18 12:39:29 2019 -0500
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/javap/resources/javap.properties	Tue Jun 18 11:52:57 2019 -0700
@@ -99,7 +99,7 @@
 \  -constants                       Show final constants
 
 main.opt.sysinfo=\
-\  -sysinfo                         Show system info (path, size, date, MD5 hash)\n\
+\  -sysinfo                         Show system info (path, size, date, SHA-256 hash)\n\
 \                                   of class being processed
 
 main.opt.module=\
--- a/test/langtools/tools/javac/T6942649.java	Tue Jun 18 12:39:29 2019 -0500
+++ b/test/langtools/tools/javac/T6942649.java	Tue Jun 18 11:52:57 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2019, 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
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 6942649
+ * @bug 6942649 8225748
  * @summary add hidden option to identify location and version of javac classes
  * @modules jdk.compiler
  */
@@ -60,7 +60,7 @@
                 throw new Exception("location of class not found in output");
         }
 
-        if (!out.contains("MD5 checksum: "))
+        if (!out.contains("SHA-256 checksum: "))
             throw new Exception("checksum not found in output");
     }
 }
--- a/test/langtools/tools/javap/T4884240.java	Tue Jun 18 12:39:29 2019 -0500
+++ b/test/langtools/tools/javap/T4884240.java	Tue Jun 18 11:52:57 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2019, 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
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 4884240
+ * @bug 4884240 8225748
  * @summary additional option required for javap
  * @modules jdk.jdeps/com.sun.tools.javap
  */
@@ -47,7 +47,7 @@
         if (lines.length < 3
             || !lines[0].trim().startsWith("Classfile")
             || !lines[1].trim().startsWith("Last modified")
-            || !lines[2].trim().startsWith("MD5")) {
+            || !lines[2].trim().startsWith("SHA-256")) {
             System.out.println(sw);
             throw new Exception("unexpected output");
         }