-
Notifications
You must be signed in to change notification settings - Fork 137
FAQ Is SWT platform specific?
If you are asking about the implementation of SWT, the answer is yes. In fact, the implementation of SWT is the only part of Eclipse that is platform specific. Several plug-ins have platform-specific add-ons, but they are largely optional. Ninety-nine percent of the task of porting Eclipse to a new platform consists of porting SWT to the new platform.
The SWT APIs, on the other hand, are largely platform independent. To be
more specific, all classes in the SWT packages not marked
internal are guaranteed to be binary compatible across all
platforms supported by SWT. Thus, if you write a Java application on
SWT, you can compile it into JARs on one platform to run on all
platforms supported by SWT without linkage errors. Thus, applications
built on SWT obey the general Java credo of �write once, run anywhere.�
The exceptions to this binary compatibility rule are packages whose
names end with the windowing system name. For example, the package
org.eclipse.swt.ole.win32
is implemented only on Win32 platforms.
Yet another angle on the platform-specific question is to ask whether the behavior of SWT is platform specific. You may have noticed the careful wording of the binary-compatibility promise, which guarantees only that you will have no linkage errors when changing to another platform. SWT does not promise consistent behavior across platforms. On each platform, SWT instead strives for behavior that is consistent with other applications on that platform. Thus, an SWT application on Windows should behave like other Windows apps, and the same SWT application on Motif should behave like other Motif apps. As most Java developers know, the goals of cross-platform consistency and platform integration are not always compatible. SWT attempts to meet both goals, but where these aims are mutually exclusive, it will opt for platform integration over cross-platform consistency.
Thus, although you don�t have to worry about recompiling your application for every platform you want to support, it is a good idea to test your application on several platforms. On some platforms, subtle bugs emerge that do not appear on others owing to the vagaries of the platform�s native widgets. In rare cases, this cross-platform brittleness needs to be worked around by tweaking your application code. The only reliable way to manage these subtle differences is to test early and test often on all platforms you are interested in supporting.
This FAQ was originally published in Official Eclipse 3.0 FAQs. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the Eclipse Public License v1.0.