Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/crypto/sanity/CheckManifestForRelease.java
38839 views
1
/*
2
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/*
25
* @test
26
* @bug 7197071
27
* @summary Makefiles for various security providers aren't including
28
* the default manifest.
29
*/
30
import java.net.*;
31
import java.io.*;
32
33
/**
34
* When the Java specification version is incremented, all of the providers
35
* must be recompiled with the proper implementation version to match.
36
*/
37
public class CheckManifestForRelease {
38
39
/**
40
* @param args the command line arguments
41
*/
42
public static void main(String[] args) throws Exception {
43
checkFileManifests();
44
}
45
46
/*
47
* Iterate over the files of interest: JCE framework and providers
48
*/
49
static private void checkFileManifests() throws Exception {
50
System.out.println("=============");
51
String libDirName = System.getProperty("java.home", ".") + "/lib";
52
String extDirName = libDirName + "/ext";
53
54
System.out.println("Checking Manifest in directory: \n " +
55
extDirName);
56
57
/*
58
* Current list of JCE providers, all of which currently live in
59
* the extensions directory. Add if more are created.
60
*/
61
String[] providers = new String[]{
62
"sunjce_provider.jar",
63
"sunec.jar",
64
"sunmscapi.jar",
65
"sunpkcs11.jar",
66
"ucrypto.jar"
67
};
68
69
checkManifest(libDirName, "jce.jar");
70
for (String provider : providers) {
71
checkManifest(extDirName, provider);
72
}
73
System.out.println("Passed.");
74
}
75
76
// Helper method to format the URL properly.
77
static private String formatURL(String dir, String file) {
78
return "jar:file:///" + dir + "/" + file + "!/";
79
}
80
81
static private String specVersion =
82
System.getProperty("java.specification.version");
83
84
/*
85
* Test the root cause, which is that there were no manifest values
86
* for many of the providers, and for those that had them, there was
87
* no test to make sure that the impl version was appropriate for
88
* the spec version.
89
*/
90
static private void checkManifest(String dir, String file)
91
throws Exception {
92
93
System.out.println("Checking: " + file);
94
95
String url = formatURL(dir, file);
96
JarURLConnection urlc =
97
(JarURLConnection) (new URL(url).openConnection());
98
99
String implVersion;
100
try {
101
implVersion = urlc.getManifest().getMainAttributes().getValue(
102
"Implementation-Version");
103
} catch (FileNotFoundException e) {
104
/*
105
* If the file doesn't exist (e.g. mscapi on solaris),
106
* skip it. If there are other problems, fail out.
107
*/
108
System.out.println(" " + file + " not found, skipping...");
109
return;
110
}
111
112
if (implVersion == null) {
113
throw new Exception(
114
"Implementation-Version not found in Manifest");
115
}
116
117
if (!implVersion.startsWith(specVersion)) {
118
throw new Exception(
119
"Implementation-Version does not match " +
120
"Specification-Version");
121
}
122
}
123
}
124
125