1 11 package org.eclipse.jdt.internal.launching.macosx; 12 13 import java.io.IOException ; 14 import java.util.MissingResourceException ; 15 import java.util.ResourceBundle ; 16 17 import org.eclipse.core.runtime.Plugin; 18 import org.eclipse.jface.util.Assert; 19 20 21 public class MacOSXLaunchingPlugin extends Plugin { 22 23 private static MacOSXLaunchingPlugin fgPlugin; 24 private static final String RESOURCE_BUNDLE= "org.eclipse.jdt.internal.launching.macosx.MacOSXLauncherMessages"; private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE); 26 27 public MacOSXLaunchingPlugin() { 28 super(); 29 Assert.isTrue(fgPlugin == null); 30 fgPlugin= this; 31 } 32 33 public static MacOSXLaunchingPlugin getDefault() { 34 return fgPlugin; 35 } 36 37 static String getString(String key) { 38 try { 39 return fgResourceBundle.getString(key); 40 } catch (MissingResourceException e) { 41 return "!" + key + "!"; } 43 } 44 45 48 static String getUniqueIdentifier() { 49 if (getDefault() == null) { 50 return "org.eclipse.jdt.launching.macosx"; } 55 return getDefault().getBundle().getSymbolicName(); 56 } 57 58 static String [] wrap(Class clazz, String [] cmdLine) { 59 60 for (int i= 0; i < cmdLine.length; i++) { 61 if (useSWT(cmdLine[i])) 63 return createSWTlauncher(clazz, cmdLine, cmdLine[0]); 64 } 65 return cmdLine; 66 } 67 68 71 private static boolean useSWT(String arg) { 72 return arg.indexOf("swt.jar") >= 0 || arg.indexOf("org.eclipse.swt") >= 0 || "-ws".equals(arg); } 76 77 80 static String [] createSWTlauncher(Class clazz, String [] cmdLine, String vmVersion) { 81 82 String java_swt= System.getProperty("org.eclipse.swtlauncher"); 85 if (java_swt == null) { 86 String [] newCmdLine= new String [cmdLine.length+1]; 88 int argCount= 0; 89 newCmdLine[argCount++]= cmdLine[0]; 90 newCmdLine[argCount++]= "-XstartOnFirstThread"; for (int i= 1; i < cmdLine.length; i++) 92 newCmdLine[argCount++]= cmdLine[i]; 93 return newCmdLine; 94 } 95 96 try { 97 Process process= Runtime.getRuntime().exec(new String [] { "/bin/cp", java_swt, "/tmp" }); process.waitFor(); 100 java_swt= "/tmp/java_swt"; } catch (IOException e) { 102 } catch (InterruptedException e) { 104 } 106 107 String [] newCmdLine= new String [cmdLine.length+1]; 108 int argCount= 0; 109 newCmdLine[argCount++]= java_swt; 110 newCmdLine[argCount++]= "-XXvm=" + vmVersion; for (int i= 1; i < cmdLine.length; i++) 112 newCmdLine[argCount++]= cmdLine[i]; 113 114 return newCmdLine; 115 } 116 } 117 | Popular Tags |