This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[ecj] Patch: FYI: fix for class initialization
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 21 Jun 2006 12:10:15 -0600
- Subject: [ecj] Patch: FYI: fix for class initialization
- Reply-to: tromey at redhat dot com
I'm checking this in on the gcj-eclipse branch.
This fixes an oddity involving class initialization when referring to
a static field. I believe we only want to initialize the field's
declaring class, not the qualifying class.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* link.cc (resolve_pool_entry): Initialize field's declaring
class, not its qualifying class.
Index: link.cc
===================================================================
--- link.cc (revision 114362)
+++ link.cc (working copy)
@@ -367,8 +367,9 @@
if (owner->state == JV_STATE_PHANTOM)
throw new java::lang::NoClassDefFoundError(owner->getName());
- if (owner != klass)
- _Jv_InitClass (owner);
+ // We don't initialize 'owner', but we do make sure that its
+ // fields exist.
+ wait_for_state (owner, JV_STATE_PREPARED);
_Jv_ushort name_index, type_index;
_Jv_loadIndexes (&pool->data[name_and_type_index],
@@ -383,8 +384,9 @@
&found_class,
field_name,
field_type_name);
- if (owner != found_class)
- _Jv_InitClass (found_class);
+ // Initialize the field's declaring class, not its qualifying
+ // class.
+ _Jv_InitClass (found_class);
pool->data[index].field = the_field;
pool->tags[index] |= JV_CONSTANT_ResolvedFlag;
}