< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ModuleNameReader.java

Print this page




  88         buf.reset();
  89         buf.appendStream(in);
  90 
  91         int magic = nextInt();
  92         if (magic != JAVA_MAGIC)
  93             throw new BadClassFile("illegal.start.of.class.file");
  94 
  95         int minorVersion = nextChar();
  96         int majorVersion = nextChar();
  97         if (majorVersion < 53)
  98             throw new BadClassFile("bad major version number for module: " + majorVersion);
  99 
 100         reader = new PoolReader(buf);
 101         bp = reader.readPool(buf, bp);
 102 
 103         int access_flags = nextChar();
 104         if (access_flags != 0x8000)
 105             throw new BadClassFile("invalid access flags for module: 0x" + Integer.toHexString(access_flags));
 106 
 107         int this_class = nextChar();
 108         // could, should, check this_class == CONSTANT_Class("mdoule-info")
 109         checkZero(nextChar(), "super_class");
 110         checkZero(nextChar(), "interface_count");
 111         checkZero(nextChar(), "fields_count");
 112         checkZero(nextChar(), "methods_count");
 113         int attributes_count = nextChar();
 114         for (int i = 0; i < attributes_count; i++) {
 115             int attr_name = nextChar();
 116             int attr_length = nextInt();
 117             if (reader.peekName(attr_name, utf8Mapper(false)).equals("Module") && attr_length > 2) {
 118                 return reader.peekModuleName(nextChar(), utf8Mapper(true));
 119             } else {
 120                 // skip over unknown attributes
 121                 bp += attr_length;
 122             }
 123         }
 124         throw new BadClassFile("no Module attribute");
 125     }
 126 
 127     void checkZero(int count, String name) throws BadClassFile {
 128         if (count != 0)




  88         buf.reset();
  89         buf.appendStream(in);
  90 
  91         int magic = nextInt();
  92         if (magic != JAVA_MAGIC)
  93             throw new BadClassFile("illegal.start.of.class.file");
  94 
  95         int minorVersion = nextChar();
  96         int majorVersion = nextChar();
  97         if (majorVersion < 53)
  98             throw new BadClassFile("bad major version number for module: " + majorVersion);
  99 
 100         reader = new PoolReader(buf);
 101         bp = reader.readPool(buf, bp);
 102 
 103         int access_flags = nextChar();
 104         if (access_flags != 0x8000)
 105             throw new BadClassFile("invalid access flags for module: 0x" + Integer.toHexString(access_flags));
 106 
 107         int this_class = nextChar();
 108         // could, should, check this_class == CONSTANT_Class("module-info")
 109         checkZero(nextChar(), "super_class");
 110         checkZero(nextChar(), "interface_count");
 111         checkZero(nextChar(), "fields_count");
 112         checkZero(nextChar(), "methods_count");
 113         int attributes_count = nextChar();
 114         for (int i = 0; i < attributes_count; i++) {
 115             int attr_name = nextChar();
 116             int attr_length = nextInt();
 117             if (reader.peekName(attr_name, utf8Mapper(false)).equals("Module") && attr_length > 2) {
 118                 return reader.peekModuleName(nextChar(), utf8Mapper(true));
 119             } else {
 120                 // skip over unknown attributes
 121                 bp += attr_length;
 122             }
 123         }
 124         throw new BadClassFile("no Module attribute");
 125     }
 126 
 127     void checkZero(int count, String name) throws BadClassFile {
 128         if (count != 0)


< prev index next >