re PR java/28754 (java.lang.nullPointerException while accessing final static members...
authorTom Tromey <tromey@redhat.com>
Tue, 12 Sep 2006 15:55:07 +0000 (15:55 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Tue, 12 Sep 2006 15:55:07 +0000 (15:55 +0000)
PR java/28754:
* expr.c (expand_java_field_op): Initialize field's declaring
interface if necessary.

From-SVN: r116890

gcc/java/ChangeLog
gcc/java/expr.c

index e7508bf..1df29cc 100644 (file)
@@ -1,5 +1,11 @@
 2006-09-12  Tom Tromey  <tromey@redhat.com>
 
+       PR java/28754:
+       * expr.c (expand_java_field_op): Initialize field's declaring
+       interface if necessary.
+
+2006-09-12  Tom Tromey  <tromey@redhat.com>
+
        PR java/28892:
        * expr.c (expand_java_field_op): No error for assignments not in
        class initializer or constructor.
index b08d33e..26cd7da 100644 (file)
@@ -2837,7 +2837,12 @@ expand_java_field_op (int is_static, int is_putting, int field_ref_index)
   field_ref = build_field_ref (field_ref, self_type, field_name);
   if (is_static
       && ! flag_indirect_dispatch)
-    field_ref = build_class_init (self_type, field_ref);
+    {
+      tree context = DECL_CONTEXT (field_ref);
+      if (context != self_type && CLASS_INTERFACE (TYPE_NAME (context)))
+       field_ref = build_class_init (context, field_ref);
+      field_ref = build_class_init (self_type, field_ref);
+    }
   if (is_putting)
     {
       flush_quick_stack ();