Bug 51403 - Ant in Eclipse breaks after upgrading to Java 1.4.2
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUIModelMessages.properties b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUIModelMessages.properties
index aa13cbb..b556eb8 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUIModelMessages.properties
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUIModelMessages.properties
@@ -15,3 +15,4 @@
 AntUtil.7=Unable to generate Ant classpath
 AntUtil.0=Editor failed to open for {0}
 AntUtil.1=External Browser could not be opened
+AntUtil.2=Error reading launch configuration
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUtil.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUtil.java
index 054a96d..b02ba7a 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUtil.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUtil.java
@@ -692,4 +692,16 @@
     		}
     	});
 	}
+    
+    public static boolean isSeparateJREAntBuild(ILaunchConfiguration configuration) {
+    	boolean separateJRE= true;
+		try {
+			//always null for same JRE
+			separateJRE = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, (String)null) != null;
+		} catch (CoreException e) {
+			AntUIPlugin.log(AntUIModelMessages.getString("AntUtil.2"), e); //$NON-NLS-1$
+		}
+    	
+		return separateJRE;
+    }
 }
\ No newline at end of file
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/IAntUIConstants.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/IAntUIConstants.java
index 28b7f5f..8e27861 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/IAntUIConstants.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/IAntUIConstants.java
@@ -117,4 +117,12 @@
 	 * Default value is <code>true</code>.
 	 */
 	public static final String SET_INPUTHANDLER= PLUGIN_ID + "SET_INPUTHANDLER"; //$NON-NLS-1$
+	
+	/**
+	 * Boolean attribute indicating if the default VM install should be used for the separate JRE build
+	 * Default value is <code>false</code> for backwards compatibility
+	 * 
+	 * @since 3.1
+	 */
+	public static final String ATTR_DEFAULT_VM_INSTALL= PLUGIN_ID + ".DEFAULT_VM_INSTALL"; //$NON-NLS-1$
 }
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntEnvironmentTab.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntEnvironmentTab.java
index d7b9851..7e5087d 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntEnvironmentTab.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntEnvironmentTab.java
@@ -10,10 +10,9 @@
  *******************************************************************************/
 package org.eclipse.ant.internal.ui.launchConfigurations;
 
-import org.eclipse.core.runtime.CoreException;
+import org.eclipse.ant.internal.ui.AntUtil;
 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
 import org.eclipse.debug.ui.EnvironmentTab;
-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
 import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Color;
@@ -61,23 +60,16 @@
 		if (wrappingComposite == null) {
 			return;
 		}
-		String vmName= null;
-		try {
-			vmName= workingCopy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME, (String) null);
-		} catch (CoreException e) {
-		}
-		boolean enabled= true;
-		if (vmName == null) {
-			enabled= false;			
-		}
-		Color tableColor= enabled ? null : Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
-		Color labelColor= enabled ? null : Display.getDefault().getSystemColor(SWT.COLOR_RED);
+		boolean isSeparateJREBuild= AntUtil.isSeparateJREAntBuild(workingCopy);
+		
+		Color tableColor= isSeparateJREBuild ? null : Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
+		Color labelColor= isSeparateJREBuild ? null : Display.getDefault().getSystemColor(SWT.COLOR_RED);
 		Table table = environmentTable.getTable();
-		table.setEnabled(enabled);
+		table.setEnabled(isSeparateJREBuild);
 		table.setBackground(tableColor);
 		warningLabel.setForeground(labelColor);
-		envAddButton.setEnabled(enabled);
-		envSelectButton.setEnabled(enabled);
+		envAddButton.setEnabled(isSeparateJREBuild);
+		envSelectButton.setEnabled(isSeparateJREBuild);
 		updateAppendReplace();
 		//update the enabled state of the edit and remove buttons
 		environmentTable.setSelection(environmentTable.getSelection());
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntJRETab.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntJRETab.java
index 5bbb4fe..1bc3c75 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntJRETab.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntJRETab.java
@@ -11,6 +11,7 @@
 
 package org.eclipse.ant.internal.ui.launchConfigurations;
 
+import org.eclipse.ant.internal.ui.AntUIPlugin;
 import org.eclipse.ant.internal.ui.IAntUIConstants;
 import org.eclipse.ant.internal.ui.IAntUIHelpContextIds;
 import org.eclipse.core.runtime.CoreException;
@@ -33,8 +34,8 @@
 
 	private static final String MAIN_TYPE_NAME= "org.eclipse.ant.internal.ui.antsupport.InternalAntRunner"; //$NON-NLS-1$
 	
