Java Code Examples for java.util.Map.ofEntries()

The following are Jave code examples for showing how to use ofEntries() of the java.util.Map class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: openjdk-jdk10   File: Configuration.java   View Source Code Vote up 6 votes
private Configuration(List<Configuration> parents, Resolver resolver) {
    Map<ResolvedModule, Set<ResolvedModule>> g = resolver.finish(this);

    @SuppressWarnings(value = {"rawtypes", "unchecked"})
    Entry<String, ResolvedModule>[] nameEntries
        = (Entry<String, ResolvedModule>[])new Entry[g.size()];
    ResolvedModule[] moduleArray = new ResolvedModule[g.size()];
    int i = 0;
    for (ResolvedModule resolvedModule : g.keySet()) {
        moduleArray[i] = resolvedModule;
        nameEntries[i] = Map.entry(resolvedModule.name(), resolvedModule);
        i++;
    }

    this.parents = Collections.unmodifiableList(parents);
    this.graph = g;
    this.modules = Set.of(moduleArray);
    this.nameToModule = Map.ofEntries(nameEntries);

    this.targetPlatform = resolver.targetPlatform();
}
 
Example 2
Project: openjdk-jdk10   File: MapFactories.java   View Source Code Vote up 5 votes
@Test
public void entryWildcardTests() {
    Map.Entry<Integer,Double> e1 = Map.entry(1, 2.0);
    Map.Entry<Float,Long> e2 = Map.entry(3.0f, 4L);
    Map<Number,Number> map = Map.ofEntries(e1, e2);
    assertEquals(map.size(), 2);
}
 
Example 3
Project: openjdk-jdk10   File: SystemModuleFinders.java   View Source Code Vote up 4 votes
SystemModuleFinder(ModuleReference[] array,
                   Map.Entry<String, ModuleReference>[] map) {
    this.mrefs = Set.of(array);
    this.nameToModule = Map.ofEntries(map);
}
 
Example 4
Project: openjdk-jdk10   File: VM.java   View Source Code Vote up 4 votes
public static void saveAndRemoveProperties(Properties props) {
    if (initLevel() != 0)
        throw new IllegalStateException("Wrong init level");

    @SuppressWarnings({"rawtypes", "unchecked"})
    Map<String, String> sp =
        Map.ofEntries(props.entrySet().toArray(new Map.Entry[0]));
    // only main thread is running at this time, so savedProps and
    // its content will be correctly published to threads started later
    savedProps = sp;

    // Set the maximum amount of direct memory.  This value is controlled
    // by the vm option -XX:MaxDirectMemorySize=<size>.
    // The maximum amount of allocatable direct buffer memory (in bytes)
    // from the system property sun.nio.MaxDirectMemorySize set by the VM.
    // The system property will be removed.
    String s = (String)props.remove("sun.nio.MaxDirectMemorySize");
    if (s != null) {
        if (s.equals("-1")) {
            // -XX:MaxDirectMemorySize not given, take default
            directMemory = Runtime.getRuntime().maxMemory();
        } else {
            long l = Long.parseLong(s);
            if (l > -1)
                directMemory = l;
        }
    }

    // Check if direct buffers should be page aligned
    s = (String)props.remove("sun.nio.PageAlignDirectMemory");
    if ("true".equals(s))
        pageAlignDirectMemory = true;

    // Remove other private system properties
    // used by java.lang.Integer.IntegerCache
    props.remove("java.lang.Integer.IntegerCache.high");

    // used by sun.launcher.LauncherHelper
    props.remove("sun.java.launcher.diag");

    // used by jdk.internal.loader.ClassLoaders
    props.remove("jdk.boot.class.path.append");
}
 
Example 5
Project: openjdk-jdk10   File: MapFactories.java   View Source Code Vote up 4 votes
@Test(expectedExceptions=IllegalArgumentException.class)
public void dupKeysDisallowedN() {
    Map.Entry<Integer,String>[] entries = genEntries(MAX_ENTRIES);
    entries[MAX_ENTRIES-1] = Map.entry(0, "xxx");
    Map<Integer, String> map = Map.ofEntries(entries);
}
 
Example 6
Project: openjdk-jdk10   File: MapFactories.java   View Source Code Vote up 4 votes
@Test(expectedExceptions=NullPointerException.class)
public void nullKeyDisallowedN() {
    Map.Entry<Integer,String>[] entries = genEntries(MAX_ENTRIES);
    entries[0] = new AbstractMap.SimpleImmutableEntry(null, "a");
    Map<Integer, String> map = Map.ofEntries(entries);
}
 
Example 7
Project: openjdk-jdk10   File: MapFactories.java   View Source Code Vote up 4 votes
@Test(expectedExceptions=NullPointerException.class)
public void nullValueDisallowedN() {
    Map.Entry<Integer,String>[] entries = genEntries(MAX_ENTRIES);
    entries[0] = new AbstractMap.SimpleImmutableEntry(0, null);
    Map<Integer, String> map = Map.ofEntries(entries);
}
 
Example 8
Project: openjdk-jdk10   File: MapFactories.java   View Source Code Vote up 4 votes
@Test(expectedExceptions=NullPointerException.class)
public void nullEntryDisallowedN() {
    Map.Entry<Integer,String>[] entries = genEntries(MAX_ENTRIES);
    entries[5] = null;
    Map<Integer, String> map = Map.ofEntries(entries);
}
 
Example 9
Project: openjdk-jdk10   File: MapFactories.java   View Source Code Vote up 4 votes
@Test(expectedExceptions=NullPointerException.class)
public void nullArrayDisallowed() {
    Map.ofEntries(null);
}