This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Recent JNI regression
- From: Andrew Haley <aph at redhat dot com>
- To: Marco Trudel <mtrudel at gmx dot ch>
- Cc: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: Wed, 7 Feb 2007 16:48:05 +0000
- Subject: Re: Recent JNI regression
- References: <45C9AC80.7050200@gmx.ch>
I have a fix for this.
2007-02-07 Andrew Haley <aph@redhat.com>
* class.c (uncache_this_class_ref): New.
* expr.c (build_jni_stub): Initialize the class.
(expand_byte_code): Call uncache_this_class_ref after generating
code.
Index: class.c
===================================================================
--- class.c (revision 121594)
+++ class.c (working copy)
@@ -1047,6 +1047,15 @@
}
}
+/* Remove the reference to the local variable that holds the current
+ class$. */
+
+void
+uncache_this_class_ref (tree fndecl ATTRIBUTE_UNUSED)
+{
+ this_classdollar = build_classdollar_field (output_class);
+}
+
/* Build a reference to the class TYPE.
Also handles primitive types and array types. */
Index: expr.c
===================================================================
--- expr.c (revision 121594)
+++ expr.c (working copy)
@@ -2799,6 +2799,21 @@
build1 (RETURN_EXPR, res_type, res_var));
TREE_SIDE_EFFECTS (body) = 1;
+ /* Prepend class initialization for static methods reachable from
+ other classes. */
+ if (METHOD_STATIC (method)
+ && (! METHOD_PRIVATE (method)
+ || INNER_CLASS_P (DECL_CONTEXT (method))))
+ {
+ tree init = build3 (CALL_EXPR, void_type_node,
+ build_address_of (soft_initclass_node),
+ build_tree_list (NULL_TREE,
+ klass),
+ NULL_TREE);
+ body = build2 (COMPOUND_EXPR, void_type_node, init, body);
+ TREE_SIDE_EFFECTS (body) = 1;
+ }
+
bind = build3 (BIND_EXPR, void_type_node, BLOCK_VARS (block),
body, block);
return bind;
@@ -3227,6 +3242,8 @@
maybe_poplevels (PC);
} /* for */
+ uncache_this_class_ref (method);
+
if (dead_code_index != -1)
{
/* We've just reached the end of a region of dead code. */
Index: java-tree.h
===================================================================
--- java-tree.h (revision 121594)
+++ java-tree.h (working copy)
@@ -1130,6 +1130,7 @@
extern tree layout_class_method (tree, tree, tree, tree);
extern void layout_class_methods (tree);
extern void cache_this_class_ref (tree);
+extern void uncache_this_class_ref (tree);
extern tree build_class_ref (tree);
extern tree build_dtable_decl (tree);
extern tree build_internal_class_name (tree);