harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r385681 - in /incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching: ./ META-INF/ src/ src/org/ src/org/apache/ src/org/apache/harmony/ src/org/apache/harmony/eclipse/ src/org/apache/harmony/eclipse/jdt/ sr...
Date Mon, 13 Mar 2006 22:27:19 GMT
Author: tellison
Date: Mon Mar 13 14:27:18 2006
New Revision: 385681

URL: http://svn.apache.org/viewcvs?rev=385681&view=rev
Log:
Initial import of HARMONY-127 (Eclipse plug-in for Harmony JRE support)

Added:
    incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/.classpath
    incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/.options
    incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/.project
    incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/LICENSE
    incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/META-INF/
    incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/META-INF/MANIFEST.MF
    incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/README
    incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/build.properties
    incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/plugin.xml
    incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/
    incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/
    incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/
    incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/
    incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/
    incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/
    incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/
    incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyDebugVMRunner.java
    incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyLauncherMessages.java
    incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyLauncherMessages.properties
    incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyLaunchingPlugin.java
    incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyVMInstall.java
    incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyVMInstallType.java
    incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyVMRunner.java
    incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/JavaVMRunner.java
Modified:
    incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/   (props changed)

Propchange: incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Mar 13 14:27:18 2006
@@ -0,0 +1,2 @@
+
+bin

Added: incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/.classpath
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/.classpath?rev=385681&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/.classpath (added)
+++ incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/.classpath Mon Mar 13 14:27:18 2006
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/.options
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/.options?rev=385681&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/.options (added)
+++ incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/.options Mon Mar 13 14:27:18 2006
@@ -0,0 +1,28 @@
+# Copyright 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.
+#
+
+# Debugging options for the org.apache.harmony.eclipse.jdt.launching plugin.
+
+# Turn on debugging for the plugin.
+org.apache.harmony.eclipse.jdt.launching/debug=true
+
+# Monitor start and stop of the plugin
+org.apache.harmony.eclipse.jdt.launching/plugin=true
+
+# Monitor installations of Harmony VMs
+org.apache.harmony.eclipse.jdt.launching/vm/installing=true
+
+# Monitor launching of applications on Harmony VMs
+org.apache.harmony.eclipse.jdt.launching/application/launching=true

Added: incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/.project
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/.project?rev=385681&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/.project (added)
+++ incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/.project Mon Mar 13 14:27:18 2006
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.apache.harmony.eclipse.jdt.launching</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/LICENSE
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/LICENSE?rev=385681&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/LICENSE (added)
+++ incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/LICENSE Mon Mar 13 14:27:18 2006
@@ -0,0 +1,203 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.
+
+   
\ No newline at end of file

Added: incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/META-INF/MANIFEST.MF?rev=385681&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/META-INF/MANIFEST.MF (added)
+++ incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/META-INF/MANIFEST.MF Mon Mar 13 14:27:18 2006
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Harmony JRE Support
+Bundle-SymbolicName: org.apache.harmony.eclipse.jdt.launching; singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Activator: org.apache.harmony.eclipse.jdt.launching.HyLaunchingPlugin
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.core.resources,
+ org.eclipse.core.runtime,
+ org.eclipse.debug.core,
+ org.eclipse.jdt.core,
+ org.eclipse.jdt.debug,
+ org.eclipse.jdt.launching
+Eclipse-LazyStart: true

Added: incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/README
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/README?rev=385681&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/README (added)
+++ incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/README Mon Mar 13 14:27:18 2006
@@ -0,0 +1,6 @@
+README for the Eclipse plug-in for Apache Harmony JRE.
+
+Source code and resources in this archive can be used to create
+a plug-in for the Eclipse 3.1 or 3.2 IDE.  The plug-in provides
+support for the layout of the Harmony JRE by defining a new
+Eclipse VM install type.

Added: incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/build.properties
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/build.properties?rev=385681&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/build.properties (added)
+++ incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/build.properties Mon Mar 13 14:27:18 2006
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               bin/
+src.includes = src/,\
+               META-INF/

