This is the mail archive of the java@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]

Don't die with duplicate entries in a jarfile


Right now we crash if the same class appears more than once in jar.
This multople include detection already works for the command line,
but not when the same file appears more than once in a jarfile.  This
perhaps ought not to be possible, but it does happen in some
well-distributed applications.

With this patch, we warn but we don't die.

Andrew.



2004-11-08  Andrew Haley  <aph@redhat.com>

	* 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.158.4.10
diff -p -2 -c -r1.158.4.10 jcf-parse.c
*** jcf-parse.c	3 Nov 2004 00:10:58 -0000	1.158.4.10
--- jcf-parse.c	8 Nov 2004 19:52:37 -0000
*************** parse_zip_file_entries (void)
*** 1370,1373 ****
--- 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;


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