< prev index next >

test/jdk/java/lang/module/ModuleFinderTest.java

Print this page

  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  * @enablePreview
 27  * @modules java.base/jdk.internal.module
 28  * @library /test/lib
 29  * @build ModuleFinderTest jdk.test.lib.util.ModuleInfoWriter
 30  * @run testng ModuleFinderTest
 31  * @summary Basic tests for java.lang.module.ModuleFinder
 32  */
 33 
 34 import java.io.File;
 35 import java.io.OutputStream;
 36 import java.lang.module.FindException;
 37 import java.lang.module.InvalidModuleDescriptorException;
 38 import java.lang.module.ModuleDescriptor;
 39 import java.lang.module.ModuleFinder;
 40 import java.lang.module.ModuleReference;
 41 import java.nio.file.Files;
 42 import java.nio.file.Path;
 43 import java.nio.file.Paths;
 44 import java.util.Optional;
 45 import java.util.Set;
 46 import java.util.jar.JarEntry;
 47 import java.util.jar.JarOutputStream;
 48 import java.util.stream.Collectors;
 49 

810         try (OutputStream out = Files.newOutputStream(file)) {
811             try (JarOutputStream jos = new JarOutputStream(out)) {
812 
813                 JarEntry je = new JarEntry("module-info.class");
814                 jos.putNextEntry(je);
815                 ModuleInfoWriter.write(descriptor, jos);
816                 jos.closeEntry();
817 
818                 for (String entry : entries) {
819                     je = new JarEntry(entry);
820                     jos.putNextEntry(je);
821                     jos.closeEntry();
822                 }
823             }
824 
825         }
826         return file;
827     }
828 
829 }
830 

  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  * @enablePreview
 27  * @modules java.base/jdk.internal.module
 28  * @library /test/lib
 29  * @build ModuleFinderTest
 30  * @run testng ModuleFinderTest
 31  * @summary Basic tests for java.lang.module.ModuleFinder
 32  */
 33 
 34 import java.io.File;
 35 import java.io.OutputStream;
 36 import java.lang.module.FindException;
 37 import java.lang.module.InvalidModuleDescriptorException;
 38 import java.lang.module.ModuleDescriptor;
 39 import java.lang.module.ModuleFinder;
 40 import java.lang.module.ModuleReference;
 41 import java.nio.file.Files;
 42 import java.nio.file.Path;
 43 import java.nio.file.Paths;
 44 import java.util.Optional;
 45 import java.util.Set;
 46 import java.util.jar.JarEntry;
 47 import java.util.jar.JarOutputStream;
 48 import java.util.stream.Collectors;
 49 

810         try (OutputStream out = Files.newOutputStream(file)) {
811             try (JarOutputStream jos = new JarOutputStream(out)) {
812 
813                 JarEntry je = new JarEntry("module-info.class");
814                 jos.putNextEntry(je);
815                 ModuleInfoWriter.write(descriptor, jos);
816                 jos.closeEntry();
817 
818                 for (String entry : entries) {
819                     je = new JarEntry(entry);
820                     jos.putNextEntry(je);
821                     jos.closeEntry();
822                 }
823             }
824 
825         }
826         return file;
827     }
828 
829 }

< prev index next >