Added: incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/plugin.xml
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/plugin.xml?rev=385681&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/plugin.xml (added)
+++ incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/plugin.xml Mon Mar 13 14:27:18 2006
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.1"?>
+<plugin>
+    
+<!-- Extensions -->
+<!-- Extension points -->
+   <extension
+         point="org.eclipse.jdt.launching.vmInstallTypes">
+      <vmInstallType
+            class="org.apache.harmony.eclipse.jdt.launching.HyVMInstallType"
+            id="org.apache.harmony.eclipse.jdt.launching.HyVMInstallType"/>
+   </extension>
+
+</plugin>

Added: incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyDebugVMRunner.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyDebugVMRunner.java?rev=385681&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyDebugVMRunner.java (added)
+++ incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyDebugVMRunner.java Mon Mar 13 14:27:18 2006
@@ -0,0 +1,367 @@
+/* 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.io.IOException;
+import java.io.InterruptedIOException;
+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.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.IStatusHandler;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.debug.core.model.IStreamsProxy;
+import org.eclipse.jdi.Bootstrap;
+import org.eclipse.jdt.debug.core.JDIDebugModel;
+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.jdt.launching.VMRunnerConfiguration;
+
+import com.sun.jdi.VirtualMachine;
+import com.sun.jdi.connect.Connector;
+import com.sun.jdi.connect.IllegalConnectorArgumentsException;
+import com.sun.jdi.connect.ListeningConnector;
+
+/**
+ * Used to attach to a VM in a separate thread, to allow for cancellation and
+ * detect that the associated System process died before the connect occurred.
+ */
+class ConnectRunnable implements Runnable {
+
+	private VirtualMachine virtualMachine = null;
+
+	private ListeningConnector connector = null;
+
+	private Map connectionMap = null;
+
+	private Exception exception = null;
+
+	/**
+	 * Constructs a runnable to connect to a VM via the given connector with the
+	 * given connection arguments.
+	 * 
+	 * @param connector
+	 *            the VM connector.
+	 * @param map
+	 *            the map of arguments
+	 */
+	public ConnectRunnable(ListeningConnector connector, Map map) {
+		this.connector = connector;
+		this.connectionMap = map;
+	}
+
+	public void run() {
+		try {
+			virtualMachine = connector.accept(connectionMap);
+		} catch (IOException e) {
+			exception = e;
+		} catch (IllegalConnectorArgumentsException e) {
+			exception = e;
+		}
+	}
+
+	/**
+	 * Returns the VM that was attached to, or <code>null</code> if none.
+	 * 
+	 * @return the VM that was attached to, or <code>null</code> if none
+	 */
+	public VirtualMachine getVirtualMachine() {
+		return virtualMachine;
+	}
+
+	/**
+	 * Returns any exception that occurred while attaching, or <code>null</code>.
+	 * 
+	 * @return IOException or IllegalConnectorArgumentsException
+	 */
+	public Exception getException() {
+		return exception;
+	}
+}
+
+public class HyDebugVMRunner extends HyVMRunner {
+
+	public HyDebugVMRunner(IVMInstall vmInstance) {
+		super(vmInstance);
+	}
+
+	protected void checkErrorMessage(IProcess process) throws CoreException {
+		IStreamsProxy streamsProxy = process.getStreamsProxy();
+		if (streamsProxy != null) {
+			String errorMessage = streamsProxy.getErrorStreamMonitor()
+					.getContents();
+			if (errorMessage.length() == 0) {
+				errorMessage = streamsProxy.getOutputStreamMonitor()
+						.getContents();
+			}
+			if (errorMessage.length() != 0) {
+				abort(errorMessage, null,
+						IJavaLaunchConfigurationConstants.ERR_VM_LAUNCH_ERROR);
+			}
+		}
+	}
+
+	/**
+	 * @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();
+		}
+
+		IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1);
+		subMonitor
+				.beginTask(
+						HyLauncherMessages
+								.getString("HyDebugVMRunner.Launching_virtual_machine..._1"), 5); //$NON-NLS-1$
+		subMonitor.subTask(HyLauncherMessages
+				.getString("HyDebugVMRunner.Finding_free_socket..._2")); //$NON-NLS-1$
+
+		int port = SocketUtil.findFreePort();
+		if (port == -1) {
+			abort(
+					HyLauncherMessages
+							.getString("HyDebugVMRunner.Could_not_find_a_free_socket_for_the_debugger_1"), null, IJavaLaunchConfigurationConstants.ERR_NO_SOCKET_AVAILABLE); //$NON-NLS-1$
+		}
+
+		subMonitor.worked(1);
+
+		// check for cancellation
+		if (monitor.isCanceled()) {
+			return;
+		}
+
+		subMonitor.subTask(HyLauncherMessages
+				.getString("HyDebugVMRunner.Constructing_command_line..._3")); //$NON-NLS-1$
+
+		String location = getJDKLocation();
+		String program = constructProgramString(location, config);
+
+		List arguments = new ArrayList(12);
+
+		arguments.add(program);
+
+		addArguments(config.getVMArguments(), arguments);
+
+		addBootClassPathArguments(arguments, config);
+
+		String[] cp = config.getClassPath();
+		if (cp.length > 0) {
+			arguments.add("-classpath"); //$NON-NLS-1$
+			arguments.add(convertClassPath(cp));
+		}
+		arguments.add("-Xdebug"); //$NON-NLS-1$
+		arguments
+				.add("-Xrunjdwp:transport=dt_socket,suspend=y,address=localhost:" + port); //$NON-NLS-1$
+
+		arguments.add(config.getClassToLaunch());
+		addArguments(config.getProgramArguments(), arguments);
+		String[] cmdLine = new String[arguments.size()];
+		arguments.toArray(cmdLine);
+
+		String[] envp = config.getEnvironment();
+
+		if (monitor.isCanceled()) {
+			return;
+		}
+
+		subMonitor.worked(1);
+		subMonitor.subTask(HyLauncherMessages
+				.getString("HyDebugVMRunner.Starting_virtual_machine..._4")); //$NON-NLS-1$
+
+		ListeningConnector connector = getConnector();
+		if (connector == null) {
+			abort(
+					HyLauncherMessages
+							.getString("HyDebugVMRunner.Couldn__t_find_an_appropriate_debug_connector_2"), null, IJavaLaunchConfigurationConstants.ERR_CONNECTOR_NOT_AVAILABLE); //$NON-NLS-1$
+		}
+		Map map = connector.defaultArguments();
+
+		specifyArguments(map, port);
+		Process p = null;
+		try {
+			try {
+				// check for cancellation
+				if (monitor.isCanceled()) {
+					return;
+				}
+
+				connector.startListening(map);
+
+				File workingDir = getWorkingDir(config);
+				p = exec(cmdLine, workingDir, envp);
+				if (p == null) {
+					return;
+				}
+
+				// check for cancellation
+				if (monitor.isCanceled()) {
+					p.destroy();
+					return;
+				}
+
+				IProcess process = newProcess(launch, p,
+						renderProcessLabel(cmdLine), getDefaultProcessMap());
+				process.setAttribute(IProcess.ATTR_CMDLINE,
+						renderCommandLine(cmdLine));
+				// Log the current launch command to the platform log
+				logLaunchCmd(cmdLine, true);
+				
+				if (HyLaunchingPlugin.getDefault().isDebugging()
+						&& (Platform
+								.getDebugOption(HyLaunchingPlugin.DEBUG_LAUNCHING)
+								.equalsIgnoreCase("true"))) { //$NON-NLS-1$
+					traceLaunchCmd(cmdLine, envp, true);
+				}
+				subMonitor.worked(1);
+				subMonitor
+						.subTask(HyLauncherMessages
+								.getString("HyDebugVMRunner.Establishing_debug_connection..._6")); //$NON-NLS-1$
+				boolean retry = false;
+				do {
+					try {
+						ConnectRunnable runnable = new ConnectRunnable(
+								connector, map);
+						Thread connectThread = new Thread(runnable,
+								"Listening Connector"); //$NON-NLS-1$
+						connectThread.start();
+						while (connectThread.isAlive()) {
+							if (monitor.isCanceled()) {
+								connector.stopListening(map);
+								p.destroy();
+								return;
+							}
+							try {
+								p.exitValue();
+								// process has terminated - stop waiting for a
+								// connection
+								try {
+									connector.stopListening(map);
+								} catch (IOException e) {
+									// expected
+								}
+								checkErrorMessage(process);
+							} catch (IllegalThreadStateException e) {
+								// expected while process is alive
+							}
+							try {
+								Thread.sleep(100);
+							} catch (InterruptedException e) {
+								// Ignore
+							}
+						}
+
+						Exception ex = runnable.getException();
+						if (ex instanceof IllegalConnectorArgumentsException) {
+							throw (IllegalConnectorArgumentsException) ex;
+						}
+						if (ex instanceof InterruptedIOException) {
+							throw (InterruptedIOException) ex;
+						}
+						if (ex instanceof IOException) {
+							throw (IOException) ex;
+						}
+
+						VirtualMachine vm = runnable.getVirtualMachine();
+						if (vm != null) {
+							JDIDebugModel.newDebugTarget(launch, vm,
+									renderDebugTarget(
+											config.getClassToLaunch(), port),
+									process, true, false);
+							subMonitor.worked(1);
+							subMonitor.done();
+						}
+						return;
+					} catch (InterruptedIOException e) {
+						checkErrorMessage(process);
+
+						// timeout, consult status handler if there is one
+						IStatus status = new Status(
+								IStatus.ERROR,
+								HyLaunchingPlugin.getUniqueIdentifier(),
+								IJavaLaunchConfigurationConstants.ERR_VM_CONNECT_TIMEOUT,
+								"", e); //$NON-NLS-1$
+						IStatusHandler handler = DebugPlugin.getDefault()
+								.getStatusHandler(status);
+
+						retry = false;
+						if (handler == null) {
+							// if there is no handler, throw the exception
+							throw new CoreException(status);
+						}
+						Object result = handler.handleStatus(status, this);
+						if (result instanceof Boolean) {
+							retry = ((Boolean) result).booleanValue();
+						}
+					}
+				} while (retry);
+			} finally {
+				connector.stopListening(map);
+			}
+		} catch (IOException e) {
+			abort(
+					HyLauncherMessages
+							.getString("HyDebugVMRunner.Couldn__t_connect_to_VM_4"), e, IJavaLaunchConfigurationConstants.ERR_CONNECTION_FAILED); //$NON-NLS-1$
+		} catch (IllegalConnectorArgumentsException e) {
+			abort(
+					HyLauncherMessages
+							.getString("HyDebugVMRunner.Couldn__t_connect_to_VM_5"), e, IJavaLaunchConfigurationConstants.ERR_CONNECTION_FAILED); //$NON-NLS-1$
+		}
+		if (p != null) {
+			p.destroy();
+		}
+	}
+
+	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())) //$NON-NLS-1$
+				return c;
+		}
+		return null;
+	}
+
+	protected void specifyArguments(Map map, int portNumber) {
+		Connector.IntegerArgument port = (Connector.IntegerArgument) map
+				.get("port"); //$NON-NLS-1$
+		port.setValue(portNumber);
+
+		Connector.IntegerArgument timeoutArg = (Connector.IntegerArgument) map
+				.get("timeout"); //$NON-NLS-1$
+		if (timeoutArg != null) {
+			int timeout = JavaRuntime.getPreferences().getInt(
+					JavaRuntime.PREF_CONNECT_TIMEOUT);
+			timeoutArg.setValue(timeout);
+		}
+	}
+}
\ No newline at end of file

Added: incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyLauncherMessages.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyLauncherMessages.java?rev=385681&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyLauncherMessages.java (added)
+++ incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyLauncherMessages.java Mon Mar 13 14:27:18 2006
@@ -0,0 +1,39 @@
+/* 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.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class HyLauncherMessages {
+
+	private static final String RESOURCE_BUNDLE = "org.apache.harmony.eclipse.jdt.launching.HyLauncherMessages"; //$NON-NLS-1$
+
+	private static ResourceBundle resourceBundle = ResourceBundle
+			.getBundle(RESOURCE_BUNDLE);
+
+	private HyLauncherMessages() {
+		super();
+	}
+
+	public static String getString(String key) {
+		try {
+			return resourceBundle.getString(key);
+		} catch (MissingResourceException e) {
+			return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
+		}
+	}
+}

Added: incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyLauncherMessages.properties
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyLauncherMessages.properties?rev=385681&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyLauncherMessages.properties (added)
+++ incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyLauncherMessages.properties Mon Mar 13 14:27:18 2006
@@ -0,0 +1,35 @@
+# 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.
+#
+
+HyDebugVMRunner.Could_not_find_a_free_socket_for_the_debugger_1=Cannot find a free socket for the debugger
+HyDebugVMRunner.Couldn__t_connect_to_VM_5=Cannot connect to VM
+HyDebugVMRunner.Couldn__t_find_an_appropriate_debug_connector_2=Cannot find an appropriate debug connector
+HyDebugVMRunner.Launching_virtual_machine..._1=Launching virtual machine...
+HyDebugVMRunner.Finding_free_socket..._2=Finding free socket...
+HyDebugVMRunner.Constructing_command_line..._3=Constructing command line...
+HyDebugVMRunner.Starting_virtual_machine..._4=Starting virtual machine...
+HyDebugVMRunner.Establishing_debug_connection..._6=Establishing debug connection...
+
+HyVMType.error.noLauncher=Not a Harmony runtime installation; executable was not found
+HyVMType.error.noBootProperties=Not a Harmony runtime installation; bootclasspath.properties was not found
+HyVMType.name=Apache Harmony VM
+
+javaVMRunner.format.dbgTarget={0} at localhost:{1}
+javaVMRunner.format.processLabel={0} ({1})
+javaVMRunner.Specified_working_directory_does_not_exist_or_is_not_a_directory__{0}_1=Specified working directory does not exist or is not a directory: {0}
+
+HyVMRunner.Launching_virtual_machine..._1=Launching virtual machine...
+HyVMRunner.Constructing_command_line..._2=Constructing command line...
+HyVMRunner.Starting_virtual_machine..._3=Starting virtual machine...

Added: incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyLaunchingPlugin.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyLaunchingPlugin.java?rev=385681&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyLaunchingPlugin.java (added)
+++ incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyLaunchingPlugin.java Mon Mar 13 14:27:18 2006
@@ -0,0 +1,14 @@
+/* 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 org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
import org.osgi.framework.BundleContext;

public class HyLaunchingPlugin extends Plugin {

	/**
	 * Unique identifier constant.
	 */
	private static final String PI_Harmony_Launching = "org.apache.harmony.jdt.launching"; //$NON-NLS-1$

	private static HyLaunchingPlugin plugin;

	static final String DEBUG_PLUGIN = PI_Harmony_Launching + "/plugin"; //$NON-NLS-1$

	static final String DEBUG_INSTALLING = PI_Harmony_Launching + "/vm/installing"; //$NON-NLS-1$

	static final String DEBUG_LAUNCHING = PI_Harmony_Launching + "/application/launching"; //$NON-NLS-1$

	/**
	 * Default constructor.
	 */
	public HyLaunchingPlugin() {
		super();
		plugin = this;
	}

	public void start(BundleContext context) throws Exception {
		super.start(context);

		if (isDebugging()
				
 && (Platform.getDebugOption(DEBUG_PLUGIN)
						.equalsIgnoreCase("true"))) { //$NON-NLS-1$
			System.out.println(PI_Harmony_Launching + "--> Plugin started"); //$NON-NLS-1$
		}
	}

	public void stop(BundleContext context) throws Exception {
		if (isDebugging()
				&& (Platform.getDebugOption(DEBUG_PLUGIN)
						.equalsIgnoreCase("true"))) { //$NON-NLS-1$
			System.out.println(PI_Harmony_Launching + "--> Plugin stopping"); //$NON-NLS-1$
		}

		super.stop(context);
	}

	public static HyLaunchingPlugin getDefault() {
		return plugin;
	}

	/**
	 * Convenience method which returns the unique identifier of this plugin.
	 */
	public static String getUniqueIdentifier() {
		return PI_Harmony_Launching;
	}

	/**
	 * Convenience method to write status information to the platform log.
	 * 
	 * @param msg
	 *            information to be written to the platform log.
	 */
	public void log(String msg) {
		log(msg, null);
	}

	/**
	 * Convenience method to write problem information to the 
 platform log.
	 * 
	 * @param msg
	 *            additional information about the event
	 * @param e
	 *            exception encapsulating any non-fatal problem
	 */
	public void log(String msg, Exception e) {
		getLog().log(
				new Status(IStatus.INFO, getUniqueIdentifier(), IStatus.OK,
						msg, e));
	}

	/**
	 * Convenience method to write error information to the platform log.
	 * 
	 * @param msg
	 *            additional information about the event
	 * @param e
	 *            exception encapsulating the error
	 */
	public void logError(String msg, Exception e) {
		getLog().log(
				new Status(IStatus.INFO, getUniqueIdentifier(), IStatus.ERROR,
						msg, e));
	}

	/**
	 * Convenience method that returns a boolean indication of whether or not
	 * the plug-in is running with debug trace on <em>and</em> if the option
	 * to allow trace messages about the VM installation activities has been
	 * specified.
	 * 
	 * @return <code>true</code> if tracing of VM install activi
 ties is
	 *         enabled, otherwise <code>false</code>.
	 */
	public static boolean isDebuggingInstalling() {
		boolean result = false;
		if (plugin.isDebugging()) {
			String option = Platform.getDebugOption(DEBUG_INSTALLING);
			if ((option != null) && option.equalsIgnoreCase("true")) { //$NON-NLS-1$
				result = true;
			}
		}
		return result;
	}
}

