home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 2 / AACD 2.iso / AACD / Programming / jikes-1.02 / src / getclass.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-09-05  |  46.0 KB  |  1,134 lines

  1. // $Id: getclass.cpp,v 1.14 1999/09/01 14:58:25 shields Exp $
  2. //
  3. // This software is subject to the terms of the IBM Jikes Compiler
  4. // License Agreement available at the following URL:
  5. // http://www.ibm.com/research/jikes.
  6. // Copyright (C) 1996, 1998, International Business Machines Corporation
  7. // and others.  All Rights Reserved.
  8. // You must accept the terms of that agreement to use this software.
  9. //
  10. #include "config.h"
  11. #include <sys/stat.h>
  12. #include "control.h"
  13. #include "semantic.h"
  14. #include "access.h"
  15. #include "getclass.h"
  16. #include "zip.h"
  17.  
  18. inline u1 Semantic::GetU1(char *buffer)
  19. {
  20.     return *buffer;
  21. }
  22.  
  23. inline u2 Semantic::GetU2(char *buffer)
  24. {
  25.     u2 i = (u1) *buffer++;
  26.     return (i << 8) + (u1) *buffer;
  27. }
  28.  
  29. inline u4 Semantic::GetU4(char *buffer)
  30. {
  31.     u4 i = (u1) *buffer++;
  32.     i = (i << 8) + (u1) *buffer++;
  33.     i = (i << 8) + (u1) *buffer++;
  34.     return (i << 8) + (u1) *buffer;
  35. }
  36.  
  37. inline u1 Semantic::GetAndSkipU1(char *&buffer)
  38. {
  39.     return (u1) *buffer++;
  40. }
  41.  
  42. inline u2 Semantic::GetAndSkipU2(char *&buffer)
  43. {
  44.     u2 i = (u1) *buffer++;
  45.     return (i << 8) + (u1) *buffer++;
  46. }
  47.  
  48. inline u4 Semantic::GetAndSkipU4(char *&buffer)
  49. {
  50.     u4 i = (u1) *buffer++;
  51.     i = (i << 8) + (u1) *buffer++;
  52.     i = (i << 8) + (u1) *buffer++;
  53.     return (i << 8) + (u1) *buffer++;
  54. }
  55.  
  56. inline void Semantic::Skip(char *&buffer, int n)
  57. {
  58.     buffer += n;
  59. }
  60.  
  61.  
  62. TypeSymbol *Semantic::ProcessNestedType(TypeSymbol *base_type, NameSymbol *name_symbol, LexStream::TokenIndex tok)
  63. {
  64.     TypeSymbol *inner_type = base_type -> FindTypeSymbol(name_symbol);
  65.     if (! inner_type)
  66.     {
  67.         int length = base_type -> ExternalNameLength() + 1 + name_symbol -> NameLength(); // +1 for $,... +1 for $
  68.         wchar_t *external_name = new wchar_t[length + 1]; // +1 for '\0';
  69.         wcscpy(external_name, base_type -> ExternalName());
  70.         wcscat(external_name, StringConstant::US__DS);
  71.         wcscat(external_name, name_symbol -> Name());
  72.         NameSymbol *external_name_symbol = control.FindOrInsertName(external_name, length);
  73.  
  74.         delete [] external_name;
  75.  
  76.         inner_type = base_type -> InsertNestedTypeSymbol(name_symbol);
  77.         inner_type -> outermost_type = base_type -> outermost_type;
  78.         inner_type -> supertypes_closure = new SymbolSet;
  79.         inner_type -> subtypes = new SymbolSet;
  80.         inner_type -> SetExternalIdentity(external_name_symbol);
  81.         inner_type -> SetOwner(base_type);
  82.         inner_type -> SetSignature(control);
  83.  
  84.         FileSymbol *file_symbol = Control::GetFile(control, base_type -> ContainingPackage(), external_name_symbol);
  85.         if (file_symbol)
  86.         {
  87.             inner_type -> file_symbol = file_symbol;
  88.             inner_type -> SetLocation();
  89.  
  90.             ReadClassFile(inner_type, tok);
  91.         }
  92.         else
  93.         {
  94.             inner_type -> SetSymbolTable(1); // this symbol table will only contain a default constructor
  95.             inner_type -> super = control.Object();
  96.             inner_type -> MarkBad();
  97.             AddDefaultConstructor(inner_type);
  98.             ReportSemError(SemanticError::TYPE_NOT_FOUND,
  99.                            tok,
  100.                            tok,
  101.                            inner_type -> ContainingPackage() -> PackageName(),
  102.                            inner_type -> ExternalName());
  103.         }
  104.     }
  105.  
  106.     return inner_type;
  107. }
  108.  
  109.  
  110. TypeSymbol *Semantic::RetrieveNestedTypes(TypeSymbol *base_type, wchar_t *signature, LexStream::TokenIndex tok)
  111. {
  112.     int len;
  113.     for (len = 0; signature[len] != U_NULL && signature[len] != U_DOLLAR; len++)
  114.         ;
  115.     NameSymbol *name_symbol = control.FindOrInsertName(signature, len);
  116.     TypeSymbol *inner_type = ProcessNestedType(base_type, name_symbol, tok);
  117.  
  118.     return (signature[len] == U_DOLLAR ? RetrieveNestedTypes(inner_type, &signature[len + 1], tok) : inner_type);
  119. }
  120.  
  121.  
  122. TypeSymbol *Semantic::ReadTypeFromSignature(TypeSymbol *base_type, char *utf8_signature, int length, LexStream::TokenIndex tok)
  123. {
  124.     TypeSymbol *type = control.type_table.FindType(utf8_signature, length);
  125.  
  126.     if (! type)
  127.     {
  128.         wchar_t *signature = new wchar_t[length + 1];
  129.         (void) Control::ConvertUtf8ToUnicode(signature, utf8_signature, length);
  130.  
  131.         int total_length;
  132.         for (total_length = 0; signature[total_length] != U_NULL && signature[total_length] != U_DOLLAR; total_length++)
  133.             ;
  134.  
  135.         if (signature[total_length] != U_NULL && Code::IsDigit(signature[total_length + 1])) // an anonymous or a local type?
  136.         {
  137.             for (total_length += 2; Code::IsDigit(signature[total_length]); total_length++) // will stop at next '$' or '\0' !!!
  138.                 ;
  139.             if (signature[total_length] != U_NULL) // not an anonymous type ?  then, it's a local type: scan local name
  140.             {
  141.                 for (total_length++; signature[total_length] != U_NULL && signature[total_length] != U_DOLLAR; total_length++)
  142.                     ;
  143.             }
  144.         }
  145.  
  146.         int len;
  147.         for (len = total_length - 1; len >= 0 && signature[len] != U_SLASH; len--)
  148.             ;
  149.  
  150.         wchar_t *name = &(signature[len + 1]);
  151.  
  152.         //
  153.         // When a package name is specified in the signature, we look for the type in question
  154.         // in that package, i.e., we redefine package. Otherwise, we search for the type in the
  155.         // unnamed package.
  156.         //
  157.         PackageSymbol *package = NULL;
  158.  
  159.         //
  160.         // Which package?
  161.         //
  162.         if (len >= 0)
  163.         {
  164.             wchar_t *package_name = new wchar_t[len + 1];
  165.             for (int i = 0; i < len; i++)
  166.                 package_name[i] = signature[i];
  167.             package_name[len] = U_NULL;
  168.             package = control.ProcessPackage(package_name);
  169.  
  170.             if (package -> directory.Length() == 0)
  171.             {
  172.                 ReportSemError(SemanticError::PACKAGE_NOT_FOUND,
  173.                                tok,
  174.                                tok,
  175.                                package -> PackageName());
  176.             }
  177.             delete [] package_name;
  178.         }
  179.         else package = control.unnamed_package;
  180.  
  181.         //
  182.         // Process type
  183.         //
  184.         NameSymbol *name_symbol = control.FindOrInsertName(name, total_length - (len + 1));
  185.         type = package -> FindTypeSymbol(name_symbol);
  186.         if (type)
  187.         {
  188.             if (type -> SourcePending())
  189.                 control.ProcessHeaders(type -> file_symbol);
  190.         }
  191.         else
  192.         {
  193.             FileSymbol *file_symbol = Control::GetFile(control, package, name_symbol);
  194.  
  195.             //
  196.             // If we are dealing with the unnamed package, ...
  197.             //
  198.             if ((! file_symbol) && package == control.unnamed_package)
  199.                 file_symbol = Control::GetFile(control, control.unnamed_package, name_symbol);
  200.  
  201.             //
  202.             // If a file_symbol was not found, ReadType will issue an error message
  203.             //
  204.             type = ReadType(file_symbol, package, name_symbol, tok);
  205.  
  206.             //
  207.             // If we have to do a full check and we have a case where a ".class" file
  208.             // depends on a ".java" file then we should signal that the ".java" file
  209.             // associated with the ".class" file should be recompiled.
  210.             //
  211.             if (control.option.full_check && (! control.option.depend) &&
  212.                 file_symbol && file_symbol -> IsJava() && (! file_symbol -> IsZip()))
  213.             {
  214.                 control.recompilation_file_set.AddElement(file_symbol);
  215.                 if (! control.option.incremental && control.option.pedantic)
  216.                 {
  217.                     ReportSemError(SemanticError::RECOMPILATION,
  218.                                    tok,
  219.                                    tok,
  220.                                    base_type -> ContainingPackage() -> Name(),
  221.                                    base_type -> ExternalName(),
  222.                                    type -> ContainingPackage() -> Name(),
  223.                                    type -> ExternalName());
  224.                 }
  225.             }
  226.         }
  227.  
  228.         if (signature[total_length] == U_DOLLAR)
  229.             type = RetrieveNestedTypes(type, &signature[total_length + 1], tok);
  230.  
  231.         delete [] signature;
  232.     }
  233.  
  234.     //
  235.     // Establish a dependence from base_type (read from a class file) to type.
  236.     //
  237.     AddDependence(base_type, type, tok);
  238.  
  239.     return type;
  240. }
  241.  
  242.  
  243. TypeSymbol *Semantic::ProcessSignature(TypeSymbol *base_type, char *signature, LexStream::TokenIndex tok)
  244. {
  245.     TypeSymbol *type;
  246.     int num_dimensions = 0;
  247.  
  248.     for (; *signature == U_LEFT_BRACKET; signature++)
  249.         num_dimensions++;
  250.  
  251.     switch(*signature)
  252.     {
  253.         case U_B:
  254.              type = control.byte_type;
  255.              break;
  256.         case U_C:
  257.              type = control.char_type;
  258.              break;
  259.         case U_D:
  260.              type = control.double_type;
  261.              break;
  262.         case U_F:
  263.              type = control.float_type;
  264.              break;
  265.         case U_I:
  266.              type = control.int_type;
  267.              break;
  268.         case U_J:
  269.              type = control.long_type;
  270.              break;
  271.         case U_L:
  272.              {
  273.                  //
  274.                  // The signature is of the form: "L<filename>;" - So, +1 to skip the 'L'
  275.                  // ReadTypeFromSignature considers a semicolon to be a terminator.
  276.                  //
  277.                  char *str = ++signature;
  278.                  while (*str != U_SEMICOLON)
  279.                      str++;
  280.                  type = ReadTypeFromSignature(base_type, signature, str - signature, tok);
  281.          }
  282.              break;
  283.         case U_S:
  284.              type = control.short_type;
  285.              break;
  286.         case U_Z:
  287.              type = control.boolean_type;
  288.              break;
  289.         case U_V:
  290.              type = control.void_type;
  291.              break;
  292.         default:
  293.             assert(! "KNOW WHAT TO DO WITH SIGNATURE");
  294.             break;
  295.     }
  296.  
  297.     return (num_dimensions == 0 ? type : type -> GetArrayType((Semantic *)this, num_dimensions));
  298. }
  299.  
  300.  
  301. inline TypeSymbol *Semantic::GetClassPool(TypeSymbol *base_type,
  302.                                           TypeSymbol **class_pool,
  303.                                           char **constant_pool,
  304.                                           int index,
  305.                                           LexStream::TokenIndex tok)
  306. {
  307.     if (! class_pool[index])
  308.     {
  309.         u2 name_index = Constant_Class_info::NameIndex(constant_pool[index]);
  310.         char *str = Constant_Utf8_info::Bytes(constant_pool[name_index]);
  311.  
  312.         if (*str == U_LEFT_BRACKET)
  313.             class_pool[index] = ProcessSignature(base_type, str, tok);
  314.         else
  315.         {
  316.             u2 length = Constant_Utf8_info::Length(constant_pool[name_index]);
  317.             char *p;
  318.             for (p = &str[length - 1]; Code::IsDigit(*p); p--)
  319.                 ;
  320.             if (*p != U_DOLLAR) // not an anonymous class
  321.                 class_pool[index] = ReadTypeFromSignature(base_type, str, length, tok);
  322.         }
  323.     }
  324.  
  325.     return class_pool[index];
  326. }
  327.  
  328.  
  329. void Semantic::ReadClassFile(TypeSymbol *type, LexStream::TokenIndex tok)
  330. {
  331. #ifdef TEST
  332.     control.class_files_read++;
  333. #endif
  334.  
  335.     FileSymbol *file_symbol = type -> file_symbol;
  336.  
  337.     if (control.option.verbose)  {
  338.         Coutput << "[read "
  339.                 << file_symbol -> FileName()
  340.                 << "]\n";
  341.     }
  342.  
  343.     if (file_symbol -> IsZip())
  344.     {
  345.         ZipFile *zipfile = new ZipFile(file_symbol);
  346.  
  347.         if (zipfile -> Buffer() == NULL)
  348.         {
  349.             type -> SetSymbolTable(1); // this symbol table will only contain a default constructor
  350.             if (type != control.Object())
  351.                 type -> super = (type == control.Throwable() ? control.Object() : control.Throwable());
  352.             type -> MarkBad();
  353.             AddDefaultConstructor(type);
  354.  
  355.             ReportSemError(SemanticError::COMPRESSED_ZIP_FILE,
  356.                            tok,
  357.                            tok,
  358.                            file_symbol -> PathSym() -> Name(),
  359.                            type -> ContainingPackage() -> PackageName(),
  360.                            type -> ExternalName());
  361.         }
  362.         else if (! ProcessClassFile(type, zipfile -> Buffer(), file_symbol -> uncompressed_size, tok))
  363.             ProcessBadClass(type, tok);
  364.  
  365.         delete zipfile;
  366.     }
  367.     else
  368.     {
  369. #if defined(UNIX_FILE_SYSTEM) || defined(AMIGAOS_FILE_SYSTEM)
  370.         FILE *classfile = ::SystemFopen(file_symbol -> FileName(), "rb");
  371.         if (classfile == NULL)
  372.         {
  373.             type -> SetSymbolTable(1); // this symbol table will only contain a default constructor
  374.             if (type != control.Object())
  375.                 type -> super = (type == control.Throwable() ? control.Object() : control.Throwable());
  376.             type -> MarkBad();
  377.             AddDefaultConstructor(type);
  378.  
  379.             ReportSemError(SemanticError::CANNOT_OPEN_CLASS_FILE,
  380.                            tok,
  381.                            tok,
  382.                            type -> ContainingPackage() -> PackageName(),
  383.                            type -> ExternalName());
  384.         }
  385.         else
  386.         {
  387.             struct stat status;
  388.             ::SystemStat(file_symbol -> FileName(), &status);
  389.  
  390.             char *class_buffer = new char[status.st_size];
  391.             fread(class_buffer, sizeof(char), status.st_size, classfile);
  392.             fclose(classfile);
  393.  
  394.             if (! ProcessClassFile(type, class_buffer, status.st_size, tok))
  395.                 ProcessBadClass(type, tok);
  396.  
  397.             delete [] class_buffer;
  398.         }
  399. #elif defined(WIN32_FILE_SYSTEM)
  400.         HANDLE classfile = CreateFile(file_symbol -> FileName(), GENERIC_READ, FILE_SHARE_READ,
  401.                                       NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL);
  402.         HANDLE mapfile = (classfile == INVALID_HANDLE_VALUE
  403.                                      ? classfile
  404.                                      : CreateFileMapping(classfile, NULL, PAGE_READONLY, 0, 0, NULL));
  405.  
  406.         char *class_buffer = (mapfile == INVALID_HANDLE_VALUE ? NULL : (char *) MapViewOfFile(mapfile, FILE_MAP_READ, 0, 0, 0));
  407.  
  408.         if (class_buffer == NULL)
  409.         {
  410.             type -> SetSymbolTable(1); // this symbol table will only contain a default constructor
  411.             if (type != control.Object())
  412.                 type -> super = (type == control.Throwable() ? control.Object() : control.Throwable());
  413.             type -> MarkBad();
  414.             AddDefaultConstructor(type);
  415.  
  416.             ReportSemError(SemanticError::CANNOT_OPEN_CLASS_FILE,
  417.                            tok,
  418.                            tok,
  419.                            type -> ContainingPackage() -> PackageName(),
  420.                            type -> ExternalName());
  421.         }
  422.         else
  423.         {
  424.             DWORD high_order,
  425.                   size = GetFileSize(classfile, &high_order);
  426.  
  427.             size = (size == 0xFFFFFFFF && GetLastError() != NO_ERROR ? 0 : size);
  428.  
  429.             if (! ProcessClassFile(type, class_buffer, size, tok))
  430.                 ProcessBadClass(type, tok);
  431.  
  432.             UnmapViewOfFile(class_buffer);
  433.             CloseHandle(mapfile);
  434.             CloseHandle(classfile);
  435.         }
  436. #endif
  437.     }
  438.  
  439.     return;
  440. }
  441.  
  442.  
  443. void Semantic::ProcessBadClass(TypeSymbol *type, LexStream::TokenIndex tok)
  444. {
  445.     if (! type -> Table()) // if there is no symbol table, add one
  446.         type -> SetSymbolTable(1); // this symbol table will only contain a default constructor
  447.     if ((! type -> super) && type != control.Object()) // if there is no super type, add one
  448.         type -> super = (type == control.Throwable() ? control.Object() : control.Throwable());
  449.     type -> MarkBad();
  450.     if (! type -> FindConstructorSymbol()) // if there are no constructors, add a default one
  451.         AddDefaultConstructor(type);
  452.  
  453.     ReportSemError(SemanticError::INVALID_CLASS_FILE,
  454.                    tok,
  455.                    tok,
  456.                    type -> ContainingPackage() -> PackageName(),
  457.                    type -> ExternalName());
  458.  
  459.     return;
  460. }
  461.  
  462.  
  463. bool Semantic::ProcessClassFile(TypeSymbol *type, char *buffer, int buffer_size, LexStream::TokenIndex tok)
  464. {
  465.     char *buffer_tail = &buffer[buffer_size];
  466.  
  467.     type -> MarkHeaderProcessed();
  468.     type -> MarkConstructorMembersProcessed();
  469.     type -> MarkMethodMembersProcessed();
  470.     type -> MarkFieldMembersProcessed();
  471.     type -> MarkLocalClassProcessingCompleted();
  472.     type -> MarkSourceNoLongerPending();
  473.  
  474.     Skip(buffer, 8); // u4 magic;
  475.                      // u2 minor_version;
  476.                      // u2 major_version;
  477.  
  478.     if (! InRange(buffer, buffer_tail, 2))
  479.         return false;
  480.     u2 constant_pool_count = GetAndSkipU2(buffer);
  481.     char **constant_pool = new char*[constant_pool_count];
  482.     TypeSymbol **class_pool = (TypeSymbol **)
  483.                               memset(new TypeSymbol*[constant_pool_count], 0, constant_pool_count * sizeof(TypeSymbol *));
  484.  
  485.     constant_pool[0] = NULL;
  486.     int *next_pool_index = new int[constant_pool_count],
  487.         Class_root = 0,
  488.         NameAndType_root = 0;
  489.  
  490.     for (int i = 1; i < constant_pool_count; i++)
  491.     {
  492.         constant_pool[i] = buffer;
  493.         if (! InRange(buffer, buffer_tail, 1))
  494.             return false;
  495.         u1 tag = GetAndSkipU1(buffer);
  496.         if (tag == Cp_Info::CONSTANT_Long || tag == Cp_Info::CONSTANT_Double)
  497.             ++i; // skip the next entry for eight-byte constants
  498.  
  499.         u2 length;
  500.         switch(tag)
  501.         {
  502.             case Cp_Info::CONSTANT_Utf8:
  503.                  if (! InRange(buffer, buffer_tail, 2))
  504.                      return false;
  505.                  length = GetAndSkipU2(buffer);
  506.                  break;
  507.             case Cp_Info::CONSTANT_Class:
  508.                  length = 2;                      // set_NameIndex(GetU2(classfile));
  509.                  next_pool_index[i] = Class_root; // save index of class constant
  510.                  Class_root = i;
  511.                  break;
  512.             case Cp_Info::CONSTANT_String:
  513.                  length = 2; // set_NameIndex(GetU2(classfile));
  514.                  break;
  515.             case Cp_Info::CONSTANT_NameAndType:
  516.                  length = 4; // set_class_index(GetU2(classfile)); set_name_and_type_index(GetU2(classfile));
  517.                              //                                     or
  518.                              // set_NameIndex(GetU2(classfile)); set_DescriptorIndex(GetU2(classfile));
  519.                              //                                     or
  520.                              // SetBytes(GetU4(classfile));
  521.                  next_pool_index[i] = NameAndType_root; // save index of class constant
  522.                  NameAndType_root = i;
  523.                  break;
  524.             case Cp_Info::CONSTANT_Fieldref:
  525.             case Cp_Info::CONSTANT_Methodref:
  526.             case Cp_Info::CONSTANT_InterfaceMethodref:
  527.             case Cp_Info::CONSTANT_Integer:
  528.             case Cp_Info::CONSTANT_Float:
  529.                  length = 4; // set_class_index(GetU2(classfile)); set_name_and_type_index(GetU2(classfile));
  530.                              //                                     or
  531.                              // set_NameIndex(GetU2(classfile)); set_DescriptorIndex(GetU2(classfile));
  532.                              //                                     or
  533.                              // SetBytes(GetU4(classfile));
  534.                  break;
  535.             case Cp_Info::CONSTANT_Long:
  536.             case Cp_Info::CONSTANT_Double:
  537.                  length = 8; // set_HighBytes(GetU4(classfile));
  538.                              // set_LowBytes(GetU4(classfile));
  539.  
  540.                  break;
  541.             default:
  542. fprintf(stderr, "%s%d%s", "chaos: CODE \"", (int) tag, "\" is an invalid tag !!!\n");
  543. fflush(stderr);
  544.                  break;
  545.         }
  546.  
  547.         Skip(buffer, length);
  548.     }
  549.  
  550.     //
  551.     // We are now ready to process this class file. If type is a nested
  552.     // class, we will set its untransformed access flags properly later...
  553.     //
  554.     if (! InRange(buffer, buffer_tail, 2))
  555.         return false;
  556.     type -> SetFlags(GetAndSkipU2(buffer));
  557.  
  558.     if (! InRange(buffer, buffer_tail, 2))
  559.         return false;
  560.     u2 this_class_index = GetAndSkipU2(buffer); // The index of this class
  561.     u2 name_index = Constant_Class_info::NameIndex(constant_pool[this_class_index]);
  562.     char *type_name = Constant_Utf8_info::Bytes(constant_pool[name_index]);
  563.     u2 type_name_length = Constant_Utf8_info::Length(constant_pool[name_index]);
  564.  
  565.     int n;
  566.     for (n = type_name_length; n >= 0 && type_name[n] != U_SLASH; n--)
  567.         ;
  568.  
  569.     bool matched_package_names;
  570.     if (type -> ContainingPackage() -> PackageNameLength() == n)
  571.     {
  572.         wchar_t *package_name = type -> ContainingPackage() -> PackageName();
  573.         int i;
  574.         for (i = 0; i < n && package_name[i] == type_name[i]; i++)
  575.             ;
  576.         matched_package_names = (i == n);
  577.     }
  578.     else matched_package_names = (n < 0 && type -> ContainingPackage() == control.unnamed_package);
  579.  
  580.     if (! matched_package_names)
  581.     {
  582.         type -> SetSymbolTable(1); // this symbol table will only contain a default constructor
  583.         if (type != control.Object())
  584.             type -> super = (type == control.Throwable() ? control.Object() : control.Throwable());
  585.         type -> MarkBad();
  586.         AddDefaultConstructor(type);
  587.  
  588.         if (n < 0)
  589.             n = 0;
  590.         wchar_t *package_name = new wchar_t[n + 1];
  591.         for (int i = 0; i < n; i++)
  592.             package_name[i] = type_name[i];
  593.         package_name[n] = U_NULL;
  594.  
  595.         if (type -> ContainingPackage() == control.unnamed_package)
  596.              ReportSemError(SemanticError::TYPE_NOT_IN_UNNAMED_PACKAGE,
  597.                             tok,
  598.                             tok,
  599.                             type -> ExternalName(),
  600.                             type -> file_symbol -> directory_symbol -> PathSym() -> Name(),
  601.                             package_name);
  602.         else ReportSemError(SemanticError::TYPE_IN_WRONG_PACKAGE,
  603.                             tok,
  604.                             tok,
  605.                             type -> ExternalName(),
  606.                             type -> ContainingPackage() -> PackageName(),
  607.                             package_name);
  608.  
  609.         delete [] package_name;
  610.     }
  611.     else
  612.     {
  613.         if ((! type -> IsNested()) && (n < 0)) // An outermost type contained in the unnamed package?
  614.         {
  615.             TypeSymbol *old_type = (TypeSymbol *) control.unnamed_package_types.Image(type -> Identity());
  616.             if (! old_type)
  617.                 control.unnamed_package_types.AddElement(type);
  618.             else
  619.             {
  620.                 ReportSemError(SemanticError::DUPLICATE_TYPE_DECLARATION,
  621.                                tok,
  622.                                tok,
  623.                                type -> Name(),
  624.                                old_type -> FileLoc());
  625.             }
  626.         }
  627.  
  628.         //
  629.         // On systems such as NT and Win-95 that are not case-sensitive,
  630.         // we need to confirm that the type name specified matches the name
  631.         // in the class file.
  632.         //
  633.         assert(type_name_length - (n + 1) == type -> ExternalNameLength());
  634.  
  635.         int i;
  636.         for (i = 0; i < type -> ExternalNameLength(); i++)
  637.         {
  638.             if (type_name[(n + 1) + i] != type -> ExternalName()[i])
  639.                 break;
  640.         }
  641.         if (i < type -> ExternalNameLength())
  642.         {
  643.             wchar_t *name = new wchar_t[type_name_length + 1];
  644.             for (int k = 0; k < type_name_length; k++)
  645.                 name[k] = type_name[k];
  646.             name[type_name_length] = U_NULL;
  647.             ReportSemError(SemanticError::TYPE_NAME_MISMATCH,
  648.                            tok,
  649.                            tok,
  650.                            type -> ContainingPackage() -> PackageName(),
  651.                            type -> ExternalName(),
  652.                            name);
  653.             delete [] name;
  654.         }
  655.  
  656.         //
  657.         // ... Start doing real work !!!
  658.         //
  659.         if (! InRange(buffer, buffer_tail, 2))
  660.             return false;
  661.         u2 super_class = GetAndSkipU2(buffer);
  662.         if (super_class)
  663.         {
  664.             type -> super = GetClassPool(type, class_pool, constant_pool, super_class, tok);
  665.  
  666.             type -> outermost_type -> supertypes_closure -> AddElement(type -> super -> outermost_type);
  667.             type -> outermost_type -> supertypes_closure -> Union(*type -> super -> outermost_type -> supertypes_closure);
  668.         }
  669.  
  670.         if (! InRange(buffer, buffer_tail, 2))
  671.             return false;
  672.         for (int j = GetAndSkipU2(buffer); j > 0; j--)
  673.         {
  674.             if (! InRange(buffer, buffer_tail, 2))
  675.                 return false;
  676.             u2 interface_index = GetAndSkipU2(buffer);
  677.             type -> AddInterface(GetClassPool(type, class_pool, constant_pool, interface_index, tok));
  678.  
  679.             type -> outermost_type -> supertypes_closure -> AddElement(type -> super -> outermost_type);
  680.             type -> outermost_type -> supertypes_closure -> Union(*type -> super -> outermost_type -> supertypes_closure);
  681.         }
  682.  
  683.         //
  684.         // Read all the fields
  685.         //
  686.         if (! InRange(buffer, buffer_tail, 2))
  687.             return false;
  688.         u2 fields_count = GetAndSkipU2(buffer);
  689.         VariableSymbol **fields = new VariableSymbol*[fields_count];
  690.         for (int k = 0; k < fields_count; k++)
  691.         {
  692.             if (! InRange(buffer, buffer_tail, 6))
  693.                 return false;
  694.             u2 access_flags = GetAndSkipU2(buffer);
  695.             u2 name_index = GetAndSkipU2(buffer);
  696.             u2 descriptor_index = GetAndSkipU2(buffer);
  697.  
  698.             NameSymbol *name_symbol = control.ConvertUtf8ToUnicode(Constant_Utf8_info::Bytes(constant_pool[name_index]),
  699.                                                                    Constant_Utf8_info::Length(constant_pool[name_index]));
  700.  
  701.             VariableSymbol *symbol = new VariableSymbol(name_symbol);
  702.             fields[k] = symbol;
  703.  
  704.             symbol -> SetOwner(type);
  705.             symbol -> MarkComplete();
  706.             symbol -> SetFlags(access_flags);
  707.             symbol -> SetSignatureString(Constant_Utf8_info::Bytes(constant_pool[descriptor_index]),
  708.                                          Constant_Utf8_info::Length(constant_pool[descriptor_index]));
  709.  
  710.             if (! InRange(buffer, buffer_tail, 2))
  711.                 return false;
  712.             int j = GetAndSkipU2(buffer);
  713.             for (; j > 0; j--)
  714.             {
  715.                 if (! InRange(buffer, buffer_tail, 2))
  716.                     return false;
  717.                 u2 name_index = GetAndSkipU2(buffer);
  718.  
  719.                 if (Constant_Utf8_info::Length(constant_pool[name_index]) == StringConstant::U8S_Synthetic_length &&
  720.                     memcmp(Constant_Utf8_info::Bytes(constant_pool[name_index]),
  721.                            StringConstant::U8S_Synthetic, StringConstant::U8S_Synthetic_length * sizeof(char)) == 0)
  722.                 {
  723.                     symbol -> MarkSynthetic();
  724.                     if (! InRange(buffer, buffer_tail, 4))
  725.                         return false;
  726.                     Skip(buffer, 4); // u4 attribute_length() { return attribute_length_; }
  727.                                      // there is no info associated with a Synthetic attribute
  728.                     break; // If the field is synthetic, remaining attributes don't matter...
  729.                 }
  730.                 else if (Constant_Utf8_info::Length(constant_pool[name_index]) == StringConstant::U8S_Deprecated_length &&
  731.                          memcmp(Constant_Utf8_info::Bytes(constant_pool[name_index]),
  732.                                 StringConstant::U8S_Deprecated, StringConstant::U8S_Deprecated_length * sizeof(char)) == 0)
  733.                 {
  734.                     symbol -> MarkDeprecated();
  735.                     if (! InRange(buffer, buffer_tail, 4))
  736.                         return false;
  737.                     Skip(buffer, 4); // u4 attribute_length() { return attribute_length_; }
  738.                                      // there is no info associated with a Deprecated attribute
  739.                 }
  740.                 else if (Constant_Utf8_info::Length(constant_pool[name_index]) == StringConstant::U8S_ConstantValue_length &&
  741.                          memcmp(Constant_Utf8_info::Bytes(constant_pool[name_index]),
  742.                                 StringConstant::U8S_ConstantValue, StringConstant::U8S_ConstantValue_length * sizeof(char)) == 0)
  743.                 {
  744.                     Skip(buffer, 4); // u4 attribute_length;
  745.                     if (! InRange(buffer, buffer_tail, 2))
  746.                         return false;
  747.                     u2 constantvalue_index = GetAndSkipU2(buffer);
  748.  
  749.                     u1 tag = Cp_Info::Tag(constant_pool[constantvalue_index]);
  750.                     if (tag == Cp_Info::CONSTANT_Integer)
  751.                     {
  752.                         int value = Constant_Integer_info::Value(constant_pool[constantvalue_index]);
  753.                         symbol -> initial_value = control.int_pool.FindOrInsert(value);
  754.                     }
  755.                     else if (tag == Cp_Info::CONSTANT_Long)
  756.                     {
  757.                         LongInt value = Constant_Long_info::Value(constant_pool[constantvalue_index]);
  758.                         symbol -> initial_value = control.long_pool.FindOrInsert(value);
  759.                     }
  760.                     else if (tag == Cp_Info::CONSTANT_Float)
  761.                     {
  762.                         IEEEfloat value = Constant_Float_info::Value(constant_pool[constantvalue_index]);
  763.                         symbol -> initial_value = control.float_pool.FindOrInsert(value);
  764.                     }
  765.                     else if (tag == Cp_Info::CONSTANT_Double)
  766.                     {
  767.                         IEEEdouble value = Constant_Double_info::Value(constant_pool[constantvalue_index]);
  768.                         symbol -> initial_value = control.double_pool.FindOrInsert(value);
  769.                     }
  770.                     else if (tag == Cp_Info::CONSTANT_String)
  771.                     {
  772.                         u2 string_index = Constant_String_info::StringIndex(constant_pool[constantvalue_index]);
  773.                         u2 length = Constant_Utf8_info::Length(constant_pool[string_index]);
  774.                         char *value = Constant_Utf8_info::Bytes(constant_pool[string_index]);
  775.                         symbol -> initial_value = control.Utf8_pool.FindOrInsert(value, length);
  776.                     }
  777.                     else if (tag == Cp_Info::CONSTANT_Utf8)
  778.                     {
  779.                         u2 length = Constant_Utf8_info::Length(constant_pool[constantvalue_index]);
  780.                         char *value = Constant_Utf8_info::Bytes(constant_pool[constantvalue_index]);
  781.                         symbol -> initial_value = control.Utf8_pool.FindOrInsert(value, length);
  782.                     }
  783. else
  784. {
  785. fprintf(stderr, "%s%d%s", "chaos: Constant tag \"", (int) tag, "\" is an invalid tag !!!\n");
  786. fflush(stderr);
  787. }
  788.                 }
  789.                 else
  790.                 {
  791.                     if (! InRange(buffer, buffer_tail, 4))
  792.                         return false;
  793.                     Skip(buffer, GetAndSkipU4(buffer)); // u4 attribute_length() { return attribute_length_; }
  794.                                                         // u1 *info; /* info[attribute_length] */
  795.                 }
  796.             }
  797.  
  798.             //
  799.             // Skip remaining attributes
  800.             //
  801.             while (--j > 0)
  802.             {
  803.                 Skip(buffer, 2);                    // u2 name_index
  804.                 if (! InRange(buffer, buffer_tail, 4))
  805.                     return false;
  806.                 Skip(buffer, GetAndSkipU4(buffer)); // u4 attribute_length() { return attribute_length_; }
  807.                                                     // u1 *info; /* info[attribute_length] */
  808.             }
  809.         }
  810.  
  811.         //
  812.         // Read all the methods
  813.         //
  814.         if (! InRange(buffer, buffer_tail, 2))
  815.             return false;
  816.         u2 methods_count = GetAndSkipU2(buffer);
  817.         MethodSymbol **methods = new MethodSymbol*[methods_count];
  818.         for (int l = 0; l < methods_count; l++)
  819.         {
  820.             if (! InRange(buffer, buffer_tail, 6))
  821.                 return false;
  822.             u2 access_flags = GetAndSkipU2(buffer);
  823.             u2 name_index = GetAndSkipU2(buffer);
  824.             u2 descriptor_index = GetAndSkipU2(buffer);
  825.  
  826.             NameSymbol *name_symbol = control.ConvertUtf8ToUnicode(Constant_Utf8_info::Bytes(constant_pool[name_index]),
  827.                                                                Constant_Utf8_info::Length(constant_pool[name_index]));
  828.  
  829.             if (! InRange(buffer, buffer_tail, 2))
  830.                 return false;
  831.             int j = GetAndSkipU2(buffer); // number of attributes
  832.  
  833.             if (name_symbol == control.clinit_name_symbol)
  834.             {
  835.                 methods[l] = NULL;
  836.                 j++; // see the loop (way) below that skips the remaining attributes
  837.             }
  838.             else
  839.             {
  840.                 MethodSymbol *method = new MethodSymbol(name_symbol);
  841.                 methods[l] = method;
  842.  
  843.                 method -> SetContainingType(type);
  844.                 method -> SetFlags(access_flags);
  845.  
  846.                 char *signature = Constant_Utf8_info::Bytes(constant_pool[descriptor_index]);
  847.                 int length = Constant_Utf8_info::Length(constant_pool[descriptor_index]);
  848.  
  849.                 method -> SetSignature(control.Utf8_pool.FindOrInsert(signature, length));
  850.  
  851.                 //
  852.                 // Read the exception that can be thrown by this method
  853.                 //
  854.                 for (; j > 0; j--)
  855.                 {
  856.                     if (! InRange(buffer, buffer_tail, 2))
  857.                         return false;
  858.                     u2 name_index = GetAndSkipU2(buffer);
  859.  
  860.                     if (Constant_Utf8_info::Length(constant_pool[name_index]) == StringConstant::U8S_Synthetic_length &&
  861.                         memcmp(Constant_Utf8_info::Bytes(constant_pool[name_index]),
  862.                                StringConstant::U8S_Synthetic, StringConstant::U8S_Synthetic_length * sizeof(char)) == 0)
  863.                     {
  864.                         method -> MarkSynthetic();
  865.                         if (! InRange(buffer, buffer_tail, 4))
  866.                             return false;
  867.                         Skip(buffer, 4); // u4 attribute_length() { return attribute_length_; }
  868.                                          // there is no info associated with a Synthetic attribute
  869.                         break; // If the field is synthetic, remaining attributes don't matter...
  870.                     }
  871.                     else if (Constant_Utf8_info::Length(constant_pool[name_index]) == StringConstant::U8S_Deprecated_length &&
  872.                              memcmp(Constant_Utf8_info::Bytes(constant_pool[name_index]),
  873.                                     StringConstant::U8S_Deprecated, StringConstant::U8S_Deprecated_length * sizeof(char)) == 0)
  874.                     {
  875.                         method -> MarkDeprecated();
  876.                         if (! InRange(buffer, buffer_tail, 4))
  877.                             return false;
  878.                         Skip(buffer, 4); // u4 attribute_length() { return attribute_length_; }
  879.                                          // there is no info associated with a Deprecated attribute
  880.                     }
  881.                     else if (Constant_Utf8_info::Length(constant_pool[name_index]) == StringConstant::U8S_Exceptions_length &&
  882.                              memcmp(Constant_Utf8_info::Bytes(constant_pool[name_index]),
  883.                                     StringConstant::U8S_Exceptions, StringConstant::U8S_Exceptions_length * sizeof(char)) == 0)
  884.                     {
  885.                         Skip(buffer, 4); // attribute_length = GetAndSkipU4(buffer);
  886.                         if (! InRange(buffer, buffer_tail, 2))
  887.                             return false;
  888.                         for (int k = GetAndSkipU2(buffer); k > 0; k--)
  889.                         {
  890.                             if (! InRange(buffer, buffer_tail, 2))
  891.                                 return false;
  892.                             int index = GetAndSkipU2(buffer);
  893.                             u2 name_index = Constant_Class_info::NameIndex(constant_pool[index]);
  894.                             method -> AddThrowsSignature(Constant_Utf8_info::Bytes(constant_pool[name_index]),
  895.                                                          Constant_Utf8_info::Length(constant_pool[name_index]));
  896.                         }
  897.                     }
  898.                     else
  899.                     {
  900.                         if (! InRange(buffer, buffer_tail, 4))
  901.                             return false;
  902.                         Skip(buffer, GetAndSkipU4(buffer)); // u4 attribute_length() { return attribute_length_; }
  903.                                                             // u1 *info; /* info[attribute_length] */
  904.                     }
  905.                 }
  906.             }
  907.  
  908.             //
  909.             // Skip remaining attributes
  910.             //
  911.             while (--j > 0)
  912.             {
  913.                 Skip(buffer, 2);                     // u2 name_index
  914.                 if (! InRange(buffer, buffer_tail, 4))
  915.                     return false;
  916.                 Skip(buffer, GetAndSkipU4(buffer)); // u4 attribute_length() { return attribute_length_; }
  917.                                                     // u1 *info; /* info[attribute_length] */
  918.             }
  919.         }
  920.  
  921.         //
  922.         // Process InnerClasses attributes
  923.         //
  924.         if (! InRange(buffer, buffer_tail, 2))
  925.             return false;
  926.         u2 attributes_count = GetAndSkipU2(buffer);
  927.         Tuple<u2> inner_name_indexes(8);
  928.         for (int a = 0; a < attributes_count; a++)
  929.         {
  930.             if (! InRange(buffer, buffer_tail, 2))
  931.                 return false;
  932.             u2 name_index = GetAndSkipU2(buffer);
  933.  
  934.             if (Constant_Utf8_info::Length(constant_pool[name_index]) == StringConstant::U8S_InnerClasses_length &&
  935.                 memcmp(Constant_Utf8_info::Bytes(constant_pool[name_index]),
  936.                        StringConstant::U8S_InnerClasses, StringConstant::U8S_InnerClasses_length * sizeof(char)) == 0)
  937.             {
  938.                 Skip(buffer, 4); // attribute_length = GetAndSkipU4(buffer);
  939.                 if (! InRange(buffer, buffer_tail, 2))
  940.                     return false;
  941.                 for (int k = GetAndSkipU2(buffer); k > 0; k--)
  942.                 {
  943.                     if (! InRange(buffer, buffer_tail, 8))
  944.                         return false;
  945.                     u2 inner_class_info_index   = GetAndSkipU2(buffer);
  946.                     u2 outer_class_info_index   = GetAndSkipU2(buffer);
  947.                     u2 inner_name_index         = GetAndSkipU2(buffer);
  948.                     u2 inner_class_access_flags = GetAndSkipU2(buffer);
  949.  
  950.                     //
  951.                     // Recall that the untransformed access flag is the one specified
  952.                     // in the inner_class attribute. (See 1.1 document)
  953.                     //
  954.                     if (inner_class_info_index == this_class_index)
  955.                         type -> SetFlags(inner_class_access_flags);
  956.                     //
  957.                     // This guard statement is used to identify only inner classes that are
  958.                     // not anonymous classes and are immediately contained within this class.
  959.                     // Recall that an inner class may not be enclosed (directly on indirectly)
  960.                     // in another class with the same name. Therefore when outer_class_info_index
  961.                     // matches this_class_index they both refer to "this" class (that we are currently processing).
  962.                     //
  963.                     else if ((outer_class_info_index == this_class_index) &&
  964.                              (inner_class_info_index != 0) &&                  // an inner class
  965.                              (inner_name_index != 0))                          // not an anonymous class
  966.                     {
  967.                         //
  968.                         // When length is 0, the inner class in question is "this" class ?
  969.                         // the one we are currently reading ?
  970.                         //
  971.                         u2 length = Constant_Utf8_info::Length(constant_pool[inner_name_index]);
  972.                         if (length > 0)
  973.                             inner_name_indexes.Next() = inner_name_index;
  974.                     }
  975.                 }
  976.             }
  977.             else if (Constant_Utf8_info::Length(constant_pool[name_index]) == StringConstant::U8S_Deprecated_length &&
  978.                      memcmp(Constant_Utf8_info::Bytes(constant_pool[name_index]),
  979.                             StringConstant::U8S_Deprecated, StringConstant::U8S_Deprecated_length * sizeof(char)) == 0)
  980.             {
  981.                 type -> MarkDeprecated();
  982.                 if (! InRange(buffer, buffer_tail, 4))
  983.                     return false;
  984.                 Skip(buffer, 4); // u4 attribute_length() { return attribute_length_; }
  985.                                  // there is no info associated with a Deprecated attribute
  986.             }
  987.             else
  988.             {
  989.                 if (! InRange(buffer, buffer_tail, 4))
  990.                     return false;
  991.                 Skip(buffer, GetAndSkipU4(buffer)); // u4 attribute_length() { return attribute_length_; }
  992.                                                     // u1 *info; /* info[attribute_length] */
  993.             }
  994.         }
  995.  
  996.         //
  997.         // We now have enough information to make a good estimate for the size of the
  998.         // symbol table we need for this class.
  999.         //
  1000.         type -> SetSymbolTable(fields_count + methods_count + inner_name_indexes.Length());
  1001.  
  1002.         //
  1003.         //   . Read in all class files that are referenced in CONSTANT_Class
  1004.         //     structures in this class file.
  1005.         //
  1006.         //   . Read in all class files that are referenced in CONSTANT_NameAndType
  1007.         //     structures in this class file.
  1008.         //
  1009.         if (control.option.full_check && (control.option.unzip || (! type -> file_symbol -> IsZip())))
  1010.         {
  1011.             for (int h = Class_root; h != 0; h = next_pool_index[h])
  1012.                 GetClassPool(type, class_pool, constant_pool, h, tok);
  1013.  
  1014.             for (int j = NameAndType_root; j != 0; j = next_pool_index[j])
  1015.             {
  1016.                 u2 descriptor_index = Constant_NameAndType_info::DescriptorIndex(constant_pool[j]);
  1017.                 char *signature = Constant_Utf8_info::Bytes(constant_pool[descriptor_index]);
  1018.  
  1019.                 if (! class_pool[descriptor_index])
  1020.                 {
  1021.                     if (*signature != U_LEFT_PARENTHESIS)  // ')' indicates a field descriptor
  1022.                         class_pool[descriptor_index] = ProcessSignature(type,
  1023.                                                                         Constant_Utf8_info::Bytes(constant_pool[descriptor_index]),
  1024.                                                                         tok);
  1025.                     else // a method descriptor
  1026.                     {
  1027.                         signature++; // +1 to skip initial '('
  1028.                         while (*signature != U_RIGHT_PARENTHESIS)
  1029.                         {
  1030.                             char *str;
  1031.                             for (str = signature; *str == U_LEFT_BRACKET; str++)
  1032.                                 ;
  1033.  
  1034.                             if (*str == U_L)
  1035.                             {
  1036.                                 for (str++; *str != U_SEMICOLON; str++)
  1037.                                     ;
  1038.                             }
  1039.  
  1040.                             int len = str - signature + 1;
  1041.                             signature += len; // make signature point to next type
  1042.                         }
  1043.                         signature++; // skip L')'
  1044.  
  1045.                         class_pool[descriptor_index] = ProcessSignature(type, signature, tok); // save the return type in first spot
  1046.                     }
  1047.                 }
  1048.             }
  1049.  
  1050.             //
  1051.             // Process all the fields, then the methods, then the inner types.
  1052.             // Read in all the types associated with the signatures.
  1053.             //
  1054.             for (int k = 0; k < fields_count; k++)
  1055.             {
  1056.                 type -> InsertVariableSymbol(fields[k]);
  1057.                 fields[k] -> ProcessVariableSignature((Semantic *) this, tok);
  1058.             }
  1059.  
  1060.             for (int l = 0; l < methods_count; l++)
  1061.             {
  1062.                 if (methods[l])
  1063.                 {
  1064.                     MethodSymbol *method = type -> FindMethodSymbol(methods[l] -> name_symbol);
  1065.  
  1066.                     if (! method)
  1067.                     {
  1068.                          if (methods[l] -> name_symbol == control.init_name_symbol)
  1069.                               type -> InsertConstructorSymbol(methods[l]);
  1070.                          else type -> InsertMethodSymbol(methods[l]);
  1071.                     }
  1072.                     else type -> Overload(method, methods[l]);
  1073.                     methods[l] -> ProcessMethodSignature((Semantic *) this, tok);
  1074.                 }
  1075.             }
  1076.  
  1077.             for (int m = 0; m < inner_name_indexes.Length(); m++)
  1078.             {
  1079.                 u2 inner_name_index = inner_name_indexes[m];
  1080.                 type -> AddNestedTypeSignature(Constant_Utf8_info::Bytes(constant_pool[inner_name_index]),
  1081.                                                Constant_Utf8_info::Length(constant_pool[inner_name_index]));
  1082.             }
  1083.             type -> ProcessNestedTypeSignatures((Semantic *) this, tok);
  1084.         }
  1085.         else
  1086.         {
  1087.             //
  1088.             // Process all the fields, then the methods, then the inner types.
  1089.             //
  1090.             for (int k = 0; k < fields_count; k++)
  1091.                 type -> InsertVariableSymbol(fields[k]);
  1092.  
  1093.             for (int l = 0; l < methods_count; l++)
  1094.             {
  1095.                 if (methods[l])
  1096.                 {
  1097.                     MethodSymbol *method = type -> FindMethodSymbol(methods[l] -> name_symbol);
  1098.  
  1099.                     if (! method)
  1100.                     {
  1101.                          if (methods[l] -> name_symbol == control.init_name_symbol)
  1102.                               type -> InsertConstructorSymbol(methods[l]);
  1103.                          else type -> InsertMethodSymbol(methods[l]);
  1104.                     }
  1105.                     else type -> Overload(method, methods[l]);
  1106.                 }
  1107.             }
  1108.  
  1109.             for (int m = 0; m < inner_name_indexes.Length(); m++)
  1110.             {
  1111.                 u2 inner_name_index = inner_name_indexes[m];
  1112.                 type -> AddNestedTypeSignature(Constant_Utf8_info::Bytes(constant_pool[inner_name_index]),
  1113.                                                Constant_Utf8_info::Length(constant_pool[inner_name_index]));
  1114.             }
  1115.         }
  1116.  
  1117.         delete [] fields;
  1118.         delete [] methods;
  1119.  
  1120.         //
  1121.         // Release extra space. This is an optimization.
  1122.         //
  1123.         type -> CompressSpace();
  1124.     }
  1125.  
  1126.     delete [] next_pool_index;
  1127.     delete [] class_pool;
  1128.     delete [] constant_pool;
  1129.  
  1130.     return true;
  1131. }
  1132.  
  1133.  
  1134.