classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] Re: [gui] GdkPixbufDecoder JNIEnv fix proposal (PR/16824)


From: Thomas Fitzsimmons
Subject: [cp-patches] Re: [gui] GdkPixbufDecoder JNIEnv fix proposal (PR/16824)
Date: Sun, 08 Aug 2004 13:17:56 -0400

On Sun, 2004-08-08 at 11:30, Mark Wielaard wrote:
> Hi,
> 
> The following is a proposal to fix http://gcc.gnu.org/PR16824
> "GdkPixbufDecoder crashes with image loading programs"
> 
> I decided to make it standalone and not depend on any of the other gtk
> peer classes since it seems that it has to be useful even when no
> GtkToolkit has been initialized. So it adds a static local JavaVM
> reference to the file which is used in all funtions/callbacks that need
> to access a JNI environment.
> 
> 2004-08-08  Mark Wielaard  <address@hidden>
> 
>         * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c:
>         #include gdk.h, not gtk.h. #include jni.h, native_state.h, string.h
>         and stdlib.h, not gtkpeer.h.
>         (*vm): New static variable.
>         (areaPreparedID): Make static.
>         (areaUpdatedID): Likewise.
>         (area_prepared): Get and use JNIEnv through stored JavaVM *vm.
>         (area_prepared): Likewise.
>         (area_updated): Likewise.
>         (closed): Likewise.
>         (initStaticState): Initialize *vm javaVM.
>         (pumpBytes): Use given env, not global gdk_env.
> 
> With this the new Frame.setIcon() and the mauve test for
> gnu.testlet.java.awt.image.PixelGrabber.SimpleGrabber work much more
> reliable.
> 
> The only issue is that gcc 3+ complains loudly about the following:
> 
> ../../../../classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c:
>  In function `area_prepared':
> ../../../../classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c:86:
>  warning: dereferencing type-punned pointer will break strict-aliasing rules
> ../../../../classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c:
>  In function `area_updated':
> ../../../../classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c:124:
>  warning: dereferencing type-punned pointer will break strict-aliasing rules
> ../../../../classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c:
>  In function `closed':
> ../../../../classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c:167:
>  warning: dereferencing type-punned pointer will break strict-aliasing rules
> 
> Does anybody know what the correct way to solve this is?

Yes, I found an explanation of this warning here:

http://lists.freebsd.org/pipermail/freebsd-current/2003-July/007561.html

Type-punning using a union is explicitly allowed by C99.  For example,
see this patch to gthread-jni.c; it eliminates type-punned warnings on
64-bit architectures:

http://gcc.gnu.org/bugzilla/attachment.cgi?id=6843&action=view

> Any comments on the general idea of the patch?
> 

The general idea seems fine to me.

Tom






reply via email to

[Prev in Thread] Current Thread [Next in Thread]