OSDN Git Service

PR java/12915:
[pf3gnuchains/gcc-fork.git] / gcc / java / class.c
index 0818bc2..2aacbd4 100644 (file)
@@ -48,19 +48,20 @@ The Free Software Foundation is independent of Sun Microsystems, Inc.  */
 #define O_BINARY 0 /* MS-DOS brain-damage */
 #endif
 
-static tree make_method_value PARAMS ((tree));
-static tree build_java_method_type PARAMS ((tree, tree, int));
-static int32 hashUtf8String PARAMS ((const char *, int));
-static tree make_field_value PARAMS ((tree));
-static tree get_dispatch_vector PARAMS ((tree));
-static tree get_dispatch_table PARAMS ((tree, tree));
-static void add_interface_do PARAMS ((tree, tree, int));
-static tree maybe_layout_super_class PARAMS ((tree, tree));
-static int assume_compiled PARAMS ((const char *));
-static tree build_method_symbols_entry PARAMS ((tree));
+static tree make_method_value (tree);
+static tree build_java_method_type (tree, tree, int);
+static int32 hashUtf8String (const char *, int);
+static tree make_field_value (tree);
+static tree get_dispatch_vector (tree);
+static tree get_dispatch_table (tree, tree);
+static int supers_all_compiled (tree type);
+static void add_interface_do (tree, tree, int);
+static tree maybe_layout_super_class (tree, tree);
+static void add_miranda_methods (tree, tree);
+static int assume_compiled (const char *);
+static tree build_symbol_entry (tree);
 
 static GTY(()) rtx registerClass_libfunc;
-static GTY(()) rtx registerResource_libfunc;
 
 struct obstack temporary_obstack;
 
@@ -86,8 +87,8 @@ typedef struct assume_compiled_node_struct
   struct assume_compiled_node_struct *child;
 } assume_compiled_node;
 
-static assume_compiled_node *find_assume_compiled_node
-                       PARAMS ((assume_compiled_node *, const char *));
+static assume_compiled_node *find_assume_compiled_node (assume_compiled_node *,
+                                                       const char *);
 
 /* This is the root of the include/exclude tree.  */
 
@@ -105,9 +106,7 @@ static GTY(()) tree class_roots[5];
    appropriate node does not exist.  */
 
 static assume_compiled_node *
