OSDN Git Service

2005-07-05 Paolo Bonzini <bonzini@gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / java / parse.y
index 5613c87..cda54c1 100644 (file)
@@ -1,6 +1,6 @@
 /* Source code parsing and tree node generation for the GNU compiler
    for the Java(TM) language.
-   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
+   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
    Free Software Foundation, Inc.
    Contributed by Alexandre Petit-Bianco (apbianco@cygnus.com)
 
@@ -18,8 +18,8 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING.  If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
+the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.
 
 Java and all Java-based marks are trademarks or registered trademarks
 of Sun Microsystems, Inc. in the United States and other countries.
@@ -57,6 +57,8 @@ definitions and other extensions.  */
 #include "real.h"
 #include "obstack.h"
 #include "toplev.h"
+#include "pretty-print.h"
+#include "diagnostic.h"
 #include "flags.h"
 #include "java-tree.h"
 #include "jcf.h"
@@ -65,16 +67,18 @@ definitions and other extensions.  */
 #include "zipfile.h"
 #include "convert.h"
 #include "buffer.h"
-#include "xref.h"
 #include "function.h"
 #include "except.h"
 #include "ggc.h"
 #include "debug.h"
 #include "tree-inline.h"
+#include "tree-dump.h"
 #include "cgraph.h"
+#include "target.h"
 
 /* Local function prototypes */
 static char *java_accstring_lookup (int);
+static const char *accessibility_string (int);
 static void  classitf_redefinition_error (const char *,tree, tree, tree);
 static void  variable_redefinition_error (tree, tree, tree, int);
 static tree  create_class (int, tree, tree, tree);
@@ -93,10 +97,14 @@ static tree lookup_java_method2 (tree, tree, int);
 static tree method_header (int, tree, tree, tree);
 static void fix_method_argument_names (tree ,tree);
 static tree method_declarator (tree, tree);
-static void parse_warning_context (tree cl, const char *msg, ...)
-  ATTRIBUTE_PRINTF_2;
-static void issue_warning_error_from_context (tree, const char *msg, va_list)
-  ATTRIBUTE_PRINTF (2, 0);
+static void parse_warning_context (tree cl, const char *gmsgid, ...) ATTRIBUTE_GCC_DIAG(2,3);
+#ifdef USE_MAPPED_LOCATION
+static void issue_warning_error_from_context
+  (source_location, const char *gmsgid, va_list *);
+#else
+static void issue_warning_error_from_context
+  (tree, const char *gmsgid, va_list *);
+#endif
 static void parse_ctor_invocation_error (void);
 static tree parse_jdk1_1_error (const char *);
 static void complete_class_report_errors (jdep *);
@@ -105,8 +113,7 @@ static void read_import_dir (tree);
 static int find_in_imports_on_demand (tree, tree);
 static void find_in_imports (tree, tree);
 static void check_inner_class_access (tree, tree, tree);
-static int check_pkg_class_access (tree, tree, bool);
-static void register_package (tree);
+static int check_pkg_class_access (tree, tree, bool, tree);
 static tree resolve_package (tree, tree *, tree *);
 static tree resolve_class (tree, tree, tree, tree);
 static void declare_local_variables (int, tree, tree);
@@ -120,8 +127,6 @@ static tree resolve_expression_name (tree, tree *);
 static tree maybe_create_class_interface_decl (tree, tree, tree, tree);
 static int check_class_interface_creation (int, int, tree, tree, tree, tree);
 static tree patch_method_invocation (tree, tree, tree, int, int *, tree *);
-static int breakdown_qualified (tree *, tree *, tree);
-static int in_same_package (tree, tree);
 static tree resolve_and_layout (tree, tree);
 static tree qualify_and_find (tree, tree, tree);
 static tree resolve_no_layout (tree, tree);
@@ -142,6 +147,7 @@ static tree java_complete_tree (tree);
 static tree maybe_generate_pre_expand_clinit (tree);
 static int analyze_clinit_body (tree, tree);
 static int maybe_yank_clinit (tree);
+static void start_complete_expand_method (tree);
 static void java_complete_expand_method (tree);
 static void java_expand_method_bodies (tree);
 static int  unresolved_type_p (tree, tree *);
@@ -156,7 +162,7 @@ static tree build_new_invocation (tree, tree);
 static tree build_assignment (int, int, tree, tree);
 static tree build_binop (enum tree_code, int, tree, tree);
 static tree patch_assignment (tree, tree);
-static tree patch_binop (tree, tree, tree);
+static tree patch_binop (tree, tree, tree, int);
 static tree build_unaryop (int, int, tree);
 static tree build_incdec (int, int, tree, int);
 static tree patch_unaryop (tree, tree);
@@ -174,7 +180,11 @@ static int build_type_name_from_array_name (tree, tree *);
 static tree build_array_from_name (tree, tree, tree, tree *);
 static tree build_array_ref (int, tree, tree);
 static tree patch_array_ref (tree);
+#ifdef USE_MAPPED_LOCATION
+static tree make_qualified_name (tree, tree, source_location);
+#else
 static tree make_qualified_name (tree, tree, int);
+#endif
 static tree merge_qualified_name (tree, tree);
 static tree make_qualified_primary (tree, tree, int);
 static int resolve_qualified_expression_name (tree, tree *, tree *, tree *);
@@ -195,7 +205,6 @@ static void check_deprecation (tree, tree);
 static int class_in_current_package (tree);
 static tree build_if_else_statement (int, tree, tree, tree);
 static tree patch_if_else_statement (tree);
-static tree add_stmt_to_compound (tree, tree, tree);
 static tree add_stmt_to_block (tree, tree, tree);
 static tree patch_exit_expr (tree);
 static tree build_labeled_block (int, tree);
@@ -214,13 +223,21 @@ static tree build_string_concatenation (tree, tree);
 static tree patch_string_cst (tree);
 static tree patch_string (tree);
 static tree encapsulate_with_try_catch (int, tree, tree, tree);
+#ifdef USE_MAPPED_LOCATION
+static tree build_assertion (source_location, tree, tree);
+#else
 static tree build_assertion (int, tree, tree);
+#endif
 static tree build_try_statement (int, tree, tree);
 static tree build_try_finally_statement (int, tree, tree);
 static tree patch_try_statement (tree);
 static tree patch_synchronized_statement (tree, tree);
 static tree patch_throw_statement (tree, tree);
+#ifdef USE_MAPPED_LOCATION
+static void check_thrown_exceptions (source_location, tree, tree);
+#else
 static void check_thrown_exceptions (int, tree, tree);
+#endif
 static int check_thrown_exceptions_do (tree);
 static void purge_unchecked_exceptions (tree);
 static bool ctors_unchecked_throws_clause_p (tree);
@@ -259,7 +276,6 @@ static tree maybe_build_array_element_wfl (tree);
 static int array_constructor_check_entry (tree, tree);
 static const char *purify_type_name (const char *);
 static tree fold_constant_for_init (tree, tree);
-static tree strip_out_static_field_access_decl (tree);
 static jdeplist *reverse_jdep_list (struct parser_ctxt *);
 static void static_ref_err (tree, tree, tree);
 static void parser_add_interface (tree, tree, tree);
@@ -294,7 +310,6 @@ static int pop_current_osb (struct parser_ctxt *);
 
 static tree maybe_make_nested_class_name (tree);
 static int make_nested_class_name (tree);
-static void set_nested_class_simple_name_value (tree, int);
 static void link_nested_class_to_enclosing (void);
 static tree resolve_inner_class (htab_t, tree, tree *, tree *, tree);
 static tree find_as_inner_class (tree, tree, tree);
@@ -306,22 +321,20 @@ static tree build_current_thisn (tree);
 static tree build_access_to_thisn (tree, tree, int);
 static tree maybe_build_thisn_access_method (tree);
 
-static tree build_outer_field_access (tree, tree);
-static tree build_outer_field_access_methods (tree);
-static tree build_outer_field_access_expr (int, tree, tree,
-                                                 tree, tree);
+static tree build_nested_field_access (tree, tree);
+static tree build_nested_field_access_methods (tree);
+static tree build_nested_field_access_method (tree, tree, tree, tree, tree);
+static tree build_nested_field_access_expr (int, tree, tree, tree, tree);
 static tree build_outer_method_access_method (tree);
 static tree build_new_access_id (void);
-static tree build_outer_field_access_method (tree, tree, tree,
-                                                   tree, tree);
 
-static int outer_field_access_p (tree, tree);
-static int outer_field_expanded_access_p (tree, tree *,
-                                                tree *, tree *);
-static tree outer_field_access_fix (tree, tree, tree);
+static int nested_field_access_p (tree, tree);
+static int nested_field_expanded_access_p (tree, tree *, tree *, tree *);
+static tree nested_field_access_fix (tree, tree, tree);
+
 static tree build_incomplete_class_ref (int, tree);
 static tree patch_incomplete_class_ref (tree);
-static tree create_anonymous_class (int, tree);
+static tree create_anonymous_class (tree);
 static void patch_anonymous_class (tree, tree, tree);
 static void add_inner_class_fields (tree, tree);
 
@@ -330,7 +343,6 @@ static tree build_dot_class_method_invocation (tree, tree);
 static void create_new_parser_context (int);
 static tree maybe_build_class_init_for_field (tree, tree);
 
-static int attach_init_test_initialization_flags (void **, void *);
 static int emit_test_initialization (void **, void *);
 
 static char *string_convert_int_cst (tree);
@@ -339,8 +351,6 @@ static char *string_convert_int_cst (tree);
 int java_error_count;
 /* Number of warning found so far. */
 int java_warning_count;
-/* Tell when not to fold, when doing xrefs */
-int do_not_fold;
 /* Cyclic inheritance report, as it can be set by layout_class */
 const char *cyclic_inheritance_report;
 
@@ -349,6 +359,7 @@ struct parser_ctxt *ctxp;
 
 /* List of things that were analyzed for which code will be generated */
 struct parser_ctxt *ctxp_for_generation = NULL;
+struct parser_ctxt *ctxp_for_generation_last = NULL;
 
 /* binop_lookup maps token to tree_code. It is used where binary
    operations are involved and required by the parser. RDIV_EXPR
@@ -395,9 +406,6 @@ static GTY(()) tree current_static_block;
 /* The generated `write_parm_value$' identifier.  */
 static GTY(()) tree wpv_id;
 
-/* The list of all packages we've seen so far */
-static GTY(()) tree package_list;
-
 /* Hold THIS for the scope of the current method decl.  */
 static GTY(()) tree current_this;
 
@@ -444,12 +452,24 @@ static GTY(()) tree src_parse_roots[1];
   int sub_token;
   struct {
     int token;
+#ifdef USE_MAPPED_LOCATION
+    source_location location;
+#else
     int location;
+#endif
   } operator;
   int value;
 }
 
 %{
+#ifdef USE_MAPPED_LOCATION
+#define SET_EXPR_LOCATION_FROM_TOKEN(EXPR, TOKEN) \
+  SET_EXPR_LOCATION(EXPR, (TOKEN).location)
+#else
+#define SET_EXPR_LOCATION_FROM_TOKEN(EXPR, TOKEN) \
+  (EXPR_WFL_LINECOL (EXPR) = (TOKEN).location)
+#endif
+
 #include "lex.c"
 %}
 
@@ -544,8 +564,8 @@ static GTY(()) tree src_parse_roots[1];
                        if_then_else_statement_nsi while_statement_nsi
                        for_statement_nsi statement_expression_list for_init
                        for_update statement_expression expression_statement
-                       primary_no_new_array expression primary
-                       array_creation_expression array_type
+                       primary_no_new_array expression primary array_type
+                       array_creation_initialized array_creation_uninitialized
                        class_instance_creation_expression field_access
                        method_invocation array_access something_dot_new
                        argument_list postfix_expression while_expression
@@ -713,7 +733,6 @@ package_declaration:
        PACKAGE_TK name SC_TK
                {
                  ctxp->package = EXPR_WFL_NODE ($2);
-                 register_package (ctxp->package);
                }
 |      PACKAGE_TK error
                {yyerror ("Missing name"); RECOVER;}
@@ -744,7 +763,7 @@ single_type_import_declaration:
                      tree err = find_name_in_single_imports (last_name);
                      if (err && err != name)
                        parse_error_context
