test/jdk/lib/testlibrary/ModuleUtils.java
branchJDK-8152988-branch
changeset 56969 25f960592a92
parent 56967 23adfcd11311
parent 56968 de6373676c08
child 56970 f6dc7d933bab
--- a/test/jdk/lib/testlibrary/ModuleUtils.java	Sat Oct 13 19:28:10 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.lang.module.ModuleDescriptor;
-import java.lang.module.ModuleFinder;
-import java.lang.module.ModuleReader;
-import java.lang.module.ModuleReference;
-import java.net.URI;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-
-
-/**
- * This class consists exclusively of static utility methods that are useful
- * for creating tests for modules.
- */
-
-public final class ModuleUtils {
-    private ModuleUtils() { }
-
-
-    /**
-     * Returns a ModuleFinder that finds modules with the given module
-     * descriptors.
-     */
-    static ModuleFinder finderOf(ModuleDescriptor... descriptors) {
-
-        // Create a ModuleReference for each module
-        Map<String, ModuleReference> namesToReference = new HashMap<>();
-
-        for (ModuleDescriptor descriptor : descriptors) {
-            String name = descriptor.name();
-
-            URI uri = URI.create("module:/" + name);
-
-            ModuleReference mref = new ModuleReference(descriptor, uri) {
-                @Override
-                public ModuleReader open() {
-                    throw new UnsupportedOperationException();
-                }
-            };
-
-            namesToReference.put(name, mref);
-        }
-
-        return new ModuleFinder() {
-            @Override
-            public Optional<ModuleReference> find(String name) {
-                Objects.requireNonNull(name);
-                return Optional.ofNullable(namesToReference.get(name));
-            }
-            @Override
-            public Set<ModuleReference> findAll() {
-                return new HashSet<>(namesToReference.values());
-            }
-        };
-    }
-
-}