public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Patch: FYI: jcf-dump and inner class info
@ 2005-03-30 17:52 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2005-03-30 17:52 UTC (permalink / raw)
  To: Java Patch List; +Cc: Gcc Patch List

I'm checking this in on the trunk.

It is valid for the inner_class_info_index or outer_class_info_index
to be '0' in a .class file.  In this situation, jcf-dump would print
this, which I found confusing:

Attribute "InnerClasses", length:10
  inner: org.apache.tools.ant.IntrospectionHelper$1 (anonymous), access flags: 0x12 private final, outer class: <constant pool index 0 not in range>

This patch changes it to print something more clear.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	* jcf-dump.c (HANDLE_INNERCLASSES_ATTRIBUTE): Handle cases where
	inner_class_info_index==0 or outer_class_info_index==0.

Index: jcf-dump.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-dump.c,v
retrieving revision 1.66
diff -u -r1.66 jcf-dump.c
--- jcf-dump.c 6 Mar 2005 12:57:56 -0000 1.66
+++ jcf-dump.c 30 Mar 2005 17:43:27 -0000
@@ -65,7 +65,7 @@
 #include <getopt.h>
 #include <math.h>
 
-/* Outout file. */
+/* Output file. */
 FILE *out;
 /* Name of output file, if NULL if stdout. */
 char *output_file = NULL;
@@ -320,8 +320,12 @@
       if (flag_print_class_info)					    \
 	{								    \
 	  fprintf (out, "\n  inner: ");					    \
-	  print_constant_terse_with_index (out, jcf,			    \
-				inner_class_info_index, CONSTANT_Class);    \
+	  if (inner_class_info_index == 0)				    \
+	    fprintf (out, " (no inner info index)");			    \
+	  else								    \
+	    print_constant_terse_with_index (out, jcf,			    \
+					     inner_class_info_index,	    \
+					     CONSTANT_Class);		    \
 	  if (inner_name_index == 0)					    \
 	    fprintf (out, " (anonymous)");				    \
 	  else if (verbose || flag_print_constant_pool)			    \
@@ -334,12 +338,16 @@
 	  fprintf (out, ", access flags: 0x%x", inner_class_access_flags);  \
 	  print_access_flags (out, inner_class_access_flags, 'c');	    \
 	  fprintf (out, ", outer class: ");				    \
-	  print_constant_terse_with_index (out, jcf,			    \
-				outer_class_info_index, CONSTANT_Class);    \
+	  if (outer_class_info_index == 0)				    \
+	    fprintf (out, "(not a member)");				    \
+	  else								    \
+	    print_constant_terse_with_index (out, jcf,			    \
+					     outer_class_info_index,	    \
+					     CONSTANT_Class);		    \
 	}								    \
     }									    \
-      if (flag_print_class_info)					    \
-	fputc ('\n', out);						    \
+  if (flag_print_class_info)						    \
+    fputc ('\n', out);							    \
 }
 
 #define HANDLE_SOURCEDEBUGEXTENSION_ATTRIBUTE(LENGTH) \

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-03-30 17:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-30 17:52 Patch: FYI: jcf-dump and inner class info Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).