summaryrefslogtreecommitdiffstats
path: root/bundles
diff options
context:
space:
mode:
authorGrant Gayed <grant_gayed@ca.ibm.com>2012-02-24 15:42:13 -0500
committerGrant Gayed <grant_gayed@ca.ibm.com>2012-02-24 15:42:13 -0500
commitb8f3061fd5b7039b3594f18c6831d62d3275c9b5 (patch)
tree09850c7fc9e07e7bc5fcb75b01d6f241354eb7d6 /bundles
parente048abbf58389e1cccd6d9514c87591bba0083f6 (diff)
downloadeclipse.platform.swt-b8f3061fd5b7039b3594f18c6831d62d3275c9b5.tar.gz
eclipse.platform.swt-b8f3061fd5b7039b3594f18c6831d62d3275c9b5.tar.xz
eclipse.platform.swt-b8f3061fd5b7039b3594f18c6831d62d3275c9b5.zip
handle missing Arch variable on 32-bit Mac
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/common_j2me/org/eclipse/swt/internal/Library.java36
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/common_j2se/org/eclipse/swt/internal/Library.java13
-rw-r--r--bundles/org.eclipse.swt/buildFragment.xml9
3 files changed, 50 insertions, 8 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2me/org/eclipse/swt/internal/Library.java b/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2me/org/eclipse/swt/internal/Library.java
index ecf1082c9f..1c06357c14 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2me/org/eclipse/swt/internal/Library.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2me/org/eclipse/swt/internal/Library.java
@@ -10,6 +10,10 @@
*******************************************************************************/
package org.eclipse.swt.internal;
+import java.io.*;
+import java.net.*;
+import java.util.jar.*;
+
public class Library {
/* SWT Version - Mmmm (M=major, mmm=minor) */
@@ -83,6 +87,38 @@ public static int SWT_VERSION (int major, int minor) {
return major * 1000 + minor;
}
+static boolean isLoadable () {
+ URL url = Platform.class.getClassLoader ().getResource ("org/eclipse/swt/internal/Library.class"); //$NON-NLS-1$
+ if (!url.getProtocol ().equals ("jar")) { //$NON-NLS-1$
+ /* SWT is presumably running in a development environment */
+ return true;
+ }
+
+ try {
+ url = new URL (url.getPath ());
+ } catch (MalformedURLException e) {
+ /* should never happen since url's initial path value must be valid */
+ }
+ String path = url.getPath ();
+ int index = path.indexOf ('!');
+ File file = new File (path.substring (0, index));
+
+ Attributes attributes = null;
+ try {
+ JarFile jar = new JarFile (file);
+ attributes = jar.getManifest ().getMainAttributes ();
+ } catch (IOException e) {
+ /* should never happen for a valid SWT jar with the expected manifest values */
+ return false;
+ }
+
+ String os = System.getProperty ("os.name"); //$NON-NLS-1$;
+ String arch = System.getProperty ("os.arch"); //$NON-NLS-1$
+ String manifestOS = attributes.getValue ("SWT-OS"); //$NON-NLS-1$
+ String manifestArch = attributes.getValue ("SWT-Arch"); //$NON-NLS-1$
+ return arch.equals (manifestArch) && os.equals (manifestOS);
+}
+
/**
* Loads the shared library that matches the version of the
* Java code which is currently running. SWT shared libraries
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 f46ad3d27d..c7c79a115b 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
@@ -189,20 +189,21 @@ static boolean isLoadable () {
return false;
}
- String libraryOS = os ();
- String libraryArch = arch ();
+ String os = os ();
+ String arch = arch ();
String manifestOS = attributes.getValue ("SWT-OS"); //$NON-NLS-1$
String manifestArch = attributes.getValue ("SWT-Arch"); //$NON-NLS-1$
- if (libraryArch.equals (manifestArch) && libraryOS.equals (manifestOS)) {
+ if (arch.equals (manifestArch) && os.equals (manifestOS)) {
return true;
}
/*
* Mac has a special case since SWT's 32-bit libraries on Mac contain natives
- * for both the x86 and PPC architectures.
+ * for both the x86 and PPC architectures. For this reason SWT's manifest file
+ * for 32-bit Mac does not specify a value for SWT-Arch.
*/
- if (libraryOS.equals ("macosx") && libraryOS.equals (manifestOS)) {
- return manifestArch.equals ("x86") && libraryArch.equals ("ppc"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (os.equals ("macosx") && os.equals (manifestOS)) { //$NON-NLS-1$
+ return manifestArch.length () == 0 && (arch.equals ("ppc") || arch.equals ("x86")); //$NON-NLS-1$ //$NON-NLS-2$
}
return false;
}
diff --git a/bundles/org.eclipse.swt/buildFragment.xml b/bundles/org.eclipse.swt/buildFragment.xml
index 6363a9c71b..3c2d3ee793 100644
--- a/bundles/org.eclipse.swt/buildFragment.xml
+++ b/bundles/org.eclipse.swt/buildFragment.xml
@@ -491,10 +491,14 @@
<param name="debug" value="true" />
<param name="jar.filename" value="swt-debug.jar" />
</antcall>
+ <condition property="arch" value="${swt.arch}" else="">
+ <isset property="swt.arch"/>
+ </condition>
<jar jarfile="${build.result.folder}/swt-debug.jar" basedir="${fragmentdir}" update="true" includes="swt*.dll,libswt*.so,libswt*.sl,libswt*.a,libswt*.jnilib,libXm.so.2">
<manifest>
<attribute name="SWT-OS" value="${swt.os}"/>
- <attribute name="SWT-Arch" value="${swt.arch}"/>
+ <attribute name="SWT-WS" value="${swt.ws}"/>
+ <attribute name="SWT-Arch" value="${arch}"/>
</manifest>
</jar>
<copy file="${build.result.folder}/swt-debug.jar" todir="${temp.folder}/swtdownload" />
@@ -506,7 +510,8 @@
<jar jarfile="${build.result.folder}/swt.jar" basedir="${fragmentdir}" update="true" includes="swt*.dll,libswt*.so,libswt*.sl,libswt*.a,libswt*.jnilib,libXm.so.2">
<manifest>
<attribute name="SWT-OS" value="${swt.os}"/>
- <attribute name="SWT-Arch" value="${swt.arch}"/>
+ <attribute name="SWT-WS" value="${swt.ws}"/>
+ <attribute name="SWT-Arch" value="${arch}"/>
</manifest>
</jar>
<copy file="${build.result.folder}/swt.jar" todir="${temp.folder}/swtdownload" />