Added: incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyVMInstall.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyVMInstall.java?rev=385681&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyVMInstall.java (added)
+++ incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyVMInstall.java Mon Mar 13 14:27:18 2006
@@ -0,0 +1,119 @@
+/* Copyright 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 org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.jdt.launching.AbstractVMInstall;
+import org.eclipse.jdt.launching.IVMInstallType;
+import org.eclipse.jdt.launching.IVMRunner;
+import org.eclipse.jdt.launching.LibraryLocation;
+
+public class HyVMInstall extends AbstractVMInstall {
+
+	/*
+	 * Constructor for a VM install.
+	 */
+	HyVMInstall(IVMInstallType type, String id) {
+		super(type, id);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.jdt.launching.IVMInstall#getVMRunner(java.lang.String)
+	 */
+	public IVMRunner getVMRunner(String mode) {
+		if (ILaunchManager.RUN_MODE.equals(mode)) {
+			return new HyVMRunner(this);
+		} else if (ILaunchManager.DEBUG_MODE.equals(mode)) {
+			return new HyDebugVMRunner(this);
+		}
+		return null;
+	}
+
+	public void setLibraryLocations(LibraryLocation[] locations) {
+		// If the libs are being explicitly set, then don't monkey with them
+		if (locations != null) {
+			super.setLibraryLocations(locations);
+			return;
+		}
+
+		if (locations == null) {
+			super.setLibraryLocations(locations);
+			return;
+		}
+
+		// 'null' means use the default locations, which for us depends
+		// upon the argument list.
+
+		// find the vm subdir and VMI name
+		String subdir = "default"; //$NON-NLS-1$
+		String vminame = "clearvm"; //$NON-NLS-1$
+		String[] args = getVMArguments();
+		if (args != null) {
+			for (int i = 0; i < args.length; i++) {
+				if (args[i].startsWith("-vmdir:")) { //$NON-NLS-1$
+					subdir = args[i].substring("-vmdir:".length()); //$NON-NLS-1$
+				}
+				if (args[i].startsWith("-vm:")) { //$NON-NLS-1$
+					vminame = args[i].substring("-vm:".length()); //$NON-NLS-1$
+				}
+			}
+		}
+
+		// Build a library location for the kernel classes
+		LibraryLocation kernel = kernelLocation(subdir, vminame);
+		LibraryLocation[] stdDefaults = getVMInstallType()
+				.getDefaultLibraryLocations(getInstallLocation());
+
+		// Ensure we don't duplicate the kernel
+		boolean found = false;
+		for (int i = 0; i < stdDefaults.length; i++) {
+			LibraryLocation location = stdDefaults[i];
+			if (location.getSystemLibraryPath().equals(
+					kernel.getSystemLibraryPath())) {
+				found = true;
+				break;
+			}
+		}
+
+		if (found) {
+			super.setLibraryLocations(null);
+		} else {
+			LibraryLocation[] allLibs = new LibraryLocation[stdDefaults.length + 1];
+			allLibs[0] = kernel;
+			System.arraycopy(stdDefaults, 0, allLibs, 1, stdDefaults.length);
+			super.setLibraryLocations(allLibs);
+		}
+	}
+
+	private LibraryLocation kernelLocation(String subdir, String vmname) {
+		return ((HyVMInstallType) getVMInstallType()).getKernelLocation(
+				getInstallLocation(), subdir, vmname);
+	}
+
+	/*
+	 * (non-Javadoc) The setVMArgs does not cause an event change, so we have to
+	 * subclass here to (potentially) change our library path based on changes
+	 * to the -vmdir argument.
+	 * 
+	 * @see org.eclipse.jdt.launching.IVMInstall#setVMArgs(java.lang.String)
+	 */
+	public void setVMArgs(String vmArgs) {
+		super.setVMArgs(vmArgs);
+		setLibraryLocations(getLibraryLocations());
+	}
+}