-find_assume_compiled_node (node, ident)
-     assume_compiled_node *node;
-     const char *ident;
+find_assume_compiled_node (assume_compiled_node *node, const char *ident)
 {
   while (node)
     {
@@ -146,14 +145,11 @@ find_assume_compiled_node (node, ident)
    if EXCLUDEP is nonzero.  */
 
 void
-add_assume_compiled (ident, excludep)
-     const char *ident;
-     int excludep;
+add_assume_compiled (const char *ident, int excludep)
 {
   int len;
   assume_compiled_node *parent;
-  assume_compiled_node *node = 
-    xmalloc (sizeof (assume_compiled_node));
+  assume_compiled_node *node = xmalloc (sizeof (assume_compiled_node));
 
   node->ident = xstrdup (ident);
   node->excludep = excludep;
@@ -199,8 +195,7 @@ add_assume_compiled (ident, excludep)
    should assume has been compiled to object code.  */
 
 static int
-assume_compiled (ident)
-     const char *ident;
+assume_compiled (const char *ident)
 {
   assume_compiled_node *i;
   int result;
@@ -221,13 +216,12 @@ assume_compiled (ident)
    Also, PREFIX is prepended, and SUFFIX is appended. */
 
 tree
-ident_subst (old_name, old_length, prefix, old_char, new_char, suffix)
-     const char* old_name;
-     int old_length;
-     const char *prefix;
-     int old_char;
-     int new_char;
-     const char *suffix;
+ident_subst (const char* old_name,
+            int old_length,
+            const char *prefix,
+            int old_char,
+            int new_char,
+            const char *suffix)
 {
   int prefix_len = strlen (prefix);
   int suffix_len = strlen (suffix);
@@ -254,12 +248,11 @@ ident_subst (old_name, old_length, prefix, old_char, new_char, suffix)
    Also, PREFIX is prepended, and SUFFIX is appended. */
 
 tree
-identifier_subst (old_id, prefix, old_char, new_char, suffix)
-     const tree old_id;
-     const char *prefix;
-     int old_char;
-     int new_char;
-     const char *suffix;
+identifier_subst (const tree old_id,
+                 const char *prefix,
+                 int old_char,
+                 int new_char,
+                 const char *suffix)
 {
   return ident_subst (IDENTIFIER_POINTER (old_id), IDENTIFIER_LENGTH (old_id),
                      prefix, old_char, new_char, suffix);
@@ -269,9 +262,7 @@ identifier_subst (old_id, prefix, old_char, new_char, suffix)
    prefixed by PREFIX. */
 
 tree
-mangled_classname (prefix, type)
-  const char *prefix;
-  tree type;
+mangled_classname (const char *prefix, tree type)
 {
   tree ident = TYPE_NAME (type);
   if (TREE_CODE (ident) != IDENTIFIER_NODE)
@@ -280,11 +271,11 @@ mangled_classname (prefix, type)
 }
 
 tree
-make_class ()
+make_class (void)
 {
   tree type;
   type = make_node (RECORD_TYPE);
-  TYPE_BINFO (type) = make_tree_vec (6);
+  TYPE_BINFO (type) = make_tree_vec (BINFO_ELTS);
   MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC (type);
 
   return type;
@@ -295,8 +286,7 @@ make_class ()
    return a corresponding IDENTIFIER_NODE, except using '.' as separator. */
 
 tree
-unmangle_classname (name, name_length)
-     const char *name;  int name_length;
+unmangle_classname (const char *name, int name_length)
 {
   tree to_return = ident_subst (name, name_length, "", '/', '.', "");
   /* It's not sufficient to compare to_return and get_identifier
@@ -315,23 +305,20 @@ unmangle_classname (name, name_length)
 }
 
 tree
-push_class (class_type, class_name)
-     tree class_type, class_name;
+push_class (tree class_type, tree class_name)
 {
   tree decl, signature;
-  const char *save_input_filename = input_filename;
-  int save_lineno = lineno;
+  location_t saved_loc = input_location;
   tree source_name = identifier_subst (class_name, "", '.', '/', ".java");
   CLASS_P (class_type) = 1;
   input_filename = IDENTIFIER_POINTER (source_name);
-  lineno = 0;
+  input_line = 0;
   decl = build_decl (TYPE_DECL, class_name, class_type);
 
   /* dbxout needs a DECL_SIZE if in gstabs mode */
   DECL_SIZE (decl) = integer_zero_node;
 
-  input_filename = save_input_filename;
-  lineno = save_lineno;
+  input_location = saved_loc;
   signature = identifier_subst (class_name, "L", '.', '/', ";");
   IDENTIFIER_SIGNATURE_TYPE (signature) = build_pointer_type (class_type);
 
@@ -351,8 +338,7 @@ push_class (class_type, class_name)
    fill in field or methods, or do layout_type. */
 
 tree
-lookup_class (name)
-     tree name;
+lookup_class (tree name)
 {
   tree decl = IDENTIFIER_CLASS_VALUE (name);
   if (decl == NULL_TREE)
@@ -361,11 +347,8 @@ lookup_class (name)
 }
 
 void
-set_super_info (access_flags, this_class, super_class, interfaces_count)
-     int access_flags;
-     tree this_class;
-     tree super_class;
-     int interfaces_count;
+set_super_info (int access_flags, tree this_class,
+               tree super_class, int interfaces_count)
 {
   int total_supers = interfaces_count;
   tree class_decl = TYPE_NAME (this_class);
@@ -375,10 +358,9 @@ set_super_info (access_flags, this_class, super_class, interfaces_count)
   TYPE_BINFO_BASETYPES (this_class) = make_tree_vec (total_supers);
   if (super_class)
     {
-      tree super_binfo = make_tree_vec (6);
+      tree super_binfo = make_tree_vec (BINFO_ELTS);
       BINFO_TYPE (super_binfo) = super_class;
       BINFO_OFFSET (super_binfo) = integer_zero_node;
-      TREE_VIA_PUBLIC (super_binfo) = 1;
       TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (this_class)), 0)
        = super_binfo;
       CLASS_HAS_SUPER (this_class) = 1;
@@ -388,9 +370,7 @@ set_super_info (access_flags, this_class, super_class, interfaces_count)
 }
 
 void
-set_class_decl_access_flags (access_flags, class_decl)
-     int access_flags;
-     tree class_decl;
+set_class_decl_access_flags (int access_flags, tree class_decl)
 {
   if (access_flags & ACC_PUBLIC)    CLASS_PUBLIC (class_decl) = 1;
   if (access_flags & ACC_FINAL)     CLASS_FINAL (class_decl) = 1;
@@ -407,8 +387,7 @@ set_class_decl_access_flags (access_flags, class_decl)
    direct sub-classes of Object are 1, and so on. */
 
 int
-class_depth (clas)
-     tree clas;
+class_depth (tree clas)
 {
   int depth = 0;
   if (! CLASS_LOADED_P (clas))
@@ -426,8 +405,7 @@ class_depth (clas)
 /* Return true iff TYPE2 is an interface that extends interface TYPE1 */
 
 int
-interface_of_p (type1, type2)
-     tree type1, type2;
+interface_of_p (tree type1, tree type2)
 {
   int n, i;
   tree basetype_vec;
@@ -454,8 +432,7 @@ interface_of_p (type1, type2)
 /* Return true iff TYPE1 inherits from TYPE2. */
 
 int
-inherits_from_p (type1, type2)
-     tree type1, type2;
+inherits_from_p (tree type1, tree type2)
 {
   while (type1 != NULL_TREE && TREE_CODE (type1) == RECORD_TYPE)
     {
@@ -469,8 +446,7 @@ inherits_from_p (type1, type2)
 /* Return a 1 iff TYPE1 is an enclosing context for TYPE2 */
 
 int
-enclosing_context_p (type1, type2)
-     tree type1, type2;
+enclosing_context_p (tree type1, tree type2)
 {
   if (!INNER_CLASS_TYPE_P (type2))
     return 0;
@@ -490,8 +466,7 @@ enclosing_context_p (type1, type2)
 /* Return 1 iff there exists a common enclosing context between TYPE1
    and TYPE2.  */
 
-int common_enclosing_context_p (type1, type2)
-     tree type1, type2;
+int common_enclosing_context_p (tree type1, tree type2)
 {
   if (!PURE_INNER_CLASS_TYPE_P (type1) || !PURE_INNER_CLASS_TYPE_P (type2))
     return 0;
@@ -512,16 +487,13 @@ int common_enclosing_context_p (type1, type2)
 }
 
 static void
-add_interface_do (basetype_vec, interface_class, i)
-     tree basetype_vec, interface_class;
-     int i;
+add_interface_do (tree basetype_vec, tree interface_class, int i)
 {
-  tree interface_binfo = make_tree_vec (6);
+  tree interface_binfo = make_tree_vec (BINFO_ELTS);
   BINFO_TYPE (interface_binfo) = interface_class;
   BINFO_OFFSET (interface_binfo) = integer_zero_node;
   BINFO_VPTR_FIELD (interface_binfo) = integer_zero_node;
   TREE_VIA_VIRTUAL (interface_binfo) = 1;
-  TREE_VIA_PUBLIC (interface_binfo) = 1;
   TREE_VEC_ELT (basetype_vec, i) = interface_binfo;
 }
 
@@ -530,8 +502,7 @@ add_interface_do (basetype_vec, interface_class, i)
    if attempt is made to add it twice. */
 
 tree
-maybe_add_interface (this_class, interface_class)
-     tree this_class, interface_class;
+maybe_add_interface (tree this_class, tree interface_class)
 {
   tree basetype_vec = TYPE_BINFO_BASETYPES (this_class);
   int i;
@@ -555,8 +526,7 @@ maybe_add_interface (this_class, interface_class)
 /* Add the INTERFACE_CLASS as one of the interfaces of THIS_CLASS. */
 
 void
-add_interface (this_class, interface_class)
-     tree this_class, interface_class;
+add_interface (tree this_class, tree interface_class)
 {
   tree basetype_vec = TYPE_BINFO_BASETYPES (this_class);
   int i;
@@ -579,9 +549,7 @@ add_interface (this_class, interface_class)
    in the list (*LIST) whose DECL_NAME is NAME. */
 
 static tree *
-find_named_method (list, name)
-     tree *list;
-     tree name;
+find_named_method (tree *list, tree name)
 {
   while (*list && DECL_NAME (*list) != name)
     list = &TREE_CHAIN (*list);
@@ -590,10 +558,7 @@ find_named_method (list, name)
 #endif
 
 static tree
-build_java_method_type (fntype, this_class, access_flags)
-     tree fntype;
-     tree this_class;
-     int access_flags;
+build_java_method_type (tree fntype, tree this_class, int access_flags)
 {
   if (access_flags & ACC_STATIC)
     return fntype;
@@ -601,11 +566,7 @@ build_java_method_type (fntype, this_class, access_flags)
 }
 
 tree
-add_method_1 (this_class, access_flags, name, function_type)
-     tree this_class;
-     int access_flags;
-     tree name;
-     tree function_type;
+add_method_1 (tree this_class, int access_flags, tree name, tree function_type)
 {
   tree method_type, fndecl;
 
@@ -657,7 +618,6 @@ add_method_1 (this_class, access_flags, name, function_type)
     METHOD_FINAL (fndecl) = DECL_INLINE (fndecl) = 1;
   if (access_flags & ACC_SYNCHRONIZED) METHOD_SYNCHRONIZED (fndecl) = 1;
   if (access_flags & ACC_ABSTRACT) METHOD_ABSTRACT (fndecl) = 1;
-  if (access_flags & ACC_TRANSIENT) METHOD_TRANSIENT (fndecl) = 1;
   if (access_flags & ACC_STRICT) METHOD_STRICTFP (fndecl) = 1;
   return fndecl;
 }
@@ -667,11 +627,7 @@ add_method_1 (this_class, access_flags, name, function_type)
    Its signature (mangled type) is METHOD_SIG (an IDENTIFIER_NODE). */
 
 tree
-add_method (this_class, access_flags, name, method_sig)
-     tree this_class;
-     int access_flags;
-     tree name;
-     tree method_sig;
+add_method (tree this_class, int access_flags, tree name, tree method_sig)
 {
   tree function_type, fndecl;
   const unsigned char *sig
@@ -687,11 +643,7 @@ add_method (this_class, access_flags, name, method_sig)
 }
 
 tree
-add_field (class, name, field_type, flags)
-     tree class;
-     tree name;
-     tree field_type;
-     int flags;
+add_field (tree class, tree name, tree field_type, int flags)
 {
   int is_static = (flags & ACC_STATIC) != 0;
   tree field;
@@ -723,8 +675,7 @@ add_field (class, name, field_type, flags)
 /* Associate a constant value CONSTANT with VAR_DECL FIELD. */
 
 void
-set_constant_value (field, constant)
-     tree field, constant;
+set_constant_value (tree field, tree constant)
 {
   if (field == NULL_TREE)
     warning ("misplaced ConstantValue attribute (not in any field)");
@@ -751,9 +702,7 @@ set_constant_value (field, constant)
 
 #if 0
 int
-strLengthUtf8 (str, len)
-     char *str;
-     int len;
+strLengthUtf8 (char *str, int len)
 {
   register unsigned char* ptr = (unsigned char*) str;
   register unsigned char *limit = ptr + len;
@@ -772,9 +721,7 @@ strLengthUtf8 (str, len)
  */
 
 static int32
-hashUtf8String (str, len)
-     const char *str;
-     int len;
+hashUtf8String (const char *str, int len)
 {
   register const unsigned char* ptr = (const unsigned char*) str;
   register const unsigned char *limit = ptr + len;
@@ -789,117 +736,10 @@ hashUtf8String (str, len)
   return hash;
 }
 
-/* Generate a byte array representing the contents of FILENAME.  The
-   array is assigned a unique local symbol.  The array represents a
-   compiled Java resource, which is accessed by the runtime using
-   NAME.  */
-void
-compile_resource_file (name, filename)
-     char *name;
-     const char *filename;
-{
-  struct stat stat_buf;
-  int fd;
-  char *buffer;
-  char buf[60];
-  tree rtype, field = NULL_TREE, data_type, rinit, data, decl;
-  static int Jr_count = 0;
-
-  fd = open (filename, O_RDONLY | O_BINARY);
-  if (fd < 0)
-    {
-      perror ("Failed to read resource file");
-      return;
-    }
-  if (fstat (fd, &stat_buf) != 0
-      || ! S_ISREG (stat_buf.st_mode))
-    {
-      perror ("Could not figure length of resource file");
-      return;
-    }
-  buffer = xmalloc (strlen (name) + stat_buf.st_size);
-  strcpy (buffer, name);
-  read (fd, buffer + strlen (name), stat_buf.st_size);
-  close (fd);
-  data_type = build_prim_array_type (unsigned_byte_type_node,
-                                    strlen (name) + stat_buf.st_size);
-  rtype = make_node (RECORD_TYPE);
-  PUSH_FIELD (rtype, field, "name_length", unsigned_int_type_node);
-  PUSH_FIELD (rtype, field, "resource_length", unsigned_int_type_node);
-  PUSH_FIELD (rtype, field, "data", data_type);
-  FINISH_RECORD (rtype);
-  START_RECORD_CONSTRUCTOR (rinit, rtype);
-  PUSH_FIELD_VALUE (rinit, "name_length", 
-                   build_int_2 (strlen (name), 0));
-  PUSH_FIELD_VALUE (rinit, "resource_length", 
-                   build_int_2 (stat_buf.st_size, 0));
-  data = build_string (strlen(name) + stat_buf.st_size, buffer);
-  TREE_TYPE (data) = data_type;
-  PUSH_FIELD_VALUE (rinit, "data", data);
-  FINISH_RECORD_CONSTRUCTOR (rinit);
-  TREE_CONSTANT (rinit) = 1;
-
-  /* Generate a unique-enough identifier.  */
-  sprintf(buf, "_Jr%d", ++Jr_count);
-
-  decl = build_decl (VAR_DECL, get_identifier (buf), rtype);
-  TREE_STATIC (decl) = 1;
-  DECL_ARTIFICIAL (decl) = 1;
-  DECL_IGNORED_P (decl) = 1;
-  TREE_READONLY (decl) = 1;
-  TREE_THIS_VOLATILE (decl) = 0;
-  DECL_INITIAL (decl) = rinit;
-  layout_decl (decl, 0);
-  pushdecl (decl);
-  rest_of_decl_compilation (decl, (char*) 0, global_bindings_p (), 0);
-  make_decl_rtl (decl, (char*) 0);
-  assemble_variable (decl, 1, 0, 0);
-
-  {
-    tree init_name = get_file_function_name ('I');
-    tree init_type = build_function_type (void_type_node, end_params_node);
-    tree init_decl;
-    
-    init_decl = build_decl (FUNCTION_DECL, init_name, init_type);
-    SET_DECL_ASSEMBLER_NAME (init_decl, init_name);
-    TREE_STATIC (init_decl) = 1;
-    current_function_decl = init_decl;
-    DECL_RESULT (init_decl) = build_decl (RESULT_DECL, 
-                                         NULL_TREE, void_type_node);
-
-    /* It can be a static function as long as collect2 does not have
-       to scan the object file to find its ctor/dtor routine.  */
-    TREE_PUBLIC (init_decl) = ! targetm.have_ctors_dtors;
-
-    pushlevel (0);
-    make_decl_rtl (init_decl, NULL);
-    init_function_start (init_decl, input_filename, 0);
-    expand_function_start (init_decl, 0);
-    
-    emit_library_call (registerResource_libfunc, 0, VOIDmode, 1,
-                      gen_rtx (SYMBOL_REF, Pmode, buf), 
-                      Pmode);
-    
-    expand_function_end (input_filename, 0, 0);
-    poplevel (1, 0, 1);
-    { 
-      /* Force generation, even with -O3 or deeper. Gross hack. FIXME */
-      int saved_flag = flag_inline_functions;
-      flag_inline_functions = 0;       
-      rest_of_compilation (init_decl);
-      flag_inline_functions = saved_flag;
-    }
-    current_function_decl = NULL_TREE;
-    (* targetm.asm_out.constructor) (XEXP (DECL_RTL (init_decl), 0),
-                                    DEFAULT_INIT_PRIORITY);
-  }     
-}
-
-tree utf8_decl_list = NULL_TREE;
+static GTY(()) tree utf8_decl_list = NULL_TREE;
 
 tree
-build_utf8_ref (name)
-     tree name;
+build_utf8_ref (tree name)
 {
   const char * name_ptr = IDENTIFIER_POINTER(name);
   int name_len = IDENTIFIER_LENGTH(name);
@@ -939,23 +779,24 @@ build_utf8_ref (name)
   TREE_READONLY (decl) = 1;
   TREE_THIS_VOLATILE (decl) = 0;
   DECL_INITIAL (decl) = cinit;
-#ifdef HAVE_GAS_SHF_MERGE
-  {
-    int decl_size;
-    /* Ensure decl_size is a multiple of utf8const_type's alignment. */
-    decl_size = (name_len + 5 + TYPE_ALIGN_UNIT (utf8const_type) - 1)
-                & ~(TYPE_ALIGN_UNIT (utf8const_type) - 1);
-    if (flag_merge_constants && decl_size < 256)
-      {
-        char buf[32];
-        int flags = (SECTION_OVERRIDE
-                  | SECTION_MERGE | (SECTION_ENTSIZE & decl_size));
-        sprintf (buf, ".rodata.jutf8.%d", decl_size);
-        named_section_flags (buf, flags);
-        DECL_SECTION_NAME (decl) = build_string (strlen (buf), buf);
-      }
-  }
-#endif
+
+  if (HAVE_GAS_SHF_MERGE)
+    {
+      int decl_size;
+      /* Ensure decl_size is a multiple of utf8const_type's alignment. */
+      decl_size = (name_len + 5 + TYPE_ALIGN_UNIT (utf8const_type) - 1)
+       & ~(TYPE_ALIGN_UNIT (utf8const_type) - 1);
+      if (flag_merge_constants && decl_size < 256)
+       {
+         char buf[32];
+         int flags = (SECTION_OVERRIDE
+                      | SECTION_MERGE | (SECTION_ENTSIZE & decl_size));
+         sprintf (buf, ".rodata.jutf8.%d", decl_size);
+         named_section_flags (buf, flags);
+         DECL_SECTION_NAME (decl) = build_string (strlen (buf), buf);
+       }
+    }
+
   TREE_CHAIN (decl) = utf8_decl_list;
   layout_decl (decl, 0);
   pushdecl (decl);
@@ -967,12 +808,25 @@ build_utf8_ref (name)
   return ref;
 }
 
+/* Like build_class_ref, but instead of a direct reference generate a
+   pointer into the constant pool.  */
+
+static tree
+build_indirect_class_ref (tree type)
+{
+  int index;
+  tree cl;
+  index = alloc_class_constant (type);
+  cl = build_ref_from_constant_pool (index); 
+  TREE_TYPE (cl) = promote_type (class_ptr_type);
+  return cl;
+}
+
 /* Build a reference to the class TYPE.
    Also handles primitive types and array types. */
 
 tree
-build_class_ref (type)
-     tree type;
+build_class_ref (tree type)
 {
   int is_compiled = is_compiled_class (type);
   if (is_compiled)
@@ -980,6 +834,12 @@ build_class_ref (type)
       tree ref, decl_name, decl;
       if (TREE_CODE (type) == POINTER_TYPE)
        type = TREE_TYPE (type);
+
+      if  (flag_indirect_dispatch 
+          && type != current_class
+          && TREE_CODE (type) == RECORD_TYPE)
+       return build_indirect_class_ref (type);
+
       if (TREE_CODE (type) == RECORD_TYPE)
        {
          if (TYPE_SIZE (type) == error_mark_node)
@@ -1062,25 +922,28 @@ build_class_ref (type)
       return ref;
     }
   else
-    {
-      int index;
-      tree cl;
-      index = alloc_class_constant (type);
-      cl = build_ref_from_constant_pool (index); 
-      TREE_TYPE (cl) = promote_type (class_ptr_type);
-      return cl;
-    }
+    return build_indirect_class_ref (type);
 }
 
 tree
-build_static_field_ref (fdecl)
-     tree fdecl;
+build_static_field_ref (tree fdecl)
 {
   tree fclass = DECL_CONTEXT (fdecl);
   int is_compiled = is_compiled_class (fclass);
 
-  /* Allow static final fields to fold to a constant.  */
-  if (is_compiled || FIELD_FINAL (fdecl))
+  /* Allow static final fields to fold to a constant.  When using
+     -fno-assume-compiled, gcj will sometimes try to fold a field from
+     an uncompiled class.  This is required when the field in question
+     meets the appropriate criteria for a compile-time constant.
+     However, currently sometimes gcj is too eager and will end up
+     returning the field itself, leading to an incorrect external
+     reference being generated.  */
+  if ((is_compiled 
+       && (! flag_indirect_dispatch || current_class == fclass))
+      || (FIELD_FINAL (fdecl) && DECL_INITIAL (fdecl) != NULL_TREE
+         && (JSTRING_TYPE_P (TREE_TYPE (fdecl))
+             || JNUMERIC_TYPE_P (TREE_TYPE (fdecl)))
+         && TREE_CONSTANT (DECL_INITIAL (fdecl))))
     {
       if (!DECL_RTL_SET_P (fdecl))
        {
@@ -1090,7 +953,18 @@ build_static_field_ref (fdecl)
        }
       return fdecl;
     }
-  else
+
+  if (flag_indirect_dispatch)
+    {
+      tree table_index 
+       = build_int_2 (get_symbol_table_index (fdecl, &atable_methods), 0);
+      tree field_address
+       = build (ARRAY_REF, build_pointer_type (TREE_TYPE (fdecl)), 
+                atable_decl, table_index);
+      return fold (build1 (INDIRECT_REF, TREE_TYPE (fdecl), 
+                          field_address));
+    }
+  else  
     {
       /* Compile as:
        * *(FTYPE*)build_class_ref(FCLASS)->fields[INDEX].info.addr */
@@ -1124,8 +998,7 @@ build_static_field_ref (fdecl)
 }
 
 int
-get_access_flags_from_decl (decl)
-     tree decl;
+get_access_flags_from_decl (tree decl)
 {
   int access_flags = 0;
   if (TREE_CODE (decl) == FIELD_DECL || TREE_CODE (decl) == VAR_DECL)
@@ -1186,23 +1059,22 @@ get_access_flags_from_decl (decl)
        access_flags |= ACC_NATIVE;
       if (METHOD_ABSTRACT (decl))
        access_flags |= ACC_ABSTRACT;
-      if (METHOD_TRANSIENT (decl))
-       access_flags |= ACC_TRANSIENT;
       if (METHOD_STRICTFP (decl))
        access_flags |= ACC_STRICT;
+      if (METHOD_INVISIBLE (decl))
+       access_flags |= ACC_INVISIBLE;
       return access_flags;
     }
   abort ();
 }
 
 static tree
-make_field_value (fdecl)
-  tree fdecl;
+make_field_value (tree fdecl)
 {
   tree finit;
   int flags;
   tree type = TREE_TYPE (fdecl);
-  int resolved = is_compiled_class (type);
+  int resolved = is_compiled_class (type) && ! flag_indirect_dispatch;
 
   START_RECORD_CONSTRUCTOR (finit, field_type_node);
   PUSH_FIELD_VALUE (finit, "name", build_utf8_ref (DECL_NAME (fdecl)));
@@ -1227,7 +1099,7 @@ make_field_value (fdecl)
 
   PUSH_FIELD_VALUE
     (finit, "info",
-     build (CONSTRUCTOR, field_info_union_node, NULL_TREE,
+     build_constructor (field_info_union_node,
            build_tree_list
            ((FIELD_STATIC (fdecl)
              ? TREE_CHAIN (TYPE_FIELDS (field_info_union_node))
@@ -1241,8 +1113,7 @@ make_field_value (fdecl)
 }
 
 static tree
-make_method_value (mdecl)
-     tree mdecl;
+make_method_value (tree mdecl)
 {
   static int method_name_count = 0;
   tree minit;
@@ -1297,7 +1168,7 @@ make_method_value (mdecl)
            table = tree_cons (NULL_TREE, utf8, table);
          }
        type = build_prim_array_type (ptr_type_node, length);
-       table = build (CONSTRUCTOR, type, NULL_TREE, table);
+       table = build_constructor (type, table);
        /* Compute something unique enough.  */
        sprintf (buf, "_methods%d", method_name_count++);
        array = build_decl (VAR_DECL, get_identifier (buf), type);
@@ -1318,11 +1189,11 @@ make_method_value (mdecl)
 }
 
 static tree
-get_dispatch_vector (type)
-     tree type;
+get_dispatch_vector (tree type)
 {
   tree vtable = TYPE_VTABLE (type);
-  if (vtable == NULL)
+
+  if (vtable == NULL_TREE)
     {
       HOST_WIDE_INT i;
       tree method;
@@ -1350,8 +1221,7 @@ get_dispatch_vector (type)
 }
 
 static tree
-get_dispatch_table (type, this_class_addr)
-     tree type, this_class_addr;
+get_dispatch_table (tree type, tree this_class_addr)
 {
   int abstract_p = CLASS_ABSTRACT (TYPE_NAME (type));
   tree vtable = get_dispatch_vector (type);
@@ -1367,8 +1237,7 @@ get_dispatch_table (type, this_class_addr)
       if (METHOD_ABSTRACT (method))
        {
          if (! abstract_p)
-           warning_with_decl (method,
-                              "abstract method in non-abstract class");
+           warning ("%Jabstract method in non-abstract class", method);
 
          if (TARGET_VTABLE_USES_DESCRIPTORS)
            for (j = 0; j < TARGET_VTABLE_USES_DESCRIPTORS; ++j)
@@ -1420,14 +1289,24 @@ get_dispatch_table (type, this_class_addr)
   if (TARGET_VTABLE_USES_DESCRIPTORS)
     arraysize *= TARGET_VTABLE_USES_DESCRIPTORS;
   arraysize += 2;
-  return build (CONSTRUCTOR,
-               build_prim_array_type (nativecode_ptr_type_node, arraysize),
-               NULL_TREE, list);
+  return build_constructor (build_prim_array_type (nativecode_ptr_type_node,
+                                                  arraysize), list);
+}
+
+static int
+supers_all_compiled (tree type)
+{
+  while (type != NULL_TREE)
+    {
+      if (!assume_compiled (IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)))))
+       return 0;
+      type = CLASSTYPE_SUPER (type);
+    }
+  return 1;
 }
 
 void
-make_class_data (type)
-     tree type;
+make_class_data (tree type)
 {
   tree decl, cons, temp;
   tree field, fields_decl;
@@ -1494,8 +1373,8 @@ make_class_data (type)
       field_array_type = build_prim_array_type (field_type_node, field_count);
       fields_decl = build_decl (VAR_DECL, mangled_classname ("_FL_", type),
                                field_array_type);
-      DECL_INITIAL (fields_decl) = build (CONSTRUCTOR, field_array_type,
-                                         NULL_TREE, static_fields);
+      DECL_INITIAL (fields_decl) = build_constructor (field_array_type,
+                                                     static_fields);
       TREE_STATIC (fields_decl) = 1;
       DECL_ARTIFICIAL (fields_decl) = 1;
       DECL_IGNORED_P (fields_decl) = 1;
@@ -1520,15 +1399,15 @@ make_class_data (type)
   method_array_type = build_prim_array_type (method_type_node, method_count);
   methods_decl = build_decl (VAR_DECL, mangled_classname ("_MT_", type),
                             method_array_type);
-  DECL_INITIAL (methods_decl) = build (CONSTRUCTOR, method_array_type,
-                                      NULL_TREE, nreverse (methods));
+  DECL_INITIAL (methods_decl) = build_constructor (method_array_type,
+                                                  nreverse (methods));
   TREE_STATIC (methods_decl) = 1;
   DECL_ARTIFICIAL (methods_decl) = 1;
   DECL_IGNORED_P (methods_decl) = 1;
   rest_of_decl_compilation (methods_decl, (char*) 0, 1, 0);
 
-  if (assume_compiled (IDENTIFIER_POINTER (DECL_NAME (type_decl)))
-      && ! CLASS_INTERFACE (type_decl) && !flag_indirect_dispatch)
+  if (supers_all_compiled (type) && ! CLASS_INTERFACE (type_decl)
+      && !flag_indirect_dispatch)
     {
       tree dtable = get_dispatch_table (type, this_class_addr);
       dtable_decl = build_dtable_decl (type);
@@ -1556,7 +1435,9 @@ make_class_data (type)
   super = CLASSTYPE_SUPER (type);
   if (super == NULL_TREE)
     super = null_pointer_node;
-  else if (assume_compiled (IDENTIFIER_POINTER (DECL_NAME (type_decl))))
+  else if (! flag_indirect_dispatch
+          && assume_compiled (IDENTIFIER_POINTER (DECL_NAME (type_decl)))
+          && assume_compiled (IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (super)))))
     super = build_class_ref (super);
   else
     {
@@ -1592,8 +1473,7 @@ make_class_data (type)
            }
          init = tree_cons (NULL_TREE, index, init); 
        }
-      DECL_INITIAL (idecl) = build (CONSTRUCTOR, interface_array_type,
-                                   NULL_TREE, init);
+      DECL_INITIAL (idecl) = build_constructor (interface_array_type, init);
       TREE_STATIC (idecl) = 1;
       DECL_ARTIFICIAL (idecl) = 1;
       DECL_IGNORED_P (idecl) = 1;
@@ -1626,7 +1506,7 @@ make_class_data (type)
   PUSH_FIELD_VALUE (cons, "method_count",  build_int_2 (method_count, 0));
 
   if (flag_indirect_dispatch)
-    PUSH_FIELD_VALUE (cons, "vtable_method_count", integer_minus_one_node)
+    PUSH_FIELD_VALUE (cons, "vtable_method_count", integer_minus_one_node);
   else
     PUSH_FIELD_VALUE (cons, "vtable_method_count", TYPE_NVIRTUALS (type));
     
@@ -1639,14 +1519,13 @@ make_class_data (type)
                    build_int_2 (static_field_count, 0));
 
   if (flag_indirect_dispatch)
-    PUSH_FIELD_VALUE (cons, "vtable", null_pointer_node)
+    PUSH_FIELD_VALUE (cons, "vtable", null_pointer_node);
   else
     PUSH_FIELD_VALUE (cons, "vtable",
                      dtable_decl == NULL_TREE ? null_pointer_node
                      : build (PLUS_EXPR, dtable_ptr_type,
                               build1 (ADDR_EXPR, dtable_ptr_type, dtable_decl),
                               dtable_start_offset));
-  
   if (otable_methods == NULL_TREE)
     {
       PUSH_FIELD_VALUE (cons, "otable", null_pointer_node);
@@ -1657,9 +1536,27 @@ make_class_data (type)
       PUSH_FIELD_VALUE (cons, "otable",
                        build1 (ADDR_EXPR, otable_ptr_type, otable_decl));
       PUSH_FIELD_VALUE (cons, "otable_syms",
-                       build1 (ADDR_EXPR, method_symbols_array_ptr_type,
+                       build1 (ADDR_EXPR, symbols_array_ptr_type,
                                otable_syms_decl));
+      TREE_CONSTANT (otable_decl) = 1;
+    }
+  if (atable_methods == NULL_TREE)
+    {
+      PUSH_FIELD_VALUE (cons, "atable", null_pointer_node);
+      PUSH_FIELD_VALUE (cons, "atable_syms", null_pointer_node);
+    }
+  else
+    {
+      PUSH_FIELD_VALUE (cons, "atable",
+                       build1 (ADDR_EXPR, atable_ptr_type, atable_decl));
+      PUSH_FIELD_VALUE (cons, "atable_syms",
+                       build1 (ADDR_EXPR, symbols_array_ptr_type,
+                               atable_syms_decl));
+      TREE_CONSTANT (atable_decl) = 1;
     }
+  PUSH_FIELD_VALUE (cons, "catch_classes",
+                   build1 (ADDR_EXPR, ptr_type_node, ctable_decl)); 
   PUSH_FIELD_VALUE (cons, "interfaces", interfaces);
   PUSH_FIELD_VALUE (cons, "loader", null_pointer_node);
   PUSH_FIELD_VALUE (cons, "interface_count", build_int_2 (interface_len, 0));
@@ -1671,6 +1568,7 @@ make_class_data (type)
   PUSH_FIELD_VALUE (cons, "idt", null_pointer_node);
   PUSH_FIELD_VALUE (cons, "arrayclass", null_pointer_node);
   PUSH_FIELD_VALUE (cons, "protectionDomain", null_pointer_node);
+  PUSH_FIELD_VALUE (cons, "signers", null_pointer_node);
   PUSH_FIELD_VALUE (cons, "chain", null_pointer_node);
 
   FINISH_RECORD_CONSTRUCTOR (cons);
@@ -1685,7 +1583,7 @@ make_class_data (type)
 }
 
 void
-finish_class ()
+finish_class (void)
 {
   tree method;
   tree type_methods = TYPE_METHODS (current_class);
@@ -1729,8 +1627,7 @@ finish_class ()
    return 0 if we cannot assume that CLASS is compiled.
    Returns 1 for primitive and 0 for array types.  */
 int
-is_compiled_class (class)
-     tree class;
+is_compiled_class (tree class)
 {
   int seen_in_zip;
   if (TREE_CODE (class) == POINTER_TYPE)
@@ -1776,8 +1673,7 @@ is_compiled_class (class)
 /* Build a VAR_DECL for the dispatch table (vtable) for class TYPE. */
 
 tree
-build_dtable_decl (type)
-     tree type;
+build_dtable_decl (tree type)
 {
   tree dtype;
 
@@ -1835,8 +1731,7 @@ build_dtable_decl (type)
    fields inherited from SUPER_CLASS. */
 
 void
-push_super_field (this_class, super_class)
-     tree this_class, super_class;
+push_super_field (tree this_class, tree super_class)
 {
   tree base_decl;
   /* Don't insert the field if we're just re-laying the class out. */ 
@@ -1853,9 +1748,7 @@ push_super_field (this_class, super_class)
 /* Handle the different manners we may have to lay out a super class.  */
 
 static tree
-maybe_layout_super_class (super_class, this_class)
-     tree super_class;
-     tree this_class;
+maybe_layout_super_class (tree super_class, tree this_class)
 {
   if (TREE_CODE (super_class) == RECORD_TYPE)
     {
@@ -1872,8 +1765,19 @@ maybe_layout_super_class (super_class, this_class)
        super_class = TREE_TYPE (super_class);
       else
        {
+         /* do_resolve_class expects an EXPR_WITH_FILE_LOCATION, so
+            we give it one.  */
+         tree this_wrap = NULL_TREE;
+
+         if (this_class)
+           {
+             tree this_decl = TYPE_NAME (this_class);
+             this_wrap = build_expr_wfl (this_class,
+                                         DECL_SOURCE_FILE (this_decl),
+                                         DECL_SOURCE_LINE (this_decl), 0);
+           }
          super_class = do_resolve_class (NULL_TREE, /* FIXME? */
-                                         super_class, NULL_TREE, this_class);
+                                         super_class, NULL_TREE, this_wrap);
          if (!super_class)
            return NULL_TREE;   /* FIXME, NULL_TREE not checked by caller. */
          super_class = TREE_TYPE (super_class);
@@ -1886,19 +1790,18 @@ maybe_layout_super_class (super_class, this_class)
 }
 
 void
-layout_class (this_class)
-     tree this_class;
+layout_class (tree this_class)
 {
   tree super_class = CLASSTYPE_SUPER (this_class);
   tree field;
-  
+
   class_list = tree_cons (this_class, NULL_TREE, class_list);
   if (CLASS_BEING_LAIDOUT (this_class))
     {
       char buffer [1024];
       char *report;
       tree current;
-      
+
       sprintf (buffer, " with `%s'",
               IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (this_class))));
       obstack_grow (&temporary_obstack, buffer, strlen (buffer));
@@ -1952,8 +1855,9 @@ layout_class (this_class)
 
   layout_type (this_class);
 
-  /* Also recursively load/layout any superinterfaces, but only if class was
-  loaded from bytecode. The source parser will take care of this itself. */
+  /* Also recursively load/layout any superinterfaces, but only if
+     class was loaded from bytecode.  The source parser will take care
+     of this itself.  */
   if (!CLASS_FROM_SOURCE_P (this_class))
     {
       tree basetype_vec = TYPE_BINFO_BASETYPES (this_class);
@@ -1981,17 +1885,65 @@ layout_class (this_class)
        }
     }
 
-  /* Convert the size back to an SI integer value */
-  TYPE_SIZE_UNIT (this_class) = 
+  /* Convert the size back to an SI integer value */
+  TYPE_SIZE_UNIT (this_class) =
     fold (convert (int_type_node, TYPE_SIZE_UNIT (this_class)));
 
   CLASS_BEING_LAIDOUT (this_class) = 0;
   class_list = TREE_CHAIN (class_list);
 }
 
+static void
+add_miranda_methods (tree base_class, tree search_class)
+{
+  tree basetype_vec = TYPE_BINFO_BASETYPES (search_class);
+  int i, n = TREE_VEC_LENGTH (basetype_vec);
+  for (i = 1; i < n; ++i)
+    {
+      tree method_decl;
+      tree elt = TREE_VEC_ELT (basetype_vec, i);
+      if (elt == NULL_TREE)
+       break;
+      elt = BINFO_TYPE (elt);
+
+      /* Ensure that interface methods are seen in declared order.  */
+      layout_class_methods (elt);
+
+      /* All base classes will have been laid out at this point, so the order 
+         will be correct.  This code must match similar layout code in the 
+         runtime.  */
+      for (method_decl = TYPE_METHODS (elt);
+          method_decl; method_decl = TREE_CHAIN (method_decl))
+       {
+         tree sig, override;
+
+         /* An interface can have <clinit>.  */
+         if (ID_CLINIT_P (DECL_NAME (method_decl)))
+           continue;
+
+         sig = build_java_argument_signature (TREE_TYPE (method_decl));
+         override = lookup_argument_method (base_class,
+                                            DECL_NAME (method_decl), sig);
+         if (override == NULL_TREE)
+           {
+             /* Found a Miranda method.  Add it.  */
+             tree new_method;
+             sig = build_java_signature (TREE_TYPE (method_decl));
+             new_method
+               = add_method (base_class,
+                             get_access_flags_from_decl (method_decl),
+                             DECL_NAME (method_decl), sig);
+             METHOD_INVISIBLE (new_method) = 1;
+           }
+       }
+
+      /* Try superinterfaces.  */
+      add_miranda_methods (base_class, elt);
+    }
+}
+
 void
-layout_class_methods (this_class)
-     tree this_class;
+layout_class_methods (tree this_class)
 {
   tree method_decl, dtable_count;
   tree super_class;
@@ -2011,29 +1963,38 @@ layout_class_methods (this_class)
   else
     dtable_count = integer_zero_node;
 
+  if (CLASS_ABSTRACT (TYPE_NAME (this_class)))
+    {
+      /* An abstract class can have methods which are declared only in
+        an implemented interface.  These are called "Miranda
+        methods".  We make a dummy method entry for such methods
+        here.  */
+      add_miranda_methods (this_class, this_class);
+    }
+
   TYPE_METHODS (this_class) = nreverse (TYPE_METHODS (this_class));
 
   for (method_decl = TYPE_METHODS (this_class);
        method_decl; method_decl = TREE_CHAIN (method_decl))
-    dtable_count = layout_class_method (this_class, super_class, 
+    dtable_count = layout_class_method (this_class, super_class,
                                        method_decl, dtable_count);
 
   TYPE_NVIRTUALS (this_class) = dtable_count;
 }
 
-/* Return 0 if NAME is equal to STR, -1 if STR is "less" than NAME,
-   and 1 if STR is "greater" than NAME.  */
-
 /* Lay METHOD_DECL out, returning a possibly new value of
    DTABLE_COUNT. Also mangle the method's name. */
 
 tree
-layout_class_method (this_class, super_class, method_decl, dtable_count)
-     tree this_class, super_class, method_decl, dtable_count;
+layout_class_method (tree this_class, tree super_class,
+                    tree method_decl, tree dtable_count)
 {
   tree method_name = DECL_NAME (method_decl);
 
   TREE_PUBLIC (method_decl) = 1;
+  /* Considered external until we know what classes are being
+     compiled into this object file.  */
+  DECL_EXTERNAL (method_decl) = 1;
 
   /* This is a good occasion to mangle the method's name */
   SET_DECL_ASSEMBLER_NAME (method_decl,
@@ -2060,7 +2021,7 @@ layout_class_method (this_class, super_class, method_decl, dtable_count)
     }
   else if (! METHOD_STATIC (method_decl) && !DECL_ARTIFICIAL (method_decl))
     {
-      tree method_sig = 
+      tree method_sig =
        build_java_argument_signature (TREE_TYPE (method_decl));
       tree super_method = lookup_argument_method (super_class, method_name,
                                                  method_sig);
@@ -2069,8 +2030,8 @@ layout_class_method (this_class, super_class, method_decl, dtable_count)
          DECL_VINDEX (method_decl) = DECL_VINDEX (super_method);
          if (DECL_VINDEX (method_decl) == NULL_TREE 
              && !CLASS_FROM_SOURCE_P (this_class))
-           error_with_decl (method_decl,
-                            "non-static method '%s' overrides static method");
+           error ("%Jnon-static method '%D' overrides static method",
+                   method_decl, method_decl);
        }
       else if (! METHOD_FINAL (method_decl)
               && ! METHOD_PRIVATE (method_decl)
@@ -2087,7 +2048,7 @@ layout_class_method (this_class, super_class, method_decl, dtable_count)
 }
 
 void
-register_class ()
+register_class (void)
 {
   /* END does not need to be registered with the garbage collector
      because it always points into the list given by REGISTERED_CLASS,
@@ -2109,12 +2070,12 @@ register_class ()
 
    The preferred mechanism is through the .jcr section, which contain
    a list of pointers to classes which get registered during
-   constructor invoction time.  The fallback mechanism is to generate
+   constructor invocation time.  The fallback mechanism is to generate
    a `constructor' function which calls _Jv_RegisterClass for each
    class in this file.  */
 
 void
-emit_register_classes ()
+emit_register_classes (void)
 {
   /* ??? This isn't quite the correct test.  We also have to know
      that the target is using gcc's crtbegin/crtend objects rather
@@ -2134,14 +2095,16 @@ emit_register_classes ()
     }
   else
     {
-      extern tree get_file_function_name PARAMS ((int));
+      extern tree get_file_function_name (int);
       tree init_name = get_file_function_name ('I');
       tree init_type = build_function_type (void_type_node, end_params_node);
       tree init_decl;
       tree t;
+      location_t saved_loc = input_location;
       
       init_decl = build_decl (FUNCTION_DECL, init_name, init_type);
       SET_DECL_ASSEMBLER_NAME (init_decl, init_name);
+      DECL_SOURCE_LINE (init_decl) = 0;
       TREE_STATIC (init_decl) = 1;
       current_function_decl = init_decl;
       DECL_RESULT (init_decl) = build_decl (RESULT_DECL, NULL_TREE,
@@ -2156,7 +2119,7 @@ emit_register_classes ()
 
       pushlevel (0);
       make_decl_rtl (init_decl, NULL);
-      init_function_start (init_decl, input_filename, 0);
+      init_function_start (init_decl);
       expand_function_start (init_decl, 0);
 
       /* Do not allow the function to be deferred.  */
@@ -2166,8 +2129,8 @@ emit_register_classes ()
       for ( t = registered_class; t; t = TREE_CHAIN (t))
        emit_library_call (registerClass_libfunc, 0, VOIDmode, 1,
                           XEXP (DECL_RTL (t), 0), Pmode);
-      
-      expand_function_end (input_filename, 0, 0);
+      input_location = DECL_SOURCE_LOCATION (init_decl);
+      expand_function_end ();
       poplevel (1, 0, 1);
       rest_of_compilation (init_decl);
       current_function_decl = NULL_TREE;
@@ -2175,61 +2138,63 @@ emit_register_classes ()
       if (targetm.have_ctors_dtors)
        (* targetm.asm_out.constructor) (XEXP (DECL_RTL (init_decl), 0),
                                         DEFAULT_INIT_PRIORITY);
+      input_location = saved_loc;
     }
 }
 
-/* Make a method_symbol_type (_Jv_MethodSymbol) node for METHOD. */
+/* Make a symbol_type (_Jv_MethodSymbol) node for DECL. */
 
-tree
-build_method_symbols_entry (tree method)
+static tree
+build_symbol_entry (tree decl)
 {
-  tree clname, name, signature, method_symbol;
+  tree clname, name, signature, sym;
   
-  clname = build_utf8_ref (DECL_NAME (TYPE_NAME (DECL_CONTEXT (method))));
-  name = build_utf8_ref (DECL_NAME (method));
-  signature = build_java_signature (TREE_TYPE (method));
+  clname = build_utf8_ref (DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl))));
+  name = build_utf8_ref (DECL_NAME (decl));
+  signature = build_java_signature (TREE_TYPE (decl));
   signature = build_utf8_ref (unmangle_classname 
                              (IDENTIFIER_POINTER (signature),
                               IDENTIFIER_LENGTH (signature)));
 
-  START_RECORD_CONSTRUCTOR (method_symbol, method_symbol_type);
-  PUSH_FIELD_VALUE (method_symbol, "clname", clname);
-  PUSH_FIELD_VALUE (method_symbol, "name", name);
-  PUSH_FIELD_VALUE (method_symbol, "signature", signature);
-  FINISH_RECORD_CONSTRUCTOR (method_symbol);
-  TREE_CONSTANT (method_symbol) = 1;
+  START_RECORD_CONSTRUCTOR (sym, symbol_type);
+  PUSH_FIELD_VALUE (sym, "clname", clname);
+  PUSH_FIELD_VALUE (sym, "name", name);
+  PUSH_FIELD_VALUE (sym, "signature", signature);
+  FINISH_RECORD_CONSTRUCTOR (sym);
+  TREE_CONSTANT (sym) = 1;
 
-  return method_symbol;
+  return sym;
 } 
 
-/* Emit the offset symbols table for indirect virtual dispatch. */
+/* Emit a symbol table: used by -findirect-dispatch.  */
 
-void
-emit_offset_symbol_table ()
+tree
+emit_symbol_table (tree name, tree the_table, tree decl_list, tree the_syms_decl, 
+                         tree the_array_element_type)
 {
   tree method_list, method, table, list, null_symbol;
-  tree otable_bound, otable_array_type;
+  tree table_size, the_array_type;
   int index;
   
-  /* Only emit an offset table if this translation unit actually made virtual 
-     calls. */
-  if (otable_methods == NULL_TREE)
-    return;
+  /* Only emit a table if this translation unit actually made any
+     references via it. */
+  if (decl_list == NULL_TREE)
+    return the_table;
 
   /* Build a list of _Jv_MethodSymbols for each entry in otable_methods. */
   index = 0;
-  method_list = otable_methods;
+  method_list = decl_list;
   list = NULL_TREE;  
   while (method_list != NULL_TREE)
     {
       method = TREE_VALUE (method_list);
-      list = tree_cons (NULL_TREE, build_method_symbols_entry (method), list);
+      list = tree_cons (NULL_TREE, build_symbol_entry (method), list);
       method_list = TREE_CHAIN (method_list);
       index++;
     }
 
   /* Terminate the list with a "null" entry. */
-  START_RECORD_CONSTRUCTOR (null_symbol, method_symbol_type);
+  START_RECORD_CONSTRUCTOR (null_symbol, symbol_type);
   PUSH_FIELD_VALUE (null_symbol, "clname", null_pointer_node);
   PUSH_FIELD_VALUE (null_symbol, "name", null_pointer_node);
   PUSH_FIELD_VALUE (null_symbol, "signature", null_pointer_node);
@@ -2239,56 +2204,94 @@ emit_offset_symbol_table ()
 
   /* Put the list in the right order and make it a constructor. */
   list = nreverse (list);
-  table = build (CONSTRUCTOR, method_symbols_array_type, NULL_TREE, list);  
+  table = build_constructor (symbols_array_type, list);  
 
   /* Make it the initial value for otable_syms and emit the decl. */
-  DECL_INITIAL (otable_syms_decl) = table;
-  DECL_ARTIFICIAL (otable_syms_decl) = 1;
-  DECL_IGNORED_P (otable_syms_decl) = 1;
-  rest_of_decl_compilation (otable_syms_decl, NULL, 1, 0);
+  DECL_INITIAL (the_syms_decl) = table;
+  DECL_ARTIFICIAL (the_syms_decl) = 1;
+  DECL_IGNORED_P (the_syms_decl) = 1;
+  rest_of_decl_compilation (the_syms_decl, NULL, 1, 0);
   
-  /* Now that its size is known, redefine otable as an uninitialized static 
-     array of INDEX + 1 integers. The extra entry is used by the runtime 
-     to track whether the otable has been initialized. */
-  otable_bound = build_index_type (build_int_2 (index, 0));
-  otable_array_type = build_array_type (integer_type_node, otable_bound);
-  otable_decl = build_decl (VAR_DECL, get_identifier ("otable"), 
-                           otable_array_type);
-  TREE_STATIC (otable_decl) = 1;
-  TREE_READONLY (otable_decl) = 1;  
-  rest_of_decl_compilation (otable_decl, NULL, 1, 0);
+  /* Now that its size is known, redefine the table as an
+     uninitialized static array of INDEX + 1 elements. The extra entry
+     is used by the runtime to track whether the table has been
+     initialized. */
+  table_size = build_index_type (build_int_2 (index, 0));
+  the_array_type = build_array_type (the_array_element_type, table_size);
+  the_table = build_decl (VAR_DECL, name, the_array_type);
+  TREE_STATIC (the_table) = 1;
+  TREE_READONLY (the_table) = 1;  
+  rest_of_decl_compilation (the_table, NULL, 1, 0);
+
+  return the_table;
+}
+
+/* make an entry for the catch_classes list.  */
+tree
+make_catch_class_record (tree catch_class, tree classname)
+{
+  tree entry;
+  tree type = TREE_TYPE (TREE_TYPE (ctable_decl));
+  START_RECORD_CONSTRUCTOR (entry, type);
+  PUSH_FIELD_VALUE (entry, "address", catch_class);
+  PUSH_FIELD_VALUE (entry, "classname", classname);
+  FINISH_RECORD_CONSTRUCTOR (entry);
+  return entry;
+}
+
+
+/* Generate the list of Throwable classes that are caught by exception
+   handlers in this compilation.  */
+void 
+emit_catch_table (void)
+{
+  tree table, table_size, array_type;
+  catch_classes 
+    = tree_cons (NULL, 
+                make_catch_class_record (null_pointer_node, null_pointer_node),
+                catch_classes);
+  catch_classes = nreverse (catch_classes);
+  catch_classes 
+    = tree_cons (NULL, 
+                make_catch_class_record (null_pointer_node, null_pointer_node),
+                catch_classes);
+  table_size = build_index_type (build_int_2 (list_length (catch_classes), 0));
+  array_type 
+    = build_array_type (TREE_TYPE (TREE_TYPE (ctable_decl)), table_size);
+  table = build_decl (VAR_DECL, DECL_NAME (ctable_decl), array_type);
+  DECL_INITIAL (table) = build_constructor (array_type, catch_classes);
+  TREE_STATIC (table) = 1;
+  TREE_READONLY (table) = 1;  
+  rest_of_decl_compilation (table, NULL, 1, 0);
+  ctable_decl = table;
 }
 
 void
-init_class_processing ()
+init_class_processing (void)
 {
   registerClass_libfunc = gen_rtx_SYMBOL_REF (Pmode, "_Jv_RegisterClass");
-  registerResource_libfunc = 
-    gen_rtx_SYMBOL_REF (Pmode, "_Jv_RegisterResource");
   fields_ident = get_identifier ("fields");
   info_ident = get_identifier ("info");
   gcc_obstack_init (&temporary_obstack);
 }
 \f
-static hashval_t java_treetreehash_hash PARAMS ((const void *));
-static int java_treetreehash_compare PARAMS ((const void *, const void *));
+static hashval_t java_treetreehash_hash (const void *);
+static int java_treetreehash_compare (const void *, const void *);
 
 /* A hash table mapping trees to trees.  Used generally.  */
 
 #define JAVA_TREEHASHHASH_H(t) (htab_hash_pointer (t))
 
 static hashval_t
-java_treetreehash_hash (k_p)
-     const void *k_p;
+java_treetreehash_hash (const void *k_p)
 {
   struct treetreehash_entry *k = (struct treetreehash_entry *) k_p;
   return JAVA_TREEHASHHASH_H (k->key);
 }
 
 static int
-java_treetreehash_compare (k1_p, k2_p)
-     const void * k1_p;
-     const void * k2_p;
+java_treetreehash_compare (const void * k1_p, const void * k2_p)
 {
   struct treetreehash_entry * k1 = (struct treetreehash_entry *) k1_p;
   tree k2 = (tree) k2_p;
@@ -2296,13 +2299,11 @@ java_treetreehash_compare (k1_p, k2_p)
 }
 
 tree 
-java_treetreehash_find (ht, t)
-     htab_t ht;
-     tree t;
+java_treetreehash_find (htab_t ht, tree t)
 {
   struct treetreehash_entry *e;
   hashval_t hv = JAVA_TREEHASHHASH_H (t);
-  e = (struct treetreehash_entry *) htab_find_with_hash (ht, t, hv);
+  e = htab_find_with_hash (ht, t, hv);
   if (e == NULL)
     return NULL;
   else
@@ -2310,11 +2311,9 @@ java_treetreehash_find (ht, t)
 }
 
 tree *
-java_treetreehash_new (ht, t)
-     htab_t ht;
-     tree t;
+java_treetreehash_new (htab_t ht, tree t)
 {
-  PTR *e;
+  void **e;
   struct treetreehash_entry *tthe;
   hashval_t hv = JAVA_TREEHASHHASH_H (t);
 
@@ -2323,7 +2322,7 @@ java_treetreehash_new (ht, t)
     {
       tthe = (*ht->alloc_f) (1, sizeof (*tthe));
       tthe->key = t;
-      *e = (PTR) tthe;
+      *e = tthe;
     }
   else
     tthe = (struct treetreehash_entry *) *e;
@@ -2331,9 +2330,7 @@ java_treetreehash_new (ht, t)
 }
 
 htab_t
-java_treetreehash_create (size, gc)
-     size_t size;
-     int gc;
+java_treetreehash_create (size_t size, int gc)
 {
   if (gc)
     return htab_create_ggc (size, java_treetreehash_hash,