diff options
author | Grant Gayed | 2006-12-11 22:10:30 +0000 |
---|---|---|
committer | Grant Gayed | 2006-12-11 22:10:30 +0000 |
commit | faf8f241b3ea3cf8658bca53e40fd0817730fcad (patch) | |
tree | 954b69aafd8403a4deabf4751b5a230976e75c78 | |
parent | f596be6f2698a524e2eb59fbf7fa4dfc8e6e5e88 (diff) | |
download | eclipse.platform.swt-faf8f241b3ea3cf8658bca53e40fd0817730fcad.tar.gz eclipse.platform.swt-faf8f241b3ea3cf8658bca53e40fd0817730fcad.tar.xz eclipse.platform.swt-faf8f241b3ea3cf8658bca53e40fd0817730fcad.zip |
find libXm.so.2
3 files changed, 53 insertions, 37 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2se/org/eclipse/swt/internal/Library.java b/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2se/org/eclipse/swt/internal/Library.java index b9a921de16..ef6f2ea4dd 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2se/org/eclipse/swt/internal/Library.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2se/org/eclipse/swt/internal/Library.java @@ -148,58 +148,71 @@ static boolean load (String libName) { * @param name the name of the library to load */ public static void loadLibrary (String name) { - /* - * Include platform name to support different windowing systems - * on same operating system. - */ - String platform = Platform.PLATFORM; + loadLibrary (name, true); +} + +/** + * Loads the shared library that matches the version of the + * Java code which is currently running. SWT shared libraries + * follow an encoding scheme where the major, minor and revision + * numbers are embedded in the library name and this along with + * <code>name</code> is used to load the library. If this fails, + * <code>name</code> is used in another attempt to load the library, + * this time ignoring the SWT version encoding scheme. + * + * @param name the name of the library to load + * @param mapName true if the name should be mapped, false otherwise + */ +public static void loadLibrary (String name, boolean mapName) { - /* - * Get version qualifier. - */ - String version = System.getProperty ("swt.version"); //$NON-NLS-1$ - if (version == null) { - version = "" + MAJOR_VERSION; //$NON-NLS-1$ - /* Force 3 digits in minor version number */ - if (MINOR_VERSION < 10) { - version += "00"; //$NON-NLS-1$ - } else { - if (MINOR_VERSION < 100) version += "0"; //$NON-NLS-1$ + /* Compute the library name and mapped name */ + String libName1, libName2, mappedName1, mappedName2; + if (mapName) { + String version = System.getProperty ("swt.version"); //$NON-NLS-1$ + if (version == null) { + version = "" + MAJOR_VERSION; //$NON-NLS-1$ + /* Force 3 digits in minor version number */ + if (MINOR_VERSION < 10) { + version += "00"; //$NON-NLS-1$ + } else { + if (MINOR_VERSION < 100) version += "0"; //$NON-NLS-1$ + } + version += MINOR_VERSION; + /* No "r" until first revision */ + if (REVISION > 0) version += "r" + REVISION; //$NON-NLS-1$ } - version += MINOR_VERSION; - /* No "r" until first revision */ - if (REVISION > 0) version += "r" + REVISION; //$NON-NLS-1$ + libName1 = name + "-" + Platform.PLATFORM + "-" + version; //$NON-NLS-1$ //$NON-NLS-2$ + libName2 = name + "-" + Platform.PLATFORM; //$NON-NLS-1$ + mappedName1 = System.mapLibraryName (libName1); + mappedName2 = System.mapLibraryName (libName2); + } else { + libName1 = libName2 = mappedName1 = mappedName2 = name; } - String libName1 = name + "-" + platform + "-" + version; //$NON-NLS-1$ //$NON-NLS-2$ - String libName2 = name + "-" + platform; //$NON-NLS-1$ - String mappedName1 = System.mapLibraryName (libName1); - String mappedName2 = System.mapLibraryName (libName2); - /* Try loading library from swt library path */ String path = System.getProperty ("swt.library.path"); //$NON-NLS-1$ if (path != null) { path = new File (path).getAbsolutePath (); if (load (path + SEPARATOR + mappedName1)) return; - if (load (path + SEPARATOR + mappedName2)) return; + if (mapName && load (path + SEPARATOR + mappedName2)) return; } /* Try loading library from java library path */ if (load (libName1)) return; - if (load (libName2)) return; + if (mapName && load (libName2)) return; /* Try loading library from the tmp directory if swt library path is not specified */ if (path == null) { path = System.getProperty ("java.io.tmpdir"); //$NON-NLS-1$ path = new File (path).getAbsolutePath (); if (load (path + SEPARATOR + mappedName1)) return; - if (load (path + SEPARATOR + mappedName2)) return; + if (mapName && load (path + SEPARATOR + mappedName2)) return; } /* Try extracting and loading library from jar */ if (path != null) { if (extract (path + SEPARATOR + mappedName1, mappedName1)) return; - if (extract (path + SEPARATOR + mappedName2, mappedName2)) return; + if (mapName && extract (path + SEPARATOR + mappedName2, mappedName2)) return; } /* Failed to find the library */ diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/OS.java index 66ab97dca0..62155e6604 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/OS.java @@ -14,15 +14,8 @@ import org.eclipse.swt.internal.*; public class OS extends Platform { - static { - Library.loadLibrary ("swt"); - } - - /* OS and locale Constants*/ public static final boolean IsAIX, IsSunOS, IsLinux, IsHPUX; - public static final boolean IsDBLocale; static { - /* Initialize the OS flags and locale constants */ String osName = System.getProperty ("os.name"); boolean isAIX = false, isSunOS = false, isLinux = false, isHPUX = false; @@ -32,8 +25,17 @@ public class OS extends Platform { if (osName.equals ("SunOS")) isSunOS = true; if (osName.equals ("HP-UX")) isHPUX = true; IsAIX = isAIX; IsSunOS = isSunOS; IsLinux = isLinux; IsHPUX = isHPUX; - IsDBLocale = OS.MB_CUR_MAX () != 1; } + static { + if (OS.IsLinux) { + try { + Library.loadLibrary ("libXm.so.2", false); + } catch (UnsatisfiedLinkError ex) {} + } + Library.loadLibrary ("swt"); + } + + public static final boolean IsDBLocale = OS.MB_CUR_MAX () != 1; public static final int CODESET = CODESET (); public static final int LC_CTYPE = LC_CTYPE (); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/Callback.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/Callback.java index 145d49c2f5..6072367c62 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/Callback.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/Callback.java @@ -33,7 +33,8 @@ public class Callback { /* Load the SWT library */ static { - Library.loadLibrary ("swt"); //$NON-NLS-1$ + // OS must be initialized before Callback. +// Library.loadLibrary ("swt"); //$NON-NLS-1$ } static final int PTR_SIZEOF = PTR_sizeof(); |