import java.util.Map;
@Test
void dumpJavaOptions() {
List<String> expectedLines =
List.of(
"java",
"--dry-run",
"--patch-module",
" com.greetings=xxx",
"--module-path",
" mods",
"--module",
" com.greetings/com.greetings.Main",
"1",
"2",
"NEW");
Bach.JdkTool.Java java = new Bach.JdkTool.Java();
java.dryRun = true;
java.patchModule = Map.of("com.greetings", List.of(Paths.get("xxx")));
java.modulePath = List.of(Paths.get("mods"));
java.module = "com.greetings/com.greetings.Main";
java.args = List.of(1, "2", Thread.State.NEW);
assertLinesMatch(expectedLines, dump(java.toCommand()));
}
开发者ID:sormuras,项目名称:bach,代码行数:24,代码来源:JdkToolTests.java
import java.util.Map;
/**
* @return the list of default DirectMethodHandle methods to generate.
*/
private static Map<String, Set<String>> defaultDMHMethods() {
return Map.of(
DMH_INVOKE_VIRTUAL, Set.of("L_L", "LL_L", "LLI_I", "L3_V"),
DMH_INVOKE_SPECIAL, Set.of("LL_I", "LL_L", "LLF_L", "LLD_L", "L3_L",
"L4_L", "L5_L", "L6_L", "L7_L", "L8_L", "LLI_I", "LLI_L",
"LLIL_I", "LLII_I", "LLII_L", "L3I_L", "L3I_I", "LLILI_I",
"LLIIL_L", "LLIILL_L", "LLIILL_I", "LLIIL_I", "LLILIL_I",
"LLILILL_I", "LLILII_I", "LLI3_I", "LLI3L_I", "LLI3LL_I",
"LLI3_L", "LLI4_I"),
DMH_INVOKE_STATIC, Set.of("LII_I", "LIL_I", "LILIL_I", "LILII_I",
"L_I", "L_L", "L_V", "LD_L", "LF_L", "LI_I", "LII_L", "LLI_L",
"LL_V", "LL_L", "L3_L", "L4_L", "L5_L", "L6_L", "L7_L",
"L8_L", "L9_L", "L10_L", "L10I_L", "L10II_L", "L10IIL_L",
"L11_L", "L12_L", "L13_L", "L14_L", "L14I_L", "L14II_L")
);
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:GenerateJLIClassesPlugin.java
import java.util.Map;
/**
* Use redefineModule to update java.base to export jdk.internal.misc
*/
public void testAddExports() {
Module baseModule = Object.class.getModule();
Module thisModule = this.getClass().getClassLoader().getUnnamedModule();
String pkg = "jdk.internal.misc";
// pre-conditions
assertFalse(baseModule.isExported(pkg));
assertFalse(baseModule.isExported(pkg, thisModule));
// update java.base to export jdk.internal.misc to an unnamed module
Map<String, Set<Module>> extraExports = Map.of(pkg, Set.of(thisModule));
redefineModule(baseModule, Set.of(), extraExports, Map.of(), Set.of(), Map.of());
assertFalse(baseModule.isExported(pkg));
assertTrue(baseModule.isExported(pkg, thisModule));
assertFalse(baseModule.isOpen(pkg));
assertFalse(baseModule.isOpen(pkg, thisModule));
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:RedefineModuleTest.java
import java.util.Map;
/**
* Use redefineModule to update java.base to open jdk.internal.loader
*/
public void testAddOpens() {
Module baseModule = Object.class.getModule();
Module thisModule = this.getClass().getClassLoader().getUnnamedModule();
String pkg = "jdk.internal.loader";
// pre-conditions
assertFalse(baseModule.isOpen(pkg));
assertFalse(baseModule.isOpen(pkg, thisModule));
// update java.base to open dk.internal.loader to an unnamed module
Map<String, Set<Module>> extraExports = Map.of(pkg, Set.of(thisModule));
redefineModule(baseModule, Set.of(), Map.of(), extraExports, Set.of(), Map.of());
assertFalse(baseModule.isExported(pkg));
assertTrue(baseModule.isExported(pkg, thisModule));
assertFalse(baseModule.isOpen(pkg));
assertTrue(baseModule.isOpen(pkg, thisModule));
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:RedefineModuleTest.java
import java.util.Map;
/**
* Test redefineClass by attempting to update java.base to provide a service
* where the service provider class is not in the module.
*/
@Test(expectedExceptions = IllegalArgumentException.class)
public void testProvideServiceNotInModule() {
Module baseModule = Object.class.getModule();
class MyProvider extends URLStreamHandlerProvider {
@Override
public URLStreamHandler createURLStreamHandler(String protocol) {
return null;
}
}
// attempt to update java.base to provide MyProvider
Map<Class<?>, List<Class<?>>> extraProvides
= Map.of(URLStreamHandlerProvider.class, List.of(MyProvider.class));
redefineModule(baseModule, Set.of(), Map.of(), Map.of(), Set.of(), extraProvides);
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:RedefineModuleTest.java
import java.util.Map; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullValueDisallowed2() {
Map<Integer, String> map = Map.of(0, "a", 1, null);
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:MapFactories.java
import java.util.Map;
@Test(expectedExceptions=NullPointerException.class)
public void nullValueDisallowed1() {
Map<Integer, String> map = Map.of(0, null);
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:MapFactories.java
import java.util.Map;
@Test(expectedExceptions = IllegalArgumentException.class)
public void testExportPackageToEmptySet() {
// attempt to update java.base to export jdk.internal.misc to nobody
Module baseModule = Object.class.getModule();
Map<String, Set<Module>> extraExports = Map.of("jdk.internal.misc", Set.of());
redefineModule(baseModule, Set.of(), extraExports, Map.of(), Set.of(), Map.of());
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:RedefineModuleTest.java
import java.util.Map; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullKeyDisallowed7() {
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e",
5, "f", null, "g");
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:MapFactories.java
import java.util.Map; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullKeyDisallowed9() {
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e",
5, "f", 6, "g", 7, "h", null, "i");
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:MapFactories.java
import java.util.Map; //导入方法依赖的package包/类
public Map<String, List<String>>
get(URI uri, Map<String, List<String>> requestHeaders)
throws IOException
{
// pre-condition check
if (uri == null || requestHeaders == null) {
throw new IllegalArgumentException("Argument is null");
}
// if there's no default CookieStore, no way for us to get any cookie
if (cookieJar == null)
return Map.of();
boolean secureLink = "https".equalsIgnoreCase(uri.getScheme());
List<HttpCookie> cookies = new java.util.ArrayList<>();
String path = uri.getPath();
if (path == null || path.isEmpty()) {
path = "/";
}
for (HttpCookie cookie : cookieJar.get(uri)) {
// apply path-matches rule (RFC 2965 sec. 3.3.4)
// and check for the possible "secure" tag (i.e. don't send
// 'secure' cookies over unsecure links)
if (pathMatches(path, cookie.getPath()) &&
(secureLink || !cookie.getSecure())) {
// Enforce httponly attribute
if (cookie.isHttpOnly()) {
String s = uri.getScheme();
if (!"http".equalsIgnoreCase(s) && !"https".equalsIgnoreCase(s)) {
continue;
}
}
// Let's check the authorize port list if it exists
String ports = cookie.getPortlist();
if (ports != null && !ports.isEmpty()) {
int port = uri.getPort();
if (port == -1) {
port = "https".equals(uri.getScheme()) ? 443 : 80;
}
if (isInPortList(ports, port)) {
cookies.add(cookie);
}
} else {
cookies.add(cookie);
}
}
}
// apply sort rule (RFC 2965 sec. 3.3.4)
List<String> cookieHeader = sortByPath(cookies);
return Map.of("Cookie", cookieHeader);
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:54,代码来源:CookieManager.java
import java.util.Map; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullValueDisallowed8() {
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e",
5, "f", 6, "g", 7, null);
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:MapFactories.java
import java.util.Map; //导入方法依赖的package包/类
@Test(expectedExceptions=IllegalArgumentException.class)
public void dupKeysDisallowed9() {
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e",
5, "f", 6, "g", 7, "h", 0, "i");
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:MapFactories.java
import java.util.Map; //导入方法依赖的package包/类
@Test(expectedExceptions=IllegalArgumentException.class)
public void dupKeysDisallowed10() {
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e",
5, "f", 6, "g", 7, "h", 8, "i", 0, "j");
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:MapFactories.java
import java.util.Map; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullValueDisallowed5() {
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, null);
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:MapFactories.java
import java.util.Map; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullValueDisallowed4() {
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, null);
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:MapFactories.java
import java.util.Map; //导入方法依赖的package包/类
@Test(expectedExceptions=IllegalArgumentException.class)
public void dupKeysDisallowed2() {
Map<Integer, String> map = Map.of(0, "a", 0, "b");
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:MapFactories.java
import java.util.Map; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullKeyDisallowed10() {
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e",
5, "f", 6, "g", 7, "h", 8, "i", null, "j");
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:MapFactories.java
import java.util.Map; //导入方法依赖的package包/类
@Test(expectedExceptions=IllegalArgumentException.class)
public void dupKeysDisallowed4() {
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 0, "d");
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:MapFactories.java
import java.util.Map; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullValueDisallowed9() {
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e",
5, "f", 6, "g", 7, "h", 8, null);
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:MapFactories.java