-                         ($2, "Ambiguous class: `%s' and `%s'",
+                         ($2, "Ambiguous class: %qs and %qs",
                           IDENTIFIER_POINTER (name),
                           IDENTIFIER_POINTER (err));
                      else
@@ -810,7 +829,7 @@ modifiers:
                  int acc = (1 << $2);
                  if ($$ & acc)
                    parse_error_context
-                     (ctxp->modifier_ctx [$2], "Modifier `%s' declared twice",
+                     (ctxp->modifier_ctx [$2], "Modifier %qs declared twice",
                       java_accstring_lookup (acc));
                  else
                    {
@@ -881,18 +900,10 @@ interface_type_list:
 class_body:
        OCB_TK CCB_TK
                {
-                 /* Store the location of the `}' when doing xrefs */
-                 if (flag_emit_xref)
-                   DECL_END_SOURCE_LINE (GET_CPC ()) =
-                     EXPR_WFL_ADD_COL ($2.location, 1);
                  $$ = GET_CPC ();
                }
 |      OCB_TK class_body_declarations CCB_TK
                {
-                 /* Store the location of the `}' when doing xrefs */
-                 if (flag_emit_xref)
-                   DECL_END_SOURCE_LINE (GET_CPC ()) =
-                     EXPR_WFL_ADD_COL ($3.location, 1);
                  $$ = GET_CPC ();
                }
 ;
@@ -908,7 +919,7 @@ class_body_declaration:
 |      constructor_declaration
 |      block                   /* Added, JDK1.1, instance initializer */
                {
-                 if ($1 != empty_stmt_node)
+                 if (!IS_EMPTY_STMT ($1))
                    {
                      TREE_CHAIN ($1) = CPC_INSTANCE_INITIALIZER_STMT (ctxp);
                      SET_CPC_INSTANCE_INITIALIZER_STMT (ctxp, $1);
@@ -933,7 +944,7 @@ field_declaration:
 |      modifiers type variable_declarators SC_TK
                {
                  check_modifiers
-                   ("Illegal modifier `%s' for field declaration",
+                   ("Illegal modifier %qs for field declaration",
                     $1, FIELD_MODIFIERS);
                  check_modifiers_consistency ($1);
                  register_fields ($1, $2, $3);
@@ -1056,7 +1067,7 @@ method_declarator:
                { $$ = method_declarator ($1, $3); }
 |      method_declarator OSB_TK CSB_TK
                {
-                 EXPR_WFL_LINECOL (wfl_operator) = $2.location;
+                 SET_EXPR_LOCATION_FROM_TOKEN (wfl_operator, $2);
                  TREE_PURPOSE ($1) =
                    build_unresolved_array_type (TREE_PURPOSE ($1));
                  parse_warning_context
@@ -1108,7 +1119,7 @@ formal_parameter:
 final:
        modifiers
                {
-                 check_modifiers ("Illegal modifier `%s'. Only `final' was expected here",
+                 check_modifiers ("Illegal modifier %qs. Only %<final%> was expected here",
                                   $1, ACC_FINAL);
                  if ($1 != ACC_FINAL)
                    MODIFIER_WFL (FINAL_TK) = build_wfl_node (NULL_TREE);
@@ -1150,13 +1161,13 @@ static_initializer:
 static:                                /* Test lval.sub_token here */
        modifiers
                {
-                 check_modifiers ("Illegal modifier `%s' for static initializer", $1, ACC_STATIC);
+                 check_modifiers ("Illegal modifier %qs for static initializer", $1, ACC_STATIC);
                  /* Can't have a static initializer in an innerclass */
                  if ($1 | ACC_STATIC &&
                      GET_CPC_LIST () && !TOPLEVEL_CLASS_DECL_P (GET_CPC ()))
                    parse_error_context
                      (MODIFIER_WFL (STATIC_TK),
-                      "Can't define static initializer in class `%s'. Static initializer can only be defined in top-level classes",
+                      "Can't define static initializer in class %qs. Static initializer can only be defined in top-level classes",
                       IDENTIFIER_POINTER (DECL_NAME (GET_CPC ())));
                  SOURCE_FRONTEND_DEBUG (("Modifiers: %d", $1));
                }
@@ -1196,7 +1207,7 @@ constructor_body:
           addition (super invocation and field initialization) */
        block_begin constructor_block_end
                {
-                 BLOCK_EXPR_BODY ($2) = empty_stmt_node;
+                 BLOCK_EXPR_BODY ($2) = build_java_empty_stmt ();
                  $$ = $2;
                }
 |      block_begin explicit_constructor_invocation constructor_block_end
@@ -1237,13 +1248,13 @@ this_or_super:                  /* Added, simplifies error diagnostics */
        THIS_TK
                {
                  tree wfl = build_wfl_node (this_identifier_node);
-                 EXPR_WFL_LINECOL (wfl) = $1.location;
+                 SET_EXPR_LOCATION_FROM_TOKEN (wfl, $1);
                  $$ = wfl;
                }
 |      SUPER_TK
                {
                  tree wfl = build_wfl_node (super_identifier_node);
-                 EXPR_WFL_LINECOL (wfl) = $1.location;
+                 SET_EXPR_LOCATION_FROM_TOKEN (wfl, $1);
                  $$ = wfl;
                }
 ;
@@ -1368,13 +1379,9 @@ block_end:
        CCB_TK
                {
                  maybe_absorb_scoping_blocks ();
-                 /* Store the location of the `}' when doing xrefs */
-                 if (current_function_decl && flag_emit_xref)
-                   DECL_END_SOURCE_LINE (current_function_decl) =
-                     EXPR_WFL_ADD_COL ($1.location, 1);
                  $$ = exit_block ();
                  if (!BLOCK_SUBBLOCKS ($$))
-                   BLOCK_SUBBLOCKS ($$) = empty_stmt_node;
+                   BLOCK_SUBBLOCKS ($$) = build_java_empty_stmt ();
                }
 ;
 
@@ -1450,10 +1457,14 @@ empty_statement:
                           (DECL_CONTEXT (current_function_decl)))))
 
                    {
+#ifdef USE_MAPPED_LOCATION
+                     SET_EXPR_LOCATION (wfl_operator, input_location);
+#else
                      EXPR_WFL_SET_LINECOL (wfl_operator, input_line, -1);
+#endif
                      parse_warning_context (wfl_operator, "An empty declaration is a deprecated feature that should not be used");
                    }
-                 $$ = empty_stmt_node;
+                 $$ = build_java_empty_stmt ();
                }
 ;
 
@@ -1487,10 +1498,14 @@ expression_statement:
                {
                  /* We have a statement. Generate a WFL around it so
                     we can debug it */
+#ifdef USE_MAPPED_LOCATION
+                 $$ = expr_add_location ($1, input_location, 1);
+#else
                  $$ = build_expr_wfl ($1, input_filename, input_line, 0);
+                 JAVA_MAYBE_GENERATE_DEBUG_INFO ($$);
+#endif
                  /* We know we have a statement, so set the debug
                      info to be eventually generate here. */
-                 $$ = JAVA_MAYBE_GENERATE_DEBUG_INFO ($$);
                }
 |      error SC_TK
                {
@@ -1586,8 +1601,9 @@ switch_statement:
 switch_expression:
        SWITCH_TK OP_TK expression CP_TK
                {
-                 $$ = build (SWITCH_EXPR, NULL_TREE, $3, NULL_TREE);
-                 EXPR_WFL_LINECOL ($$) = $2.location;
+                 $$ = build3 (SWITCH_EXPR, NULL_TREE, $3,
+                              NULL_TREE, NULL_TREE);
+                 SET_EXPR_LOCATION_FROM_TOKEN ($$, $2);
                }
 |      SWITCH_TK error
                {yyerror ("'(' expected"); RECOVER;}
@@ -1629,13 +1645,13 @@ switch_label:
        CASE_TK constant_expression REL_CL_TK
                {
                  tree lab = build1 (CASE_EXPR, NULL_TREE, $2);
-                 EXPR_WFL_LINECOL (lab) = $1.location;
+                 SET_EXPR_LOCATION_FROM_TOKEN (lab, $1);
                  java_method_add_stmt (current_function_decl, lab);
                }
 |      DEFAULT_TK REL_CL_TK
                {
-                 tree lab = build (DEFAULT_EXPR, NULL_TREE, NULL_TREE);
-                 EXPR_WFL_LINECOL (lab) = $1.location;
+                 tree lab = make_node (DEFAULT_EXPR);
+                 SET_EXPR_LOCATION_FROM_TOKEN (lab, $1);
                  java_method_add_stmt (current_function_decl, lab);
                }
 |      CASE_TK error
@@ -1687,7 +1703,7 @@ do_statement:
 for_statement:
        for_begin SC_TK expression SC_TK for_update CP_TK statement
                {
-                 if (TREE_CODE_CLASS (TREE_CODE ($3)) == 'c')
+                 if (CONSTANT_CLASS_P ($3))
                    $3 = build_wfl_node ($3);
                  $$ = finish_for_loop (EXPR_WFL_LINECOL ($3), $3, $5, $7);
                }
@@ -1696,7 +1712,7 @@ for_statement:
                  $$ = finish_for_loop (0, NULL_TREE, $4, $6);
                  /* We have not condition, so we get rid of the EXIT_EXPR */
                  LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY ($$), 0) =
-                   empty_stmt_node;
+                   build_java_empty_stmt ();
                }
 |      for_begin SC_TK error
                {yyerror ("Invalid control expression"); RECOVER;}
@@ -1714,7 +1730,7 @@ for_statement_nsi:
                  $$ = finish_for_loop (0, NULL_TREE, $4, $6);
                  /* We have not condition, so we get rid of the EXIT_EXPR */
                  LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY ($$), 0) =
-                   empty_stmt_node;
+                   build_java_empty_stmt ();
                }
 ;
 
@@ -1745,7 +1761,7 @@ for_begin:
                }
 ;
 for_init:                      /* Can be empty */
-               { $$ = empty_stmt_node; }
+               { $$ = build_java_empty_stmt (); }
 |      statement_expression_list
                {
                  /* Init statement recorded within the previously
@@ -1763,7 +1779,7 @@ for_init:                 /* Can be empty */
 ;
 
 for_update:                    /* Can be empty */
-               {$$ = empty_stmt_node;}
+               {$$ = build_java_empty_stmt ();}
 |      statement_expression_list
                { $$ = build_debugable_stmt (BUILD_LOCATION (), $1); }
 ;
@@ -1814,7 +1830,7 @@ throw_statement:
        THROW_TK expression SC_TK
                {
                  $$ = build1 (THROW_EXPR, NULL_TREE, $2);
-                 EXPR_WFL_LINECOL ($$) = $1.location;
+                 SET_EXPR_LOCATION_FROM_TOKEN ($$, $1);
                }
 |      THROW_TK error
                {yyerror ("Missing term"); RECOVER;}
@@ -1840,7 +1856,7 @@ assert_statement:
 synchronized_statement:
        synchronized OP_TK expression CP_TK block
                {
-                 $$ = build (SYNCHRONIZED_EXPR, NULL_TREE, $3, $5);
+                 $$ = build2 (SYNCHRONIZED_EXPR, NULL_TREE, $3, $5);
                  EXPR_WFL_LINECOL ($$) =
                    EXPR_WFL_LINECOL (MODIFIER_WFL (SYNCHRONIZED_TK));
                }
@@ -1858,7 +1874,7 @@ synchronized:
        modifiers
                {
                  check_modifiers (
-             "Illegal modifier `%s'. Only `synchronized' was expected here",
+             "Illegal modifier %qs. Only %<synchronized%> was expected here",
                                   $1, ACC_SYNCHRONIZED);
                  if ($1 != ACC_SYNCHRONIZED)
                    MODIFIER_WFL (SYNCHRONIZED_TK) =
@@ -1905,15 +1921,24 @@ catch_clause_parameter:
                     formal_parameter (CCBP). The formal parameter is
                     declared initialized by the appropriate function
                     call */
-                 tree ccpb = enter_block ();
-                 tree init = build_assignment
-                   (ASSIGN_TK, $2.location, TREE_PURPOSE ($3),
-                    build (JAVA_EXC_OBJ_EXPR, ptr_type_node));
-                 declare_local_variables (0, TREE_VALUE ($3),
-                                          build_tree_list (TREE_PURPOSE ($3),
-                                                           init));
-                 $$ = build1 (CATCH_EXPR, NULL_TREE, ccpb);
-                 EXPR_WFL_LINECOL ($$) = $1.location;
+                  tree ccpb;
+                  tree init;
+                  if ($3)
+                    {
+                      ccpb = enter_block ();
+                      init = build_assignment
+                        (ASSIGN_TK, $2.location, TREE_PURPOSE ($3),
+                         build0 (JAVA_EXC_OBJ_EXPR, ptr_type_node));
+                      declare_local_variables (0, TREE_VALUE ($3),
+                                               build_tree_list 
+                                              (TREE_PURPOSE ($3), init));
+                      $$ = build1 (JAVA_CATCH_EXPR, NULL_TREE, ccpb);
+                      SET_EXPR_LOCATION_FROM_TOKEN ($$, $1);
+                    }
+                  else
+                    {
+                      $$ = error_mark_node;
+                    }
                }
 |      CATCH_TK error
                {yyerror ("'(' expected"); RECOVER; $$ = NULL_TREE;}
@@ -1936,7 +1961,8 @@ finally:
 /* 19.12 Production from 15: Expressions  */
 primary:
        primary_no_new_array
-|      array_creation_expression
+|      array_creation_uninitialized
+|      array_creation_initialized
 ;
 
 primary_no_new_array:
@@ -1951,7 +1977,7 @@ primary_no_new_array:
 |      array_access
 |      type_literals
         /* Added, JDK1.1 inner classes. Documentation is wrong
-           refering to a 'ClassName' (class_name) rule that doesn't
+           referring to a 'ClassName' (class_name) rule that doesn't
            exist. Used name: instead.  */
 |      name DOT_TK THIS_TK
                {
@@ -2006,17 +2032,22 @@ class_instance_creation_expression:
                }
 |      something_dot_new identifier OP_TK argument_list CP_TK class_body
 |      NEW_TK error SC_TK
-               {yyerror ("'(' expected"); DRECOVER(new_1);}
+               {$$ = NULL_TREE; yyerror ("'(' expected"); DRECOVER(new_1);}
 |      NEW_TK class_type error
-               {yyerror ("'(' expected"); RECOVER;}
+               {$$ = NULL_TREE; yyerror ("'(' expected"); RECOVER;}
 |      NEW_TK class_type OP_TK error
-               {yyerror ("')' or term expected"); RECOVER;}
+               {$$ = NULL_TREE; yyerror ("')' or term expected"); RECOVER;}
 |      NEW_TK class_type OP_TK argument_list error
-               {yyerror ("')' expected"); RECOVER;}
+               {$$ = NULL_TREE; yyerror ("')' expected"); RECOVER;}
 |      something_dot_new error
-               {YYERROR_NOW; yyerror ("Identifier expected"); RECOVER;}
+               {
+                 $$ = NULL_TREE;
+                 YYERROR_NOW;
+                 yyerror ("Identifier expected");
+                 RECOVER;
+               }
 |      something_dot_new identifier error
-               {yyerror ("'(' expected"); RECOVER;}
+               {$$ = NULL_TREE; yyerror ("'(' expected"); RECOVER;}
 ;
 
 /* Created after JDK1.1 rules originally added to
@@ -2026,7 +2057,7 @@ class_instance_creation_expression:
 
 anonymous_class_creation:
        NEW_TK class_type OP_TK argument_list CP_TK
-               { create_anonymous_class ($1.location, $2); }
+               { create_anonymous_class ($2); }
         class_body
                {
                  tree id = build_wfl_node (DECL_NAME (GET_CPC ()));
@@ -2053,13 +2084,13 @@ anonymous_class_creation:
                     later on in verify_constructor_super.
 
                     It's during the expansion of a `new' statement
-                    refering to an anonymous class that a ctor will
+                    referring to an anonymous class that a ctor will
                     be generated for the anonymous class, with the
                     right arguments. */
 
                }
 |      NEW_TK class_type OP_TK CP_TK
-               { create_anonymous_class ($1.location, $2); }
+               { create_anonymous_class ($2); }
         class_body
                {
                  tree id = build_wfl_node (DECL_NAME (GET_CPC ()));
@@ -2097,7 +2128,7 @@ argument_list:
                {yyerror ("Missing term"); RECOVER;}
 ;
 
-array_creation_expression:
+array_creation_uninitialized:
        NEW_TK primitive_type dim_exprs
                { $$ = build_newarray_node ($2, $3, 0); }
 |      NEW_TK class_or_interface_type dim_exprs
@@ -2106,9 +2137,16 @@ array_creation_expression:
                { $$ = build_newarray_node ($2, $3, pop_current_osb (ctxp));}
 |      NEW_TK class_or_interface_type dim_exprs dims
                { $$ = build_newarray_node ($2, $3, pop_current_osb (ctxp));}
+|      NEW_TK error CSB_TK
+               {yyerror ("'[' expected"); DRECOVER ("]");}
+|      NEW_TK error OSB_TK
+               {yyerror ("']' expected"); RECOVER;}
+;
+
+array_creation_initialized:
         /* Added, JDK1.1 anonymous array. Initial documentation rule
            modified */
-|      NEW_TK class_or_interface_type dims array_initializer
+       NEW_TK class_or_interface_type dims array_initializer
                {
                  char *sig;
                  int osb = pop_current_osb (ctxp);
@@ -2116,8 +2154,8 @@ array_creation_expression:
                    obstack_grow (&temporary_obstack, "[]", 2);
                  obstack_1grow (&temporary_obstack, '\0');
                  sig = obstack_finish (&temporary_obstack);
-                 $$ = build (NEW_ANONYMOUS_ARRAY_EXPR, NULL_TREE,
-                             $2, get_identifier (sig), $4);
+                 $$ = build3 (NEW_ANONYMOUS_ARRAY_EXPR, NULL_TREE,
+                              $2, get_identifier (sig), $4);
                }
 |      NEW_TK primitive_type dims array_initializer
                {
@@ -2125,8 +2163,8 @@ array_creation_expression:
                  tree type = $2;
                  while (osb--)
                    type = build_java_array_type (type, -1);
-                 $$ = build (NEW_ANONYMOUS_ARRAY_EXPR, NULL_TREE,
-                             build_pointer_type (type), NULL_TREE, $4);
+                 $$ = build3 (NEW_ANONYMOUS_ARRAY_EXPR, NULL_TREE,
+                              build_pointer_type (type), NULL_TREE, $4);
                }
 |      NEW_TK error CSB_TK
                {yyerror ("'[' expected"); DRECOVER ("]");}
@@ -2203,7 +2241,7 @@ field_access:
 |      SUPER_TK DOT_TK identifier
                {
                  tree super_wfl = build_wfl_node (super_identifier_node);
-                 EXPR_WFL_LINECOL (super_wfl) = $1.location;
+                 SET_EXPR_LOCATION_FROM_TOKEN (super_wfl, $1);
                  $$ = make_qualified_name (super_wfl, $3, $2.location);
                }
 |      SUPER_TK error
@@ -2262,6 +2300,8 @@ array_access:
                { $$ = build_array_ref ($2.location, $1, $3); }
 |      primary_no_new_array OSB_TK expression CSB_TK
                { $$ = build_array_ref ($2.location, $1, $3); }
+|      array_creation_initialized OSB_TK expression CSB_TK
+               { $$ = build_array_ref ($2.location, $1, $3); }
 |      name OSB_TK error
                {
                  yyerror ("Missing term and ']' expected");
@@ -2282,6 +2322,16 @@ array_access:
                  yyerror ("']' expected");
                  DRECOVER(array_access);
                }
+|      array_creation_initialized OSB_TK error
+               {
+                 yyerror ("Missing term and ']' expected");
+                 DRECOVER(array_access);
+               }
+|      array_creation_initialized OSB_TK expression error
+               {
+                 yyerror ("']' expected");
+                 DRECOVER(array_access);
+               }
 ;
 
 postfix_expression:
@@ -2314,7 +2364,8 @@ trap_overflow_corner_case:
 unary_expression:
        trap_overflow_corner_case
                {
-                 error_if_numeric_overflow ($1);
+                 if ($1)
+                   error_if_numeric_overflow ($1);
                  $$ = $1;
                }
 |      MINUS_TK trap_overflow_corner_case
@@ -2573,8 +2624,8 @@ conditional_expression:           /* Error handling here is weak */
        conditional_or_expression
 |      conditional_or_expression REL_QM_TK expression REL_CL_TK conditional_expression
                {
-                 $$ = build (CONDITIONAL_EXPR, NULL_TREE, $1, $3, $5);
-                 EXPR_WFL_LINECOL ($$) = $2.location;
+                 $$ = build3 (CONDITIONAL_EXPR, NULL_TREE, $1, $3, $5);
+                 SET_EXPR_LOCATION_FROM_TOKEN ($$, $2);
                }
 |      conditional_or_expression REL_QM_TK REL_CL_TK error
                {
@@ -2683,16 +2734,15 @@ void
 java_pop_parser_context (int generate)
 {
   tree current;
-  struct parser_ctxt *toFree, *next;
+  struct parser_ctxt *next;
 
   if (!ctxp)
     return;
 
-  toFree = ctxp;
   next = ctxp->next;
   if (next)
     {
-      input_line = ctxp->lineno;
+      input_location = ctxp->save_location;
       current_class = ctxp->class_type;
     }
 
@@ -2705,19 +2755,23 @@ java_pop_parser_context (int generate)
   for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
     IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (TREE_VALUE (current)) = 0;
 
-  /* And restore those of the previous context */
-  if ((ctxp = next))           /* Assignment is really meant here */
-    for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
-      IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (TREE_VALUE (current)) = 1;
-
   /* If we pushed a context to parse a class intended to be generated,
      we keep it so we can remember the class. What we could actually
      do is to just update a list of class names.  */
   if (generate)
     {
-      toFree->next = ctxp_for_generation;
-      ctxp_for_generation = toFree;
+      if (ctxp_for_generation_last == NULL)
+        ctxp_for_generation = ctxp;
+      else
+        ctxp_for_generation_last->next = ctxp;
+      ctxp->next = NULL;
+      ctxp_for_generation_last = ctxp;
     }
+
+  /* And restore those of the previous context */
+  if ((ctxp = next))           /* Assignment is really meant here */
+    for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
+      IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (TREE_VALUE (current)) = 1;
 }
 
 /* Create a parser context for the use of saving some global
@@ -2740,9 +2794,8 @@ java_parser_context_save_global (void)
       ctxp->saved_data_ctx = 1;
     }
 
-  ctxp->lineno = input_line;
+  ctxp->save_location = input_location;
   ctxp->class_type = current_class;
-  ctxp->filename = input_filename;
   ctxp->function_decl = current_function_decl;
   ctxp->saved_data = 1;
 }
@@ -2753,15 +2806,14 @@ java_parser_context_save_global (void)
 void
 java_parser_context_restore_global (void)
 {
-  input_line = ctxp->lineno;
+  input_location = ctxp->save_location;
   current_class = ctxp->class_type;
-  input_filename = ctxp->filename;
   if (wfl_operator)
-    {
-      tree s;
-      BUILD_FILENAME_IDENTIFIER_NODE (s, input_filename);
-      EXPR_WFL_FILENAME_NODE (wfl_operator) = s;
-    }
+#ifdef USE_MAPPED_LOCATION
+    SET_EXPR_LOCATION (wfl_operator, ctxp->save_location);
+#else
+    EXPR_WFL_FILENAME_NODE (wfl_operator) = get_identifier (input_filename);
+#endif
   current_function_decl = ctxp->function_decl;
   ctxp->saved_data = 0;
   if (ctxp->saved_data_ctx)
@@ -2929,8 +2981,6 @@ java_debug_context_do (int tab)
       TAB_CONTEXT (tab);
       fprintf (stderr, "filename: %s\n", copy->filename);
       TAB_CONTEXT (tab);
-      fprintf (stderr, "lineno: %d\n", copy->lineno);
-      TAB_CONTEXT (tab);
       fprintf (stderr, "package: %s\n",
               (copy->package ?
                IDENTIFIER_POINTER (copy->package) : "<none>"));
@@ -2975,42 +3025,56 @@ parse_ctor_invocation_error (void)
 static tree
 parse_jdk1_1_error (const char *msg)
 {
-  sorry (": `%s' JDK1.1(TM) feature", msg);
+  sorry (": %qs JDK1.1(TM) feature", msg);
   java_error_count++;
-  return empty_stmt_node;
+  return build_java_empty_stmt ();
 }
 
 static int do_warning = 0;
 
 void
-yyerror (const char *msg)
+yyerror (const char *msgid)
 {
+#ifdef USE_MAPPED_LOCATION
+  static source_location elc;
+  expanded_location xloc = expand_location (input_location);
+  int current_line = xloc.line;
+#else
   static java_lc elc;
-  static int  prev_lineno;
+  int save_lineno;
+  int current_line = input_line;
+#endif
+  static int prev_lineno;
   static const char *prev_msg;
 
-  int save_lineno;
   char *remainder, *code_from_source;
 
-  if (!force_error && prev_lineno == input_line)
+  if (!force_error && prev_lineno == current_line)
     return;
+#ifndef USE_MAPPED_LOCATION
+  current_line = ctxp->lexer->token_start.line;
+#endif
 
   /* Save current error location but report latter, when the context is
      richer.  */
   if (ctxp->java_error_flag == 0)
     {
       ctxp->java_error_flag = 1;
-      elc = ctxp->elc;
+#ifdef USE_MAPPED_LOCATION
+      elc = input_location;
+#else
+      elc = ctxp->lexer->token_start;
+#endif
       /* Do something to use the previous line if we're reaching the
         end of the file... */
 #ifdef VERBOSE_SKELETON
-      printf ("* Error detected (%s)\n", (msg ? msg : "(null)"));
+      printf ("* Error detected (%s)\n", (msgid ? msgid : "(null)"));
 #endif
       return;
     }
 
   /* Ignore duplicate message on the same line. BTW, this is dubious. FIXME */
-  if (!force_error && msg == prev_msg && prev_lineno == elc.line)
+  if (!force_error && msgid == prev_msg && prev_lineno == current_line)
     return;
 
   ctxp->java_error_flag = 0;
@@ -3019,80 +3083,135 @@ yyerror (const char *msg)
   else
     java_error_count++;
 
-  if (elc.col == 0 && msg && msg[1] == ';')
-    {
-      elc.col  = ctxp->p_line->char_col-1;
-      elc.line = ctxp->p_line->lineno;
-    }
+#if 0 /* FIXME */
+  if (elc.col == 0 && msgid && msgid[1] == ';')
+    elc = ctxp->prev_line_end;
+#endif
 
+  prev_msg = msgid;
+
+#ifdef USE_MAPPED_LOCATION
+  prev_lineno = current_line;
+  code_from_source = java_get_line_col (xloc.file, current_line, xloc.column);
+#else
   save_lineno = input_line;
-  prev_lineno = input_line = elc.line;
-  prev_msg = msg;
+  prev_lineno = input_line = current_line;
+  code_from_source = java_get_line_col (input_filename, current_line,
+                                       ctxp->lexer->token_start.col);
+#endif
+
 
-  code_from_source = java_get_line_col (ctxp->filename, elc.line, elc.col);
   obstack_grow0 (&temporary_obstack,
                 code_from_source, strlen (code_from_source));
   remainder = obstack_finish (&temporary_obstack);
   if (do_warning)
-    warning ("%s.\n%s", msg, remainder);
+    warning (0, "%s.\n%s", msgid, remainder);
   else
-    error ("%s.\n%s", msg, remainder);
+    error ("%s.\n%s", msgid, remainder);
 
   /* This allow us to cheaply avoid an extra 'Invalid expression
      statement' error report when errors have been already reported on
      the same line. This occurs when we report an error but don't have
      a synchronization point other than ';', which
      expression_statement is the only one to take care of.  */
-  ctxp->prevent_ese = input_line = save_lineno;
+#ifndef USE_MAPPED_LOCATION
+  input_line = save_lineno;
+#endif
+  ctxp->prevent_ese = input_line;
 }
 
 static void
-issue_warning_error_from_context (tree cl, const char *msg, va_list ap)
+issue_warning_error_from_context (
+#ifdef USE_MAPPED_LOCATION
+                                 source_location cl,
+#else
+                                 tree cl,
+#endif
+                                 const char *gmsgid, va_list *ap)
 {
-  const char *saved, *saved_input_filename;
+#ifdef USE_MAPPED_LOCATION
+  source_location saved_location = input_location;
+  expanded_location xloc = expand_location (cl);
+#else
+  java_lc save_lc = ctxp->lexer->token_start;
+  const char *saved = ctxp->filename, *saved_input_filename;
+#endif
   char buffer [4096];
-  vsprintf (buffer, msg, ap);
+  text_info text;
+
+  text.err_no = errno;
+  text.args_ptr = ap;
+  text.format_spec = gmsgid;
+  pp_format (global_dc->printer, &text);
+  pp_output_formatted_text (global_dc->printer);
+  strncpy (buffer, pp_formatted_text (global_dc->printer), sizeof (buffer) - 1);
+  buffer[sizeof (buffer) - 1] = '\0';
+  pp_clear_output_area (global_dc->printer);
+
   force_error = 1;
 
-  ctxp->elc.line = EXPR_WFL_LINENO (cl);
-  ctxp->elc.col  = (EXPR_WFL_COLNO (cl) == 0xfff ? -1 :
-                   (EXPR_WFL_COLNO (cl) == 0xffe ? -2 : EXPR_WFL_COLNO (cl)));
+#ifdef USE_MAPPED_LOCATION
+  if (xloc.file != NULL)
+    {
+      ctxp->filename = xloc.file;
+      input_location = cl;
+    }
+#else
+  ctxp->lexer->token_start.line = EXPR_WFL_LINENO (cl);
+  ctxp->lexer->token_start.col  = (EXPR_WFL_COLNO (cl) == 0xfff ? -1
+                                  : EXPR_WFL_COLNO (cl) == 0xffe ? -2
+                                  : EXPR_WFL_COLNO (cl));
 
   /* We have a CL, that's a good reason for using it if it contains data */
-  saved = ctxp->filename;
   if (TREE_CODE (cl) == EXPR_WITH_FILE_LOCATION && EXPR_WFL_FILENAME_NODE (cl))
     ctxp->filename = EXPR_WFL_FILENAME (cl);
   saved_input_filename = input_filename;
   input_filename = ctxp->filename;
+#endif
   java_error (NULL);
   java_error (buffer);
+#ifdef USE_MAPPED_LOCATION
+  input_location = saved_location;
+#else
   ctxp->filename = saved;
   input_filename = saved_input_filename;
+  ctxp->lexer->token_start = save_lc;
+#endif
   force_error = 0;
 }
 
-/* Issue an error message at a current source line CL */
+/* Issue an error message at a current source line CL.
+   FUTURE/FIXME:  change cl to be a source_location. */
 
 void
-parse_error_context (tree cl, const char *msg, ...)
+parse_error_context (tree cl, const char *gmsgid, ...)
 {
   va_list ap;
-  va_start (ap, msg);
-  issue_warning_error_from_context (cl, msg, ap);
+  va_start (ap, gmsgid);
+#ifdef USE_MAPPED_LOCATION
+  issue_warning_error_from_context (EXPR_LOCATION (cl), gmsgid, &ap);
+#else
+  issue_warning_error_from_context (cl, gmsgid, &ap);
+#endif
   va_end (ap);
 }
 
-/* Issue a warning at a current source line CL */
+/* Issue a warning at a current source line CL.
+   FUTURE/FIXME:  change cl to be a source_location. */
 
 static void
-parse_warning_context (tree cl, const char *msg, ...)
+parse_warning_context (tree cl, const char *gmsgid, ...)
 {
   va_list ap;
-  va_start (ap, msg);
+  va_start (ap, gmsgid);
 
-  force_error = do_warning = 1;
-  issue_warning_error_from_context (cl, msg, ap);
-  do_warning = force_error = 0;
+  do_warning = 1;
+#ifdef USE_MAPPED_LOCATION
+  issue_warning_error_from_context (EXPR_LOCATION (cl), gmsgid, &ap);
+#else
+  issue_warning_error_from_context (cl, gmsgid, &ap);
+#endif
+  do_warning = 0;
   va_end (ap);
 }
 
@@ -3101,7 +3220,7 @@ find_expr_with_wfl (tree node)
 {
   while (node)
     {
-      char code;
+      enum tree_code_class code;
       tree to_return;
 
       switch (TREE_CODE (node))
@@ -3122,12 +3241,13 @@ find_expr_with_wfl (tree node)
          continue;
 
        case LABELED_BLOCK_EXPR:
-         node = TREE_OPERAND (node, 1);
+         node = LABELED_BLOCK_BODY (node);
          continue;
 
        default:
          code = TREE_CODE_CLASS (TREE_CODE (node));
-         if (((code == '1') || (code == '2') || (code == 'e'))
+         if (((code == tcc_unary) || (code == tcc_binary)
+              || (code == tcc_expression))
              && EXPR_WFL_LINECOL (node))
            return node;
          return NULL_TREE;
@@ -3142,7 +3262,11 @@ find_expr_with_wfl (tree node)
 static void
 missing_return_error (tree method)
 {
+#ifdef USE_MAPPED_LOCATION
+  SET_EXPR_LOCATION (wfl_operator, DECL_FUNCTION_LAST_LINE (method));
+#else
   EXPR_WFL_SET_LINECOL (wfl_operator, DECL_FUNCTION_LAST_LINE (method), -2);
+#endif
   parse_error_context (wfl_operator, "Missing return statement");
 }
 
@@ -3160,7 +3284,11 @@ unreachable_stmt_error (tree node)
 
   if (node)
     {
+#ifdef USE_MAPPED_LOCATION
+      SET_EXPR_LOCATION (wfl_operator, EXPR_LOCATION (node));
+#else
       EXPR_WFL_SET_LINECOL (wfl_operator, EXPR_WFL_LINENO (node), -2);
+#endif
       parse_error_context (wfl_operator, "Unreachable statement");
     }
   else
@@ -3171,8 +3299,8 @@ static int
 not_accessible_field_error (tree wfl, tree decl)
 {
   parse_error_context 
-    (wfl, "Can't access %s field `%s.%s' from `%s'",
-     java_accstring_lookup (get_access_flags_from_decl (decl)),
+    (wfl, "Can't access %s field %<%s.%s%> from %qs",
+     accessibility_string (get_access_flags_from_decl (decl)),
      GET_TYPE_NAME (DECL_CONTEXT (decl)),
      IDENTIFIER_POINTER (DECL_NAME (decl)),
      IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
@@ -3218,13 +3346,29 @@ java_accstring_lookup (int flags)
 #undef COPY_RETURN
 }
 
+/* Returns a string denoting the accessibility of a class or a member as
+   indicated by FLAGS.  We need a separate function from
+   java_accstring_lookup, as the latter can return spurious "static", etc.
+   if package-private access is defined (in which case none of the
+   relevant access control bits in FLAGS is set).  */
+
+static const char *
+accessibility_string (int flags)
+{
+  if (flags & ACC_PRIVATE) return "private";
+  if (flags & ACC_PROTECTED) return "protected";
+  if (flags & ACC_PUBLIC) return "public";
+
+  return "package-private";
+}
+
 /* Issuing error messages upon redefinition of classes, interfaces or
    variables. */
 
 static void
 classitf_redefinition_error (const char *context, tree id, tree decl, tree cl)
 {
-  parse_error_context (cl, "%s `%s' already defined in %s:%d",
+  parse_error_context (cl, "%s %qs already defined in %s:%d",
                       context, IDENTIFIER_POINTER (id),
                       DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
   /* Here we should point out where its redefined. It's a unicode. FIXME */
@@ -3242,7 +3386,7 @@ variable_redefinition_error (tree context, tree name, tree type, int line)
     type_name = lang_printable_name (type, 0);
 
   parse_error_context (context,
-                      "Variable `%s' is already defined in this method and was declared `%s %s' at line %d",
+                      "Variable %qs is already defined in this method and was declared %<%s %s%> at line %d",
                       IDENTIFIER_POINTER (name),
                       type_name, IDENTIFIER_POINTER (name), line);
 }
@@ -3335,10 +3479,14 @@ build_unresolved_array_type (tree type_or_wfl)
                 IDENTIFIER_LENGTH (EXPR_WFL_NODE (type_or_wfl)));
   obstack_grow0 (&temporary_obstack, "[]", 2);
   ptr = obstack_finish (&temporary_obstack);
+#ifdef USE_MAPPED_LOCATION
+  wfl = build_expr_wfl (get_identifier (ptr), EXPR_LOCATION (type_or_wfl));
+#else
   wfl = build_expr_wfl (get_identifier (ptr),
                        EXPR_WFL_FILENAME (type_or_wfl),
                        EXPR_WFL_LINENO (type_or_wfl),
                        EXPR_WFL_COLNO (type_or_wfl));
+#endif
   /* Re-install the existing qualifications so that the type can be
      resolved properly. */
   EXPR_WFL_QUALIFICATION (wfl) = EXPR_WFL_QUALIFICATION (type_or_wfl);
@@ -3349,7 +3497,7 @@ static void
 parser_add_interface (tree class_decl, tree interface_decl, tree wfl)
 {
   if (maybe_add_interface (TREE_TYPE (class_decl), TREE_TYPE (interface_decl)))
-    parse_error_context (wfl, "Interface `%s' repeated",
+    parse_error_context (wfl, "Interface %qs repeated",
                         IDENTIFIER_POINTER (DECL_NAME (interface_decl)));
 }
 
@@ -3379,7 +3527,7 @@ check_class_interface_creation (int is_interface, int flags, tree raw_name,
       && !CPC_INNER_P ())
     {
       parse_error_context
-       (cl, "%s name `%s' clashes with imported type `%s'",
+       (cl, "%s name %qs clashes with imported type %qs",
         (is_interface ? "Interface" : "Class"),
         IDENTIFIER_POINTER (raw_name), IDENTIFIER_POINTER (node));
       return 1;
@@ -3398,19 +3546,20 @@ check_class_interface_creation (int is_interface, int flags, tree raw_name,
      when dealing with an inner class */
   if (!CPC_INNER_P () && (flags & ACC_PUBLIC ))
     {
+      const char *fname = input_filename;
       const char *f;
 
-      for (f = &input_filename [strlen (input_filename)];
-          f != input_filename && ! IS_DIR_SEPARATOR (f[0]);
+      for (f = fname + strlen (fname);
+          f != fname && ! IS_DIR_SEPARATOR (*f);
           f--)
        ;
-      if (IS_DIR_SEPARATOR (f[0]))
+      if (IS_DIR_SEPARATOR (*f))
        f++;
       if (strncmp (IDENTIFIER_POINTER (raw_name),
                   f , IDENTIFIER_LENGTH (raw_name)) ||
          f [IDENTIFIER_LENGTH (raw_name)] != '.')
        parse_error_context
-         (cl, "Public %s `%s' must be defined in a file called `%s.java'",
+         (cl, "Public %s %qs must be defined in a file called %<%s.java%>",
                             (is_interface ? "interface" : "class"),
                             IDENTIFIER_POINTER (qualified_name),
                             IDENTIFIER_POINTER (raw_name));
@@ -3425,7 +3574,7 @@ check_class_interface_creation (int is_interface, int flags, tree raw_name,
         complaining a second time */
       if (CPC_INNER_P () && !TOPLEVEL_CLASS_DECL_P (GET_CPC()))
        {
-         parse_error_context (cl, "Inner class `%s' can't be static. Static classes can only occur in interfaces and top-level classes",
+         parse_error_context (cl, "Inner class %qs can't be static. Static classes can only occur in interfaces and top-level classes",
                               IDENTIFIER_POINTER (qualified_name));
          sca = ACC_STATIC;
        }
@@ -3460,13 +3609,13 @@ check_class_interface_creation (int is_interface, int flags, tree raw_name,
       else
        uaaf = INTERFACE_MODIFIERS;
 
-      check_modifiers ("Illegal modifier `%s' for interface declaration",
+      check_modifiers ("Illegal modifier %qs for interface declaration",
                       flags, uaaf);
     }
   else
     check_modifiers ((current_function_decl ?
-                     "Illegal modifier `%s' for local class declaration" :
-                     "Illegal modifier `%s' for class declaration"),
+                     "Illegal modifier %qs for local class declaration" :
+                     "Illegal modifier %qs for class declaration"),
                     flags, uaaf|sca|icaf);
   return 0;
 }
@@ -3506,7 +3655,7 @@ check_inner_class_redefinition (tree raw_name, tree cl)
     if (raw_name == GET_CPC_UN_NODE (scope_list))
       {
        parse_error_context
-         (cl, "The class name `%s' is already defined in this scope. An inner class may not have the same simple name as any of its enclosing classes",
+         (cl, "The class name %qs is already defined in this scope. An inner class may not have the same simple name as any of its enclosing classes",
           IDENTIFIER_POINTER (raw_name));
        return 1;
       }
@@ -3557,7 +3706,7 @@ resolve_inner_class (htab_t circularity_hash, tree cl, tree *enclosing,
         break;
 
       if (TREE_CODE (local_super) == POINTER_TYPE)
-        local_super = do_resolve_class (NULL, local_super, NULL, NULL);
+        local_super = do_resolve_class (NULL, NULL, local_super, NULL, NULL);
       else
        local_super = TYPE_NAME (local_super);
 
@@ -3602,7 +3751,7 @@ find_as_inner_class (tree enclosing, tree name, tree cl)
   else if (cl)
     qual = build_tree_list (cl, NULL_TREE);
   else
-    qual = build_tree_list (build_expr_wfl (name, NULL, 0, 0), NULL_TREE);
+    qual = build_tree_list (build_unknown_wfl (name), NULL_TREE);
 
   if ((to_return = find_as_inner_class_do (qual, enclosing)))
     return to_return;
@@ -3619,7 +3768,7 @@ find_as_inner_class (tree enclosing, tree name, tree cl)
          acc = merge_qualified_name (acc,
                                      EXPR_WFL_NODE (TREE_PURPOSE (qual)));
          BUILD_PTR_FROM_NAME (ptr, acc);
-         decl = do_resolve_class (NULL_TREE, ptr, NULL_TREE, cl);
+         decl = do_resolve_class (NULL_TREE, NULL_TREE, ptr, NULL_TREE, cl);
        }
 
       /* A NULL qual and a decl means that the search ended
@@ -3632,7 +3781,7 @@ find_as_inner_class (tree enclosing, tree name, tree cl)
     }
   /* Otherwise, create a qual for the other part of the resolution. */
   else
-    qual = build_tree_list (build_expr_wfl (name, NULL, 0, 0), NULL_TREE);
+    qual = build_tree_list (build_unknown_wfl (name), NULL_TREE);
 
   return find_as_inner_class_do (qual, enclosing);
 }
@@ -3667,19 +3816,6 @@ find_as_inner_class_do (tree qual, tree enclosing)
   return (!qual && enclosing ? enclosing : NULL_TREE);
 }
 
-/* Reach all inner classes and tie their unqualified name to a
-   DECL. */
-
-static void
-set_nested_class_simple_name_value (tree outer, int set)
-{
-  tree l;
-
-  for (l = DECL_INNER_CLASS_LIST (outer); l; l = TREE_CHAIN (l))
-    IDENTIFIER_GLOBAL_VALUE (TREE_VALUE (l)) = (set ?
-                                               TREE_PURPOSE (l) : NULL_TREE);
-}
-
 static void
 link_nested_class_to_enclosing (void)
 {
@@ -3734,16 +3870,24 @@ maybe_create_class_interface_decl (tree decl, tree raw_name,
     decl = push_class (make_class (), qualified_name);
 
   /* Take care of the file and line business */
+#ifdef USE_MAPPED_LOCATION
+  DECL_SOURCE_LOCATION (decl) = EXPR_LOCATION (cl);
+#else
   DECL_SOURCE_FILE (decl) = EXPR_WFL_FILENAME (cl);
-  /* If we're emitting xrefs, store the line/col number information */
-  if (flag_emit_xref)
-    DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (cl);
-  else
-    DECL_SOURCE_LINE (decl) = EXPR_WFL_LINENO (cl);
+  DECL_SOURCE_LINE (decl) = EXPR_WFL_LINENO (cl);
+#endif
   CLASS_FROM_SOURCE_P (TREE_TYPE (decl)) = 1;
   CLASS_PARSED_P (TREE_TYPE (decl)) = 1;
+#ifdef USE_MAPPED_LOCATION
+  {
+    tree tmp = maybe_get_identifier (EXPR_FILENAME (cl));
+    CLASS_FROM_CURRENTLY_COMPILED_P (TREE_TYPE (decl)) =
+      tmp && IS_A_COMMAND_LINE_FILENAME_P (tmp);
+  }
+#else
   CLASS_FROM_CURRENTLY_COMPILED_P (TREE_TYPE (decl)) =
     IS_A_COMMAND_LINE_FILENAME_P (EXPR_WFL_FILENAME_NODE (cl));
+#endif
 
   PUSH_CPC (decl, raw_name);
   DECL_CONTEXT (decl) = GET_ENCLOSING_CPC_CONTEXT ();
@@ -3834,11 +3978,18 @@ create_interface (int flags, tree id, tree super)
   if ((flags & ACC_ABSTRACT) && flag_redundant)
     parse_warning_context
       (MODIFIER_WFL (ABSTRACT_TK),
-       "Redundant use of `abstract' modifier. Interface `%s' is implicitly abstract", IDENTIFIER_POINTER (raw_name));
+       "Redundant use of %<abstract%> modifier. Interface %qs is implicitly abstract", IDENTIFIER_POINTER (raw_name));
 
   /* Create a new decl if DECL is NULL, otherwise fix it */
   decl = maybe_create_class_interface_decl (decl, raw_name, q_name, id);
 
+  /* Interfaces are always abstract. */
+  flags |= ACC_ABSTRACT;
+
+  /* Inner interfaces are always static.  */
+  if (INNER_CLASS_DECL_P (decl))
+    flags |= ACC_STATIC;
+
   /* Set super info and mark the class a complete */
   set_super_info (ACC_INTERFACE | flags, TREE_TYPE (decl),
                  object_type_node, ctxp->interface_number);
@@ -3865,16 +4016,24 @@ patch_anonymous_class (tree type_decl, tree class_decl, tree wfl)
   /* If it's an interface, implement it */
   if (CLASS_INTERFACE (type_decl))
     {
-      tree s_binfo;
-      int length;
-
       if (parser_check_super_interface (type_decl, class_decl, wfl))
        return;
 
-      s_binfo = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (class)), 0);
-      length = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (class))+1;
-      TYPE_BINFO_BASETYPES (class) = make_tree_vec (length);
-      TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (class)), 0) = s_binfo;
+      if (!VEC_space (tree, BINFO_BASE_BINFOS (binfo), 1))
+       {
+          /* Extend the binfo - by reallocating and copying it. */
+         tree new_binfo;
+         tree base_binfo;
+         int i;
+         
+         new_binfo = make_tree_binfo ((BINFO_N_BASE_BINFOS (binfo) + 1) * 2);
+         for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
+           BINFO_BASE_APPEND (new_binfo, base_binfo);
+         CLASS_HAS_SUPER_FLAG (new_binfo) = CLASS_HAS_SUPER_FLAG (binfo);
+         BINFO_VTABLE (new_binfo) = BINFO_VTABLE (binfo);
+         TYPE_BINFO (class) = new_binfo;
+       }
+      
       /* And add the interface */
       parser_add_interface (class_decl, type_decl, wfl);
     }
@@ -3883,12 +4042,15 @@ patch_anonymous_class (tree type_decl, tree class_decl, tree wfl)
     {
       if (parser_check_super (type_decl, class_decl, wfl))
        return;
-      BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (binfo), 0)) = type;
+      BINFO_TYPE (BINFO_BASE_BINFO (binfo, 0)) = type;
     }
 }
 
+/* Create an anonymous class which extends/implements TYPE_NAME, and return
+   its decl.  */
+
 static tree
-create_anonymous_class (int location, tree type_name)
+create_anonymous_class (tree type_name)
 {
   char buffer [80];
   tree super = NULL_TREE, itf = NULL_TREE;
@@ -3897,7 +4059,7 @@ create_anonymous_class (int location, tree type_name)
   /* The unqualified name of the anonymous class. It's just a number. */
   sprintf (buffer, "%d", anonymous_class_counter++);
   id = build_wfl_node (get_identifier (buffer));
-  EXPR_WFL_LINECOL (id) = location;
+  EXPR_WFL_LINECOL (id) = EXPR_WFL_LINECOL (type_name);
 
   /* We know about the type to extend/implement. We go ahead */
   if ((type_decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (type_name))))
@@ -3971,7 +4133,7 @@ create_class (int flags, tree id, tree super, tree interfaces)
        - Public classes defined in the correct file */
   if ((flags & ACC_ABSTRACT) && (flags & ACC_FINAL))
     parse_error_context
-      (id, "Class `%s' can't be declared both abstract and final",
+      (id, "Class %qs can't be declared both abstract and final",
        IDENTIFIER_POINTER (raw_name));
 
   /* Create a new decl if DECL is NULL, otherwise fix it */
@@ -3980,10 +4142,10 @@ create_class (int flags, tree id, tree super, tree interfaces)
   /* If SUPER exists, use it, otherwise use Object */
   if (super)
     {
-      /* Can't extend java.lang.Object */
+      /* java.lang.Object can't extend anything.  */
       if (TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_id)) == object_type_node)
        {
-         parse_error_context (id, "Can't extend `java.lang.Object'");
+         parse_error_context (id, "%<java.lang.Object%> can't extend anything");
          return NULL_TREE;
        }
 
@@ -4010,17 +4172,23 @@ create_class (int flags, tree id, tree super, tree interfaces)
   CLASS_COMPLETE_P (decl) = 1;
   add_superinterfaces (decl, interfaces);
 
+  /* TYPE_VFIELD' is a compiler-generated field used to point to
+     virtual function tables.  In gcj, every class has a common base
+     virtual function table in java.lang.object.  */
+  TYPE_VFIELD (TREE_TYPE (decl)) = TYPE_VFIELD (object_type_node);
+
+  /* We keep the compilation unit imports in the class so that
+     they can be used later to resolve type dependencies that
+     aren't necessary to solve now. */
+  TYPE_IMPORT_LIST (TREE_TYPE (decl)) = ctxp->import_list;
+  TYPE_IMPORT_DEMAND_LIST (TREE_TYPE (decl)) = ctxp->import_demand_list;
+
   /* Add the private this$<n> field, Replicate final locals still in
      scope as private final fields mangled like val$<local_name>.
-     This doesn't not occur for top level (static) inner classes. */
+     This does not occur for top level (static) inner classes. */
   if (PURE_INNER_CLASS_DECL_P (decl))
     add_inner_class_fields (decl, current_function_decl);
 
-  /* If doing xref, store the location at which the inherited class
-     (if any) was seen. */
-  if (flag_emit_xref && super)
-    DECL_INHERITED_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (super);
-
   /* Eventually sets the @deprecated tag flag */
   CHECK_DEPRECATED (decl);
 
@@ -4220,7 +4388,7 @@ duplicate_declaration_error_p (tree new_field_name, tree new_type, tree cl)
                          IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (decl))) :
                          lang_printable_name (TREE_TYPE (decl), 1)));
       parse_error_context
-       (cl , "Duplicate variable declaration: `%s %s' was `%s %s' (%s:%d)",
+       (cl, "Duplicate variable declaration: %<%s %s%> was %<%s %s%> (%s:%d)",
         t1, IDENTIFIER_POINTER (new_field_name),
         t2, IDENTIFIER_POINTER (DECL_NAME (decl)),
         DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
@@ -4240,7 +4408,7 @@ register_fields (int flags, tree type, tree variable_list)
 {
   tree current, saved_type;
   tree class_type = NULL_TREE;
-  int saved_lineno = input_line;
+  location_t saved_location = input_location;
   int must_chain = 0;
   tree wfl = NULL_TREE;
 
@@ -4260,7 +4428,7 @@ register_fields (int flags, tree type, tree variable_list)
                                 flags, ACC_STATIC, "interface field(s)");
       OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (FINAL_TK),
                                 flags, ACC_FINAL, "interface field(s)");
-      check_modifiers ("Illegal interface member modifier `%s'", flags,
+      check_modifiers ("Illegal interface member modifier %qs", flags,
                       INTERFACE_FIELD_MODIFIERS);
       flags |= (ACC_PUBLIC | ACC_STATIC | ACC_FINAL);
     }
@@ -4284,7 +4452,7 @@ register_fields (int flags, tree type, tree variable_list)
       if ((flags & ACC_STATIC) && !TOPLEVEL_CLASS_TYPE_P (class_type)
           && !(flags & ACC_FINAL))
        parse_error_context
-          (cl, "Field `%s' can't be static in inner class `%s' unless it is final",
+          (cl, "Field %qs can't be static in inner class %qs unless it is final",
           IDENTIFIER_POINTER (EXPR_WFL_NODE (cl)),
           lang_printable_name (class_type, 0));
 
@@ -4307,12 +4475,13 @@ register_fields (int flags, tree type, tree variable_list)
       if (duplicate_declaration_error_p (current_name, real_type, cl))
        continue;
 
-      /* Set lineno to the line the field was found and create a
+      /* Set input_line to the line the field was found and create a
          declaration for it. Eventually sets the @deprecated tag flag. */
-      if (flag_emit_xref)
-       input_line = EXPR_WFL_LINECOL (cl);
-      else
-       input_line = EXPR_WFL_LINENO (cl);
+#ifdef USE_MAPPED_LOCATION
+      input_location = EXPR_LOCATION (cl);
+#else
+      input_line = EXPR_WFL_LINENO (cl);
+#endif
       field_decl = add_field (class_type, current_name, real_type, flags);
       CHECK_DEPRECATED_NO_RESET (field_decl);
 
@@ -4374,7 +4543,7 @@ register_fields (int flags, tree type, tree variable_list)
     }
 
   CLEAR_DEPRECATED;
-  input_line = saved_lineno;
+  input_location = saved_location;
 }
 
 /* Generate finit$, using the list of initialized fields to populate
@@ -4495,7 +4664,7 @@ method_header (int flags, tree type, tree mdecl, tree throws)
   tree meth_name = NULL_TREE;
   tree current, orig_arg, this_class = NULL;
   tree id, meth;
-  int saved_lineno;
+  location_t saved_location;
   int constructor_ok = 0, must_chain;
   int count;
 
@@ -4525,21 +4694,22 @@ method_header (int flags, tree type, tree mdecl, tree throws)
       if (!CLASS_ABSTRACT (TYPE_NAME (this_class))
          && !CLASS_INTERFACE (TYPE_NAME (this_class)))
        parse_error_context
-         (id, "Class `%s' must be declared abstract to define abstract method `%s'",
+         (id,
+           "Class %qs must be declared abstract to define abstract method %qs",
           IDENTIFIER_POINTER (DECL_NAME (GET_CPC ())),
           IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
     }
 
   /* A native method can't be strictfp.  */
   if ((flags & ACC_NATIVE) && (flags & ACC_STRICT))
-    parse_error_context (id, "native method `%s' can't be strictfp",
+    parse_error_context (id, "native method %qs can't be strictfp",
                         IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
   /* No such thing as a transient or volatile method.  */
   if ((flags & ACC_TRANSIENT))
-    parse_error_context (id, "method `%s' can't be transient",
+    parse_error_context (id, "method %qs can't be transient",
                         IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
   if ((flags & ACC_VOLATILE))
-    parse_error_context (id, "method `%s' can't be volatile",
+    parse_error_context (id, "method %qs can't be volatile",
                         IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
 
   /* Things to be checked when declaring a constructor */
@@ -4589,7 +4759,7 @@ method_header (int flags, tree type, tree mdecl, tree throws)
   if ((flags & ACC_STATIC) && !TOPLEVEL_CLASS_TYPE_P (this_class))
     {
       parse_error_context
-       (id, "Method `%s' can't be static in inner class `%s'. Only members of interfaces and top-level classes can be static",
+       (id, "Method %qs can't be static in inner class %qs. Only members of interfaces and top-level classes can be static",
         IDENTIFIER_POINTER (EXPR_WFL_NODE (id)),
         lang_printable_name (this_class, 0));
     }
@@ -4626,12 +4796,17 @@ method_header (int flags, tree type, tree mdecl, tree throws)
   else
     TREE_TYPE (meth) = type;
 
-  saved_lineno = input_line;
+  saved_location = input_location;
   /* When defining an abstract or interface method, the curly
      bracket at level 1 doesn't exist because there is no function
      body */
-  input_line = (ctxp->first_ccb_indent1 ? ctxp->first_ccb_indent1 :
-           EXPR_WFL_LINENO (id));
+#ifdef USE_MAPPED_LOCATION
+  input_location = (ctxp->first_ccb_indent1 ? ctxp->first_ccb_indent1 :
+                   EXPR_LOCATION (id));
+#else
+  input_line = (ctxp->first_ccb_indent1 ? (int) ctxp->first_ccb_indent1 :
+               EXPR_WFL_LINENO (id));
+#endif
 
   /* Remember the original argument list */
   orig_arg = TYPE_ARG_TYPES (meth);
@@ -4664,7 +4839,7 @@ method_header (int flags, tree type, tree mdecl, tree throws)
   /* Register the parameter number and re-install the current line
      number */
   DECL_MAX_LOCALS (meth) = ctxp->formal_parameter_number+1;
-  input_line = saved_lineno;
+  input_location = saved_location;
 
   /* Register exception specified by the `throws' keyword for
      resolution and set the method decl appropriate field to the list.
@@ -4702,11 +4877,6 @@ method_header (int flags, tree type, tree mdecl, tree throws)
   /* Eventually set the @deprecated tag flag */
   CHECK_DEPRECATED (meth);
 
-  /* If doing xref, store column and line number information instead
-     of the line number only. */
-  if (flag_emit_xref)
-    DECL_SOURCE_LINE (meth) = EXPR_WFL_LINECOL (id);
-
   return meth;
 }
 
@@ -4744,7 +4914,7 @@ finish_method_declaration (tree method_body)
     {
       tree name = DECL_NAME (current_function_decl);
       parse_error_context (DECL_FUNCTION_WFL (current_function_decl),
-                          "%s method `%s' can't have a body defined",
+                          "%s method %qs can't have a body defined",
                           (METHOD_NATIVE (current_function_decl) ?
                            "Native" : "Abstract"),
                           IDENTIFIER_POINTER (name));
@@ -4755,7 +4925,7 @@ finish_method_declaration (tree method_body)
       tree name = DECL_NAME (current_function_decl);
       parse_error_context
        (DECL_FUNCTION_WFL (current_function_decl),
-        "Non native and non abstract method `%s' must have a body defined",
+        "Non native and non abstract method %qs must have a body defined",
         IDENTIFIER_POINTER (name));
       method_body = NULL_TREE;
     }
@@ -4772,8 +4942,7 @@ finish_method_declaration (tree method_body)
   exit_block ();
   /* Merge last line of the function with first line, directly in the
      function decl. It will be used to emit correct debug info. */
-  if (!flag_emit_xref)
-    DECL_FUNCTION_LAST_LINE (current_function_decl) = ctxp->last_ccb_indent1;
+  DECL_FUNCTION_LAST_LINE (current_function_decl) = ctxp->last_ccb_indent1;
 
   /* Since function's argument's list are shared, reset the
      ARG_FINAL_P parameter that might have been set on some of this
@@ -4791,8 +4960,8 @@ static char *
 constructor_circularity_msg (tree from, tree to)
 {
   static char string [4096];
-  char *t = xstrdup (lang_printable_name (from, 0));
-  sprintf (string, "`%s' invokes `%s'", t, lang_printable_name (to, 0));
+  char *t = xstrdup (lang_printable_name (from, 2));
+  sprintf (string, "'%s' invokes '%s'", t, lang_printable_name (to, 2));
   free (t);
   return string;
 }
@@ -4824,9 +4993,9 @@ verify_constructor_circularity (tree meth, tree current)
                  java_error_count--;
                }
            }
-         t = xstrdup (lang_printable_name (meth, 0));
+         t = xstrdup (lang_printable_name (meth, 2));
          parse_error_context (TREE_PURPOSE (c),
-                              "%s: recursive invocation of constructor `%s'",
+                              "%s: recursive invocation of constructor %qs",
                               constructor_circularity_msg (current, meth), t);
          free (t);
          vcc_list = NULL_TREE;
@@ -4856,7 +5025,7 @@ check_modifiers_consistency (int flags)
   THIS_MODIFIER_ONLY (flags, ACC_PROTECTED, PROTECTED_TK, acc_count, cl);
   if (acc_count > 1)
     parse_error_context
-      (cl, "Inconsistent member declaration.  At most one of `public', `private', or `protected' may be specified");
+      (cl, "Inconsistent member declaration.  At most one of %<public%>, %<private%>, or %<protected%> may be specified");
 
   acc_count = 0;
   cl = NULL_TREE;
@@ -4864,7 +5033,7 @@ check_modifiers_consistency (int flags)
   THIS_MODIFIER_ONLY (flags, ACC_VOLATILE, VOLATILE_TK, acc_count, cl);
   if (acc_count > 1)
     parse_error_context (cl,
-                        "Inconsistent member declaration.  At most one of `final' or `volatile' may be specified");
+                        "Inconsistent member declaration.  At most one of %<final%> or %<volatile%> may be specified");
 }
 
 /* Check the methode header METH for abstract specifics features */
@@ -4881,7 +5050,7 @@ check_abstract_method_header (tree meth)
                              ACC_PUBLIC, "abstract method",
                              IDENTIFIER_POINTER (DECL_NAME (meth)));
 
-  check_modifiers ("Illegal modifier `%s' for interface method",
+  check_modifiers ("Illegal modifier %qs for interface method",
                  flags, INTERFACE_METHOD_MODIFIERS);
 }
 
@@ -4954,7 +5123,7 @@ method_declarator (tree id, tree list)
        if (TREE_PURPOSE (already) == name)
          {
            parse_error_context
-             (wfl_name, "Variable `%s' is used more than once in the argument list of method `%s'",
+             (wfl_name, "Variable %qs is used more than once in the argument list of method %qs",
               IDENTIFIER_POINTER (name),
               IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
            break;
@@ -4989,7 +5158,6 @@ method_declarator (tree id, tree list)
 
 static int
 unresolved_type_p (tree wfl, tree *returned)
-
 {
   if (TREE_CODE (wfl) == EXPR_WITH_FILE_LOCATION)
     {
@@ -5039,7 +5207,7 @@ parser_check_super_interface (tree super_decl, tree this_decl, tree this_wfl)
   if (!CLASS_INTERFACE (super_decl))
     {
       parse_error_context
-       (this_wfl, "%s `%s' can't implement/extend %s `%s'",
+       (this_wfl, "%s %qs can't implement/extend %s %qs",
         (CLASS_INTERFACE (TYPE_NAME (TREE_TYPE (this_decl))) ?
          "Interface" : "Class"),
         IDENTIFIER_POINTER (DECL_NAME (this_decl)),
@@ -5052,7 +5220,7 @@ parser_check_super_interface (tree super_decl, tree this_decl, tree this_wfl)
      access rules (6.6.1). */
   if (! INNER_CLASS_P (super_type)
       && check_pkg_class_access (DECL_NAME (super_decl),
-                                lookup_cl (this_decl), true))
+                                NULL_TREE, true, this_decl))
     return 1;
 
   SOURCE_FRONTEND_DEBUG (("Completing interface %s with %s",
@@ -5073,7 +5241,7 @@ parser_check_super (tree super_decl, tree this_decl, tree wfl)
   if (TYPE_ARRAY_P (super_type) || CLASS_INTERFACE (TYPE_NAME (super_type)))
     {
       parse_error_context
-       (wfl, "Class `%s' can't subclass %s `%s'",
+       (wfl, "Class %qs can't subclass %s %qs",
         IDENTIFIER_POINTER (DECL_NAME (this_decl)),
         (CLASS_INTERFACE (TYPE_NAME (super_type)) ? "interface" : "array"),
         IDENTIFIER_POINTER (DECL_NAME (super_decl)));
@@ -5090,7 +5258,7 @@ parser_check_super (tree super_decl, tree this_decl, tree wfl)
   /* Check top-level class scope. Inner classes are subject to member access
      rules (6.6.1). */
   if (! INNER_CLASS_P (super_type)
-      && (check_pkg_class_access (DECL_NAME (super_decl), wfl, true)))
+      && (check_pkg_class_access (DECL_NAME (super_decl), wfl, true, NULL_TREE)))
     return 1;
 
   SOURCE_FRONTEND_DEBUG (("Completing class %s with %s",
@@ -5114,7 +5282,7 @@ create_jdep_list (struct parser_ctxt *ctxp)
 static jdeplist *
 reverse_jdep_list (struct parser_ctxt *ctxp)
 {
-  register jdeplist *prev = NULL, *current, *next;
+  jdeplist *prev = NULL, *current, *next;
   for (current = ctxp->classd_list; current; current = next)
     {
       next = current->next;
@@ -5169,12 +5337,9 @@ register_incomplete_type (int kind, tree wfl, tree decl, tree ptr)
   JDEP_MISC (new) = NULL_TREE;
   /* For some dependencies, set the enclosing class of the current
      class to be the enclosing context */
-  if ((kind == JDEP_INTERFACE  || kind == JDEP_ANONYMOUS)
+  if ((kind == JDEP_INTERFACE || kind == JDEP_ANONYMOUS || kind == JDEP_SUPER)
       && GET_ENCLOSING_CPC ())
     JDEP_ENCLOSING (new) = TREE_VALUE (GET_ENCLOSING_CPC ());
-  else if (kind == JDEP_SUPER)
-    JDEP_ENCLOSING (new) = (GET_ENCLOSING_CPC () ?
-                           TREE_VALUE (GET_ENCLOSING_CPC ()) : NULL_TREE);
   else
     JDEP_ENCLOSING (new) = GET_CPC ();
   JDEP_GET_PATCH (new) = (tree *)NULL;
@@ -5195,23 +5360,18 @@ register_incomplete_type (int kind, tree wfl, tree decl, tree ptr)
 static tree
 check_inner_circular_reference (tree source, tree target)
 {
-  tree basetype_vec = TYPE_BINFO_BASETYPES (source);
+  tree base_binfo;
   tree ctx, cl;
   int i;
 
-  if (!basetype_vec)
-    return NULL_TREE;
-
-  for (i = 0; i < TREE_VEC_LENGTH (basetype_vec); i++)
+  for (i = 0; BINFO_BASE_ITERATE (TYPE_BINFO (source), i, base_binfo); i++)
     {
       tree su;
 
       /* We can end up with a NULL_TREE or an incomplete type here if
         we encountered previous type resolution errors. It's safe to
         simply ignore these cases.  */
-      if (TREE_VEC_ELT (basetype_vec, i) == NULL_TREE)
-       continue;
-      su = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
+      su = BINFO_TYPE (base_binfo);
       if (INCOMPLETE_TYPE_P (su))
        continue;
 
@@ -5241,10 +5401,10 @@ check_inner_circular_reference (tree source, tree target)
 static tree
 check_circular_reference (tree type)
 {
-  tree basetype_vec = TYPE_BINFO_BASETYPES (type);
+  tree base_binfo;
   int i;
 
-  if (!basetype_vec)
+  if (!BINFO_N_BASE_BINFOS (TYPE_BINFO (type)))
     return NULL_TREE;
 
   if (! CLASS_INTERFACE (TYPE_NAME (type)))
@@ -5254,12 +5414,11 @@ check_circular_reference (tree type)
       return NULL_TREE;
     }
 
-  for (i = 0; i < TREE_VEC_LENGTH (basetype_vec); i++)
+  for (i = 0; BINFO_BASE_ITERATE (TYPE_BINFO (type), i, base_binfo); i++)
     {
-      tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
-      if (vec_elt && BINFO_TYPE (vec_elt) != object_type_node
-         && interface_of_p (type, BINFO_TYPE (vec_elt)))
-       return lookup_cl (TYPE_NAME (BINFO_TYPE (vec_elt)));
+      if (BINFO_TYPE (base_binfo) != object_type_node
+         && interface_of_p (type, BINFO_TYPE (base_binfo)))
+       return lookup_cl (TYPE_NAME (BINFO_TYPE (base_binfo)));
     }
   return NULL_TREE;
 }
@@ -5374,19 +5533,14 @@ craft_constructor (tree class_decl, tree args)
 {
   tree class_type = TREE_TYPE (class_decl);
   tree parm = NULL_TREE;
-  int flags = (get_access_flags_from_decl (class_decl) & ACC_PUBLIC ?
-              ACC_PUBLIC : 0);
+  /* Inherit access flags for the constructor from its enclosing class. */
+  int valid_ctor_flags = ACC_PUBLIC | ACC_PROTECTED | ACC_PRIVATE;
+  int flags = (get_access_flags_from_decl (class_decl) & valid_ctor_flags);
   int i = 0, artificial = 0;
   tree decl, ctor_name;
   char buffer [80];
 
-  /* The constructor name is <init> unless we're dealing with an
-     anonymous class, in which case the name will be fixed after having
-     be expanded. */
-  if (ANONYMOUS_CLASS_P (class_type))
-    ctor_name = DECL_NAME (class_decl);
-  else
-    ctor_name = init_identifier_node;
+  ctor_name = init_identifier_node;
 
   /* If we're dealing with an inner class constructor, we hide the
      this$<n> decl in the name field of its parameter declaration. */
@@ -5406,6 +5560,10 @@ craft_constructor (tree class_decl, tree args)
   /* Then if there are any args to be enforced, enforce them now */
   for (; args && args != end_params_node; args = TREE_CHAIN (args))
     {
+      /* If we see a `void *', we need to change it to Object.  */
+      if (TREE_VALUE (args) == TREE_TYPE (null_pointer_node))
+       TREE_VALUE (args) = object_ptr_type_node;
+
       sprintf (buffer, "parm%d", i++);
       parm = tree_cons (get_identifier (buffer), TREE_VALUE (args), parm);
     }
@@ -5442,7 +5600,7 @@ java_fix_constructors (void)
       if (CLASS_INTERFACE (TYPE_NAME (class_type)))
        continue;
 
-      current_class = class_type;
+      output_class = current_class = class_type;
       for (decl = TYPE_METHODS (class_type); decl; decl = TREE_CHAIN (decl))
        {
          if (DECL_CONSTRUCTOR_P (decl))
@@ -5459,7 +5617,7 @@ java_fix_constructors (void)
 }
 
 /* safe_layout_class just makes sure that we can load a class without
-   disrupting the current_class, input_file, lineno, etc, information
+   disrupting the current_class, input_file, input_line, etc, information
    about the class processed currently.  */
 
 void
@@ -5494,7 +5652,7 @@ jdep_resolve_class (jdep *dep)
 
   if (!decl)
     complete_class_report_errors (dep);
-  else if (PURE_INNER_CLASS_DECL_P (decl))
+  else if (INNER_CLASS_DECL_P (decl))
     {
       tree inner = TREE_TYPE (decl);
       if (! CLASS_LOADED_P (inner))
@@ -5531,12 +5689,6 @@ java_complete_class (void)
     {
       jdep *dep;
 
-      /* We keep the compilation unit imports in the class so that
-        they can be used later to resolve type dependencies that
-        aren't necessary to solve now. */
-      TYPE_IMPORT_LIST (TREE_TYPE (cclass)) = ctxp->import_list;
-      TYPE_IMPORT_DEMAND_LIST (TREE_TYPE (cclass)) = ctxp->import_demand_list;
-
       for (dep = CLASSD_FIRST (cclassd); dep; dep = JDEP_CHAIN (dep))
        {
          tree decl;
@@ -5550,8 +5702,9 @@ java_complete_class (void)
              /* Simply patch super */
              if (parser_check_super (decl, JDEP_DECL (dep), JDEP_WFL (dep)))
                continue;
-             BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO
-               (TREE_TYPE (JDEP_DECL (dep)))), 0)) = TREE_TYPE (decl);
+             BINFO_TYPE (BINFO_BASE_BINFO
+                         (TYPE_BINFO (TREE_TYPE (JDEP_DECL (dep))), 0))
+               = TREE_TYPE (decl);
              break;
 
            case JDEP_FIELD:
@@ -5566,7 +5719,7 @@ java_complete_class (void)
                DECL_USER_ALIGN (field_decl) = 0;
                layout_decl (field_decl, 0);
                SOURCE_FRONTEND_DEBUG
-                 (("Completed field/var decl `%s' with `%s'",
+                 (("Completed field/var decl '%s' with '%s'",
                    IDENTIFIER_POINTER (DECL_NAME (field_decl)),
                    IDENTIFIER_POINTER (DECL_NAME (decl))));
                break;
@@ -5584,8 +5737,8 @@ java_complete_class (void)
                      JDEP_APPLY_PATCH (dep, type);
                      SOURCE_FRONTEND_DEBUG
                        (((JDEP_KIND (dep) == JDEP_METHOD_RETURN ?
-                          "Completing fct `%s' with ret type `%s'":
-                          "Completing arg `%s' with type `%s'"),
+                          "Completing fct '%s' with ret type '%s'":
+                          "Completing arg '%s' with type '%s'"),
                          IDENTIFIER_POINTER (EXPR_WFL_NODE
                                              (JDEP_DECL_WFL (dep))),
                          IDENTIFIER_POINTER (DECL_NAME (decl))));
@@ -5639,7 +5792,7 @@ java_complete_class (void)
            case JDEP_EXCEPTION:
              JDEP_APPLY_PATCH (dep, TREE_TYPE (decl));
              SOURCE_FRONTEND_DEBUG
-               (("Completing `%s' `throws' argument node",
+               (("Completing '%s' 'throws' argument node",
                  IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep)))));
              break;
 
@@ -5686,7 +5839,7 @@ resolve_class (tree enclosing, tree class_type, tree decl, tree cl)
     WFL_STRIP_BRACKET (cl, cl);
 
   /* 2- Resolve the bare type */
-  if (!(resolved_type_decl = do_resolve_class (enclosing, class_type,
+  if (!(resolved_type_decl = do_resolve_class (enclosing, NULL_TREE, class_type,
                                               decl, cl)))
     return NULL_TREE;
   resolved_type = TREE_TYPE (resolved_type_decl);
@@ -5709,7 +5862,8 @@ resolve_class (tree enclosing, tree class_type, tree decl, tree cl)
    and (but it doesn't really matter) qualify_and_find.  */
 
 tree
-do_resolve_class (tree enclosing, tree class_type, tree decl, tree cl)
+do_resolve_class (tree enclosing, tree import_type, tree class_type, tree decl,
+                 tree cl)
 {
   tree new_class_decl = NULL_TREE, super = NULL_TREE;
   tree saved_enclosing_type = enclosing ? TREE_TYPE (enclosing) : NULL_TREE;
@@ -5723,10 +5877,10 @@ do_resolve_class (tree enclosing, tree class_type, tree decl, tree cl)
         class and then treat Id as a member type.  If we can't find Q
         as a class then we fall through.  */
       tree q, left, left_type, right;
-      if (breakdown_qualified (&left, &right, TYPE_NAME (class_type)) == 0)
+      if (split_qualified_name (&left, &right, TYPE_NAME (class_type)) == 0)
        {
          BUILD_PTR_FROM_NAME (left_type, left);
-         q = do_resolve_class (enclosing, left_type, decl, cl);
+         q = do_resolve_class (enclosing, import_type, left_type, decl, cl);
          if (q)
            {
              enclosing = q;
@@ -5771,15 +5925,17 @@ do_resolve_class (tree enclosing, tree class_type, tree decl, tree cl)
        return new_class_decl;
     }
 
-  /* 1- Check for the type in single imports. This will change
-     TYPE_NAME() if something relevant is found */
+  /* 1- Check for the type in single imports.  Look at enclosing classes and,
+     if we're laying out a superclass, at the import list for the subclass.
+     This will change TYPE_NAME() if something relevant is found. */
+  if (import_type && TYPE_IMPORT_LIST (import_type))
+    find_in_imports (import_type, class_type);
   find_in_imports (saved_enclosing_type, class_type);
 
   /* 2- And check for the type in the current compilation unit */
   if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
     {
-      if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
-         !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
+      if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)))
        load_class (TYPE_NAME (class_type), 0);
       return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
     }
@@ -5795,30 +5951,20 @@ do_resolve_class (tree enclosing, tree class_type, tree decl, tree cl)
   /* 4- Check the import on demands. Don't allow bar.baz to be
      imported from foo.* */
   if (!QUALIFIED_P (TYPE_NAME (class_type)))
-    if (find_in_imports_on_demand (saved_enclosing_type, class_type))
-      return NULL_TREE;
+    {
+      if (import_type
+         && TYPE_IMPORT_DEMAND_LIST (import_type)
+         && find_in_imports_on_demand (import_type, class_type))
+        return NULL_TREE;
+      if (find_in_imports_on_demand (saved_enclosing_type, class_type))
+        return NULL_TREE;
+    }
 
   /* If found in find_in_imports_on_demand, the type has already been
      loaded. */
   if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
     return new_class_decl;
 
-  /* 5- Try with a name qualified with the package name we've seen so far */
-  if (!QUALIFIED_P (TYPE_NAME (class_type)))
-    {
-      tree package;
-
-      /* If there is a current package (ctxp->package), it's the first
-        element of package_list and we can skip it. */
-      for (package = (ctxp->package ?
-                     TREE_CHAIN (package_list) : package_list);
-          package; package = TREE_CHAIN (package))
-       if ((new_class_decl = qualify_and_find (class_type,
-                                              TREE_PURPOSE (package),
-                                              TYPE_NAME (class_type))))
-         return new_class_decl;
-    }
-
   /* 5- Check another compilation unit that bears the name of type */
   load_class (TYPE_NAME (class_type), 0);
 
@@ -5830,7 +5976,7 @@ do_resolve_class (tree enclosing, tree class_type, tree decl, tree cl)
      by the caller. */
   if (cl)
     {
-      if (check_pkg_class_access (TYPE_NAME (class_type), cl, true))
+      if (check_pkg_class_access (TYPE_NAME (class_type), cl, true, NULL_TREE))
         return NULL_TREE;
     }
 
@@ -5873,9 +6019,8 @@ qualify_and_find (tree class_type, tree package, tree name)
     load_class (new_qualified, 0);
   if ((new_class_decl = IDENTIFIER_CLASS_VALUE (new_qualified)))
     {
-      if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
-         !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
-       load_class (new_qualified, 0);
+      if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)))
+       load_class (TREE_TYPE (new_class_decl), 0);
       TYPE_NAME (class_type) = new_qualified;
       return IDENTIFIER_CLASS_VALUE (new_qualified);
     }
@@ -5994,46 +6139,46 @@ complete_class_report_errors (jdep *dep)
     {
     case JDEP_SUPER:
       parse_error_context
-       (JDEP_WFL (dep), "Superclass `%s' of class `%s' not found",
+       (JDEP_WFL (dep), "Superclass %qs of class %qs not found",
         purify_type_name (name),
         IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
       break;
     case JDEP_FIELD:
       parse_error_context
-       (JDEP_WFL (dep), "Type `%s' not found in declaration of field `%s'",
+       (JDEP_WFL (dep), "Type %qs not found in declaration of field %qs",
         purify_type_name (name),
         IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
       break;
     case JDEP_METHOD:          /* Covers arguments */
       parse_error_context
-       (JDEP_WFL (dep), "Type `%s' not found in the declaration of the argument `%s' of method `%s'",
+       (JDEP_WFL (dep), "Type %qs not found in the declaration of the argument %qs of method %qs",
         purify_type_name (name),
         IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))),
         IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_MISC (dep))));
       break;
     case JDEP_METHOD_RETURN:   /* Covers return type */
       parse_error_context
-       (JDEP_WFL (dep), "Type `%s' not found in the declaration of the return type of method `%s'",
+       (JDEP_WFL (dep), "Type %qs not found in the declaration of the return type of method %qs",
         purify_type_name (name),
         IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))));
       break;
     case JDEP_INTERFACE:
       parse_error_context
-       (JDEP_WFL (dep), "Superinterface `%s' of %s `%s' not found",
+       (JDEP_WFL (dep), "Superinterface %qs of %s %qs not found",
         IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))),
         (CLASS_OR_INTERFACE (JDEP_DECL (dep), "class", "interface")),
         IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
       break;
     case JDEP_VARIABLE:
       parse_error_context
-       (JDEP_WFL (dep), "Type `%s' not found in the declaration of the local variable `%s'",
+       (JDEP_WFL (dep), "Type %qs not found in the declaration of the local variable %qs",
         purify_type_name (IDENTIFIER_POINTER
                           (EXPR_WFL_NODE (JDEP_WFL (dep)))),
         IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
       break;
     case JDEP_EXCEPTION:       /* As specified by `throws' */
       parse_error_context
-         (JDEP_WFL (dep), "Class `%s' not found in `throws'",
+         (JDEP_WFL (dep), "Class %qs not found in %<throws%>",
         IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))));
       break;
     default:
@@ -6059,7 +6204,7 @@ get_printable_method_name (tree decl)
       DECL_NAME (decl) = DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)));
     }
 
-  to_return = lang_printable_name (decl, 0);
+  to_return = lang_printable_name (decl, 2);
   if (DECL_CONSTRUCTOR_P (decl))
     DECL_NAME (decl) = name;
 
@@ -6090,7 +6235,7 @@ check_method_redefinition (tree class, tree method)
          && !DECL_ARTIFICIAL (method))
        {
          parse_error_context
-           (DECL_FUNCTION_WFL (method), "Duplicate %s declaration `%s'",
+           (DECL_FUNCTION_WFL (method), "Duplicate %s declaration %qs",
             (DECL_CONSTRUCTOR_P (redef) ? "constructor" : "method"),
             get_printable_method_name (redef));
          return 1;
@@ -6164,9 +6309,9 @@ check_abstract_method_definitions (int do_interface, tree class_decl,
 
          parse_error_context
            (lookup_cl (class_decl),
-            "Class `%s' doesn't define the abstract method `%s %s' from %s `%s'. This method must be defined or %s `%s' must be declared abstract",
+            "Class %qs doesn't define the abstract method %<%s %s%> from %s %<%s%>. This method must be defined or %s %qs must be declared abstract",
             IDENTIFIER_POINTER (DECL_NAME (class_decl)),
-            t, lang_printable_name (method, 0),
+            t, lang_printable_name (method, 2),
             (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))) ?
              "interface" : "class"),
             IDENTIFIER_POINTER (ccn),
@@ -6181,12 +6326,13 @@ check_abstract_method_definitions (int do_interface, tree class_decl,
     {
       /* Check for implemented interfaces. */
       int i;
-      tree vector = TYPE_BINFO_BASETYPES (type);
-      for (i = 1; ok && vector && i < TREE_VEC_LENGTH (vector); i++)
-       {
-         tree super = BINFO_TYPE (TREE_VEC_ELT (vector, i));
-         ok = check_abstract_method_definitions (1, class_decl, super);
-       }
+      tree base_binfo;
+      
+      for (i = 1;
+          ok && BINFO_BASE_ITERATE (TYPE_BINFO (type), i, base_binfo);
+          i++)
+       ok = check_abstract_method_definitions (1, class_decl,
+                                               BINFO_TYPE (base_binfo));
     }
 
   return ok;
@@ -6199,7 +6345,7 @@ static void
 java_check_abstract_method_definitions (tree class_decl)
 {
   tree class = TREE_TYPE (class_decl);
-  tree super, vector;
+  tree super, base_binfo;
   int i;
 
   if (CLASS_ABSTRACT (class_decl))
@@ -6213,12 +6359,8 @@ java_check_abstract_method_definitions (tree class_decl)
   } while (super != object_type_node);
 
   /* Check for implemented interfaces. */
-  vector = TYPE_BINFO_BASETYPES (class);
-  for (i = 1; i < TREE_VEC_LENGTH (vector); i++)
-    {
-      super = BINFO_TYPE (TREE_VEC_ELT (vector, i));
-      check_abstract_method_definitions (1, class_decl, super);
-    }
+  for (i = 1; BINFO_BASE_ITERATE (TYPE_BINFO (class), i, base_binfo); i++)
+    check_abstract_method_definitions (1, class_decl, BINFO_TYPE (base_binfo));
 }
 
 /* Check all the types method DECL uses and return 1 if all of them
@@ -6323,7 +6465,7 @@ java_check_regular_methods (tree class_decl)
        {
          if (!inherits_from_p (TREE_VALUE (mthrows), throwable_type_node))
            parse_error_context
-             (TREE_PURPOSE (mthrows), "Class `%s' in `throws' clause must be a subclass of class `java.lang.Throwable'",
+             (TREE_PURPOSE (mthrows), "Class %qs in %<throws%> clause must be a subclass of class %<java.lang.Throwable%>",
               IDENTIFIER_POINTER
                 (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))));
        }
@@ -6346,8 +6488,8 @@ java_check_regular_methods (tree class_decl)
        {
          char *t = xstrdup (lang_printable_name (class, 0));
          parse_error_context
-           (method_wfl, "Method `%s' can't be static in inner class `%s'. Only members of interfaces and top-level classes can be static",
-            lang_printable_name (method, 0), t);
+           (method_wfl, "Method %qs can't be static in inner class %qs. Only members of interfaces and top-level classes can be static",
+            lang_printable_name (method, 2), t);
          free (t);
        }
 
@@ -6367,9 +6509,9 @@ java_check_regular_methods (tree class_decl)
          && !METHOD_PUBLIC (method))
        {
          tree found_decl = TYPE_NAME (DECL_CONTEXT (found));
-         parse_error_context (method_wfl, "Class `%s' must override `%s' with a public method in order to implement interface `%s'",
+         parse_error_context (method_wfl, "Class %qs must override %qs with a public method in order to implement interface %qs",
                               IDENTIFIER_POINTER (DECL_NAME (class_decl)),
-                              lang_printable_name (method, 0),
+                              lang_printable_name (method, 2),
                               IDENTIFIER_POINTER (DECL_NAME (found_decl)));
        }
 
@@ -6378,11 +6520,11 @@ java_check_regular_methods (tree class_decl)
       if (TREE_TYPE (TREE_TYPE (found)) != TREE_TYPE (TREE_TYPE (method)))
        {
          char *t = xstrdup
-           (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0));
+           (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 2));
          parse_error_context
            (method_wfl,
-            "Method `%s' was defined with return type `%s' in class `%s'",
-            lang_printable_name (found, 0), t,
+            "Method %qs was defined with return type %qs in class %qs",
+            lang_printable_name (found, 2), t,
             IDENTIFIER_POINTER
               (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
          free (t);
@@ -6398,9 +6540,9 @@ java_check_regular_methods (tree class_decl)
            continue;
          parse_error_context
            (method_wfl,
-            "%s methods can't be overridden. Method `%s' is %s in class `%s'",
+            "%s methods can't be overridden. Method %qs is %s in class %qs",
             (METHOD_FINAL (found) ? "Final" : "Static"),
-            lang_printable_name (found, 0),
+            lang_printable_name (found, 2),
             (METHOD_FINAL (found) ? "final" : "static"),
             IDENTIFIER_POINTER
               (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
@@ -6412,8 +6554,8 @@ java_check_regular_methods (tree class_decl)
        {
          parse_error_context
            (method_wfl,
-            "Instance methods can't be overridden by a static method. Method `%s' is an instance method in class `%s'",
-            lang_printable_name (found, 0),
+            "Instance methods can't be overridden by a static method. Method %qs is an instance method in class %qs",
+            lang_printable_name (found, 2),
             IDENTIFIER_POINTER
               (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
          continue;
@@ -6435,7 +6577,7 @@ java_check_regular_methods (tree class_decl)
        {
          parse_error_context
            (method_wfl,
-            "Methods can't be overridden to be more private. Method `%s' is not %s in class `%s'", lang_printable_name (method, 0),
+            "Methods can't be overridden to be more private. Method %qs is not %s in class %qs", lang_printable_name (method, 2),
             (METHOD_PUBLIC (method) ? "public" :
              (METHOD_PRIVATE (method) ? "private" : "protected")),
             IDENTIFIER_POINTER (DECL_NAME
@@ -6476,13 +6618,20 @@ check_interface_throws_clauses (tree check_class_decl, tree class_decl)
 {
   for (; class_decl != NULL_TREE; class_decl = CLASSTYPE_SUPER (class_decl))
     {
-      tree bases = TYPE_BINFO_BASETYPES (class_decl);
-      int iface_len = TREE_VEC_LENGTH (bases) - 1;
       int i;
 
-      for (i = iface_len; i > 0; --i)
+      if (! CLASS_LOADED_P (class_decl))
+       {
+         if (CLASS_FROM_SOURCE_P (class_decl))
+           safe_layout_class (class_decl);
+         else
+           load_class (class_decl, 1);
+       }
+
+      for (i = BINFO_N_BASE_BINFOS (TYPE_BINFO (class_decl)) - 1; i > 0; --i)
        {
-         tree interface = BINFO_TYPE (TREE_VEC_ELT (bases, i));
+         tree interface
+           = BINFO_TYPE (BINFO_BASE_BINFO (TYPE_BINFO (class_decl), i));
          tree iface_method;
 
          for (iface_method = TYPE_METHODS (interface);
@@ -6505,7 +6654,8 @@ check_interface_throws_clauses (tree check_class_decl, tree class_decl)
                 Also, multiple inheritance with conflicting throws
                 clauses is fine in the absence of a concrete
                 implementation.  */
-             if (method != NULL_TREE && !METHOD_ABSTRACT (method))
+             if (method != NULL_TREE && !METHOD_ABSTRACT (method)
+                 && !METHOD_INVISIBLE (iface_method))
                {
                  tree method_wfl = DECL_FUNCTION_WFL (method);
                  check_throws_clauses (method, method_wfl, iface_method);
@@ -6546,10 +6696,6 @@ check_throws_clauses (tree method, tree method_wfl, tree found)
 {
   tree mthrows;
 
-  /* Can't check these things with class loaded from bytecode. FIXME */
-  if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (found)))
-    return;
-
   for (mthrows = DECL_FUNCTION_THROWS (method);
        mthrows; mthrows = TREE_CHAIN (mthrows))
     {
@@ -6568,9 +6714,9 @@ check_throws_clauses (tree method, tree method_wfl, tree found)
       if (!fthrows)
        {
          parse_error_context
-           (method_wfl, "Invalid checked exception class `%s' in `throws' clause.  The exception must be a subclass of an exception thrown by `%s' from class `%s'",
+           (method_wfl, "Invalid checked exception class %qs in %<throws%> clause.  The exception must be a subclass of an exception thrown by %qs from class %qs",
             IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))),
-            lang_printable_name (found, 0),
+            lang_printable_name (found, 2),
             IDENTIFIER_POINTER
             (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
        }
@@ -6581,9 +6727,10 @@ check_throws_clauses (tree method, tree method_wfl, tree found)
 static void
 java_check_abstract_methods (tree interface_decl)
 {
-  int i, n;
-  tree method, basetype_vec, found;
+  int i;
+  tree method, found;
   tree interface = TREE_TYPE (interface_decl);
+  tree base_binfo;
 
   for (method = TYPE_METHODS (interface); method; method = TREE_CHAIN (method))
     {
@@ -6596,11 +6743,11 @@ java_check_abstract_methods (tree interface_decl)
       if (found)
        {
          char *t;
-         t = xstrdup (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0));
+         t = xstrdup (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 2));
          parse_error_context
            (DECL_FUNCTION_WFL (found),
-            "Method `%s' was defined with return type `%s' in class `%s'",
-            lang_printable_name (found, 0), t,
+            "Method %qs was defined with return type %qs in class %qs",
+            lang_printable_name (found, 2), t,
             IDENTIFIER_POINTER
               (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
          free (t);
@@ -6609,16 +6756,11 @@ java_check_abstract_methods (tree interface_decl)
     }
 
   /* 4- Inherited methods can't differ by their returned types */
-  if (!(basetype_vec = TYPE_BINFO_BASETYPES (interface)))
-    return;
-  n = TREE_VEC_LENGTH (basetype_vec);
-  for (i = 0; i < n; i++)
+  for (i = 0; BINFO_BASE_ITERATE (TYPE_BINFO (interface), i, base_binfo); i++)
     {
       tree sub_interface_method, sub_interface;
-      tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
-      if (!vec_elt)
-       continue;
-      sub_interface = BINFO_TYPE (vec_elt);
+
+      sub_interface = BINFO_TYPE (base_binfo);
       for (sub_interface_method = TYPE_METHODS (sub_interface);
           sub_interface_method;
           sub_interface_method = TREE_CHAIN (sub_interface_method))
@@ -6629,9 +6771,9 @@ java_check_abstract_methods (tree interface_decl)
            {
              parse_error_context
                (lookup_cl (sub_interface_method),
-                "Interface `%s' inherits method `%s' from interface `%s'. This method is redefined with a different return type in interface `%s'",
+                "Interface %qs inherits method %qs from interface %qs. This method is redefined with a different return type in interface %qs",
                 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (interface))),
-                lang_printable_name (found, 0),
+                lang_printable_name (found, 2),
                 IDENTIFIER_POINTER
                   (DECL_NAME (TYPE_NAME
                               (DECL_CONTEXT (sub_interface_method)))),
@@ -6648,25 +6790,21 @@ java_check_abstract_methods (tree interface_decl)
 static tree
 lookup_java_interface_method2 (tree class, tree method_decl)
 {
-  int i, n;
-  tree basetype_vec = TYPE_BINFO_BASETYPES (class), to_return;
-
-  if (!basetype_vec)
-    return NULL_TREE;
+  int i;
+  tree base_binfo;
+  tree to_return;
 
-  n = TREE_VEC_LENGTH (basetype_vec);
-  for (i = 0; i < n; i++)
+  for (i = 0; BINFO_BASE_ITERATE (TYPE_BINFO (class), i, base_binfo); i++)
     {
-      tree vec_elt = TREE_VEC_ELT (basetype_vec, i), to_return;
-      if ((BINFO_TYPE (vec_elt) != object_type_node)
+      if ((BINFO_TYPE (base_binfo) != object_type_node)
          && (to_return =
-             lookup_java_method2 (BINFO_TYPE (vec_elt), method_decl, 1)))
+             lookup_java_method2 (BINFO_TYPE (base_binfo), method_decl, 1)))
        return to_return;
     }
-  for (i = 0; i < n; i++)
+  for (i = 0; BINFO_BASE_ITERATE (TYPE_BINFO (class), i, base_binfo); i++)
     {
       to_return = lookup_java_interface_method2
-       (BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i)), method_decl);
+       (BINFO_TYPE (base_binfo), method_decl);
       if (to_return)
        return to_return;
     }
@@ -6707,22 +6845,28 @@ lookup_java_method2 (tree clas, tree method_decl, int do_interface)
 }
 
 /* Return the line that matches DECL line number, and try its best to
-   position the column number. Used during error reports.  */
+   position the column number. Used during error reports.
+   FUTURE/FIXME: return source_location instead of node. */
 
 static GTY(()) tree cl_v;
 static tree
 lookup_cl (tree decl)
 {
+#ifndef USE_MAPPED_LOCATION
   char *line, *found;
+#endif
 
   if (!decl)
     return NULL_TREE;
 
   if (cl_v == NULL_TREE)
     {
-      cl_v = build_expr_wfl (NULL_TREE, NULL, 0, 0);
+      cl_v = build_unknown_wfl (NULL_TREE);
     }
 
+#ifdef USE_MAPPED_LOCATION
+  SET_EXPR_LOCATION (cl_v, DECL_SOURCE_LOCATION (decl));
+#else
   EXPR_WFL_FILENAME_NODE (cl_v) = get_identifier (DECL_SOURCE_FILE (decl));
   EXPR_WFL_SET_LINECOL (cl_v, DECL_SOURCE_LINE (decl), -1);
 
@@ -6733,6 +6877,7 @@ lookup_cl (tree decl)
                  (const char *)IDENTIFIER_POINTER (DECL_NAME (decl)));
   if (found)
     EXPR_WFL_SET_LINECOL (cl_v, EXPR_WFL_LINENO (cl_v), found - line);
+#endif
 
   return cl_v;
 }
@@ -6764,14 +6909,14 @@ process_imports (void)
       tree to_be_found = EXPR_WFL_NODE (TREE_PURPOSE (import));
       char *original_name;
 
-      original_name = xmemdup (IDENTIFIER_POINTER (to_be_found),
-                              IDENTIFIER_LENGTH (to_be_found),
-                              IDENTIFIER_LENGTH (to_be_found) + 1);
-
       /* Don't load twice something already defined. */
       if (IDENTIFIER_CLASS_VALUE (to_be_found))
        continue;
 
+      original_name = xmemdup (IDENTIFIER_POINTER (to_be_found),
+                              IDENTIFIER_LENGTH (to_be_found),
+                              IDENTIFIER_LENGTH (to_be_found) + 1);
+
       while (1)
        {
          tree left;
@@ -6779,7 +6924,7 @@ process_imports (void)
          QUALIFIED_P (to_be_found) = 1;
          load_class (to_be_found, 0);
          error_found =
-           check_pkg_class_access (to_be_found, TREE_PURPOSE (import), true);
+           check_pkg_class_access (to_be_found, TREE_PURPOSE (import), true, NULL_TREE);
 
          /* We found it, we can bail out */
          if (IDENTIFIER_CLASS_VALUE (to_be_found))
@@ -6793,7 +6938,7 @@ process_imports (void)
             inner class.  The only way for us to know is to try again
             after having dropped a qualifier. If we can't break it further,
             we have an error. */
-         if (breakdown_qualified (&left, NULL, to_be_found))
+         if (split_qualified_name (&left, NULL, to_be_found))
            break;
 
          to_be_found = left;
@@ -6801,7 +6946,7 @@ process_imports (void)
       if (!IDENTIFIER_CLASS_VALUE (to_be_found))
        {
          parse_error_context (TREE_PURPOSE (import),
-                              "Class or interface `%s' not found in import",
+                              "Class or interface %qs not found in import",
                               original_name);
          error_found = 1;
        }
@@ -6819,8 +6964,12 @@ process_imports (void)
 static void
 find_in_imports (tree enclosing_type, tree class_type)
 {
-  tree import = (enclosing_type ? TYPE_IMPORT_LIST (enclosing_type) :
-                ctxp->import_list);
+  tree import;
+  if (enclosing_type && TYPE_IMPORT_LIST (enclosing_type))
+    import = TYPE_IMPORT_LIST (enclosing_type);
+  else
+    import = ctxp->import_list;
+
   while (import)
     {
       if (TREE_VALUE (import) == TYPE_NAME (class_type))
@@ -6884,7 +7033,7 @@ read_import_dir (tree wfl)
          buffer_grow (filename, entry_length);
          memcpy (filename->data, entry_name, entry_length - 1);
          filename->data[entry_length-1] = '\0';
-         zipf = opendir_in_zip (filename->data, jcf_path_is_system (entry));
+         zipf = opendir_in_zip ((const char *) filename->data, jcf_path_is_system (entry));
          if (zipf == NULL)
            error ("malformed .zip archive in CLASSPATH: %s", entry_name);
          else
@@ -6904,7 +7053,7 @@ read_import_dir (tree wfl)
                  int current_entry_len = zipd->filename_length;
 
                  if (current_entry_len >= BUFFER_LENGTH (filename)
-                     && strncmp (filename->data, current_entry,
+                     && strncmp ((const char *) filename->data, current_entry,
                                  BUFFER_LENGTH (filename)) != 0)
                    continue;
                  found |= note_possible_classname (current_entry,
@@ -6916,7 +7065,7 @@ read_import_dir (tree wfl)
        {
          BUFFER_RESET (filename);
          buffer_grow (filename, entry_length + package_length + 4);
-         strcpy (filename->data, entry_name);
+         strcpy ((char *) filename->data, entry_name);
          filename->ptr = filename->data + entry_length;
          for (k = 0; k < package_length; k++)
            {
@@ -6925,7 +7074,7 @@ read_import_dir (tree wfl)
            }
          *filename->ptr = '\0';
 
-         dirp = opendir (filename->data);
+         dirp = opendir ((const char *) filename->data);
          if (dirp == NULL)
            continue;
          *filename->ptr++ = '/';
@@ -6939,8 +7088,8 @@ read_import_dir (tree wfl)
              d_name = direntp->d_name;
              len = strlen (direntp->d_name);
              buffer_grow (filename, len+1);
-             strcpy (filename->ptr, d_name);
-             found |= note_possible_classname (filename->data + entry_length,
+             strcpy ((char *) filename->ptr, d_name);
+             found |= note_possible_classname ((const char *) filename->data + entry_length,
                                                package_length+len+1);
            }
          if (dirp)
@@ -6957,12 +7106,12 @@ read_import_dir (tree wfl)
       static int first = 1;
       if (first)
        {
-         error ("Can't find default package `%s'. Check the CLASSPATH environment variable and the access to the archives", package_name);
+         error ("Can't find default package %qs. Check the CLASSPATH environment variable and the access to the archives", package_name);
          java_error_count++;
          first = 0;
        }
       else
-       parse_error_context (wfl, "Package `%s' not found in import",
+       parse_error_context (wfl, "Package %qs not found in import",
                             package_name);
       current_jcf = saved_jcf;
       return;
@@ -6978,16 +7127,20 @@ static int
 find_in_imports_on_demand (tree enclosing_type, tree class_type)
 {
   tree class_type_name = TYPE_NAME (class_type);
-  tree import = (enclosing_type ? TYPE_IMPORT_DEMAND_LIST (enclosing_type) :
-                 ctxp->import_demand_list);
   tree cl = NULL_TREE;
   int seen_once = -1;  /* -1 when not set, 1 if seen once, >1 otherwise. */
   int to_return = -1;  /* -1 when not set, 0 or 1 otherwise */
   tree node;
+  tree import;
+
+  if (enclosing_type && TYPE_IMPORT_DEMAND_LIST (enclosing_type))
+    import = TYPE_IMPORT_DEMAND_LIST (enclosing_type);
+  else
+    import = ctxp->import_demand_list;
 
   for (; import; import = TREE_CHAIN (import))
     {
-      int saved_lineno = input_line;
+      location_t saved_location = input_location;
       int access_check;
       const char *id_name;
       tree decl, type_name_copy;
@@ -7004,9 +7157,13 @@ find_in_imports_on_demand (tree enclosing_type, tree class_type)
       if (! (node = maybe_get_identifier (id_name)))
        continue;
 
-      /* Setup lineno so that it refers to the line of the import (in
+      /* Setup input_line so that it refers to the line of the import (in
         case we parse a class file and encounter errors */
+#ifdef USE_MAPPED_LOCATION
+      input_location = EXPR_LOCATION (TREE_PURPOSE (import));
+#else
       input_line = EXPR_WFL_LINENO (TREE_PURPOSE (import));
+#endif
 
       type_name_copy = TYPE_NAME (class_type);
       TYPE_NAME (class_type) = node;
@@ -7015,20 +7172,19 @@ find_in_imports_on_demand (tree enclosing_type, tree class_type)
       access_check = -1;
       /* If there is no DECL set for the class or if the class isn't
         loaded and not seen in source yet, then load */
-      if (!decl || (!CLASS_LOADED_P (TREE_TYPE (decl))
-                   && !CLASS_FROM_SOURCE_P (TREE_TYPE (decl))))
+      if (!decl || ! CLASS_LOADED_P (TREE_TYPE (decl)))
        {
          load_class (node, 0);
          decl = IDENTIFIER_CLASS_VALUE (node);
        }
       if (decl && ! INNER_CLASS_P (TREE_TYPE (decl)))
        access_check = check_pkg_class_access (node, TREE_PURPOSE (import),
-                                              false);
+                                              false, NULL_TREE);
       else
        /* 6.6.1: Inner classes are subject to member access rules. */
        access_check = 0;
 
-      input_line = saved_lineno;
+      input_location = saved_location;
 
       /* If the loaded class is not accessible or couldn't be loaded,
         we restore the original TYPE_NAME and process the next
@@ -7056,7 +7212,7 @@ find_in_imports_on_demand (tree enclosing_type, tree class_type)
              seen_once++;
              parse_error_context
                (location,
-                "Type `%s' also potentially defined in package `%s'",
+                "Type %qs also potentially defined in package %qs",
                 IDENTIFIER_POINTER (TYPE_NAME (class_type)),
                 IDENTIFIER_POINTER (package));
            }
@@ -7070,27 +7226,6 @@ find_in_imports_on_demand (tree enclosing_type, tree class_type)
     return (seen_once < 0 ? 0 : seen_once); /* It's ok not to have found */
 }
 
-/* Add package NAME to the list of packages encountered so far. To
-   speed up class lookup in do_resolve_class, we make sure a
-   particular package is added only once.  */
-
-static void
-register_package (tree name)
-{
-  static htab_t pht;
-  void **e;
-
-  if (pht == NULL)
-    pht = htab_create (50, htab_hash_pointer, htab_eq_pointer, NULL);
-
-  e = htab_find_slot (pht, name, INSERT);
-  if (*e == NULL)
-    {
-      package_list = chainon (package_list, build_tree_list (name, NULL));
-      *e = name;
-    }
-}
-
 static tree
 resolve_package (tree pkg, tree *next, tree *type_name)
 {
@@ -7203,16 +7338,17 @@ check_inner_class_access (tree decl, tree enclosing_decl, tree cl)
 
   parse_error_context (cl, "Nested %s %s is %s; cannot be accessed from here",
                       (CLASS_INTERFACE (decl) ? "interface" : "class"),
-                      lang_printable_name (decl, 0), access);
+                      lang_printable_name (decl, 2), access);
 }
 
 /* Accessibility check for top-level classes. If CLASS_NAME is in a
    foreign package, it must be PUBLIC. Return 0 if no access
    violations were found, 1 otherwise. If VERBOSE is true and an error
-   was found, it is reported and accounted for.  */
+   was found, it is reported and accounted for.  If CL is NULL then 
+   look it up with THIS_DECL.  */
 
 static int
-check_pkg_class_access (tree class_name, tree cl, bool verbose)
+check_pkg_class_access (tree class_name, tree cl, bool verbose, tree this_decl)
 {
   tree type;
 
@@ -7227,7 +7363,7 @@ check_pkg_class_access (tree class_name, tree cl, bool verbose)
       /* Access to a private class within the same package is
          allowed. */
       tree l, r;
-      breakdown_qualified (&l, &r, class_name);
+      split_qualified_name (&l, &r, class_name);
       if (!QUALIFIED_P (class_name) && !ctxp->package)
        /* Both in the empty package. */
         return 0;
@@ -7237,7 +7373,8 @@ check_pkg_class_access (tree class_name, tree cl, bool verbose)
 
       if (verbose)
        parse_error_context
-         (cl, "Can't access %s `%s'. Only public classes and interfaces in other packages can be accessed",
+         (cl == NULL ? lookup_cl (this_decl): cl,
+           "Can't access %s %qs. Only public classes and interfaces in other packages can be accessed",
           (CLASS_INTERFACE (TYPE_NAME (type)) ? "interface" : "class"),
           IDENTIFIER_POINTER (class_name));
       return 1;
@@ -7275,7 +7412,7 @@ declare_local_variables (int modifier, tree type, tree vlist)
        {
          parse_error_context
            (ctxp->modifier_ctx [i],
-            "Only `final' is allowed as a local variables modifier");
+            "Only %<final%> is allowed as a local variables modifier");
          return;
        }
     }
@@ -7321,15 +7458,17 @@ declare_local_variables (int modifier, tree type, tree vlist)
       DECL_FINAL (decl) = final_p;
       BLOCK_CHAIN_DECL (decl);
 
-      /* If doing xreferencing, replace the line number with the WFL
-         compound value */
-      if (flag_emit_xref)
-       DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (wfl);
-
       /* Don't try to use an INIT statement when an error was found */
       if (init && java_error_count)
        init = NULL_TREE;
 
+      /* Remember it if this is an initialized-upon-declaration final
+         variable.  */
+      if (init && final_p)
+        {
+          DECL_LOCAL_FINAL_IUD (decl) = 1;
+        }
+
       /* Add the initialization function to the current function's code */
       if (init)
        {
@@ -7415,14 +7554,18 @@ create_artificial_method (tree class, int flags, tree type,
                          tree name, tree args)
 {
   tree mdecl;
+  location_t save_location = input_location;
 
-  java_parser_context_save_global ();
-  input_line = 0;
+  input_location = DECL_SOURCE_LOCATION (TYPE_NAME (class));
   mdecl = make_node (FUNCTION_TYPE);
   TREE_TYPE (mdecl) = type;
   TYPE_ARG_TYPES (mdecl) = args;
-  mdecl = add_method (class, flags, name, build_java_signature (mdecl));
-  java_parser_context_restore_global ();
+  /* We used to compute the signature of MDECL here and then use
+     add_method(), but that failed because our caller might modify
+     the type of the returned method, which trashes the cache in
+     get_type_from_signature().  */
+  mdecl = add_method_1 (class, flags, name, mdecl);
+  input_location = save_location;
   DECL_ARTIFICIAL (mdecl) = 1;
   return mdecl;
 }
@@ -7432,8 +7575,13 @@ create_artificial_method (tree class, int flags, tree type,
 static void
 start_artificial_method_body (tree mdecl)
 {
+#ifdef USE_MAPPED_LOCATION
+  DECL_SOURCE_LOCATION (mdecl) = ctxp->file_start_location;
+  DECL_FUNCTION_LAST_LINE (mdecl) = ctxp->file_start_location;
+#else
   DECL_SOURCE_LINE (mdecl) = 1;
   DECL_FUNCTION_LAST_LINE (mdecl) = 1;
+#endif
   source_start_java_method (mdecl);
   enter_block ();
 }
@@ -7477,24 +7625,25 @@ source_end_java_method (void)
     return;
 
   java_parser_context_save_global ();
+#ifdef USE_MAPPED_LOCATION
+  input_location = ctxp->last_ccb_indent1;
+#else
   input_line = ctxp->last_ccb_indent1;
+#endif
 
   /* Turn function bodies with only a NOP expr null, so they don't get
      generated at all and we won't get warnings when using the -W
      -Wall flags. */
-  if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) == empty_stmt_node)
+  if (IS_EMPTY_STMT (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl))))
     BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) = NULL_TREE;
 
-  /* We've generated all the trees for this function, and it has been
-     patched.  Dump it to a file if the user requested it.  */
-  dump_java_tree (TDI_original, fndecl);
-
-  /* Defer expanding the method until cgraph analysis is complete.  */
-  if (DECL_SAVED_TREE (fndecl))
-    cgraph_finalize_function (fndecl, false);
+  if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl))
+      && ! flag_emit_class_files)
+    finish_method (fndecl);
 
   current_function_decl = NULL_TREE;
   java_parser_context_restore_global ();
+  current_function_decl = NULL_TREE;
 }
 
 /* Record EXPR in the current function block. Complements compound
@@ -7524,19 +7673,10 @@ add_stmt_to_block (tree b, tree type, tree stmt)
   return c;
 }
 
-/* Add STMT to EXISTING if possible, otherwise create a new
-   COMPOUND_EXPR and add STMT to it. */
+/* Lays out the methods for the classes seen so far.  */
 
-static tree
-add_stmt_to_compound (tree existing, tree type, tree stmt)
-{
-  if (existing)
-    return build (COMPOUND_EXPR, type, existing, stmt);
-  else
-    return stmt;
-}
-
-void java_layout_seen_class_methods (void)
+void
+java_layout_seen_class_methods (void)
 {
   tree previous_list = all_class_list;
   tree end = NULL_TREE;
@@ -7546,7 +7686,20 @@ void java_layout_seen_class_methods (void)
     {
       for (current = previous_list;
           current != end; current = TREE_CHAIN (current))
-       layout_class_methods (TREE_TYPE (TREE_VALUE (current)));
+        {
+         tree decl = TREE_VALUE (current);
+          tree cls = TREE_TYPE (decl);
+
+         input_location = DECL_SOURCE_LOCATION (decl);
+
+          if (! CLASS_LOADED_P (cls))
+            load_class (cls, 0);
+
+          layout_class_methods (cls);
+        }
+
+      /* Note that new classes might have been added while laying out
+         methods, changing the value of all_class_list.  */
 
       if (previous_list != all_class_list)
        {
@@ -7566,7 +7719,7 @@ java_reorder_fields (void)
 
   for (current = gclass_list; current; current = TREE_CHAIN (current))
     {
-      current_class = TREE_TYPE (TREE_VALUE (current));
+      output_class = current_class = TREE_TYPE (TREE_VALUE (current));
 
       if (current_class == stop_reordering)
        break;
@@ -7623,7 +7776,7 @@ java_layout_classes (void)
 
   for (current = gclass_list; current; current = TREE_CHAIN (current))
     {
-      current_class = TREE_TYPE (TREE_VALUE (current));
+      output_class = current_class = TREE_TYPE (TREE_VALUE (current));
       layout_class (current_class);
 
       /* Error reported by the caller */
@@ -7646,8 +7799,6 @@ java_complete_expand_classes (void)
 {
   tree current;
 
-  do_not_fold = flag_emit_xref;
-
   for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
     if (!INNER_CLASS_DECL_P (current))
       java_complete_expand_class (current);
@@ -7661,8 +7812,6 @@ java_complete_expand_class (tree outer)
 {
   tree inner_list;
 
-  set_nested_class_simple_name_value (outer, 1); /* Set */
-
   /* We need to go after all inner classes and start expanding them,
      starting with most nested ones. We have to do that because nested
      classes might add functions to outer classes */
@@ -7672,7 +7821,6 @@ java_complete_expand_class (tree outer)
     java_complete_expand_class (TREE_PURPOSE (inner_list));
 
   java_complete_expand_methods (outer);
-  set_nested_class_simple_name_value (outer, 0); /* Reset */
 }
 
 /* Expand methods registered in CLASS_DECL. The general idea is that
@@ -7687,10 +7835,7 @@ java_complete_expand_methods (tree class_decl)
 {
   tree clinit, decl, first_decl;
 
-  current_class = TREE_TYPE (class_decl);
-
-  /* Initialize a new constant pool */
-  init_outgoing_cpool ();
+  output_class = current_class = TREE_TYPE (class_decl);
 
   /* Pre-expand <clinit> to figure whether we really need it or
      not. If we do need it, we pre-expand the static fields so they're
@@ -7712,21 +7857,9 @@ java_complete_expand_methods (tree class_decl)
   /* Now do the constructors */
   for (decl = first_decl ; !java_error_count && decl; decl = TREE_CHAIN (decl))
     {
-      int no_body;
-
       if (!DECL_CONSTRUCTOR_P (decl))
        continue;
-
-      no_body = !DECL_FUNCTION_BODY (decl);
-      /* Don't generate debug info on line zero when expanding a
-        generated constructor. */
-      if (no_body)
-       restore_line_number_status (1);
-
       java_complete_expand_method (decl);
-
-      if (no_body)
-       restore_line_number_status (0);
     }
 
   /* First, do the ordinary methods. */
@@ -7775,9 +7908,6 @@ java_complete_expand_methods (tree class_decl)
       if (DECL_CONSTRUCTOR_P (decl)
          && verify_constructor_circularity (decl, decl))
        break;
-
-  /* Save the constant pool. We'll need to restore it later. */
-  TYPE_CPOOL (current_class) = outgoing_cpool;
 }
 
 /* Attempt to create <clinit>. Pre-expand static fields so they can be
@@ -7814,7 +7944,7 @@ maybe_generate_pre_expand_clinit (tree class_type)
       /* We build the assignment expression that will initialize the
         field to its value. There are strict rules on static
         initializers (8.5). FIXME */
-      if (TREE_CODE (stmt) != BLOCK && stmt != empty_stmt_node)
+      if (TREE_CODE (stmt) != BLOCK && !IS_EMPTY_STMT (stmt))
        stmt = build_debugable_stmt (EXPR_WFL_LINECOL (stmt), stmt);
       java_method_add_stmt (mdecl, stmt);
     }
@@ -7908,7 +8038,7 @@ maybe_yank_clinit (tree mdecl)
     bbody = BLOCK_EXPR_BODY (bbody);
   else
     return 0;
-  if (bbody && ! flag_emit_class_files && bbody != empty_stmt_node)
+  if (bbody && ! flag_emit_class_files && !IS_EMPTY_STMT (bbody))
     return 0;
 
   type = DECL_CONTEXT (mdecl);
@@ -7942,7 +8072,7 @@ maybe_yank_clinit (tree mdecl)
 
   /* Now we analyze the method body and look for something that
      isn't a MODIFY_EXPR */
-  if (bbody != empty_stmt_node && analyze_clinit_body (type, bbody))
+  if (bbody && !IS_EMPTY_STMT (bbody) && analyze_clinit_body (type, bbody))
     return 0;
 
   /* Get rid of <clinit> in the class' list of methods */
@@ -7977,7 +8107,7 @@ start_complete_expand_method (tree mdecl)
       /* TREE_CHAIN (tem) will change after pushdecl. */
       tree next = TREE_CHAIN (tem);
       tree type = TREE_TYPE (tem);
-      if (PROMOTE_PROTOTYPES
+      if (targetm.calls.promote_prototypes (type)
          && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)
          && INTEGRAL_TYPE_P (type))
        type = integer_type_node;
@@ -7989,7 +8119,7 @@ start_complete_expand_method (tree mdecl)
       TREE_CHAIN (tem) = next;
     }
   pushdecl_force_head (DECL_ARGUMENTS (mdecl));
-  input_line = DECL_SOURCE_LINE (mdecl);
+  input_location = DECL_SOURCE_LOCATION (mdecl);
   build_result_decl (mdecl);
 }
 
@@ -8047,7 +8177,7 @@ java_complete_expand_method (tree mdecl)
       htab_traverse (DECL_FUNCTION_INIT_TEST_TABLE (mdecl),
                     attach_init_test_initialization_flags, block_body);
 
-      if (! flag_emit_xref && ! METHOD_NATIVE (mdecl))
+      if (! METHOD_NATIVE (mdecl))
        {
          check_for_initialization (block_body, mdecl);
 
@@ -8077,8 +8207,7 @@ java_complete_expand_method (tree mdecl)
      an error_mark_node here. */
   if (block_body != error_mark_node
       && (block_body == NULL_TREE || CAN_COMPLETE_NORMALLY (block_body))
-      && TREE_CODE (TREE_TYPE (TREE_TYPE (mdecl))) != VOID_TYPE
-      && !flag_emit_xref)
+      && TREE_CODE (TREE_TYPE (TREE_TYPE (mdecl))) != VOID_TYPE)
     missing_return_error (current_function_decl);
 
   /* See if we can get rid of <clinit> if MDECL happens to be <clinit> */
@@ -8094,7 +8223,7 @@ java_complete_expand_method (tree mdecl)
   if (currently_caught_type_list)
     abort ();
 
-  /* Restore the copy of the list of exceptions if emitting xrefs. */
+  /* Restore the copy of the list of exceptions. */
   DECL_FUNCTION_THROWS (mdecl) = exception_copy;
 }
 
@@ -8107,7 +8236,6 @@ java_expand_method_bodies (tree class)
   for (decl = TYPE_METHODS (class); decl; decl = TREE_CHAIN (decl))
     {
       tree block;
-      tree body;
 
       if (! DECL_FUNCTION_BODY (decl))
        continue;
@@ -8116,17 +8244,9 @@ java_expand_method_bodies (tree class)
 
       block = BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (decl));
 
-      if (TREE_CODE (block) != BLOCK)
-       abort ();
-
-      /* Save the function body for inlining.  */
+      /* Save the function body for gimplify and inlining.  */
       DECL_SAVED_TREE (decl) = block;
 
-      body = BLOCK_EXPR_BODY (block);
-
-      if (TREE_TYPE (body) == NULL_TREE)
-       abort ();
-
       /* It's time to assign the variable flagging static class
         initialization based on which classes invoked static methods
         are definitely initializing. This should be flagged. */
@@ -8158,41 +8278,7 @@ java_expand_method_bodies (tree class)
            }
        }
 
-      /* Prepend class initialization to static methods.  */
-      if (METHOD_STATIC (decl) && ! METHOD_PRIVATE (decl)
-         && ! flag_emit_class_files
-         && ! DECL_CLINIT_P (decl)
-         && ! CLASS_INTERFACE (TYPE_NAME (class)))
-       {
-         tree init = build (CALL_EXPR, void_type_node,
-                            build_address_of (soft_initclass_node),
-                            build_tree_list (NULL_TREE,
-                                             build_class_ref (class)),
-                            NULL_TREE);
-         TREE_SIDE_EFFECTS (init) = 1;
-         body = build (COMPOUND_EXPR, TREE_TYPE (body), init, body);
-         BLOCK_EXPR_BODY (block) = body;
-       }
-
-      /* Wrap synchronized method bodies in a monitorenter
-        plus monitorexit cleanup.  */
-      if (METHOD_SYNCHRONIZED (decl) && ! flag_emit_class_files)
-       {
-         tree enter, exit, lock;
-         if (METHOD_STATIC (decl))
-           lock = build_class_ref (class);
-         else
-           lock = DECL_ARGUMENTS (decl);
-         BUILD_MONITOR_ENTER (enter, lock);
-         BUILD_MONITOR_EXIT (exit, lock);
-
-         body = build (COMPOUND_EXPR, void_type_node,
-                       enter,
-                       build (TRY_FINALLY_EXPR, void_type_node, body, exit));
-         BLOCK_EXPR_BODY (block) = body;
-       }
-
-      /* Expand the the function body.  */
+      /* Expand the function body.  */
       source_end_java_method ();
     }
 }
@@ -8203,114 +8289,159 @@ java_expand_method_bodies (tree class)
    fields either directly by using the relevant access to this$<n> or
    by invoking an access method crafted for that purpose.  */
 
-/* Build the necessary access from an inner class to an outer
-   class. This routine could be optimized to cache previous result
+/* Build the necessary access across nested class boundaries.
+   This routine could be optimized to cache previous result
    (decl, current_class and returned access).  When an access method
-   needs to be generated, it always takes the form of a read. It might
-   be later turned into a write by calling outer_field_access_fix.  */
+   needs to be generated, it always takes the form of a read.  It might
+   be later turned into a write by calling nested_field_access_fix.  */
 
 static tree
-build_outer_field_access (tree id, tree decl)
+build_nested_field_access (tree id, tree decl)
 {
   tree access = NULL_TREE;
-  tree ctx = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (current_class)));
+  tree ctx = NULL_TREE;
   tree decl_ctx = DECL_CONTEXT (decl);
+  bool is_static = FIELD_STATIC (decl);
 
-  /* If the immediate enclosing context of the current class is the
-     field decl's class or inherits from it; build the access as
-     `this$<n>.<field>'. Note that we will break the `private' barrier
-     if we're not emitting bytecodes. */
-  if ((ctx == decl_ctx || inherits_from_p (ctx, decl_ctx))
-      && (!FIELD_PRIVATE (decl) || !flag_emit_class_files ))
+  if (DECL_CONTEXT (TYPE_NAME (current_class)))
+    ctx = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (current_class)));
+
+  /* For non-static fields, if the immediate enclosing context of the
+     current class is the field decl's class or inherits from it,
+     build the access as `this$<n>.<field>'.  Note that we will break
+     the `private' barrier if we're not emitting bytecodes.  */
+  if (!is_static
+      && ctx
+      && (ctx == decl_ctx || inherits_from_p (ctx, decl_ctx))
+      && (!FIELD_PRIVATE (decl) || !flag_emit_class_files))
     {
       tree thisn = build_current_thisn (current_class);
       access = make_qualified_primary (build_wfl_node (thisn),
                                       id, EXPR_WFL_LINECOL (id));
     }
-  /* Otherwise, generate access methods to outer this and access the
-     field (either using an access method or by direct access.) */
+  /* Otherwise, generate and use accessor methods for the field as
+     needed.  */
   else
     {
       int lc = EXPR_WFL_LINECOL (id);
 
       /* Now we chain the required number of calls to the access$0 to
-        get a hold to the enclosing instance we need, and then we
-        build the field access. */
-      access = build_access_to_thisn (current_class, decl_ctx, lc);
+        get a hold to the enclosing instance we need for a non-static
+         field, and then we build the field access. */
+      if (!is_static)
+        access = build_access_to_thisn (current_class, decl_ctx, lc);
 
       /* If the field is private and we're generating bytecode, then
-         we generate an access method */
-      if (FIELD_PRIVATE (decl) && flag_emit_class_files )
+         we generate an access method */
+      if (FIELD_PRIVATE (decl) && flag_emit_class_files)
        {
-         tree name = build_outer_field_access_methods (decl);
-         access = build_outer_field_access_expr (lc, decl_ctx,
-                                                 name, access, NULL_TREE);
+         tree name = build_nested_field_access_methods (decl);
+         access = build_nested_field_access_expr (lc, decl_ctx,
+                                                  name, access, NULL_TREE);
        }
-      /* Otherwise we use `access$(this$<j>). ... access$(this$<i>).<field>'.
+      /* Otherwise we use `access$(this$<j>). ... access$(this$<i>).<field>'
+         for non-static fields.
         Once again we break the `private' access rule from a foreign
-        class. */
+        class.  */
+      else if (is_static)
+        {
+          tree class_name = DECL_NAME (TYPE_NAME (decl_ctx));
+          access
+            = make_qualified_primary (build_wfl_node (class_name), id, lc);
+        }
       else
-       access = make_qualified_primary (access, id, lc);
+        access = make_qualified_primary (access, id, lc);
     }
+
   return resolve_expression_name (access, NULL);
 }
 
-/* Return a nonzero value if NODE describes an outer field inner
-   access.  */
+/* Return a nonzero value if DECL describes a field access across nested
+   class boundaries.  That is, DECL is in a class that either encloses,
+   is enclosed by or shares a common enclosing class with, the class
+   TYPE.  */
 
 static int
-outer_field_access_p (tree type, tree decl)
+nested_field_access_p (tree type, tree decl)
 {
+  bool is_static = false;
+  tree decl_type = DECL_CONTEXT (decl);
+  tree type_root, decl_type_root;
+
+  if (decl_type == type
+      || (TREE_CODE (decl) != FIELD_DECL && TREE_CODE (decl) != VAR_DECL))
+    return 0;
+  
   if (!INNER_CLASS_TYPE_P (type)
-      || TREE_CODE (decl) != FIELD_DECL
-      || DECL_CONTEXT (decl) == type)
+      && !(TREE_CODE (decl_type) == RECORD_TYPE
+           && INNER_CLASS_TYPE_P (decl_type)))
     return 0;
 
-  /* If the inner class extends the declaration context of the field
-     we're trying to access, then this isn't an outer field access */
-  if (inherits_from_p (type, DECL_CONTEXT (decl)))
+  is_static = FIELD_STATIC (decl);
+
+  /* If TYPE extends the declaration context of the non-static
+     field we're trying to access, then this isn't a nested field
+     access we need to worry about.  */
+  if (!is_static && inherits_from_p (type, decl_type))
     return 0;
 
-  for (type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))); ;
-       type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))))
+  for (type_root = type;
+       DECL_CONTEXT (TYPE_NAME (type_root));
+       type_root = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type_root))))
     {
-      if (type == DECL_CONTEXT (decl))
-       return 1;
-
-      if (!DECL_CONTEXT (TYPE_NAME (type)))
-       {
-         /* Before we give up, see whether the field is inherited from
-            the enclosing context we're considering. */
-         if (inherits_from_p (type, DECL_CONTEXT (decl)))
-           return 1;
-         break;
-       }
+      if (type_root == decl_type)
+        return 1;
     }
 
-  return 0;
-}
-
-/* Return a nonzero value if NODE represents an outer field inner
-   access that was been already expanded. As a side effect, it returns
-   the name of the field being accessed and the argument passed to the
-   access function, suitable for a regeneration of the access method
-   call if necessary. */
+  if (TREE_CODE (decl_type) == RECORD_TYPE
+      && INNER_CLASS_TYPE_P (decl_type))
+    {
+      for (decl_type_root = decl_type;
+           DECL_CONTEXT (TYPE_NAME (decl_type_root));
+           decl_type_root
+             = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (decl_type_root))))
+        {
+          if (decl_type_root == type)
+            return 1;
+        }
+    }
+  else
+    decl_type_root = decl_type;
+    
+  if (type_root == decl_type_root)
+    return 1;
+
+  /* Before we give up, see whether it is a non-static field
+     inherited from the enclosing context we are considering.  */
+  if (!DECL_CONTEXT (TYPE_NAME (type_root))
+      && !is_static
+      && inherits_from_p (type_root, decl_type))
+    return 1;
+
+  return 0;
+}
+
+/* Return a nonzero value if NODE represents a cross-nested-class 
+   access that has already been expanded.  As a side effect, it returns
+   the name of the field being accessed and the argument passed to the
+   access function, suitable for a regeneration of the access method
+   call if necessary.  */
 
 static int
