This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[gui][patch] avoid type punning
- From: graydon hoare <graydon at redhat dot com>
- To: java-patches at gcc dot gnu dot org
- Date: Thu, 20 Jan 2005 01:44:02 -0500
- Subject: [gui][patch] avoid type punning
hi,
this patch corrects a type punning warning I introduced with my patch to
the GTK peers last night. I've committed it to java-gui-branch.
-graydon
2005-01-20 Graydon Hoare <graydon@redhat.com>
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c (env_union):
Use union to avoid type-punning warning.
--- jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c 18 Jan 2005 23:30:52 -0000 1.2.16.4
+++ jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c 20 Jan 2005 06:40:54 -0000
@@ -72,12 +72,18 @@
JavaVM *java_vm;
+union env_union
+{
+ void *void_env;
+ JNIEnv *jni_env;
+};
+
JNIEnv *
gdk_env()
{
- JNIEnv *tmp;
- g_assert((*java_vm)->GetEnv(java_vm, (void **)&tmp, JNI_VERSION_1_2) == JNI_OK);
- return tmp;
+ union env_union tmp;
+ g_assert((*java_vm)->GetEnv(java_vm, &tmp.void_env, JNI_VERSION_1_2) == JNI_OK);
+ return tmp.jni_env;
}