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]

[gcjx] Patch: FYI: generic types in bytecode generator


I'm checking this in on the gcjx branch.

When the tree back end looks for a method (or field) it needs, it
neglects to look for the erasure of the type.  (This is an
internal-only thing so is a little hacky -- it doesn't do real method
lookup.)  This means we won't find certain methods or fields if
pointed at a 1.5 class library.

This patch fixes the lookup.  Now all the boxing and unboxing jacks
tests pass when gcjx is run using the classpath generics branch (still
compiled with ecj) as its class library.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	* bytecode/generate.cc (find_field): Examine erasure of field's
	type.
	(find_method): Examine erasures of method's types.

Index: bytecode/generate.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/bytecode/Attic/generate.cc,v
retrieving revision 1.1.2.18
diff -u -r1.1.2.18 generate.cc
--- bytecode/generate.cc 12 Jul 2005 17:30:26 -0000 1.1.2.18
+++ bytecode/generate.cc 12 Jul 2005 17:31:05 -0000
@@ -2101,7 +2101,7 @@
        ++it)
     {
       model_field *field = (*it).get ();
-      if (field->get_name () == name && field->type () == type)
+      if (field->get_name () == name && field->type ()->erasure () == type)
         return field;
     }
   throw request->error ("couldn't find field %1 of type %2 in class %3")
@@ -2131,7 +2131,7 @@
       if (! argtype || len != 1)
 	continue;
       ref_variable_decl var = params.front ();
-      if (var->type () == argtype)
+      if (var->type ()->erasure () == argtype)
 	{
 	  result = meth;
 	  break;
@@ -2146,7 +2146,7 @@
 	% mname % (argtype ? argtype : primitive_void_type) % klass;
     }
 
-  if (result->get_return_type () != result_type)
+  if (result->get_return_type ()->erasure () != result_type)
     {
       throw request->error ("method %1 doesn't have expected return type"
 			    " of %2")
@@ -2302,8 +2302,9 @@
   if (type->primitive_p () || type == primitive_void_type)
     {
       model_class *wrapper = box_primitive_type (type);
-      model_field *field = find_field ("TYPE", wrapper,
-        global->get_compiler ()->java_lang_Class (), ref);
+      model_field *field
+	= find_field ("TYPE", wrapper,
+		      global->get_compiler ()->java_lang_Class (), ref);
       emit (op_getstatic);
       emit2 (cpool->add (wrapper, field));
     }


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