This is the mail archive of the java-discuss@sources.redhat.com 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]

Re: More bugs with inner classes (was: Freenet compilation errors.)



Mark J. Roberts writes:

> So the problem is with parsing the .class file for
> Connection.java. I'll try to make a test case right now.

OK. Here's what's happening. finit$ is generated on the fly by the
class being compiled, it's looked up, but there's really only one
valid candidate which always sits in the class being searched. In your
case, the bytecode loader was grabbing an already generated finit$
which was conflicting with the one we're searching. This situation
uncovered an other problem: we weren't marking synthetic members when
loaded from the bytecode parser (hence the confusing error message.)

With the following patch, gcj bails out building Freenet.contrib.fproxy.\
mumail.mime.MIME_text_plain because there isn't a sun.io.CharacterEncoding.\
aliasName method available. This patch include Tom's suggestion of
simplifying resolve_package which contained irrelevant code, and clean
things a bit (we've been picking up some warnings lately.)

I need to throughly test this patch before I commit it.

./A

Thu Jan 18 17:17:51 2001  Alexandre Petit-Bianco  <apbianco@cygnus.com>

	* jcf-parse.c (HANDLE_END_METHODS): Nullify current_method.
	(HANDLE_SYNTHETIC_ATTRIBUTE): New macro.
	* jcf-reader.c (get_attribute): Handle `Synthetic' attribute.
	(jcf_parse_fields): Nullify current_field when done.
	(jcf_parse_methods): Nullify current_method when done.
	* parse.y (lookup_package_type_and_set_next): Deleted.
	(resolve_package): Removed necessary code.
	(find_applicable_accessible_methods_list): `finit$' can't be
 	inherited.
	* verify.c (pop_argument_types): Added missing prototype.
	* zipfile.h (struct ZipDirectory): Fields `size' and
 	`uncompressed_size' to be of type `ssize_t'. Fixed comment
 	identation, removed commented out fields.

Index: jcf-parse.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/jcf-parse.c,v
retrieving revision 1.62
diff -u -p -r1.62 jcf-parse.c
--- jcf-parse.c	2000/11/10 16:01:20	1.62
+++ jcf-parse.c	2001/01/19 02:34:34
@@ -155,7 +155,8 @@ set_source_filename (jcf, index)
 
 #define HANDLE_END_METHODS() \
 { tree handle_type = CLASS_TO_HANDLE_TYPE (current_class); \
-  if (handle_type != current_class) layout_type (handle_type); }
+  if (handle_type != current_class) layout_type (handle_type); \
+  current_method = NULL_TREE; }
 
 #define HANDLE_CODE_ATTRIBUTE(MAX_STACK, MAX_LOCALS, CODE_LENGTH) \
 { DECL_MAX_STACK (current_method) = (MAX_STACK); \
@@ -208,6 +209,15 @@ set_source_filename (jcf, index)
       else								  \
 	JCF_SKIP (jcf, 6);						  \
     }									  \
+}
+
+#define HANDLE_SYNTHETIC_ATTRIBUTE()					\
+{									\
+  /* Irrelevant decls should have been nullified by the END macros. */ \
+  if (current_method)							\
+    DECL_ARTIFICIAL (current_method) = 1;				\
+  else									\
+    DECL_ARTIFICIAL (current_field) = 1;				\
 }
 
 #include "jcf-reader.c"
Index: jcf-reader.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/jcf-reader.c,v
retrieving revision 1.13
diff -u -p -r1.13 jcf-reader.c
--- jcf-reader.c	2000/10/21 15:10:38	1.13
+++ jcf-reader.c	2001/01/19 02:34:34
@@ -206,6 +206,13 @@ DEFUN(get_attribute, (jcf),
     }
   else
 #endif