-	protected VMArgumentsBlock fVMArgumentsBlock=  new VMArgumentsBlock();
-	protected AntWorkingDirectoryBlock fWorkingDirectoryBlock= new AntWorkingDirectoryBlock();
+	private VMArgumentsBlock fVMArgumentsBlock=  new VMArgumentsBlock();
+	private AntWorkingDirectoryBlock fWorkingDirectoryBlock= new AntWorkingDirectoryBlock();
 
 	/* (non-Javadoc)
 	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
@@ -91,9 +92,17 @@
 			configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME, (String)null);
 			configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, (String)null);
 			configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, (String)null);
-			configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String)null);			
+			configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String)null);
+			configuration.setAttribute(IAntUIConstants.ATTR_DEFAULT_VM_INSTALL, false);
 		} else {
 			super.performApply(configuration);
+			
+			if (useDefaultSeparateJRE(configuration)) {
+				configuration.setAttribute(IAntUIConstants.ATTR_DEFAULT_VM_INSTALL, true);
+			} else {
+				configuration.setAttribute(IAntUIConstants.ATTR_DEFAULT_VM_INSTALL, false);
+			}
+			
 			applySeparateVMAttributes(configuration);
 			fVMArgumentsBlock.performApply(configuration);
 			fWorkingDirectoryBlock.performApply(configuration);
@@ -101,6 +110,28 @@
 		setLaunchConfigurationWorkingCopy(configuration);
 	}
 	
+	private boolean useDefaultSeparateJRE(ILaunchConfigurationWorkingCopy configuration) {
+		boolean deflt= false;
+		String vmInstallType= null;
+		try {
+			vmInstallType= configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, (String)null);
+		} catch (CoreException e) {
+		}
+		if (vmInstallType != null) {
+			configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, (String)null);
+		}
+		IVMInstall defaultVMInstall= getDefaultVMInstall(configuration);
+		if (defaultVMInstall != null) {
+			IVMInstall vm= fJREBlock.getJRE();
+			deflt= defaultVMInstall.equals(vm);
+		}
+		
+		if (vmInstallType != null) {
+			configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, vmInstallType);
+		}
+		return deflt;
+	}
+	
 	private void applySeparateVMAttributes(ILaunchConfigurationWorkingCopy configuration) {
 		configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, MAIN_TYPE_NAME);
 		configuration.setAttribute(DebugPlugin.ATTR_PROCESS_FACTORY_ID, IAntUIConstants.REMOTE_ANT_PROCESS_FACTORY_ID);
@@ -110,6 +141,22 @@
 	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
 	 */
 	public void initializeFrom(ILaunchConfiguration configuration) {
+		try {
+			 boolean isDefaultVMInstall= configuration.getAttribute(IAntUIConstants.ATTR_DEFAULT_VM_INSTALL, false);
+			 if (isDefaultVMInstall) {
+			 	IVMInstall defaultVMInstall= getDefaultVMInstall(configuration);
+			 	ILaunchConfigurationWorkingCopy copy;
+			 	if (configuration instanceof ILaunchConfigurationWorkingCopy) {
+			 		copy= (ILaunchConfigurationWorkingCopy) configuration;
+			 	} else {
+			 		copy= configuration.getWorkingCopy();
+			 	}
+			 	//update if required
+				setDefaultVMInstallAttributes(defaultVMInstall, copy);
+			 }
+        } catch (CoreException ce) {
+        	AntUIPlugin.log(ce);
+        }
 		super.initializeFrom(configuration);
 		fVMArgumentsBlock.initializeFrom(configuration);
 		fWorkingDirectoryBlock.initializeFrom(configuration);
@@ -168,22 +215,32 @@
 	 */
 	public void setDefaults(ILaunchConfigurationWorkingCopy config) {
 		super.setDefaults(config);
-		//by default set an Ant build to occur in a separate VM
-		IVMInstall defaultInstall= null;
+		IVMInstall defaultVMInstall= getDefaultVMInstall(config);
+		if (defaultVMInstall != null) {
+			config.setAttribute(IAntUIConstants.ATTR_DEFAULT_VM_INSTALL, true);
+			setDefaultVMInstallAttributes(defaultVMInstall, config);
+			applySeparateVMAttributes(config);
+		} 
+	}
+
+	private IVMInstall getDefaultVMInstall(ILaunchConfiguration config) {
+		IVMInstall defaultVMInstall;
 		try {
-			defaultInstall = JavaRuntime.computeVMInstall(config);
+			defaultVMInstall = JavaRuntime.computeVMInstall(config);
 		} catch (CoreException e) {
 			//core exception thrown for non-Java project
-			defaultInstall= JavaRuntime.getDefaultVMInstall();
+			defaultVMInstall= JavaRuntime.getDefaultVMInstall();
 		}
-		if (defaultInstall != null) {
-			String vmName = defaultInstall.getName();
-			String vmTypeID = defaultInstall.getVMInstallType().getId();					
-			config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME, vmName);
-			config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, vmTypeID);
-			applySeparateVMAttributes(config);
-		}
+		return defaultVMInstall;
 	}
