harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r451266 [2/2] - in /incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching: ./ src/org/apache/harmony/eclipse/jdt/launching/
Date Fri, 29 Sep 2006 12:45:09 GMT
Modified: incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyVMInstallType.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyVMInstallType.java?view=diff&rev=451266&r1=451265&r2=451266
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyVMInstallType.java (original)
+++ incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyVMInstallType.java Fri Sep 29 05:45:08 2006
@@ -1,470 +1,470 @@
-/* Copyright 2000, 2006 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.eclipse.jdt.launching;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jdt.launching.AbstractVMInstallType;
-import org.eclipse.jdt.launching.IVMInstall;
-import org.eclipse.jdt.launching.LibraryLocation;
-
-public class HyVMInstallType extends AbstractVMInstallType {
-
-	static final String LAUNCHER_HOME_TOKEN = "%LAUNCHER_HOME%"; //$NON-NLS-1$
-
-	public IVMInstall doCreateVMInstall(String id) {
-		return new HyVMInstall(this, id);
-	}
-
-	public String getName() {
-		return HyLauncherMessages.getString("HyVMType.name"); //$NON-NLS-1$
-	}
-
-	public IStatus validateInstallLocation(File installLocation) {
-		// Check we can find the launcher.
-		File java = new File(installLocation, "bin" + File.separator + "java"); //$NON-NLS-2$ //$NON-NLS-1$
-		File javaExe = new File(installLocation,
-				"bin" + File.separator + "java.exe"); //$NON-NLS-2$ //$NON-NLS-1$
-		if (!(java.isFile() || javaExe.isFile())) {
-			if (HyLaunchingPlugin.isDebuggingInstalling()) {
-				try {
-					System.out.println(HyLaunchingPlugin.getUniqueIdentifier()
-							+ "--> No Harmony launcher detected at location : " //$NON-NLS-1$
-							+ installLocation.getCanonicalPath());
-				} catch (IOException e) {
-					// Intentionally empty
-				}
-			}
-
-			return new Status(IStatus.ERROR, HyLaunchingPlugin
-					.getUniqueIdentifier(), 0, HyLauncherMessages
-					.getString("HyVMType.error.noLauncher"), null); //$NON-NLS-1$
-		}
-
-		// Check we can find the bootclasspath.properties file.
-		File bootPropsFile = new File(
-				installLocation,
-				"lib"	+ File.separator + "boot" + File.separator + "bootclasspath.properties"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-		if (!bootPropsFile.isFile()) {
-			return new Status(IStatus.ERROR, HyLaunchingPlugin
-					.getUniqueIdentifier(), 0, HyLauncherMessages
-					.getString("HyVMType.error.noBootProperties"), null); //$NON-NLS-1$
-		}
-
-		// Everything looks good.
-		return new Status(IStatus.OK, HyLaunchingPlugin.getUniqueIdentifier(),
-				0, "ok", null); //$NON-NLS-1$
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.jdt.launching.IVMInstallType#detectInstallLocation()
-	 */
-	public File detectInstallLocation() {
-		// Try to detect wether the current VM is a Harmony installation.
-		if (!"clear".equals(System.getProperty("com.ibm.oti.configuration", "missing"))) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-			return null;
-
-		File home = new File(System.getProperty("java.home")); //$NON-NLS-1$
-		IStatus status = validateInstallLocation(home);
-		if (status.isOK()) {
-			return home;
-		}
-		return null;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.jdt.launching.IVMInstallType#getDefaultLibraryLocations(java.io.File)
-	 */
-	public LibraryLocation[] getDefaultLibraryLocations(File installLocation) {
-
-		// Find kernel types
-		List kernelLibraries = getKernelLibraries(installLocation,
-				"default", "harmonyvm"); //$NON-NLS-1$ //$NON-NLS-2$
-		if (kernelLibraries == null) {
-			return new LibraryLocation[] {};
-		}
-
-		List bootLibraries = getBootLibraries(installLocation);
-		if (bootLibraries == null) {
-			return new LibraryLocation[] {};
-		}
-
-		// Find the extension class libraries
-		List extensions = getExtensionLibraries(installLocation);
-
-		// Combine the libraries result
-		LibraryLocation[] allLibraries = new LibraryLocation[kernelLibraries.size()
-				+ bootLibraries.size() + extensions.size()];
-		
-		int libraryCount = 0;
-
-		// Start with the kernel library locations
-		for (int i = 0; i < kernelLibraries.size(); i++) {
-			allLibraries[libraryCount++] = (LibraryLocation) kernelLibraries
-					.get(i);
-		}
-
-		// Append the boot libraries
-		for (int i = 0; i < bootLibraries.size(); i++) {
-			allLibraries[libraryCount++] = (LibraryLocation) bootLibraries
-					.get(i);
-		}
-
-		// Append the extensions libraries
-		for (int i = 0; i < extensions.size(); i++) {
-			allLibraries[libraryCount++] = (LibraryLocation) extensions.get(i);
-		}
-
-		// We are done
-		return allLibraries;
-	}
-
-	private List getBootLibraries(File installLocation) {
-		// The location of the bootclasspath libraries
-		File bootDirectory = new File(installLocation,
-				"lib" + File.separator + "boot"); //$NON-NLS-1$ //$NON-NLS-2$
-
-		// Load the bootclasspath properties file to figure out the required
-		// libraries
-		Properties bootclasspathProperties = new Properties();
-		try {
-			FileInputStream propertiesStream = new FileInputStream(new File(
-					bootDirectory, "bootclasspath.properties")); //$NON-NLS-1$
-			bootclasspathProperties.load(propertiesStream);
-			propertiesStream.close();
-		} catch (IOException exception) {
-			// Cannot find bootclasspath.properties file or cannot read it.
-			return null;
-		}
-
-		List bootOrder = findBootOrder(bootclasspathProperties, "bootclasspath.");
-		if (bootOrder == null) {
-			return null;
-		}
-
-		List bootLibraries = new ArrayList(bootOrder.size());
-
-		// Interpret the key values, in order, as library locations
-		for (Iterator bootOrderKeyItr = bootOrder.iterator(); bootOrderKeyItr
-				.hasNext();) {
-			String bootOrderKey = (String) bootOrderKeyItr.next();
-			// Here '14' is the offset past "bootclasspath."
-			String orderSuffix = bootOrderKey.substring(14);
-
-			// The library location first...
-			String bootLibraryLocation = bootclasspathProperties
-					.getProperty(bootOrderKey);
-			File libraryFile = new File(bootDirectory, bootLibraryLocation);
-			if (!libraryFile.exists()) {
-				// Ignore library descriptions for files that don't exist
-				continue;
-			}
-			IPath libraryPath;
-			try {
-				libraryPath = new Path(libraryFile.getCanonicalPath());
-			} catch (IOException exception1) {
-				// Ignore invalid path values.
-				continue;
-			}
-
-			// The source location can be deduced from the boot library name
-			String sourceLocationKey = "bootclasspath.source." + orderSuffix; //$NON-NLS-1$ 
-			String sourceLocation = bootclasspathProperties
-					.getProperty(sourceLocationKey);
-			IPath sourcePath;
-			if (sourceLocation == null) {
-				// source location was not specified
-				sourcePath = new Path(""); //$NON-NLS-1$
-			} else {
-				File sourceFile = new File(bootDirectory, sourceLocation);
-				if (!sourceFile.exists()) {
-					// If we cannot find the source jar, we default to missing token
-					sourcePath = new Path("");
-				} else {
-					try {
-						sourcePath = new Path(sourceFile.getCanonicalPath());
-					} catch (IOException exception1) {
-						// If we cannot find the source, we default to missing token
-						sourcePath = new Path(""); //$NON-NLS-1$
-					}
-				}
-			}
-
-			// The source package root is the offset in the jar where package
-			// names begin
-			String sourceRootKey = "bootclasspath.source.packageroot." + orderSuffix; //$NON-NLS-1$
-			// Default root location is "/"
-			String sourceRoot = bootclasspathProperties.getProperty(
-					sourceRootKey, "/"); //$NON-NLS-1$
-			IPath sourceRootPath = new Path(sourceRoot);
-
-			// We have everything we need to build up a library location
-			LibraryLocation libLocation = new LibraryLocation(libraryPath,
-					sourcePath, sourceRootPath);
-			bootLibraries.add(libLocation);
-		}
-		return bootLibraries;
-	}
-
-	private List findBootOrder(Properties bootclasspathProperties, final String propertyStartsWith) {
-
-		// Only keep keys that are propertyStartsWith."<something>"
-		Set allKeys = bootclasspathProperties.keySet();
-		Set bootKeys = new HashSet(allKeys.size());
-		for (Iterator iter = allKeys.iterator(); iter.hasNext();) {
-			String key = (String) iter.next();
-			if ((key.startsWith(propertyStartsWith) &&
-				(key.indexOf('.', propertyStartsWith.length()) == -1))) { // Ensure there are no more '.'s
-				bootKeys.add(key);
-			}
-		}
-		
-		// Now order the keys by their numerical postfix.
-		SortedSet bootOrder = new TreeSet(new Comparator() {
-			public int compare(Object object1, Object object2) {
-				// Use propertyStartsWith.length() to get the offset for the end of
-				// e.g. "bootclasspath."
-				String str1 = ((String) object1).substring(propertyStartsWith.length());
-				String str2 = ((String) object2).substring(propertyStartsWith.length());
-				
-				// Puts entries to the end, in any order, if they do not
-				// parse.
-				int first, second;
-				try {
-					first = Integer.parseInt(str1);
-				} catch (NumberFormatException exception) {
-					first = Integer.MAX_VALUE;
-				}
-				try {
-					second = Integer.parseInt(str2);
-				} catch (NumberFormatException exception1) {
-					second = Integer.MAX_VALUE;
-				}
-				if (first == second) {
-					return 0;
-				}
-				return (first < second) ? -1 : 1;
-			}
-		});
-		bootOrder.addAll(bootKeys);
-		return Arrays.asList(bootOrder.toArray(new String[bootOrder.size()]));
-	}
-
-	/**
-	 * Returns a list of default extension jars that should be placed on the
-	 * build path and runtime classpath, by default.
-	 * 
-	 * @param installLocation
-	 * @return List
-	 */
-	protected List getExtensionLibraries(File installLocation) {
-		File extDir = getDefaultExtensionDirectory(installLocation);
-		List extensions = new ArrayList();
-		if (extDir != null && extDir.exists() && extDir.isDirectory()) {
-			String[] names = extDir.list();
-			for (int i = 0; i < names.length; i++) {
-				String name = names[i];
-				File jar = new File(extDir, name);
-				if (jar.isFile()) {
-					int length = name.length();
-					if (length > 4) {
-						String suffix = name.substring(length - 4);
-						if (suffix.equalsIgnoreCase(".zip") || suffix.equalsIgnoreCase(".jar")) { //$NON-NLS-1$ //$NON-NLS-2$
-							try {
-								IPath libPath = new Path(jar.getCanonicalPath());
-								LibraryLocation library = new LibraryLocation(
-										libPath, Path.ROOT, Path.EMPTY);
-								extensions.add(library);
-							} catch (IOException e) {
-								// Ignored.
-							}
-						}
-					}
-				}
-			}
-		}
-		return extensions;
-	}
-
-	/**
-	 * Returns the default location of the extension directory, based on the
-	 * given install location. The resulting file may not exist, or be
-	 * <code>null</code> if an extension directory is not supported.
-	 * 
-	 * @param installLocation
-	 * @return default extension directory or <code>null</code>
-	 */
-	protected File getDefaultExtensionDirectory(File installLocation) {
-		File lib = new File(installLocation, "lib"); //$NON-NLS-1$
-		File ext = new File(lib, "ext"); //$NON-NLS-1$
-		return ext;
-	}
-
-	List getKernelLibraries(File installLocation, String vmdir,
-			String vmname) {
-		Properties kernelProperties = new Properties();
-		File kernelDirectory = new File(installLocation, "bin" + File.separator +
-				vmdir);
-		File propertyFile = new File(kernelDirectory, vmname + ".properties"); //$NON-NLS-1$
-				
-		try {
-			FileInputStream propsFile = new FileInputStream(propertyFile);
-			kernelProperties.load(propsFile);
-			propsFile.close();
-		} catch (IOException ex) {
-			System.out
-					.println("Warning: could not open properties file " + propertyFile.getPath()); //$NON-NLS-1$
-			return null;
-		}
-		
-		// If we have a VME v1 style kernel (ie single kernel) then read its location
-		if (kernelProperties.getProperty("bootclasspath.kernel") != null) {
-			List kernelLibraries = new ArrayList(1);
-					
-			String libStr = tokenReplace(installLocation, kernelProperties
-					.getProperty("bootclasspath.kernel")); //$NON-NLS-1$
-			IPath libraryPath = new Path(libStr);
-
-			String srcStr = tokenReplace(installLocation, kernelProperties
-					.getProperty("bootclasspath.source.kernel")); //$NON-NLS-1$
-			IPath sourcePath;
-			if (srcStr == null) {
-				sourcePath = Path.EMPTY;
-			} else {
-				File sourceFile = new File(srcStr);
-				if (!sourceFile.exists()) {
-					sourcePath = Path.EMPTY;
-				} else {
-					sourcePath = new Path(srcStr);
-				}
-			}
-
-			String rootStr = tokenReplace(installLocation, kernelProperties
-					.getProperty("bootclasspath.source.packageroot.kernel")); //$NON-NLS-1$
-			IPath sourceRootPath;
-			if (rootStr == null) {
-				sourceRootPath = Path.ROOT;
-			} else {
-				sourceRootPath = new Path(rootStr);
-			}
-			
-			// We have everything we need to build up a library location
-			LibraryLocation libLocation = new LibraryLocation(libraryPath,
-					sourcePath, sourceRootPath);
-			kernelLibraries.add(libLocation);
-
-			return kernelLibraries;
-		} // endif VME v1
-		
-		
-		// We have a VME v2 style split kernel (luni and security). Prepare to read in
-		// multiple kernel locations 
-		List bootOrder = findBootOrder(kernelProperties, "bootclasspath.kernel.");
-		if (bootOrder == null) {
-			return null;
-		}
-		
-		List kernelLibraries = new ArrayList(bootOrder.size());
-
-		// Interpret the key values, in order, as library locations
-		for (Iterator bootOrderKeyItr = bootOrder.iterator(); bootOrderKeyItr
-				.hasNext();) {
-			String bootOrderKey = (String) bootOrderKeyItr.next();
-			// Here '21' is the offset past "bootclasspath.kernel."
-			String orderSuffix = bootOrderKey.substring(21);
-			
-			String kernelLibraryLocation = tokenReplace(installLocation, kernelProperties
-					.getProperty(bootOrderKey)); //$NON-NLS-1$
-			File libraryFile = new File(kernelLibraryLocation);
-			if (!libraryFile.exists()) {
-				// Ignore library descriptions for files that don't exist
-				continue;
-			}
-			IPath libraryPath = new Path(kernelLibraryLocation);
-
-			String sourceLocation = tokenReplace(installLocation, kernelProperties
-					.getProperty("bootclasspath.kernel.source." + orderSuffix)); //$NON-NLS-1$
-			IPath sourcePath;
-			if (sourceLocation == null) {
-				sourcePath = Path.EMPTY;
-			} else {
-				File sourceFile = new File(sourceLocation);
-				if (!sourceFile.exists()) {
-					sourcePath = Path.EMPTY;
-				} else {
-					sourcePath = new Path(sourceLocation);
-				}
-			}
-
-			String rootStr = tokenReplace(installLocation, kernelProperties
-					.getProperty("bootclasspath.kernel.source.packageroot." + orderSuffix)); //$NON-NLS-1$
-			IPath sourceRootPath;
-			if (rootStr == null) {
-				sourceRootPath = Path.ROOT;
-			} else {
-				sourceRootPath = new Path(rootStr);
-			}
-			
-			// We have everything we need to build up a library location
-			LibraryLocation libLocation = new LibraryLocation(libraryPath,
-					sourcePath, sourceRootPath);
-			kernelLibraries.add(libLocation);
-			
-		}
-		return kernelLibraries;
-		
-	}
-
-	private String tokenReplace(File installLocation, String str) {
-		if (str == null) {
-			return null;
-		}
-		int index = str.indexOf(LAUNCHER_HOME_TOKEN);
-		if (index == -1) {
-			return str;
-		}
-		String realHome = installLocation.getPath();
-		StringBuffer buf = new StringBuffer(str.length() + realHome.length());
-		buf.append(str.substring(0, index));
-		buf.append(realHome);
-		buf.append(IPath.SEPARATOR);
-		buf.append("bin"); //$NON-NLS-1$
-		buf.append(IPath.SEPARATOR);
-		buf.append(str.substring(index + LAUNCHER_HOME_TOKEN.length(), str
-				.length()));
-		return buf.toString();
-	}
+/* Copyright 2000, 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.eclipse.jdt.launching;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.launching.AbstractVMInstallType;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.LibraryLocation;
+
+public class HyVMInstallType extends AbstractVMInstallType {
+
+	static final String LAUNCHER_HOME_TOKEN = "%LAUNCHER_HOME%"; //$NON-NLS-1$
+
+	public IVMInstall doCreateVMInstall(String id) {
+		return new HyVMInstall(this, id);
+	}
+
+	public String getName() {
+		return HyLauncherMessages.getString("HyVMType.name"); //$NON-NLS-1$
+	}
+
+	public IStatus validateInstallLocation(File installLocation) {
+		// Check we can find the launcher.
+		File java = new File(installLocation, "bin" + File.separator + "java"); //$NON-NLS-2$ //$NON-NLS-1$
+		File javaExe = new File(installLocation,
+				"bin" + File.separator + "java.exe"); //$NON-NLS-2$ //$NON-NLS-1$
+		if (!(java.isFile() || javaExe.isFile())) {
+			if (HyLaunchingPlugin.isDebuggingInstalling()) {
+				try {
+					System.out.println(HyLaunchingPlugin.getUniqueIdentifier()
+							+ "--> No Harmony launcher detected at location : " //$NON-NLS-1$
+							+ installLocation.getCanonicalPath());
+				} catch (IOException e) {
+					// Intentionally empty
+				}
+			}
+
+			return new Status(IStatus.ERROR, HyLaunchingPlugin
+					.getUniqueIdentifier(), 0, HyLauncherMessages
+					.getString("HyVMType.error.noLauncher"), null); //$NON-NLS-1$
+		}
+
+		// Check we can find the bootclasspath.properties file.
+		File bootPropsFile = new File(
+				installLocation,
+				"lib"	+ File.separator + "boot" + File.separator + "bootclasspath.properties"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+		if (!bootPropsFile.isFile()) {
+			return new Status(IStatus.ERROR, HyLaunchingPlugin
+					.getUniqueIdentifier(), 0, HyLauncherMessages
+					.getString("HyVMType.error.noBootProperties"), null); //$NON-NLS-1$
+		}
+
+		// Everything looks good.
+		return new Status(IStatus.OK, HyLaunchingPlugin.getUniqueIdentifier(),
+				0, "ok", null); //$NON-NLS-1$
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.jdt.launching.IVMInstallType#detectInstallLocation()
+	 */
+	public File detectInstallLocation() {
+		// Try to detect wether the current VM is a Harmony installation.
+		if (!"clear".equals(System.getProperty("com.ibm.oti.configuration", "missing"))) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			return null;
+
+		File home = new File(System.getProperty("java.home")); //$NON-NLS-1$
+		IStatus status = validateInstallLocation(home);
+		if (status.isOK()) {
+			return home;
+		}
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.jdt.launching.IVMInstallType#getDefaultLibraryLocations(java.io.File)
+	 */
+	public LibraryLocation[] getDefaultLibraryLocations(File installLocation) {
+
+		// Find kernel types
+		List kernelLibraries = getKernelLibraries(installLocation,
+				"default", "harmonyvm"); //$NON-NLS-1$ //$NON-NLS-2$
+		if (kernelLibraries == null) {
+			return new LibraryLocation[] {};
+		}
+
+		List bootLibraries = getBootLibraries(installLocation);
+		if (bootLibraries == null) {
+			return new LibraryLocation[] {};
+		}
+
+		// Find the extension class libraries
+		List extensions = getExtensionLibraries(installLocation);
+
+		// Combine the libraries result
+		LibraryLocation[] allLibraries = new LibraryLocation[kernelLibraries.size()
+				+ bootLibraries.size() + extensions.size()];
+		
+		int libraryCount = 0;
+
+		// Start with the kernel library locations
+		for (int i = 0; i < kernelLibraries.size(); i++) {
+			allLibraries[libraryCount++] = (LibraryLocation) kernelLibraries
+					.get(i);
+		}
+
+		// Append the boot libraries
+		for (int i = 0; i < bootLibraries.size(); i++) {
+			allLibraries[libraryCount++] = (LibraryLocation) bootLibraries
+					.get(i);
+		}
+
+		// Append the extensions libraries
+		for (int i = 0; i < extensions.size(); i++) {
+			allLibraries[libraryCount++] = (LibraryLocation) extensions.get(i);
+		}
+
+		// We are done
+		return allLibraries;
+	}
+
+	private List getBootLibraries(File installLocation) {
+		// The location of the bootclasspath libraries
+		File bootDirectory = new File(installLocation,
+				"lib" + File.separator + "boot"); //$NON-NLS-1$ //$NON-NLS-2$
+
+		// Load the bootclasspath properties file to figure out the required
+		// libraries
+		Properties bootclasspathProperties = new Properties();
+		try {
+			FileInputStream propertiesStream = new FileInputStream(new File(
+					bootDirectory, "bootclasspath.properties")); //$NON-NLS-1$
+			bootclasspathProperties.load(propertiesStream);
+			propertiesStream.close();
+		} catch (IOException exception) {
+			// Cannot find bootclasspath.properties file or cannot read it.
+			return null;
+		}
+
+		List bootOrder = findBootOrder(bootclasspathProperties, "bootclasspath.");
+		if (bootOrder == null) {
+			return null;
+		}
+
+		List bootLibraries = new ArrayList(bootOrder.size());
+
+		// Interpret the key values, in order, as library locations
+		for (Iterator bootOrderKeyItr = bootOrder.iterator(); bootOrderKeyItr
+				.hasNext();) {
+			String bootOrderKey = (String) bootOrderKeyItr.next();
+			// Here '14' is the offset past "bootclasspath."
+			String orderSuffix = bootOrderKey.substring(14);
+
+			// The library location first...
+			String bootLibraryLocation = bootclasspathProperties
+					.getProperty(bootOrderKey);
+			File libraryFile = new File(bootDirectory, bootLibraryLocation);
+			if (!libraryFile.exists()) {
+				// Ignore library descriptions for files that don't exist
+				continue;
+			}
+			IPath libraryPath;
+			try {
+				libraryPath = new Path(libraryFile.getCanonicalPath());
+			} catch (IOException exception1) {
+				// Ignore invalid path values.
+				continue;
+			}
+
+			// The source location can be deduced from the boot library name
+			String sourceLocationKey = "bootclasspath.source." + orderSuffix; //$NON-NLS-1$ 
+			String sourceLocation = bootclasspathProperties
+					.getProperty(sourceLocationKey);
+			IPath sourcePath;
+			if (sourceLocation == null) {
+				// source location was not specified
+				sourcePath = new Path(""); //$NON-NLS-1$
+			} else {
+				File sourceFile = new File(bootDirectory, sourceLocation);
+				if (!sourceFile.exists()) {
+					// If we cannot find the source jar, we default to missing token
+					sourcePath = new Path("");
+				} else {
+					try {
+						sourcePath = new Path(sourceFile.getCanonicalPath());
+					} catch (IOException exception1) {
+						// If we cannot find the source, we default to missing token
+						sourcePath = new Path(""); //$NON-NLS-1$
+					}
+				}
+			}
+
+			// The source package root is the offset in the jar where package
+			// names begin
+			String sourceRootKey = "bootclasspath.source.packageroot." + orderSuffix; //$NON-NLS-1$
+			// Default root location is "/"
+			String sourceRoot = bootclasspathProperties.getProperty(
+					sourceRootKey, "/"); //$NON-NLS-1$
+			IPath sourceRootPath = new Path(sourceRoot);
+
+			// We have everything we need to build up a library location
+			LibraryLocation libLocation = new LibraryLocation(libraryPath,
+					sourcePath, sourceRootPath);
+			bootLibraries.add(libLocation);
+		}
+		return bootLibraries;
+	}
+
+	private List findBootOrder(Properties bootclasspathProperties, final String propertyStartsWith) {
+
+		// Only keep keys that are propertyStartsWith."<something>"
+		Set allKeys = bootclasspathProperties.keySet();
+		Set bootKeys = new HashSet(allKeys.size());
+		for (Iterator iter = allKeys.iterator(); iter.hasNext();) {
+			String key = (String) iter.next();
+			if ((key.startsWith(propertyStartsWith) &&
+				(key.indexOf('.', propertyStartsWith.length()) == -1))) { // Ensure there are no more '.'s
+				bootKeys.add(key);
+			}
+		}
+		
+		// Now order the keys by their numerical postfix.
+		SortedSet bootOrder = new TreeSet(new Comparator() {
+			public int compare(Object object1, Object object2) {
+				// Use propertyStartsWith.length() to get the offset for the end of
+				// e.g. "bootclasspath."
+				String str1 = ((String) object1).substring(propertyStartsWith.length());
+				String str2 = ((String) object2).substring(propertyStartsWith.length());
+				
+				// Puts entries to the end, in any order, if they do not
+				// parse.
+				int first, second;
+				try {
+					first = Integer.parseInt(str1);
+				} catch (NumberFormatException exception) {
+					first = Integer.MAX_VALUE;
+				}
+				try {
+					second = Integer.parseInt(str2);
+				} catch (NumberFormatException exception1) {
+					second = Integer.MAX_VALUE;
+				}
+				if (first == second) {
+					return 0;
+				}
+				return (first < second) ? -1 : 1;
+			}
+		});
+		bootOrder.addAll(bootKeys);
+		return Arrays.asList(bootOrder.toArray(new String[bootOrder.size()]));
+	}
+
+	/**
+	 * Returns a list of default extension jars that should be placed on the
+	 * build path and runtime classpath, by default.
+	 * 
+	 * @param installLocation
+	 * @return List
+	 */
+	protected List getExtensionLibraries(File installLocation) {
+		File extDir = getDefaultExtensionDirectory(installLocation);
+		List extensions = new ArrayList();
+		if (extDir != null && extDir.exists() && extDir.isDirectory()) {
+			String[] names = extDir.list();
+			for (int i = 0; i < names.length; i++) {
+				String name = names[i];
+				File jar = new File(extDir, name);
+				if (jar.isFile()) {
+					int length = name.length();
+					if (length > 4) {
+						String suffix = name.substring(length - 4);
+						if (suffix.equalsIgnoreCase(".zip") || suffix.equalsIgnoreCase(".jar")) { //$NON-NLS-1$ //$NON-NLS-2$
+							try {
+								IPath libPath = new Path(jar.getCanonicalPath());
+								LibraryLocation library = new LibraryLocation(
+										libPath, Path.ROOT, Path.EMPTY);
+								extensions.add(library);
+							} catch (IOException e) {
+								// Ignored.
+							}
+						}
+					}
+				}
+			}
+		}
+		return extensions;
+	}
+
+	/**
+	 * Returns the default location of the extension directory, based on the
+	 * given install location. The resulting file may not exist, or be
+	 * <code>null</code> if an extension directory is not supported.
+	 * 
+	 * @param installLocation
+	 * @return default extension directory or <code>null</code>
+	 */
+	protected File getDefaultExtensionDirectory(File installLocation) {
+		File lib = new File(installLocation, "lib"); //$NON-NLS-1$
+		File ext = new File(lib, "ext"); //$NON-NLS-1$
+		return ext;
+	}
+
+	List getKernelLibraries(File installLocation, String vmdir,
+			String vmname) {
+		Properties kernelProperties = new Properties();
+		File kernelDirectory = new File(installLocation, "bin" + File.separator +
+				vmdir);
+		File propertyFile = new File(kernelDirectory, vmname + ".properties"); //$NON-NLS-1$
+				
+		try {
+			FileInputStream propsFile = new FileInputStream(propertyFile);
+			kernelProperties.load(propsFile);
+			propsFile.close();
+		} catch (IOException ex) {
+			System.out
+					.println("Warning: could not open properties file " + propertyFile.getPath()); //$NON-NLS-1$
+			return null;
+		}
+		
+		// If we have a VME v1 style kernel (ie single kernel) then read its location
+		if (kernelProperties.getProperty("bootclasspath.kernel") != null) {
+			List kernelLibraries = new ArrayList(1);
+					
+			String libStr = tokenReplace(installLocation, kernelProperties
+					.getProperty("bootclasspath.kernel")); //$NON-NLS-1$
+			IPath libraryPath = new Path(libStr);
+
+			String srcStr = tokenReplace(installLocation, kernelProperties
+					.getProperty("bootclasspath.source.kernel")); //$NON-NLS-1$
+			IPath sourcePath;
+			if (srcStr == null) {
+				sourcePath = Path.EMPTY;
+			} else {
+				File sourceFile = new File(srcStr);
+				if (!sourceFile.exists()) {
+					sourcePath = Path.EMPTY;
+				} else {
+					sourcePath = new Path(srcStr);
+				}
+			}
+
+			String rootStr = tokenReplace(installLocation, kernelProperties
+					.getProperty("bootclasspath.source.packageroot.kernel")); //$NON-NLS-1$
+			IPath sourceRootPath;
+			if (rootStr == null) {
+				sourceRootPath = Path.ROOT;
+			} else {
+				sourceRootPath = new Path(rootStr);
+			}
+			
+			// We have everything we need to build up a library location
+			LibraryLocation libLocation = new LibraryLocation(libraryPath,
+					sourcePath, sourceRootPath);
+			kernelLibraries.add(libLocation);
+
+			return kernelLibraries;
+		} // endif VME v1
+		
+		
+		// We have a VME v2 style split kernel (luni and security). Prepare to read in
+		// multiple kernel locations 
+		List bootOrder = findBootOrder(kernelProperties, "bootclasspath.kernel.");
+		if (bootOrder == null) {
+			return null;
+		}
+		
+		List kernelLibraries = new ArrayList(bootOrder.size());
+
+		// Interpret the key values, in order, as library locations
+		for (Iterator bootOrderKeyItr = bootOrder.iterator(); bootOrderKeyItr
+				.hasNext();) {
+			String bootOrderKey = (String) bootOrderKeyItr.next();
+			// Here '21' is the offset past "bootclasspath.kernel."
+			String orderSuffix = bootOrderKey.substring(21);
+			
+			String kernelLibraryLocation = tokenReplace(installLocation, kernelProperties
+					.getProperty(bootOrderKey)); //$NON-NLS-1$
+			File libraryFile = new File(kernelLibraryLocation);
+			if (!libraryFile.exists()) {
+				// Ignore library descriptions for files that don't exist
+				continue;
+			}
+			IPath libraryPath = new Path(kernelLibraryLocation);
+
+			String sourceLocation = tokenReplace(installLocation, kernelProperties
+					.getProperty("bootclasspath.kernel.source." + orderSuffix)); //$NON-NLS-1$
+			IPath sourcePath;
+			if (sourceLocation == null) {
+				sourcePath = Path.EMPTY;
+			} else {
+				File sourceFile = new File(sourceLocation);
+				if (!sourceFile.exists()) {
+					sourcePath = Path.EMPTY;
+				} else {
+					sourcePath = new Path(sourceLocation);
+				}
+			}
+
+			String rootStr = tokenReplace(installLocation, kernelProperties
+					.getProperty("bootclasspath.kernel.source.packageroot." + orderSuffix)); //$NON-NLS-1$
+			IPath sourceRootPath;
+			if (rootStr == null) {
+				sourceRootPath = Path.ROOT;
+			} else {
+				sourceRootPath = new Path(rootStr);
+			}
+			
+			// We have everything we need to build up a library location
+			LibraryLocation libLocation = new LibraryLocation(libraryPath,
+					sourcePath, sourceRootPath);
+			kernelLibraries.add(libLocation);
+			
+		}
+		return kernelLibraries;
+		
+	}
+
+	private String tokenReplace(File installLocation, String str) {
+		if (str == null) {
+			return null;
+		}
+		int index = str.indexOf(LAUNCHER_HOME_TOKEN);
+		if (index == -1) {
+			return str;
+		}
+		String realHome = installLocation.getPath();
+		StringBuffer buf = new StringBuffer(str.length() + realHome.length());
+		buf.append(str.substring(0, index));
+		buf.append(realHome);
+		buf.append(IPath.SEPARATOR);
+		buf.append("bin"); //$NON-NLS-1$
+		buf.append(IPath.SEPARATOR);
+		buf.append(str.substring(index + LAUNCHER_HOME_TOKEN.length(), str
+				.length()));
+		return buf.toString();
+	}
 }

Propchange: incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyVMInstallType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyVMRunner.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyVMRunner.java?view=diff&rev=451266&r1=451265&r2=451266
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyVMRunner.java (original)
+++ incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyVMRunner.java Fri Sep 29 05:45:08 2006
@@ -1,187 +1,187 @@
-/* Copyright 2000, 2005 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.eclipse.jdt.launching;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
-import org.eclipse.jdt.launching.IVMInstall;
-import org.eclipse.jdt.launching.VMRunnerConfiguration;
-
-public class HyVMRunner extends JavaVMRunner {
-	
-	public HyVMRunner(IVMInstall vmInstance) {
-		super(vmInstance);
-	}
-
-	/**
-	 * @see org.eclipse.jdt.launching.IVMRunner#run(VMRunnerConfiguration, ILaunch, IProgressMonitor)
-	 */
-	public void run(VMRunnerConfiguration config, ILaunch launch, IProgressMonitor monitor) throws CoreException {
-		
-		if (monitor == null) {
-			monitor = new NullProgressMonitor();
-		}
-		
-		// check for cancellation
-		if (monitor.isCanceled()) {
-			return;
-		}
-		
-		IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1);
-		subMonitor.beginTask(HyLauncherMessages.getString("HyVMRunner.Launching_virtual_machine..._1"), 2); //$NON-NLS-1$
-		subMonitor.subTask(HyLauncherMessages.getString("HyVMRunner.Constructing_command_line..._2"));	 //$NON-NLS-1$
-		
-		File workingDir = getWorkingDir(config);
-		String location= getJDKLocation();
-		String program = constructProgramString(location, config);
-		List arguments= new ArrayList();
-
-		arguments.add(program);
-		
-		addBootClassPathArguments(arguments, config);
-
-		String[] cp= config.getClassPath();
-		if (cp.length > 0) {
-			arguments.add("-classpath"); //$NON-NLS-1$
-			arguments.add(convertClassPath(cp));
-		}
-		String[] vmArgs= config.getVMArguments();
-		addArguments(vmArgs, arguments);
-		
-		arguments.add(config.getClassToLaunch());
-		
-		String[] programArgs= config.getProgramArguments();
-		addArguments(programArgs, arguments);
-				
-		String[] cmdLine= new String[arguments.size()];
-		arguments.toArray(cmdLine);
-		
-		String[] envp= config.getEnvironment();
-		
-		// check for cancellation
-		if (monitor.isCanceled()) {
-			return;
-		}
-		
-		subMonitor.worked(1);
-		subMonitor.subTask(HyLauncherMessages.getString("HyVMRunner.Starting_virtual_machine..._3")); //$NON-NLS-1$
-		
-		Process p= exec(cmdLine, workingDir, envp);
-		if (p != null) {
-			// Log the current launch command to the platform log
-			logLaunchCmd(cmdLine, false);
-			if (HyLaunchingPlugin.getDefault().isDebugging()
-					&& (Platform
-							.getDebugOption(HyLaunchingPlugin.DEBUG_LAUNCHING)
-							.equalsIgnoreCase("true"))) { //$NON-NLS-1$
-				traceLaunchCmd(cmdLine, envp, false);
-			}
-			
-			IProcess process= newProcess(launch, p, renderProcessLabel(cmdLine), getDefaultProcessMap());
-			process.setAttribute(IProcess.ATTR_CMDLINE, renderCommandLine(cmdLine));
-		}
-		subMonitor.worked(1);
-		subMonitor.done();
-	}
-
-	/**
-	 * Write the launch invocation string to the platform log.
-	 * 
-	 * @param cmdLine
-	 *            a <code>String</code> array whose elements contain the
-	 *            VM launch options.
-	 * @param debug
-	 *            set to <code>true</code> if the launch is being done in
-	 *            debug mode.
-	 */
-	protected void logLaunchCmd(String[] cmdLine, boolean debug) {
-		StringBuffer sBuff = new StringBuffer("Launching Harmony VM "); //$NON-NLS-1$
-		if (debug) {
-			sBuff.append("in debug mode "); //$NON-NLS-1$
-		}
-		sBuff.append(": "); //$NON-NLS-1$
-		sBuff.append(renderCommandLine(cmdLine));
-		HyLaunchingPlugin.getDefault().log(sBuff.toString());
-	}
-
-	/**
-	 * Write the launch invocation string to the debug console.
-	 * 
-	 * @param cmdLine
-	 *            a <code>String</code> array whose elements contain the
-	 *            VM launch options.
-	 * @param envp
-	 *            the launch environment
-	 * @param debug
-	 *            set to <code>true</code> if the launch is being done in
-	 *            debug mode.
-	 */
-	protected void traceLaunchCmd(String[] cmdLine, String[] envp, boolean debug) {
-		StringBuffer sBuff = new StringBuffer(HyLaunchingPlugin
-				.getUniqueIdentifier()
-				+ "--> Launching Harmony VM "); //$NON-NLS-1$
-		if (debug) {
-			sBuff.append("in debug mode "); //$NON-NLS-1$
-		}
-		sBuff.append(": "); //$NON-NLS-1$
-		sBuff.append(renderCommandLine(cmdLine));
-		sBuff.append("\n"); //$NON-NLS-1$
-		if (envp != null) {
-			sBuff.append("\t----Environment details begins----\n"); //$NON-NLS-1$
-			for (int i = 0; i < envp.length; i++) {
-				sBuff.append("\t\t"); //$NON-NLS-1$
-				sBuff.append(envp[i]);
-				sBuff.append("\n"); //$NON-NLS-1$
-			}// end for
-			sBuff.append("\t----Environment details ends------\n"); //$NON-NLS-1$
-		}// end if
-		System.out.println(sBuff);
-	}
-
-	protected String constructProgramString(String location, VMRunnerConfiguration config) {
-		String command= null;
-		Map map= config.getVMSpecificAttributesMap();
-		if (map != null) {
-			command= (String)map.get(IJavaLaunchConfigurationConstants.ATTR_JAVA_COMMAND);
-		}
-		
-		StringBuffer program= new StringBuffer();
-		program.append(location).append(File.separator).append("bin").append(File.separator); //$NON-NLS-1$
-		int directoryLength= program.length();
-		if (command == null) {
-			program.append("javaw.exe"); //$NON-NLS-1$
-			File javaw= new File(program.toString());
-			if (!javaw.exists()) {
-				program.replace(directoryLength, program.length(), "java"); //$NON-NLS-1$
-			}
-		} else {
-			program.append(command);
-		}
-		
-		return program.toString();
-	}
+/* Copyright 2000, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.eclipse.jdt.launching;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.VMRunnerConfiguration;
+
+public class HyVMRunner extends JavaVMRunner {
+	
+	public HyVMRunner(IVMInstall vmInstance) {
+		super(vmInstance);
+	}
+
+	/**
+	 * @see org.eclipse.jdt.launching.IVMRunner#run(VMRunnerConfiguration, ILaunch, IProgressMonitor)
+	 */
+	public void run(VMRunnerConfiguration config, ILaunch launch, IProgressMonitor monitor) throws CoreException {
+		
+		if (monitor == null) {
+			monitor = new NullProgressMonitor();
+		}
+		
+		// check for cancellation
+		if (monitor.isCanceled()) {
+			return;
+		}
+		
+		IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1);
+		subMonitor.beginTask(HyLauncherMessages.getString("HyVMRunner.Launching_virtual_machine..._1"), 2); //$NON-NLS-1$
+		subMonitor.subTask(HyLauncherMessages.getString("HyVMRunner.Constructing_command_line..._2"));	 //$NON-NLS-1$
+		
+		File workingDir = getWorkingDir(config);
+		String location= getJDKLocation();
+		String program = constructProgramString(location, config);
+		List arguments= new ArrayList();
+
+		arguments.add(program);
+		
+		addBootClassPathArguments(arguments, config);
+
+		String[] cp= config.getClassPath();
+		if (cp.length > 0) {
+			arguments.add("-classpath"); //$NON-NLS-1$
+			arguments.add(convertClassPath(cp));
+		}
+		String[] vmArgs= config.getVMArguments();
+		addArguments(vmArgs, arguments);
+		
+		arguments.add(config.getClassToLaunch());
+		
+		String[] programArgs= config.getProgramArguments();
+		addArguments(programArgs, arguments);
+				
+		String[] cmdLine= new String[arguments.size()];
+		arguments.toArray(cmdLine);
+		
+		String[] envp= config.getEnvironment();
+		
+		// check for cancellation
+		if (monitor.isCanceled()) {
+			return;
+		}
+		
+		subMonitor.worked(1);
+		subMonitor.subTask(HyLauncherMessages.getString("HyVMRunner.Starting_virtual_machine..._3")); //$NON-NLS-1$
+		
+		Process p= exec(cmdLine, workingDir, envp);
+		if (p != null) {
+			// Log the current launch command to the platform log
+			logLaunchCmd(cmdLine, false);
+			if (HyLaunchingPlugin.getDefault().isDebugging()
+					&& (Platform
+							.getDebugOption(HyLaunchingPlugin.DEBUG_LAUNCHING)
+							.equalsIgnoreCase("true"))) { //$NON-NLS-1$
+				traceLaunchCmd(cmdLine, envp, false);
+			}
+			
+			IProcess process= newProcess(launch, p, renderProcessLabel(cmdLine), getDefaultProcessMap());
+			process.setAttribute(IProcess.ATTR_CMDLINE, renderCommandLine(cmdLine));
+		}
+		subMonitor.worked(1);
+		subMonitor.done();
+	}
+
+	/**
+	 * Write the launch invocation string to the platform log.
+	 * 
+	 * @param cmdLine
+	 *            a <code>String</code> array whose elements contain the
+	 *            VM launch options.
+	 * @param debug
+	 *            set to <code>true</code> if the launch is being done in
+	 *            debug mode.
+	 */
+	protected void logLaunchCmd(String[] cmdLine, boolean debug) {
+		StringBuffer sBuff = new StringBuffer("Launching Harmony VM "); //$NON-NLS-1$
+		if (debug) {
+			sBuff.append("in debug mode "); //$NON-NLS-1$
+		}
+		sBuff.append(": "); //$NON-NLS-1$
+		sBuff.append(renderCommandLine(cmdLine));
+		HyLaunchingPlugin.getDefault().log(sBuff.toString());
+	}
+
+	/**
+	 * Write the launch invocation string to the debug console.
+	 * 
+	 * @param cmdLine
+	 *            a <code>String</code> array whose elements contain the
+	 *            VM launch options.
+	 * @param envp
+	 *            the launch environment
+	 * @param debug
+	 *            set to <code>true</code> if the launch is being done in
+	 *            debug mode.
+	 */
+	protected void traceLaunchCmd(String[] cmdLine, String[] envp, boolean debug) {
+		StringBuffer sBuff = new StringBuffer(HyLaunchingPlugin
+				.getUniqueIdentifier()
+				+ "--> Launching Harmony VM "); //$NON-NLS-1$
+		if (debug) {
+			sBuff.append("in debug mode "); //$NON-NLS-1$
+		}
+		sBuff.append(": "); //$NON-NLS-1$
+		sBuff.append(renderCommandLine(cmdLine));
+		sBuff.append("\n"); //$NON-NLS-1$
+		if (envp != null) {
+			sBuff.append("\t----Environment details begins----\n"); //$NON-NLS-1$
+			for (int i = 0; i < envp.length; i++) {
+				sBuff.append("\t\t"); //$NON-NLS-1$
+				sBuff.append(envp[i]);
+				sBuff.append("\n"); //$NON-NLS-1$
+			}// end for
+			sBuff.append("\t----Environment details ends------\n"); //$NON-NLS-1$
+		}// end if
+		System.out.println(sBuff);
+	}
+
+	protected String constructProgramString(String location, VMRunnerConfiguration config) {
+		String command= null;
+		Map map= config.getVMSpecificAttributesMap();
+		if (map != null) {
+			command= (String)map.get(IJavaLaunchConfigurationConstants.ATTR_JAVA_COMMAND);
+		}
+		
+		StringBuffer program= new StringBuffer();
+		program.append(location).append(File.separator).append("bin").append(File.separator); //$NON-NLS-1$
+		int directoryLength= program.length();
+		if (command == null) {
+			program.append("javaw.exe"); //$NON-NLS-1$
+			File javaw= new File(program.toString());
+			if (!javaw.exists()) {
+				program.replace(directoryLength, program.length(), "java"); //$NON-NLS-1$
+			}
+		} else {
+			program.append(command);
+		}
+		
+		return program.toString();
+	}
 }

