test/jdk/java/lang/module/ClassFileVersionsTest.java
author darcy
Thu, 13 Dec 2018 19:06:11 +0100
changeset 53023 6879069d9d94
parent 50892 a5557f24b4d4
child 55382 30b1b7b4dd86
permissions -rw-r--r--
8205626: Start of release updates for JDK 13 8205393: Add SourceVersion.RELEASE_13 8205394: Add source 13 and target 13 to javac 8205645: Bump maximum recognized class file version to 57 for JDK 13 8214825: Update preview language features for start of JDK 13 Reviewed-by: erikj, alanb, mchung, mcimadamore, dholmes, smarks, jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
48203
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
     1
/*
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
     4
 *
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
     8
 *
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    13
 * accompanied this code).
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    14
 *
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    18
 *
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    21
 * questions.
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    22
 */
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    23
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    24
/**
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    25
 * @test
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    26
 * @modules java.base/jdk.internal.module
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    27
 * @run testng ClassFileVersionsTest
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    28
 * @summary Test parsing of module-info.class with different class file versions
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    29
 */
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    30
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    31
import java.lang.module.InvalidModuleDescriptorException;
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    32
import java.lang.module.ModuleDescriptor;
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    33
import java.lang.module.ModuleDescriptor.Requires.Modifier;
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    34
import java.nio.ByteBuffer;
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    35
import java.util.Set;
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    36
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    37
import static java.lang.module.ModuleDescriptor.Requires.Modifier.*;
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    38
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    39
import jdk.internal.module.ModuleInfoWriter;
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    40
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    41
import org.testng.annotations.DataProvider;
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    42
import org.testng.annotations.Test;
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    43
import static org.testng.Assert.*;
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    44
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    45
public class ClassFileVersionsTest {
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    46
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    47
    // major, minor, modifiers for requires java.base
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    48
    @DataProvider(name = "supported")
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    49
    public Object[][] supported() {
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    50
        return new Object[][]{
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    51
                { 53,   0,  Set.of() },                      // JDK 9
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    52
                { 53,   0,  Set.of(STATIC) },
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    53
                { 53,   0,  Set.of(TRANSITIVE) },
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    54
                { 53,   0,  Set.of(STATIC, TRANSITIVE) },
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    55
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    56
                { 54,   0,  Set.of() },                      // JDK 10
50892
a5557f24b4d4 8205615: Start of release updates for JDK 12
darcy
parents: 48355
diff changeset
    57
                { 55,   0,  Set.of() },                      // JDK 11
a5557f24b4d4 8205615: Start of release updates for JDK 12
darcy
parents: 48355
diff changeset
    58
                { 56,   0,  Set.of() },                      // JDK 12
53023
6879069d9d94 8205626: Start of release updates for JDK 13
darcy
parents: 50892
diff changeset
    59
                { 57,   0,  Set.of() },                      // JDK 13
48203
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    60
        };
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    61
    }
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    62
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    63
    // major, minor, modifiers for requires java.base
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    64
    @DataProvider(name = "unsupported")
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    65
    public Object[][] unsupported() {
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    66
        return new Object[][]{
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    67
                { 50,   0,  Set.of()},                       // JDK 6
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    68
                { 51,   0,  Set.of()},                       // JDK 7
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    69
                { 52,   0,  Set.of()},                       // JDK 8
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    70
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    71
                { 54,   0,  Set.of(STATIC) },                // JDK 10
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    72
                { 54,   0,  Set.of(TRANSITIVE) },
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    73
                { 54,   0,  Set.of(STATIC, TRANSITIVE) },
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    74
48355
4944950606ef 8191913: Bump classfile version number to 55
psandoz
parents: 48203
diff changeset
    75
                { 55,   0,  Set.of(STATIC) },                // JDK 11
4944950606ef 8191913: Bump classfile version number to 55
psandoz
parents: 48203
diff changeset
    76
                { 55,   0,  Set.of(TRANSITIVE) },
4944950606ef 8191913: Bump classfile version number to 55
psandoz
parents: 48203
diff changeset
    77
                { 55,   0,  Set.of(STATIC, TRANSITIVE) },
4944950606ef 8191913: Bump classfile version number to 55
psandoz
parents: 48203
diff changeset
    78
50892
a5557f24b4d4 8205615: Start of release updates for JDK 12
darcy
parents: 48355
diff changeset
    79
                { 56,   0,  Set.of(STATIC) },                // JDK 12
a5557f24b4d4 8205615: Start of release updates for JDK 12
darcy
parents: 48355
diff changeset
    80
                { 56,   0,  Set.of(TRANSITIVE) },
a5557f24b4d4 8205615: Start of release updates for JDK 12
darcy
parents: 48355
diff changeset
    81
                { 56,   0,  Set.of(STATIC, TRANSITIVE) },
a5557f24b4d4 8205615: Start of release updates for JDK 12
darcy
parents: 48355
diff changeset
    82
53023
6879069d9d94 8205626: Start of release updates for JDK 13
darcy
parents: 50892
diff changeset
    83
                { 57,   0,  Set.of(STATIC) },                // JDK 13
6879069d9d94 8205626: Start of release updates for JDK 13
darcy
parents: 50892
diff changeset
    84
                { 57,   0,  Set.of(TRANSITIVE) },
6879069d9d94 8205626: Start of release updates for JDK 13
darcy
parents: 50892
diff changeset
    85
                { 57,   0,  Set.of(STATIC, TRANSITIVE) },
6879069d9d94 8205626: Start of release updates for JDK 13
darcy
parents: 50892
diff changeset
    86
6879069d9d94 8205626: Start of release updates for JDK 13
darcy
parents: 50892
diff changeset
    87
                { 58,   0,  Set.of()},                       // JDK 14
48203
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    88
        };
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    89
    }
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    90
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    91
    @Test(dataProvider = "supported")
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    92
    public void testSupported(int major, int minor, Set<Modifier> ms) {
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    93
        ModuleDescriptor descriptor = ModuleDescriptor.newModule("foo")
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    94
                .requires(ms, "java.base")
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    95
                .build();
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    96
        ByteBuffer bb = ModuleInfoWriter.toByteBuffer(descriptor);
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    97
        classFileVersion(bb, major, minor);
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    98
        descriptor = ModuleDescriptor.read(bb);
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
    99
        assertEquals(descriptor.name(), "foo");
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
   100
    }
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
   101
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
   102
    @Test(dataProvider = "unsupported",
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
   103
          expectedExceptions = InvalidModuleDescriptorException.class)
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
   104
    public void testUnsupported(int major, int minor, Set<Modifier> ms) {
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
   105
        ModuleDescriptor descriptor = ModuleDescriptor.newModule("foo")
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
   106
                .requires(ms, "java.base")
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
   107
                .build();
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
   108
        ByteBuffer bb = ModuleInfoWriter.toByteBuffer(descriptor);
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
   109
        classFileVersion(bb, major, minor);
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
   110
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
   111
        // throws InvalidModuleDescriptorException
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
   112
        ModuleDescriptor.read(bb);
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
   113
    }
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
   114
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
   115
    private void classFileVersion(ByteBuffer bb, int major, int minor) {
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
   116
        bb.putShort(4, (short) minor);
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
   117
        bb.putShort(6, (short) major);
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
   118
    }
4fd79561f38f 8191867: Module attribute in 54.0+ class file cannot contains a requires java.base with ACC_TRANSITIVE or ACC_STATIC_PHASE
alanb
parents:
diff changeset
   119
}