Patch: FYI: jcf-dump and inner class info
Tom Tromey
tromey@redhat.com
Wed Mar 30 18:58:00 GMT 2005
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) \
More information about the Java-patches
mailing list