-outer_field_expanded_access_p (tree node, tree *name, tree *arg_type,
-                              tree *arg)
+nested_field_expanded_access_p (tree node, tree *name, tree *arg_type,
+                               tree *arg)
 {
   int identified = 0;
 
   if (TREE_CODE (node) != CALL_EXPR)
     return 0;
 
-  /* Well, gcj generates slightly different tree nodes when compiling
-     to native or bytecodes. It's the case for function calls. */
+  /* Well, GCJ generates slightly different tree nodes when compiling
+     to native or bytecodes.  It's the case for function calls.  */
 
   if (flag_emit_class_files
       && TREE_CODE (node) == CALL_EXPR
-      && OUTER_FIELD_ACCESS_IDENTIFIER_P (DECL_NAME (TREE_OPERAND (node, 0))))
+      && NESTED_FIELD_ACCESS_IDENTIFIER_P (DECL_NAME (TREE_OPERAND (node, 0))))
     identified = 1;
   else if (!flag_emit_class_files)
     {
@@ -8322,7 +8453,7 @@ outer_field_expanded_access_p (tree node, tree *name, tree *arg_type,
          node = TREE_OPERAND (node, 0);
          if (TREE_OPERAND (node, 0)
              && TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL
-             && (OUTER_FIELD_ACCESS_IDENTIFIER_P
+             && (NESTED_FIELD_ACCESS_IDENTIFIER_P
                  (DECL_NAME (TREE_OPERAND (node, 0)))))
            identified = 1;
        }
@@ -8332,26 +8463,37 @@ outer_field_expanded_access_p (tree node, tree *name, tree *arg_type,
     {
       tree argument = TREE_OPERAND (node, 1);
       *name = DECL_NAME (TREE_OPERAND (node, 0));
-      *arg_type = TREE_TYPE (TREE_TYPE (TREE_VALUE (argument)));
-      *arg = TREE_VALUE (argument);
+
+      /* The accessors for static fields do not take in a this$<n> argument,
+         so we take the class name from the accessor's context instead.  */
+      if (argument)
+        {
+          *arg_type = TREE_TYPE (TREE_TYPE (TREE_VALUE (argument)));
+          *arg = TREE_VALUE (argument);
+        }
+      else
+        {
+          *arg_type = DECL_CONTEXT (TREE_OPERAND (node, 0));
+          *arg = NULL_TREE;
+        }
     }
   return identified;
 }
 
-/* Detect in NODE an outer field read access from an inner class and
-   transform it into a write with RHS as an argument. This function is
-   called from the java_complete_lhs when an assignment to a LHS can
-   be identified. */
+/* Detect in NODE cross-nested-class field read access and
+   transform it into a write with RHS as an argument.  This function
+   is called from the java_complete_lhs when an assignment to a LHS can
+   be identified.  */
 
 static tree
-outer_field_access_fix (tree wfl, tree node, tree rhs)
+nested_field_access_fix (tree wfl, tree node, tree rhs)
 {
   tree name, arg_type, arg;
 
-  if (outer_field_expanded_access_p (node, &name, &arg_type, &arg))
+  if (nested_field_expanded_access_p (node, &name, &arg_type, &arg))
     {
-      node = build_outer_field_access_expr (EXPR_WFL_LINECOL (wfl),
-                                           arg_type, name, arg, rhs);
+      node = build_nested_field_access_expr (EXPR_WFL_LINECOL (wfl),
+                                            arg_type, name, arg, rhs);
       return java_complete_tree (node);
     }
   return NULL_TREE;
@@ -8364,23 +8506,34 @@ outer_field_access_fix (tree wfl, tree node, tree rhs)
    read access.  */
 
 static tree
-build_outer_field_access_expr (int lc, tree type, tree access_method_name,
-                              tree arg1, tree arg2)
+build_nested_field_access_expr (int lc, tree type, tree access_method_name,
+                               tree arg1, tree arg2)
 {
   tree args, cn, access;
 
-  args = arg1 ? arg1 :
-    build_wfl_node (build_current_thisn (current_class));
-  args = build_tree_list (NULL_TREE, args);
+  if (arg1)
+    args = build_tree_list (NULL_TREE, arg1);
+  else
+    args = NULL_TREE;
 
   if (arg2)
-    args = tree_cons (NULL_TREE, arg2, args);
+    {
+      if (args)
+        args = tree_cons (NULL_TREE, arg2, args);
+      else
+        args = build_tree_list (NULL_TREE, arg2);
+    }
 
-  access = build_method_invocation (build_wfl_node (access_method_name), args);
+  access
+    = build_method_invocation (build_wfl_node (access_method_name), args);
   cn = build_wfl_node (DECL_NAME (TYPE_NAME (type)));
+
   return make_qualified_primary (cn, access, lc);
 }
 
+/* Build the name of a synthetic accessor used to access class members
+   across nested class boundaries.  */
+
 static tree
 build_new_access_id (void)
 {
@@ -8391,8 +8544,8 @@ build_new_access_id (void)
   return get_identifier (buffer);
 }
 
-/* Create the static access functions for the outer field DECL. We define a
-   read:
+/* Create the static access functions for the cross-nested-class field DECL.
+   We define a read:
      TREE_TYPE (<field>) access$<n> (DECL_CONTEXT (<field>) inst$) {
        return inst$.field;
      }
@@ -8401,63 +8554,89 @@ build_new_access_id (void)
                                      TREE_TYPE (<field>) value$) {
        return inst$.field = value$;
      }
-   We should have a usage flags on the DECL so we can lazily turn the ones
-   we're using for code generation. FIXME.
+   For static fields, these methods are generated without the instance
+   parameter.
+   We should have a usage flag on the DECL so we can lazily turn the ones
+   we're using for code generation.  FIXME.
 */
 
 static tree
-build_outer_field_access_methods (tree decl)
+build_nested_field_access_methods (tree decl)
 {
-  tree id, args, stmt, mdecl;
+  tree id, args, stmt, mdecl, class_name = NULL_TREE;
+  bool is_static = FIELD_STATIC (decl);
 
-  if (FIELD_INNER_ACCESS_P (decl))
-    return FIELD_INNER_ACCESS (decl);
+  if (FIELD_NESTED_ACCESS_P (decl))
+    return FIELD_NESTED_ACCESS (decl);
 
   MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl);
 
-  /* Create the identifier and a function named after it. */
+  /* Create the identifier and a function named after it.  */
   id = build_new_access_id ();
 
   /* The identifier is marked as bearing the name of a generated write
-     access function for outer field accessed from inner classes. */
-  OUTER_FIELD_ACCESS_IDENTIFIER_P (id) = 1;
+     access function for outer field accessed from inner classes.  */
+  NESTED_FIELD_ACCESS_IDENTIFIER_P (id) = 1;
 
-  /* Create the read access */
-  args = build_tree_list (inst_id, build_pointer_type (DECL_CONTEXT (decl)));
-  TREE_CHAIN (args) = end_params_node;
-  stmt = make_qualified_primary (build_wfl_node (inst_id),
-                                build_wfl_node (DECL_NAME (decl)), 0);
+  /* Create the read access.  */
+  if (!is_static)
+    {
+      args = build_tree_list (inst_id,
+                              build_pointer_type (DECL_CONTEXT (decl)));
+      TREE_CHAIN (args) = end_params_node;
+      stmt = make_qualified_primary (build_wfl_node (inst_id),
+                                    build_wfl_node (DECL_NAME (decl)), 0);
+    }
+  else
+    {
+      args = end_params_node;
+      class_name = DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)));
+      stmt = make_qualified_primary (build_wfl_node (class_name),
+                                     build_wfl_node (DECL_NAME (decl)), 0);
+    }
   stmt = build_return (0, stmt);
