This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Java: Fix for PR15734
- From: Bryce McKinlay <mckinlay at redhat dot com>
- To: java-patches at gcc dot gnu dot org
- Date: Fri, 25 Jun 2004 17:05:37 -0400
- Subject: Java: Fix for PR15734
gcj segfaults when compiling bytecode that contains a getstatic op for a
field in another class if it has not yet encountered some other bytecode
that causes the target class to be loaded. This probably doesnt happen
with the output from standard java compilers because they must first
initialize the class in question, but in this case the class file is
produced by a compiler for another language, thus the bytecode produced
is not bound to the rules of the JLS.
No testsuite regressions - ok to commit?
Bryce
2004-06-25 Bryce McKinlay <mckinlay@redhat.com>
PR java/15734
* expr.c (expand_java_field_op): Ensure that target class for static
field access has been loaded.
Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/expr.c,v
retrieving revision 1.193
diff -u -r1.193 expr.c
--- expr.c 22 Jun 2004 03:07:03 -0000 1.193
+++ expr.c 25 Jun 2004 20:59:00 -0000
@@ -2375,7 +2375,11 @@
tree new_value = is_putting ? pop_value (field_type) : NULL_TREE;
tree field_ref;
int is_error = 0;
- tree field_decl = lookup_field (&self_type, field_name);
+ tree field_decl;
+
+ if (! CLASS_LOADED_P (self_type))
+ load_class (self_type, 1);
+ field_decl = lookup_field (&self_type, field_name);
if (field_decl == error_mark_node)
{
is_error = 1;