Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sun/security/krb5/auto/ModuleName.java
41152 views
1
/*
2
* Copyright (c) 2017, 2018, 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 8164437 8194486
27
* @summary GSSContext type when jdk.security.jgss is not available
28
* @library /test/lib
29
* @compile -XDignore.symbol.file ModuleName.java
30
* @build jdk.test.lib.Utils
31
* jdk.test.lib.Asserts
32
* jdk.test.lib.JDKToolFinder
33
* jdk.test.lib.JDKToolLauncher
34
* jdk.test.lib.Platform
35
* jdk.test.lib.process.*
36
* @run main jdk.test.lib.FileInstaller TestHosts TestHosts
37
* @run main/othervm -Djdk.net.hosts.file=TestHosts ModuleName
38
*/
39
40
import jdk.test.lib.process.ProcessTools;
41
import sun.security.jgss.GSSUtil;
42
43
import java.util.List;
44
import java.util.stream.Stream;
45
46
public class ModuleName {
47
48
public static void main(String[] args) throws Throwable {
49
50
if (args.length == 0) { // jtreg launched here
51
52
// With all modules
53
test("jdk.security.jgss");
54
55
// With limited modules
56
List<String> cmd = ProcessTools.createJavaProcessBuilder().command();
57
Stream.of(jdk.internal.misc.VM.getRuntimeArguments())
58
.filter(arg -> arg.startsWith("--add-exports=") ||
59
arg.startsWith("--add-opens="))
60
.forEach(cmd::add);
61
cmd.addAll(List.of(
62
"-Djdk.net.hosts.file=TestHosts",
63
"-Dtest.src=" + System.getProperty("test.src"),
64
"--add-modules",
65
"java.base,java.security.jgss,jdk.security.auth",
66
"--limit-modules",
67
"java.security.jgss,jdk.security.auth",
68
"ModuleName",
69
"launched-limited"));
70
ProcessTools.executeCommand(cmd.toArray(new String[cmd.size()]))
71
.shouldHaveExitValue(0);
72
} else { // Launched by ProcessTools above, with limited modules.
73
test("java.security.jgss");
74
}
75
}
76
77
static void test(String expected) throws Exception {
78
79
new OneKDC(null).writeJAASConf();
80
81
Context c = Context.fromJAAS("client");
82
c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID);
83
84
String moduleName = c.x().getClass().getModule().getName();
85
if (!moduleName.equals(expected)) {
86
throw new Exception("Expected: " + expected
87
+ ". Actual: " + moduleName);
88
}
89
}
90
}
91
92