[gcjx] Patch: FYI: fix descriptor generation
Tom Tromey
tromey@redhat.com
Tue Mar 8 01:21:00 GMT 2005
I'm checking this in on the gcjx branch.
For some reason, gcj and libgcj expect class descriptors using '.'
instead of '/'. I forgot this initially, but this patch changes gcjx
to emit descriptors this way.
We should really fix this, I think it is a source of inefficiency and
confusion. Better, IMO, to just follow .class files exactly.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* classobj.cc (get_descriptor): New methods.
(create_one_field_record): Update.
(create_method_throws): Likewise.
(create_one_method_record): Likewise.
(create_index_table): Likewise.
Index: classobj.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/classobj.cc,v
retrieving revision 1.1.2.15
diff -u -r1.1.2.15 classobj.cc
--- classobj.cc 8 Mar 2005 00:53:04 -0000 1.1.2.15
+++ classobj.cc 8 Mar 2005 01:03:49 -0000
@@ -81,6 +81,20 @@
+static std::string
+get_descriptor (model_type *t)
+{
+ // Why do we do this?
+ return join (split (t->get_descriptor (), '/'), '.');
+}
+
+static std::string
+get_descriptor (model_method *m)
+{
+ // Why do we do this?
+ return join (split (m->get_descriptor (), '/'), '.');
+}
+
tree
class_object_creator::make_decl (tree type, tree value)
{
@@ -104,7 +118,7 @@
inst.set_field ("name", builtins->map_utf8const (field->get_name ()));
// FIXME: ABI difference here.
inst.set_field ("type",
- builtins->map_utf8const (field->type ()->get_descriptor ()));
+ builtins->map_utf8const (get_descriptor (field->type ())));
inst.set_field ("accflags", build_int_cst (type_jint,
field->get_modifiers ()));
inst.set_field ("bsize", TYPE_SIZE_UNIT (TREE_TYPE (fdecl)));
@@ -175,7 +189,7 @@
i != throw_list.end ();
++i)
{
- tree utf = builtins->map_utf8const ((*i)->type ()->get_descriptor ());
+ tree utf = builtins->map_utf8const (get_descriptor ((*i)->type ()));
cons_list = tree_cons (NULL_TREE, utf, cons_list);
}
@@ -195,7 +209,7 @@
tree mdecl = builtins->map_method (method);
inst.set_field ("name", builtins->map_utf8const (method->get_name()));
inst.set_field ("signature",
- builtins->map_utf8const (method->get_descriptor ()));
+ builtins->map_utf8const (get_descriptor (method)));
inst.set_field ("accflags",
build_int_cst (type_jushort, method->get_modifiers ()));
gcj_abi *abi = builtins->find_abi ();
@@ -259,16 +273,16 @@
if (dynamic_cast<model_field *> (*i))
{
model_field *field = assert_cast<model_field *> (*i);
- class_desc = field->get_declaring_class ()->get_descriptor ();
+ class_desc = get_descriptor (field->get_declaring_class ());
name = field->get_name ();
- descriptor = field->type ()->get_descriptor ();
+ descriptor = get_descriptor (field->type ());
}
else
{
model_method *method = assert_cast<model_method *> (*i);
- class_desc = method->get_declaring_class ()->get_descriptor ();
+ class_desc = get_descriptor (method->get_declaring_class ());
name = method->get_name ();
- descriptor = method->get_descriptor ();
+ descriptor = get_descriptor (method);
}
tree class_tree = builtins->map_utf8const (class_desc);
More information about the Java-patches
mailing list