< prev index next >

test/jdk/java/lang/module/ClassFileVersionsTest.java

Print this page




  41 import org.testng.annotations.DataProvider;
  42 import org.testng.annotations.Test;
  43 import static org.testng.Assert.*;
  44 
  45 public class ClassFileVersionsTest {
  46 
  47     // major, minor, modifiers for requires java.base
  48     @DataProvider(name = "supported")
  49     public Object[][] supported() {
  50         return new Object[][]{
  51                 { 53,   0,  Set.of() },                      // JDK 9
  52                 { 53,   0,  Set.of(STATIC) },
  53                 { 53,   0,  Set.of(TRANSITIVE) },
  54                 { 53,   0,  Set.of(STATIC, TRANSITIVE) },
  55 
  56                 { 54,   0,  Set.of() },                      // JDK 10
  57                 { 55,   0,  Set.of() },                      // JDK 11
  58                 { 56,   0,  Set.of() },                      // JDK 12
  59                 { 57,   0,  Set.of() },                      // JDK 13
  60                 { 58,   0,  Set.of() },                      // JDK 14

  61         };
  62     }
  63 
  64     // major, minor, modifiers for requires java.base
  65     @DataProvider(name = "unsupported")
  66     public Object[][] unsupported() {
  67         return new Object[][]{
  68                 { 50,   0,  Set.of()},                       // JDK 6
  69                 { 51,   0,  Set.of()},                       // JDK 7
  70                 { 52,   0,  Set.of()},                       // JDK 8
  71 
  72                 { 54,   0,  Set.of(STATIC) },                // JDK 10
  73                 { 54,   0,  Set.of(TRANSITIVE) },
  74                 { 54,   0,  Set.of(STATIC, TRANSITIVE) },
  75 
  76                 { 55,   0,  Set.of(STATIC) },                // JDK 11
  77                 { 55,   0,  Set.of(TRANSITIVE) },
  78                 { 55,   0,  Set.of(STATIC, TRANSITIVE) },
  79 
  80                 { 56,   0,  Set.of(STATIC) },                // JDK 12
  81                 { 56,   0,  Set.of(TRANSITIVE) },
  82                 { 56,   0,  Set.of(STATIC, TRANSITIVE) },
  83 
  84                 { 57,   0,  Set.of(STATIC) },                // JDK 13
  85                 { 57,   0,  Set.of(TRANSITIVE) },
  86                 { 57,   0,  Set.of(STATIC, TRANSITIVE) },
  87 
  88                 { 58,   0,  Set.of(STATIC) },                // JDK 14
  89                 { 58,   0,  Set.of(TRANSITIVE) },
  90                 { 58,   0,  Set.of(STATIC, TRANSITIVE) },
  91 
  92                 { 59,   0,  Set.of()},                       // JDK 15




  93         };
  94     }
  95 
  96     @Test(dataProvider = "supported")
  97     public void testSupported(int major, int minor, Set<Modifier> ms) {
  98         ModuleDescriptor descriptor = ModuleDescriptor.newModule("foo")
  99                 .requires(ms, "java.base")
 100                 .build();
 101         ByteBuffer bb = ModuleInfoWriter.toByteBuffer(descriptor);
 102         classFileVersion(bb, major, minor);
 103         descriptor = ModuleDescriptor.read(bb);
 104         assertEquals(descriptor.name(), "foo");
 105     }
 106 
 107     @Test(dataProvider = "unsupported",
 108           expectedExceptions = InvalidModuleDescriptorException.class)
 109     public void testUnsupported(int major, int minor, Set<Modifier> ms) {
 110         ModuleDescriptor descriptor = ModuleDescriptor.newModule("foo")
 111                 .requires(ms, "java.base")
 112                 .build();


  41 import org.testng.annotations.DataProvider;
  42 import org.testng.annotations.Test;
  43 import static org.testng.Assert.*;
  44 
  45 public class ClassFileVersionsTest {
  46 
  47     // major, minor, modifiers for requires java.base
  48     @DataProvider(name = "supported")
  49     public Object[][] supported() {
  50         return new Object[][]{
  51                 { 53,   0,  Set.of() },                      // JDK 9
  52                 { 53,   0,  Set.of(STATIC) },
  53                 { 53,   0,  Set.of(TRANSITIVE) },
  54                 { 53,   0,  Set.of(STATIC, TRANSITIVE) },
  55 
  56                 { 54,   0,  Set.of() },                      // JDK 10
  57                 { 55,   0,  Set.of() },                      // JDK 11
  58                 { 56,   0,  Set.of() },                      // JDK 12
  59                 { 57,   0,  Set.of() },                      // JDK 13
  60                 { 58,   0,  Set.of() },                      // JDK 14
  61                 { 59,   0,  Set.of() },                      // JDK 15
  62         };
  63     }
  64 
  65     // major, minor, modifiers for requires java.base
  66     @DataProvider(name = "unsupported")
  67     public Object[][] unsupported() {
  68         return new Object[][]{
  69                 { 50,   0,  Set.of()},                       // JDK 6
  70                 { 51,   0,  Set.of()},                       // JDK 7
  71                 { 52,   0,  Set.of()},                       // JDK 8
  72 
  73                 { 54,   0,  Set.of(STATIC) },                // JDK 10
  74                 { 54,   0,  Set.of(TRANSITIVE) },
  75                 { 54,   0,  Set.of(STATIC, TRANSITIVE) },
  76 
  77                 { 55,   0,  Set.of(STATIC) },                // JDK 11
  78                 { 55,   0,  Set.of(TRANSITIVE) },
  79                 { 55,   0,  Set.of(STATIC, TRANSITIVE) },
  80 
  81                 { 56,   0,  Set.of(STATIC) },                // JDK 12
  82                 { 56,   0,  Set.of(TRANSITIVE) },
  83                 { 56,   0,  Set.of(STATIC, TRANSITIVE) },
  84 
  85                 { 57,   0,  Set.of(STATIC) },                // JDK 13
  86                 { 57,   0,  Set.of(TRANSITIVE) },
  87                 { 57,   0,  Set.of(STATIC, TRANSITIVE) },
  88 
  89                 { 58,   0,  Set.of(STATIC) },                // JDK 14
  90                 { 58,   0,  Set.of(TRANSITIVE) },
  91                 { 58,   0,  Set.of(STATIC, TRANSITIVE) },
  92 
  93                 { 59,   0,  Set.of(STATIC) },                // JDK 15
  94                 { 59,   0,  Set.of(TRANSITIVE) },
  95                 { 59,   0,  Set.of(STATIC, TRANSITIVE) },
  96 
  97                 { 60,   0,  Set.of()},                       // JDK 16
  98         };
  99     }
 100 
 101     @Test(dataProvider = "supported")
 102     public void testSupported(int major, int minor, Set<Modifier> ms) {
 103         ModuleDescriptor descriptor = ModuleDescriptor.newModule("foo")
 104                 .requires(ms, "java.base")
 105                 .build();
 106         ByteBuffer bb = ModuleInfoWriter.toByteBuffer(descriptor);
 107         classFileVersion(bb, major, minor);
 108         descriptor = ModuleDescriptor.read(bb);
 109         assertEquals(descriptor.name(), "foo");
 110     }
 111 
 112     @Test(dataProvider = "unsupported",
 113           expectedExceptions = InvalidModuleDescriptorException.class)
 114     public void testUnsupported(int major, int minor, Set<Modifier> ms) {
 115         ModuleDescriptor descriptor = ModuleDescriptor.newModule("foo")
 116                 .requires(ms, "java.base")
 117                 .build();
< prev index next >