Propchange: incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyVMRunner.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/JavaVMRunner.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/JavaVMRunner.java?view=diff&rev=451266&r1=451265&r2=451266
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/JavaVMRunner.java (original)
+++ incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/JavaVMRunner.java Fri Sep 29 05:45:08 2006
@@ -1,196 +1,196 @@
-/* Copyright 2000, 2005 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.eclipse.jdt.launching;
-
-import java.io.File;
-import java.text.DateFormat;
-import java.text.MessageFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.jdt.launching.AbstractVMRunner;
-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
-import org.eclipse.jdt.launching.IVMInstall;
-import org.eclipse.jdt.launching.VMRunnerConfiguration;
-
-public abstract class JavaVMRunner extends AbstractVMRunner {
-
-	protected IVMInstall vmInstance;
-
-	public JavaVMRunner(IVMInstall vmInstance) {
-		super();
-		this.vmInstance = vmInstance;
-	}
-
-	protected String renderDebugTarget(String classToRun, int host) {
-		String format = HyLauncherMessages
-				.getString("javaVMRunner.format.dbgTarget"); //$NON-NLS-1$
-		return MessageFormat.format(format, new String[] { classToRun,
-				String.valueOf(host) });
-	}
-
-	public static String renderProcessLabel(String[] commandLine) {
-		String format = HyLauncherMessages
-				.getString("javaVMRunner.format.processLabel"); //$NON-NLS-1$
-		String timestamp = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,
-				DateFormat.MEDIUM).format(new Date(System.currentTimeMillis()));
-		return MessageFormat.format(format, new String[] { commandLine[0],
-				timestamp });
-	}
-
-	protected static String renderCommandLine(String[] commandLine) {
-		if (commandLine.length < 1)
-			return ""; //$NON-NLS-1$
-		StringBuffer buf = new StringBuffer();
-		for (int i = 0; i < commandLine.length; i++) {
-			buf.append(' ');
-			char[] characters = commandLine[i].toCharArray();
-			StringBuffer command = new StringBuffer();
-			boolean containsSpace = false;
-			for (int j = 0; j < characters.length; j++) {
-				char character = characters[j];
-				if (character == '\"') {
-					command.append('\\');
-				} else if (character == ' ') {
-					containsSpace = true;
-				}
-				command.append(character);
-			}
-			if (containsSpace) {
-				buf.append('\"');
-				buf.append(command);
-				buf.append('\"');
-			} else {
-				buf.append(command);
-			}
-		}
-		return buf.toString();
-	}
-
-	protected void addArguments(String[] args, List v) {
-		if (args == null) {
-			return;
-		}
-		for (int i = 0; i < args.length; i++) {
-			v.add(args[i]);
-		}
-	}
-
-	protected String getJDKLocation() {
-		File location = vmInstance.getInstallLocation();
-		return location.getAbsolutePath();
-	}
-
-	/**
-	 * Returns the working directory to use for the launched VM, or
-	 * <code>null</code> if the working directory is to be inherited from the
-	 * current process.
-	 * 
-	 * @return the working directory to use
-	 * @exception CoreException
-	 *                if the working directory specified by the configuration
-	 *                does not exist or is not a directory
-	 */
-	protected File getWorkingDir(VMRunnerConfiguration config)
-			throws CoreException {
-		String path = config.getWorkingDirectory();
-		if (path == null) {
-			return null;
-		}
-		File dir = new File(path);
-		if (!dir.isDirectory()) {
-			abort(
-					MessageFormat
-							.format(
-									HyLauncherMessages
-											.getString("javaVMRunner.Specified_working_directory_does_not_exist_or_is_not_a_directory__{0}_1"), new String[] { path }), null, IJavaLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST); //$NON-NLS-1$
-		}
-		return dir;
-	}
-
-	/**
-	 * @see VMRunner#getPluginIdentifier()
-	 */
-	protected String getPluginIdentifier() {
-		return HyLaunchingPlugin.getUniqueIdentifier();
-	}
-
-	/**
-	 * Returns the default process attribute map for java processes.
-	 * 
-	 * @return default process attribute map for java processes
-	 */
-	protected Map getDefaultProcessMap() {
-		Map map = new HashMap();
-		map.put(IProcess.ATTR_PROCESS_TYPE, "harmony"); //$NON-NLS-1$
-		return map;
-	}
-
-	protected void addBootClassPathArguments(List arguments,
-			VMRunnerConfiguration config) {
-		Map map = config.getVMSpecificAttributesMap();
-		if (map == null) {
-			return;
-		}
-		String[] prependBootCP = (String[]) map
-				.get(IJavaLaunchConfigurationConstants.ATTR_BOOTPATH_PREPEND);
-		String[] bootCP = (String[]) map
-				.get(IJavaLaunchConfigurationConstants.ATTR_BOOTPATH);
-		String[] appendBootCP = (String[]) map
-				.get(IJavaLaunchConfigurationConstants.ATTR_BOOTPATH_APPEND);
-		if (prependBootCP == null && bootCP == null && appendBootCP == null) {
-			// use old single attribute instead of new attributes if not
-			// specified
-			bootCP = config.getBootClassPath();
-		}
-		if (prependBootCP != null) {
-			arguments
-					.add("-Xbootclasspath/p:" + convertClassPath(prependBootCP)); //$NON-NLS-1$
-		}
-		if (bootCP != null) {
-			if (bootCP.length > 0) {
-				arguments.add("-Xbootclasspath:" + convertClassPath(bootCP)); //$NON-NLS-1$
-			} else {
-				// empty
-				arguments.add("-Xbootclasspath:"); //$NON-NLS-1$	
-			}
-		}
-		if (appendBootCP != null) {
-			arguments
-					.add("-Xbootclasspath/a:" + convertClassPath(appendBootCP)); //$NON-NLS-1$
-		}
-	}
-
-	protected String convertClassPath(String[] cp) {
-		if (cp.length == 0) {
-			return ""; //$NON-NLS-1$
-		}
-		StringBuffer buf = new StringBuffer();
-		int pathCount = 0;
-		for (int i = 0; i < cp.length; i++) {
-			if (pathCount > 0) {
-				buf.append(File.pathSeparator);
-			}
-			buf.append(cp[i]);
-			pathCount++;
-		}
-		return buf.toString();
-	}
+/* Copyright 2000, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.eclipse.jdt.launching;
+
+import java.io.File;
+import java.text.DateFormat;
+import java.text.MessageFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.jdt.launching.AbstractVMRunner;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.VMRunnerConfiguration;
+
+public abstract class JavaVMRunner extends AbstractVMRunner {
+
+	protected IVMInstall vmInstance;
+
+	public JavaVMRunner(IVMInstall vmInstance) {
+		super();
+		this.vmInstance = vmInstance;
+	}
+
+	protected String renderDebugTarget(String classToRun, int host) {
+		String format = HyLauncherMessages
+				.getString("javaVMRunner.format.dbgTarget"); //$NON-NLS-1$
+		return MessageFormat.format(format, new String[] { classToRun,
+				String.valueOf(host) });
+	}
+
+	public static String renderProcessLabel(String[] commandLine) {
+		String format = HyLauncherMessages
+				.getString("javaVMRunner.format.processLabel"); //$NON-NLS-1$
+		String timestamp = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,
+				DateFormat.MEDIUM).format(new Date(System.currentTimeMillis()));
+		return MessageFormat.format(format, new String[] { commandLine[0],
+				timestamp });
+	}
+
+	protected static String renderCommandLine(String[] commandLine) {
+		if (commandLine.length < 1)
+			return ""; //$NON-NLS-1$
+		StringBuffer buf = new StringBuffer();
+		for (int i = 0; i < commandLine.length; i++) {
+			buf.append(' ');
+			char[] characters = commandLine[i].toCharArray();
+			StringBuffer command = new StringBuffer();
+			boolean containsSpace = false;
+			for (int j = 0; j < characters.length; j++) {
+				char character = characters[j];
+				if (character == '\"') {
+					command.append('\\');
+				} else if (character == ' ') {
+					containsSpace = true;
+				}
+				command.append(character);
+			}
+			if (containsSpace) {
+				buf.append('\"');
+				buf.append(command);
+				buf.append('\"');
+			} else {
+				buf.append(command);
+			}
+		}
+		return buf.toString();
+	}
+
+	protected void addArguments(String[] args, List v) {
+		if (args == null) {
+			return;
+		}
+		for (int i = 0; i < args.length; i++) {
+			v.add(args[i]);
+		}
+	}
+
+	protected String getJDKLocation() {
+		File location = vmInstance.getInstallLocation();
+		return location.getAbsolutePath();
+	}
+
+	/**
+	 * Returns the working directory to use for the launched VM, or
+	 * <code>null</code> if the working directory is to be inherited from the
+	 * current process.
+	 * 
+	 * @return the working directory to use
+	 * @exception CoreException
+	 *                if the working directory specified by the configuration
+	 *                does not exist or is not a directory
+	 */
+	protected File getWorkingDir(VMRunnerConfiguration config)
+			throws CoreException {
+		String path = config.getWorkingDirectory();
+		if (path == null) {
+			return null;
+		}
+		File dir = new File(path);
+		if (!dir.isDirectory()) {
+			abort(
+					MessageFormat
+							.format(
+									HyLauncherMessages
+											.getString("javaVMRunner.Specified_working_directory_does_not_exist_or_is_not_a_directory__{0}_1"), new String[] { path }), null, IJavaLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST); //$NON-NLS-1$
+		}
+		return dir;
+	}
+
+	/**
+	 * @see VMRunner#getPluginIdentifier()
+	 */
+	protected String getPluginIdentifier() {
+		return HyLaunchingPlugin.getUniqueIdentifier();
+	}
+
+	/**
+	 * Returns the default process attribute map for java processes.
+	 * 
+	 * @return default process attribute map for java processes
+	 */
+	protected Map getDefaultProcessMap() {
+		Map map = new HashMap();
+		map.put(IProcess.ATTR_PROCESS_TYPE, "harmony"); //$NON-NLS-1$
+		return map;
+	}
+
+	protected void addBootClassPathArguments(List arguments,
+			VMRunnerConfiguration config) {
+		Map map = config.getVMSpecificAttributesMap();
+		if (map == null) {
+			return;
+		}
+		String[] prependBootCP = (String[]) map
+				.get(IJavaLaunchConfigurationConstants.ATTR_BOOTPATH_PREPEND);
+		String[] bootCP = (String[]) map
+				.get(IJavaLaunchConfigurationConstants.ATTR_BOOTPATH);
+		String[] appendBootCP = (String[]) map
+				.get(IJavaLaunchConfigurationConstants.ATTR_BOOTPATH_APPEND);
+		if (prependBootCP == null && bootCP == null && appendBootCP == null) {
+			// use old single attribute instead of new attributes if not
+			// specified
+			bootCP = config.getBootClassPath();
+		}
+		if (prependBootCP != null) {
+			arguments
+					.add("-Xbootclasspath/p:" + convertClassPath(prependBootCP)); //$NON-NLS-1$
+		}
+		if (bootCP != null) {
+			if (bootCP.length > 0) {
+				arguments.add("-Xbootclasspath:" + convertClassPath(bootCP)); //$NON-NLS-1$
+			} else {
+				// empty
+				arguments.add("-Xbootclasspath:"); //$NON-NLS-1$	
+			}
+		}
+		if (appendBootCP != null) {
+			arguments
+					.add("-Xbootclasspath/a:" + convertClassPath(appendBootCP)); //$NON-NLS-1$
+		}
+	}
+
+	protected String convertClassPath(String[] cp) {
+		if (cp.length == 0) {
+			return ""; //$NON-NLS-1$
+		}
+		StringBuffer buf = new StringBuffer();
+		int pathCount = 0;
+		for (int i = 0; i < cp.length; i++) {
+			if (pathCount > 0) {
+				buf.append(File.pathSeparator);
+			}
+			buf.append(cp[i]);
+			pathCount++;
+		}
+		return buf.toString();
+	}
 }

Propchange: incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/JavaVMRunner.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message