This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: warn if there are duplicate definitions of a class in an archive
- From: Andrew Haley <aph at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org, java-patches at gcc dot gnu dot org
- Date: Mon, 6 Dec 2004 15:42:29 +0000
- Subject: Patch: warn if there are duplicate definitions of a class in an archive
This patch was written and tested some time ago, but got lost when
merging the new ABI branch into mainline. (OK, so I forgot about it.)
Despite being in regression fixing only mode, I'd like to commit it
now. Without it, gcj crashes if the same class is defined more than
once.
Andrew.
* jcf-parse.c (parse_zip_file_entries): Warn if we see the same
class more than once in a jar file.
Index: jcf-parse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-parse.c,v
retrieving revision 1.180
diff -p -2 -c -r1.180 jcf-parse.c
*** jcf-parse.c 28 Nov 2004 06:49:48 -0000 1.180
--- jcf-parse.c 6 Dec 2004 15:40:49 -0000
*************** parse_zip_file_entries (void)
*** 1371,1374 ****
--- 1371,1388 ----
class = lookup_class (get_identifier (class_name));
FREE (class_name);
+
+ {
+ char *class_name_in_zip_dir = ZIPDIR_FILENAME (zdir);
+ tree id = get_identifier (class_name_in_zip_dir);
+ if (IS_A_COMMAND_LINE_FILENAME_P (id))
+ {
+ input_location = DECL_SOURCE_LOCATION (TYPE_NAME (class));
+ warning ("%s appears more than once in this compilation",
+ class_name_in_zip_dir);
+ break;
+ }
+ IS_A_COMMAND_LINE_FILENAME_P (id) = 1;
+ }
+
current_jcf = TYPE_JCF (class);
output_class = current_class = class;