This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Java: `finit$' to replace `$finit$'.
- To: gcc-patches at gcc dot gnu dot org
- Subject: [PATCH] Java: `finit$' to replace `$finit$'.
- From: Alexandre Petit-Bianco <apbianco at cygnus dot com>
- Date: Thu, 17 Aug 2000 14:34:27 -0700
- Reply-to: apbianco at redhat dot com
I'm checking in this patch, which should be used in conjunction with a
Java runtime patch that I'm also checking in and appending to this
email.
The goal of this patch is to use `finit$' instead of `$finit$' as a
name for the method created to initialize fields. The primary reason
for this is that gdb doesn't expect leading `$' signs in identifier in
certain situations. The other reason is that even though `$' signs can
be used in mechanically generated names, I never saw one generated
with a leading `$' and I don't want this to bite us in the future.
This compiler patch and the associated run-time patch let gcj generate
`finit$' in place of `$finit$'. It also let the compiler recognize
`$finit$' as being equivalent to `finit$' -- the run-time patch
basically does the same thing; it's a backward compatibility hack.
There's no need for Java hackers to rebuild their existing world,
`$fini$' and finit$' should be able to coexists peacefully.
./A
2000-08-15 Alexandre Petit-Bianco <apbianco@cygnus.com>
* decl.c (finit_leg_identifier_node): New global.
(init_decl_processing): Use `finit$' to initialize
finit_identifier_node. Use `$finit$' to initialize
finit_leg_identifier_node.
* expr.c (expand_java_field_op): Use ID_FINIT_P.
* java-tree.h (finit_identifier_node): Changed attached comment.
(finit_leg_identifier_node): New declaration.
(ID_FINIT_P): Take finit_identifier_node and
finit_leg_identifier_node into account. This is a backward
compatibility hack.
Index: decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/decl.c,v
retrieving revision 1.69
diff -u -p -r1.69 decl.c
--- decl.c 2000/06/11 04:29:48 1.69
+++ decl.c 2000/08/17 21:07:23
@@ -360,6 +360,7 @@ tree TYPE_identifier_node;
tree init_identifier_node;
tree clinit_identifier_node;
tree finit_identifier_node;
+tree finit_leg_identifier_node;
tree void_signature_node;
tree length_identifier_node;
tree this_identifier_node;
@@ -646,7 +647,12 @@ init_decl_processing ()
TYPE_identifier_node = get_identifier ("TYPE");
init_identifier_node = get_identifier ("<init>");
clinit_identifier_node = get_identifier ("<clinit>");
- finit_identifier_node = get_identifier ("$finit$");
+ /* Legacy `$finit$' special method identifier. This needs to be
+ recognized as equivalent to `finit$' but isn't generated anymore. */
+ finit_leg_identifier_node = get_identifier ("$finit$");
+ /* The new `finit$' special method identifier. This one is now
+ generated in place of `$finit$'. */
+ finit_identifier_node = get_identifier ("finit$");
void_signature_node = get_identifier ("()V");
length_identifier_node = get_identifier ("length");
this_identifier_node = get_identifier ("this");
Index: expr.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/expr.c,v
retrieving revision 1.81
diff -u -p -r1.81 expr.c
--- expr.c 2000/08/08 03:33:36 1.81
+++ expr.c 2000/08/17 21:07:30
@@ -2210,7 +2210,7 @@ expand_java_field_op (is_static, is_putt
{
tree cfndecl_name = DECL_NAME (current_function_decl);
if (! DECL_CONSTRUCTOR_P (current_function_decl)
- && (cfndecl_name != finit_identifier_node))
+ && !ID_FINIT_P (cfndecl_name))
error_with_decl (field_decl, "assignment to final field `%s' not in constructor");
}
}
Index: java-tree.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/java-tree.h,v
retrieving revision 1.77
diff -u -p -r1.77 java-tree.h
--- java-tree.h 2000/08/11 22:01:37 1.77
+++ java-tree.h 2000/08/17 21:07:34
@@ -253,7 +253,8 @@ extern tree double_array_vtable;
extern tree TYPE_identifier_node; /* "TYPE" */
extern tree init_identifier_node; /* "<init>" */
extern tree clinit_identifier_node; /* "<clinit>" */
-extern tree finit_identifier_node; /* "$finit$" */
+extern tree finit_identifier_node; /* "finit$" */
+extern tree finit_leg_identifier_node; /* "$finit$" */
extern tree void_signature_node; /* "()V" */
extern tree length_identifier_node; /* "length" */
extern tree this_identifier_node; /* "this" */
@@ -821,7 +822,12 @@ struct rtx_def * java_lang_expand_expr P
/* Predicates on method identifiers. Kept close to other macros using
them */
#define ID_INIT_P(ID) ((ID) == init_identifier_node)
-#define ID_FINIT_P(ID) ((ID) == finit_identifier_node)
+/* Match ID to either `$finit$' or `finit$', so that `$finit$'
+ continues to be recognized as an equivalent to `finit$' which is
+ now the prefered name used for the field initialization special
+ method. */
+#define ID_FINIT_P(ID) ((ID) == finit_identifier_node \
+ || (ID) == finit_leg_identifier_node)
#define ID_CLINIT_P(ID) ((ID) == clinit_identifier_node)
/* Access flags etc for a variable/field (a FIELD_DECL): */
Here's the Java run-time patch that you'll need to apply if you apply
the previous patch to the compiler:
2000-08-15 Alexandre Petit-Bianco <apbianco@cygnus.com>
* java/lang/natClass.cc (finit_name): Initialized with `finit$'.
(finit_leg_name): New global.
(java::lang::Class::getDeclaredMethods): Test for `finit$' or
`$finit$'.
(java::lang::Class::_getMethods): Likewise.
Index: libjava/java/lang/natClass.cc
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/lang/natClass.cc,v
retrieving revision 1.27
diff -u -p -r1.27 natClass.cc
--- natClass.cc 2000/06/18 22:14:06 1.27
+++ natClass.cc 2000/08/17 20:12:37
@@ -70,7 +70,10 @@ extern java::lang::Class ConstructorClas
static _Jv_Utf8Const *void_signature = _Jv_makeUtf8Const ("()V", 3);
static _Jv_Utf8Const *clinit_name = _Jv_makeUtf8Const ("<clinit>", 8);
static _Jv_Utf8Const *init_name = _Jv_makeUtf8Const ("<init>", 6);
-static _Jv_Utf8Const *finit_name = _Jv_makeUtf8Const ("$finit$", 7);
+static _Jv_Utf8Const *finit_name = _Jv_makeUtf8Const ("finit$", 6);
+// The legacy `$finit$' method name, which still needs to be
+// recognized as equivalent to the now prefered `finit$' name.
+static _Jv_Utf8Const *finit_leg_name = _Jv_makeUtf8Const ("$finit$", 7);
@@ -331,7 +334,9 @@ java::lang::Class::getDeclaredMethods (v
if (method->name == NULL
|| _Jv_equalUtf8Consts (method->name, clinit_name)
|| _Jv_equalUtf8Consts (method->name, init_name)
- || _Jv_equalUtf8Consts (method->name, finit_name))
+ || _Jv_equalUtf8Consts (method->name, finit_name)
+ // Backward compatibility hack: match the legacy `$finit$' name
+ || _Jv_equalUtf8Consts (method->name, finit_leg_name))
continue;
numMethods++;
}
@@ -345,7 +350,9 @@ java::lang::Class::getDeclaredMethods (v
if (method->name == NULL
|| _Jv_equalUtf8Consts (method->name, clinit_name)
|| _Jv_equalUtf8Consts (method->name, init_name)
- || _Jv_equalUtf8Consts (method->name, finit_name))
+ || _Jv_equalUtf8Consts (method->name, finit_name)
+ // Backward compatibility hack: match the legacy `$finit$' name
+ || _Jv_equalUtf8Consts (method->name, finit_leg_name))
continue;
java::lang::reflect::Method* rmethod
= new java::lang::reflect::Method ();
@@ -508,7 +515,9 @@ java::lang::Class::_getMethods (JArray<j
if (method->name == NULL
|| _Jv_equalUtf8Consts (method->name, clinit_name)
|| _Jv_equalUtf8Consts (method->name, init_name)
- || _Jv_equalUtf8Consts (method->name, finit_name))
+ || _Jv_equalUtf8Consts (method->name, finit_name)
+ // Backward compatibility hack: match the legacy `$finit$' name
+ || _Jv_equalUtf8Consts (method->name, finit_leg_name))
continue;
// Only want public methods.
if (! java::lang::reflect::Modifier::isPublic (method->accflags))