swt controlexample

Erik Poupaert erik.poupaert@chello.be
Fri Jan 3 20:42:00 GMT 2003


Jeff Sturm wrote:
>>>> I'm wondering if it would be easier to use JNIRegisterNatives and avoid
>>>> the whole libltdl mess, at least when compliling to a single image
(.exe)
>>>> without any dependence on external libraries.

I've grepped the gcc sourcetree, and there seems no way to invoke
RegisterNatives() from java. It seems like a purely native method:
gcc/libjava/include/jni.h:633: jint (JNICALL *RegisterNatives)
(JNIEnv *, jclass,
gcc/libjava/include/jni.h:1505: jint RegisterNatives (jclass cl0, const
JNINativeMethod * val1, jint val2)
gcc/libjava/include/jni.h:1506: { return p->RegisterNatives (this, cl0,
val1, val2); }
gcc/libjava/jni.cc:1830:(JNICALL _Jv_JNI_RegisterNatives) (JNIEnv *env,
jclass klass,
gcc/libjava/jni.cc:2655: _Jv_JNI_RegisterNatives, //
RegisterNatives
Maybe we could expose the method somewhere, as to make it available in java?
Ranjit Mathew wrote:
>>>> This is getting interesting - I tried my hand at it and have
>>>> some positive results to show you - I was able to compile the
>>>> SWT native sources from SWT 2.0.52 (Eclipse 2.0.2) using
>>>> MinGW itself!

What are the chances of the minGW people adding these missing symbols get to
"w32api" in a (hopefully not too) distant future? If they then get added,
will these additions break our patched win32/commctrl.h and swt/structs.h?
I wouldn't like to reverse or move your patches in the future ...
By the way, I've just finished compiling under gcj/mingw the swt
"controlexample" into one fully self-contained executable. Controlexample is
a nifty GUI that nicely demonstrates the SWT capabilities:
 [exec] Ultimate Packer for eXecutables
 [exec] Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
 [exec] UPX 1.24w Markus F.X.J. Oberhumer & Laszlo Molnar
Nov 7th 2002
 [exec] File size Ratio Format Name
 [exec] -------------------- ------ ----------- -----------
 [exec] 4963328 -> 1110016 22.36% win32/pe
controlexample.exe
 [exec] Packed 1 file.
It's only slightly bigger than the example distributed with Excelsior Jet
(with some major upx cheating). Excelsior Jet is a native (but proprietary)
compiler, a bit similar to gcj.
Controlexample.exe is a fully self-contained, zero-install, "click and go"
executable. No need to drag around the jni-dll or anything else. By the way,
maybe we could also distribute the pre-compiled swt examples on the GCJ
site. These examples seem to be a convincing sales argument.
(http://www.excelsior-usa.com/jetswt.html).
I think the entire sales pitch of excelsior jet applies fully to gcj:
"""
Who should use [GCJ]?
http://www.excelsior-usa.com/jetfaq.html
* Improvement of application performance in comparison with the latest VMs
* Improvement of application scalability (e.g. handling more simultaneous
connections on the same hardware) in comparison with the latest VMs
* Application memory footprint reduction
* Application startup time reduction
* Protection of applications against reverse engineering [duh...]
* Application disk footprint/download size reduction ([GCJ] only makes this
possible for applications not using AWT or Swing at the moment.)
* Easy Windows-style application deployment
* Transformation of Java applications into conventional Windows EXE and DLLs
(typical requirement in Microsoft-only shops)
"""
GCJ clearly fits the bill! We even have the same examples to prove it :)
A last remark, compiling the example required another strange patch to SWT,
to org.eclipse.internal.image.FileFormat:
I had to replace:
//X				Class clazz = Class.forName(FORMAT_PACKAGE + '.' + FORMATS[i] +
FORMAT_SUFFIX);
//X				fileFormat = (FileFormat) clazz.newInstance();
with the more mundane:
				if(format.compareTo("GIF")==0)
				{
					fileFormat=new GIFFileFormat();
				}
				else if(format.compareTo("JPEG")==0)
				{
					fileFormat=new JPEGFileFormat();
				}
				else if(format.compareTo("PNG")==0)
				{
					fileFormat=new PNGFileFormat();
				}
				else if(format.compareTo("WinBMP")==0)
				{
					fileFormat=new WinBMPFileFormat();
				}
				else if(format.compareTo("WinICO")==0)
				{
					fileFormat=new WinICOFileFormat();
				}
Does anybody know why?


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /