[BC] Patch: FYI: prepare target class

Tom Tromey tromey@redhat.com
Fri Aug 13 23:02:00 GMT 2004


I'm checking this in on the BC branch.

This prepares the target class, if it is interpreted, when resolving a
static field.  It also re-enables the code in the front end to handle
static field references using indirect dispatch.

This isn't perfect, since we're probably loading classes too eagerly.
That will taken care of when I start revamping this code more
seriously; see the discussion on java-patches about handling static
field references.

With this patch, I can now compile swt.jar to a .so and have the
resulting Eclipse still start up properly.

Tom

Index: gcc/java/ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	* class.c (build_static_field_ref): Re-enable atable lookups for
	static fields.

Index: gcc/java/class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/class.c,v
retrieving revision 1.180.2.7
diff -u -r1.180.2.7 class.c
--- gcc/java/class.c 23 Jun 2004 12:22:21 -0000 1.180.2.7
+++ gcc/java/class.c 13 Aug 2004 20:17:48 -0000
@@ -1087,10 +1087,7 @@
       return fdecl;
     }
 
-  /* FIXME: The gcj runtime is broken in that atable references to
-     static fields in interpreted classes aren't fixed up until too
-     late.  When this is fixed we can re-enable this code.  */
-  if (0 && flag_indirect_dispatch)
+  if (flag_indirect_dispatch)
     {
       tree table_index 
 	= build_int_2 (get_symbol_table_index 
Index: libjava/ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	* java/lang/natClass.cc (_Jv_LinkSymbolTable): Prepare the target
	class if it is interpreted.

Index: libjava/java/lang/natClass.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natClass.cc,v
retrieving revision 1.75.2.8
diff -u -r1.75.2.8 natClass.cc
--- libjava/java/lang/natClass.cc 12 Aug 2004 23:16:27 -0000 1.75.2.8
+++ libjava/java/lang/natClass.cc 13 Aug 2004 20:17:52 -0000
@@ -1870,8 +1870,11 @@
 		  _Jv_ResolveField (field, cls->loader);
 
 		if (_Jv_IsInterpretedClass (target_class))
-		  _Jv_AssertDoCall ("can't fixup reference to static field in interpreted class");
-		
+		  {
+		    JvSynchronize sync (target_class);
+		    _Jv_PrepareClass(target_class);
+		  }
+
 // 		if (field_type != 0 && field->type != field_type)
 // 		  throw new java::lang::LinkageError
 // 		    (JvNewStringLatin1 



More information about the Gcc-patches mailing list