35
35
* @run main/manual/othervm Compatibility
36
36
*/
37
37
38
+ import static java .nio .charset .StandardCharsets .UTF_8 ;
39
+
38
40
import java .io .BufferedReader ;
39
41
import java .io .File ;
40
42
import java .io .FileOutputStream ;
43
45
import java .io .IOException ;
44
46
import java .io .OutputStream ;
45
47
import java .io .PrintStream ;
46
- import java .nio .file .Path ;
47
48
import java .nio .file .Files ;
49
+ import java .nio .file .Path ;
48
50
import java .text .DateFormat ;
49
51
import java .text .SimpleDateFormat ;
50
- import java .util .Arrays ;
51
52
import java .util .ArrayList ;
53
+ import java .util .Arrays ;
52
54
import java .util .Calendar ;
53
55
import java .util .Date ;
54
56
import java .util .HashMap ;
57
59
import java .util .Locale ;
58
60
import java .util .Map ;
59
61
import java .util .Set ;
62
+ import java .util .concurrent .TimeUnit ;
60
63
import java .util .function .Consumer ;
61
64
import java .util .function .Function ;
62
- import java .util .jar .Manifest ;
63
65
import java .util .jar .Attributes .Name ;
64
- import java .util .concurrent . TimeUnit ;
66
+ import java .util .jar . Manifest ;
65
67
import java .util .stream .Collectors ;
66
68
import java .util .stream .IntStream ;
69
+
67
70
import jdk .test .lib .process .OutputAnalyzer ;
68
71
import jdk .test .lib .process .ProcessTools ;
69
72
import jdk .test .lib .util .JarUtils ;
70
73
71
- import static java .nio .charset .StandardCharsets .UTF_8 ;
72
-
73
74
public class Compatibility {
74
75
75
76
private static final String TEST_SRC = System .getProperty ("test.src" );
@@ -179,7 +180,7 @@ public static void main(String... args) throws Throwable {
179
180
List <SignItem > signItems =
180
181
test (jdkInfoList , tsaList , certList , createJars ());
181
182
182
- boolean failed = generateReport (tsaList , signItems );
183
+ boolean failed = generateReport (jdkInfoList , tsaList , signItems );
183
184
184
185
// Restores the original stdout and stderr.
185
186
System .setOut (origStdOut );
@@ -415,11 +416,15 @@ private static List<JdkInfo> jdkInfoList() throws Throwable {
415
416
}
416
417
417
418
List <JdkInfo > jdkInfoList = new ArrayList <>();
419
+ int index = 0 ;
418
420
for (String jdkPath : jdkList ) {
419
421
JdkInfo jdkInfo = "TEST_JDK" .equalsIgnoreCase (jdkPath ) ?
420
422
TEST_JDK_INFO : new JdkInfo (jdkPath );
421
423
// The JDK version must be unique.
422
424
if (!jdkInfoList .contains (jdkInfo )) {
425
+ jdkInfo .index = index ++;
426
+ jdkInfo .version = String .format (
427
+ "%s(%d)" , jdkInfo .version , jdkInfo .index );
423
428
jdkInfoList .add (jdkInfo );
424
429
} else {
425
430
System .out .println ("The JDK version is duplicate: " + jdkPath );
@@ -908,13 +913,22 @@ private static OutputAnalyzer verifyJar(String jarsignerPath,
908
913
}
909
914
910
915
// Generates the test result report.
911
- private static boolean generateReport (List <TsaInfo > tsaList ,
916
+ private static boolean generateReport (List <JdkInfo > jdkList , List < TsaInfo > tsaList ,
912
917
List <SignItem > signItems ) throws IOException {
913
918
System .out .println ("Report is being generated..." );
914
919
915
920
StringBuilder report = new StringBuilder ();
916
921
report .append (HtmlHelper .startHtml ());
917
922
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
+
918
932
// Generates TSA URLs
919
933
report .append ("TSA list:\n " );
920
934
for (TsaInfo tsaInfo : tsaList ) {
@@ -1024,24 +1038,27 @@ private static OutputAnalyzer execTool(String toolPath, String... args)
1024
1038
1025
1039
private static class JdkInfo {
1026
1040
1041
+ private int index ;
1027
1042
private final String jdkPath ;
1028
1043
private final String jarsignerPath ;
1029
- private final String version ;
1044
+ private final String runtimeVersion ;
1045
+ private String version ;
1030
1046
private final int majorVersion ;
1031
1047
private final boolean supportsTsadigestalg ;
1032
1048
1033
1049
private Map <String , Boolean > sigalgMap = new HashMap <>();
1034
1050
1035
1051
private JdkInfo (String jdkPath ) throws Throwable {
1036
1052
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 ()) {
1039
1056
throw new RuntimeException (
1040
1057
"Cannot determine the JDK version: " + jdkPath );
1041
1058
}
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].*$" , "" ) );
1045
1062
supportsTsadigestalg = execTool (jarsignerPath , "-help" )
1046
1063
.getOutput ().contains ("-tsadigestalg" );
1047
1064
}
@@ -1073,7 +1090,7 @@ public int hashCode() {
1073
1090
final int prime = 31 ;
1074
1091
int result = 1 ;
1075
1092
result = prime * result
1076
- + ((version == null ) ? 0 : version .hashCode ());
1093
+ + ((runtimeVersion == null ) ? 0 : runtimeVersion .hashCode ());
1077
1094
return result ;
1078
1095
}
1079
1096
@@ -1086,17 +1103,17 @@ public boolean equals(Object obj) {
1086
1103
if (getClass () != obj .getClass ())
1087
1104
return false ;
1088
1105
JdkInfo other = (JdkInfo ) obj ;
1089
- if (version == null ) {
1090
- if (other .version != null )
1106
+ if (runtimeVersion == null ) {
1107
+ if (other .runtimeVersion != null )
1091
1108
return false ;
1092
- } else if (!version .equals (other .version ))
1109
+ } else if (!runtimeVersion .equals (other .runtimeVersion ))
1093
1110
return false ;
1094
1111
return true ;
1095
1112
}
1096
1113
1097
1114
@ Override
1098
1115
public String toString () {
1099
- return "JdkInfo[" + version + ", " + jdkPath + "]" ;
1116
+ return "JdkInfo[" + runtimeVersion + ", " + jdkPath + "]" ;
1100
1117
}
1101
1118
}
1102
1119
0 commit comments