In eclipse3.4, The SWT class provides the getplatform method to return to the operating system platform.
At first, I thought this method must have been obtained by calling the functions of the system platform or the native method.
With this idea. View the source code of SWT.
System. Out. println (SWT. getplatform (); // return to the system platform
Source code:
/**
* Returns the SWT platform name.
* Examples: "Win32", "motif", "GTK", "photon", "Carbon"
*
* @ Return the SWT platform name
*/
Public static string getplatform (){
Return platform. Platform;
}
Package org. Eclipse. SWT. Internal;
Public class platform {
Public static final string platform = "Win32 ";
}
The source code shows that it is not a system platform function or local method called. However, when the strings represented by the current platform are hard-coded (written to the dead ),
In the final state variable of platform. platform. The source code above is viewed in the wndows 32bit version.
At the same time, under Linux (Linux 32bit), I checked the Linux version of Eclipse.
It is found that the getplatform method in the SWT class is also hard-coded, as follows:
Public static string getplatform (){
Return "GTK ";
}
Users who often download and update eclipse know that eclipse officially provides three different versions of Eclipse, windows, Linux, and Mac, for users to download.
View the source code above. We can know that eclipse on different platforms has different jar libraries corresponding to SWT.
That is, to provide multiple platform versions (such as Windows and Linux) during RCP development, you must provide one, A Linux version is also provided (you need to use eclipse of Linux for packaging ).
At the same time, it should be clear that cross-platform is only a relative concept.