JNI in GCJ 3.2 for Win32
Ranjit Mathew
rmathew@hotmail.com
Mon Nov 11 08:36:00 GMT 2002
Wow! Thanks for that detailed explanation!
I tried it out for the case of just adding the extra
argument size, but it failed with an "internal error:
Segmentation fault" :-(
I'll try it afresh tomorrow.
In any case, here's my attempted changes for the native
stubs part (GCJ 3.2) so far:
-------------------------- 8< -----------------------------
--- decl.c.orig 2002年11月11日 03:02:05.000000000 +0530
+++ decl.c 2002年11月11日 03:40:08.000000000 +0530
@@ -850,5 +850,6 @@
t = tree_cons (NULL_TREE, object_ptr_type_node,
tree_cons (NULL_TREE, ptr_type_node,
- tree_cons (NULL_TREE, ptr_type_node, endlink)));
+ tree_cons (NULL_TREE, ptr_type_node,
+ tree_cons (NULL_TREE, unsigned_short_type_node,
endlink))));
soft_lookupjnimethod_node
= builtin_function ("_Jv_LookupJNIMethod",
--- expr.c.orig 2002年11月11日 03:02:00.000000000 +0530
+++ expr.c 2002年11月11日 05:43:36.000000000 +0530
@@ -2187,4 +2187,6 @@
tree meth_var;
+ unsigned short args_size = 0;
+
tree klass = DECL_CONTEXT (method);
int from_class = ! CLASS_FROM_SOURCE_P (klass);
@@ -2248,5 +2250,8 @@
args = NULL_TREE;
for (tem = method_args; tem != NULL_TREE; tem = TREE_CHAIN (tem))
- args = tree_cons (NULL_TREE, tem, args);
+ {
+ args_size += size_in_bytes (TREE_TYPE(tem));
+ args = tree_cons (NULL_TREE, tem, args);
+ }
args = nreverse (args);
arg_types = TYPE_ARG_TYPES (TREE_TYPE (method));
@@ -2257,4 +2262,5 @@
if (METHOD_STATIC (method))
{
+ args_size += size_in_bytes (TREE_TYPE(klass));
args = tree_cons (NULL_TREE, klass, args);
arg_types = tree_cons (NULL_TREE, object_ptr_type_node, arg_types);
@@ -2262,4 +2268,5 @@
/* The JNIEnv structure is the first argument to the JNI function. */
+ args_size += size_in_bytes (TREE_TYPE(env_var));
args = tree_cons (NULL_TREE, env_var, args);
arg_types = tree_cons (NULL_TREE, ptr_type_node, arg_types);
@@ -2268,18 +2275,24 @@
function pointer. _Jv_LookupJNIMethod will throw the appropriate
exception if this function is not found at runtime. */
+ tem = build_tree_list (NULL_TREE, build_int_2 (args_size, 0));
method_sig = build_java_signature (TREE_TYPE (method));
- lookup_arg =
- build_tree_list (NULL_TREE,
- build_utf8_ref (unmangle_classname
- (IDENTIFIER_POINTER (method_sig),
- IDENTIFIER_LENGTH (method_sig))));
+ lookup_arg
+ = tree_cons (
+ NULL_TREE,
+ build_utf8_ref (unmangle_classname (
+ IDENTIFIER_POINTER (method_sig),
+ IDENTIFIER_LENGTH (method_sig))),
+ tem);
tem = DECL_NAME (method);
lookup_arg
= tree_cons (NULL_TREE, klass,
tree_cons (NULL_TREE, build_utf8_ref (tem), lookup_arg));
-
- jni_func_type
- = build_pointer_type (build_function_type (TREE_TYPE (TREE_TYPE
(method)),
- arg_types));
+
+ tem = build_function_type (TREE_TYPE (TREE_TYPE (method)), arg_types);
+#if defined (__MINGW32__) || defined (__CYGWIN__)
+ /* JNI methods on Win32 are invoked using the stdcall convention */
+ tem = build_type_attribute_variant (tem, get_identifier ("stdcall"));
+#endif
+ jni_func_type = build_pointer_type (tem);
jnifunc = build (COND_EXPR, ptr_type_node,
-------------------------- 8< -----------------------------
More information about the Java
mailing list