[gui] GdkPixbufDecoder JNIEnv fix proposal (PR/16824)

Mark Wielaard mark@klomp.org
Wed Aug 11 11:10:00 GMT 2004


Hi,

On Sun, 2004-08-08 at 19:17, Thomas Fitzsimmons wrote:
> On Sun, 2004-08-08 at 11:30, Mark Wielaard wrote:
> > 2004-08-08  Mark Wielaard  <mark@klomp.org>
> > 
> >         * 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.
[ ... ]
> > 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.

Thanks. I added that workaround and committed to GNU Classpath CVS and
libgcj gui branchs as attached.

Cheers,

Mark
-------------- next part --------------
A non-text attachment was scrubbed...
Name: GdkPixbufDecoder.patch
Type: text/x-patch
Size: 4911 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20040811/bb066396/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20040811/bb066396/attachment.sig>


More information about the Java-patches mailing list