+
+	private void setDefaultVMInstallAttributes(IVMInstall defaultVMInstall, ILaunchConfigurationWorkingCopy config) {
+		String vmName = defaultVMInstall.getName();
+		String vmTypeID = defaultVMInstall.getVMInstallType().getId();
+		config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME, vmName);
+		config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, vmTypeID);
+	}
+	
 	/* (non-Javadoc)
 	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#deactivated(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
 	 */
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchDelegate.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchDelegate.java
index 386b940..083f5e9 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchDelegate.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchDelegate.java
@@ -54,6 +54,8 @@
 import org.eclipse.debug.ui.IDebugUIConstants;
 import org.eclipse.debug.ui.RefreshTab;
 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.JavaRuntime;
 import org.eclipse.jdt.launching.SocketUtil;
 import org.eclipse.jface.dialogs.MessageDialogWithToggle;
 import org.eclipse.jface.preference.IPreferenceStore;
@@ -92,13 +94,7 @@
 		// migrate the config to the new classpath format if required
 		AntUtil.migrateToNewClasspathFormat(configuration);
 		
-		String vmTypeID= null;
-		try {
-			//check if set to run in a separate VM
-			vmTypeID = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, (String)null);
-		} catch (CoreException ce) {
-			AntUIPlugin.log(ce);			
-		}
+		boolean isSeparateJRE= AntUtil.isSeparateJREAntBuild(configuration);
 		
 		if (CommonTab.isLaunchInBackground(configuration)) {
 			monitor.beginTask(MessageFormat.format(AntLaunchConfigurationMessages.getString("AntLaunchDelegate.Launching_{0}_1"), new String[] {configuration.getName()}), 10); //$NON-NLS-1$
@@ -114,7 +110,7 @@
 			return;
 		}
 		
-		if (vmTypeID == null && AntRunner.isBuildRunning()) {
+		if (!isSeparateJRE && AntRunner.isBuildRunning()) {
 			IStatus status= new Status(IStatus.ERROR, IAntUIConstants.PLUGIN_ID, 1, MessageFormat.format(AntLaunchConfigurationMessages.getString("AntLaunchDelegate.Build_In_Progress"), new String[]{location.toOSString()}), null); //$NON-NLS-1$
 			throw new CoreException(status);
 		}		
@@ -160,7 +156,7 @@
 		}
 		
 		AntRunner runner= null;
-		if (vmTypeID == null) {
+		if (!isSeparateJRE) {
 			runner = configureAntRunner(configuration, location, basedir, idProperty, arguments, userProperties, propertyFiles, targets, customClasspath, antHome, setInputHandler);
 		}
 		 
@@ -172,7 +168,7 @@
 		boolean captureOutput= ExternalToolsUtil.getCaptureOutput(configuration);
 		int port= -1;
 		int requestPort= -1;
-		if (vmTypeID != null && captureOutput) {
+		if (isSeparateJRE && captureOutput) {
 			if (userProperties == null) {
 				userProperties= new HashMap();
 			}
@@ -185,9 +181,9 @@
 			}
 		}
 		
-		StringBuffer commandLine= generateCommandLine(location, arguments, userProperties, propertyFiles, targets, antHome, basedir, vmTypeID != null, captureOutput, setInputHandler);
+		StringBuffer commandLine= generateCommandLine(location, arguments, userProperties, propertyFiles, targets, antHome, basedir, isSeparateJRE, captureOutput, setInputHandler);
 		
-		if (vmTypeID != null) {
+		if (isSeparateJRE) {
 			monitor.beginTask(MessageFormat.format(AntLaunchConfigurationMessages.getString("AntLaunchDelegate.Launching_{0}_1"), new String[] {configuration.getName()}), 10); //$NON-NLS-1$
 			runInSeparateVM(configuration, launch, monitor, idStamp, port, requestPort, commandLine, captureOutput, setInputHandler);
 		} else {
@@ -490,6 +486,10 @@
 		StringBuffer vmArgs= generateVMArguments(copy, setInputHandler);
 		copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArgs.toString());
         copy.setAttribute(IDebugUIConstants.ATTR_PRIVATE, true);
+        if (copy.getAttribute(IAntUIConstants.ATTR_DEFAULT_VM_INSTALL, false)) {
+        	setDefaultVM(configuration, copy);
+        }
+
 		//copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"); //$NON-NLS-1$
 		IProgressMonitor subMonitor= new SubProgressMonitor(monitor, 10);
 		AntJavaLaunchDelegate delegate= new AntJavaLaunchDelegate();
@@ -537,6 +537,20 @@
 			}
 		}
 	}