+#ifdef HANDLE_SYNTHETIC_ATTRIBUTE
+  if (name_length == 9 && memcmp (name_data, "Synthetic", 9) == 0)
+    {
+      HANDLE_SYNTHETIC_ATTRIBUTE ();
+    }
+  else
+#endif
     {
 #ifdef PROCESS_OTHER_ATTRIBUTE
       PROCESS_OTHER_ATTRIBUTE(jcf, attribute_name, attribute_length);
Index: parse.y
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/parse.y,v
retrieving revision 1.244
diff -u -p -r1.244 parse.y
--- parse.y	2001/01/18 03:07:01	1.244
+++ parse.y	2001/01/19 02:34:34
@@ -113,7 +113,6 @@ static int check_pkg_class_access PARAMS
 static void register_package PARAMS ((tree));
 static tree resolve_package PARAMS ((tree, tree *));
 static tree lookup_package_type PARAMS ((const char *, int));
-static tree lookup_package_type_and_set_next PARAMS ((const char *, int, tree *));
 static tree resolve_class PARAMS ((tree, tree, tree, tree));
 static void declare_local_variables PARAMS ((int, tree, tree));
 static void source_start_java_method PARAMS ((tree));
@@ -6832,35 +6831,6 @@ resolve_package (pkg, next)
 
   *next = EXPR_WFL_QUALIFICATION (pkg);
 
-  /* Try the current package. */
-  if (ctxp->package && !strncmp (name, IDENTIFIER_POINTER (ctxp->package),  
-				 IDENTIFIER_LENGTH (ctxp->package)))
-    {
-      type_name = 
-	lookup_package_type_and_set_next (name, 
-					  IDENTIFIER_LENGTH (ctxp->package), 
-					  next );
-      if (type_name)
-	return type_name;
-    }
-
-  /* Search in imported package */
-  for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
-    {
-      tree current_pkg_name = EXPR_WFL_NODE (TREE_PURPOSE (current));
-      int len = IDENTIFIER_LENGTH (current_pkg_name);
-      if (!strncmp (name, IDENTIFIER_POINTER (current_pkg_name), len))
-	{
-	  tree left, dummy;
-	  
-	  breakdown_qualified (&left, &dummy, current_pkg_name);
-	  len = IDENTIFIER_LENGTH (left);
-	  type_name = lookup_package_type_and_set_next (name, len, next);
-	  if (type_name)
-	    break;
-	}
-    }
-
   /* Try to progressively construct a type name */
   if (TREE_CODE (pkg) == EXPR_WITH_FILE_LOCATION)
     for (acc = NULL_TREE, current = EXPR_WFL_QUALIFICATION (pkg); 
@@ -6881,27 +6851,6 @@ resolve_package (pkg, next)
 }
 
 static tree
-lookup_package_type_and_set_next (name, len, next)
-     const char *name;
-     int len;
-     tree *next;
-{
-  const char *ptr;
-  tree type_name = lookup_package_type (name, len);
-
-  if (!type_name)
-    return NULL;
-  
-  ptr = IDENTIFIER_POINTER (type_name);
-  while (ptr && (ptr = strchr (ptr, '.'))) 
-    {
-      *next = TREE_CHAIN (*next);
-      ptr++;
-    }
-  return type_name;
-}
-
-static tree
 lookup_package_type (name, from)
      const char *name;
      int from;
@@ -10568,6 +10517,16 @@ find_applicable_accessible_methods_list 
       int seen_inner_class = 0;
       search_applicable_methods_list (lc, TYPE_METHODS (class), 
 				      name, arglist, &list, &all_list);
+
+      /* When looking finit$, we turn LC to 1 so that we only search
+	 in class. Note that we should have found something at
+	 this point. */
+      if (ID_FINIT_P (name))
+	{
+	  lc = 1;
+	  if (!list)
+	    fatal ("finit$ not found in class -- find_applicable_accessible_methods_list");
+	}
 
       /* We must search all interfaces of this class */
       if (!lc)
Index: verify.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/verify.c,v
retrieving revision 1.35
diff -u -p -r1.35 verify.c
--- verify.c	2001/01/14 21:48:10	1.35
+++ verify.c	2001/01/19 02:34:34
@@ -38,6 +38,7 @@ static tree merge_types PARAMS ((tree, t
 static const char *check_pending_block PARAMS ((tree));
 static void type_stack_dup PARAMS ((int, int));
 static int start_pc_cmp PARAMS ((const PTR, const PTR));
+static char *pop_argument_types PARAMS ((tree));
 
 extern int stack_pointer;
 
Index: zipfile.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/zipfile.h,v
retrieving revision 1.10
diff -u -p -r1.10 zipfile.h
--- zipfile.h	2000/12/10 03:53:33	1.10
+++ zipfile.h	2001/01/19 02:34:34
@@ -35,13 +35,10 @@ struct ZipDirectory {
   int direntry_size;
   int filename_offset;
   int compression_method;
-  unsigned size; /* length of file */
-  unsigned uncompressed_size; /* length of uncompressed data */
-  unsigned filestart;  /* start of file in archive */
+  ssize_t size;			/* length of file */
+  ssize_t uncompressed_size;	/* length of uncompressed data */
+  unsigned filestart;		/* start of file in archive */
   int filename_length;
-  /* char mid_padding[...]; */
-  /* char filename[filename_length]; */
-  /* char end_padding[...]; */
 };
 
 typedef struct ZipDirectory ZipDirectory;



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