-  mdecl = build_outer_field_access_method (DECL_CONTEXT (decl),
-                                          TREE_TYPE (decl), id, args, stmt);
+  mdecl = build_nested_field_access_method (DECL_CONTEXT (decl),
+                                           TREE_TYPE (decl), id, args, stmt);
   DECL_FUNCTION_ACCESS_DECL (mdecl) = decl;
 
-  /* Create the write access method. No write access for final variable */
+  /* Create the write access method.  No write access for final variable */
   if (!FIELD_FINAL (decl))
     {
-      args = build_tree_list (inst_id,
-                             build_pointer_type (DECL_CONTEXT (decl)));
-      TREE_CHAIN (args) = build_tree_list (wpv_id, TREE_TYPE (decl));
-      TREE_CHAIN (TREE_CHAIN (args)) = end_params_node;
-      stmt = make_qualified_primary (build_wfl_node (inst_id),
-                                    build_wfl_node (DECL_NAME (decl)), 0);
+      if (!is_static)
+        {
+          args = build_tree_list (inst_id,
+                                 build_pointer_type (DECL_CONTEXT (decl)));
+          TREE_CHAIN (args) = build_tree_list (wpv_id, TREE_TYPE (decl));
+          TREE_CHAIN (TREE_CHAIN (args)) = end_params_node;
+          stmt = make_qualified_primary (build_wfl_node (inst_id),
+                                        build_wfl_node (DECL_NAME (decl)),
+                                         0);
+        }
+      else
+        {
+          args = build_tree_list (wpv_id, TREE_TYPE (decl));
+          TREE_CHAIN (args) = end_params_node;
+          stmt = make_qualified_primary (build_wfl_node (class_name),
+                                         build_wfl_node (DECL_NAME (decl)),
+                                         0);
+        }
       stmt = build_return (0, build_assignment (ASSIGN_TK, 0, stmt,
                                                build_wfl_node (wpv_id)));
-      mdecl = build_outer_field_access_method (DECL_CONTEXT (decl),
-                                              TREE_TYPE (decl), id,
-                                              args, stmt);
+      mdecl = build_nested_field_access_method (DECL_CONTEXT (decl),
+                                               TREE_TYPE (decl), id,
+                                               args, stmt);
     }
   DECL_FUNCTION_ACCESS_DECL (mdecl) = decl;
 
   /* Return the access name */
