This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[ecj] Patch: FYI: fix for class initialization


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;
       }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]