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
private void setTimeout(VirtualMachine vm) {		
		if (vm instanceof org.eclipse.jdi.VirtualMachine) {
			int timeout= fVMInstance.getDebuggerTimeout();
			org.eclipse.jdi.VirtualMachine vm2= (org.eclipse.jdi.VirtualMachine)vm;
			vm2.setRequestTimeout(timeout);
		}
	}
		
	protected void specifyArguments(Map map, int portNumber, int timeout) {
		
		Connector.IntegerArgument port= (Connector.IntegerArgument) map.get("port"); 
		port.setValue(portNumber);
		
		Connector.IntegerArgument timeoutArg= (Connector.IntegerArgument) map.get("timeout"); 
		timeoutArg.setValue(timeout);
		
		
	}
	protected ListeningConnector getConnector() {
		List connectors= Bootstrap.virtualMachineManager().listeningConnectors();
		for (int i= 0; i < connectors.size(); i++) {
			ListeningConnector c= (ListeningConnector) connectors.get(i);
			if ("com.sun.jdi.SocketListen".equals(c.name())) 
				return c;
		}
		return null;
	}
}