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


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

Patch: PR gcj/343


This patch fixes PR gcj/343.  The bug is that Java arrays implement
java.io.Serializable, but the gcj front end doesn't realize this.

Ok to commit?

2000-09-07  Tom Tromey  <tromey@cygnus.com>

	Fix for PR gcj/343:
	* lex.c (java_init_lex): Initialize java_io_serializable.
	* parse.y (java_io_serializable): New global.
	(valid_ref_assignconv_cast_p): An array can be cast to
	serializable.

Tom

Index: lex.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/lex.c,v
retrieving revision 1.40
diff -u -r1.40 lex.c
--- lex.c	2000/06/29 17:03:49	1.40
+++ lex.c	2000/09/08 01:32:49
@@ -72,6 +72,8 @@
     java_lang_id = get_identifier ("java.lang");
   if (!java_lang_cloneable)
     java_lang_cloneable = get_identifier ("java.lang.Cloneable");
+  if (!java_io_serializable)
+    java_io_serializable = get_identifier ("java.io.Serializable");
   if (!inst_id)
     inst_id = get_identifier ("inst$");
   if (!wpv_id)
Index: parse.y
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/parse.y,v
retrieving revision 1.207
diff -u -r1.207 parse.y
--- parse.y	2000/09/06 02:37:09	1.207
+++ parse.y	2000/09/08 01:33:01
@@ -387,6 +387,9 @@
 /* The "java.lang.Cloneable" qualified name.  */
 static tree java_lang_cloneable = NULL_TREE;
 
+/* The "java.io.Serializable" qualified name.  */
+static tree java_io_serializable = NULL_TREE; 
+
 /* Context and flag for static blocks */
 static tree current_static_block = NULL_TREE;
 
@@ -12303,19 +12306,25 @@
 	    }
 	  else
 	    return source == dest || interface_of_p (dest, source);
+	}
+      else
+	{
+	  /* Array */
+	  return (cast
+		  && (DECL_NAME (TYPE_NAME (source)) == java_lang_cloneable
+		      || (DECL_NAME (TYPE_NAME (source))
+			  == java_io_serializable)));
 	}
-      else			/* Array */
-	return (cast ? 
-		(DECL_NAME (TYPE_NAME (source)) == java_lang_cloneable) : 0);
     }
   if (TYPE_ARRAY_P (source))
     {
       if (TYPE_CLASS_P (dest))
 	return dest == object_type_node;
       /* Can't cast an array to an interface unless the interface is
-	 java.lang.Cloneable */
+	 java.lang.Cloneable or java.io.Serializable.  */
       if (TYPE_INTERFACE_P (dest))
-	return (DECL_NAME (TYPE_NAME (dest)) == java_lang_cloneable ? 1 : 0);
+	return (DECL_NAME (TYPE_NAME (dest)) == java_lang_cloneable
+		|| DECL_NAME (TYPE_NAME (dest)) == java_io_serializable);
       else			/* Arrays */
 	{
 	  tree source_element_type = TYPE_ARRAY_ELEMENT (source);

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