#include "jcf.h"
#include "tree.h"
+#include "version.h"
#include "javaop.h"
#include "java-tree.h"
#include "java-opcodes.h"
int length;
unsigned char *signature;
int sig_length;
+ int is_native;
struct method_name *next;
};
return 0;
}
-/* If there is already a method named NAME, whose signature is not
+/* Free the method name list. */
+static void
+free_method_name_list ()
+{
+ struct method_name *p = method_name_list;
+ while (p != NULL)
+ {
+ struct method_name *next = p->next;
+ free (p->name);
+ free (p->signature);
+ free (p);
+ p = next;
+ }
+ method_name_list = NULL;
+}
+
+/* If there is already a native method named NAME, whose signature is not
SIGNATURE, then return true. Otherwise return false. */
static int
overloaded_jni_method_exists_p (const unsigned char *name, int length,
for (p = method_name_list; p != NULL; p = p->next)
{
- if (p->length == length
+ if (p->is_native
+ && p->length == length
&& ! memcmp (p->name, name, length)
&& (p->sig_length != sig_length
|| memcmp (p->signature, signature, sig_length)))
fputs (" ", out);
if ((flags & ACC_STATIC))
- fputs ("static ", out);
-
- if ((flags & ACC_FINAL))
{
- if (current_field_value > 0)
+ fputs ("static ", out);
+
+ if ((flags & ACC_FINAL) && current_field_value > 0)
{
char buffer[25];
int done = 1;
nn->next = method_name_list;
nn->sig_length = JPOOL_UTF_LENGTH (jcf, sig_index);
nn->signature = xmalloc (nn->sig_length);
+ nn->is_native = METHOD_IS_NATIVE (flags);
memcpy (nn->signature, JPOOL_UTF_DATA (jcf, sig_index),
nn->sig_length);
method_name_list = nn;
(htab_del) free);
/* Make sure the root classes show up in the tables. */
- str = xstrdup ("java.lang.Throwable");
+ str = (unsigned char *) xstrdup ("java.lang.Throwable");
slot = htab_find_slot (throw_hash, str, INSERT);
*slot = str;
- str = xstrdup ("java.lang.Object");
+ str = (unsigned char *) xstrdup ("java.lang.Object");
slot = htab_find_slot (non_throw_hash, str, INSERT);
*slot = str;
void **slot;
unsigned char *super, *tmp;
int super_length = -1;
- const char *classfile_name = find_class (current, strlen (current),
+ const char *classfile_name = find_class ((char *) current, strlen ((const char *) current),
&jcf, 0);
if (! classfile_name)
if (flag_jni)
{
/* We know about certain types and special-case their names. */
- if (! strncmp (signature, "Ljava/lang/String;",
+ if (! strncmp ((const char *) signature, "Ljava/lang/String;",
sizeof ("Ljava/lang/String;") -1))
ctype = "jstring";
- else if (! strncmp (signature, "Ljava/lang/Class;",
+ else if (! strncmp ((const char *) signature, "Ljava/lang/Class;",
sizeof ("Ljava/lang/Class;") - 1))
ctype = "jclass";
/* Skip leading 'L' for throwable_p call. */
int sig_len = JPOOL_UTF_LENGTH (jcf, signature_index);
if (overloaded_jni_method_exists_p (JPOOL_UTF_DATA (jcf, name_index),
JPOOL_UTF_LENGTH (jcf, name_index),
- signature, sig_len))
+ (const char *) signature, sig_len))
{
/* If this method is overloaded by another native method,
then include the argument information in the mangled
return;
if (flag_jni && ! stubs)
- fputs ("extern JNIEXPORT ", stream);
+ fputs ("JNIEXPORT ", stream);
/* If printing a method, skip to the return signature and print
that first. However, there is no return value if this is a
return;
if (len == -1)
- len = strlen (utf8);
+ len = strlen ((const char *) utf8);
for (incl = all_includes; incl; incl = incl->next)
{
/* We check the length because we might have a proper prefix. */
if (len == (int) strlen (incl->name)
- && ! strncmp (incl->name, utf8, len))
+ && ! strncmp (incl->name, (const char *) utf8, len))
return;
}
incl = xmalloc (sizeof (struct include));
incl->name = xmalloc (len + 1);
- strncpy (incl->name, utf8, len);
+ strncpy (incl->name, (const char *) utf8, len);
incl->name[len] = '\0';
incl->next = all_includes;
all_includes = incl;
#define JAVAIO "java/io/"
#define JAVAUTIL "java/util/"
if ((name_limit - name >= (int) sizeof (JAVALANG) - 1
- && ! strncmp (name, JAVALANG, sizeof (JAVALANG) - 1))
+ && ! strncmp ((const char *) name, JAVALANG, sizeof (JAVALANG) - 1))
|| (name_limit - name >= (int) sizeof (JAVAUTIL) - 1
- && ! strncmp (name, JAVAUTIL, sizeof (JAVAUTIL) - 1))
+ && ! strncmp ((const char *) name, JAVAUTIL, sizeof (JAVAUTIL) - 1))
|| (name_limit - name >= (int) sizeof (JAVAIO) - 1
- && ! strncmp (name, JAVAIO, sizeof (JAVAIO) - 1)))
+ && ! strncmp ((const char *) name, JAVAIO, sizeof (JAVAIO) - 1)))
return;
}
{
/* We check the length because we might have a proper prefix. */
if ((int) strlen (np->name) == p - name &&
- ! strncmp (name, np->name, p - name))
+ ! strncmp ((const char *) name, np->name, p - name))
{
n = np;
break;
{
n = xmalloc (sizeof (struct namelet));
n->name = xmalloc (p - name + 1);
- strncpy (n->name, name, p - name);
+ strncpy (n->name, (const char *) name, p - name);
n->name[p - name] = '\0';
n->is_class = (p == name_limit);
n->subnamelets = NULL;
/* If we see an array, then we include the array header. */
if (s[i] == '[')
{
- print_include (out, "gcj/array", -1);
+ print_include (out, (const unsigned char *) "gcj/array", -1);
continue;
}
for (i = 0; i < len; ++i)
name[i] = jcf->classname[i] == '.' ? '/' : jcf->classname[i];
name[i] = '\0';
- print_include (out, name, len);
+ print_include (out, (const unsigned char *) name, len);
free (name);
if (! flag_jni)
{
- print_include (out, "gcj/cni", -1);
- print_include (out, "java/lang/UnsupportedOperationException",
+ print_include (out, (const unsigned char *) "gcj/cni", -1);
+ print_include (out, (const unsigned char *) "java/lang/UnsupportedOperationException",
-1);
}
}
}
}
}
+ free_method_name_list ();
process_file (&jcf, out);
JCF_FINISH (&jcf);
if (current_output_file != output_file)