Added: 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/viewcvs/incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyVMInstallType.java?rev=385681&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyVMInstallType.java (added)
+++ incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyVMInstallType.java Mon Mar 13 14:27:18 2006
@@ -0,0 +1,385 @@
+/* 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.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
+		LibraryLocation kernel = getKernelLocation(installLocation,
+				"default", "clearvm"); //$NON-NLS-1$ //$NON-NLS-2$
+		if (kernel == 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[1
+				+ bootLibraries.size() + extensions.size()];
+		
+		int libraryCount = 0;
+
+		// Start with the kernel library location
+		allLibraries[libraryCount++] = kernel;
+
+		// 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);
+		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);
+				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) {
+
+		// Only keep keys that are "bootclasspath.<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("bootclasspath.") && //$NON-NLS-1$
+			(key.indexOf('.', 14) == -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) {
+				// Here '14' is the offset past "bootclasspath."
+				String str1 = ((String) object1).substring(14);
+				String str2 = ((String) object2).substring(14);
+				// 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;
+	}
+
+	
+	LibraryLocation getKernelLocation(File installLocation, String vmdir,
+			String vmname) {
+		Properties kernelProperties = new Properties();
+		File propertyFile = new File(installLocation, "bin" + File.separator + //$NON-NLS-1$
+				vmdir + File.separator + 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;
+		}
+
+		String libStr = tokenReplace(installLocation, kernelProperties
+				.getProperty("bootclasspath.kernel")); //$NON-NLS-1$
+		IPath libPath = new Path(libStr);
+
+		String srcStr = tokenReplace(installLocation, kernelProperties
+				.getProperty("bootclasspath.source.kernel")); //$NON-NLS-1$
+		IPath srcPath;
+		if (srcStr == null) {
+			srcPath = Path.EMPTY;
+		} else {
+			srcPath = new Path(srcStr);
+		}
+
+		String rootStr = tokenReplace(installLocation, kernelProperties
+				.getProperty("bootclasspath.source.packageroot.kernel")); //$NON-NLS-1$
+		IPath rootPath;
+		if (rootStr == null) {
+			rootPath = Path.ROOT;
+		} else {
+			rootPath = new Path(rootStr);
+		}
+
+		return new LibraryLocation(libPath, srcPath, rootPath);
+	}
+
+	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();
+	}
+}
\ No newline at end of file

Added: 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/viewcvs/incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyVMRunner.java?rev=385681&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyVMRunner.java (added)
+++ incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/HyVMRunner.java Mon Mar 13 14:27:18 2006
@@ -0,0 +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();
+	}
+}
\ No newline at end of file

Added: 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/viewcvs/incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/JavaVMRunner.java?rev=385681&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/JavaVMRunner.java (added)
+++ incubator/harmony/enhanced/tools/trunk/eclipse/org.apache.harmony.eclipse.jdt.launching/src/org/apache/harmony/eclipse/jdt/launching/JavaVMRunner.java Mon Mar 13 14:27:18 2006
@@ -0,0 +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();
+	}
+}
\ No newline at end of file



Mime
View raw message