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: abstract method handling


I'm checking this in on the gcjx branch.

We don't want to emit a vtable for an interface.  We also don't want
to emit pointers to an abstract method's decl in the method table,
since no such decl exists.  (Perhaps we should even emit a pointer to
_Jv_ThrowNoSuchMethodError, but I haven't done that yet.)

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	* builtins.cc (lay_out_vtable): Handle abstract methods.
	* classobj.cc (create_one_method_record): Handle abstract
	methods.
	* abi.cc (get_vtable): Don't generate vtable for interface.

Index: abi.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/abi.cc,v
retrieving revision 1.1.2.22
diff -u -r1.1.2.22 abi.cc
--- abi.cc 4 Apr 2005 00:52:42 -0000 1.1.2.22
+++ abi.cc 27 Apr 2005 17:39:06 -0000
@@ -267,6 +267,9 @@
 tree
 cxx_abi::get_vtable (tree_builtins *builtins, model_class *klass)
 {
+  // An interface doesn't have a vtable.
+  if (klass->interface_p ())
+    return null_pointer_node;
   return build_address_of (builtins->get_vtable_decl (klass));
 }
 
Index: builtins.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/builtins.cc,v
retrieving revision 1.1.2.36
diff -u -r1.1.2.36 builtins.cc
--- builtins.cc 27 Apr 2005 17:38:08 -0000 1.1.2.36
+++ builtins.cc 27 Apr 2005 17:39:06 -0000
@@ -663,7 +663,13 @@
        i != vtable.end ();
        ++i)
     {
-      TREE_VEC_ELT (vtable_tree, index) = build_address_of (map_method (*i));
+      tree meth;
+      // FIXME: consider using _Jv_ThrowNoSuchMethodError.
+      if ((*i)->abstract_p ())
+	meth = null_pointer_node;
+      else
+	meth = build_address_of (map_method (*i));
+      TREE_VEC_ELT (vtable_tree, index) = meth;
       ++index;
     }
 
Index: classobj.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/classobj.cc,v
retrieving revision 1.1.2.22
diff -u -r1.1.2.22 classobj.cc
--- classobj.cc 17 Apr 2005 21:29:28 -0000 1.1.2.22
+++ classobj.cc 27 Apr 2005 17:39:06 -0000
@@ -206,7 +206,12 @@
 class_object_creator::create_one_method_record (model_method *method)
 {
   record_creator inst (type_method);
-  tree mdecl = builtins->map_method (method);
+  tree mdecl;
+  // FIXME: consider using _Jv_ThrowNoSuchMethodError.
+  if (method->abstract_p ())
+    mdecl = null_pointer_node;
+  else
+    mdecl = builtins->map_method (method);
   inst.set_field ("name", builtins->map_utf8const (method->get_name()));
   inst.set_field ("signature",
 		  builtins->map_utf8const (get_descriptor (method)));


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