3535 * @run main/manual/othervm Compatibility
3636 */
3737
38+ import static java .nio .charset .StandardCharsets .UTF_8 ;
39+
3840import java .io .BufferedReader ;
3941import java .io .File ;
4042import java .io .FileOutputStream ;
4345import java .io .IOException ;
4446import java .io .OutputStream ;
4547import java .io .PrintStream ;
46- import java .nio .file .Path ;
4748import java .nio .file .Files ;
49+ import java .nio .file .Path ;
4850import java .text .DateFormat ;
4951import java .text .SimpleDateFormat ;
50- import java .util .Arrays ;
5152import java .util .ArrayList ;
53+ import java .util .Arrays ;
5254import java .util .Calendar ;
5355import java .util .Date ;
5456import java .util .HashMap ;
5759import java .util .Locale ;
5860import java .util .Map ;
5961import java .util .Set ;
62+ import java .util .concurrent .TimeUnit ;
6063import java .util .function .Consumer ;
6164import java .util .function .Function ;
62- import java .util .jar .Manifest ;
6365import java .util .jar .Attributes .Name ;
64- import java .util .concurrent . TimeUnit ;
66+ import java .util .jar . Manifest ;
6567import java .util .stream .Collectors ;
6668import java .util .stream .IntStream ;
69+
6770import jdk .test .lib .process .OutputAnalyzer ;
6871import jdk .test .lib .process .ProcessTools ;
6972import jdk .test .lib .util .JarUtils ;
7073
71- import static java .nio .charset .StandardCharsets .UTF_8 ;
72-
7374public class Compatibility {
7475
7576 private static final String TEST_SRC = System .getProperty ("test.src" );
@@ -179,7 +180,7 @@ public static void main(String... args) throws Throwable {
179180 List <SignItem > signItems =
180181 test (jdkInfoList , tsaList , certList , createJars ());
181182
182- boolean failed = generateReport (tsaList , signItems );
183+ boolean failed = generateReport (jdkInfoList , tsaList , signItems );
183184
184185 // Restores the original stdout and stderr.
185186 System .setOut (origStdOut );
@@ -415,11 +416,15 @@ private static List<JdkInfo> jdkInfoList() throws Throwable {
415416 }
416417
417418 List <JdkInfo > jdkInfoList = new ArrayList <>();
419+ int index = 0 ;
418420 for (String jdkPath : jdkList ) {
419421 JdkInfo jdkInfo = "TEST_JDK" .equalsIgnoreCase (jdkPath ) ?
420422 TEST_JDK_INFO : new JdkInfo (jdkPath );
421423 // The JDK version must be unique.
422424 if (!jdkInfoList .contains (jdkInfo )) {
425+ jdkInfo .index = index ++;
426+ jdkInfo .version = String .format (
427+ "%s(%d)" , jdkInfo .version , jdkInfo .index );
423428 jdkInfoList .add (jdkInfo );
424429 } else {
425430 System .out .println ("The JDK version is duplicate: " + jdkPath );
@@ -908,13 +913,22 @@ private static OutputAnalyzer verifyJar(String jarsignerPath,
908913 }
909914
910915 // Generates the test result report.
911- private static boolean generateReport (List <TsaInfo > tsaList ,
916+ private static boolean generateReport (List <JdkInfo > jdkList , List < TsaInfo > tsaList ,
912917 List <SignItem > signItems ) throws IOException {
913918 System .out .println ("Report is being generated..." );
914919
915920 StringBuilder report = new StringBuilder ();
916921 report .append (HtmlHelper .startHtml ());
917922 report .append (HtmlHelper .startPre ());
923+
924+ // Generates JDK list
925+ report .append ("JDK list:\n " );
926+ for (JdkInfo jdkInfo : jdkList ) {
927+ report .append (String .format ("%d=%s%n" ,
928+ jdkInfo .index ,
929+ jdkInfo .runtimeVersion ));
930+ }
931+
918932 // Generates TSA URLs
919933 report .append ("TSA list:\n " );
920934 for (TsaInfo tsaInfo : tsaList ) {
@@ -1024,24 +1038,27 @@ private static OutputAnalyzer execTool(String toolPath, String... args)
10241038
10251039 private static class JdkInfo {
10261040
1041+ private int index ;
10271042 private final String jdkPath ;
10281043 private final String jarsignerPath ;
1029- private final String version ;
1044+ private final String runtimeVersion ;
1045+ private String version ;
10301046 private final int majorVersion ;
10311047 private final boolean supportsTsadigestalg ;
10321048
10331049 private Map <String , Boolean > sigalgMap = new HashMap <>();
10341050
10351051 private JdkInfo (String jdkPath ) throws Throwable {
10361052 this .jdkPath = jdkPath ;
1037- version = execJdkUtils (jdkPath , JdkUtils .M_JAVA_RUNTIME_VERSION );
1038- if (version == null || version .isBlank ()) {
1053+ jarsignerPath = jarsignerPath (jdkPath );
1054+ runtimeVersion = execJdkUtils (jdkPath , JdkUtils .M_JAVA_RUNTIME_VERSION );
1055+ if (runtimeVersion == null || runtimeVersion .isBlank ()) {
10391056 throw new RuntimeException (
10401057 "Cannot determine the JDK version: " + jdkPath );
10411058 }
1042- majorVersion = Integer . parseInt (( version . matches ( "^1[.].*" ) ?
1043- version . substring ( 2 ) : version ). replaceAll ( "[^0-9 ].*$" , "" ));
1044- jarsignerPath = jarsignerPath ( jdkPath );
1059+ version = execJdkUtils ( jdkPath , JdkUtils . M_JAVA_VERSION );
1060+ majorVersion = Integer . parseInt (( runtimeVersion . matches ( "^1[. ].*" ) ?
1061+ runtimeVersion . substring ( 2 ) : runtimeVersion ). replaceAll ( "[^0-9].*$" , "" ) );
10451062 supportsTsadigestalg = execTool (jarsignerPath , "-help" )
10461063 .getOutput ().contains ("-tsadigestalg" );
10471064 }
@@ -1073,7 +1090,7 @@ public int hashCode() {
10731090 final int prime = 31 ;
10741091 int result = 1 ;
10751092 result = prime * result
1076- + ((version == null ) ? 0 : version .hashCode ());
1093+ + ((runtimeVersion == null ) ? 0 : runtimeVersion .hashCode ());
10771094 return result ;
10781095 }
10791096
@@ -1086,17 +1103,17 @@ public boolean equals(Object obj) {
10861103 if (getClass () != obj .getClass ())
10871104 return false ;
10881105 JdkInfo other = (JdkInfo ) obj ;
1089- if (version == null ) {
1090- if (other .version != null )
1106+ if (runtimeVersion == null ) {
1107+ if (other .runtimeVersion != null )
10911108 return false ;
1092- } else if (!version .equals (other .version ))
1109+ } else if (!runtimeVersion .equals (other .runtimeVersion ))
10931110 return false ;
10941111 return true ;
10951112 }
10961113
10971114 @ Override
10981115 public String toString () {
1099- return "JdkInfo[" + version + ", " + jdkPath + "]" ;
1116+ return "JdkInfo[" + runtimeVersion + ", " + jdkPath + "]" ;
11001117 }
11011118 }
11021119
0 commit comments