-  return FIELD_INNER_ACCESS (decl) = id;
+  return FIELD_NESTED_ACCESS (decl) = id;
 }
 
-/* Build an field access method NAME.  */
+/* Build a field access method NAME.  */
 
 static tree
-build_outer_field_access_method (tree class, tree type, tree name,
-                                tree args, tree body)
+build_nested_field_access_method (tree class, tree type, tree name,
+                                 tree args, tree body)
 {
   tree saved_current_function_decl, mdecl;
 
@@ -8501,7 +8680,7 @@ build_outer_method_access_method (tree decl)
 
   /* Obtain an access identifier and mark it */
   id = build_new_access_id ();
-  OUTER_FIELD_ACCESS_IDENTIFIER_P (id) = 1;
+  NESTED_FIELD_ACCESS_IDENTIFIER_P (id) = 1;
 
   carg = TYPE_ARG_TYPES (TREE_TYPE (decl));
   /* Create the arguments, as much as the original */
@@ -8567,7 +8746,7 @@ build_outer_method_access_method (tree decl)
    others. Access methods to this$<n> are build on the fly if
    necessary. This CAN'T be used to solely access this$<n-1> from
    this$<n> (which alway yield to special cases and optimization, see
-   for example build_outer_field_access).  */
+   for example build_nested_field_access).  */
 
 static tree
 build_access_to_thisn (tree from, tree to, int lc)
@@ -8704,7 +8883,11 @@ build_thisn_assign (void)
       tree lhs = make_qualified_primary (build_wfl_node (this_identifier_node),
                                         build_wfl_node (thisn), 0);
       tree rhs = build_wfl_node (thisn);
+#ifdef USE_MAPPED_LOCATION
+      SET_EXPR_LOCATION (lhs, input_location);
+#else
       EXPR_WFL_SET_LINECOL (lhs, input_line, 0);
+#endif
       return build_assignment (ASSIGN_TK, EXPR_WFL_LINECOL (lhs), lhs, rhs);
     }
   return NULL_TREE;
@@ -8728,7 +8911,11 @@ static tree
 build_dot_class_method (tree class)
 {
 #define BWF(S) build_wfl_node (get_identifier ((S)))
+#ifdef USE_MAPPED_LOCATION
+#define MQN(X,Y) make_qualified_name ((X), (Y), UNKNOWN_LOCATION)
+#else
 #define MQN(X,Y) make_qualified_name ((X), (Y), 0)
+#endif
   tree args, tmp, saved_current_function_decl, mdecl, qual_name;
   tree stmt, throw_stmt;
 
@@ -8766,8 +8953,13 @@ build_dot_class_method (tree class)
 
   /* Now onto the catch block. We start by building the expression
      throwing a new exception: throw new NoClassDefFoundError (_.getMessage) */
+#ifdef USE_MAPPED_LOCATION
+  throw_stmt = make_qualified_name (build_wfl_node (wpv_id),
+                                   get_message_wfl, UNKNOWN_LOCATION);
+#else
   throw_stmt = make_qualified_name (build_wfl_node (wpv_id),
                                    get_message_wfl, 0);
+#endif
   throw_stmt = build_method_invocation (throw_stmt, NULL_TREE);
 
   /* Build new NoClassDefFoundError (_.getMessage) */
@@ -8832,7 +9024,7 @@ static void
 fix_constructors (tree mdecl)
 {
   tree iii;                    /* Instance Initializer Invocation */
-  tree body = DECL_FUNCTION_BODY (mdecl);
+  tree *bodyp = &DECL_FUNCTION_BODY (mdecl);
   tree thisn_assign, compound = NULL_TREE;
   tree class_type = DECL_CONTEXT (mdecl);
 
@@ -8840,7 +9032,7 @@ fix_constructors (tree mdecl)
     return;
   DECL_FIXED_CONSTRUCTOR_P (mdecl) = 1;
 
-  if (!body)
+  if (!*bodyp)
     {
       /* It is an error for the compiler to generate a default
         constructor if the superclass doesn't have a constructor that
@@ -8853,8 +9045,8 @@ fix_constructors (tree mdecl)
          DECL_NAME (mdecl) = DECL_NAME (sclass_decl);
          parse_error_context
            (lookup_cl (TYPE_NAME (class_type)),
-            "No constructor matching `%s' found in class `%s'",
-            lang_printable_name (mdecl, 0), n);
+            "No constructor matching %qs found in class %qs",
+            lang_printable_name (mdecl, 2), n);
          DECL_NAME (mdecl) = save;
        }
 
@@ -8884,31 +9076,30 @@ fix_constructors (tree mdecl)
     {
       int found = 0;
       int invokes_this = 0;
-      tree found_call = NULL_TREE;
-      tree main_block = BLOCK_EXPR_BODY (body);
+      tree main_block = BLOCK_EXPR_BODY (*bodyp);
 
-      while (body)
-       switch (TREE_CODE (body))
-         {
-         case CALL_EXPR:
-           found = CALL_EXPLICIT_CONSTRUCTOR_P (body);
-           if (CALL_THIS_CONSTRUCTOR_P (body))
-             invokes_this = 1;
-           body = NULL_TREE;
-           break;
-         case COMPOUND_EXPR:
-         case EXPR_WITH_FILE_LOCATION:
-           found_call = body;
-           body = TREE_OPERAND (body, 0);
-           break;
-         case BLOCK:
-           found_call = body;
-           body = BLOCK_EXPR_BODY (body);
-           break;
-         default:
-           found = 0;
-           body = NULL_TREE;
-         }
+      while (*bodyp)
+       {
+         tree body = *bodyp;
+         switch (TREE_CODE (body))
+           {
+           case CALL_EXPR:
+             found = CALL_EXPLICIT_CONSTRUCTOR_P (body);
+             if (CALL_THIS_CONSTRUCTOR_P (body))
+               invokes_this = 1;
+             break;
+           case COMPOUND_EXPR:
+           case EXPR_WITH_FILE_LOCATION:
+             bodyp = &TREE_OPERAND (body, 0);
+             continue;
+           case BLOCK:
+             bodyp = &BLOCK_EXPR_BODY (body);
+             continue;
+           default:
+             break;
+           }
+         break;
+       }
 
       /* Generate the assignment to this$<n>, if necessary */
       if ((thisn_assign = build_thisn_assign ()))
@@ -8922,9 +9113,8 @@ fix_constructors (tree mdecl)
          instance initializer blocks. */
       else
        {
-         compound = add_stmt_to_compound (compound, NULL_TREE,
-                                          TREE_OPERAND (found_call, 0));
-         TREE_OPERAND (found_call, 0) = empty_stmt_node;
+         compound = add_stmt_to_compound (compound, NULL_TREE, *bodyp);
+         *bodyp = build_java_empty_stmt ();
        }
 
       DECL_INIT_CALLS_THIS (mdecl) = invokes_this;
@@ -9005,23 +9195,33 @@ java_expand_classes (void)
 {
   int save_error_count = 0;
   static struct parser_ctxt *cur_ctxp = NULL;
+  location_t save_location;
 
   java_parse_abort_on_error ();
   if (!(ctxp = ctxp_for_generation))
     return;
   java_layout_classes ();
   java_parse_abort_on_error ();
+  save_location = input_location;
 
   for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
     {
+      tree current;
+      for (current = cur_ctxp->class_list; 
+          current; 
+          current = TREE_CHAIN (current))
+       gen_indirect_dispatch_tables (TREE_TYPE (current));
+    }
+  
+  for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
+    {
       ctxp = cur_ctxp;
-      input_filename = ctxp->filename;
+      input_location = ctxp->file_start_location;
       lang_init_source (2);           /* Error msgs have method prototypes */
       java_complete_expand_classes (); /* Complete and expand classes */
       java_parse_abort_on_error ();
     }
-  input_filename = main_input_filename;
-
+  input_location = save_location;
 
   /* Find anonymous classes and expand their constructor. This extra pass is
      necessary because the constructor itself is only generated when the
@@ -9032,7 +9232,7 @@ java_expand_classes (void)
       ctxp = cur_ctxp;
       for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
        {
-         current_class = TREE_TYPE (current);
+         output_class = current_class = TREE_TYPE (current);
          if (ANONYMOUS_CLASS_P (current_class))
            {
              tree d;
@@ -9040,9 +9240,7 @@ java_expand_classes (void)
                {
                  if (DECL_CONSTRUCTOR_P (d))
                    {
-                     restore_line_number_status (1);
                      java_complete_expand_method (d);
-                     restore_line_number_status (0);
                      break;    /* There is only one constructor. */
                    }
                }
@@ -9060,15 +9258,11 @@ java_expand_classes (void)
       for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
        {
          tree d;
-         current_class = TREE_TYPE (current);
+         output_class = current_class = TREE_TYPE (current);
          for (d = TYPE_METHODS (current_class); d; d = TREE_CHAIN (d))
            {
              if (DECL_RESULT (d) == NULL_TREE)
-               {
-                 restore_line_number_status (1);
-                 java_complete_expand_method (d);
-                 restore_line_number_status (0);
-               }
+               java_complete_expand_method (d);
            }
        }
     }
@@ -9091,15 +9285,13 @@ java_expand_classes (void)
              for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
                {
                  tree d;
-                 current_class = TREE_TYPE (current);
+                 output_class = current_class = TREE_TYPE (current);
                  for (d = TYPE_METHODS (current_class); d; d = TREE_CHAIN (d))
                    {
                      if (DECL_RESULT (d) == NULL_TREE)
                        {
                          something_changed = 1;
-                         restore_line_number_status (1);
                          java_complete_expand_method (d);
-                         restore_line_number_status (0);
                        }
                    }
                }
@@ -9110,10 +9302,10 @@ java_expand_classes (void)
 #endif
 
   /* If we've found error at that stage, don't try to generate
-     anything, unless we're emitting xrefs or checking the syntax only
+     anything, unless we're checking the syntax only
      (but not using -fsyntax-only for the purpose of generating
-     bytecode. */
-  if (java_error_count && !flag_emit_xref
+     bytecode).  */
+  if (java_error_count
       && (!flag_syntax_only && !flag_emit_class_files))
     return;
 
@@ -9156,12 +9348,9 @@ java_expand_classes (void)
           current;
           current = TREE_CHAIN (current))
        {
-         current_class = TREE_TYPE (TREE_VALUE (current));
-         outgoing_cpool = TYPE_CPOOL (current_class);
+         output_class = current_class = TREE_TYPE (TREE_VALUE (current));
          if (flag_emit_class_files)
            write_classfile (current_class);
-         if (flag_emit_xref)
-           expand_xref (current_class);
          else if (! flag_syntax_only)
            java_expand_method_bodies (current_class);
        }
@@ -9178,8 +9367,7 @@ java_finish_classes (void)
       ctxp = cur_ctxp;
       for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
        {
-         current_class = TREE_TYPE (current);
-         outgoing_cpool = TYPE_CPOOL (current_class);
+         output_class = current_class = TREE_TYPE (current);
          finish_class ();
        }
     }
@@ -9243,11 +9431,17 @@ merge_qualified_name (tree left, tree right)
    inherited from the location information of the `.' operator. */
 
 static tree
-make_qualified_name (tree left, tree right, int location)
+make_qualified_name (tree left, tree right,
+#ifdef USE_MAPPED_LOCATION
+                    source_location location
+#else
+                    int location
+#endif
+                    )
 {
 #ifdef USE_COMPONENT_REF
-  tree node = build (COMPONENT_REF, NULL_TREE, left, right);
-  EXPR_WFL_LINECOL (node) = location;
+  tree node = build3 (COMPONENT_REF, NULL_TREE, left, right, NULL_TREE);
+  SET_EXPR_LOCATION (node, location);
   return node;
 #else
   tree left_id = EXPR_WFL_NODE (left);
@@ -9257,6 +9451,15 @@ make_qualified_name (tree left, tree right, int location)
   merge = merge_qualified_name (left_id, right_id);
 
   /* Left wasn't qualified and is now qualified */
+#ifdef USE_MAPPED_LOCATION
+  if (!QUALIFIED_P (left_id))
+    {
+      tree wfl = build_expr_wfl (left_id, EXPR_LOCATION (left));
+      EXPR_WFL_QUALIFICATION (left) = build_tree_list (wfl, NULL_TREE);
+    }
+
+  wfl = build_expr_wfl (right_id, location);
+#else
   if (!QUALIFIED_P (left_id))
     {
       tree wfl = build_expr_wfl (left_id, ctxp->filename, 0, 0);
@@ -9266,8 +9469,8 @@ make_qualified_name (tree left, tree right, int location)
 
   wfl = build_expr_wfl (right_id, ctxp->filename, 0, 0);
   EXPR_WFL_LINECOL (wfl) = location;
+#endif
   chainon (EXPR_WFL_QUALIFICATION (left), build_tree_list (wfl, NULL_TREE));
-
   EXPR_WFL_NODE (left) = merge;
   return left;
 #endif
@@ -9340,21 +9543,21 @@ resolve_expression_name (tree id, tree *orig)
                  && !enclosing_context_p (DECL_CONTEXT (decl), current_class))
                {
                  parse_error_context
-                   (id, "Can't reference `%s' before the superclass constructor has been called", IDENTIFIER_POINTER (name));
+                   (id, "Can't reference %qs before the superclass constructor has been called", IDENTIFIER_POINTER (name));
                  return error_mark_node;
                }
 
              /* If we're processing an inner class and we're trying
                 to access a field belonging to an outer class, build
-                the access to the field */
-             if (!fs && outer_field_access_p (current_class, decl))
+                the access to the field */
+             if (nested_field_access_p (current_class, decl))
                {
-                 if (CLASS_STATIC (TYPE_NAME (current_class)))
+                 if (!fs && CLASS_STATIC (TYPE_NAME (current_class)))
                    {
                      static_ref_err (id, DECL_NAME (decl), current_class);
                      return error_mark_node;
                    }
-                 access = build_outer_field_access (id, decl);
+                 access = build_nested_field_access (id, decl);
                  if (orig)
                    *orig = access;
                  return access;
@@ -9394,12 +9597,12 @@ resolve_expression_name (tree id, tree *orig)
   /* We've got an error here */
   if (INNER_CLASS_TYPE_P (current_class))
     parse_error_context (id,
-                        "Local variable `%s' can't be accessed from within the inner class `%s' unless it is declared final",
+                        "Local variable %qs can't be accessed from within the inner class %qs unless it is declared final",
                         IDENTIFIER_POINTER (name),
                         IDENTIFIER_POINTER (DECL_NAME
                                             (TYPE_NAME (current_class))));
   else
-    parse_error_context (id, "Undefined variable `%s'",
+    parse_error_context (id, "Undefined variable %qs",
                         IDENTIFIER_POINTER (name));
 
   return error_mark_node;
@@ -9410,7 +9613,7 @@ static_ref_err (tree wfl, tree field_id, tree class_type)
 {
   parse_error_context
     (wfl,
-     "Can't make a static reference to nonstatic variable `%s' in class `%s'",
+     "Can't make a static reference to nonstatic variable %qs in class %qs",
      IDENTIFIER_POINTER (field_id),
      IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (class_type))));
 }
