Bug 5791 NPE in SocketUtil
Launch Eclipse using JDK 1.4 as JRE. From the launched eclispe, launch another program in debug mode, using JDK 1.4. This produces an NPE in SocketUtil: java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:277) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run (ProgressMonitorDialog.java:335) at org.eclipse.jdt.internal.ui.launcher.JavaApplicationLauncherDelegate.doLaunch (JavaApplicationLauncherDelegate.java:181) at org.eclipse.jdt.internal.ui.launcher.JavaApplicationLauncherDelegate.launchEleme nt(JavaApplicationLauncherDelegate.java:81) at org.eclipse.jdt.internal.ui.launcher.JavaApplicationLauncherDelegate.launch (JavaApplicationLauncherDelegate.java:93) at org.eclipse.debug.internal.core.Launcher.launch(Launcher.java:104) at org.eclipse.debug.internal.ui.RelaunchActionDelegate.relaunch (RelaunchActionDelegate.java:37) at org.eclipse.debug.internal.ui.RelaunchActionDelegate.relaunch (RelaunchActionDelegate.java:46) at org.eclipse.debug.internal.ui.RelaunchHistoryLaunchAction$1.run (RelaunchHistoryLaunchAction.java:49) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:56) at org.eclipse.debug.internal.ui.RelaunchHistoryLaunchAction.run (RelaunchHistoryLaunchAction.java:47) at org.eclipse.jface.action.Action.runWithEvent(Action.java:453) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:361) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:352) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:47) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:54) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:635) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1365) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1167) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:727) at org.eclipse.ui.internal.Workbench.run(Workbench.java:710) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at SlimLauncher.main(SlimLauncher.java:14) Caused by: java.lang.NullPointerException at java.net.Socket.<init>(Socket.java:285) at java.net.Socket.<init>(Socket.java:121) at org.eclipse.jdt.internal.ui.launcher.SocketUtil.findUnusedLocalPort (SocketUtil.java:21) at org.eclipse.jdt.internal.ui.launcher.JDK12DebugLauncher.run (JDK12DebugLauncher.java:60) at org.eclipse.jdt.internal.ui.launcher.JavaApplicationLauncherDelegate$1.run (JavaApplicationLauncherDelegate.java:170) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run (ModalContext.java:98)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/launcher/JDK12DebugLauncher.java
*/
	public VMRunnerResult run(VMRunnerConfiguration config) throws CoreException {
		int port= SocketUtil.findUnusedLocalPort(null, 5000, 15000);
		if (port == -1) {
			throw new CoreException(createStatus(LauncherMessages.getString("jdkLauncher.noPort"), null)); 
		}
		String location= getJDKLocation(""); 
		if ("".equals(location)) { 
			throw new CoreException(createStatus(LauncherMessages.getString("jdkLauncher.error.noJDKHome"), null)); 
		}
		String program= location+File.separator+"bin"+File.separator+"java"; 
		File javawexe= new File(program+"w.exe"); 
		File javaw= new File(program+"w"); 
		
		if (javaw.isFile()) 
			program= javaw.getAbsolutePath();
		else if (javawexe.isFile())
			program= javawexe.getAbsolutePath();
		Vector arguments= new Vector();
		arguments.addElement(program);
		String[] bootCP= config.getBootClassPath();
		if (bootCP.length > 0) {
			arguments.add("-Xbootclasspath:"+convertClassPath(bootCP)); 
		} 
		
		String[] cp= config.getClassPath();
		if (cp.length > 0) {
			arguments.add("-classpath"); 
			arguments.add(convertClassPath(cp));
		}