langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Module_attribute.java
changeset 42822 a84956e7ee4d
parent 42407 f3702cff2933
child 43767 9cff98a149cb
equal deleted inserted replaced
42812:084017ef9300 42822:a84956e7ee4d
    24  */
    24  */
    25 
    25 
    26 package com.sun.tools.classfile;
    26 package com.sun.tools.classfile;
    27 
    27 
    28 import java.io.IOException;
    28 import java.io.IOException;
       
    29 
       
    30 import com.sun.tools.classfile.ConstantPool.CONSTANT_Module_info;
    29 
    31 
    30 /**
    32 /**
    31  * See Jigsaw.
    33  * See Jigsaw.
    32  *
    34  *
    33  *  <p><b>This is NOT part of any supported API.
    35  *  <p><b>This is NOT part of any supported API.
    46         super(name_index, length);
    48         super(name_index, length);
    47 
    49 
    48         module_name = cr.readUnsignedShort();
    50         module_name = cr.readUnsignedShort();
    49         module_flags = cr.readUnsignedShort();
    51         module_flags = cr.readUnsignedShort();
    50 
    52 
       
    53         module_version_index = cr.readUnsignedShort();
       
    54 
    51         requires_count = cr.readUnsignedShort();
    55         requires_count = cr.readUnsignedShort();
    52         requires = new RequiresEntry[requires_count];
    56         requires = new RequiresEntry[requires_count];
    53         for (int i = 0; i < requires_count; i++)
    57         for (int i = 0; i < requires_count; i++)
    54             requires[i] = new RequiresEntry(cr);
    58             requires[i] = new RequiresEntry(cr);
    55 
    59 
    75     }
    79     }
    76 
    80 
    77     public Module_attribute(int name_index,
    81     public Module_attribute(int name_index,
    78             int module_name,
    82             int module_name,
    79             int module_flags,
    83             int module_flags,
       
    84             int module_version_index,
    80             RequiresEntry[] requires,
    85             RequiresEntry[] requires,
    81             ExportsEntry[] exports,
    86             ExportsEntry[] exports,
    82             OpensEntry[] opens,
    87             OpensEntry[] opens,
    83             int[] uses,
    88             int[] uses,
    84             ProvidesEntry[] provides) {
    89             ProvidesEntry[] provides) {
    85         super(name_index, 2);
    90         super(name_index, 2);
    86         this.module_name = module_name;
    91         this.module_name = module_name;
    87         this.module_flags = module_flags;
    92         this.module_flags = module_flags;
       
    93         this.module_version_index = module_version_index;
    88         requires_count = requires.length;
    94         requires_count = requires.length;
    89         this.requires = requires;
    95         this.requires = requires;
    90         exports_count = exports.length;
    96         exports_count = exports.length;
    91         this.exports = exports;
    97         this.exports = exports;
    92         opens_count = opens.length;
    98         opens_count = opens.length;
   107         return visitor.visitModule(this, data);
   113         return visitor.visitModule(this, data);
   108     }
   114     }
   109 
   115 
   110     public final int module_name;
   116     public final int module_name;
   111     public final int module_flags;
   117     public final int module_flags;
       
   118     public final int module_version_index;
   112     public final int requires_count;
   119     public final int requires_count;
   113     public final RequiresEntry[] requires;
   120     public final RequiresEntry[] requires;
   114     public final int exports_count;
   121     public final int exports_count;
   115     public final ExportsEntry[] exports;
   122     public final ExportsEntry[] exports;
   116     public final int opens_count;
   123     public final int opens_count;
   122 
   129 
   123     public static class RequiresEntry {
   130     public static class RequiresEntry {
   124         RequiresEntry(ClassReader cr) throws IOException {
   131         RequiresEntry(ClassReader cr) throws IOException {
   125             requires_index = cr.readUnsignedShort();
   132             requires_index = cr.readUnsignedShort();
   126             requires_flags = cr.readUnsignedShort();
   133             requires_flags = cr.readUnsignedShort();
   127         }
   134             requires_version_index = cr.readUnsignedShort();
   128 
   135         }
   129         public RequiresEntry(int index, int flags) {
   136 
       
   137         public RequiresEntry(int index, int flags, int version_index) {
   130             this.requires_index = index;
   138             this.requires_index = index;
   131             this.requires_flags = flags;
   139             this.requires_flags = flags;
       
   140             this.requires_version_index = version_index;
   132         }
   141         }
   133 
   142 
   134         public String getRequires(ConstantPool constant_pool) throws ConstantPoolException {
   143         public String getRequires(ConstantPool constant_pool) throws ConstantPoolException {
   135             return constant_pool.getUTF8Value(requires_index);
   144             CONSTANT_Module_info info = constant_pool.getModuleInfo(requires_index);
       
   145             return info.getName();
   136         }
   146         }
   137 
   147 
   138         public static final int length = 4;
   148         public static final int length = 4;
   139 
   149 
   140         public final int requires_index;
   150         public final int requires_index;
   141         public final int requires_flags;
   151         public final int requires_flags;
       
   152         public final int requires_version_index;
   142     }
   153     }
   143 
   154 
   144     public static class ExportsEntry {
   155     public static class ExportsEntry {
   145         ExportsEntry(ClassReader cr) throws IOException {
   156         ExportsEntry(ClassReader cr) throws IOException {
   146             exports_index = cr.readUnsignedShort();
   157             exports_index = cr.readUnsignedShort();