@@ -9425,7 +9628,7 @@ resolve_field_access (tree qual_wfl, tree *field_decl, tree *field_type)
 {
   int is_static = 0;
   tree field_ref;
-  tree decl, where_found, type_found;
+  tree decl = NULL_TREE, where_found, type_found;
 
   if (resolve_qualified_expression_name (qual_wfl, &decl,
                                         &where_found, &type_found))
@@ -9434,17 +9637,13 @@ resolve_field_access (tree qual_wfl, tree *field_decl, tree *field_type)
   /* Resolve the LENGTH field of an array here */
   if (DECL_P (decl) && DECL_NAME (decl) == length_identifier_node
       && type_found && TYPE_ARRAY_P (type_found)
-      && ! flag_emit_class_files && ! flag_emit_xref)
+      && ! flag_emit_class_files)
     {
       tree length = build_java_array_length_access (where_found);
       field_ref = length;
 
       /* In case we're dealing with a static array, we need to
-        initialize its class before the array length can be fetched.
-        It's also a good time to create a DECL_RTL for the field if
-        none already exists, otherwise if the field was declared in a
-        class found in an external file and hasn't been (and won't
-        be) accessed for its value, none will be created. */
+        initialize its class before the array length can be fetched.  */
       if (TREE_CODE (where_found) == VAR_DECL && FIELD_STATIC (where_found))
        {
          build_static_field_ref (where_found);
@@ -9460,7 +9659,7 @@ resolve_field_access (tree qual_wfl, tree *field_decl, tree *field_type)
       if (!type_found)
        type_found = DECL_CONTEXT (decl);
       is_static = FIELD_STATIC (decl);
-      field_ref = build_field_ref ((is_static && !flag_emit_xref?
+      field_ref = build_field_ref ((is_static ?
                                    NULL_TREE : where_found),
                                   type_found, DECL_NAME (decl));
       if (field_ref == error_mark_node)
@@ -9473,7 +9672,6 @@ resolve_field_access (tree qual_wfl, tree *field_decl, tree *field_type)
         looks like `field.ref', where `field' is a static field in an
         interface we implement.  */
       if (!flag_emit_class_files
-         && !flag_emit_xref
          && TREE_CODE (where_found) == VAR_DECL
          && FIELD_STATIC (where_found))
        {
@@ -9492,12 +9690,12 @@ resolve_field_access (tree qual_wfl, tree *field_decl, tree *field_type)
   return field_ref;
 }
 
-/* If NODE is an access to f static field, strip out the class
+/* If NODE is an access to a static field, strip out the class
    initialization part and return the field decl, otherwise, return
    NODE. */
 
-static tree
-strip_out_static_field_access_decl (tree node)
+tree
+extract_field_decl (tree node)
 {
   if (TREE_CODE (node) == COMPOUND_EXPR)
     {
@@ -9507,8 +9705,8 @@ strip_out_static_field_access_decl (tree node)
           tree call = TREE_OPERAND (op1, 0);
           if (TREE_CODE (call) == CALL_EXPR
               && TREE_CODE (TREE_OPERAND (call, 0)) == ADDR_EXPR
-              && TREE_OPERAND (TREE_OPERAND (call, 0), 0)
-              == soft_initclass_node)
+              && (TREE_OPERAND (TREE_OPERAND (call, 0), 0)
+                  == soft_initclass_node))
             return TREE_OPERAND (op1, 1);
         }
       else if (JDECL_P (op1))
@@ -9539,7 +9737,11 @@ resolve_qualified_expression_name (tree wfl, tree *found_decl,
     {
       tree qual_wfl = QUAL_WFL (q);
       tree ret_decl;           /* for EH checking */
+#ifdef USE_MAPPED_LOCATION
+      source_location location;  /* for EH checking */
+#else
       int location;            /* for EH checking */
+#endif
 
       /* 15.10.1 Field Access Using a Primary */
       switch (TREE_CODE (qual_wfl))
@@ -9585,8 +9787,14 @@ resolve_qualified_expression_name (tree wfl, tree *found_decl,
 
          if (from_super && TREE_CODE (qual_wfl) == CALL_EXPR)
            CALL_USING_SUPER (qual_wfl) = 1;
+#ifdef USE_MAPPED_LOCATION
+         location = (TREE_CODE (qual_wfl) == CALL_EXPR
+                     ? EXPR_LOCATION (TREE_OPERAND (qual_wfl, 0))
+                     : UNKNOWN_LOCATION);
+#else
          location = (TREE_CODE (qual_wfl) == CALL_EXPR ?
                      EXPR_WFL_LINECOL (TREE_OPERAND (qual_wfl, 0)) : 0);
+#endif
          *where_found = patch_method_invocation (qual_wfl, decl, type,
                                                  from_super,
                                                  &is_static, &ret_decl);
@@ -9606,7 +9814,7 @@ resolve_qualified_expression_name (tree wfl, tree *found_decl,
              && INNER_ENCLOSING_SCOPE_CHECK (type))
            {
              parse_error_context
-               (qual_wfl, "No enclosing instance for inner class `%s' is in scope%s",
+               (qual_wfl, "No enclosing instance for inner class %qs is in scope%s",
                 lang_printable_name (type, 0),
                 (!current_this ? "" :
                  "; an explicit one must be provided when creating this inner class"));
@@ -9618,7 +9826,11 @@ resolve_qualified_expression_name (tree wfl, tree *found_decl,
             instantiation using a primary qualified by a `new' */
          RESTORE_THIS_AND_CURRENT_CLASS;
 
+#ifdef USE_MAPPED_LOCATION
+         if (location != UNKNOWN_LOCATION)
+#else
          if (location)
+#endif
            {
              tree arguments = NULL_TREE;
              if (TREE_CODE (qual_wfl) == CALL_EXPR
@@ -9633,8 +9845,11 @@ resolve_qualified_expression_name (tree wfl, tree *found_decl,
             forcoming function's argument. */
          if (previous_call_static && is_static)
            {
-             decl = build (COMPOUND_EXPR, TREE_TYPE (*where_found),
-                           decl, *where_found);
+             /* We must set CAN_COMPLETE_NORMALLY for the first call
+                since it is done nowhere else.  */
+             CAN_COMPLETE_NORMALLY (decl) = 1;
+             decl = build2 (COMPOUND_EXPR, TREE_TYPE (*where_found),
+                            decl, *where_found);
              TREE_SIDE_EFFECTS (decl) = 1;
            }
          else
@@ -9718,13 +9933,13 @@ resolve_qualified_expression_name (tree wfl, tree *found_decl,
          if (!current_this)
            {
              parse_error_context
-               (wfl, "Keyword `this' used outside allowed context");
+               (wfl, "Keyword %<this%> used outside allowed context");
              return 1;
            }
          if (ctxp->explicit_constructor_p
              && type == current_class)
            {
-             parse_error_context (wfl, "Can't reference `this' before the superclass constructor has been called");
+             parse_error_context (wfl, "Can't reference %<this%> before the superclass constructor has been called");
              return 1;
            }
          /* We have to generate code for intermediate access */
@@ -9740,7 +9955,7 @@ resolve_qualified_expression_name (tree wfl, tree *found_decl,
              if (!enclosing_context_p (type, current_class))
                {
                  char *p  = xstrdup (lang_printable_name (type, 0));
-                 parse_error_context (qual_wfl, "Can't use variable `%s.this': type `%s' isn't an outer type of type `%s'",
+                 parse_error_context (qual_wfl, "Can't use variable %<%s.this%>: type %qs isn't an outer type of type %qs",
                                       p, p,
                                       lang_printable_name (current_class, 0));
                  free (p);
@@ -9773,7 +9988,7 @@ resolve_qualified_expression_name (tree wfl, tree *found_decl,
              || current_class == object_type_node)
            {
              parse_error_context
-               (wfl, "Keyword `super' used outside allowed context");
+               (wfl, "Keyword %<super%> used outside allowed context");
              return 1;
            }
          /* Otherwise, treat SUPER as (SUPER_CLASS)THIS */
@@ -9798,6 +10013,8 @@ resolve_qualified_expression_name (tree wfl, tree *found_decl,
              tree list;
              *where_found = decl;
 
+             check_pkg_class_access (DECL_NAME (decl), qual_wfl, true, NULL);
+
              /* We want to be absolutely sure that the class is laid
                  out. We're going to search something inside it. */
              *type_found = type = TREE_TYPE (decl);
@@ -9810,7 +10027,6 @@ resolve_qualified_expression_name (tree wfl, tree *found_decl,
                  list = TREE_CHAIN (q);
                  while (list)
                    {
-                     RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (list)) = 1;
                      RESOLVE_PACKAGE_NAME_P (QUAL_WFL (list)) = 0;
                      list = TREE_CHAIN (list);
                    }
@@ -9821,12 +10037,12 @@ resolve_qualified_expression_name (tree wfl, tree *found_decl,
              if (from_super || from_cast)
                parse_error_context
                  ((from_cast ? qual_wfl : wfl),
-                  "No variable `%s' defined in class `%s'",
+                  "No variable %qs defined in class %qs",
                   IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
                   lang_printable_name (type, 0));
              else
                parse_error_context
-                 (qual_wfl, "Undefined variable or class name: `%s'",
+                 (qual_wfl, "Undefined variable or class name: %qs",
                   IDENTIFIER_POINTER (name));
              return 1;
            }
@@ -9839,18 +10055,18 @@ resolve_qualified_expression_name (tree wfl, tree *found_decl,
          decl = QUAL_RESOLUTION (q);
 
          /* Sneak preview. If next we see a `new', we're facing a
-            qualification with resulted in a type being selected
-            instead of a field.  Report the error */
+            qualification which resulted in a type being selected
+            instead of a field.  Report the error */
          if(TREE_CHAIN (q)
             && TREE_CODE (TREE_PURPOSE (TREE_CHAIN (q))) == NEW_CLASS_EXPR)
            {
-             parse_error_context (qual_wfl, "Undefined variable `%s'",
+             parse_error_context (qual_wfl, "Undefined variable %qs",
                                   IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
              return 1;
            }
 
-         if (not_accessible_p (TREE_TYPE (decl), decl, type, 0))
-           return not_accessible_field_error (qual_wfl, decl);
+         check_pkg_class_access (DECL_NAME (decl), qual_wfl, true, NULL);
+          
          check_deprecation (qual_wfl, decl);
 
          type = TREE_TYPE (decl);
@@ -9870,18 +10086,29 @@ resolve_qualified_expression_name (tree wfl, tree *found_decl,
              decl = QUAL_RESOLUTION (q);
              if (!type)
                {
-                 if (TREE_CODE (decl) == FIELD_DECL && !FIELD_STATIC (decl))
+                 if (TREE_CODE (decl) == FIELD_DECL
+                      || TREE_CODE (decl) == VAR_DECL)
                    {
-                     if (current_this)
-                       *where_found = current_this;
-                     else
-                       {
-                         static_ref_err (qual_wfl, DECL_NAME (decl),
-                                         current_class);
-                         return 1;
-                       }
-                      if (outer_field_access_p (current_class, decl))
-                        decl = build_outer_field_access (qual_wfl, decl);
+                      if (TREE_CODE (decl) == FIELD_DECL
+                          && !FIELD_STATIC (decl))
+                        {
+                                 if (current_this)
+                            *where_found = current_this;
+                          else
+                            {
+                              static_ref_err (qual_wfl, DECL_NAME (decl),
+                                              current_class);
+                              return 1;
+                            }
+                        }
+                      else
+                        {
+                          *where_found = TREE_TYPE (decl);
+                          if (TREE_CODE (*where_found) == POINTER_TYPE)
+                            *where_found = TREE_TYPE (*where_found);
+                        }
+                      if (nested_field_access_p (current_class, decl))
+                        decl = build_nested_field_access (qual_wfl, decl);
                    }
                  else
                    {
@@ -9897,7 +10124,7 @@ resolve_qualified_expression_name (tree wfl, tree *found_decl,
          else if (TREE_CODE (qual_wfl) == INTEGER_CST)
            {
              parse_error_context
-               (wfl, "Can't use type `%s' as a qualifier",
+               (wfl, "Can't use type %qs as a qualifier",
                 lang_printable_name (TREE_TYPE (qual_wfl), 0));
              return 1;
            }
@@ -9916,7 +10143,7 @@ resolve_qualified_expression_name (tree wfl, tree *found_decl,
              if (!from_type && !JREFERENCE_TYPE_P (type))
                {
                  parse_error_context
-                   (qual_wfl, "Attempt to reference field `%s' in `%s %s'",
+                   (qual_wfl, "Attempt to reference field %qs in %<%s %s%>",
                     IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
                     lang_printable_name (type, 0),
                     IDENTIFIER_POINTER (DECL_NAME (decl)));
@@ -9947,7 +10174,7 @@ resolve_qualified_expression_name (tree wfl, tree *found_decl,
              if (field_decl == NULL_TREE)
                {
                  parse_error_context
-                   (qual_wfl, "No variable `%s' defined in type `%s'",
+                   (qual_wfl, "No variable %qs defined in type %qs",
                     IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
                     GET_TYPE_NAME (type));
                  return 1;
@@ -9970,7 +10197,7 @@ resolve_qualified_expression_name (tree wfl, tree *found_decl,
 
              /* Check on accessibility here */
              if (not_accessible_p (current_class, field_decl,
-                                   DECL_CONTEXT (field_decl), from_super))
+                                   *type_found, from_super))
                return not_accessible_field_error (qual_wfl,field_decl);    
              check_deprecation (qual_wfl, field_decl);
 
@@ -9990,7 +10217,7 @@ resolve_qualified_expression_name (tree wfl, tree *found_decl,
                }
              from_cast = from_super = 0;
 
-             /* It's an access from a type but it isn't static, we
+             /* If it's an access from a type but isn't static, we
                 make it relative to `this'. */
              if (!is_static && from_type)
                decl = current_this;
@@ -10005,8 +10232,8 @@ resolve_qualified_expression_name (tree wfl, tree *found_decl,
                    return 1;
                }
 
-             /* We want to keep the location were found it, and the type
-                we found. */
+              /* We want to keep the location where we found it, and the
+                 type we found.  */
              *where_found = decl;
              *type_found = type;
 
@@ -10014,10 +10241,18 @@ resolve_qualified_expression_name (tree wfl, tree *found_decl,
                 qualified this */
              if (from_qualified_this)
                {
-                 field_decl = build_outer_field_access (qual_wfl, field_decl);
+                 field_decl
+                    = build_nested_field_access (qual_wfl, field_decl);
                  from_qualified_this = 0;
                }
 
+              /* If needed, generate accessors for static field access.  */
+              if (is_static
+                  && FIELD_PRIVATE (field_decl)
+                  && flag_emit_class_files
+                  && nested_field_access_p (current_class, field_decl))
+                field_decl = build_nested_field_access (qual_wfl, field_decl);
+
              /* This is the decl found and eventually the next one to
                 search from */
              decl = field_decl;
@@ -10031,7 +10266,7 @@ resolve_qualified_expression_name (tree wfl, tree *found_decl,
              && TREE_CODE (TREE_PURPOSE (TREE_CHAIN (q))) == NEW_CLASS_EXPR
              && !JREFERENCE_TYPE_P (type))
            {
-             parse_error_context (qual_wfl, "Attempt to reference field `new' in a `%s'",
+             parse_error_context (qual_wfl, "Attempt to reference field %<new%> in a %qs",
                                   lang_printable_name (type, 0));
              return 1;
            }
@@ -10056,10 +10291,13 @@ static int
 not_accessible_p (tree reference, tree member, tree where, int from_super)
 {
   int access_flag = get_access_flags_from_decl (member);
-
-  /* Inner classes are processed by check_inner_class_access */
-  if (INNER_CLASS_TYPE_P (reference))
-    return 0;
+  bool is_static = false;
+  if (TREE_CODE (member) == FIELD_DECL ||
+      TREE_CODE (member) == VAR_DECL)
+    is_static = FIELD_STATIC (member);
+  else
+    is_static = METHOD_STATIC (member);
 
   /* Access always granted for members declared public */
   if (access_flag & ACC_PUBLIC)
@@ -10078,26 +10316,34 @@ not_accessible_p (tree reference, tree member, tree where, int from_super)
       if (from_super)
        return 0;
 
-      /* If where is active, access was made through a
-        qualifier. Access is granted if the type of the qualifier is
-        or is a sublass of the type the access made from (6.6.2.1.)  */
-      if (where && !inherits_from_p (reference, where))
-       return 1;
-
-      /* Otherwise, access is granted if occurring from the class where
-        member is declared or a subclass of it. Find the right
-        context to perform the check */
-      if (PURE_INNER_CLASS_TYPE_P (reference))
+      /* If WHERE is active, access was made through a qualifier. For 
+         non-static members, access is granted if the type of the qualifier 
+        is or is a sublass of the type the access is made from (6.6.2.1.)  */
+      if (where && !is_static)
         {
-          while (INNER_CLASS_TYPE_P (reference))
+         while (reference)
             {
-              if (inherits_from_p (reference, DECL_CONTEXT (member)))
-                return 0;
-              reference = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (reference)));
-            }
+             if (inherits_from_p (where, reference))
+               return 0;
+             if (INNER_CLASS_TYPE_P (reference))
+               reference = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (reference)));
+             else
+               break;
+           }
+         return 1;
+       }
+
+      /* Otherwise, access is granted if occurring from within the class
+         where member is declared, or a subclass of it.  */
+      while (reference)
+        {
+          if (inherits_from_p (reference, DECL_CONTEXT (member)))
+            return 0;
+         if (INNER_CLASS_TYPE_P (reference))
+            reference = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (reference)));
+         else
+           break;
         }
-      if (inherits_from_p (reference, DECL_CONTEXT (member)))
-       return 0;
       return 1;
     }
 
@@ -10106,21 +10352,15 @@ not_accessible_p (tree reference, tree member, tree where, int from_super)
      it for innerclasses too. */
   if (access_flag & ACC_PRIVATE)
     {
-      if (reference == DECL_CONTEXT (member))
-       return 0;
-      if (enclosing_context_p (reference, DECL_CONTEXT (member)))
+      if (reference == DECL_CONTEXT (member) ||
+          common_enclosing_context_p (DECL_CONTEXT (member), reference))
        return 0;
       return 1;
     }
 
-  /* Default access are permitted only when occurring within the
-     package in which the type (REFERENCE) is declared. In other words,
-     REFERENCE is defined in the current package */
-  if (ctxp->package)
-    return !class_in_current_package (reference);
-
-  /* Otherwise, access is granted */
-  return 0;
+  /* Default access is permitted only when occurring from within the
+     package in which the context (MEMBER) is declared.  */
+  return !class_in_current_package (DECL_CONTEXT (member));
 }
 
 /* Test deprecated decl access.  */
@@ -10130,7 +10370,7 @@ check_deprecation (tree wfl, tree decl)
   const char *file;
   tree elt;
 
-  if (! flag_deprecated)
+  if (! warn_deprecated)
     return;
 
   /* We want to look at the element type of arrays here, so we strip
@@ -10163,7 +10403,7 @@ check_deprecation (tree wfl, tree decl)
          the = "field";
          break;
        case TYPE_DECL:
-         parse_warning_context (wfl, "The class `%s' has been deprecated",
+         parse_warning_context (wfl, "The class %qs has been deprecated",
                                 IDENTIFIER_POINTER (DECL_NAME (decl)));
          return;
        default:
@@ -10173,7 +10413,7 @@ check_deprecation (tree wfl, tree decl)
          whole. */
       if (! CLASS_DEPRECATED (TYPE_NAME (DECL_CONTEXT (decl))))
        parse_warning_context
-         (wfl, "The %s `%s' in class `%s' has been deprecated",
+         (wfl, "The %s %qs in class %qs has been deprecated",
           the, lang_printable_name (decl, 0),
           IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)))));
     }
@@ -10206,7 +10446,7 @@ class_in_current_package (tree class)
     return 1;
 
   /* Compare the left part of the name of CLASS with the package name */
-  breakdown_qualified (&left, NULL, DECL_NAME (TYPE_NAME (class)));
+  split_qualified_name (&left, NULL, DECL_NAME (TYPE_NAME (class)));
   if (ctxp->package == left)
     {
       cicp_cache = class;
@@ -10277,7 +10517,7 @@ patch_method_invocation (tree patch, tree primary, tree where, int from_super,
       if (TREE_CODE (resolved) == VAR_DECL && FIELD_STATIC (resolved)
          && FIELD_FINAL (resolved)
          && !inherits_from_p (DECL_CONTEXT (resolved), current_class)
-         && !flag_emit_class_files && !flag_emit_xref)
+         && !flag_emit_class_files)
        resolved = build_class_init (DECL_CONTEXT (resolved), resolved);
 
       if (resolved == error_mark_node)
@@ -10290,7 +10530,7 @@ patch_method_invocation (tree patch, tree primary, tree where, int from_super,
         {
          parse_error_context
            (identifier_wfl,
-            "Can't invoke a method on primitive type `%s'",
+            "Can't invoke a method on primitive type %qs",
             IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
          PATCH_METHOD_RETURN_ERROR ();
        }
@@ -10305,17 +10545,17 @@ patch_method_invocation (tree patch, tree primary, tree where, int from_super,
            {
              parse_error_context
                (identifier_wfl,
-               "Can't make static reference to method `%s' in interface `%s'",
+               "Can't make static reference to method %qs in interface %qs",
                 IDENTIFIER_POINTER (identifier),
                 IDENTIFIER_POINTER (name));
              PATCH_METHOD_RETURN_ERROR ();
            }
          if (list && !METHOD_STATIC (list))
            {
-             char *fct_name = xstrdup (lang_printable_name (list, 0));
+             char *fct_name = xstrdup (lang_printable_name (list, 2));
              parse_error_context
                (identifier_wfl,
-                "Can't make static reference to method `%s %s' in class `%s'",
+                "Can't make static reference to method %<%s %s%> in class %qs",
                 lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0),
                 fct_name, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
              free (fct_name);
@@ -10368,7 +10608,7 @@ patch_method_invocation (tree patch, tree primary, tree where, int from_super,
              if (!class_to_search)
                {
                  parse_error_context
-                   (wfl, "Class `%s' not found in type declaration",
+                   (wfl, "Class %qs not found in type declaration",
                     IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
                  PATCH_METHOD_RETURN_ERROR ();
                }
@@ -10380,7 +10620,7 @@ patch_method_invocation (tree patch, tree primary, tree where, int from_super,
                  && TREE_CODE (patch) == NEW_CLASS_EXPR)
                {
                  parse_error_context
-                   (wfl, "Class `%s' is an abstract class. It can't be instantiated",
+                   (wfl, "Class %qs is an abstract class. It can't be instantiated",
                     IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
                  PATCH_METHOD_RETURN_ERROR ();
                }
@@ -10410,7 +10650,7 @@ patch_method_invocation (tree patch, tree primary, tree where, int from_super,
                  if (! INNER_CLASS_TYPE_P (class_to_search))
                    {
                      parse_error_context (wfl,
-                                          "No method named `%s' in scope",
+                                          "No method named %qs in scope",
                                           IDENTIFIER_POINTER (name));
                      PATCH_METHOD_RETURN_ERROR ();
                    }
@@ -10448,7 +10688,7 @@ patch_method_invocation (tree patch, tree primary, tree where, int from_super,
          && !DECL_INIT_P (current_function_decl))
        {
          parse_error_context
-           (wfl, "No enclosing instance for inner class `%s' is in scope%s",
+           (wfl, "No enclosing instance for inner class %qs is in scope%s",
             lang_printable_name (class_to_search, 0),
             (!current_this ? "" :
              "; an explicit one must be provided when creating this inner class"));
@@ -10513,17 +10753,15 @@ patch_method_invocation (tree patch, tree primary, tree where, int from_super,
     {
       const char *const fct_name = IDENTIFIER_POINTER (DECL_NAME (list));
       const char *const access =
-       java_accstring_lookup (get_access_flags_from_decl (list));
+       accessibility_string (get_access_flags_from_decl (list));
       const char *const klass =
        IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (list))));
       const char *const refklass =
        IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class)));
       const char *const what = (DECL_CONSTRUCTOR_P (list)
                                ? "constructor" : "method");
-      /* FIXME: WFL yields the wrong message here but I don't know
-        what else to use.  */
       parse_error_context (wfl,
-                          "Can't access %s %s `%s.%s' from `%s'",
+                          "Can't access %s %s %<%s.%s%> from %qs",
                           access, what, klass, fct_name, refklass);
       PATCH_METHOD_RETURN_ERROR ();
     }
@@ -10604,7 +10842,7 @@ patch_method_invocation (tree patch, tree primary, tree where, int from_super,
       && (!primary || primary == current_this)
       && (TREE_CODE (patch) != NEW_CLASS_EXPR))
     {
-      parse_error_context (wfl, "Can't reference `this' before the superclass constructor has been called");
+      parse_error_context (wfl, "Can't reference %<this%> before the superclass constructor has been called");
       PATCH_METHOD_RETURN_ERROR ();
     }
   java_parser_context_restore_global ();
@@ -10633,8 +10871,8 @@ patch_method_invocation (tree patch, tree primary, tree where, int from_super,
         initialization statement and build a compound statement along
         with the super constructor invocation. */
       CAN_COMPLETE_NORMALLY (patch) = 1;
-      patch = build (COMPOUND_EXPR, void_type_node, patch,
-                    java_complete_tree (finit_call));
+      patch = build2 (COMPOUND_EXPR, void_type_node, patch,
+                     java_complete_tree (finit_call));
     }
   return patch;
 }
@@ -10651,7 +10889,7 @@ check_for_static_method_reference (tree wfl, tree node, tree method,
     {
       char *fct_name = xstrdup (lang_printable_name (method, 0));
       parse_error_context
-       (wfl, "Can't make static reference to method `%s %s' in class `%s'",
+       (wfl, "Can't make static reference to method %<%s %s%> in class %qs",
         lang_printable_name (TREE_TYPE (TREE_TYPE (method)), 0), fct_name,
         IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (where))));
       free (fct_name);
@@ -10758,7 +10996,7 @@ patch_invoke (tree patch, tree method, tree args)
   if (TREE_CODE (t) == POINTER_TYPE && !CLASS_LOADED_P (TREE_TYPE (t)))
     resolve_and_layout (TREE_TYPE (t), NULL);
 
-  if (flag_emit_class_files || flag_emit_xref)
+  if (flag_emit_class_files)
     func = method;
   else
     {
@@ -10821,32 +11059,29 @@ patch_invoke (tree patch, tree method, tree args)
   if (TREE_CODE (original_call) == NEW_CLASS_EXPR)
     {
       tree class = DECL_CONTEXT (method);
-      tree c1, saved_new, size, new;
+      tree c1, saved_new, new;
       tree alloc_node;
 
-      if (flag_emit_class_files || flag_emit_xref)
+      if (flag_emit_class_files)
        {
          TREE_TYPE (patch) = build_pointer_type (class);
          return patch;
        }
       if (!TYPE_SIZE (class))
        safe_layout_class (class);
-      size = size_in_bytes (class);
       alloc_node =
        (class_has_finalize_method (class) ? alloc_object_node
                                           : alloc_no_finalizer_node);
-      new = build (CALL_EXPR, promote_type (class),
-                  build_address_of (alloc_node),
-                  tree_cons (NULL_TREE, build_class_ref (class),
-                             build_tree_list (NULL_TREE,
-                                              size_in_bytes (class))),
-                  NULL_TREE);
+      new = build3 (CALL_EXPR, promote_type (class),
+                   build_address_of (alloc_node),
+                   build_tree_list (NULL_TREE, build_class_ref (class)),
+                   NULL_TREE);
       saved_new = save_expr (new);
       c1 = build_tree_list (NULL_TREE, saved_new);
       TREE_CHAIN (c1) = TREE_OPERAND (original_call, 1);
       TREE_OPERAND (original_call, 1) = c1;
       TREE_SET_CODE (original_call, CALL_EXPR);
-      patch = build (COMPOUND_EXPR, TREE_TYPE (new), patch, saved_new);
+      patch = build2 (COMPOUND_EXPR, TREE_TYPE (new), patch, saved_new);
     }
 
   /* If CHECK is set, then we are building a check to see if the object
@@ -10856,8 +11091,8 @@ patch_invoke (tree patch, tree method, tree args)
       /* We have to call force_evaluation_order now because creating a
         COMPOUND_EXPR wraps the arg list in a way that makes it
         unrecognizable by force_evaluation_order later.  Yuk.  */
-      patch = build (COMPOUND_EXPR, TREE_TYPE (patch), check, 
-                    force_evaluation_order (patch));
+      patch = build2 (COMPOUND_EXPR, TREE_TYPE (patch), check, 
+                     force_evaluation_order (patch));
       TREE_SIDE_EFFECTS (patch) = 1;
     }
 
@@ -10876,16 +11111,16 @@ patch_invoke (tree patch, tree method, tree args)
       /* We have to call force_evaluation_order now because creating a
         COMPOUND_EXPR wraps the arg list in a way that makes it
         unrecognizable by force_evaluation_order later.  Yuk.  */
-      tree save = save_expr (force_evaluation_order (patch));
+      tree save = force_evaluation_order (patch);
       tree type = TREE_TYPE (patch);
 
-      patch = build (COMPOUND_EXPR, type, save, empty_stmt_node);
+      patch = build2 (COMPOUND_EXPR, type, save, build_java_empty_stmt ());
       list = tree_cons (method, patch,
                        DECL_FUNCTION_STATIC_METHOD_INVOCATION_COMPOUND (fndecl));
 
       DECL_FUNCTION_STATIC_METHOD_INVOCATION_COMPOUND (fndecl) = list;
 
-      patch = build (COMPOUND_EXPR, type, patch, save);
+      patch = build2 (COMPOUND_EXPR, type, patch, save);
     }
 
   return patch;
@@ -10907,11 +11142,20 @@ invocation_mode (tree method, int super)
   if (DECL_CONSTRUCTOR_P (method))
     return INVOKE_STATIC;
 
-  if (access & ACC_FINAL || access & ACC_PRIVATE)
+  if (access & ACC_PRIVATE)
     return INVOKE_NONVIRTUAL;
 
-  if (CLASS_FINAL (TYPE_NAME (DECL_CONTEXT (method))))
-    return INVOKE_NONVIRTUAL;
+  /* Binary compatibility: just because it's final today, that doesn't
+     mean it'll be final tomorrow.  */
+  if (! flag_indirect_dispatch  
+      || DECL_CONTEXT (method) == object_type_node)
+    {
+      if (access & ACC_FINAL)
+       return INVOKE_NONVIRTUAL;
+
+      if (CLASS_FINAL (TYPE_NAME (DECL_CONTEXT (method))))
+       return INVOKE_NONVIRTUAL;
+    }
 
   if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))))
     return INVOKE_INTERFACE;
@@ -10949,12 +11193,10 @@ lookup_method_invoke (int lc, tree cl, tree class, tree name, tree arg_list)
 
   if (lc && ANONYMOUS_CLASS_P (class))
     {
-      tree saved_current_class;
       tree mdecl = craft_constructor (TYPE_NAME (class), atl);
-      saved_current_class = current_class;
-      current_class = class;
-      fix_constructors (mdecl);
-      current_class = saved_current_class;
+      /* The anonymous class may have already been laid out, so make sure
+         the new constructor is laid out here.  */
+      layout_class_method (class, CLASSTYPE_SUPER (class), mdecl, NULL_TREE);
     }
 
   /* Find all candidates and then refine the list, searching for the
@@ -10979,7 +11221,7 @@ lookup_method_invoke (int lc, tree cl, tree class, tree name, tree arg_list)
          if (!cm || not_accessible_p (class, cm, NULL_TREE, 0))
            continue;
          sprintf
-           (string, "  `%s' in `%s'%s",
+           (string, "  '%s' in '%s'%s",
             get_printable_method_name (cm),
             IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (cm)))),
             (TREE_CHAIN (current) ? "\n" : ""));
@@ -10993,7 +11235,7 @@ lookup_method_invoke (int lc, tree cl, tree class, tree name, tree arg_list)
   TYPE_ARG_TYPES (method) = atl;
   signature = build_java_argument_signature (method);
   dup = xstrdup (lang_printable_name (class, 0));
-  parse_error_context (cl, "Can't find %s `%s(%s)' in type `%s'%s",
+  parse_error_context (cl, "Can't find %s %<%s(%s)%> in type %qs%s",
                       (lc ? "constructor" : "method"),
                       (lc ? dup : IDENTIFIER_POINTER (name)),
                       IDENTIFIER_POINTER (signature), dup,
@@ -11012,6 +11254,8 @@ find_applicable_accessible_methods_list (int lc, tree class, tree name,
   static htab_t searched_classes;
   static int search_not_done = 0;
   tree list = NULL_TREE, all_list = NULL_TREE;
+  tree base_binfo;
+  int i;
 
   /* Check the hash table to determine if this class has been searched
      already. */
@@ -11029,7 +11273,7 @@ find_applicable_accessible_methods_list (int lc, tree class, tree name,
   search_not_done++;
   *htab_find_slot (searched_classes, class, INSERT) = class;
 
-  if (!CLASS_LOADED_P (class) && !CLASS_FROM_SOURCE_P (class))
+  if (!CLASS_LOADED_P (class))
     {
       load_class (class, 1);
       safe_layout_class (class);
@@ -11039,16 +11283,13 @@ find_applicable_accessible_methods_list (int lc, tree class, tree name,
   if (TREE_CODE (TYPE_NAME (class)) == TYPE_DECL
       && CLASS_INTERFACE (TYPE_NAME (class)))
     {
-      int i, n;
-      tree basetype_vec = TYPE_BINFO_BASETYPES (class);
       search_applicable_methods_list (lc, TYPE_METHODS (class),
                                      name, arglist, &list, &all_list);
-      n = TREE_VEC_LENGTH (basetype_vec);
-      for (i = 1; i < n; i++)
+      for (i = 1; BINFO_BASE_ITERATE (TYPE_BINFO (class), i, base_binfo); i++)
        {
-         tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
+         tree t = BINFO_TYPE (base_binfo);
          tree rlist;
-
+         
          rlist = find_applicable_accessible_methods_list (lc,  t, name,
                                                           arglist);
          list = chainon (rlist, list);
@@ -11072,21 +11313,20 @@ find_applicable_accessible_methods_list (int lc, tree class, tree name,
 
       /* We must search all interfaces of this class */
       if (!lc)
-      {
-       tree basetype_vec = TYPE_BINFO_BASETYPES (class);
-       int n = TREE_VEC_LENGTH (basetype_vec), i;
-       for (i = 1; i < n; i++)
-         {
-           tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
-           if (t != object_type_node)
-             {
-               tree rlist
-                 = find_applicable_accessible_methods_list (lc, t,
-                                                            name, arglist);
-               list = chainon (rlist, list);
-             }
-         }
-      }
+       {
+         for (i = 1;
+              BINFO_BASE_ITERATE (TYPE_BINFO (class), i, base_binfo); i++)
+           {
+             tree t = BINFO_TYPE (base_binfo);
+             if (t != object_type_node)
+               {
+                 tree rlist
+                   = find_applicable_accessible_methods_list (lc, t,
+                                                              name, arglist);
+                 list = chainon (rlist, list);
+               }
+           }
+       }
 
       /* Search superclass */
       if (!lc && CLASSTYPE_SUPER (class) != NULL_TREE)
@@ -11178,13 +11418,9 @@ find_most_specific_methods_list (tree list)
          if (argument_types_convertible (method_v, current_v))
            {
              if (valid_method_invocation_conversion_p
-                 (DECL_CONTEXT (method_v), DECL_CONTEXT (current_v))
-                 || (INNER_CLASS_TYPE_P (DECL_CONTEXT (current_v))
-                     && enclosing_context_p (DECL_CONTEXT (method_v),
-                                             DECL_CONTEXT (current_v))))
+                 (DECL_CONTEXT (method_v), DECL_CONTEXT (current_v)))
                {
-                 int v = (DECL_SPECIFIC_COUNT (current_v) +=
-                   (INNER_CLASS_TYPE_P (DECL_CONTEXT (current_v)) ? 2 : 1));
+                 int v = (DECL_SPECIFIC_COUNT (current_v) += 1);
                  max = (v > max ? v : max);
                }
            }
@@ -11251,7 +11487,7 @@ static GTY(()) tree m2_arg_cache;
 static int
 argument_types_convertible (tree m1, tree m2_or_arglist)
 {
-  register tree m1_arg, m2_arg;
+  tree m1_arg, m2_arg;
 
   SKIP_THIS_AND_ARTIFICIAL_PARMS (m1_arg, m1)
 
@@ -11288,211 +11524,58 @@ argument_types_convertible (tree m1, tree m2_or_arglist)
 
 /* Qualification routines */
 
+/* Given a name x.y.z, look up x locally.  If it's found, save the
+   decl.  If it's not found, mark the name as RESOLVE_PACKAGE_NAME_P,
+   so that we later try and load the appropriate classes.  */
 static void
 qualify_ambiguous_name (tree id)
 {
-  tree qual, qual_wfl, name = NULL_TREE, decl, ptr_type = NULL_TREE,
-    saved_current_class;
-  int again, super_found = 0, this_found = 0, new_array_found = 0;
-  int code;
-
-  /* We first qualify the first element, then derive qualification of
-     others based on the first one. If the first element is qualified
-     by a resolution (field or type), this resolution is stored in the
-     QUAL_RESOLUTION of the qual element being examined. We need to
-     save the current_class since the use of SUPER might change the
-     its value. */
-  saved_current_class = current_class;
-  qual = EXPR_WFL_QUALIFICATION (id);
-  do {
-
-    /* Simple qualified expression feature a qual_wfl that is a
-       WFL. Expression derived from a primary feature more complicated
-       things like a CALL_EXPR. Expression from primary need to be
-       worked out to extract the part on which the qualification will
-       take place. */
-    qual_wfl = QUAL_WFL (qual);
-    switch (TREE_CODE (qual_wfl))
-      {
-      case CALL_EXPR:
-       qual_wfl = TREE_OPERAND (qual_wfl, 0);
-       if (TREE_CODE (qual_wfl) != EXPR_WITH_FILE_LOCATION
-           || (EXPR_WFL_QUALIFICATION (qual_wfl)
-               && TREE_CODE (EXPR_WFL_QUALIFICATION (qual_wfl)) == TREE_LIST))
-         {
-           qual = EXPR_WFL_QUALIFICATION (qual_wfl);
-           qual_wfl = QUAL_WFL (qual);
-         }
-       break;
-      case NEW_ARRAY_EXPR:
-      case NEW_ANONYMOUS_ARRAY_EXPR:
-       qual = TREE_CHAIN (qual);
-       again = new_array_found = 1;
-       continue;
-      case CONVERT_EXPR:
-       break;
-      case NEW_CLASS_EXPR:
-       qual_wfl = TREE_OPERAND (qual_wfl, 0);
-       break;
-      case ARRAY_REF:
-       while (TREE_CODE (qual_wfl) == ARRAY_REF)
-         qual_wfl = TREE_OPERAND (qual_wfl, 0);
-       break;
-      case STRING_CST:
-       qual = TREE_CHAIN (qual);
-       qual_wfl = QUAL_WFL (qual);
-       break;
-      case CLASS_LITERAL:
-       qual = TREE_CHAIN (qual);
-       qual_wfl = QUAL_WFL (qual);
-      break;
-      default:
-       /* Fix for -Wall. Just break doing nothing */
-       break;
-      }
-
-    ptr_type = current_class;
-    again = 0;
-    code = TREE_CODE (qual_wfl);
-
-    /* Pos evaluation: non WFL leading expression nodes */
-    if (code == CONVERT_EXPR
-       && TREE_CODE (TREE_TYPE (qual_wfl)) == EXPR_WITH_FILE_LOCATION)
-      name = EXPR_WFL_NODE (TREE_TYPE (qual_wfl));
-
-    else if (code == INTEGER_CST)
-      name = qual_wfl;
-
-    else if (code == CONVERT_EXPR &&
-            TREE_CODE (TREE_OPERAND (qual_wfl, 0)) == EXPR_WITH_FILE_LOCATION)
-      name = TREE_OPERAND (qual_wfl, 0);
+  tree name, decl;
 
-    else if (code == CONVERT_EXPR
-            && TREE_CODE (TREE_OPERAND (qual_wfl, 0)) == CALL_EXPR
-            && (TREE_CODE (TREE_OPERAND (TREE_OPERAND (qual_wfl, 0), 0))
-                == EXPR_WITH_FILE_LOCATION))
-      name = TREE_OPERAND (TREE_OPERAND (qual_wfl, 0), 0);
+  /* We inspect the first item of the qualification list.  As a sanity
+     check, make sure that it is an identfier node.  */
+  tree qual = EXPR_WFL_QUALIFICATION (id);
+  tree qual_wfl = QUAL_WFL (qual);
 
-    else if ((code == ARRAY_REF || code == CALL_EXPR || code == MODIFY_EXPR) &&
-            TREE_CODE (TREE_OPERAND (qual_wfl, 0)) == EXPR_WITH_FILE_LOCATION)
-      name = EXPR_WFL_NODE (TREE_OPERAND (qual_wfl, 0));
-
-    else if (code == TREE_LIST)
-      name = EXPR_WFL_NODE (TREE_PURPOSE (qual_wfl));
+  if (TREE_CODE (qual_wfl) != EXPR_WITH_FILE_LOCATION)
+    return;
 
-    else if (code == STRING_CST || code == CONDITIONAL_EXPR
-            || code == PLUS_EXPR)
-      {
-       qual = TREE_CHAIN (qual);
-       qual_wfl = QUAL_WFL (qual);
-       again = 1;
-      }
-    else
-      {
-       name = EXPR_WFL_NODE (qual_wfl);
-       if (!name)
-         {
-           qual = EXPR_WFL_QUALIFICATION (qual_wfl);
-           again = 1;
-         }
-      }
+  name = EXPR_WFL_NODE (qual_wfl);
 
-    /* If we have a THIS (from a primary), we set the context accordingly */
-    if (name == this_identifier_node)
-      {
-       /* This isn't really elegant. One more added irregularity
-          before I start using COMPONENT_REF (hopefully very soon.)  */
-       if (TREE_CODE (TREE_PURPOSE (qual)) == ARRAY_REF
-           && TREE_CODE (TREE_OPERAND (TREE_PURPOSE (qual), 0)) ==
-              EXPR_WITH_FILE_LOCATION
-           && EXPR_WFL_NODE (TREE_OPERAND (TREE_PURPOSE (qual), 0)) ==
-              this_identifier_node)
-           {
-             qual = TREE_OPERAND (TREE_PURPOSE (qual), 0);
-             qual = EXPR_WFL_QUALIFICATION (qual);
-           }
-       qual = TREE_CHAIN (qual);
-       qual_wfl = QUAL_WFL (qual);
-       if (TREE_CODE (qual_wfl) == CALL_EXPR)
-         again = 1;
-       else if (TREE_CODE (qual_wfl) == EXPR_WITH_FILE_LOCATION)
-         name = EXPR_WFL_NODE (qual_wfl);
-       else if (TREE_CODE (qual_wfl) == NEW_CLASS_EXPR)
-         name = TREE_OPERAND (qual_wfl, 0);
-       this_found = 1;
-      }
-    /* If we have a SUPER, we set the context accordingly */
-    if (name == super_identifier_node)
-      {
-       current_class = CLASSTYPE_SUPER (ptr_type);
-       /* Check that there is such a thing as a super class. If not,
-          return.  The error will be caught later on, during the
-          resolution */
-       if (!current_class)
-         {
-           current_class = saved_current_class;
-           return;
-         }
-       qual = TREE_CHAIN (qual);
-       /* Do one more iteration to set things up */
-       super_found = again = 1;
-      }
-  } while (again);
+  /* If we don't have an identifier, or we have a 'this' or 'super',
+     then field access processing is all we need : there is nothing
+     for us to do.  */
+  if (!name || TREE_CODE (name) != IDENTIFIER_NODE ||
+      name == this_identifier_node ||
+      name == super_identifier_node)
+    return;
 
   /* If name appears within the scope of a local variable declaration
-     or parameter declaration, then it is an expression name. We don't
-     carry this test out if we're in the context of the use of SUPER
-     or THIS */
-  if (!this_found && !super_found
-      && TREE_CODE (name) != STRING_CST && TREE_CODE (name) != INTEGER_CST
-      && (decl = IDENTIFIER_LOCAL_VALUE (name)))
-    {
-      RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
+     or parameter declaration, or is a field within an enclosing
+     class, then it is an expression name.  Save the decl and let
+     resolve_field_access do it's work.  */
+  if ((decl = IDENTIFIER_LOCAL_VALUE (name)) ||
+      (decl = lookup_field_wrapper (current_class, name)))
+    {
       QUAL_RESOLUTION (qual) = decl;
+      return;
     }
 
-  /* If within the class/interface NAME was found to be used there
-     exists a (possibly inherited) field named NAME, then this is an
-     expression name. If we saw a NEW_ARRAY_EXPR before and want to
-     address length, it is OK. */
-  else if ((decl = lookup_field_wrapper (ptr_type, name))
-          || name == length_identifier_node)
-    {
-      RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
-      QUAL_RESOLUTION (qual) = (new_array_found ? NULL_TREE : decl);
-    }
-
-  /* We reclassify NAME as yielding to a type name resolution if:
-     - NAME is a class/interface declared within the compilation
-       unit containing NAME,
-     - NAME is imported via a single-type-import declaration,
-     - NAME is declared in an another compilation unit of the package
-       of the compilation unit containing NAME,
-     - NAME is declared by exactly on type-import-on-demand declaration
-     of the compilation unit containing NAME.
-     - NAME is actually a STRING_CST.
-     This can't happen if the expression was qualified by `this.' */
-  else if (! this_found &&
-          (TREE_CODE (name) == STRING_CST ||
-           TREE_CODE (name) == INTEGER_CST ||
-           (decl = resolve_and_layout (name, NULL_TREE))))
+  /* If name is a known class name (either declared or imported), mark
+     us as a type name.  */
+  if ((decl = resolve_and_layout (name, NULL_TREE)))
     {
       RESOLVE_TYPE_NAME_P (qual_wfl) = 1;
       QUAL_RESOLUTION (qual) = decl;
     }
 
-  /* Method call, array references and cast are expression name */
-  else if (TREE_CODE (QUAL_WFL (qual)) == CALL_EXPR
-          || TREE_CODE (QUAL_WFL (qual)) == ARRAY_REF
-          || TREE_CODE (QUAL_WFL (qual)) == CONVERT_EXPR
-          || TREE_CODE (QUAL_WFL (qual)) == MODIFY_EXPR)
-    RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
-
   /* Check here that NAME isn't declared by more than one
      type-import-on-demand declaration of the compilation unit
      containing NAME. FIXME */
 
-  /* Otherwise, NAME is reclassified as a package name */
+  /* We couldn't find a declaration for the name.  Assume for now that
+     we have a qualified class name that needs to be loaded from an
+     external class file.  */
   else
     RESOLVE_PACKAGE_NAME_P (qual_wfl) = 1;
 
@@ -11503,75 +11586,14 @@ qualify_ambiguous_name (tree id)
     {
       if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
        RESOLVE_PACKAGE_NAME_P (QUAL_WFL (qual)) = 1;
-      else
-       RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (qual)) = 1;
     }
 
   /* Store the global qualification for the ambiguous part of ID back
      into ID fields */
-  if (RESOLVE_EXPRESSION_NAME_P (qual_wfl))
-    RESOLVE_EXPRESSION_NAME_P (id) = 1;
-  else if (RESOLVE_TYPE_NAME_P (qual_wfl))
+  if (RESOLVE_TYPE_NAME_P (qual_wfl))
     RESOLVE_TYPE_NAME_P (id) = 1;
   else if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
     RESOLVE_PACKAGE_NAME_P (id) = 1;
-
-  /* Restore the current class */
-  current_class = saved_current_class;
-}
-
-static int
-breakdown_qualified (tree *left, tree *right, tree source)
-{
-  char *p, *base;
-  int l = IDENTIFIER_LENGTH (source);
-
-  base = alloca (l + 1);
-  memcpy (base, IDENTIFIER_POINTER (source), l + 1);
-
-  /* Breakdown NAME into REMAINDER . IDENTIFIER.  */
-  p = base + l - 1;
-  while (*p != '.' && p != base)
-    p--;
-
-  /* We didn't find a '.'. Return an error.  */
-  if (p == base)
-    return 1;
-
-  *p = '\0';
-  if (right)
-    *right = get_identifier (p+1);
-  *left = get_identifier (base);
-
-  return 0;
-}
-
-/* Return TRUE if two classes are from the same package. */
-
-static int
-in_same_package (tree name1, tree name2)
-{
-  tree tmp;
-  tree pkg1;
-  tree pkg2;
-
-  if (TREE_CODE (name1) == TYPE_DECL)
-    name1 = DECL_NAME (name1);
-  if (TREE_CODE (name2) == TYPE_DECL)
-    name2 = DECL_NAME (name2);
-
-  if (QUALIFIED_P (name1) != QUALIFIED_P (name2))
-    /* One in empty package. */
-    return 0;
-
-  if (QUALIFIED_P (name1) == 0 && QUALIFIED_P (name2) == 0)
-    /* Both in empty package. */
-    return 1;
-
-  breakdown_qualified (&pkg1, &tmp, name1);
-  breakdown_qualified (&pkg2, &tmp, name2);
-
-  return (pkg1 == pkg2);
 }
 
 /* Patch tree nodes in a function body. When a BLOCK is found, push
@@ -11583,8 +11605,7 @@ java_complete_tree (tree node)
 {
   node = java_complete_lhs (node);
   if (JDECL_P (node) && CLASS_FINAL_VARIABLE_P (node)
-      && DECL_INITIAL (node) != NULL_TREE
-      && !flag_emit_xref)
+      && DECL_INITIAL (node) != NULL_TREE)
     {
       tree value = fold_constant_for_init (node, node);
       if (value != NULL_TREE)
@@ -11668,12 +11689,12 @@ java_complete_lhs (tree node)
              long blocks. */
          ptr = &BLOCK_EXPR_BODY (node);
          while (TREE_CODE (*ptr) == COMPOUND_EXPR
-                && TREE_OPERAND (*ptr, 1) != empty_stmt_node)
+                && !IS_EMPTY_STMT (TREE_OPERAND (*ptr, 1)))
            {
              tree cur = java_complete_tree (TREE_OPERAND (*ptr, 0));
              tree *next = &TREE_OPERAND (*ptr, 1);
              TREE_OPERAND (*ptr, 0) = cur;
-             if (cur == empty_stmt_node)
+             if (IS_EMPTY_STMT (cur))
                {
                  /* Optimization;  makes it easier to detect empty bodies.
                     Most useful for <clinit> with all-constant initializer. */
@@ -11734,13 +11755,11 @@ java_complete_lhs (tree node)
     case TRY_FINALLY_EXPR:
       COMPLETE_CHECK_OP_0 (node);
       COMPLETE_CHECK_OP_1 (node);
-      /* Reduce try/finally nodes with an empty try block.  */
-      if (TREE_OPERAND (node, 0) == empty_stmt_node
-         || BLOCK_EMPTY_P (TREE_OPERAND (node, 0)))
+      if (IS_EMPTY_STMT (TREE_OPERAND (node, 0)))
+       /* Reduce try/finally nodes with an empty try block.  */
        return TREE_OPERAND (node, 1);
-      /* Likewise for an empty finally block.  */
-      if (TREE_OPERAND (node, 1) == empty_stmt_node
-         || BLOCK_EMPTY_P (TREE_OPERAND (node, 1)))
+      if (IS_EMPTY_STMT (TREE_OPERAND (node, 1)))
+       /* Likewise for an empty finally block.  */
        return TREE_OPERAND (node, 0);
       CAN_COMPLETE_NORMALLY (node)
        = (CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0))
@@ -11755,7 +11774,7 @@ java_complete_lhs (tree node)
       TREE_TYPE (node) = void_type_node;
       POP_LABELED_BLOCK ();
 
-      if (LABELED_BLOCK_BODY (node) == empty_stmt_node)
+      if (IS_EMPTY_STMT (LABELED_BLOCK_BODY (node)))
        {
          LABELED_BLOCK_BODY (node) = NULL_TREE;
          CAN_COMPLETE_NORMALLY (node) = 1;
@@ -11765,8 +11784,6 @@ java_complete_lhs (tree node)
       return node;
 
     case EXIT_BLOCK_EXPR:
-      /* We don't complete operand 1, because it's the return value of
-         the EXIT_BLOCK_EXPR which doesn't exist it Java */
       return patch_bc_statement (node);
 
     case CASE_EXPR:
@@ -11776,8 +11793,13 @@ java_complete_lhs (tree node)
 
       /* First, the case expression must be constant. Values of final
          fields are accepted. */
+      nn = fold_constant_for_init (cn, NULL_TREE);
+      if (nn != NULL_TREE)
+       cn = nn;
+
       cn = fold (cn);
-      if ((TREE_CODE (cn) == COMPOUND_EXPR || TREE_CODE (cn) == COMPONENT_REF)
+      if ((TREE_CODE (cn) == COMPOUND_EXPR
+          || TREE_CODE (cn) == COMPONENT_REF)
          && JDECL_P (TREE_OPERAND (cn, 1))
          && FIELD_FINAL (TREE_OPERAND (cn, 1))
          && DECL_INITIAL (TREE_OPERAND (cn, 1)))
@@ -11786,10 +11808,11 @@ java_complete_lhs (tree node)
                                       TREE_OPERAND (cn, 1));
        }
       /* Accept final locals too. */
-      else if (TREE_CODE (cn) == VAR_DECL && DECL_FINAL (cn))
+      else if (TREE_CODE (cn) == VAR_DECL && DECL_FINAL (cn) 
+              && DECL_INITIAL (cn))
        cn = fold_constant_for_init (DECL_INITIAL (cn), cn);
 
-      if (!TREE_CONSTANT (cn) && !flag_emit_xref)
+      if (!TREE_CONSTANT (cn))
        {
          EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
          parse_error_context (node, "Constant expression required");
@@ -11805,7 +11828,7 @@ java_complete_lhs (tree node)
          EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
          parse_error_context
            (wfl_operator,
-            "Incompatible type for case. Can't convert `%s' to `int'",
+            "Incompatible type for case. Can't convert %qs to %<int%>",
             lang_printable_name (TREE_TYPE (cn), 0));
          return error_mark_node;
        }
@@ -11833,9 +11856,13 @@ java_complete_lhs (tree node)
       /* Only one default label is allowed per switch statement */
       if (SWITCH_HAS_DEFAULT (nn))
        {
+#ifdef USE_MAPPED_LOCATION
+         SET_EXPR_LOCATION (wfl_operator, EXPR_LOCATION (node));
+#else
          EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
+#endif
          parse_error_context (wfl_operator,
-                              "Duplicate case label: `default'");
+                              "Duplicate case label: %<default%>");
          return error_mark_node;
        }
       else
@@ -11890,7 +11917,16 @@ java_complete_lhs (tree node)
       TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
       if (TREE_OPERAND (node, 1) == error_mark_node)
        return error_mark_node;
-      TREE_OPERAND (node, 2) = java_complete_tree (TREE_OPERAND (node, 2));
+      {
+       /* This is a special case due to build_assertion().  When
+          assertions are disabled we build a COND_EXPR in which
+          Operand 1 is the body of the assertion.  If that happens to
+          be a string concatenation we'll need to patch it here.  */
+       tree patched = patch_string (TREE_OPERAND (node, 1));
+       if (patched)
+         TREE_OPERAND (node, 1) = patched;
+      }
+     TREE_OPERAND (node, 2) = java_complete_tree (TREE_OPERAND (node, 2));
       if (TREE_OPERAND (node, 2) == error_mark_node)
        return error_mark_node;
       return patch_if_else_statement (node);
@@ -11911,7 +11947,7 @@ java_complete_lhs (tree node)
       wfl_op2 = TREE_OPERAND (node, 1);
       TREE_OPERAND (node, 0) = nn =
        java_complete_tree (TREE_OPERAND (node, 0));
-      if (wfl_op2 == empty_stmt_node)
+      if (IS_EMPTY_STMT (wfl_op2))
        CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (nn);
       else
        {
@@ -11961,30 +11997,28 @@ java_complete_lhs (tree node)
       if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
          || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
        {
-         tree wfl = node;
          node = resolve_expression_name (node, NULL);
          if (node == error_mark_node)
            return node;
-         /* Keep line number information somewhere were it doesn't
-            disrupt the completion process. */
-         if (flag_emit_xref && TREE_CODE (node) != CALL_EXPR)
-           {
-             EXPR_WFL_NODE (wfl) = TREE_OPERAND (node, 1);
-             TREE_OPERAND (node, 1) = wfl;
-           }
          CAN_COMPLETE_NORMALLY (node) = 1;
        }
       else
        {
          tree body;
-         int save_lineno = input_line;
+         location_t save_location = input_location;
+#ifdef USE_MAPPED_LOCATION
+         input_location = EXPR_LOCATION (node);
+         if (input_location == UNKNOWN_LOCATION)
+           input_location = save_location;
+#else
          input_line = EXPR_WFL_LINENO (node);
+#endif
          body = java_complete_tree (EXPR_WFL_NODE (node));
-         input_line = save_lineno;
+         input_location = save_location;
          EXPR_WFL_NODE (node) = body;
          TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (body);
          CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (body);
-         if (body == empty_stmt_node || TREE_CONSTANT (body))
+         if (IS_EMPTY_STMT (body) || TREE_CONSTANT (body))
            {
              /* Makes it easier to constant fold, detect empty bodies. */
              return body;
@@ -12020,9 +12054,13 @@ java_complete_lhs (tree node)
              TREE_VALUE (cn) = dim;
              /* Setup the location of the current dimension, for
                 later error report. */
+#ifdef USE_MAPPED_LOCATION
+             TREE_PURPOSE (cn) = expr_add_location (NULL_TREE, location, 0);
+#else
              TREE_PURPOSE (cn) =
                build_expr_wfl (NULL_TREE, input_filename, 0, 0);
              EXPR_WFL_LINECOL (TREE_PURPOSE (cn)) = location;
+#endif
            }
        }
       /* They complete the array creation expression, if no errors
@@ -12061,6 +12099,11 @@ java_complete_lhs (tree node)
          int from_super = (EXPR_WFL_NODE (TREE_OPERAND (node, 0)) ==
                            super_identifier_node);
          tree arguments;
+#ifdef USE_MAPPED_LOCATION
+         source_location location = EXPR_LOCATION (node);
+#else
+         int location = EXPR_WFL_LINECOL (node);
+#endif
 
          node = patch_method_invocation (node, NULL_TREE, NULL_TREE,
                                          from_super, 0, &decl);
@@ -12072,8 +12115,7 @@ java_complete_lhs (tree node)
            arguments = TREE_VALUE (TREE_OPERAND (node, 1));
          else
            arguments = NULL_TREE;
-         check_thrown_exceptions (EXPR_WFL_LINECOL (node), decl,
-                                  arguments);
+         check_thrown_exceptions (location, decl, arguments);
          /* If we call this(...), register signature and positions */
          if (in_this)
            DECL_CONSTRUCTOR_CALLS (current_function_decl) =
@@ -12120,7 +12162,7 @@ java_complete_lhs (tree node)
                  else
                    DECL_INITIAL (nn) = TREE_OPERAND (node, 1);
                  DECL_FIELD_FINAL_IUD (nn) = 1;
-                 return empty_stmt_node;
+                 return build_java_empty_stmt ();
                }
            }
          if (! flag_emit_class_files)
@@ -12160,7 +12202,7 @@ java_complete_lhs (tree node)
          if (JREFERENCE_TYPE_P (TREE_TYPE (lvalue))
              && ! JSTRING_TYPE_P (TREE_TYPE (lvalue)))
            parse_error_context (wfl_op2,
-                                "Incompatible type for `+='. Can't convert `%s' to `java.lang.String'",
+                                "Incompatible type for %<+=%>. Can't convert %qs to %<java.lang.String%>",
                                 lang_printable_name (TREE_TYPE (lvalue), 0));
 
          /* 15.25.2.b: Left hand is an array access. FIXME */
@@ -12191,10 +12233,10 @@ java_complete_lhs (tree node)
       if ((nn = patch_string (TREE_OPERAND (node, 1))))
        TREE_OPERAND (node, 1) = nn;
 
-      if ((nn = outer_field_access_fix (wfl_op1, TREE_OPERAND (node, 0),
-                                       TREE_OPERAND (node, 1))))
+      if ((nn = nested_field_access_fix (wfl_op1, TREE_OPERAND (node, 0),
+                                        TREE_OPERAND (node, 1))))
        {
-         /* We return error_mark_node if outer_field_access_fix
+         /* We return error_mark_node if nested_field_access_fix
             detects we write into a final. */
          if (nn == error_mark_node)
            return error_mark_node;
@@ -12268,17 +12310,12 @@ java_complete_lhs (tree node)
 
           TREE_OPERAND (node, 1) = nn;
         }
-      return patch_binop (node, wfl_op1, wfl_op2);
+      return patch_binop (node, wfl_op1, wfl_op2, 0);
 
     case INSTANCEOF_EXPR:
       wfl_op1 = TREE_OPERAND (node, 0);
       COMPLETE_CHECK_OP_0 (node);
-      if (flag_emit_xref)
-       {
-         TREE_TYPE (node) = boolean_type_node;
-         return node;
-       }
-      return patch_binop (node, wfl_op1, TREE_OPERAND (node, 1));
+      return patch_binop (node, wfl_op1, TREE_OPERAND (node, 1), 0);
 
     case UNARY_PLUS_EXPR:
     case NEGATE_EXPR:
@@ -12307,14 +12344,14 @@ java_complete_lhs (tree node)
       TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
       if (TREE_OPERAND (node, 0) == error_mark_node)
        return error_mark_node;
-      if (!flag_emit_class_files && !flag_emit_xref)
+      if (!flag_emit_class_files)
        TREE_OPERAND (node, 0) = save_expr (TREE_OPERAND (node, 0));
       /* The same applies to wfl_op2 */
       wfl_op2 = TREE_OPERAND (node, 1);
       TREE_OPERAND (node, 1) = java_complete_tree (wfl_op2);
       if (TREE_OPERAND (node, 1) == error_mark_node)
        return error_mark_node;
-      if (!flag_emit_class_files && !flag_emit_xref)
+      if (!flag_emit_class_files)
        TREE_OPERAND (node, 1) = save_expr (TREE_OPERAND (node, 1));
       return patch_array_ref (node);
 
@@ -12331,12 +12368,12 @@ java_complete_lhs (tree node)
          tree field = lookup_field_wrapper (TREE_OPERAND (node, 0), name);
          if (field == NULL_TREE)
            {
-             error ("missing static field `%s'", IDENTIFIER_POINTER (name));
+             error ("missing static field %qs", IDENTIFIER_POINTER (name));
              return error_mark_node;
            }
          if (! FIELD_STATIC (field))
            {
-             error ("not a static field `%s'", IDENTIFIER_POINTER (name));
+             error ("not a static field %qs", IDENTIFIER_POINTER (name));
              return error_mark_node;
            }
          return field;
@@ -12351,7 +12388,7 @@ java_complete_lhs (tree node)
        {
          EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
          parse_error_context (wfl_operator,
-                              "Keyword `this' used outside allowed context");
+                              "Keyword %<this%> used outside allowed context");
          TREE_TYPE (node) = error_mark_node;
          return error_mark_node;
        }
@@ -12359,7 +12396,7 @@ java_complete_lhs (tree node)
        {
          EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
          parse_error_context
-           (wfl_operator, "Can't reference `this' or `super' before the superclass constructor has been called");
+           (wfl_operator, "Can't reference %<this%> or %<super%> before the superclass constructor has been called");
          TREE_TYPE (node) = error_mark_node;
          return error_mark_node;
        }
@@ -12404,8 +12441,8 @@ complete_function_arguments (tree node)
          flag = 1;
          continue;
        }
-      /* If have a string literal that we haven't transformed yet or a
-        crafted string buffer, as a result of use of the the String
+      /* If we have a string literal that we haven't transformed yet or a
+        crafted string buffer, as a result of the use of the String
         `+' operator. Build `parm.toString()' and expand it. */
       if ((temp = patch_string (parm)))
        parm = temp;
@@ -12425,16 +12462,19 @@ build_debugable_stmt (int location, tree stmt)
 {
   if (TREE_CODE (stmt) != EXPR_WITH_FILE_LOCATION)
     {
+#ifdef USE_MAPPED_LOCATION
+      stmt = expr_add_location (stmt, location, 1);
+#else
       stmt = build_expr_wfl (stmt, input_filename, 0, 0);
       EXPR_WFL_LINECOL (stmt) = location;
+      JAVA_MAYBE_GENERATE_DEBUG_INFO (stmt);
+#endif
     }
-  JAVA_MAYBE_GENERATE_DEBUG_INFO (stmt);
   return stmt;
 }
 
 static tree
 build_expr_block (tree body, tree decls)
-
 {
   tree node = make_node (BLOCK);
   BLOCK_EXPR_DECLS (node) = decls;
@@ -12557,25 +12597,37 @@ build_wfl_wrap (tree node, int location)
   if (TREE_CODE (node) == THIS_EXPR)
     node_to_insert = wfl = build_wfl_node (this_identifier_node);
   else
+#ifdef USE_MAPPED_LOCATION
+    wfl = build_unknown_wfl (NULL_TREE);
+
+  SET_EXPR_LOCATION (wfl, location);
+#else
     wfl = build_expr_wfl (NULL_TREE, ctxp->filename, 0, 0);
 
   EXPR_WFL_LINECOL (wfl) = location;
+#endif
   EXPR_WFL_QUALIFICATION (wfl) = build_tree_list (node_to_insert, NULL_TREE);
   return wfl;
 }
 
-/* Build a super() constructor invocation. Returns empty_stmt_node if
+/* Build a super() constructor invocation. Returns an empty statement if
    we're currently dealing with the class java.lang.Object. */
 
 static tree
 build_super_invocation (tree mdecl)
 {
   if (DECL_CONTEXT (mdecl) == object_type_node)
-    return empty_stmt_node;
+    return build_java_empty_stmt ();
   else
     {
       tree super_wfl = build_wfl_node (super_identifier_node);
       tree a = NULL_TREE, t;
+
+      /* This is called after parsing is done, so the parser context
+         won't be accurate. Set location info from current_class decl. */
+      tree class_wfl = lookup_cl (TYPE_NAME (current_class));
+      EXPR_WFL_LINECOL (super_wfl) = EXPR_WFL_LINECOL (class_wfl);
+
       /* If we're dealing with an anonymous class, pass the arguments
          of the crafted constructor along. */
       if (ANONYMOUS_CLASS_P (DECL_CONTEXT (mdecl)))
@@ -12607,7 +12659,7 @@ build_this_super_qualified_invocation (int use_this, tree name, tree args,
 static tree
 build_method_invocation (tree name, tree args)
 {
-  tree call = build (CALL_EXPR, NULL_TREE, name, args, NULL_TREE);
+  tree call = build3 (CALL_EXPR, NULL_TREE, name, args, NULL_TREE);
   TREE_SIDE_EFFECTS (call) = 1;
   EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
   return call;
@@ -12618,7 +12670,7 @@ build_method_invocation (tree name, tree args)
 static tree
 build_new_invocation (tree name, tree args)
 {
-  tree call = build (NEW_CLASS_EXPR, NULL_TREE, name, args, NULL_TREE);
+  tree call = build3 (NEW_CLASS_EXPR, NULL_TREE, name, args, NULL_TREE);
   TREE_SIDE_EFFECTS (call) = 1;
   EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
   return call;
@@ -12638,7 +12690,7 @@ build_assignment (int op, int op_location, tree lhs, tree rhs)
       rhs = build_binop (BINOP_LOOKUP (op), op_location, lhs, rhs);
       COMPOUND_ASSIGN_P (rhs) = 1;
     }
-  assignment = build (MODIFY_EXPR, NULL_TREE, lhs, rhs);
+  assignment = build2 (MODIFY_EXPR, NULL_TREE, lhs, rhs);
   TREE_SIDE_EFFECTS (assignment) = 1;
   EXPR_WFL_LINECOL (assignment) = op_location;
   return assignment;
@@ -12804,8 +12856,8 @@ patch_assignment (tree node, tree wfl_op1)
   new_rhs = try_builtin_assignconv (wfl_op1, lhs_type, rhs);
 
   /* 5.2 If it failed, try a reference conversion */
-  if (!new_rhs && (new_rhs = try_reference_assignconv (lhs_type, rhs)))
-    lhs_type = promote_type (rhs_type);
+  if (!new_rhs)
+    new_rhs = try_reference_assignconv (lhs_type, rhs);
 
   /* 15.25.2 If we have a compound assignment, convert RHS into the
      type of the LHS */
@@ -12838,17 +12890,17 @@ patch_assignment (tree node, tree wfl_op1)
          if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1)))
            strcpy (operation, "assignment");
          else if (is_return)
-           strcpy (operation, "`return'");
+           strcpy (operation, "'return'");
          else
-           strcpy (operation, "`='");
+           strcpy (operation, "'='");
        }
 
       if (!valid_cast_to_p (rhs_type, lhs_type))
        parse_error_context
-         (wfl, "Incompatible type for %s. Can't convert `%s' to `%s'",
+         (wfl, "Incompatible type for %s. Can't convert %qs to %qs",
           operation, t1, t2);
       else
-       parse_error_context (wfl, "Incompatible type for %s. Explicit cast needed to convert `%s' to `%s'",
+       parse_error_context (wfl, "Incompatible type for %s. Explicit cast needed to convert %qs to %qs",
                             operation, t1, t2);
       free (t1); free (t2);
       error_found = 1;
@@ -12864,7 +12916,6 @@ patch_assignment (tree node, tree wfl_op1)
 
   /* 10.10: Array Store Exception runtime check */
   if (!flag_emit_class_files
-      && !flag_emit_xref
       && lvalue_from_array
       && JREFERENCE_TYPE_P (TYPE_ARRAY_ELEMENT (lhs_type)))
     {
@@ -12892,8 +12943,8 @@ patch_assignment (tree node, tree wfl_op1)
         base = lvalue;
 
       index_expr = TREE_OPERAND (base, 1);
-      TREE_OPERAND (base, 1) = build (COMPOUND_EXPR, TREE_TYPE (index_expr),
-                                     store_check, index_expr);
+      TREE_OPERAND (base, 1) = build2 (COMPOUND_EXPR, TREE_TYPE (index_expr),
+                                      store_check, index_expr);
     }
 
   /* Final locals can be used as case values in switch
@@ -12906,6 +12957,7 @@ patch_assignment (tree node, tree wfl_op1)
       )
     {
       TREE_CONSTANT (lvalue) = 1;
+      TREE_INVARIANT (lvalue) = 1;
       DECL_INITIAL (lvalue) = new_rhs;
     }
 
@@ -12918,7 +12970,7 @@ patch_assignment (tree node, tree wfl_op1)
        case INDIRECT_REF:
        case COMPONENT_REF:
          /* Transform a = foo.bar 
-            into a = { int tmp; tmp = foo.bar; tmp; ).              
+            into a = ({int tmp; tmp = foo.bar;}).
             We need to ensure that if a read from memory fails
             because of a NullPointerException, a destination variable
             will remain unchanged.  An explicit temporary does what
@@ -12933,12 +12985,11 @@ patch_assignment (tree node, tree wfl_op1)
                                   TREE_TYPE (new_rhs));
            tree block = make_node (BLOCK);
            tree assignment 
-             = build (MODIFY_EXPR, TREE_TYPE (new_rhs), tmp, fold (new_rhs));
+             = build2 (MODIFY_EXPR, TREE_TYPE (new_rhs), tmp, fold (new_rhs));
            DECL_CONTEXT (tmp) = current_function_decl;
            TREE_TYPE (block) = TREE_TYPE (new_rhs);
            BLOCK_VARS (block) = tmp;
-           BLOCK_EXPR_BODY (block) 
-             = build (COMPOUND_EXPR, TREE_TYPE (new_rhs), assignment, tmp);
+           BLOCK_EXPR_BODY (block) = assignment;
            TREE_SIDE_EFFECTS (block) = 1;
            new_rhs = block;
          }
@@ -13020,7 +13071,8 @@ try_builtin_assignconv (tree wfl_op1, tree lhs_type, tree rhs)
         new_rhs = convert (lhs_type, rhs);
       else if (wfl_op1)                /* Might be called with a NULL */
        parse_warning_context
-         (wfl_op1, "Constant expression `%s' too wide for narrowing primitive conversion to `%s'",
+         (wfl_op1,
+           "Constant expression %qs too wide for narrowing primitive conversion to %qs",
           print_int_node (rhs), lang_printable_name (lhs_type, 0));
       /* Reported a warning that will turn into an error further
         down, so we don't return */
@@ -13257,7 +13309,7 @@ valid_method_invocation_conversion_p (tree dest, tree source)
 static tree
 build_binop (enum tree_code op, int op_location, tree op1, tree op2)
 {
-  tree binop = build (op, NULL_TREE, op1, op2);
+  tree binop = build2 (op, NULL_TREE, op1, op2);
   TREE_SIDE_EFFECTS (binop) = 1;
   /* Store the location of the operator, for better error report. The
      string of the operator will be rebuild based on the OP value. */
@@ -13397,7 +13449,7 @@ java_refold (tree t)
    of remaining nodes and detects more errors in certain cases.  */
 
 static tree
-patch_binop (tree node, tree wfl_op1, tree wfl_op2)
+patch_binop (tree node, tree wfl_op1, tree wfl_op2, int folding)
 {
   tree op1 = TREE_OPERAND (node, 0);
   tree op2 = TREE_OPERAND (node, 1);
@@ -13458,8 +13510,11 @@ patch_binop (tree node, tree wfl_op1, tree wfl_op2)
              (TREE_CODE (op2) == INTEGER_CST &&
               ! TREE_INT_CST_LOW (op2)  && ! TREE_INT_CST_HIGH (op2))))
        {
-         parse_warning_context (wfl_operator, "Evaluating this expression will result in an arithmetic exception being thrown");
+         parse_warning_context
+            (wfl_operator,
+             "Evaluating this expression will result in an arithmetic exception being thrown");
          TREE_CONSTANT (node) = 0;
+         TREE_INVARIANT (node) = 0;
        }
 
       /* Change the division operator if necessary */
@@ -13492,8 +13547,6 @@ patch_binop (tree node, tree wfl_op1, tree wfl_op2)
        {
          tree mod = build_java_binop (TRUNC_MOD_EXPR, prom_type, op1, op2);
          COMPOUND_ASSIGN_P (mod) = COMPOUND_ASSIGN_P (node);
-         TREE_SIDE_EFFECTS (mod)
-           = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
          return mod;
        }
       break;
@@ -13541,12 +13594,12 @@ patch_binop (tree node, tree wfl_op1, tree wfl_op2)
            {
              if (JNUMERIC_TYPE_P (op2_type))
                parse_error_context (wfl_operator,
-                                    "Incompatible type for `%s'. Explicit cast needed to convert shift distance from `%s' to integral",
+                                    "Incompatible type for %qs. Explicit cast needed to convert shift distance from %qs to integral",
                                     operator_string (node),
                                     lang_printable_name (op2_type, 0));
              else
                parse_error_context (wfl_operator,
-                                    "Incompatible type for `%s'. Can't convert shift distance from `%s' to integral",
+                                    "Incompatible type for %qs. Can't convert shift distance from %qs to integral",
                                     operator_string (node),
                                     lang_printable_name (op2_type, 0));
            }
@@ -13571,23 +13624,21 @@ patch_binop (tree node, tree wfl_op1, tree wfl_op2)
 
       /* Shift int only up to 0x1f and long up to 0x3f */
       if (prom_type == int_type_node)
-       op2 = fold (build (BIT_AND_EXPR, int_type_node, op2,
-                          build_int_2 (0x1f, 0)));
+       op2 = fold (build2 (BIT_AND_EXPR, int_type_node, op2,
+                           build_int_cst (NULL_TREE, 0x1f)));
       else
-       op2 = fold (build (BIT_AND_EXPR, int_type_node, op2,
-                          build_int_2 (0x3f, 0)));
+       op2 = fold (build2 (BIT_AND_EXPR, int_type_node, op2,
+                           build_int_cst (NULL_TREE, 0x3f)));
 
       /* The >>> operator is a >> operating on unsigned quantities */
-      if (code == URSHIFT_EXPR && ! flag_emit_class_files)
+      if (code == URSHIFT_EXPR && (folding || ! flag_emit_class_files))
        {
          tree to_return;
           tree utype = java_unsigned_type (prom_type);
           op1 = convert (utype, op1);
-         TREE_SET_CODE (node, RSHIFT_EXPR);
-          TREE_OPERAND (node, 0) = op1;
-          TREE_OPERAND (node, 1) = op2;
-          TREE_TYPE (node) = utype;
-         to_return = convert (prom_type, node);
+
+         to_return = fold_build2 (RSHIFT_EXPR, utype, op1, op2);
+         to_return = convert (prom_type, to_return);
          /* Copy the original value of the COMPOUND_ASSIGN_P flag */
          COMPOUND_ASSIGN_P (to_return) = COMPOUND_ASSIGN_P (node);
          TREE_SIDE_EFFECTS (to_return)
@@ -13622,7 +13673,7 @@ patch_binop (tree node, tree wfl_op1, tree wfl_op2)
        {
          SET_WFL_OPERATOR (wfl_operator, node, wfl_op2);
          parse_error_context
-           (wfl_operator, "Invalid argument `%s' for `instanceof'",
+           (wfl_operator, "Invalid argument %qs for %<instanceof%>",
             lang_printable_name (op2_type, 0));
          error_found = 1;
        }
@@ -13649,7 +13700,7 @@ patch_binop (tree node, tree wfl_op1, tree wfl_op2)
          char *t1 = xstrdup (lang_printable_name (op1_type, 0));
          SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
          parse_error_context
-           (wfl_operator, "Impossible for `%s' to be instance of `%s'",
+           (wfl_operator, "Impossible for %qs to be instance of %qs",
             t1, lang_printable_name (op2_type, 0));
          free (t1);
          error_found = 1;
@@ -13763,7 +13814,9 @@ patch_binop (tree node, tree wfl_op1, tree wfl_op2)
       /* Types have to be either references or the null type. If
          they're references, it must be possible to convert either
          type to the other by casting conversion. */
-      else if (op1 == null_pointer_node || op2 == null_pointer_node
+      else if ((op1 == null_pointer_node && op2 == null_pointer_node)
+               || (op1 == null_pointer_node && JREFERENCE_TYPE_P (op2_type))
+               || (JREFERENCE_TYPE_P (op1_type) && op2 == null_pointer_node)
               || (JREFERENCE_TYPE_P (op1_type) && JREFERENCE_TYPE_P (op2_type)
                   && (valid_ref_assignconv_cast_p (op1_type, op2_type, 1)
                       || valid_ref_assignconv_cast_p (op2_type,
@@ -13778,7 +13831,7 @@ patch_binop (tree node, tree wfl_op1, tree wfl_op2)
          t1 = xstrdup (lang_printable_name (op1_type, 0));
          parse_error_context
            (wfl_operator,
-            "Incompatible type for `%s'. Can't convert `%s' to `%s'",
+            "Incompatible type for %qs. Can't convert %qs to %qs",
             operator_string (node), t1,
             lang_printable_name (op2_type, 0));
          free (t1);
@@ -13800,9 +13853,6 @@ patch_binop (tree node, tree wfl_op1, tree wfl_op2)
   TREE_TYPE (node) = prom_type;
   TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
 
-  if (flag_emit_xref)
-    return node;
-
   /* fold does not respect side-effect order as required for Java but not C.
    * Also, it sometimes create SAVE_EXPRs which are bad when emitting
    * bytecode.
@@ -13947,9 +13997,6 @@ build_string_concatenation (tree op1, tree op2)
   tree result;
   int side_effects = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
 
-  if (flag_emit_xref)
-    return build (PLUS_EXPR, string_type_node, op1, op2);
-
   /* Try to do some static optimization */
   if ((result = string_constant_concatenation (op1, op2)))
     return result;
@@ -13995,8 +14042,7 @@ build_string_concatenation (tree op1, tree op2)
       /* OP1 is no longer the last node holding a crafted StringBuffer */
       IS_CRAFTED_STRING_BUFFER_P (op1) = 0;
       /* Create a node for `{new...,xxx}.append (op2)' */
-      if (op2)
-       op1 = make_qualified_primary (op1, BUILD_APPEND (op2), 0);
+      op1 = make_qualified_primary (op1, BUILD_APPEND (op2), 0);
     }
 
   /* Mark the last node holding a crafted StringBuffer */
@@ -14046,8 +14092,15 @@ patch_string_cst (tree node)
       location = alloc_name_constant (CONSTANT_String, node);
       node = build_ref_from_constant_pool (location);
     }
-  TREE_TYPE (node) = string_ptr_type_node;
   TREE_CONSTANT (node) = 1;
+  TREE_INVARIANT (node) = 1;
+
+  /* ??? Guessing that the class file code can't handle casts.  */
+  if (! flag_emit_class_files)
+    node = convert (string_ptr_type_node, node);
+  else
+    TREE_TYPE (node) = string_ptr_type_node;
+
   return node;
 }
 
@@ -14087,8 +14140,8 @@ build_incdec (int op_token, int op_location, tree op1, int is_post_p)
       { PREDECREMENT_EXPR, PREINCREMENT_EXPR, },
       { POSTDECREMENT_EXPR, POSTINCREMENT_EXPR, },
     };
-  tree node = build (lookup [is_post_p][(op_token - DECR_TK)],
-                    NULL_TREE, op1, NULL_TREE);
+  tree node = build2 (lookup [is_post_p][(op_token - DECR_TK)],
+                     NULL_TREE, op1, NULL_TREE);
   TREE_SIDE_EFFECTS (node) = 1;
   /* Store the location of the operator, for better error report. The
      string of the operator will be rebuild based on the OP value. */
@@ -14124,25 +14177,32 @@ build_incomplete_class_ref (int location, tree class_name)
       && !JPRIMITIVE_TYPE_P (class_name)
       && !(TREE_CODE (class_name) == VOID_TYPE))
     {
+      tree cpc_list = GET_CPC_LIST();
+      tree cpc = cpc_list;
       tree target_class;
 
-      if (CLASS_INTERFACE (TYPE_NAME (this_class)))
+      /* For inner classes, add a 'class$' method to their outermost
+        context, creating it if necessary.  */
+      
+      while (GET_NEXT_ENCLOSING_CPC(cpc))
+       cpc = GET_NEXT_ENCLOSING_CPC(cpc);
+      class_decl = TREE_VALUE (cpc);
+
+      target_class = TREE_TYPE (class_decl);
+
+      if (CLASS_INTERFACE (TYPE_NAME (target_class)))
        {
          /* For interfaces, adding a static 'class$' method directly 
             is illegal.  So create an inner class to contain the new
             method.  Empirically this matches the behavior of javac.  */
-         tree t = build_wfl_node (DECL_NAME (TYPE_NAME (object_type_node)));
-         tree inner = create_anonymous_class (0, t);
+         tree t, inner;
+         /* We want the generated inner class inside the outermost class. */
+         GET_CPC_LIST() = cpc;
+         t = build_wfl_node (DECL_NAME (TYPE_NAME (object_type_node)));
+         inner = create_anonymous_class (t);
          target_class = TREE_TYPE (inner);
          end_class_declaration (1);
-       }
-      else
-       {
-         /* For inner classes, add a 'class$' method to their outermost
-            context, creating it if necessary.  */
-         while (INNER_CLASS_DECL_P (class_decl))
-           class_decl = DECL_CONTEXT (class_decl);
-         target_class = TREE_TYPE (class_decl);
+         GET_CPC_LIST() = cpc_list;
        }
 
       if (TYPE_DOT_CLASS (target_class) == NULL_TREE)
@@ -14194,7 +14254,7 @@ patch_unaryop (tree node, tree wfl_op)
   tree op = TREE_OPERAND (node, 0);
   tree op_type = TREE_TYPE (op);
   tree prom_type = NULL_TREE, value, decl;
-  int outer_field_flag = 0;
+  int nested_field_flag = 0;
   int code = TREE_CODE (node);
   int error_found = 0;
 
@@ -14210,11 +14270,12 @@ patch_unaryop (tree node, tree wfl_op)
     case PREINCREMENT_EXPR:
       /* 15.14.2 Prefix Decrement Operator -- */
     case PREDECREMENT_EXPR:
-      op = decl = strip_out_static_field_access_decl (op);
-      outer_field_flag = outer_field_expanded_access_p (op, NULL, NULL, NULL);
+      op = decl = extract_field_decl (op);
+      nested_field_flag
+        = nested_field_expanded_access_p (op, NULL, NULL, NULL);
       /* We might be trying to change an outer field accessed using
          access method. */
-      if (outer_field_flag)
+      if (nested_field_flag)
        {
          /* Retrieve the decl of the field we're trying to access. We
              do that by first retrieving the function we would call to
@@ -14245,7 +14306,7 @@ patch_unaryop (tree node, tree wfl_op)
       if (!JNUMERIC_TYPE_P (op_type))
        {
          parse_error_context
-           (wfl_op, "Invalid argument type `%s' to `%s'",
+           (wfl_op, "Invalid argument type %qs to %qs",
             lang_printable_name (op_type, 0), operator_string (node));
          TREE_TYPE (node) = error_mark_node;
          error_found = 1;
@@ -14256,27 +14317,27 @@ patch_unaryop (tree node, tree wfl_op)
             both operands, if really necessary */
          if (JINTEGRAL_TYPE_P (op_type))
            {
-             value = build_int_2 (1, 0);
-             TREE_TYPE (value) = TREE_TYPE (node) = op_type;
+             value = build_int_cst (op_type, 1);
+             TREE_TYPE (node) = op_type;
            }
          else
            {
-             value = build_int_2 (1, 0);
+             value = build_int_cst (NULL_TREE, 1);
              TREE_TYPE (node) =
                binary_numeric_promotion (op_type,
                                          TREE_TYPE (value), &op, &value);
            }
 
          /* We remember we might be accessing an outer field */
-         if (outer_field_flag)
+         if (nested_field_flag)
            {
              /* We re-generate an access to the field */
-             value = build (PLUS_EXPR, TREE_TYPE (op),
-                            build_outer_field_access (wfl_op, decl), value);
+             value = build2 (PLUS_EXPR, TREE_TYPE (op),
+                             build_nested_field_access (wfl_op, decl), value);
 
              /* And we patch the original access$() into a write
                  with plus_op as a rhs */
-             return outer_field_access_fix (node, op, value);
+             return nested_field_access_fix (node, op, value);
            }
 
          /* And write back into the node. */
@@ -14354,10 +14415,15 @@ patch_unaryop (tree node, tree wfl_op)
       else
        {
          value = fold (value);
-         TREE_SIDE_EFFECTS (value) = TREE_SIDE_EFFECTS (op);
          return value;
        }
       break;
+
+    case NOP_EXPR:
+      /* This can only happen when the type is already known.  */
+      gcc_assert (TREE_TYPE (node) != NULL_TREE);
+      prom_type = TREE_TYPE (node);
+      break;
     }
 
   if (error_found)
@@ -14385,7 +14451,7 @@ resolve_type_during_patch (tree type)
       if (!type_decl)
        {
          parse_error_context (type,
-                              "Class `%s' not found in type declaration",
+                              "Class %qs not found in type declaration",
                               IDENTIFIER_POINTER (EXPR_WFL_NODE (type)));
          return NULL_TREE;
        }
@@ -14467,16 +14533,16 @@ patch_cast (tree node, tree wfl_op)
        }
 
       /* The cast requires a run-time check */
-      return build (CALL_EXPR, promote_type (cast_type),
-                   build_address_of (soft_checkcast_node),
-                   tree_cons (NULL_TREE, build_class_ref (cast_type),
-                              build_tree_list (NULL_TREE, op)),
-                   NULL_TREE);
+      return build3 (CALL_EXPR, promote_type (cast_type),
+                    build_address_of (soft_checkcast_node),
+                    tree_cons (NULL_TREE, build_class_ref (cast_type),
+                               build_tree_list (NULL_TREE, op)),
+                    NULL_TREE);
     }
 
   /* Any other casts are proven incorrect at compile time */
   t1 = xstrdup (lang_printable_name (op_type, 0));
-  parse_error_context (wfl_op, "Invalid cast from `%s' to `%s'",
+  parse_error_context (wfl_op, "Invalid cast from %qs to %qs",
                       t1, lang_printable_name (cast_type, 0));
   free (t1);
   return error_mark_node;
@@ -14487,8 +14553,7 @@ patch_cast (tree node, tree wfl_op)
 static tree
 build_null_of_type (tree type)
 {
-  tree node = build_int_2 (0, 0);
-  TREE_TYPE (node) = promote_type (type);
+  tree node = build_int_cst (promote_type (type), 0);
   return node;
 }
 
@@ -14497,7 +14562,8 @@ build_null_of_type (tree type)
 static tree
 build_array_ref (int location, tree array, tree index)
 {
-  tree node = build (ARRAY_REF, NULL_TREE, array, index);
+  tree node = build4 (ARRAY_REF, NULL_TREE, array, index,
+                     NULL_TREE, NULL_TREE);
   EXPR_WFL_LINECOL (node) = location;
   return node;
 }
@@ -14523,7 +14589,7 @@ patch_array_ref (tree node)
     {
       parse_error_context
        (wfl_operator,
-        "`[]' can only be applied to arrays. It can't be applied to `%s'",
+        "%<[]%> can only be applied to arrays. It can't be applied to %qs",
         lang_printable_name (array_type, 0));
       TREE_TYPE (node) = error_mark_node;
       error_found = 1;
@@ -14536,11 +14602,11 @@ patch_array_ref (tree node)
     {
       if (valid_cast_to_p (index_type, int_type_node))
        parse_error_context (wfl_operator,
-   "Incompatible type for `[]'. Explicit cast needed to convert `%s' to `int'",
+   "Incompatible type for %<[]%>. Explicit cast needed to convert %qs to %<int%>",
                             lang_printable_name (index_type, 0));
       else
        parse_error_context (wfl_operator,
-          "Incompatible type for `[]'. Can't convert `%s' to `int'",
+          "Incompatible type for %<[]%>. Can't convert %qs to %<int%>",
                             lang_printable_name (index_type, 0));
       TREE_TYPE (node) = error_mark_node;
       error_found = 1;
@@ -14551,7 +14617,7 @@ patch_array_ref (tree node)
 
   array_type = TYPE_ARRAY_ELEMENT (array_type);
 
-  if (flag_emit_class_files || flag_emit_xref)
+  if (flag_emit_class_files)
     {
       TREE_OPERAND (node, 0) = array;
       TREE_OPERAND (node, 1) = index;
@@ -14567,9 +14633,9 @@ patch_array_ref (tree node)
 static tree
 build_newarray_node (tree type, tree dims, int extra_dims)
 {
-  tree node =
-    build (NEW_ARRAY_EXPR, NULL_TREE, type, nreverse (dims),
-          build_int_2 (extra_dims, 0));
+  tree node = build3 (NEW_ARRAY_EXPR, NULL_TREE, type,
+                     nreverse (dims),
+                     build_int_cst (NULL_TREE, extra_dims));
   return node;
 }
 
@@ -14611,7 +14677,7 @@ patch_newarray (tree node)
        {
          parse_error_context
            (TREE_PURPOSE (cdim),
-            "Incompatible type for dimension in array creation expression. %s convert `%s' to `int'",
+            "Incompatible type for dimension in array creation expression. %s convert %qs to %<int%>",
             (valid_cast_to_p (TREE_TYPE (dim), int_type_node) ?
              "Explicit cast needed to" : "Can't"),
             lang_printable_name (TREE_TYPE (dim), 0));
@@ -14663,12 +14729,14 @@ patch_newarray (tree node)
 
   /* Can't reuse what's already written in expr.c because it uses the
      JVM stack representation. Provide a build_multianewarray. FIXME */
-  return build (CALL_EXPR, array_type,
-               build_address_of (soft_multianewarray_node),
-               tree_cons (NULL_TREE, build_class_ref (TREE_TYPE (array_type)),
-                          tree_cons (NULL_TREE,
-                                     build_int_2 (ndims, 0), dims )),
-               NULL_TREE);
+  return build3 (CALL_EXPR, array_type,
+                build_address_of (soft_multianewarray_node),
+                tree_cons (NULL_TREE,
+                           build_class_ref (TREE_TYPE (array_type)),
+                           tree_cons (NULL_TREE,
+                                      build_int_cst (NULL_TREE, ndims),
+                                      dims)),
+                NULL_TREE);
 }
 
 /* 10.6 Array initializer.  */
@@ -14680,8 +14748,18 @@ static tree
 maybe_build_array_element_wfl (tree node)
 {
   if (TREE_CODE (node) != EXPR_WITH_FILE_LOCATION)
-    return build_expr_wfl (NULL_TREE, ctxp->filename,
-                          ctxp->elc.line, ctxp->elc.prev_col);
+    {
+      /* FIXME - old code used "prev_lc.line" and "elc.prev_col */
+      return build_expr_wfl (NULL_TREE,
+#ifdef USE_MAPPED_LOCATION
+                            input_location
+#else
+                            ctxp->filename,
+                            ctxp->lexer->token_start.line,
+                            ctxp->lexer->token_start.col
+#endif
+                            );
+    }
   else
     return NULL_TREE;
 }
@@ -14715,7 +14793,7 @@ patch_new_array_init (tree type, tree node)
   if (TREE_CODE (type) != POINTER_TYPE || ! TYPE_ARRAY_P (TREE_TYPE (type)))
     {
       parse_error_context (node,
-                          "Invalid array initializer for non-array type `%s'",
+                          "Invalid array initializer for non-array type %qs",
                           lang_printable_name (type, 1));
       return error_mark_node;
     }
@@ -14758,7 +14836,9 @@ patch_new_array_init (tree type, tree node)
   TREE_TYPE (init) = TREE_TYPE (TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (type))));
   TREE_TYPE (node) = promote_type (type);
   TREE_CONSTANT (init) = all_constant;
+  TREE_INVARIANT (init) = all_constant;
   TREE_CONSTANT (node) = all_constant;
+  TREE_INVARIANT (node) = all_constant;
   return node;
 }
 
@@ -14800,7 +14880,7 @@ array_constructor_check_entry (tree type, tree entry)
       if (!array_type_string)
        array_type_string = xstrdup (lang_printable_name (type, 1));
       parse_error_context
-       (wfl_operator, "Incompatible type for array. %s convert `%s' to `%s'",
+       (wfl_operator, "Incompatible type for array. %s convert %qs to %qs",
         msg, lang_printable_name (type_value, 1), array_type_string);
       error_seen = 1;
     }
@@ -14869,25 +14949,25 @@ patch_return (tree node)
     {
       if (DECL_INSTINIT_P (current_function_decl))
        parse_error_context (wfl_operator,
-                            "`return' inside instance initializer");
+                            "%<return%> inside instance initializer");
 
       else if (DECL_CLINIT_P (current_function_decl))
        parse_error_context (wfl_operator,
-                            "`return' inside static initializer");
+                            "%<return%> inside static initializer");
 
       else if (!DECL_CONSTRUCTOR_P (meth))
        {
          char *t = xstrdup (lang_printable_name (mtype, 0));
          parse_error_context (wfl_operator,
-                              "`return' with%s value from `%s %s'",
+                              "%<return%> with%s value from %<%s %s%>",
                               (error_found == 1 ? "" : "out"),
-                              t, lang_printable_name (meth, 0));
+                              t, lang_printable_name (meth, 2));
          free (t);
        }
       else
        parse_error_context (wfl_operator,
-                            "`return' with value from constructor `%s'",
-                            lang_printable_name (meth, 0));
+                            "%<return%> with value from constructor %qs",
+                            lang_printable_name (meth, 2));
       return error_mark_node;
     }
 
@@ -14902,7 +14982,7 @@ patch_return (tree node)
       if ((patched = patch_string (exp)))
        exp = patched;
 
-      modify = build (MODIFY_EXPR, NULL_TREE, DECL_RESULT (meth), exp);
+      modify = build2 (MODIFY_EXPR, NULL_TREE, DECL_RESULT (meth), exp);
       EXPR_WFL_LINECOL (modify) = EXPR_WFL_LINECOL (node);
       modify = java_complete_tree (modify);
 
@@ -14927,8 +15007,8 @@ build_if_else_statement (int location, tree expression, tree if_body,
 {
   tree node;
   if (!else_body)
-    else_body = empty_stmt_node;
-  node = build (COND_EXPR, NULL_TREE, expression, if_body, else_body);
+    else_body = build_java_empty_stmt ();
+  node = build3 (COND_EXPR, NULL_TREE, expression, if_body, else_body);
   EXPR_WFL_LINECOL (node) = location;
   node = build_debugable_stmt (location, node);
   return node;
@@ -14951,24 +15031,11 @@ patch_if_else_statement (tree node)
     {
       parse_error_context
        (wfl_operator,
-        "Incompatible type for `if'. Can't convert `%s' to `boolean'",
+        "Incompatible type for %<if%>. Can't convert %qs to %<boolean%>",
         lang_printable_name (TREE_TYPE (expression), 0));
       return error_mark_node;
     }
 
-  if (TREE_CODE (expression) == INTEGER_CST)
-    {
-      if (integer_zerop (expression))
-       node = TREE_OPERAND (node, 2);
-      else
-       node = TREE_OPERAND (node, 1);
-      if (CAN_COMPLETE_NORMALLY (node) != can_complete_normally)
-       {
-         node = build (COMPOUND_EXPR, void_type_node, node, empty_stmt_node);
-         CAN_COMPLETE_NORMALLY (node) = can_complete_normally;
-       }
-      return node;
-    }
   TREE_TYPE (node) = void_type_node;
   TREE_SIDE_EFFECTS (node) = 1;
   CAN_COMPLETE_NORMALLY (node) = can_complete_normally;
@@ -14997,19 +15064,19 @@ build_labeled_block (int location, tree label)
        {
          EXPR_WFL_LINECOL (wfl_operator) = location;
          parse_error_context (wfl_operator,
-            "Declaration of `%s' shadows a previous label declaration",
+            "Declaration of %qs shadows a previous label declaration",
                               IDENTIFIER_POINTER (label));
          EXPR_WFL_LINECOL (wfl_operator) =
            EXPR_WFL_LINECOL (IDENTIFIER_LOCAL_VALUE (label_name));
          parse_error_context (wfl_operator,
-            "This is the location of the previous declaration of label `%s'",
+            "This is the location of the previous declaration of label %qs",
                               IDENTIFIER_POINTER (label));
          java_error_count--;
        }
     }
 
   label_decl = create_label_decl (label_name);
-  node = build (LABELED_BLOCK_EXPR, NULL_TREE, label_decl, NULL_TREE);
+  node = build2 (LABELED_BLOCK_EXPR, NULL_TREE, label_decl, NULL_TREE);
   EXPR_WFL_LINECOL (node) = location;
   TREE_SIDE_EFFECTS (node) = 1;
   return node;
@@ -15036,7 +15103,7 @@ finish_labeled_statement (tree lbe, /* Labeled block expr */
 static tree
 build_new_loop (tree loop_body)
 {
-  tree loop =  build (LOOP_EXPR, NULL_TREE, loop_body);
+  tree loop = build1 (LOOP_EXPR, NULL_TREE, loop_body);
   TREE_SIDE_EFFECTS (loop) = 1;
   PUSH_LOOP (loop);
   return loop;
@@ -15067,7 +15134,7 @@ build_loop_body (int location, tree condition, int reversed)
 {
   tree first, second, body;
 
-  condition = build (EXIT_EXPR, NULL_TREE, condition); /* Force walk */
+  condition = build1 (EXIT_EXPR, NULL_TREE, condition); /* Force walk */
   EXPR_WFL_LINECOL (condition) = location; /* For accurate error report */
   condition = build_debugable_stmt (location, condition);
   TREE_SIDE_EFFECTS (condition) = 1;
@@ -15075,9 +15142,9 @@ build_loop_body (int location, tree condition, int reversed)
   body = build_labeled_block (0, continue_identifier_node);
   first = (reversed ? body : condition);
   second = (reversed ? condition : body);
-  return
-    build (COMPOUND_EXPR, NULL_TREE,
-          build (COMPOUND_EXPR, NULL_TREE, first, second), empty_stmt_node);
+  return build2 (COMPOUND_EXPR, NULL_TREE,
+                build2 (COMPOUND_EXPR, NULL_TREE, first, second),
+                build_java_empty_stmt ());
 }
 
 /* Install CONDITION (if any) and loop BODY (using REVERSED to tell
@@ -15095,9 +15162,13 @@ finish_loop_body (int location, tree condition, tree body, int reversed)
       /* We wrapped the EXIT_EXPR around a WFL so we can debug it.
          The real EXIT_EXPR is one operand further. */
       EXPR_WFL_LINECOL (cnode) = location;
-      /* This one is for accurate error reports */
-      EXPR_WFL_LINECOL (TREE_OPERAND (cnode, 0)) = location;
-      TREE_OPERAND (TREE_OPERAND (cnode, 0), 0) = condition;
+      if (TREE_CODE (cnode) == EXPR_WITH_FILE_LOCATION)
+       {
+         cnode = EXPR_WFL_NODE (cnode);
+         /* This one is for accurate error reports */
+         EXPR_WFL_LINECOL (cnode) = location;
+       }
+      TREE_OPERAND (cnode, 0) = condition;
     }
   LOOP_EXPR_BODY_BODY_EXPR (loop_body, reversed) = body;
   POP_LOOP ();
@@ -15117,19 +15188,18 @@ finish_for_loop (int location, tree condition, tree update, tree body)
      this because the (current interpretation of the) JLS requires
      that the update expression be considered reachable even if the
      for loop's body doesn't complete normally.  */
-  if (update != NULL_TREE && update != empty_stmt_node)
+  if (update != NULL_TREE && !IS_EMPTY_STMT (update))
     {
       tree up2 = update;
       if (TREE_CODE (up2) == EXPR_WITH_FILE_LOCATION)
        up2 = EXPR_WFL_NODE (up2);
       /* It is possible for the update expression to be an
         EXPR_WFL_NODE wrapping nothing.  */
-      if (up2 != NULL_TREE && up2 != empty_stmt_node)
+      if (up2 != NULL_TREE && !IS_EMPTY_STMT (up2))
        {
          /* Try to detect constraint violations.  These would be
             programming errors somewhere.  */
-         if (! IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (up2)))
-             || TREE_CODE (up2) == LOOP_EXPR)
+         if (! EXPR_P (up2) || TREE_CODE (up2) == LOOP_EXPR)
            abort ();
          SUPPRESS_UNREACHABLE_ERROR (up2) = 1;
        }
@@ -15225,8 +15295,7 @@ build_bc_statement (int location, int is_break, tree name)
     }
   /* Unlabeled break/continue will be handled during the
      break/continue patch operation */
-  break_continue
-    = build (EXIT_BLOCK_EXPR, NULL_TREE, label_block_expr, NULL_TREE);
+  break_continue = build1 (EXIT_BLOCK_EXPR, NULL_TREE, label_block_expr);
 
   IS_BREAK_STMT_P (break_continue) = is_break;
   TREE_SIDE_EFFECTS (break_continue) = 1;
@@ -15247,7 +15316,7 @@ patch_bc_statement (tree node)
   /* Having an identifier here means that the target is unknown. */
   if (bc_label != NULL_TREE && TREE_CODE (bc_label) == IDENTIFIER_NODE)
     {
-      parse_error_context (wfl_operator, "No label definition found for `%s'",
+      parse_error_context (wfl_operator, "No label definition found for %qs",
                           IDENTIFIER_POINTER (bc_label));
       return error_mark_node;
     }
@@ -15260,10 +15329,10 @@ patch_bc_statement (tree node)
            {
              if (bc_label == NULL_TREE)
                parse_error_context (wfl_operator,
-                                    "`continue' must be in loop");
+                                    "%<continue%> must be in loop");
              else
                parse_error_context
-                 (wfl_operator, "continue label `%s' does not name a loop",
+                 (wfl_operator, "continue label %qs does not name a loop",
                   IDENTIFIER_POINTER (bc_label));
              return error_mark_node;
            }
@@ -15284,7 +15353,7 @@ patch_bc_statement (tree node)
          if (labeled_block == NULL_TREE)
            {
              parse_error_context (wfl_operator,
-                                    "`break' must be in loop or switch");
+                                    "%<break%> must be in loop or switch");
              return error_mark_node;
            }
          target_stmt = LABELED_BLOCK_BODY (labeled_block);
@@ -15325,7 +15394,7 @@ patch_exit_expr (tree node)
     {
       parse_error_context
        (wfl_operator,
-    "Incompatible type for loop conditional. Can't convert `%s' to `boolean'",
+    "Incompatible type for loop conditional. Can't convert %qs to %<boolean%>",
         lang_printable_name (TREE_TYPE (expression), 0));
       return error_mark_node;
     }
@@ -15363,7 +15432,7 @@ patch_switch_statement (tree node)
     {
       EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
       parse_error_context (wfl_operator,
-         "Incompatible type for `switch'. Can't convert `%s' to `int'",
+         "Incompatible type for %<switch%>. Can't convert %qs to %<int%>",
                           lang_printable_name (se_type, 0));
       /* This is what java_complete_tree will check */
       TREE_OPERAND (node, 0) = error_mark_node;
@@ -15394,8 +15463,8 @@ patch_switch_statement (tree node)
                = EXPR_WFL_LINECOL (TREE_PURPOSE (iter));
              /* The case_label_list is in reverse order, so print the
                 outer label first.  */
-             parse_error_context (wfl_operator, "duplicate case label: `"
-                                  HOST_WIDE_INT_PRINT_DEC "'", subval);
+             parse_error_context (wfl_operator, "duplicate case label: %<"
+                                  HOST_WIDE_INT_PRINT_DEC "%>", subval);
              EXPR_WFL_LINECOL (wfl_operator)
                = EXPR_WFL_LINECOL (TREE_PURPOSE (subiter));
              parse_error_context (wfl_operator, "original label is here");
@@ -15426,11 +15495,27 @@ patch_switch_statement (tree node)
 /* Build an assertion expression for `assert CONDITION : VALUE'; VALUE
    might be NULL_TREE.  */
 static tree
-build_assertion (int location, tree condition, tree value)
+build_assertion (
+#ifdef USE_MAPPED_LOCATION
+                source_location location,
+#else
+                int location,
+#endif
+                tree condition, tree value)
 {
   tree node;
   tree klass = GET_CPC ();
 
+  if (! enable_assertions (klass))
+    {
+      condition = build2 (TRUTH_ANDIF_EXPR, NULL_TREE,
+                         boolean_false_node, condition);
+      if (value == NULL_TREE)
+       value = build_java_empty_stmt ();
+      return build_if_else_statement (location, condition,
+                                     value, NULL_TREE);
+    }
+
   if (! CLASS_USES_ASSERTIONS (klass))
     {
       tree field, classdollar, id, call;
@@ -15443,13 +15528,11 @@ build_assertion (int location, tree condition, tree value)
       MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (field);
       FIELD_SYNTHETIC (field) = 1;
 
-      if (!TYPE_DOT_CLASS (class_type))
-       build_dot_class_method (class_type);
-      classdollar = build_dot_class_method_invocation (class_type, class_type);
+      classdollar = build_incomplete_class_ref (location, class_type);
 
       /* Call CLASS.desiredAssertionStatus().  */
       id = build_wfl_node (get_identifier ("desiredAssertionStatus"));
-      call = build (CALL_EXPR, NULL_TREE, id, NULL_TREE, NULL_TREE);
+      call = build3 (CALL_EXPR, NULL_TREE, id, NULL_TREE, NULL_TREE);
       call = make_qualified_primary (classdollar, call, location);
       TREE_SIDE_EFFECTS (call) = 1;
 
@@ -15461,7 +15544,7 @@ build_assertion (int location, tree condition, tree value)
       DECL_INITIAL (field) = call;
 
       /* Record the initializer in the initializer statement list.  */
-      call = build (MODIFY_EXPR, NULL_TREE, field, call);
+      call = build2 (MODIFY_EXPR, NULL_TREE, field, call);
       TREE_CHAIN (call) = CPC_STATIC_INITIALIZER_STMT (ctxp);
       SET_CPC_STATIC_INITIALIZER_STMT (ctxp, call);
       MODIFY_EXPR_FROM_INITIALIZATION_P (call) = 1;
@@ -15478,7 +15561,7 @@ build_assertion (int location, tree condition, tree value)
   node = make_qualified_name (node, build_wfl_node (get_identifier ("AssertionError")),
                              location);
 
-  node = build (NEW_CLASS_EXPR, NULL_TREE, node, value, NULL_TREE);
+  node = build3 (NEW_CLASS_EXPR, NULL_TREE, node, value, NULL_TREE);
   TREE_SIDE_EFFECTS (node) = 1;
   /* It is too early to use BUILD_THROW.  */
   node = build1 (THROW_EXPR, NULL_TREE, node);
@@ -15489,10 +15572,10 @@ build_assertion (int location, tree condition, tree value)
   condition = build1 (TRUTH_NOT_EXPR, NULL_TREE, condition);
   /* Check $assertionsDisabled.  */
   condition
-    = build (TRUTH_ANDIF_EXPR, NULL_TREE,
-            build1 (TRUTH_NOT_EXPR, NULL_TREE,
-                    build_wfl_node (get_identifier ("$assertionsDisabled"))),
-            condition);
+    = build2 (TRUTH_ANDIF_EXPR, NULL_TREE,
+             build1 (TRUTH_NOT_EXPR, NULL_TREE,
+                     build_wfl_node (get_identifier ("$assertionsDisabled"))),
+             condition);
   node = build_if_else_statement (location, condition, node, NULL_TREE);
   return node;
 }
@@ -15530,15 +15613,15 @@ encapsulate_with_try_catch (int location, tree type_or_name, tree try_stmts,
   catch_block = build_expr_block (NULL_TREE, catch_clause_param);
 
   /* Initialize the variable and store in the block */
-  catch = build (MODIFY_EXPR, NULL_TREE, catch_clause_param,
-                build (JAVA_EXC_OBJ_EXPR, ptr_type_node));
+  catch = build2 (MODIFY_EXPR, NULL_TREE, catch_clause_param,
+                 build0 (JAVA_EXC_OBJ_EXPR, ptr_type_node));
   add_stmt_to_block (catch_block, NULL_TREE, catch);
 
   /* Add the catch statements */
   add_stmt_to_block (catch_block, NULL_TREE, catch_stmts);
 
-  /* Now we can build a CATCH_EXPR */
-  catch_block = build1 (CATCH_EXPR, NULL_TREE, catch_block);
+  /* Now we can build a JAVA_CATCH_EXPR */
+  catch_block = build1 (JAVA_CATCH_EXPR, NULL_TREE, catch_block);
 
   return build_try_statement (location, try_block, catch_block);
 }
@@ -15546,7 +15629,7 @@ encapsulate_with_try_catch (int location, tree type_or_name, tree try_stmts,
 static tree
 build_try_statement (int location, tree try_block, tree catches)
 {
-  tree node = build (TRY_EXPR, NULL_TREE, try_block, catches);
+  tree node = build2 (TRY_EXPR, NULL_TREE, try_block, catches);
   EXPR_WFL_LINECOL (node) = location;
   return node;
 }
@@ -15554,7 +15637,7 @@ build_try_statement (int location, tree try_block, tree catches)
 static tree
 build_try_finally_statement (int location, tree try_block, tree finally)
 {
-  tree node = build (TRY_FINALLY_EXPR, NULL_TREE, try_block, finally);
+  tree node = build2 (TRY_FINALLY_EXPR, NULL_TREE, try_block, finally);
   EXPR_WFL_LINECOL (node) = location;
   return node;
 }
@@ -15571,7 +15654,7 @@ patch_try_statement (tree node)
   /* Check catch clauses, if any. Every time we find an error, we try
      to process the next catch clause. We process the catch clause before
      the try block so that when processing the try block we can check thrown
-     exceptions againts the caught type list. */
+     exceptions against the caught type list. */
   for (current = catch; current; current = TREE_CHAIN (current))
     {
       tree carg_decl, carg_type;
@@ -15579,7 +15662,7 @@ patch_try_statement (tree node)
       int unreachable;
 
       /* At this point, the structure of the catch clause is
-          CATCH_EXPR           (catch node)
+          JAVA_CATCH_EXPR              (catch node)
             BLOCK              (with the decl of the parameter)
                COMPOUND_EXPR
                  MODIFY_EXPR   (assignment of the catch parameter)
@@ -15601,7 +15684,7 @@ patch_try_statement (tree node)
        {
          EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
          parse_error_context (wfl_operator,
-                              "Can't catch class `%s'. Catch clause parameter type must be a subclass of class `java.lang.Throwable'",
+                              "Can't catch class %qs. Catch clause parameter type must be a subclass of class %<java.lang.Throwable%>",
                               lang_printable_name (carg_type, 0));
          error_found = 1;
          continue;
@@ -15625,7 +15708,7 @@ patch_try_statement (tree node)
              EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
              parse_error_context
                (wfl_operator,
-                "`catch' not reached because of the catch clause at line %d",
+                "%<catch%> not reached because of the catch clause at line %d",
                 EXPR_WFL_LINENO (sub_current));
              unreachable = error_found = 1;
              break;
@@ -15692,19 +15775,11 @@ patch_synchronized_statement (tree node, tree wfl_op1)
   if (!JREFERENCE_TYPE_P (TREE_TYPE (expr)))
     {
       SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
-      parse_error_context (wfl_operator, "Incompatible type for `synchronized'. Can't convert `%s' to `java.lang.Object'",
+      parse_error_context (wfl_operator, "Incompatible type for %<synchronized%>. Can't convert %qs to %<java.lang.Object%>",
                           lang_printable_name (TREE_TYPE (expr), 0));
       return error_mark_node;
     }
 
-  if (flag_emit_xref)
-    {
-      TREE_OPERAND (node, 0) = expr;
-      TREE_OPERAND (node, 1) = java_complete_tree (block);
-      CAN_COMPLETE_NORMALLY (node) = 1;
-      return node;
-    }
-
   /* Generate a try-finally for the synchronized statement, except
      that the handler that catches all throw exception calls
      _Jv_MonitorExit and then rethrow the exception.
@@ -15727,11 +15802,11 @@ patch_synchronized_statement (tree node, tree wfl_op1)
   BUILD_MONITOR_EXIT (exit, expr_decl);
   CAN_COMPLETE_NORMALLY (enter) = 1;
   CAN_COMPLETE_NORMALLY (exit) = 1;
-  assignment = build (MODIFY_EXPR, NULL_TREE, expr_decl, expr);
+  assignment = build2 (MODIFY_EXPR, NULL_TREE, expr_decl, expr);
   TREE_SIDE_EFFECTS (assignment) = 1;
-  node = build (COMPOUND_EXPR, NULL_TREE,
-               build (COMPOUND_EXPR, NULL_TREE, assignment, enter),
-               build (TRY_FINALLY_EXPR, NULL_TREE, block, exit));
+  node = build2 (COMPOUND_EXPR, NULL_TREE,
+                build2 (COMPOUND_EXPR, NULL_TREE, assignment, enter),
+                build2 (TRY_FINALLY_EXPR, NULL_TREE, block, exit));
   node = build_expr_block (node, expr_decl);
 
   return java_complete_tree (node);
@@ -15751,7 +15826,7 @@ patch_throw_statement (tree node, tree wfl_op1)
     {
       SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
       parse_error_context (wfl_operator,
-    "Can't throw `%s'; it must be a subclass of class `java.lang.Throwable'",
+    "Can't throw %qs; it must be a subclass of class %<java.lang.Throwable%>",
                           lang_printable_name (type, 0));
       /* If the thrown expression was a reference, we further the
          compile-time check. */
@@ -15780,7 +15855,7 @@ patch_throw_statement (tree node, tree wfl_op1)
        if (DECL_CONSTRUCTOR_P (current)
            && !check_thrown_exceptions_do (TREE_TYPE (expr)))
          {
-           parse_error_context (wfl_operator, "Checked exception `%s' can't be thrown in instance initializer (not all declared constructor are declaring it in their `throws' clause)",
+           parse_error_context (wfl_operator, "Checked exception %qs can't be thrown in instance initializer (not all declared constructor are declaring it in their %<throws%> clause)",
                                 lang_printable_name (TREE_TYPE (expr), 0));
            return error_mark_node;
          }
@@ -15801,7 +15876,7 @@ patch_throw_statement (tree node, tree wfl_op1)
         only if there is something after the list of checked
         exception thrown by the current function (if any). */
       if (IN_TRY_BLOCK_P ())
-       parse_error_context (wfl_operator, "Checked exception `%s' can't be caught by any of the catch clause(s) of the surrounding `try' block",
+       parse_error_context (wfl_operator, "Checked exception %qs can't be caught by any of the catch clause(s) of the surrounding %<try%> block",
                             lang_printable_name (type, 0));
       /* If we have no surrounding try statement and the method doesn't have
         any throws, report it now. FIXME */
@@ -15814,27 +15889,24 @@ patch_throw_statement (tree node, tree wfl_op1)
        {
          if (DECL_CLINIT_P (current_function_decl))
            parse_error_context (wfl_operator,
-                   "Checked exception `%s' can't be thrown in initializer",
+                   "Checked exception %qs can't be thrown in initializer",
                                 lang_printable_name (type, 0));
          else
            parse_error_context (wfl_operator,
-                   "Checked exception `%s' isn't thrown from a `try' block",
+                   "Checked exception %qs isn't thrown from a %<try%> block",
                                 lang_printable_name (type, 0));
        }
       /* Otherwise, the current method doesn't have the appropriate
          throws declaration */
       else
-       parse_error_context (wfl_operator, "Checked exception `%s' doesn't match any of current method's `throws' declaration(s)",
+       parse_error_context (wfl_operator, "Checked exception %qs doesn't match any of current method's %<throws%> declaration(s)",
                             lang_printable_name (type, 0));
       return error_mark_node;
     }
 
-  if (! flag_emit_class_files && ! flag_emit_xref)
+  if (! flag_emit_class_files)
     BUILD_THROW (node, expr);
 
-  /* If doing xrefs, keep the location where the `throw' was seen. */
-  if (flag_emit_xref)
-    EXPR_WFL_LINECOL (node) = EXPR_WFL_LINECOL (wfl_op1);
   return node;
 }
 
@@ -15842,13 +15914,20 @@ patch_throw_statement (tree node, tree wfl_op1)
    effectively caught from where DECL is invoked.  THIS_EXPR is the
    expression that computes `this' for the method call.  */
 static void
-check_thrown_exceptions (int location, tree decl, tree this_expr)
+check_thrown_exceptions (
+#ifdef USE_MAPPED_LOCATION
+                        source_location location,
+#else
+
+                        int location,
+#endif
+                        tree decl, tree this_expr)
 {
   tree throws;
   int is_array_call = 0;
 
   /* Skip check within generated methods, such as access$<n>.  */
-  if (OUTER_FIELD_ACCESS_IDENTIFIER_P (DECL_NAME (current_function_decl)))
+  if (NESTED_FIELD_ACCESS_IDENTIFIER_P (DECL_NAME (current_function_decl)))
     return;
 
   if (this_expr != NULL_TREE
@@ -15865,15 +15944,19 @@ check_thrown_exceptions (int location, tree decl, tree this_expr)
        if (is_array_call && DECL_NAME (decl) == get_identifier ("clone"))
          continue;
 
+#ifdef USE_MAPPED_LOCATION
+       SET_EXPR_LOCATION (wfl_operator, location);
+#else
        EXPR_WFL_LINECOL (wfl_operator) = location;
+#endif
        if (DECL_FINIT_P (current_function_decl))
          parse_error_context
-            (wfl_operator, "Exception `%s' can't be thrown in initializer",
+            (wfl_operator, "Exception %qs can't be thrown in initializer",
             lang_printable_name (TREE_VALUE (throws), 0));
        else
          {
            parse_error_context
-             (wfl_operator, "Exception `%s' must be caught, or it must be declared in the `throws' clause of `%s'",
+             (wfl_operator, "Exception %qs must be caught, or it must be declared in the %<throws%> clause of %qs",
               lang_printable_name (TREE_VALUE (throws), 0),
               (DECL_INIT_P (current_function_decl) ?
                IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))) :
@@ -15969,8 +16052,10 @@ patch_conditional_expr (tree node, tree wfl_cond, tree wfl_op1)
   tree t1, t2, patched;
   int error_found = 0;
 
-  /* Operands of ?: might be StringBuffers crafted as a result of a
-     string concatenation. Obtain a descent operand here.  */
+  /* The condition and operands of ?: might be StringBuffers crafted
+     as a result of a string concatenation.  Obtain decent ones here.  */
+  if ((patched = patch_string (cond)))
+    TREE_OPERAND (node, 0) = cond = patched;
   if ((patched = patch_string (op1)))
     TREE_OPERAND (node, 1) = op1 = patched;
   if ((patched = patch_string (op2)))
@@ -15984,7 +16069,7 @@ patch_conditional_expr (tree node, tree wfl_cond, tree wfl_op1)
     {
       SET_WFL_OPERATOR (wfl_operator, node, wfl_cond);
       parse_error_context (wfl_operator,
-               "Incompatible type for `?:'. Can't convert `%s' to `boolean'",
+               "Incompatible type for %<?:%>. Can't convert %qs to %<boolean%>",
                           lang_printable_name (TREE_TYPE (cond), 0));
       error_found = 1;
     }
@@ -16052,7 +16137,7 @@ patch_conditional_expr (tree node, tree wfl_cond, tree wfl_op1)
       char *t = xstrdup (lang_printable_name (t1, 0));
       SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
       parse_error_context (wfl_operator,
-                "Incompatible type for `?:'. Can't convert `%s' to `%s'",
+                "Incompatible type for %<?:%>. Can't convert %qs to %qs",
                           t, lang_printable_name (t2, 0));
       free (t);
       error_found = 1;
@@ -16076,7 +16161,7 @@ static tree
 maybe_build_class_init_for_field (tree decl, tree expr)
 {
   tree clas = DECL_CONTEXT (decl);
-  if (flag_emit_class_files || flag_emit_xref)
+  if (flag_emit_class_files)
     return expr;
 
   if (TREE_CODE (decl) == VAR_DECL && FIELD_STATIC (decl)
@@ -16140,13 +16225,14 @@ fold_constant_for_init (tree node, tree context)
       if (val == NULL_TREE || ! TREE_CONSTANT (val))
        return NULL_TREE;
       TREE_OPERAND (node, 1) = val;
-      return patch_binop (node, op0, op1);
+      return patch_binop (node, op0, op1, 1);
 
     case UNARY_PLUS_EXPR:
     case NEGATE_EXPR:
     case TRUTH_NOT_EXPR:
     case BIT_NOT_EXPR:
     case CONVERT_EXPR:
+    case NOP_EXPR:
       op0 = TREE_OPERAND (node, 0);
       val = fold_constant_for_init (op0, context);
       if (val == NULL_TREE || ! TREE_CONSTANT (val))
@@ -16172,8 +16258,8 @@ fold_constant_for_init (tree node, tree context)
       if (val == NULL_TREE || ! TREE_CONSTANT (val))
        return NULL_TREE;
       TREE_OPERAND (node, 2) = val;
-      return integer_zerop (TREE_OPERAND (node, 0)) ? TREE_OPERAND (node, 1)
-       : TREE_OPERAND (node, 2);
+      return integer_zerop (TREE_OPERAND (node, 0)) ? TREE_OPERAND (node, 2)
+       : TREE_OPERAND (node, 1);
 
     case VAR_DECL:
     case FIELD_DECL:
@@ -16208,16 +16294,16 @@ fold_constant_for_init (tree node, tree context)
            }
          else
            {
-             /* Install the proper context for the field resolution.
-                The prior context is restored once the name is
-                properly qualified. */
+             tree r = NULL_TREE;
+             /* Install the proper context for the field resolution.  */
              tree saved_current_class = current_class;
              /* Wait until the USE_COMPONENT_REF re-write.  FIXME. */
              current_class = DECL_CONTEXT (context);
              qualify_ambiguous_name (node);
+             r = resolve_field_access (node, &decl, NULL);
+             /* Restore prior context.  */
              current_class = saved_current_class;
-             if (resolve_field_access (node, &decl, NULL)
-                 && decl != NULL_TREE)
+             if (r != error_mark_node && decl != NULL_TREE)
                return fold_constant_for_init (decl, decl);
              return NULL_TREE;
            }
@@ -16271,22 +16357,6 @@ init_src_parse (void)
 /* This section deals with the functions that are called when tables
    recording class initialization information are traversed.  */
 
-/* Attach to PTR (a block) the declaration found in ENTRY. */
-
-static int
-attach_init_test_initialization_flags (void **entry, void *ptr)
-{
-  tree block = (tree)ptr;
-  struct treetreehash_entry *ite = (struct treetreehash_entry *) *entry;
-
-  if (block != error_mark_node)
-    {
-      TREE_CHAIN (ite->value) = BLOCK_EXPR_DECLS (block);
-      BLOCK_EXPR_DECLS (block) = ite->value;
-    }
-  return true;
-}
-
 /* This function is called for each class that is known definitely
    initialized when a given static method was called. This function
    augments a compound expression (INFO) storing all assignment to
@@ -16336,7 +16406,7 @@ emit_test_initialization (void **entry_p, void *info)
 
   /* Now simply augment the compound that holds all the assignments
      pertaining to this method invocation. */
-  init = build (MODIFY_EXPR, boolean_type_node, decl, boolean_true_node);
+  init = build2 (MODIFY_EXPR, boolean_type_node, decl, boolean_true_node);
   TREE_SIDE_EFFECTS (init) = 1;
   TREE_VALUE (l) = add_stmt_to_compound (TREE_VALUE (l), void_type_node, init);
   TREE_SIDE_EFFECTS (TREE_VALUE (l)) = 1;
@@ -16344,5 +16414,22 @@ emit_test_initialization (void **entry_p, void *info)
   return true;
 }
 
+#ifdef __XGETTEXT__
+/* Depending on the version of Bison used to compile this grammar,
+   it may issue generic diagnostics spelled "syntax error" or
+   "parse error".  To prevent this from changing the translation
+   template randomly, we list all the variants of this particular
+   diagnostic here.  Translators: there is no fine distinction
+   between diagnostics with "syntax error" in them, and diagnostics
+   with "parse error" in them.  It's okay to give them both the same
+   translation.  */
+const char d1[] = N_("syntax error");
+const char d2[] = N_("parse error");
+const char d3[] = N_("syntax error; also virtual memory exhausted");
+const char d4[] = N_("parse error; also virtual memory exhausted");
+const char d5[] = N_("syntax error: cannot back up");
+const char d6[] = N_("parse error: cannot back up");
+#endif
+
 #include "gt-java-parse.h"
 #include "gtype-java.h"