JNI in GCJ 3.2 for Win32

Tom Tromey tromey@redhat.com
Tue Nov 12 08:57:00 GMT 2002


>>>>> "Ranjit" == Ranjit Mathew <rmathew@hotmail.com> writes:

Ranjit> 2. I used the __MINGW32__ and __CYGWIN__ definitions simply
Ranjit> because I didn't know how to switch based on the target.  None
Ranjit> of xm-*ming*.h or *ming*.h in "gcc/config/i386" contained any
Ranjit> useful #define.

I don't know how to do this either, but it is a requirement for this
patch to go in.  You could ask on the main gcc list.

I dug around a little.  TARGET_DLLIMPORT_DECL_ATTRIBUTES would work,
but I suspect this isn't the approach the gcc maintainers would want.
Asking is your best bet.

 [ jni.cc ]

Ranjit> +#ifdef WIN32
Ranjit> +  // On Win32, we use the stdcall calling convention (ref. JNICALL in
Ranjit> jni.h).
Ranjit> +  //
Ranjit> +  // The stdcall convention puts a '@xx' at the end of a function that
Ranjit> +  // takes 'xx' number of bytes as arguments.
Ranjit> +
Ranjit> +  char asz_buf[7];      /* '@' + '65535' (16-bit ushort max.) + '\0' */
Ranjit> +  sprintf( asz_buf, "@%hu", args_size);
Ranjit> +  strcat( buf, asz_buf);
Ranjit> +#else
Ranjit> +  args_size;   /* Dummy statement to avoid unused parameter warning */
Ranjit> +#endif /* ! WIN32 */

This patch only adds the length information to the short name.  It must
do the same for both names.

In JNI you have a choice of using a full name, including all type
information, or a short name, which just has the name of the method.
The latter is more convenient when you don't have any name overloading
in the class.  Look at the `if' block following the first call to
_Jv_FindSymbolInExecutable in _Jv_LookupJNIMethod, or see
mangled_name().

Ranjit> +			    tree_cons (NULL_TREE, ptr_type_node,
Ranjit> +			               tree_cons (NULL_TREE,

This still needs to be int_type_node.

Ranjit> +      args_size += int_size_in_bytes (TREE_TYPE(tem));

Space before `('.  There are a few of these.

Also, your patch wrapped around.  Could you turn off line wrapping?
Or attach the patch in some way so it doesn't wrap?

Otherwise this is looking pretty good to me.  Andrew or Per will have
to approve the gcc/java bits though.

Tom



More information about the Java mailing list