gcj/129
Alexandre Petit-Bianco
apbianco@cygnus.com
Tue May 2 00:16:00 GMT 2000
The following reply was made to PR gcj/129; it has been noted by GNATS.
From: Alexandre Petit-Bianco <apbianco@cygnus.com>
To: Java Gnats Server <java-gnats@sourceware.cygnus.com>
Cc:
Subject: Re: gcj/129
Date: Tue, 2 May 2000 00:10:47 -0700 (PDT)
Alexandre Petit-Bianco writes:
> Yes. I have the following patch, but the runtime fails because we're
> not initializing class `A' before we use `strArr'. This needs to be
> fixed.
This patch wasn't really fixing the problem at its source. Here's an
other one I think is better.
./A
2000-05-02 Alexandre Petit-Bianco <apbianco@kazmo.drew.net>
* parse.y (resolve_field_access): Call the appropriate <clinit>
before accessing the length of a static array. Craft a decl for
the field while its time.
Index: parse.y
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/parse.y,v
retrieving revision 1.160
diff -u -p -r1.160 parse.y
--- parse.y 2000/05/01 22:32:20 1.160
+++ parse.y 2000/05/02 07:04:13
@@ -8576,6 +8636,18 @@ resolve_field_access (qual_wfl, field_de
tree length = build_java_array_length_access (where_found);
field_ref =
build_java_arraynull_check (type_found, length, int_type_node);
+
+ /* 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. */
+ if (TREE_CODE (where_found) == VAR_DECL && FIELD_STATIC (where_found))
+ {
+ build_static_field_ref (where_found);
+ field_ref = build_class_init (DECL_CONTEXT (where_found), field_ref);
+ }
}
/* We might have been trying to resolve field.method(). In which
case, the resolution is over and decl is the answer */
More information about the Java-prs
mailing list