+
+	private void setDefaultVM(ILaunchConfiguration configuration, ILaunchConfigurationWorkingCopy copy) {
+		try {
+			JavaRuntime.getJavaProject(configuration);
+			//remove the vm name and install type for the Java launching concept of default VM
+			copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME, (String)null);
+			copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, (String)null);
+		} catch (CoreException ce) {
+			//not in a Java project
+			IVMInstall defaultVMInstall= JavaRuntime.getDefaultVMInstall();
+			copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME, defaultVMInstall.getName());
+			copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, defaultVMInstall.getVMInstallType().getId());
+		}
+	}
 	
 	private StringBuffer generateVMArguments(ILaunchConfiguration config, boolean setInputHandler) {
 		StringBuffer vmArgs= new StringBuffer();
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntPropertiesTab.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntPropertiesTab.java
index 1a95bd8..c19817f 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntPropertiesTab.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntPropertiesTab.java
@@ -13,7 +13,6 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-
 import org.eclipse.ant.core.AntCorePlugin;
 import org.eclipse.ant.core.AntCorePreferences;
 import org.eclipse.ant.core.Property;
@@ -29,7 +28,6 @@
 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
 import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
 import org.eclipse.debug.ui.ILaunchConfigurationTab;
-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
 import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
@@ -111,7 +109,7 @@
 	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
 	 */
 	public void initializeFrom(ILaunchConfiguration configuration) {
-        fSeparateJRE= isSeparateJRE(configuration);
+        fSeparateJRE= AntUtil.isSeparateJREAntBuild(configuration);
 		setErrorMessage(null);
 		setMessage(null);
 		Map properties= null;
@@ -154,16 +152,6 @@
         fAntPropertiesBlock.setTablesEnabled(false);
         fUseDefaultButton.setSelection(true);
     }
-
-    private boolean isSeparateJRE(ILaunchConfiguration configuration) {
-        boolean separateVM= true;
-        try {
-            separateVM= (null != configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, (String)null));
-        } catch (CoreException ce) {
-            AntUIPlugin.log(AntLaunchConfigurationMessages.getString("AntPropertiesTab.Error_reading_configuration_9"), ce); //$NON-NLS-1$
-        }
-        return separateVM;
-    }
 	
 	/**
 	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
@@ -254,7 +242,7 @@
 	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#activated(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
 	 */
 	public void activated(ILaunchConfigurationWorkingCopy workingCopy) {
-        if (fSeparateJRE != isSeparateJRE(workingCopy)) {
+        if (fSeparateJRE != AntUtil.isSeparateJREAntBuild(workingCopy)) {
             //update the properties if changed whether build is in separate JRE
             initializeFrom(workingCopy);
         }
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/ContributedClasspathEntriesEntry.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/ContributedClasspathEntriesEntry.java
index 72253bd..ec92f91 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/ContributedClasspathEntriesEntry.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/ContributedClasspathEntriesEntry.java
@@ -17,6 +17,7 @@
 import org.eclipse.ant.core.AntCorePlugin;
 import org.eclipse.ant.core.AntCorePreferences;
 import org.eclipse.ant.core.IAntClasspathEntry;
+import org.eclipse.ant.internal.ui.AntUtil;
 import org.eclipse.ant.internal.ui.IAntUIConstants;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
@@ -70,7 +71,7 @@
 	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getRuntimeClasspathEntries(org.eclipse.debug.core.ILaunchConfiguration)
 	 */
 	public IRuntimeClasspathEntry[] getRuntimeClasspathEntries(ILaunchConfiguration configuration) throws CoreException {
-		boolean separateVM= (null != configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, (String)null));
+		boolean separateVM= AntUtil.isSeparateJREAntBuild(configuration);
 		boolean setInputHandler= configuration.getAttribute(IAntUIConstants.SET_INPUTHANDLER, true);
 		AntCorePreferences prefs= AntCorePlugin.getPlugin().getPreferences();
 		IAntClasspathEntry[] antClasspathEntries = prefs.getContributedClasspathEntries();