Index: configure.ac =================================================================== RCS file: /cvsroot/classpath/classpath/configure.ac,v retrieving revision 1.36 diff -u -b -B -r1.36 configure.ac --- configure.ac 11 Jul 2004 13:04:29 -0000 1.36 +++ configure.ac 17 Jul 2004 07:10:16 -0000 @@ -432,7 +432,6 @@ native/cni/Makefile native/jni/Makefile native/jni/classpath/Makefile -native/jni/java-awt/Makefile native/jni/java-io/Makefile native/jni/java-lang/Makefile native/jni/java-net/Makefile Index: gnu/java/awt/EmbeddedWindow.java =================================================================== RCS file: /cvsroot/classpath/classpath/gnu/java/awt/EmbeddedWindow.java,v retrieving revision 1.2 diff -u -b -B -r1.2 EmbeddedWindow.java --- gnu/java/awt/EmbeddedWindow.java 1 Jul 2004 08:03:13 -0000 1.2 +++ gnu/java/awt/EmbeddedWindow.java 17 Jul 2004 07:10:16 -0000 @@ -40,23 +40,20 @@ import gnu.classpath.Configuration; import gnu.java.awt.peer.EmbeddedWindowPeer; + +import java.awt.Component; import java.awt.Frame; import java.awt.Toolkit; +import java.lang.reflect.Field; /** * Represents an AWT window that can be embedded into another * application. * - * @author Michael Koch + * @author Michael Koch (address@hidden) */ public class EmbeddedWindow extends Frame { - static - { - if (Configuration.INIT_LOAD_LIBRARY) - System.loadLibrary("javaawt"); - } - private long handle; /** @@ -93,13 +90,24 @@ throw new UnsupportedOperationException ("Embedded windows are not supported by the current peers: " + tk.getClass()); - setWindowPeer (((EmbeddedWindowSupport) tk).createEmbeddedWindow (this)); - super.addNotify(); + // Circumvent the package-privateness of the AWT internal + // java.awt.Component.peer member variable. + try + { + Field peerField = Component.class.getDeclaredField("peer"); + peerField.set(this, ((EmbeddedWindowSupport) tk).createEmbeddedWindow (this)); + } + catch (IllegalAccessException e) + { + // This should never happen. + } + catch (NoSuchFieldException e) + { + // This should never happen. } - // This method is only made native to circumvent the package-privateness of - // an AWT internal java.awt.Component.peer member variable. - native void setWindowPeer (EmbeddedWindowPeer peer); + super.addNotify(); + } /** * If the native peer for this embedded window has been created, Index: native/jni/Makefile.am =================================================================== RCS file: /cvsroot/classpath/classpath/native/jni/Makefile.am,v retrieving revision 1.9 diff -u -b -B -r1.9 Makefile.am --- native/jni/Makefile.am 12 Feb 2004 16:53:09 -0000 1.9 +++ native/jni/Makefile.am 17 Jul 2004 07:10:16 -0000 @@ -4,6 +4,6 @@ GTKDIR = gtk-peer endif -SUBDIRS = classpath java-awt java-io java-lang java-net java-nio java-util $(GTKDIR) -DIST_SUBDIRS = classpath java-awt java-io java-lang java-net java-nio java-util gtk-peer +SUBDIRS = classpath java-io java-lang java-net java-nio java-util $(GTKDIR) +DIST_SUBDIRS = classpath java-io java-lang java-net java-nio java-util gtk-peer Index: native/jni/java-awt/.cvsignore =================================================================== RCS file: native/jni/java-awt/.cvsignore diff -N native/jni/java-awt/.cvsignore --- native/jni/java-awt/.cvsignore 29 Mar 2004 07:07:27 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,2 +0,0 @@ -Makefile -Makefile.in Index: native/jni/java-awt/Makefile.am =================================================================== RCS file: native/jni/java-awt/Makefile.am diff -N native/jni/java-awt/Makefile.am --- native/jni/java-awt/Makefile.am 21 May 2004 07:25:43 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,6 +0,0 @@ -pkglib_LTLIBRARIES = libjavaawt.la - -libjavaawt_la_SOURCES = gnu_java_awt_EmbeddedWindow.c - -libjavaawt_la_LDFLAGS = @CLASSPATH_MODULE@ -libjavaawt_la_LIBADD = $(top_builddir)/native/jni/classpath/jcl.lo Index: native/jni/java-awt/gnu_java_awt_EmbeddedWindow.c =================================================================== RCS file: native/jni/java-awt/gnu_java_awt_EmbeddedWindow.c diff -N native/jni/java-awt/gnu_java_awt_EmbeddedWindow.c --- native/jni/java-awt/gnu_java_awt_EmbeddedWindow.c 29 Mar 2004 07:07:27 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,67 +0,0 @@ -/* EmbeddedWindow.c - - Copyright (C) 2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -#include -#include - -#include -#include - -#include "gnu_java_awt_EmbeddedWindow.h" - -#define AWT_EXCEPTION "java/awt/AWTException" - -JNIEXPORT void JNICALL -Java_gnu_java_awt_EmbeddedWindow_setWindowPeer (JNIEnv *env, jobject obj, jobject peer) -{ - jclass clazz; - jfieldID fid; - - if (!peer) { - clazz = (*env)->FindClass (env, "java.awt.Component"); - if (clazz == NULL) { - JCL_ThrowException (env, AWT_EXCEPTION, "gnu.java.awt.EmbbeddedWindow.setWindowPeer(): Error"); - } - - fid = (*env)->GetFieldID (env, clazz, "peer", "[java.awt.peer.ComponentPeer"); - if (fid == NULL) { - JCL_ThrowException (env, AWT_EXCEPTION, "gnu.java.awt.EmbbeddedWindow.setWindowPeer(): Error"); - } - - (*env)->SetObjectField (env, obj, fid, peer); - } -}