< prev index next >

test/jdk/java/lang/module/ModuleDescriptorTest.java

Print this page
rev 51958 : 8211122: Reduce the number of internal classes made accessible to jdk.unsupported
Reviewed-by: alanb, dfuchs, kvn
   1 /*
   2  * Copyright (c) 2013, 2017, 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  * @modules java.base/jdk.internal.module
  27  *          java.base/jdk.internal.misc
  28  * @run testng ModuleDescriptorTest
  29  * @summary Basic test for java.lang.module.ModuleDescriptor and its builder
  30  */
  31 
  32 import java.io.ByteArrayOutputStream;
  33 import java.io.IOException;
  34 import java.io.InputStream;
  35 import java.lang.module.InvalidModuleDescriptorException;
  36 import java.lang.module.ModuleDescriptor;
  37 import java.lang.module.ModuleDescriptor.Builder;
  38 import java.lang.module.ModuleDescriptor.Exports;
  39 import java.lang.module.ModuleDescriptor.Opens;
  40 import java.lang.module.ModuleDescriptor.Requires;
  41 import java.lang.module.ModuleDescriptor.Provides;
  42 import java.lang.module.ModuleDescriptor.Requires.Modifier;
  43 import java.lang.module.ModuleDescriptor.Version;
  44 import java.nio.ByteBuffer;
  45 import java.util.ArrayList;
  46 import java.util.Collections;
  47 import java.util.EnumSet;
  48 import java.util.HashSet;
  49 import java.util.Iterator;
  50 import java.util.List;
  51 import java.util.Objects;
  52 import java.util.Optional;
  53 import java.util.Set;
  54 import java.util.stream.Collectors;
  55 
  56 import static java.lang.module.ModuleDescriptor.Requires.Modifier.*;
  57 
  58 import jdk.internal.misc.JavaLangModuleAccess;
  59 import jdk.internal.misc.SharedSecrets;
  60 import jdk.internal.module.ModuleInfoWriter;
  61 import org.testng.annotations.DataProvider;
  62 import org.testng.annotations.Test;
  63 import static org.testng.Assert.*;
  64 
  65 @Test
  66 public class ModuleDescriptorTest {
  67 
  68     @DataProvider(name = "invalidNames")
  69     public Object[][] invalidNames() {
  70         return new Object[][]{
  71 
  72             { null,             null },
  73             { "1",              null },
  74             { "1foo",           null },
  75             { ".foo",           null },
  76             { "foo.",           null },
  77             { "[foo]",          null },
  78             { "foo.1",          null },
  79             { "1foo.bar",       null },


   1 /*
   2  * Copyright (c) 2013, 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  * @modules java.base/jdk.internal.access
  27  *          java.base/jdk.internal.module
  28  * @run testng ModuleDescriptorTest
  29  * @summary Basic test for java.lang.module.ModuleDescriptor and its builder
  30  */
  31 
  32 import java.io.ByteArrayOutputStream;
  33 import java.io.IOException;
  34 import java.io.InputStream;
  35 import java.lang.module.InvalidModuleDescriptorException;
  36 import java.lang.module.ModuleDescriptor;
  37 import java.lang.module.ModuleDescriptor.Builder;
  38 import java.lang.module.ModuleDescriptor.Exports;
  39 import java.lang.module.ModuleDescriptor.Opens;
  40 import java.lang.module.ModuleDescriptor.Requires;
  41 import java.lang.module.ModuleDescriptor.Provides;
  42 import java.lang.module.ModuleDescriptor.Requires.Modifier;
  43 import java.lang.module.ModuleDescriptor.Version;
  44 import java.nio.ByteBuffer;
  45 import java.util.ArrayList;
  46 import java.util.Collections;
  47 import java.util.EnumSet;
  48 import java.util.HashSet;
  49 import java.util.Iterator;
  50 import java.util.List;
  51 import java.util.Objects;

  52 import java.util.Set;
  53 import java.util.stream.Collectors;
  54 
  55 import static java.lang.module.ModuleDescriptor.Requires.Modifier.*;
  56 
  57 import jdk.internal.access.JavaLangModuleAccess;
  58 import jdk.internal.access.SharedSecrets;
  59 import jdk.internal.module.ModuleInfoWriter;
  60 import org.testng.annotations.DataProvider;
  61 import org.testng.annotations.Test;
  62 import static org.testng.Assert.*;
  63 
  64 @Test
  65 public class ModuleDescriptorTest {
  66 
  67     @DataProvider(name = "invalidNames")
  68     public Object[][] invalidNames() {
  69         return new Object[][]{
  70 
  71             { null,             null },
  72             { "1",              null },
  73             { "1foo",           null },
  74             { ".foo",           null },
  75             { "foo.",           null },
  76             { "[foo]",          null },
  77             { "foo.1",          null },
  78             { "1foo.bar",       null },


< prev index next >