handle missing Arch variable on 32-bit Mac
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 ecf1082..1c06357 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 @@
 	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 f46ad3d..c7c79a1 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 @@
 		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 6363a9c..3c2d3ee 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" />