Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 26810 Details for
Bug 106683
org.eclipse.jdt.launching.j9 contribution
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
updated to work with the HEAD
patch2.txt (text/plain), 210.63 KB, created by
fernando concha
on 2005-09-02 15:29:48 EDT
(
hide
)
Description:
updated to work with the HEAD
Filename:
MIME Type:
Creator:
fernando concha
Created:
2005-09-02 15:29:48 EDT
Size:
210.63 KB
patch
obsolete
>Index: .classpath >=================================================================== >RCS file: .classpath >diff -N .classpath >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .classpath 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,7 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<classpath> >+ <classpathentry kind="src" path="j9/"/> >+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> >+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> >+ <classpathentry kind="output" path="bin"/> >+</classpath> >Index: .cvsignore >=================================================================== >RCS file: .cvsignore >diff -N .cvsignore >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .cvsignore 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,8 @@ >+bin >+build.xml >+j9launching.jar >+j9launchingsrc.zip >+org.eclipse.jdt.launching.j9_*.jar >+publish.xml >+publish_all.xml >+temp.folder >Index: .options >=================================================================== >RCS file: .options >diff -N .options >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .options 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,2 @@ >+org.eclipse.jdt.launching.j9/debug = false >+org.eclipse.jdt.launching.j9/command_line = false >Index: .project >=================================================================== >RCS file: .project >diff -N .project >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .project 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,28 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<projectDescription> >+ <name>org.eclipse.jdt.launching.j9</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.jdt.core.javanature</nature> >+ <nature>org.eclipse.pde.PluginNature</nature> >+ </natures> >+</projectDescription> >Index: build.properties >=================================================================== >RCS file: build.properties >diff -N build.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ build.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,7 @@ >+bin.includes = plugin.xml,\ >+ about.html,\ >+ plugin.properties,\ >+ j9launching.jar >+source.j9launching.jar = j9/ >+ >+src.includes=about.html >Index: epl-1.0.html >=================================================================== >RCS file: epl-1.0.html >diff -N epl-1.0.html >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ epl-1.0.html 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,328 @@ >+<html xmlns:o="urn:schemas-microsoft-com:office:office" >+xmlns:w="urn:schemas-microsoft-com:office:word" >+xmlns="http://www.w3.org/TR/REC-html40"> >+ >+<head> >+<meta http-equiv=Content-Type content="text/html; charset=windows-1252"> >+<meta name=ProgId content=Word.Document> >+<meta name=Generator content="Microsoft Word 9"> >+<meta name=Originator content="Microsoft Word 9"> >+<link rel=File-List >+href="./Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml"> >+<title>Eclipse Public License - Version 1.0</title> >+<!--[if gte mso 9]><xml> >+ <o:DocumentProperties> >+ <o:Revision>2</o:Revision> >+ <o:TotalTime>3</o:TotalTime> >+ <o:Created>2004-03-05T23:03:00Z</o:Created> >+ <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved> >+ <o:Pages>4</o:Pages> >+ <o:Words>1626</o:Words> >+ <o:Characters>9270</o:Characters> >+ <o:Lines>77</o:Lines> >+ <o:Paragraphs>18</o:Paragraphs> >+ <o:CharactersWithSpaces>11384</o:CharactersWithSpaces> >+ <o:Version>9.4402</o:Version> >+ </o:DocumentProperties> >+</xml><![endif]--><!--[if gte mso 9]><xml> >+ <w:WordDocument> >+ <w:TrackRevisions/> >+ </w:WordDocument> >+</xml><![endif]--> >+<style> >+<!-- >+ /* Font Definitions */ >+@font-face >+ {font-family:Tahoma; >+ panose-1:2 11 6 4 3 5 4 4 2 4; >+ mso-font-charset:0; >+ mso-generic-font-family:swiss; >+ mso-font-pitch:variable; >+ mso-font-signature:553679495 -2147483648 8 0 66047 0;} >+ /* Style Definitions */ >+p.MsoNormal, li.MsoNormal, div.MsoNormal >+ {mso-style-parent:""; >+ margin:0in; >+ margin-bottom:.0001pt; >+ mso-pagination:widow-orphan; >+ font-size:12.0pt; >+ font-family:"Times New Roman"; >+ mso-fareast-font-family:"Times New Roman";} >+p >+ {margin-right:0in; >+ mso-margin-top-alt:auto; >+ mso-margin-bottom-alt:auto; >+ margin-left:0in; >+ mso-pagination:widow-orphan; >+ font-size:12.0pt; >+ font-family:"Times New Roman"; >+ mso-fareast-font-family:"Times New Roman";} >+p.BalloonText, li.BalloonText, div.BalloonText >+ {mso-style-name:"Balloon Text"; >+ margin:0in; >+ margin-bottom:.0001pt; >+ mso-pagination:widow-orphan; >+ font-size:8.0pt; >+ font-family:Tahoma; >+ mso-fareast-font-family:"Times New Roman";} >+@page Section1 >+ {size:8.5in 11.0in; >+ margin:1.0in 1.25in 1.0in 1.25in; >+ mso-header-margin:.5in; >+ mso-footer-margin:.5in; >+ mso-paper-source:0;} >+div.Section1 >+ {page:Section1;} >+--> >+</style> >+</head> >+ >+<body lang=EN-US style='tab-interval:.5in'> >+ >+<div class=Section1> >+ >+<p align=center style='text-align:center'><b>Eclipse Public License - v 1.0</b> >+</p> >+ >+<p><span style='font-size:10.0pt'>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER >+THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, >+REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE >+OF THIS AGREEMENT.</span> </p> >+ >+<p><b><span style='font-size:10.0pt'>1. DEFINITIONS</span></b> </p> >+ >+<p><span style='font-size:10.0pt'>"Contribution" means:</span> </p> >+ >+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a) >+in the case of the initial Contributor, the initial code and documentation >+distributed under this Agreement, and<br clear=left> >+b) in the case of each subsequent Contributor:</span></p> >+ >+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i) >+changes to the Program, and</span></p> >+ >+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii) >+additions to the Program;</span></p> >+ >+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>where >+such changes and/or additions to the Program originate from and are distributed >+by that particular Contributor. A Contribution 'originates' from a Contributor >+if it was added to the Program by such Contributor itself or anyone acting on >+such Contributor's behalf. Contributions do not include additions to the >+Program which: (i) are separate modules of software distributed in conjunction >+with the Program under their own license agreement, and (ii) are not derivative >+works of the Program. </span></p> >+ >+<p><span style='font-size:10.0pt'>"Contributor" means any person or >+entity that distributes the Program.</span> </p> >+ >+<p><span style='font-size:10.0pt'>"Licensed Patents " mean patent >+claims licensable by a Contributor which are necessarily infringed by the use >+or sale of its Contribution alone or when combined with the Program. </span></p> >+ >+<p><span style='font-size:10.0pt'>"Program" means the Contributions >+distributed in accordance with this Agreement.</span> </p> >+ >+<p><span style='font-size:10.0pt'>"Recipient" means anyone who >+receives the Program under this Agreement, including all Contributors.</span> </p> >+ >+<p><b><span style='font-size:10.0pt'>2. GRANT OF RIGHTS</span></b> </p> >+ >+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a) >+Subject to the terms of this Agreement, each Contributor hereby grants Recipient >+a non-exclusive, worldwide, royalty-free copyright license to<span >+style='color:red'> </span>reproduce, prepare derivative works of, publicly >+display, publicly perform, distribute and sublicense the Contribution of such >+Contributor, if any, and such derivative works, in source code and object code >+form.</span></p> >+ >+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) >+Subject to the terms of this Agreement, each Contributor hereby grants >+Recipient a non-exclusive, worldwide,<span style='color:green'> </span>royalty-free >+patent license under Licensed Patents to make, use, sell, offer to sell, import >+and otherwise transfer the Contribution of such Contributor, if any, in source >+code and object code form. This patent license shall apply to the combination >+of the Contribution and the Program if, at the time the Contribution is added >+by the Contributor, such addition of the Contribution causes such combination >+to be covered by the Licensed Patents. The patent license shall not apply to >+any other combinations which include the Contribution. No hardware per se is >+licensed hereunder. </span></p> >+ >+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>c) >+Recipient understands that although each Contributor grants the licenses to its >+Contributions set forth herein, no assurances are provided by any Contributor >+that the Program does not infringe the patent or other intellectual property >+rights of any other entity. Each Contributor disclaims any liability to Recipient >+for claims brought by any other entity based on infringement of intellectual >+property rights or otherwise. As a condition to exercising the rights and >+licenses granted hereunder, each Recipient hereby assumes sole responsibility >+to secure any other intellectual property rights needed, if any. For example, >+if a third party patent license is required to allow Recipient to distribute >+the Program, it is Recipient's responsibility to acquire that license before >+distributing the Program.</span></p> >+ >+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>d) >+Each Contributor represents that to its knowledge it has sufficient copyright >+rights in its Contribution, if any, to grant the copyright license set forth in >+this Agreement. </span></p> >+ >+<p><b><span style='font-size:10.0pt'>3. REQUIREMENTS</span></b> </p> >+ >+<p><span style='font-size:10.0pt'>A Contributor may choose to distribute the >+Program in object code form under its own license agreement, provided that:</span> >+</p> >+ >+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a) >+it complies with the terms and conditions of this Agreement; and</span></p> >+ >+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) >+its license agreement:</span></p> >+ >+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i) >+effectively disclaims on behalf of all Contributors all warranties and >+conditions, express and implied, including warranties or conditions of title >+and non-infringement, and implied warranties or conditions of merchantability >+and fitness for a particular purpose; </span></p> >+ >+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii) >+effectively excludes on behalf of all Contributors all liability for damages, >+including direct, indirect, special, incidental and consequential damages, such >+as lost profits; </span></p> >+ >+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iii) >+states that any provisions which differ from this Agreement are offered by that >+Contributor alone and not by any other party; and</span></p> >+ >+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iv) >+states that source code for the Program is available from such Contributor, and >+informs licensees how to obtain it in a reasonable manner on or through a >+medium customarily used for software exchange.<span style='color:blue'> </span></span></p> >+ >+<p><span style='font-size:10.0pt'>When the Program is made available in source >+code form:</span> </p> >+ >+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a) >+it must be made available under this Agreement; and </span></p> >+ >+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) a >+copy of this Agreement must be included with each copy of the Program. </span></p> >+ >+<p><span style='font-size:10.0pt'>Contributors may not remove or alter any >+copyright notices contained within the Program. </span></p> >+ >+<p><span style='font-size:10.0pt'>Each Contributor must identify itself as the >+originator of its Contribution, if any, in a manner that reasonably allows >+subsequent Recipients to identify the originator of the Contribution. </span></p> >+ >+<p><b><span style='font-size:10.0pt'>4. COMMERCIAL DISTRIBUTION</span></b> </p> >+ >+<p><span style='font-size:10.0pt'>Commercial distributors of software may >+accept certain responsibilities with respect to end users, business partners >+and the like. While this license is intended to facilitate the commercial use >+of the Program, the Contributor who includes the Program in a commercial >+product offering should do so in a manner which does not create potential >+liability for other Contributors. Therefore, if a Contributor includes the >+Program in a commercial product offering, such Contributor ("Commercial >+Contributor") hereby agrees to defend and indemnify every other >+Contributor ("Indemnified Contributor") against any losses, damages and >+costs (collectively "Losses") arising from claims, lawsuits and other >+legal actions brought by a third party against the Indemnified Contributor to >+the extent caused by the acts or omissions of such Commercial Contributor in >+connection with its distribution of the Program in a commercial product >+offering. The obligations in this section do not apply to any claims or Losses >+relating to any actual or alleged intellectual property infringement. In order >+to qualify, an Indemnified Contributor must: a) promptly notify the Commercial >+Contributor in writing of such claim, and b) allow the Commercial Contributor >+to control, and cooperate with the Commercial Contributor in, the defense and >+any related settlement negotiations. The Indemnified Contributor may participate >+in any such claim at its own expense.</span> </p> >+ >+<p><span style='font-size:10.0pt'>For example, a Contributor might include the >+Program in a commercial product offering, Product X. That Contributor is then a >+Commercial Contributor. If that Commercial Contributor then makes performance >+claims, or offers warranties related to Product X, those performance claims and >+warranties are such Commercial Contributor's responsibility alone. Under this >+section, the Commercial Contributor would have to defend claims against the >+other Contributors related to those performance claims and warranties, and if a >+court requires any other Contributor to pay any damages as a result, the >+Commercial Contributor must pay those damages.</span> </p> >+ >+<p><b><span style='font-size:10.0pt'>5. NO WARRANTY</span></b> </p> >+ >+<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS >+AGREEMENT, THE PROGRAM IS PROVIDED 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. Each Recipient is solely >+responsible for determining the appropriateness of using and distributing the >+Program and assumes all risks associated with its exercise of rights under this >+Agreement , including but not limited to the risks and costs of program errors, >+compliance with applicable laws, damage to or loss of data, programs or >+equipment, and unavailability or interruption of operations. </span></p> >+ >+<p><b><span style='font-size:10.0pt'>6. DISCLAIMER OF LIABILITY</span></b> </p> >+ >+<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS >+AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR >+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY >+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING >+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF >+THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF >+THE POSSIBILITY OF SUCH DAMAGES.</span> </p> >+ >+<p><b><span style='font-size:10.0pt'>7. GENERAL</span></b> </p> >+ >+<p><span style='font-size:10.0pt'>If any provision of this Agreement is invalid >+or unenforceable under applicable law, it shall not affect the validity or >+enforceability of the remainder of the terms of this Agreement, and without >+further action by the parties hereto, such provision shall be reformed to the >+minimum extent necessary to make such provision valid and enforceable.</span> </p> >+ >+<p><span style='font-size:10.0pt'>If Recipient institutes patent litigation >+against any entity (including a cross-claim or counterclaim in a lawsuit) >+alleging that the Program itself (excluding combinations of the Program with >+other software or hardware) infringes such Recipient's patent(s), then such >+Recipient's rights granted under Section 2(b) shall terminate as of the date >+such litigation is filed. </span></p> >+ >+<p><span style='font-size:10.0pt'>All Recipient's rights under this Agreement >+shall terminate if it fails to comply with any of the material terms or >+conditions of this Agreement and does not cure such failure in a reasonable >+period of time after becoming aware of such noncompliance. If all Recipient's >+rights under this Agreement terminate, Recipient agrees to cease use and >+distribution of the Program as soon as reasonably practicable. However, >+Recipient's obligations under this Agreement and any licenses granted by >+Recipient relating to the Program shall continue and survive. </span></p> >+ >+<p><span style='font-size:10.0pt'>Everyone is permitted to copy and distribute >+copies of this Agreement, but in order to avoid inconsistency the Agreement is >+copyrighted and may only be modified in the following manner. The Agreement >+Steward reserves the right to publish new versions (including revisions) of >+this Agreement from time to time. No one other than the Agreement Steward has >+the right to modify this Agreement. The Eclipse Foundation is the initial >+Agreement Steward. The Eclipse Foundation may assign the responsibility to >+serve as the Agreement Steward to a suitable separate entity. Each new version >+of the Agreement will be given a distinguishing version number. The Program >+(including Contributions) may always be distributed subject to the version of >+the Agreement under which it was received. In addition, after a new version of >+the Agreement is published, Contributor may elect to distribute the Program >+(including its Contributions) under the new version. Except as expressly stated >+in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to >+the intellectual property of any Contributor under this Agreement, whether >+expressly, by implication, estoppel or otherwise. All rights in the Program not >+expressly granted under this Agreement are reserved.</span> </p> >+ >+<p><span style='font-size:10.0pt'>This Agreement is governed by the laws of the >+State of New York and the intellectual property laws of the United States of >+America. No party to this Agreement will bring a legal action under this >+Agreement more than one year after the cause of action arose. Each party waives >+its rights to a jury trial in any resulting litigation.</span> </p> >+ >+<p class=MsoNormal><![if !supportEmptyParas]> <![endif]><o:p></o:p></p> >+ >+</div> >+ >+</body> >+ >+</html> >Index: plugin.properties >=================================================================== >RCS file: plugin.properties >diff -N plugin.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ plugin.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,16 @@ >+###################################################################### >+# Copyright (c) 2002, 2004 IBM Corporation. >+# All rights reserved. This program and the accompanying materials >+# are made available under the terms of the Eclipse Public License v1.0 >+# which accompanies this distribution, and is available at >+# http://www.eclipse.org/legal/epl-v10.html >+# >+# Contributors: >+# IBM Corporation - Initial implementation >+###################################################################### >+ >+pluginName=J9 VM Launching >+providerName=IBM >+ >+J9PreferencePage.label=J9 >+J9PropertyPage.label=J9 >Index: plugin.xml >=================================================================== >RCS file: plugin.xml >diff -N plugin.xml >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ plugin.xml 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,99 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<?eclipse version="3.0"?> >+<plugin >+ id="org.eclipse.jdt.launching.j9" >+ name="%pluginName" >+ version="5.7.1" >+ provider-name="%providerName" >+ class="org.eclipse.jdt.internal.launching.j9.J9LaunchingPlugin"> >+ >+ <runtime> >+ <library name="j9launching.jar"> >+ <export name="*"/> >+ </library> >+ </runtime> >+ <requires> >+ <import plugin="org.eclipse.core.resources"/> >+ <import plugin="org.eclipse.core.runtime"/> >+ <import plugin="org.eclipse.debug.core"/> >+ <import plugin="org.eclipse.debug.ui"/> >+ <import plugin="org.eclipse.jdt.core"/> >+ <import plugin="org.eclipse.jdt.debug"/> >+ <import plugin="org.eclipse.jdt.debug.ui"/> >+ <import plugin="org.eclipse.jdt.launching"/> >+ <import plugin="org.eclipse.ui"/> >+ <import plugin="org.eclipse.ui.ide"/> >+ <import plugin="org.eclipse.update.configurator"/> >+ </requires> >+ >+ >+<!-- Extension points --> >+ <extension-point id="J9VMInstallLocations" name="J9 VM Install Locations"/> >+ >+<!-- Extensions --> >+ <extension >+ point="org.eclipse.ui.preferencePages"> >+ <page >+ name="%J9PreferencePage.label" >+ category="org.eclipse.jdt.ui.preferences.JavaBasePreferencePage" >+ class="org.eclipse.jdt.internal.launching.j9.J9PreferencePage" >+ id="com.ibm.ive.internal.j9.launcher.J9PreferencePage"> >+ </page> >+ </extension> >+ <extension >+ point="org.eclipse.ui.propertyPages"> >+ <page >+ objectClass="org.eclipse.core.resources.IProject" >+ adaptable="true" >+ name="%J9PropertyPage.label" >+ class="org.eclipse.jdt.internal.launching.j9.J9PropertyPage" >+ id="com.ibm.ive.internal.j9.launcher.J9PropertyPage"> >+ <filter >+ name="projectNature" >+ value="com.ibm.ive.j9.J2MENature"> >+ </filter> >+ </page> >+ </extension> >+ <extension >+ point="org.eclipse.ui.propertyPages"> >+ <page >+ objectClass="org.eclipse.core.resources.IProject" >+ adaptable="true" >+ name="%J9PropertyPage.label" >+ class="org.eclipse.jdt.internal.launching.j9.J9PropertyPage" >+ id="com.ibm.ive.internal.j9.launcher.J9PropertyPage"> >+ <filter >+ name="projectNature" >+ value="com.ibm.ive.j9.CustomNature"> >+ </filter> >+ </page> >+ </extension> >+ <extension >+ point="org.eclipse.jdt.launching.vmInstallTypes"> >+ <vmInstallType >+ class="org.eclipse.jdt.internal.launching.j9.J9VMInstallType" >+ id="com.ibm.ive.internal.j9.launcher.J9VMType"> >+ </vmInstallType> >+ </extension> >+<!-- added the SocketAttach back in to keep old projects with devices happy. --> >+ <extension >+ point="org.eclipse.jdt.launching.vmConnectors"> >+ <vmConnector >+ class="org.eclipse.jdt.internal.launching.j9.J9ConnectorDelegate" >+ id="com.ibm.ive.internal.j9.launcher.J9ConnectorDelegate"> >+ </vmConnector> >+ <vmConnector >+ class="org.eclipse.jdt.internal.launching.j9.J9SocketAttachConnectorDelegate" >+ id="com.ibm.ive.internal.j9.launcher.J9SocketAttachConnector"> >+ </vmConnector> >+ </extension> >+ <extension >+ point="org.eclipse.jdt.debug.ui.vmInstallTypePage"> >+ <vmInstallTypePage >+ vmInstallTypeID="com.ibm.ive.internal.j9.launcher.J9VMType" >+ class="org.eclipse.jdt.internal.launching.j9.J9VMCommandTab" >+ id="com.ibm.ive.internal.j9.launcher.J9VMCommandTab"> >+ </vmInstallTypePage> >+ </extension> >+ >+</plugin> >Index: j9/org/eclipse/jdt/internal/launching/j9/ComboFieldEditor.java >=================================================================== >RCS file: j9/org/eclipse/jdt/internal/launching/j9/ComboFieldEditor.java >diff -N j9/org/eclipse/jdt/internal/launching/j9/ComboFieldEditor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ j9/org/eclipse/jdt/internal/launching/j9/ComboFieldEditor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,179 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.launching.j9; >+ >+import org.eclipse.jface.preference.FieldEditor; >+import org.eclipse.jface.util.Assert; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.Combo; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+ >+/** >+ * A field editor for a combo box that allows the drop-down selection of one of a list of items. >+ */ >+public class ComboFieldEditor extends FieldEditor { >+ >+ /** >+ * The <code>Combo</code> widget. >+ */ >+ private Combo fCombo; >+ >+ /** >+ * The value (not the name) of the currently selected item in the Combo widget. >+ */ >+ private String fValue; >+ >+ /** >+ * The names (labels) and underlying values to populate the combo widget. These should be >+ * arranged as: { {name1, value1}, {name2, value2}, ...} >+ */ >+ private String[][] fEntryNamesAndValues; >+ >+ public ComboFieldEditor(String name, String labelText, String[][] entryNamesAndValues, Composite parent) { >+ init(name, labelText); >+ Assert.isTrue(checkArray(entryNamesAndValues)); >+ fEntryNamesAndValues = entryNamesAndValues; >+ createControl(parent); >+ } >+ >+ /** >+ * Checks whether given <code>String[][]</code> is of "type" >+ * <code>String[][2]</code>. >+ * >+ * @return <code>true</code> if it is ok, and <code>false</code> otherwise >+ */ >+ private boolean checkArray(String[][] table) { >+ if (table == null) { >+ return false; >+ } >+ for (int i = 0; i < table.length; i++) { >+ String[] array = table[i]; >+ if (array == null || array.length != 2) { >+ return false; >+ } >+ } >+ return true; >+ } >+ >+ /** >+ * @see FieldEditor#adjustForNumColumns(int) >+ */ >+ protected void adjustForNumColumns(int numColumns) { >+ } >+ >+ /** >+ * @see FieldEditor#doFillIntoGrid(Composite, int) >+ */ >+ protected void doFillIntoGrid(Composite parent, int numColumns) { >+ Control control = getLabelControl(parent); >+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); >+ gd.horizontalSpan = 1; >+ control.setLayoutData(gd); >+ control = getComboBoxControl(parent); >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); >+ gd.horizontalSpan = 1; >+ control.setLayoutData(gd); >+ } >+ >+ /** >+ * @see FieldEditor#doLoad() >+ */ >+ protected void doLoad() { >+ updateComboForValue(getPreferenceStore().getString(getPreferenceName())); >+ } >+ >+ /** >+ * @see FieldEditor#doLoadDefault() >+ */ >+ protected void doLoadDefault() { >+ updateComboForValue(getPreferenceStore().getDefaultString(getPreferenceName())); >+ } >+ >+ /** >+ * @see FieldEditor#doStore() >+ */ >+ protected void doStore() { >+ /* >+ * the receiver does not hear about vms added and removed while the preference page >+ * is open, hence the current selection can be a non-existant vm, so first ensure it >+ * exits before writing it to the store >+ */ >+ if (fValue == null || J9PreferencePage.getVMNamesFromId(fValue) == null) { >+ getPreferenceStore().setToDefault(getPreferenceName()); >+ return; >+ } >+ >+ getPreferenceStore().setValue(getPreferenceName(), fValue); >+ } >+ >+ /** >+ * @see FieldEditor#getNumberOfControls() >+ */ >+ public int getNumberOfControls() { >+ return 2; >+ } >+ >+ /** >+ * Lazily create and return the Combo control. >+ */ >+ public Combo getComboBoxControl(Composite parent) { >+ if (fCombo == null) { >+ fCombo = new Combo(parent, SWT.READ_ONLY); >+ for (int i = 0; i < fEntryNamesAndValues.length; i++) { >+ fCombo.add(fEntryNamesAndValues[i][0], i); >+ } >+ >+ fCombo.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent evt) { >+ String oldValue = fValue; >+ String name = fCombo.getText(); >+ fValue = getValueForName(name); >+ setPresentsDefaultValue(false); >+ fireValueChanged(VALUE, oldValue, fValue); >+ } >+ }); >+ } >+ return fCombo; >+ } >+ >+ /** >+ * Given the name (label) of an entry, return the corresponding value. >+ */ >+ protected String getValueForName(String name) { >+ for (int i = 0; i < fEntryNamesAndValues.length; i++) { >+ String[] entry = fEntryNamesAndValues[i]; >+ if (name.equals(entry[0])) { >+ return entry[1]; >+ } >+ } >+ return fEntryNamesAndValues[0][0]; >+ } >+ >+ /** >+ * Set the name in the combo widget to match the specified value. >+ */ >+ protected void updateComboForValue(String value) { >+ fValue = value; >+ for (int i = 0; i < fEntryNamesAndValues.length; i++) { >+ if (value.equals(fEntryNamesAndValues[i][1])) { >+ fCombo.setText(fEntryNamesAndValues[i][0]); >+ return; >+ } >+ } >+ if (fEntryNamesAndValues.length > 0) { >+ fValue = fEntryNamesAndValues[0][1]; >+ } >+ } >+} >Index: j9/org/eclipse/jdt/internal/launching/j9/IJ9Connector.java >=================================================================== >RCS file: j9/org/eclipse/jdt/internal/launching/j9/IJ9Connector.java >diff -N j9/org/eclipse/jdt/internal/launching/j9/IJ9Connector.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ j9/org/eclipse/jdt/internal/launching/j9/IJ9Connector.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,32 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.launching.j9; >+ >+import java.util.Map; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.debug.core.ILaunch; >+import org.eclipse.jdt.launching.IVMInstall; >+ >+public interface IJ9Connector { >+ >+ public void postLaunch(Map arguments, IProgressMonitor monitor, ILaunch launch) throws CoreException; >+ public void preLaunch(Map arguments, IProgressMonitor monitor, ILaunch launch) throws CoreException; >+ >+ /** >+ * Run the connector. >+ */ >+ public void connect(Map arguments, IProgressMonitor monitor, ILaunch launch) throws CoreException; >+ >+ public IVMInstall getIVMInstall(); >+ public void setIVMInstall(IVMInstall vm); >+} >Index: j9/org/eclipse/jdt/internal/launching/j9/J9ConnectorDelegate.java >=================================================================== >RCS file: j9/org/eclipse/jdt/internal/launching/j9/J9ConnectorDelegate.java >diff -N j9/org/eclipse/jdt/internal/launching/j9/J9ConnectorDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ j9/org/eclipse/jdt/internal/launching/j9/J9ConnectorDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,407 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.launching.j9; >+ >+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.debug.core.ILaunch; >+import org.eclipse.jdt.debug.core.JDIDebugModel; >+import org.eclipse.jdt.launching.IVMConnector; >+import org.eclipse.jdt.launching.IVMInstall; >+import org.eclipse.jdt.launching.j9.IJ9LaunchConfigurationConstants; >+import org.eclipse.jdt.launching.j9.J9Launching; >+ >+import com.sun.jdi.connect.Connector; >+ >+/** >+ * Delegating J9 connector. For 2.0 VMs it provides a SocketAttachConnector, >+ * and for 2.1 VMs it launches the listening socket and creates a Listening >+ * connector. >+ */ >+public class J9ConnectorDelegate implements IVMConnector { >+ public final static String ARG_HOSTNAME = "hostname"; //$NON-NLS-1$ >+ public final static String ARG_PORT = "port"; //$NON-NLS-1$ >+ public final static String ARG_DBGPORT = "debugport"; //$NON-NLS-1$ >+ public final static String ARG_DEBUG_TIMEOUT = "debug_timeout"; //$NON-NLS-1$ >+ public final static String ARG_VM_INSTALL_NAME = "proxyvm"; //$NON-NLS-1$ >+ public final static String ARG_PROXY_OPTIONS = "proxy_options"; //$NON-NLS-1$ >+ >+ // tbd: Note that the identifier "Default" is stored in launch configs >+ // Therefore, the string should not be translated for nls >+ public final static String DEFAULT_JRE_NAME = "Default"; //$NON-NLS-1$ >+ >+ private IJ9Connector connector; >+ private J9VMInstall vmInstall; >+ >+ /** >+ * Constructor for J9Connector. >+ */ >+ public J9ConnectorDelegate() { >+ super(); >+ } >+ >+ /** >+ * Set up this delegate to use the following VM >+ */ >+ public void configure(J9VMInstall vmInstall) throws CoreException { >+ this.vmInstall = vmInstall; >+ if (vmInstall.is21J9Version()) { >+ connector = new J9ListeningConnector(); >+ } >+ else { >+ connector = new J9SocketAttachConnector(); >+ } >+ connector.setIVMInstall(this.getVmInstall()); >+ } >+ >+ public void postLaunch(Map arguments, IProgressMonitor monitor, ILaunch launch) throws CoreException { >+ connector.postLaunch(arguments, monitor, launch); >+ } >+ >+ public void preLaunch(Map arguments, IProgressMonitor monitor, ILaunch launch) throws CoreException { >+ connector.preLaunch(arguments, monitor, launch); >+ } >+ >+ /** >+ * @see org.eclipse.jdt.launching.IVMConnector#connect(Map, IProgressMonitor, ILaunch) >+ */ >+ public void connect( >+ Map arguments, >+ IProgressMonitor monitor, >+ ILaunch launch) >+ throws CoreException { >+ >+ connector.connect(arguments, monitor, launch); >+ } >+ >+ /** >+ * @see org.eclipse.jdt.launching.IVMConnector#getName() >+ */ >+ public String getName() { >+ return J9LauncherMessages.getString("J9SocketAttachConnector.J9_21_(Proxied_Socket_Attach)"); //$NON-NLS-1$ >+ } >+ >+ /** >+ * @see org.eclipse.jdt.launching.IVMConnector#getIdentifier() >+ */ >+ public String getIdentifier() { >+ return IJ9LaunchConfigurationConstants.ID_J9_SOCKET_ATTACH_VM_CONNECTOR; >+ } >+ >+ /* >+ * Return names of configured j9 vm installs. >+ */ >+ private static List getJ9VMInstallNames() { >+ IVMInstall vmInstalls[] = J9Launching.getJ9VMInstalls(); >+ ArrayList names = new ArrayList(); >+ for (int i = 0; i < vmInstalls.length; i++) { >+ names.add(vmInstalls[i].getName()); >+ } >+ return names; >+ } >+ >+ /** >+ * @see org.eclipse.jdt.launching.IVMConnector#getDefaultArguments() >+ */ >+ public Map getDefaultArguments() throws CoreException { >+ Map def = >+ J9Launching.getAttachingConnector() >+ .defaultArguments(); >+ String label = J9LauncherMessages.getString("J9ConnectorDelegate.&Host_1"); //$NON-NLS-1$ >+ String description = J9LauncherMessages.getString("J9ConnectorDelegate.Host_2"); //$NON-NLS-1$ >+ Connector.StringArgument hostArg = >+ new StringArgumentImpl( >+ ARG_HOSTNAME, >+ description, >+ label, >+ true); >+ hostArg.setValue(J9ListeningConnector.getLocalIP()); >+ def.put(hostArg.name(), hostArg); >+ >+ >+ //98093Connector.IntegerArgument portArg = >+ //98093 (Connector.IntegerArgument) def.get(ARG_PORT); >+ //98093portArg.setValue(IJ9LaunchConfigurationConstants.DEFAULT_DEBUG_PORT); >+ //98093 >+ label = >+ J9LauncherMessages.getString( >+ "J9ConnectorDelegate.&Port"); //$NON-NLS-1$ >+ description = J9LauncherMessages.getString("J9ConnectorDelegate.Port"); //$NON-NLS-1$ >+ Connector.IntegerArgument portArg = >+ new IntegerArgumentImpl( >+ ARG_PORT, >+ description, >+ label, >+ true, >+ 1, >+ Integer.MAX_VALUE); >+ portArg.setValue(IJ9LaunchConfigurationConstants.DEFAULT_DEBUG_PORT); >+ def.put(portArg.name(), portArg); >+ // end 98093 fix >+ >+ List names = getJ9VMInstallNames(); >+ names.add(0, DEFAULT_JRE_NAME); >+ >+ >+ label = >+ J9LauncherMessages.getString( >+ "J9SocketAttachConnector.Debug_timeout"); //$NON-NLS-1$ >+ description = J9LauncherMessages.getString("J9ConnectorDelegate.Debug_timeout_(ms)_3"); //$NON-NLS-1$ >+ Connector.IntegerArgument timeoutArg = >+ new IntegerArgumentImpl( >+ ARG_DEBUG_TIMEOUT, >+ description, >+ label, >+ false, >+ 1, >+ Integer.MAX_VALUE); >+ int timeout = Math.max(JDIDebugModel.getPreferences().getInt(JDIDebugModel.PREF_REQUEST_TIMEOUT), 120000); >+ timeoutArg.setValue(timeout); >+ def.put(timeoutArg.name(), timeoutArg); >+ >+ label = >+ J9LauncherMessages.getString( >+ "J9SocketAttachConnector.JRE_(used_for_debug_proxy)"); //$NON-NLS-1$ >+ description = J9LauncherMessages.getString("J9ConnectorDelegate.JRE_(used_for_debug_proxy)_4"); //$NON-NLS-1$ >+ Connector.SelectedArgument vmArg = >+ new SelectedArgumentImpl( >+ ARG_VM_INSTALL_NAME, >+ description, >+ label, >+ true, >+ names); >+ vmArg.setValue(DEFAULT_JRE_NAME); >+ def.put(vmArg.name(), vmArg); >+ >+ label = >+ J9LauncherMessages.getString( >+ "J9SocketAttachConnector.Proxy_options"); //$NON-NLS-1$ >+ description = J9LauncherMessages.getString("J9ConnectorDelegate.Proxy_options_5"); //$NON-NLS-1$ >+ Connector.StringArgument proxyOptionsArg = >+ new StringArgumentImpl( >+ ARG_PROXY_OPTIONS, >+ description, >+ label, >+ true); >+ proxyOptionsArg.setValue(""); //$NON-NLS-1$ >+ def.put(proxyOptionsArg.name(), proxyOptionsArg); >+ >+ return def; >+ } >+ >+ /** >+ * @see org.eclipse.jdt.launching.IVMConnector#getArgumentOrder() >+ */ >+ public List getArgumentOrder() { >+ List list = new ArrayList(4); >+ list.add(ARG_HOSTNAME); >+ list.add(ARG_PORT); >+ list.add(ARG_DEBUG_TIMEOUT); >+ list.add(ARG_VM_INSTALL_NAME); >+ list.add(ARG_PROXY_OPTIONS); >+ return list; >+ } >+ >+ /** >+ * Argument class for arguments that are used to establish a connection. >+ */ >+ public abstract class ArgumentImpl implements com.sun.jdi.connect.Connector.Argument { >+ private String fName; >+ private String fDescription; >+ private String fLabel; >+ private boolean fMustSpecify; >+ >+ protected ArgumentImpl(String name, String description, String label, boolean mustSpecify) { >+ fName = name; >+ fLabel = label; >+ fDescription = description; >+ fMustSpecify = mustSpecify; >+ } >+ >+ public String name() { >+ return fName; >+ } >+ >+ public String description() { >+ return fDescription; >+ } >+ >+ public String label() { >+ return fLabel; >+ } >+ >+ public boolean mustSpecify() { >+ return fMustSpecify; >+ } >+ >+ public abstract String value(); >+ public abstract void setValue(String value); >+ public abstract boolean isValid(String value); >+ public abstract String toString(); >+ } >+ >+ public class StringArgumentImpl extends ArgumentImpl implements com.sun.jdi.connect.Connector.StringArgument { >+ private String fValue; >+ >+ protected StringArgumentImpl(String name, String description, String label, boolean mustSpecify) { >+ super(name, description, label, mustSpecify); >+ } >+ >+ public String value() { >+ return fValue; >+ } >+ >+ public void setValue(String value) { >+ fValue = value; >+ } >+ >+ public boolean isValid(String value) { >+ return true; >+ } >+ >+ public String toString() { >+ return fValue; >+ } >+ >+ } >+ >+ public class IntegerArgumentImpl extends ArgumentImpl implements com.sun.jdi.connect.Connector.IntegerArgument { >+ private Integer fValue; >+ private int fMin; >+ private int fMax; >+ >+ protected IntegerArgumentImpl(String name, String description, String label, boolean mustSpecify, int min, int max) { >+ super(name, description, label, mustSpecify); >+ fMin = min; >+ fMax = max; >+ } >+ >+ public String value() { >+ return fValue.toString(); >+ } >+ >+ public void setValue(String value) { >+ fValue = new Integer(value); >+ } >+ >+ public boolean isValid(String value) { >+ Integer val; >+ try { >+ val = new Integer(value); >+ } catch (NumberFormatException e) { >+ return false; >+ } >+ return isValid(val.intValue()); >+ } >+ >+ public String toString() { >+ return value(); >+ } >+ >+ public int intValue() { >+ return fValue.intValue(); >+ } >+ >+ public void setValue(int value) { >+ fValue = new Integer(value); >+ } >+ >+ public int min() { >+ return fMin; >+ } >+ >+ public int max() { >+ return fMax; >+ } >+ >+ public boolean isValid(int value) { >+ return fMin <= value && value <= fMax; >+ } >+ >+ public String stringValueOf(int value) { >+ return new Integer(value).toString(); >+ } >+ } >+ >+ public class BooleanArgumentImpl extends ArgumentImpl implements com.sun.jdi.connect.Connector.BooleanArgument { >+ private Boolean fValue; >+ >+ protected BooleanArgumentImpl(String name, String description, String label, boolean mustSpecify) { >+ super(name, description, label, mustSpecify); >+ } >+ >+ public String value() { >+ return fValue.toString(); >+ } >+ >+ public void setValue(String value) { >+ fValue = new Boolean(value); >+ } >+ >+ public boolean isValid(String value) { >+ return true; >+ } >+ >+ public String toString() { >+ return value(); >+ } >+ >+ public boolean booleanValue() { >+ return fValue.booleanValue(); >+ } >+ >+ public void setValue(boolean value) { >+ fValue = new Boolean(value); >+ } >+ >+ public String stringValueOf(boolean value) { >+ return new Boolean(value).toString(); >+ } >+ } >+ >+ public class SelectedArgumentImpl extends StringArgumentImpl implements com.sun.jdi.connect.Connector.SelectedArgument { >+ private List fChoices; >+ >+ protected SelectedArgumentImpl(String name, String description, String label, boolean mustSpecify, List choices) { >+ super(name, description, label, mustSpecify); >+ fChoices = choices; >+ } >+ >+ public List choices() { >+ return fChoices; >+ } >+ >+ public boolean isValid(java.lang.String value) { >+ return fChoices.contains(value); >+ } >+ } >+ >+ >+ /** >+ * Returns the connector. >+ * @return IJ9Connector >+ */ >+ public IJ9Connector getConnector() { >+ return connector; >+ } >+ /** >+ * Returns the vmInstall. >+ * @return J9VMInstall >+ */ >+ public J9VMInstall getVmInstall() { >+ return vmInstall; >+ } >+ >+} >Index: j9/org/eclipse/jdt/internal/launching/j9/J9DebugServerVMRunner.java >=================================================================== >RCS file: j9/org/eclipse/jdt/internal/launching/j9/J9DebugServerVMRunner.java >diff -N j9/org/eclipse/jdt/internal/launching/j9/J9DebugServerVMRunner.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ j9/org/eclipse/jdt/internal/launching/j9/J9DebugServerVMRunner.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,218 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.launching.j9; >+ >+import java.io.File; >+import java.util.ArrayList; >+import java.util.HashMap; >+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.debug.core.DebugPlugin; >+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; >+import org.eclipse.jdt.launching.j9.J9Launching; >+ >+/** >+ * Currently this sets up the >+ * launch such that the VM uses a debug server and the VM calls home to Eclipse >+ * to establish the debug connection. This configuration should be suitable for >+ * all of our J9 VM 2.1 launches. This class makes the assumption that the debug >+ * server will die when the VM dies. >+ */ >+public class J9DebugServerVMRunner extends J9VMRunner { >+ >+ /** >+ * Constructor for J921VMRunner. >+ * >+ * @param vmInstance the VM instance. >+ */ >+ public J9DebugServerVMRunner(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 { >+ >+ J9ListeningConnector connectorManager = null; >+ Process dbgsvrOSProcess = null, vmOSProcess = null; >+ >+ try { >+ if (monitor == null) { >+ monitor = new NullProgressMonitor(); >+ } >+ >+ // check for cancellation >+ if (monitor.isCanceled()) { >+ return; >+ } >+ >+ // Convert configuration to use -jxe option if requested. >+ config = J9Launching.adaptVMRunnerConfiguration(config, getJ9VMInstall()); >+ >+ // Add VM options extracted from rules found on the bootclasspath >+ addVMOptionsFromRules(config); >+ File workingDir = getWorkingDir(config); >+ >+ // check for cancellation >+ if (monitor.isCanceled()) { >+ return; >+ } >+ >+ // Starts up the server socket in eclipse for connections from the debugger. >+ Map args = launch.getLaunchConfiguration().getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE_SPECIFIC_ATTRS_MAP, new HashMap(3)); >+ try { >+ args.put(J9ConnectorDelegate.ARG_DBGPORT, Integer.toString(J9ListeningConnector.getFreePort())); >+ connectorManager = new J9ListeningConnector(); >+ connectorManager.setIVMInstall(fVMInstance); >+ connectorManager.preLaunch(args, monitor, launch); >+ } >+ catch (Exception e) { >+ J9LaunchingPlugin.abort(J9LauncherMessages.getString("J9Launching.Error_when_executing_j9_1"), e, IJavaLaunchConfigurationConstants.ERR_INTERNAL_ERROR); //$NON-NLS-1$ >+ return; >+ } >+ >+ >+ // check for cancellation >+ if (monitor.isCanceled()) { >+ return; >+ } >+ >+ String[] cmdLine = getCmdLine(connectorManager, config); >+ //start the VM >+ vmOSProcess= exec(cmdLine, workingDir); >+ if (vmOSProcess == null) { >+ return; >+ } >+ >+ // check for cancellation >+ if (monitor.isCanceled()) { >+ return; >+ } >+ >+ try { >+ IProcess vmProcess= DebugPlugin.newProcess(launch, vmOSProcess, J9Launching.renderProcessLabel(cmdLine)); >+ vmProcess.setAttribute(IProcess.ATTR_CMDLINE, J9Launching.renderCommandLine(cmdLine)); >+ if (monitor.isCanceled()) { >+ return; >+ } >+ Map map = new HashMap(args); >+ map.put(J9ListeningConnector.ARG_LABEL, J9Launching.renderDebugTarget(config.getClassToLaunch(), connectorManager.getConnectorPort())); //$NON-NLS-1$ >+ map.put(J9ListeningConnector.ARG_VMPROCESS, vmProcess); >+ connectorManager.connect(map, monitor, launch); >+ >+ //set the two processes to null to avoid them being killed by cleanUp >+ vmOSProcess = dbgsvrOSProcess = null; >+ } >+ catch (Exception e) { >+ J9LaunchingPlugin.abort(J9LauncherMessages.getString("J9Launching.Error_when_executing_j9_1"), e, IJavaLaunchConfigurationConstants.ERR_INTERNAL_ERROR); //$NON-NLS-1$ >+ } >+ } >+ finally { >+ cleanUp(vmOSProcess, dbgsvrOSProcess, connectorManager); >+ } >+ } >+ >+ /** >+ * Method getCmdLine. Taken and modified from J9DebugVMRunner. >+ * >+ * @param debugServerPort >+ * @param connectorPort >+ * @param config >+ * @return String[] >+ */ >+ private String[] getCmdLine( >+ J9ListeningConnector connector, >+ VMRunnerConfiguration config) throws CoreException { >+ String location= getJDKLocation(); >+ String program= constructProgramString(location, config); >+ List arguments= new ArrayList(); >+ >+ arguments.add(program); >+ >+ String[] bootCP= config.getBootClassPath(); >+ String[] cp= config.getClassPath(); >+ String[] vmArgs= config.getVMArguments(); >+ String[] programArgs= config.getProgramArguments(); >+ >+ if (bootCP != null) { >+ String bootpathOpt = isOldJ9Version() ? "-bp:" : "-Xbootclasspath:"; //$NON-NLS-1$ //$NON-NLS-2$ >+ if (bootCP.length > 0) { >+ arguments.add(bootpathOpt+convertClassPath(bootCP)); >+ } else { >+ // empty >+// arguments.add(bootpathOpt); >+ } >+ } >+ >+ if (cp.length > 0) { >+ arguments.add("-classpath"); //$NON-NLS-1$ >+ arguments.add(convertClassPath(cp)); >+ } >+ if (connector.getDebugServerPort() != -1) { >+ arguments.add("-Xrdbginfo:" + J9ListeningConnector.getLocalIP() + ":" + connector.getDebugServerPort()); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ >+ if (connector.getConnectorPort() != -1) { >+ arguments.add("-Xrunjdwp:address=" + J9ListeningConnector.getLocalIP() + ":" + connector.getConnectorPort() + ",transport=dt_socket"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >+ arguments.add("-Xdebug"); //$NON-NLS-1$ >+ } >+ >+ >+ addArguments(vmArgs, arguments); >+ arguments.add(config.getClassToLaunch()); >+ addArguments(programArgs, arguments); >+ >+ String[] cmdLine= new String[arguments.size()]; >+ arguments.toArray(cmdLine); >+ return cmdLine; >+ } >+ >+ >+ /** >+ * Stop all processes that need stopping and stop the ListeningConnection >+ * from listening any more. >+ * >+ * @param dbgsvrOSProcess >+ * @param vmOSProcess >+ * @param manager >+ */ >+ private void cleanUp(Process vmOSProcess, >+ Process dbgsvrOSProcess, >+ J9ListeningConnector manager ) throws CoreException { >+ >+ if (dbgsvrOSProcess != null) { >+ dbgsvrOSProcess.destroy(); >+ } >+ if (vmOSProcess != null) { >+ vmOSProcess.destroy(); >+ } >+ >+ try { >+ manager.stopConnector(); >+ } >+ catch (Exception e) { >+ J9LaunchingPlugin.abort(J9LauncherMessages.getString("J9Launching.Error_when_executing_j9_1"), e, IJavaLaunchConfigurationConstants.ERR_INTERNAL_ERROR); //$NON-NLS-1$ >+ } >+ } >+} >Index: j9/org/eclipse/jdt/internal/launching/j9/J9DebugVMRunner.java >=================================================================== >RCS file: j9/org/eclipse/jdt/internal/launching/j9/J9DebugVMRunner.java >diff -N j9/org/eclipse/jdt/internal/launching/j9/J9DebugVMRunner.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ j9/org/eclipse/jdt/internal/launching/j9/J9DebugVMRunner.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,153 @@ >+/******************************************************************************* >+ * Copyright (c) 2002, 2004 IBM Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Lester Lopez (IBM Corp.) - Support latest version of JVM and Eclipse. >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.launching.j9; >+ >+import java.io.File; >+import java.io.IOException; >+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.debug.core.DebugPlugin; >+import org.eclipse.debug.core.ILaunch; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.model.IProcess; >+import org.eclipse.jdt.debug.core.JDIDebugModel; >+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; >+import org.eclipse.jdt.launching.IVMInstall; >+import org.eclipse.jdt.launching.SocketUtil; >+import org.eclipse.jdt.launching.VMRunnerConfiguration; >+import org.eclipse.jdt.launching.j9.IJ9LaunchConfigurationConstants; >+import org.eclipse.jdt.launching.j9.J9Launching; >+ >+import com.sun.jdi.VMDisconnectedException; >+import com.sun.jdi.VirtualMachine; >+import com.sun.jdi.connect.IllegalConnectorArgumentsException; >+ >+public class J9DebugVMRunner extends J9VMRunner { >+ >+ // Use 127.0.0.1 to avoid timeout due to potential dns resolution delays >+ private final static String LOCALHOST = "127.0.0.1"; //$NON-NLS-1$ >+ >+ public J9DebugVMRunner(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; >+ } >+ >+ /* >+ * LL: Migration to 3.0: SocketUtil.findUnusedLocalPort() has been deprecated. >+ * Use SocketUtil.findFreePort() instead. >+ */ >+ int port= SocketUtil.findFreePort(); >+ if (port == -1) { >+ abort(J9LauncherMessages.getString("J9DebugVMRunner.Could_not_find_a_free_socket_for_the_debugger"), null, IJavaLaunchConfigurationConstants.ERR_NO_SOCKET_AVAILABLE); //$NON-NLS-1$ >+ } >+ >+ // Convert configuration to use -jxe option if requested. >+ config = J9Launching.adaptVMRunnerConfiguration(config, getJ9VMInstall()); >+ >+ // Add VM options extracted from rules found on the bootclasspath >+ addVMOptionsFromRules(config); >+ >+ String[] cmdLine = getCmdLine(port, -1, null, config); >+ File workingDir = getWorkingDir(config); >+ >+ // check for cancellation >+ if (monitor.isCanceled()) { >+ return; >+ } >+ >+ Process vmOSProcess= exec(cmdLine, workingDir); >+ if (vmOSProcess == null) { >+ return; >+ } >+ >+ // check for cancellation >+ if (monitor.isCanceled()) { >+ vmOSProcess.destroy(); >+ return; >+ } >+ >+ ILaunchConfiguration configuration = launch.getLaunchConfiguration(); >+ String[] symbolPath = J9Launching.getResolvedSymbolLookupPath(configuration); >+ >+ String debugTimeout= null; >+ Map vmSpecificAttributes= config.getVMSpecificAttributesMap(); >+ if (vmSpecificAttributes != null) { >+ debugTimeout = (String)vmSpecificAttributes.get(IJ9LaunchConfigurationConstants.ATTR_DEBUG_TIMEOUT); >+ } >+ >+ >+ Process proxyOSProcess= null; >+ try { >+ J9ProxyConnection proxyConnector = new J9ProxyConnection(LOCALHOST, Integer.toString(port), symbolPath, debugTimeout, (J9VMInstall)fVMInstance, ""); //$NON-NLS-1$ >+ proxyOSProcess= proxyConnector.runProxy(); >+ >+ IProcess vmProcess= DebugPlugin.newProcess(launch, vmOSProcess, J9Launching.renderProcessLabel(cmdLine)); >+ IProcess proxyProcess= DebugPlugin.newProcess(launch, proxyOSProcess, J9Launching.renderProcessLabel(proxyConnector.getProxyCommand())); >+ vmProcess.setAttribute(IProcess.ATTR_CMDLINE, J9Launching.renderCommandLine(cmdLine)); >+ proxyProcess.setAttribute(IProcess.ATTR_CMDLINE, J9Launching.renderCommandLine(proxyConnector.getProxyCommand())); >+ >+ boolean retry= false; >+ do { >+ try { >+ // check for cancellation >+ if (monitor.isCanceled()) { >+ vmOSProcess.destroy(); >+ proxyOSProcess.destroy(); >+ return; >+ } >+ >+ VirtualMachine vm = proxyConnector.connect(monitor); >+ JDIDebugModel.newDebugTarget(launch, vm, J9Launching.renderDebugTarget(config.getClassToLaunch(), port), vmProcess, true, false); >+ return; >+ } catch (IOException e) { >+ String errorMessage= vmProcess.getStreamsProxy().getErrorStreamMonitor().getContents(); >+ if (errorMessage.length() == 0) { >+ errorMessage= proxyProcess.getStreamsProxy().getErrorStreamMonitor().getContents(); >+ } >+ retry = J9ProxyConnection.handleConnectException(this, e, errorMessage); >+ } catch (VMDisconnectedException e) { >+ String errorMessage= vmProcess.getStreamsProxy().getErrorStreamMonitor().getContents(); >+ if (errorMessage.length() == 0) { >+ errorMessage= proxyProcess.getStreamsProxy().getErrorStreamMonitor().getContents(); >+ } >+ retry = J9ProxyConnection.handleConnectException(this, e, errorMessage); >+ } catch (IllegalConnectorArgumentsException e) { >+ retry= false; >+ abort(J9LauncherMessages.getString("J9DebugVMRunner.Could_not_connect_to_VM"), e, IJavaLaunchConfigurationConstants.ERR_CONNECTION_FAILED); //$NON-NLS-1$ >+ } >+ } while (retry); >+ } catch (CoreException e) { >+ vmOSProcess.destroy(); >+ if (proxyOSProcess != null) proxyOSProcess.destroy(); >+ throw e; >+ } >+ vmOSProcess.destroy(); >+ proxyOSProcess.destroy(); >+ } >+ >+} >Index: j9/org/eclipse/jdt/internal/launching/j9/J9LauncherMessages.java >=================================================================== >RCS file: j9/org/eclipse/jdt/internal/launching/j9/J9LauncherMessages.java >diff -N j9/org/eclipse/jdt/internal/launching/j9/J9LauncherMessages.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ j9/org/eclipse/jdt/internal/launching/j9/J9LauncherMessages.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,32 @@ >+/******************************************************************************* >+ * Copyright (c) 2002, 2003 IBM Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.launching.j9; >+ >+import java.util.MissingResourceException; >+import java.util.ResourceBundle; >+ >+public class J9LauncherMessages { >+ >+ private static final String RESOURCE_BUNDLE= "org.eclipse.jdt.internal.launching.j9.J9LauncherMessages";//$NON-NLS-1$ >+ >+ private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE); >+ >+ private J9LauncherMessages() { >+ } >+ >+ public static String getString(String key) { >+ try { >+ return fgResourceBundle.getString(key); >+ } catch (MissingResourceException e) { >+ return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ >+ } >+ } >+} >Index: j9/org/eclipse/jdt/internal/launching/j9/J9LauncherMessages.properties >=================================================================== >RCS file: j9/org/eclipse/jdt/internal/launching/j9/J9LauncherMessages.properties >diff -N j9/org/eclipse/jdt/internal/launching/j9/J9LauncherMessages.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ j9/org/eclipse/jdt/internal/launching/j9/J9LauncherMessages.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,56 @@ >+######################################################################### >+# Copyright (c) 2002, 2004 IBM Corporation. >+# All rights reserved. This program and the accompanying materials >+# are made available under the terms of the Eclipse Public License v1.0 >+# which accompanies this distribution, and is available at >+# http://www.eclipse.org/legal/epl-v10.html >+# >+# Contributors: >+# IBM Corporation - Initial implementation >+########################################################################## >+ >+J9DebugVMRunner.Could_not_find_a_free_socket_for_the_debugger=Could not find a free socket for the debugger >+J9DebugVMRunner.Could_not_connect_to_VM=Could not connect to VM >+ >+J9VMType.error.notRoot=Not a J9 JDK Root; J9 VM executable or system library not found >+J9VMType.name=J9 VM >+ >+J9Launching.format.dbgTarget={0} at localhost:{1} >+J9Launching.format.processLabel={0} ({1}) >+ >+JavaVMRunner.Specified_working_directory_does_not_exist_or_is_not_a_directory=Specified working directory does not exist or is not a directory: {0} >+ >+J9Launching.Socket_attaching_connector_not_available=Socket attaching connector not available >+ >+J9ProxyConnection.Could_not_find_a_free_socket_for_the_proxy=Could not find a free socket for the J9 debug proxy >+J9ProxyConnection.Could_not_start_debug_proxy=Could not start the J9 debug proxy >+ >+#J9SocketAttachConnector.J9_(Proxied_Socket_Attach)=J9 (Proxied Socket Attach) >+J9SocketAttachConnector.J9_21_(Proxied_Socket_Attach)=Not Available (Proxied Socket Attach) >+J9SocketAttachConnector.J9_20_(Proxied_Socket_Attach)=J9 2.0 (Proxied Socket Attach) >+J9SocketAttachConnector.Port_unspecified_for_remote_connection=Port unspecified for remote connection. >+J9SocketAttachConnector.Hostname_unspecified_for_remote_connection=Hostname unspecified for remote connection. >+J9SocketAttachConnector.Proxy_options_unspecified_for_remote_connection=Debug options unspecified for remote connection. >+J9SocketAttachConnector.VM_does_not_exist_for_remote_connection=Debug VM does not exist for remote connection. >+J9SocketAttachConnector.Debug_timeout=De&bug timeout (ms) >+J9SocketAttachConnector.JRE_(used_for_debug_proxy)=J&RE (used for debugging) >+J9SocketAttachConnector.Failed_to_connect_to_remote_VM_because_of_unknown_host=Failed to connect to remote VM because of unknown host \"{0}\"" >+J9SocketAttachConnector.Failed_to_connect_to_remote_VM=Failed to connect to remote VM >+J9SocketAttachConnector.Proxy_options=Debug &options >+J9Launching.General_settings_for_J9_Plugin_1=General settings for J9 Plugin. >+J9Launching.Default_J9_VM_2=&Default J9 VM: >+J9Launching.J9Pref_Notice_String=Note: this preference is updated when a J9 VM is set as default. In the event that a J9 VM is not the default (see Java->Installed JREs), this preference indicates the default J9 VM. >+J9Launching.Timeout_while_connecting_to_VM,_try_using_a_different_port_number_1=Timeout while connecting to VM, try using a different port number >+J9Launching.Error_when_executing_j9_1=Error when executing j9 >+J9VMCommandTab.Run_as_console=&Run as console application >+J9VMCommandTab.Run_from_executable_archive=&Execute using -jxe or -jar option, if applicable >+J9VMCommandTab.J9_VM_specific_attributes_2=J9 VM specific attributes >+J9ConnectorDelegate.&Host_1=&Host >+J9ConnectorDelegate.Host_2=Host >+J9ConnectorDelegate.&Port=&Port >+J9ConnectorDelegate.Port=Port >+J9ConnectorDelegate.Debug_timeout_(ms)_3=Debug timeout (ms) >+J9ConnectorDelegate.JRE_(used_for_debug_proxy)_4=J&RE (used for debugging) >+J9ConnectorDelegate.Proxy_options_5=Debug &options >+J9_VM___4=J9 VM: >+J9PropertyPage.J9_VM_Not_Found_3=J9 VM Not Found >Index: j9/org/eclipse/jdt/internal/launching/j9/J9LaunchingPlugin.java >=================================================================== >RCS file: j9/org/eclipse/jdt/internal/launching/j9/J9LaunchingPlugin.java >diff -N j9/org/eclipse/jdt/internal/launching/j9/J9LaunchingPlugin.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ j9/org/eclipse/jdt/internal/launching/j9/J9LaunchingPlugin.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,114 @@ >+/******************************************************************************* >+ * Copyright (c) 2002, 2004 IBM Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Lester Lopez (IBM Corp.) - Support latest version of JVM and Eclipse. >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.launching.j9; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.jface.util.IPropertyChangeListener; >+import org.eclipse.ui.plugin.AbstractUIPlugin; >+ >+public class J9LaunchingPlugin extends AbstractUIPlugin { >+ private static J9LaunchingPlugin fgPlugin; >+ /** >+ * Constructor for J9LaunchingPlugin >+ */ >+ public J9LaunchingPlugin() { >+ super(); >+ fgPlugin = this; >+ } >+ >+ public static J9LaunchingPlugin getDefault() { >+ return fgPlugin; >+ } >+ >+ /** >+ * Convenience method which returns the unique identifier of this plugin. >+ */ >+ public static String getUniqueIdentifier() { >+ if (getDefault() == null) { >+ // If the default instance is not yet initialized, >+ // return a static identifier. This identifier must >+ // match the plugin id defined in plugin.xml >+ return "org.eclipse.jdt.launching.j9"; //$NON-NLS-1$ >+ } >+ /* >+ * LL: Migration to 3.0: IPluginDescriptor.getUniqueIdentifier() has been deprecated. >+ * Use Bundle.getSymbolicName() instead. >+ */ >+ return getDefault().getBundle().getSymbolicName(); >+ } >+ >+ /** >+ * Throws a core exception with an error status object built from >+ * the given message, lower level exception, and error code. >+ * >+ * @param message the status message >+ * @param exception lower level exception associated with the >+ * error, or <code>null</code> if none >+ * @param code error code >+ */ >+ public static void abort(String message, Throwable exception, int code) throws CoreException { >+ Status status = new Status(IStatus.ERROR, J9LaunchingPlugin.getUniqueIdentifier(), code, message, exception); >+ getDefault().getLog().log(status); >+ throw new CoreException(status); >+ } >+ public static void log(String message, Throwable exception, int code) throws CoreException { >+ Status status = new Status(IStatus.ERROR, J9LaunchingPlugin.getUniqueIdentifier(), code, message, exception); >+ getDefault().getLog().log(status); >+ } >+ >+ /** >+ * @see AbstractUIPlugin#initializeDefaultPreferences >+ */ >+ protected void initializeDefaultPreferences(IPreferenceStore prefs) { >+ J9PreferencePage.initDefaults(prefs); >+ } >+ >+ public void addPreferenceStoreChangeListener(IPropertyChangeListener changeListener) { >+ getPreferenceStore().addPropertyChangeListener(changeListener); >+ } >+ >+ /** >+ * This is used to store a temporary version of the preferred J9 Location until >+ * the Project has been initialized and the project properties can be used. >+ * @return >+ */ >+ /* >+ * This may have problems if the new project wizard is being used twice at the same time. >+ */ >+ public String getCurrentJ9Path() >+ { >+ IPreferenceStore store = getPreferenceStore(); >+ if (store != null) >+ { >+ String currentPath = >+ store.getString( >+ "currentJ9Path"); >+ return currentPath; >+ } >+ else >+ return null; >+ } >+ public void setCurrentJ9Path (String currentPath) >+ { >+ IPreferenceStore store = getPreferenceStore(); >+ if (store != null) >+ { >+ store.setValue("currentJ9Path", currentPath); >+ } >+ >+ } >+ >+ >+} >Index: j9/org/eclipse/jdt/internal/launching/j9/J9ListeningConnector.java >=================================================================== >RCS file: j9/org/eclipse/jdt/internal/launching/j9/J9ListeningConnector.java >diff -N j9/org/eclipse/jdt/internal/launching/j9/J9ListeningConnector.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ j9/org/eclipse/jdt/internal/launching/j9/J9ListeningConnector.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,443 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.launching.j9; >+ >+import java.io.File; >+import java.io.IOException; >+import java.net.ConnectException; >+import java.net.InetAddress; >+import java.net.Socket; >+import java.net.SocketException; >+import java.net.UnknownHostException; >+import java.util.ArrayList; >+import java.util.Map; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.debug.core.ILaunch; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.model.IProcess; >+import org.eclipse.jdt.debug.core.JDIDebugModel; >+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; >+import org.eclipse.jdt.launching.IVMInstall; >+import org.eclipse.jdt.launching.SocketUtil; >+import org.eclipse.jdt.launching.j9.J9Launching; >+ >+import com.sun.jdi.VirtualMachine; >+import com.sun.jdi.connect.Connector; >+import com.sun.jdi.connect.IllegalConnectorArgumentsException; >+import com.sun.jdi.connect.ListeningConnector; >+ >+ >+/** >+ * Utility class that will help manage the lifecycle of ListeningConnectors. >+ * This could be further extended to also support the launching of the debug >+ * server. In this way any runner/launch config that needs to support 2.1 needs >+ * only launch the VM. >+ * >+ * Implements IVMConnector for use in the device launching strategies. >+ */ >+public class J9ListeningConnector implements IJ9Connector { >+ >+ public final static String ARG_LABEL = "org.eclipse.jdt.internal.launching.j9.J9ListeningConnection.LABEL"; //$NON-NLS-1$ >+ public final static String ARG_VMPROCESS = "org.eclipse.jdt.internal.launching.j9.J9ListeningConnection.VMPROCESS"; //$NON-NLS-1$ >+ public final static String ARG_TIMEOUT = "timeout"; //$NON-NLS-1$ >+ >+ >+ private ListeningConnector fConnector; >+ private Map fConnectorMap; >+ private int fConnectorPort, fDebugServerPort = -1; >+ >+ private IVMInstall fIVMInstall; >+ >+ /** >+ * Create a ListeningConnectionManager that will manage the lifecycle of >+ * ListeningConnections. >+ */ >+ public J9ListeningConnector() { >+ >+ } >+ >+ /** >+ * @return "org.eclipse.jdt.launching.j9" >+ */ >+ protected String getPluginIdentifier() { >+ return "org.eclipse.jdt.launching.j9"; //$NON-NLS-1$ >+ } >+ >+ /** >+ * Stops the connector from listening for incomming connections if it is doing so. >+ */ >+ public void stopConnector() throws IOException, IllegalConnectorArgumentsException { >+ if (fConnector != null) { >+ fConnector.stopListening(fConnectorMap); >+ } >+ } >+ >+ /** >+ * Configure the connector to use the proper port and timeout values. >+ */ >+ public void setupConnector(Map map) throws IOException, CoreException, IllegalConnectorArgumentsException { >+ fConnector = J9Launching.getListeningConnector(); >+ fConnectorMap = fConnector.defaultArguments(); >+ Connector.Argument param= (Connector.Argument) fConnectorMap.get(J9ConnectorDelegate.ARG_PORT); >+ String portString = (String)map.get(J9ConnectorDelegate.ARG_PORT); >+ if (portString == null) { >+ fConnectorPort = getFreePort(); >+ portString = Integer.toString(fConnectorPort); >+ } >+ else { >+ fConnectorPort = Integer.parseInt(portString); >+ } >+ >+ /* Add code here to call a method to check if the specified port is in use. */ >+ //if (isPortInUse(fConnectorPort)) { >+ param.setValue(portString); >+ //} >+ >+ String debugPortString = (String)map.get(J9ConnectorDelegate.ARG_DBGPORT); >+ if (debugPortString != null) { >+ fDebugServerPort = Integer.parseInt(debugPortString); >+ } >+ >+ param = (Connector.Argument) fConnectorMap.get(ARG_TIMEOUT); >+ param.setValue(Integer.toString(getTimeout(map))); >+ } >+ >+ /** >+ * Enables the listening socket of this connector. >+ */ >+ public void startConnector() throws IOException, IllegalConnectorArgumentsException{ >+ fConnector.startListening(fConnectorMap); >+ } >+ >+ /** >+ * @return int the port on which this connector is listening. >+ */ >+ public int getConnectorPort() { >+ return fConnectorPort; >+ } >+ >+ public int getTimeout(Map map) { >+ int timeout; >+ String debugTimeout = (String) map.get(J9ConnectorDelegate.ARG_DEBUG_TIMEOUT); >+ if (debugTimeout != null) { >+ timeout = Integer.parseInt(debugTimeout); >+ } >+ else { >+ timeout = JDIDebugModel.getPreferences().getInt(JDIDebugModel.PREF_REQUEST_TIMEOUT); >+ } >+ return timeout; >+ } >+ >+ public static int getFreePort() throws CoreException { >+ /* >+ * LL: Migration to 3.0: SocketUtil.findUnusedLocalPort() has been deprecated. >+ * Use SocketUtil.findFreePort() instead. >+ */ >+ int freePort = SocketUtil.findFreePort(); >+ if (freePort == -1) { >+ throw new CoreException( >+ new Status( >+ Status.ERROR, >+ J9LaunchingPlugin.getUniqueIdentifier(), >+ IJavaLaunchConfigurationConstants.ERR_NO_SOCKET_AVAILABLE, >+ J9LauncherMessages.getString("J9DebugVMRunner.Could_not_find_a_free_socket_for_the_debugger"), //$NON-NLS-1$ >+ null)); >+ } >+ return freePort; >+ } >+ >+ /** >+ * Checks the ListeningConnector for an incomming debug session and >+ * returns the Virtual Machine associated with it. >+ * >+ * @param monitor >+ * @return VirtualMachine >+ */ >+ private VirtualMachine connect(Map map, IProgressMonitor monitor) throws CoreException, IOException, IllegalConnectorArgumentsException { >+ int timeout = getTimeout(map); >+ long timeLimit = System.currentTimeMillis() + timeout; >+ for(;;) { >+ try { >+ VirtualMachine vm = attach(fConnector, fConnectorMap, timeout); >+ setDebugTimeout(vm, timeout); >+ return vm; >+ } catch (SocketException e) { >+ // Cannot bind to vm or proxy, may still be initializing (for example loading symbol files). >+ if (System.currentTimeMillis() > timeLimit) { >+ throw e; >+ } else { >+ synchronized (fConnector) { >+ try { >+ fConnector.wait(250); >+ } catch(InterruptedException ie) { >+ } >+ } >+ } >+ } >+ } >+ >+ } >+ >+ /** >+ * Method attach. >+ * @param connector >+ * @param map >+ * @param debugTimeout >+ * @return VirtualMachine >+ */ >+ private VirtualMachine attach( >+ final ListeningConnector connector, >+ final Map map, >+ final int debugTimeout) throws IOException, IllegalConnectorArgumentsException, CoreException { >+ final Exception[] exc = new Exception[1]; >+ final VirtualMachine[] vm = new VirtualMachine[1]; >+ Runnable runnable = new Runnable() { >+ public void run() { >+ try { >+ vm[0] = connector.accept(map); >+ } catch (IOException e) { >+ exc[0] = e; >+ } catch (IllegalConnectorArgumentsException e) { >+ exc[0] = e; >+ } >+ } >+ }; >+ Thread thread = new Thread(runnable, "J9ProxyConnection Attach"); //$NON-NLS-1$ >+ thread.start(); >+ try { >+ thread.join(debugTimeout); >+ } catch (InterruptedException e) { >+ } >+ >+ if (exc[0] instanceof IOException) >+ throw (IOException)exc[0]; >+ else if (exc[0] instanceof IllegalConnectorArgumentsException) >+ throw (IllegalConnectorArgumentsException)exc[0]; >+ >+ if (vm[0] == null) { >+ String msg = J9LauncherMessages.getString("J9Launching.Timeout_while_connecting_to_VM,_try_using_a_different_port_number_1"); //$NON-NLS-1$ >+ J9LaunchingPlugin.abort(msg, null, IJavaLaunchConfigurationConstants.ERR_VM_CONNECT_TIMEOUT); >+ } >+ return vm[0]; >+ } >+ >+ /** >+ * Set the debug timeout for the given virtual machine. >+ * >+ * @param vm the VM >+ * @param timeout the timeout >+ */ >+ private void setDebugTimeout(VirtualMachine vm, int timeout) { >+ if (vm instanceof org.eclipse.jdi.VirtualMachine && timeout > 0) { >+ org.eclipse.jdi.VirtualMachine vm2= (org.eclipse.jdi.VirtualMachine)vm; >+ vm2.setRequestTimeout(timeout); >+ } >+ } >+ >+ /** >+ * The new launching strategy is quite different from the old. Before we'd >+ * launch the VM, "forget about it", then in the connector launch the proxy >+ * and use it as the debug target. This doesn't work for the Listening >+ * proxy - we need to know the actual VM process to pipe it's output through >+ * the JDI debug target. Because of this, we pass some bogus 'arguments' >+ * in the argument map. We pass J9ListeningConnector.ARG_LABEL (String) >+ * as the debug label and J9ListeningConnector.ARG_VMPROCESS (IProcess) >+ * which is a reference to the IProcess corresponding to the VM process >+ * (if any). Note that this method will work with either or both of these >+ * properties set, but it won't be 'pretty' and the console IO won't be >+ * displayed in the debug window. >+ */ >+ public void connect( >+ Map arguments, >+ IProgressMonitor monitor, >+ ILaunch launch) throws CoreException { >+ >+ boolean retry = false; >+ do { >+ IProcess vmProcess = null; >+ try { >+ VirtualMachine vm = connect(arguments, monitor); >+ String label = (String)arguments.get(ARG_LABEL); >+ vmProcess = (IProcess)arguments.get(ARG_VMPROCESS); >+ JDIDebugModel.newDebugTarget(launch, vm, label, vmProcess, true, false); >+ } >+ catch (IOException e) { >+ String errorMessage= vmProcess.getStreamsProxy().getErrorStreamMonitor().getContents(); >+ retry = J9ProxyConnection.handleConnectException(this, e, errorMessage); >+ } >+ catch (IllegalConnectorArgumentsException e) { >+ J9LaunchingPlugin.abort(J9LauncherMessages.getString("J9SocketAttachConnector.Failed_to_connect_to_remote_VM"), e, IJavaLaunchConfigurationConstants.ERR_REMOTE_VM_CONNECTION_FAILED); //$NON-NLS-1$ >+ } >+ } >+ while(retry); >+ } >+ >+ /** >+ * @see org.eclipse.jdt.internal.launching.j9.IJ9Connector#postLaunch() >+ */ >+ public void postLaunch(Map arguments, IProgressMonitor monitor, ILaunch launch) throws CoreException { >+ try { >+ stopConnector(); >+ } >+ catch (Exception e) { >+ J9LaunchingPlugin.abort(J9LauncherMessages.getString("J9Launching.Error_when_executing_j9_1"), e, IJavaLaunchConfigurationConstants.ERR_INTERNAL_ERROR); //$NON-NLS-1$ >+ } >+ } >+ >+ /** >+ * @see org.eclipse.jdt.internal.launching.j9.IJ9Connector#preLaunch() >+ */ >+ public void preLaunch(Map arguments, IProgressMonitor monitor, ILaunch launch) throws CoreException { >+ try { >+ setupConnector(arguments); >+ setupDebugServer(arguments, monitor, launch); >+ startConnector(); >+// } catch (ConnectException excep) { >+// J9LaunchingPlugin.abort(J9LauncherMessages.getString("J9Launching.Port_is_probably_in_use,_please_specify_a_different_port_number"),excep, IJavaLaunchConfigurationConstants.ERR_INVALID_PORT); //$NON-NLS-1$ >+ } catch (Exception e) { >+ J9LaunchingPlugin.abort(J9LauncherMessages.getString("J9Launching.Error_when_executing_j9_1"), e, IJavaLaunchConfigurationConstants.ERR_INTERNAL_ERROR); //$NON-NLS-1$ >+ } >+ } >+ >+ /** >+ * Method setupDebugServer. >+ * @param arguments >+ */ >+ private void setupDebugServer(Map arguments, IProgressMonitor monitor, ILaunch launch) throws CoreException, IOException { >+ if (fDebugServerPort != -1) { >+ ILaunchConfiguration configuration = launch.getLaunchConfiguration(); >+ String[] symbolPath = J9Launching.getResolvedSymbolLookupPath(configuration); >+ String [] dbgCmdLine = getDbgCmdLine(launch.getLaunchConfiguration(), fDebugServerPort, symbolPath); >+ String[] args = null; >+ //needs better error checking >+ String osName = System.getProperty("os.name"); //$NON-NLS-1$ >+ if (osName != null) { >+ osName = osName.toLowerCase(); >+ if (osName.indexOf("linux") != -1) { //$NON-NLS-1$ >+ int idx = dbgCmdLine[0].indexOf("j9dbgserv"); >+ args = new String[]{ "LD_LIBRARY_PATH=" + dbgCmdLine[0].substring(0, idx)}; >+ } >+ } >+ >+ >+ Process dbgsvrOSProcess = Runtime.getRuntime().exec(dbgCmdLine, args); >+ IProcess dbgsvrProcess= DebugPlugin.newProcess(launch, dbgsvrOSProcess, J9Launching.renderProcessLabel(dbgCmdLine)); >+ dbgsvrProcess.setAttribute(IProcess.ATTR_CMDLINE, J9Launching.renderCommandLine(dbgCmdLine)); >+ // check for cancellation >+ if (monitor.isCanceled()) { >+ return; >+ } >+ } >+ } >+ >+ /** >+ * Get a command line that is suitable for launching the debug server. >+ * >+ * @param port >+ * @param symbolPath >+ * @return String[] >+ */ >+ private String[] getDbgCmdLine(ILaunchConfiguration config, int port, String[] symbolPath) throws CoreException { >+ String location= getJDKLocation(); >+ location = location + File.separator + "bin" + File.separator + "j9dbgserv"; //$NON-NLS-1$ //$NON-NLS-2$ >+ ArrayList list = new ArrayList(); >+ list.add(location); >+ list.add("-J-Dconsole.encoding=" + System.getProperty("file.encoding")); >+ list.add("-port:" + port); //$NON-NLS-1$ >+ StringBuffer symPath = new StringBuffer(); >+ for (int i = 0; i < symbolPath.length; i++) { >+ if (i > 0) symPath.append(File.pathSeparatorChar); >+ symPath.append(symbolPath[i]); >+ } >+ if (symPath.length() > 0) { >+ list.add("-symfiles:" + symPath.toString()); //$NON-NLS-1$ >+ } >+ >+ return (String[])list.toArray(new String[list.size()]); >+ } >+ >+ protected String getJDKLocation() throws CoreException { >+ return fIVMInstall.getInstallLocation().getAbsolutePath(); >+ } >+ >+ >+ >+ /** >+ * Get an IP of this machine, defaulting to 127.0.0.1 if none can be >+ * determined. Java 1.3 had problems with this if you were running on a >+ * multihomed system, IIRC. This shouldn't impact us in any way - any IP >+ * should do for our needs. >+ * >+ * @return the IP. >+ */ >+ public static String getLocalIP() { >+ try { >+ return InetAddress.getLocalHost().getHostAddress(); >+ } >+ catch (UnknownHostException e) { >+ return "127.0.0.1"; //$NON-NLS-1$ >+ } >+ } >+ >+ /** >+ * Returns the debugServerPort. >+ * @return int >+ */ >+ public int getDebugServerPort() { >+ return fDebugServerPort; >+ } >+ >+ public IVMInstall getIVMInstall() { >+ return fIVMInstall; >+ } >+ >+ public void setIVMInstall(IVMInstall connector) { >+ fIVMInstall = connector; >+ } >+ >+ /** >+ * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(ILaunchConfiguration, String, ILaunch, IProgressMonitor) >+ */ >+ >+ /* >+ * isPortInUse() method checks if the specified port is in use. >+ * >+ */ >+ public boolean isPortInUse(int port) throws CoreException, ConnectException { >+ >+ boolean portInUse = false; >+ Socket s= null; >+ try { >+ s= new Socket(getLocalIP(), port); >+ }/* catch (ConnectException e) { >+ portInUse = true; >+ throw new ConnectException(e.getMessage()); >+ }*/ catch (IOException e) { >+ portInUse = true; >+ throw new ConnectException(e.getMessage()); >+ } finally { >+ if (s != null) { >+ try { >+ s.close(); >+ } catch (IOException ioe) { >+ } >+ } >+ } >+ return portInUse; >+ } >+ >+ >+ >+} >Index: j9/org/eclipse/jdt/internal/launching/j9/J9PreferencePage.java >=================================================================== >RCS file: j9/org/eclipse/jdt/internal/launching/j9/J9PreferencePage.java >diff -N j9/org/eclipse/jdt/internal/launching/j9/J9PreferencePage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ j9/org/eclipse/jdt/internal/launching/j9/J9PreferencePage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,181 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.launching.j9; >+ >+import org.eclipse.jdt.launching.IVMInstall; >+import org.eclipse.jdt.launching.IVMInstallChangedListener; >+import org.eclipse.jdt.launching.IVMInstallType; >+import org.eclipse.jdt.launching.JavaRuntime; >+import org.eclipse.jdt.launching.PropertyChangeEvent; >+import org.eclipse.jdt.launching.j9.IJ9LaunchConfigurationConstants; >+import org.eclipse.jdt.launching.j9.J9Launching; >+import org.eclipse.jface.preference.FieldEditorPreferencePage; >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.ui.IWorkbench; >+import org.eclipse.ui.IWorkbenchPreferencePage; >+ >+/** >+ * Preference page to select the default J9 VM >+ */ >+public class J9PreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { >+ >+ private static class VMInstallListener implements IVMInstallChangedListener { >+ >+ public void defaultVMInstallChanged(IVMInstall previous, IVMInstall current) { >+ // If the default vm is set to a J9 vm, the default J9 vm is set the same >+ String currentId = getPrefStore().getString(IJ9LaunchConfigurationConstants.PREF_DEFAULT_J9); >+ if (current.getId().equals(currentId)) >+ return; >+ if (J9Launching.isJ9VMInstall(current)) { >+ setJ9(getPrefStore(), current); >+ setJ9Default(getPrefStore(), current); >+ } >+ } >+ >+ public void vmRemoved(IVMInstall vm) { >+ /* >+ * removing a vm will change the default, so we do not re-aquire a default >+ * selection here >+ */ >+ if (J9Launching.getDefaultJ9VMInstall() == null) { >+ // calling this will trigger a new vm to be added >+ calculateNewDefaultJ9Install(); >+ } >+ } >+ >+ public void vmAdded(IVMInstall vm) { >+ // If no J9 VM was previously available, calculate a new J9 default vm >+ if (J9Launching.getDefaultJ9VMInstall() == null && J9Launching.isJ9VMInstall(vm)) { >+ setJ9(getPrefStore(), vm); >+ setJ9Default(getPrefStore(), vm); >+ } >+ } >+ >+ public void vmChanged(PropertyChangeEvent event) { >+ // Does not effect the default J9 VM >+ } >+ } >+ >+ public J9PreferencePage() { >+ super(GRID); >+ >+ IPreferenceStore store= J9LaunchingPlugin.getDefault().getPreferenceStore(); >+ setPreferenceStore(store); >+ setDescription(J9LauncherMessages.getString("J9Launching.General_settings_for_J9_Plugin_1")); //$NON-NLS-1$ >+ } >+ >+ private static String[][] getVMNamesAndIds() { >+ String[][] result; >+ IVMInstallType type = JavaRuntime.getVMInstallType(IJ9LaunchConfigurationConstants.ID_J9_VM_INSTALL_TYPE); >+ IVMInstall[] installs = type.getVMInstalls(); >+ result = new String[installs.length][]; >+ for (int i = 0; i < installs.length; i++) { >+ result[i] = new String[] {installs[i].getName(),installs[i].getId()}; >+ } >+ return result; >+ } >+ >+ >+ public static String getVMNamesFromId(String id) { >+ IVMInstallType type = JavaRuntime.getVMInstallType(IJ9LaunchConfigurationConstants.ID_J9_VM_INSTALL_TYPE); >+ IVMInstall[] installs = type.getVMInstalls(); >+ for (int i = 0; i < installs.length; i++) { >+ if (installs[i].getId() == id) >+ return installs[i].getName(); >+ } >+ return null; >+ } >+ >+ /** >+ * @see FieldEditorPreferencePage#createFieldEditors >+ */ >+ protected void createFieldEditors() { >+ Composite parent = getFieldEditorParent(); >+ // add some empty space >+ GridData tempData = new GridData(GridData.FILL_HORIZONTAL); >+ tempData.horizontalSpan = 2; >+ new Label(parent, SWT.NONE).setLayoutData(tempData); >+ >+ >+ ComboFieldEditor fieldEditor = new ComboFieldEditor(IJ9LaunchConfigurationConstants.PREF_DEFAULT_J9, >+ J9LauncherMessages.getString("J9Launching.Default_J9_VM_2"), //$NON-NLS-1$ >+ getVMNamesAndIds(), >+ parent); >+ addField(fieldEditor); >+ >+ String noticeString = J9LauncherMessages.getString("J9Launching.J9Pref_Notice_String"); //$NON-NLS-1$ >+ Label notice= new Label(parent, SWT.WRAP); >+ notice.setText(noticeString); >+ GridData noticeData= new GridData(GridData.FILL_HORIZONTAL); >+ noticeData.horizontalSpan = 2; >+ noticeData.grabExcessHorizontalSpace= true; >+ noticeData.widthHint= convertWidthInCharsToPixels(60); >+ notice.setLayoutData(noticeData); >+ } >+ >+ /** >+ * @see IWorkbenchPreferencePage#init(IWorkbench) >+ */ >+ public void init(IWorkbench workbench) { >+ } >+ >+ >+ public static void initDefaults(IPreferenceStore store) { >+ IVMInstall newDefaultJ9 = calculateNewDefaultJ9Install(); >+ setJ9Default(store, newDefaultJ9); >+ if (J9Launching.getDefaultJ9VMInstall() == null) { >+ setJ9(store, newDefaultJ9); >+ } >+ JavaRuntime.addVMInstallChangedListener(new VMInstallListener()); >+ } >+ >+ private static void setJ9(IPreferenceStore store, IVMInstall install) { >+ String id = install == null ? "" : install.getId(); //$NON-NLS-1$ >+ store.setValue(IJ9LaunchConfigurationConstants.PREF_DEFAULT_J9, id); >+ } >+ >+ private static void setJ9Default(IPreferenceStore store, IVMInstall install) { >+ String id = install == null ? "" : install.getId(); //$NON-NLS-1$ >+ store.setDefault(IJ9LaunchConfigurationConstants.PREF_DEFAULT_J9, id); >+ } >+ >+ private static IPreferenceStore getPrefStore() { >+ return J9LaunchingPlugin.getDefault().getPreferenceStore(); >+ } >+ >+ private static IVMInstall calculateNewDefaultJ9Install() { >+ IVMInstall defaultVM = JavaRuntime.getDefaultVMInstall(); >+ return getNewDefaultJ9Install(defaultVM); >+ } >+ >+ private static IVMInstall getNewDefaultJ9Install(IVMInstall defaultVM) { >+ IVMInstall result; >+ if (J9Launching.isJ9VMInstall(defaultVM)) { >+ // The workspace default VM is a J9 VM >+ result = defaultVM; >+ } else { >+ // Find first J9 VM that is installed >+ result = null; >+ IVMInstallType type = JavaRuntime.getVMInstallType(IJ9LaunchConfigurationConstants.ID_J9_VM_INSTALL_TYPE); >+ IVMInstall[] installs = type.getVMInstalls(); >+ for (int i = 0; result == null && i < installs.length; i++) { >+ if (J9Launching.isJ9VMInstall(installs[i])) { >+ result = installs[i]; >+ } >+ } >+ } >+ return result; >+ } >+} >Index: j9/org/eclipse/jdt/internal/launching/j9/J9PropertyPage.java >=================================================================== >RCS file: j9/org/eclipse/jdt/internal/launching/j9/J9PropertyPage.java >diff -N j9/org/eclipse/jdt/internal/launching/j9/J9PropertyPage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ j9/org/eclipse/jdt/internal/launching/j9/J9PropertyPage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,356 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.launching.j9; >+ >+import java.io.ByteArrayInputStream; >+import java.io.IOException; >+import java.io.InputStream; >+ >+import org.eclipse.core.internal.resources.ResourceException; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.core.runtime.QualifiedName; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.List; >+import org.eclipse.ui.IWorkbenchPropertyPage; >+import org.eclipse.ui.dialogs.PropertyPage; >+import org.eclipse.ui.help.WorkbenchHelp; >+ >+public class J9PropertyPage >+ extends PropertyPage >+ implements IWorkbenchPropertyPage >+{ >+ private List J9List = null; >+ >+ private static final String J9_DOT_FILE = ".j9"; //$NON-NLS-1$ >+ public static final String J9_EMPTY_VERSION = "0.0.0"; //$NON-NLS-1$ >+ >+ private static final QualifiedName THIS_PROJECT_J9 = >+ new QualifiedName ("org.eclipse.jdt.launching.j9", "current_j9"); //$NON-NLS-1$ //$NON-NLS-2$ >+ private Composite parentComposite = null; >+ >+ public String getCurrentJ9 () >+ { >+ IResource resource = (IResource) getElement(); >+ >+ try >+ { >+ String propValue = >+ resource.getPersistentProperty(THIS_PROJECT_J9); >+ if (propValue != null) >+ return propValue; >+ >+ } >+ catch (ResourceException e) >+ { >+ // the project doesn't exist yet. Get value from persistent store >+ return getCurrentJ9PreferenceStore(); >+ } >+ catch (CoreException e) >+ { >+ e.printStackTrace(); >+ } >+ >+ // Try to load out of the J9 File >+ String storedJ9 = readCurrentJ9 (J9_DOT_FILE); >+ if (storedJ9 != null) >+ { >+ setCurrentJ9 (storedJ9); >+ return storedJ9; >+ } >+ >+ return J9VMContentProvider.getDefaultVMVersion(); >+ >+ } >+ >+ private String validateCurrentJ9 (String initialValue) >+ { >+ >+ // Special case default 0.0.0 >+ if (initialValue.compareTo (J9_EMPTY_VERSION) == 0) //$NON-NLS-1$ >+ { >+ return J9_EMPTY_VERSION; //$NON-NLS-1$ >+ //J9VMContentProvider.getDefaultVMName(); >+ } >+ >+ String[][] availableJ9s = J9VMContentProvider.getVMNamesAndVersions(); >+ // Try to match initial value in the names >+ for (int i = 0; i < availableJ9s.length; i++) >+ { // [0] is the name [1] is the version value >+ if (initialValue.compareTo (availableJ9s[i][1]) == 0) >+ { >+ return initialValue; >+ } >+ int lastSegment = initialValue.lastIndexOf ('.'); >+ if (lastSegment != -1) >+ { >+ String tmp = new String (initialValue.substring(0, lastSegment)); >+ if (tmp.compareTo (availableJ9s[i][1]) == 0) >+ return initialValue; >+ } >+ } >+ >+ return null; >+ } >+ >+ public boolean setCurrentJ9 (String value) >+ { >+ boolean success = false; >+ >+ String newValue = validateCurrentJ9 (value); >+ if (newValue == null) >+ return false; >+ IResource resource = (IResource) getElement(); >+ try >+ { >+ resource.setPersistentProperty (THIS_PROJECT_J9, value); >+ success = true; >+ writeCurrentJ9 (J9_DOT_FILE, value); >+ readCurrentJ9 (J9_DOT_FILE); >+ } >+ catch (ResourceException e) >+ { >+ // The resource does not exist, save in the persistent store >+ setCurrentJ9PreferenceStore (value); >+ success = true; >+ } >+ catch (CoreException e) >+ { >+ e.printStackTrace(); >+ } >+ catch (NullPointerException e) >+ { >+ e.printStackTrace(); >+ } >+ return success; >+ } >+ >+ private String getCurrentJ9PreferenceStore () >+ { >+ J9LaunchingPlugin j9LaunchingPlugin = J9LaunchingPlugin.getDefault(); >+ return j9LaunchingPlugin.getCurrentJ9Path(); >+ >+ } >+ >+ private void setCurrentJ9PreferenceStore (String value) >+ { >+ J9LaunchingPlugin j9LaunchingPlugin = J9LaunchingPlugin.getDefault(); >+ j9LaunchingPlugin.setCurrentJ9Path(value); >+ } >+ >+ public J9PropertyPage () >+ { >+ super(); >+ } >+ public J9PropertyPage (IAdaptable element) >+ { >+ this (); >+ this.setElement (element); >+ >+ } >+ protected Control createContents (Composite parent) >+ { >+ parentComposite = parent; >+ Composite composite = new Composite (parent, SWT.NONE); >+ GridLayout layout = new GridLayout(); >+ composite.setLayout (layout); >+ >+ >+ String currentJ9 = getCurrentJ9(); >+ if (currentJ9 == null) >+ getUserJ9(composite); >+ else >+ displayUserJ9(composite, currentJ9); >+ return parent; >+ } >+ >+ protected void displayUserJ9(Composite composite, String currentJ9) >+ { >+ // KMH: Probably only want to do this if we have a value >+ noDefaultAndApplyButton(); >+ >+ Label description = new Label (composite, SWT.NONE); >+ if (currentJ9 != null) >+ { >+ String name = J9VMContentProvider.getVMNameFromVersion(currentJ9); >+ description.setText (J9LauncherMessages.getString("J9_VM___4") + currentJ9 + " (" + name + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >+ } >+ else >+ description.setText (J9LauncherMessages.getString("J9_VM___4") + J9LauncherMessages.getString("J9PropertyPage.J9_VM_Not_Found_3")); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) >+ */ >+ public void createControl(Composite parent) { >+ super.createControl (parent); >+ WorkbenchHelp.setHelp(parent, "org.eclipse.jdt.internal.launching.j9" + ".J9LaunchindPlugin" + ".J9PropertyPage_context"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >+ >+ } >+ >+ protected void getUserJ9 (Composite composite) >+ { >+ J9List = new List (composite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL); >+ >+ J9VMContentProvider availableJ9 = new J9VMContentProvider(); >+ String[][]newJ9s = J9VMContentProvider.getVMNamesAndVersions(); >+ >+ GridData gd = >+ new GridData( >+ GridData.FILL_BOTH >+ ); >+ >+ composite.setLayoutData(gd); >+ GridData listGd = >+ new GridData( >+ GridData.FILL_BOTH >+ ); >+ listGd.verticalSpan = 1; >+ J9List.setLayoutData(listGd); >+ >+ for (int i = 0; i < newJ9s.length; i++) >+ J9List.add(newJ9s[i][0] + " (" + newJ9s[i][1] + ")"); //$NON-NLS-1$ //$NON-NLS-2$ >+ J9List.setSelection(0); >+ //J9SelectionChanged(); >+ } >+ >+ private void J9SelectionChanged () >+ { >+ String selection = ((String) J9List.getSelection()[0]); >+ int firstIndex = selection.indexOf("("); //$NON-NLS-1$ >+ int endIndex = selection.indexOf (")"); //$NON-NLS-1$ >+ String versionSelection = selection.substring(firstIndex + 1, endIndex); >+ //setCurrentJ9 ((String) J9List.getSelection()[0]); >+ boolean a = setCurrentJ9 (versionSelection); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.preference.PreferencePage#performApply() >+ */ >+ protected void performApply() { >+ super.performApply(); >+ J9SelectionChanged(); >+ } >+ >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.preference.PreferencePage#performDefaults() >+ */ >+ protected void performDefaults() { >+ super.performDefaults(); >+ // J9List only matters when we are filling data, not on the display >+ // only >+ if (J9List != null) >+ J9List.setSelection(0); >+ } >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.IDialogPage#performHelp() >+ */ >+ public void performHelp() { >+ // Auto-generated method stub >+ >+ } >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.preference.IPreferencePage#performOk() >+ */ >+ public boolean performOk() { >+ // J9List only matters when we are filling data, not on the display >+ // only >+ if (J9List != null) >+ { >+ String[] tmp = J9List.getSelection(); >+ if (tmp != null) >+ if (tmp.length > 0) >+ { >+ setCurrentJ9 ((String) J9List.getSelection()[0]); >+ J9SelectionChanged(); >+ } >+ } >+ >+ return true; >+ } >+ >+ // Store the backup file with the current J9 value >+ // Note: This will only be used when a project is imported, since the value >+ // is stored in a property. >+ public void writeCurrentJ9(String key, String value) >+ { >+ try >+ { >+ IResource resource = (IResource) getElement(); >+ IProject project = resource.getProject(); >+ IFile rscFile = project.getFile(key); >+ InputStream inputStream = new ByteArrayInputStream(value.getBytes()); >+ // update the resource content >+ if (rscFile.exists()) >+ { >+ if (rscFile.isReadOnly()) >+ { >+ // provide opportunity to checkout read-only value file >+ ResourcesPlugin.getWorkspace().validateEdit(new IFile[]{rscFile}, null); >+ } >+ rscFile.setContents(inputStream, IResource.FORCE, null); >+ } >+ else >+ { >+ rscFile.create(inputStream, IResource.FORCE, null); >+ } >+ } >+ catch (CoreException e) >+ { >+ // Output error writing file >+ e.printStackTrace(); >+ } >+ } >+ >+ // Try to read the backup file with the current J9 value >+ public String readCurrentJ9(String key) >+ { >+ try >+ { >+ IResource resource = (IResource) getElement(); >+ IProject project = resource.getProject(); >+ IFile rscFile = project.getFile(key); >+ // update the resource content >+ if (rscFile.exists()) >+ { >+ InputStream is = rscFile.getContents(); >+ byte[] b = new byte[5]; >+ int stat = is.read(b, 0, 5); >+ if (stat == -1) >+ return null; >+ String output = new String (b); >+ return output; >+ } >+ return null; >+ } >+ catch (CoreException e) >+ { >+ // Output error writing file >+ e.printStackTrace(); >+ } >+ catch (IOException e) >+ { >+ // Output error writing file >+ e.printStackTrace(); >+ } >+ return null; >+ } >+} >Index: j9/org/eclipse/jdt/internal/launching/j9/J9ProxyConnection.java >=================================================================== >RCS file: j9/org/eclipse/jdt/internal/launching/j9/J9ProxyConnection.java >diff -N j9/org/eclipse/jdt/internal/launching/j9/J9ProxyConnection.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ j9/org/eclipse/jdt/internal/launching/j9/J9ProxyConnection.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,250 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.launching.j9; >+ >+import java.io.File; >+import java.io.IOException; >+import java.net.SocketException; >+import java.util.ArrayList; >+import java.util.List; >+import java.util.Map; >+import java.util.StringTokenizer; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.debug.core.IStatusHandler; >+import org.eclipse.jdt.debug.core.JDIDebugModel; >+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; >+import org.eclipse.jdt.launching.SocketUtil; >+import org.eclipse.jdt.launching.j9.J9Launching; >+ >+import com.sun.jdi.VirtualMachine; >+import com.sun.jdi.connect.AttachingConnector; >+import com.sun.jdi.connect.Connector; >+import com.sun.jdi.connect.IllegalConnectorArgumentsException; >+ >+/** >+ * A J9 JVM debug socket attaching connector connecting through the J9 debug proxy. >+ */ >+public class J9ProxyConnection { >+ >+ // Use 127.0.0.1 to avoid timeout due to dns resolution delays >+ public final static String LOCALHOST = "127.0.0.1"; //$NON-NLS-1$ >+ private final static String ARG_HOSTNAME = "hostname"; //$NON-NLS-1$ >+ private final static String ARG_PORT = "port"; //$NON-NLS-1$ >+ >+ private String fHost; >+ private String fPort; >+ private String[] fSymbolPath; >+ private String fDebugTimeout; >+ private J9VMInstall fVMInstall; >+ private String fProxyOptions; >+ private Process fProxyProcess; >+ private String[] fProxyCmd; >+ private String fProxyPort; >+ >+ >+ /** >+ * Constructor for J9ProxyAttachConnector. >+ * >+ * @param host Host name of target vm proxy must connect to >+ * @param port Port name of target vm proxy must connect to >+ * @param symbolPath Symbol file path. >+ * @param debugTimeout Debug timeout in ms, or null for global default >+ * @param vmInstall J9 VM install of proxy utility location >+ */ >+ public J9ProxyConnection(String host, String port, String symbolPath[], String debugTimeout, J9VMInstall vmInstall, String proxyOptions) { >+ fHost = host; >+ fPort = port; >+ fSymbolPath = symbolPath; >+ fDebugTimeout = debugTimeout; >+ fVMInstall = vmInstall; >+ fProxyOptions = proxyOptions; >+ } >+ >+ private List getProxyOptions() throws CoreException { >+ StringTokenizer tokenizer = new StringTokenizer(fProxyOptions); >+ List result = new ArrayList(tokenizer.countTokens() + 1); >+ while (tokenizer.hasMoreTokens()) { >+ result.add(tokenizer.nextToken()); >+ } >+ if (!fVMInstall.isPre20J9Version()) { >+ result.add("-timeout=" + getDebugTimeout()); //$NON-NLS-1$ >+ } >+ return result; >+ } >+ >+ public Process runProxy() throws CoreException { >+ /* >+ * LL: Migration to 3.0: SocketUtil.findUnusedLocalPort() has been deprecated. >+ * Use SocketUtil.findFreePort() instead. >+ */ >+ int proxyPort= SocketUtil.findFreePort(); >+ if (proxyPort == -1) { >+ J9LaunchingPlugin.abort(J9LauncherMessages.getString("J9ProxyConnection.Could_not_find_a_free_socket_for_the_proxy"), null, IJavaLaunchConfigurationConstants.ERR_NO_SOCKET_AVAILABLE); //$NON-NLS-1$ >+ } >+ fProxyPort = Integer.toString(proxyPort); >+ >+ StringBuffer proxy= new StringBuffer(fVMInstall.getInstallLocation().getAbsolutePath()); >+ proxy.append(File.separatorChar); >+ proxy.append("bin"); //$NON-NLS-1$ >+ proxy.append(File.separatorChar); >+ proxy.append("j9proxy"); //$NON-NLS-1$ >+ StringBuffer symPath = new StringBuffer(); >+ for (int i = 0; i < fSymbolPath.length; i++) { >+ if (i > 0) symPath.append(File.pathSeparatorChar); >+ symPath.append(fSymbolPath[i]); >+ } >+ List proxyCmd = new ArrayList(); >+ proxyCmd.add(proxy.toString()); >+ proxyCmd.addAll(getProxyOptions()); >+ proxyCmd.add(fHost + ':'+ fPort); >+ proxyCmd.add(fProxyPort); >+ proxyCmd.add(symPath.toString()); >+ fProxyCmd = (String[])proxyCmd.toArray(new String[proxyCmd.size()]); >+ try { >+ fProxyProcess = Runtime.getRuntime().exec(fProxyCmd); >+ } catch (IOException e) { >+ J9LaunchingPlugin.abort(J9LauncherMessages.getString("J9ProxyConnection.Could_not_start_debug_proxy"), e, IJavaLaunchConfigurationConstants.ERR_INTERNAL_ERROR); //$NON-NLS-1$ >+ } >+ >+ return fProxyProcess; >+ } >+ >+ /** >+ * Create a JDI socket attching connector and connect it to the J9 VM >+ * through the j9 debug proxy. >+ * >+ * @exception CoreException if unable to create the connector >+ */ >+ public VirtualMachine connect(IProgressMonitor monitor) throws CoreException, IOException, IllegalConnectorArgumentsException { >+ >+ AttachingConnector connector= J9Launching.getAttachingConnector(); >+ Map map= connector.defaultArguments(); >+ Connector.Argument param= (Connector.Argument) map.get(ARG_HOSTNAME); >+ param.setValue(LOCALHOST); >+ param= (Connector.Argument) map.get(ARG_PORT); >+ param.setValue(fProxyPort); >+ >+ int debugTimeout = getDebugTimeout(); >+ long timeLimit = System.currentTimeMillis() + debugTimeout; >+ for(;;) { >+ try { >+ VirtualMachine vm = attach(connector, map, debugTimeout); >+ setDebugTimeout(vm, debugTimeout); >+ return vm; >+ } catch (SocketException e) { >+ // Cannot bind to vm or proxy, may still be initializing (for example loading symbol files). >+ if (System.currentTimeMillis() > timeLimit) { >+ throw e; >+ } else { >+ synchronized (connector) { >+ try { >+ connector.wait(250); >+ } catch(InterruptedException ie) { >+ } >+ } >+ } >+ } >+ } >+ } >+ >+ private int getDebugTimeout() { >+ if (fDebugTimeout == null) { >+ return JDIDebugModel.getPreferences().getInt(JDIDebugModel.PREF_REQUEST_TIMEOUT); >+ } else { >+ return Integer.parseInt(fDebugTimeout); >+ } >+ } >+ >+ /** >+ * Attaches to a virtual machine. This method implemts using a timeout to avoid >+ * hanging indefinitely in SocketTransportImpl.PerformHandshake. >+ */ >+ private VirtualMachine attach(final AttachingConnector connector, final Map map, final int debugTimeout) throws CoreException, IOException, IllegalConnectorArgumentsException { >+ final Exception[] exc = new Exception[1]; >+ final VirtualMachine[] vm = new VirtualMachine[1]; >+ Runnable runnable = new Runnable() { >+ public void run() { >+ try { >+ vm[0] = connector.attach(map); >+ } catch (IOException e) { >+ exc[0] = e; >+ } catch (IllegalConnectorArgumentsException e) { >+ exc[0] = e; >+ } >+ } >+ }; >+ Thread thread = new Thread(runnable, "J9ProxyConnection Attach"); //$NON-NLS-1$ >+ thread.start(); >+ try { >+ thread.join(debugTimeout); >+ } catch (InterruptedException e) { >+ } >+ >+ if (exc[0] instanceof IOException) >+ throw (IOException)exc[0]; >+ else if (exc[0] instanceof IllegalConnectorArgumentsException) >+ throw (IllegalConnectorArgumentsException)exc[0]; >+ >+ if (vm[0] == null) { >+ String msg = J9LauncherMessages.getString("J9Launching.Timeout_while_connecting_to_VM,_try_using_a_different_port_number_1"); //$NON-NLS-1$ >+ J9LaunchingPlugin.abort(msg, null, IJavaLaunchConfigurationConstants.ERR_VM_CONNECT_TIMEOUT); >+ } >+ return vm[0]; >+ } >+ >+ public String[] getProxyCommand() { >+ return fProxyCmd; >+ } >+ >+ /** >+ * Set the debug request timeout of a vm in ms, if supported by the vm implementation. >+ */ >+ private static void setDebugTimeout(VirtualMachine vm, int timeOut) { >+ if (vm instanceof org.eclipse.jdi.VirtualMachine && timeOut > 0) { >+ org.eclipse.jdi.VirtualMachine vm2= (org.eclipse.jdi.VirtualMachine)vm; >+ vm2.setRequestTimeout(timeOut); >+ } >+ } >+ >+ /** >+ * Utility function to consult status handler (if there is one) for errors and connect >+ * timeouts, or else throw a CoreException. Always abort for fatal errors. >+ */ >+ public static boolean handleConnectException(Object errorSource, Exception e, String errorStreamMonitorContents) throws CoreException { >+ boolean retry = false; >+ if (errorStreamMonitorContents != null && errorStreamMonitorContents.length() != 0) { >+ J9LaunchingPlugin.abort(errorStreamMonitorContents, e, IJavaLaunchConfigurationConstants.ERR_VM_LAUNCH_ERROR); >+ } else { >+ // timeout, consult status handler if there is one >+ IStatus status = new Status(IStatus.ERROR, "org.eclipse.jdt.launching.j9", IJavaLaunchConfigurationConstants.ERR_VM_CONNECT_TIMEOUT, e.getLocalizedMessage(), 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); >+ } else { >+ Object result = handler.handleStatus(status, errorSource); >+ if (result instanceof Boolean) { >+ retry = ((Boolean)result).booleanValue(); >+ } >+ } >+ } >+ return retry; >+ } >+ >+} >+ >Index: j9/org/eclipse/jdt/internal/launching/j9/J9SocketAttachConnector.java >=================================================================== >RCS file: j9/org/eclipse/jdt/internal/launching/j9/J9SocketAttachConnector.java >diff -N j9/org/eclipse/jdt/internal/launching/j9/J9SocketAttachConnector.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ j9/org/eclipse/jdt/internal/launching/j9/J9SocketAttachConnector.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,200 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.launching.j9; >+ >+import java.io.IOException; >+import java.net.UnknownHostException; >+import java.text.MessageFormat; >+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.debug.core.DebugPlugin; >+import org.eclipse.debug.core.ILaunch; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.model.IDebugTarget; >+import org.eclipse.debug.core.model.IProcess; >+import org.eclipse.jdi.TimeoutException; >+import org.eclipse.jdt.debug.core.JDIDebugModel; >+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; >+import org.eclipse.jdt.launching.IVMInstall; >+import org.eclipse.jdt.launching.j9.J9Launching; >+ >+import com.sun.jdi.VMDisconnectedException; >+import com.sun.jdi.VirtualMachine; >+import com.sun.jdi.connect.IllegalConnectorArgumentsException; >+ >+/** >+ * A J9 JVM debug proxy socket attaching IVMConnector >+ */ >+public class J9SocketAttachConnector implements IJ9Connector{ >+ >+ public final static String ARG_HOSTNAME = "hostname"; //$NON-NLS-1$ >+ public final static String ARG_PORT = "port"; //$NON-NLS-1$ >+ public final static String ARG_DEBUG_TIMEOUT = "debug_timeout"; //$NON-NLS-1$ >+ public final static String ARG_VM_INSTALL_NAME = "proxyvm"; //$NON-NLS-1$ >+ public final static String ARG_PROXY_OPTIONS = "proxy_options"; //$NON-NLS-1$ >+ >+ // tbd: Note that the identifier "Default" is stored in launch configs >+ // Therefore, the string should not be translated for nls >+ public final static String DEFAULT_JRE_NAME = "Default"; //$NON-NLS-1$ >+ >+ private IVMInstall fIVMInstall; >+ >+ public IVMInstall getIVMInstall() { >+ return fIVMInstall; >+ } >+ >+ public void setIVMInstall(IVMInstall connector) { >+ fIVMInstall = connector; >+ } >+ >+ /** >+ * @see org.eclipse.jdt.launching.IVMConnector#connect(Map, IProgressMonitor, ILaunch) >+ */ >+ public void connect( >+ Map arguments, >+ IProgressMonitor monitor, >+ ILaunch launch) throws CoreException { >+ >+ ILaunchConfiguration configuration = launch.getLaunchConfiguration(); >+ >+ String port = (String) arguments.get(ARG_PORT); >+ if (port == null) { >+ J9LaunchingPlugin.abort(J9LauncherMessages.getString("J9SocketAttachConnector.Port_unspecified_for_remote_connection"), null, IJavaLaunchConfigurationConstants.ERR_UNSPECIFIED_PORT); //$NON-NLS-1$ >+ } >+ String host = (String) arguments.get(ARG_HOSTNAME); >+ if (host == null) { >+ J9LaunchingPlugin.abort(J9LauncherMessages.getString("J9SocketAttachConnector.Hostname_unspecified_for_remote_connection"), null, IJavaLaunchConfigurationConstants.ERR_UNSPECIFIED_HOSTNAME); //$NON-NLS-1$ >+ } >+ >+ String symbolPath[] = J9Launching.getResolvedSymbolLookupPath(configuration); >+ String debugTimeout = (String) arguments.get(ARG_DEBUG_TIMEOUT); >+ >+ if (fIVMInstall == null) { >+ J9LaunchingPlugin.abort(J9LauncherMessages.getString("J9SocketAttachConnector.VM_does_not_exist_for_remote_connection"), null, IJavaLaunchConfigurationConstants.ERR_VM_INSTALL_DOES_NOT_EXIST); //$NON-NLS-1$ >+ } >+ >+ String proxyOptions = (String) arguments.get(ARG_PROXY_OPTIONS); >+ if (proxyOptions == null) { >+ J9LaunchingPlugin.abort(J9LauncherMessages.getString("J9SocketAttachConnector.Proxy_options_unspecified_for_remote_connection"), null, IStatus.OK); //$NON-NLS-1$ >+ } >+ >+ boolean allowTerminate = false; >+ if (configuration != null) { >+ allowTerminate = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_ALLOW_TERMINATE, false); >+ } >+ >+ Process proxyOSProcess = null; >+ try { >+ J9ProxyConnection proxyConnector = new J9ProxyConnection(host, port, symbolPath, debugTimeout, (J9VMInstall)fIVMInstall, proxyOptions); >+ proxyOSProcess = proxyConnector.runProxy(); >+ IProcess proxyProcess= DebugPlugin.newProcess(launch, proxyOSProcess, J9Launching.renderProcessLabel(proxyConnector.getProxyCommand())); >+ proxyProcess.setAttribute(IProcess.ATTR_CMDLINE, J9Launching.renderCommandLine(proxyConnector.getProxyCommand())); >+ >+ boolean retry = false; >+ do { >+ try { >+ // check for cancellation >+ if (monitor.isCanceled()) { >+ proxyOSProcess.destroy(); >+ return; >+ } >+ >+ VirtualMachine vm = proxyConnector.connect(monitor); >+ String vmLabel = constructVMLabel(vm, host, port, configuration); >+ IDebugTarget debugTarget= JDIDebugModel.newDebugTarget(launch, vm, vmLabel, null, allowTerminate, true); >+ launch.addDebugTarget(debugTarget); >+ return; >+ } catch (UnknownHostException e) { >+ J9LaunchingPlugin.abort(MessageFormat.format(J9LauncherMessages.getString("J9SocketAttachConnector.Failed_to_connect_to_remote_VM_because_of_unknown_host"), new String[]{host}), e, IJavaLaunchConfigurationConstants.ERR_REMOTE_VM_CONNECTION_FAILED); //$NON-NLS-1$ >+ } catch (IOException e) { >+ String errorMessage= proxyProcess.getStreamsProxy().getErrorStreamMonitor().getContents(); >+ retry = J9ProxyConnection.handleConnectException(this, e, errorMessage); >+ } catch (VMDisconnectedException e) { >+ String errorMessage= proxyProcess.getStreamsProxy().getErrorStreamMonitor().getContents(); >+ retry = J9ProxyConnection.handleConnectException(this, e, errorMessage); >+ } catch (IllegalConnectorArgumentsException e) { >+ J9LaunchingPlugin.abort(J9LauncherMessages.getString("J9SocketAttachConnector.Failed_to_connect_to_remote_VM"), e, IJavaLaunchConfigurationConstants.ERR_REMOTE_VM_CONNECTION_FAILED); //$NON-NLS-1$ >+ >+ } >+ } while (retry); >+ } catch (CoreException e) { >+ if (proxyOSProcess != null) proxyOSProcess.destroy(); >+ throw e; >+ } >+ proxyOSProcess.destroy(); >+ } >+ >+ /** >+ * Helper method that constructs a human-readable label for a remote VM. >+ */ >+ protected String constructVMLabel(VirtualMachine vm, String host, String port, ILaunchConfiguration configuration) { >+ String name = null; >+ try { >+ name = vm.name(); >+ } catch (TimeoutException e) { >+ // do nothing >+ } catch (VMDisconnectedException e) { >+ // do nothing >+ } >+ if (name == null) { >+ if (configuration == null) { >+ name = ""; //$NON-NLS-1$ >+ } else { >+ name = configuration.getName(); >+ } >+ } >+ StringBuffer buffer = new StringBuffer(name); >+ buffer.append('['); //$NON-NLS-1$ >+ buffer.append(host); >+ buffer.append(':'); //$NON-NLS-1$ >+ buffer.append(port); >+ buffer.append(']'); //$NON-NLS-1$ >+ return buffer.toString(); >+ } >+ >+ /* >+ * Return names of configured j9 vm installs. >+ */ >+ private static List getJ9VMInstallNames() { >+ IVMInstall vmInstalls[] = J9Launching.getJ9VMInstalls(); >+ ArrayList names = new ArrayList(); >+ for (int i = 0; i < vmInstalls.length; i++) { >+ names.add(vmInstalls[i].getName()); >+ } >+ return names; >+ } >+ >+ /** >+ * @see org.eclipse.jdt.internal.launching.j9.IJ9Connector#postLaunch(Map, IProgressMonitor, ILaunch) >+ */ >+ public void postLaunch( >+ Map arguments, >+ IProgressMonitor monitor, >+ ILaunch launch) >+ throws CoreException { >+ } >+ >+ /** >+ * @see org.eclipse.jdt.internal.launching.j9.IJ9Connector#preLaunch(Map, IProgressMonitor, ILaunch) >+ */ >+ public void preLaunch( >+ Map arguments, >+ IProgressMonitor monitor, >+ ILaunch launch) >+ throws CoreException { >+ } >+ >+} >Index: j9/org/eclipse/jdt/internal/launching/j9/J9SocketAttachConnectorDelegate.java >=================================================================== >RCS file: j9/org/eclipse/jdt/internal/launching/j9/J9SocketAttachConnectorDelegate.java >diff -N j9/org/eclipse/jdt/internal/launching/j9/J9SocketAttachConnectorDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ j9/org/eclipse/jdt/internal/launching/j9/J9SocketAttachConnectorDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,47 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.launching.j9; >+ >+/** >+ * THIS CLASS IS A THROWAWAY! >+ * >+ * It's an unchanged subclass of J9Connector >+ * delegate. This allows us to add another vmconnector extension point with a >+ * different ID. The vmconnector point uses the ID supplied by the created class >+ * and not the plugin descriptor itself... we'll use the migration plugin to take >+ * care of this issue in 5.6 >+ */ >+public final class J9SocketAttachConnectorDelegate >+ extends J9ConnectorDelegate { >+ >+ /** >+ * Constructor for J9SocketAttachConnectorDelegate. >+ */ >+ public J9SocketAttachConnectorDelegate() { >+ super(); >+ } >+ >+ /** >+ * @see org.eclipse.jdt.launching.IVMConnector#getIdentifier() >+ */ >+ public String getIdentifier() { >+ return "com.ibm.ive.internal.j9.launcher.J9SocketAttachConnector"; //$NON-NLS-1$ >+ } >+ >+ /** >+ * @see org.eclipse.jdt.launching.IVMConnector#getName() >+ */ >+ public String getName() { >+ return J9LauncherMessages.getString("J9SocketAttachConnector.J9_20_(Proxied_Socket_Attach)"); //$NON-NLS-1$ >+ } >+ >+ >+} >Index: j9/org/eclipse/jdt/internal/launching/j9/J9VMCommandTab.java >=================================================================== >RCS file: j9/org/eclipse/jdt/internal/launching/j9/J9VMCommandTab.java >diff -N j9/org/eclipse/jdt/internal/launching/j9/J9VMCommandTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ j9/org/eclipse/jdt/internal/launching/j9/J9VMCommandTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,108 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.launching.j9; >+ >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; >+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; >+import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; >+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; >+import org.eclipse.jdt.launching.j9.IJ9LaunchConfigurationConstants; >+import org.eclipse.jdt.launching.j9.J9Launching; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+ >+/** >+ * User interface for J9 specific launch attributes >+ */ >+public class J9VMCommandTab extends AbstractLaunchConfigurationTab { >+ >+ protected Button fRunAsConsoleButton; >+ protected Button fExecFromArchiveButton; >+ >+ /** >+ * @see ILaunchConfigurationTab#createControl(Composite) >+ */ >+ public void createControl(Composite parent) { >+ >+ Composite comp = new Composite(parent, SWT.NONE); >+ setControl(comp); >+ GridLayout topLayout = new GridLayout(); >+ comp.setLayout(topLayout); >+ topLayout.marginWidth= 0; >+ topLayout.marginHeight= 0; >+ GridData gd = new GridData(GridData.FILL_HORIZONTAL); >+ comp.setLayoutData(gd); >+ >+// createVerticalSpacer(comp, 2); >+ >+ fRunAsConsoleButton = new Button(comp, SWT.CHECK); >+ fRunAsConsoleButton.setText(J9LauncherMessages.getString("J9VMCommandTab.Run_as_console")); //$NON-NLS-1$ >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); >+ gd.horizontalSpan = 2; >+ fRunAsConsoleButton.setLayoutData(gd); >+ >+ fExecFromArchiveButton = new Button(comp, SWT.CHECK); >+ fExecFromArchiveButton.setText(J9LauncherMessages.getString("J9VMCommandTab.Run_from_executable_archive")); //$NON-NLS-1$ >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); >+ gd.horizontalSpan = 2; >+ fExecFromArchiveButton.setLayoutData(gd); >+ >+ setControl(comp); >+ } >+ >+ /** >+ * @see ILaunchConfigurationTab#getName() >+ */ >+ public String getName() { >+ return J9LauncherMessages.getString("J9VMCommandTab.J9_VM_specific_attributes_2"); //$NON-NLS-1$ >+ } >+ >+ /** >+ * @see ILaunchConfigurationTab#initializeFrom(ILaunchConfiguration) >+ */ >+ public void initializeFrom(ILaunchConfiguration configuration) { >+ try { >+ Map attributeMap = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE_SPECIFIC_ATTRS_MAP, (Map)null); >+ fRunAsConsoleButton.setSelection(J9Launching.runAsConsole(attributeMap)); >+ fExecFromArchiveButton.setSelection(J9Launching.executeFromArchive(attributeMap)); >+ } catch(CoreException ce) { >+ JDIDebugUIPlugin.log(ce); >+ } >+ } >+ >+ /** >+ * @see ILaunchConfigurationTab#performApply(ILaunchConfigurationWorkingCopy) >+ */ >+ public void performApply(ILaunchConfigurationWorkingCopy configuration) { >+ Map attributeMap = new HashMap(1); >+ attributeMap.put(IJ9LaunchConfigurationConstants.ATTR_RUN_AS_CONSOLE, new Boolean(fRunAsConsoleButton.getSelection()).toString()); >+ attributeMap.put(IJ9LaunchConfigurationConstants.ATTR_EXECUTE_FROM_ARCHIVE, new Boolean(fExecFromArchiveButton.getSelection()).toString()); >+ configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE_SPECIFIC_ATTRS_MAP, attributeMap); >+ } >+ >+ /** >+ * @see ILaunchConfigurationTab#setDefaults(ILaunchConfigurationWorkingCopy) >+ */ >+ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { >+ Map attributeMap = new HashMap(1); >+ attributeMap.put(IJ9LaunchConfigurationConstants.ATTR_RUN_AS_CONSOLE, new Boolean(J9Launching.runAsConsole(null)).toString()); >+ attributeMap.put(IJ9LaunchConfigurationConstants.ATTR_EXECUTE_FROM_ARCHIVE, new Boolean(J9Launching.executeFromArchive(null)).toString()); >+ configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE_SPECIFIC_ATTRS_MAP, attributeMap); >+ } >+} >Index: j9/org/eclipse/jdt/internal/launching/j9/J9VMContentProvider.java >=================================================================== >RCS file: j9/org/eclipse/jdt/internal/launching/j9/J9VMContentProvider.java >diff -N j9/org/eclipse/jdt/internal/launching/j9/J9VMContentProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ j9/org/eclipse/jdt/internal/launching/j9/J9VMContentProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,269 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.launching.j9; >+ >+import java.util.Vector; >+ >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.jdt.core.IJavaProject; >+import org.eclipse.jdt.launching.IVMInstall; >+import org.eclipse.jdt.launching.IVMInstallType; >+import org.eclipse.jdt.launching.JavaRuntime; >+import org.eclipse.jdt.launching.j9.IJ9LaunchConfigurationConstants; >+import org.eclipse.jdt.launching.j9.J9Launching; >+import org.eclipse.jface.viewers.IStructuredContentProvider; >+import org.eclipse.jface.viewers.Viewer; >+ >+/** >+ * Retrieve all known J9 VMs in the system >+ */ >+public class J9VMContentProvider >+ implements IStructuredContentProvider >+{ >+ /* (non-Javadoc) >+ * Object is determined from internal references. arg0 is ignored. >+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) >+ */ >+ public Object[] getElements(Object arg0) { >+ return getVMNames().toArray(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.IContentProvider#dispose() >+ */ >+ public void dispose() { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) >+ */ >+ public void inputChanged(Viewer arg0, Object arg1, Object arg2) { >+ } >+ >+ public Vector getVMNames () >+ { >+ String[][] namesAndIds = getVMNamesAndIds(); >+ Vector elementNames = new Vector (); >+ for (int i = 0; i < namesAndIds.length; i++) >+ { >+ elementNames.add (namesAndIds[i][0]); >+ } >+ elementNames.trimToSize(); >+ >+ return elementNames; >+ } >+ >+ private static String[][] getVMNamesAndIds() { >+ String[][] result; >+ IVMInstallType type = JavaRuntime.getVMInstallType(IJ9LaunchConfigurationConstants.ID_J9_VM_INSTALL_TYPE); >+ IVMInstall[] installs = type.getVMInstalls(); >+ result = new String[installs.length][]; >+ for (int i = 0; i < installs.length; i++) { >+ result[i] = new String[] {installs[i].getName(),installs[i].getId()}; >+ } >+ return result; >+ } >+ >+ public static String[][] getVMNamesAndVersions() { >+ String[][] result; >+ IVMInstallType type = JavaRuntime.getVMInstallType(IJ9LaunchConfigurationConstants.ID_J9_VM_INSTALL_TYPE); >+ IVMInstall[] installs = type.getVMInstalls(); >+ result = new String[installs.length][]; >+ for (int i = 0; i < installs.length; i++) { >+ try >+ { >+ String J9Version = ((J9VMInstall)installs[i]).getJ9Version(); >+ int countDots = 0; >+ int currentIndex = 0; >+ while (currentIndex != -1) >+ { >+ currentIndex = J9Version.indexOf('.', currentIndex); >+ if (currentIndex != -1) >+ { >+ countDots++; // Increment Count >+ currentIndex++; // Continue to look starting at the next character >+ } >+ } >+ if (countDots == 1) >+ J9Version = J9Version + ".0"; //$NON-NLS-1$ >+ >+ // Since there is no version below 2.2.0 that can be found in the metadata >+ // reset the version to 0.0.0 >+ if (J9Version.compareTo ("2.2.0") < 0) //$NON-NLS-1$ >+ J9Version = "0.0.0"; // $NON-NLS-1$ >+ result[i] = new String[] {installs[i].getName(),J9Version}; >+ } >+ catch (CoreException e) >+ { >+ result[i] = new String[] {installs[i].getName(),""}; //$NON-NLS-1$ >+ } >+ } >+ return result; >+ } >+ >+ >+ >+ public static String getVMNamesFromId(String id) { >+ IVMInstallType type = JavaRuntime.getVMInstallType(IJ9LaunchConfigurationConstants.ID_J9_VM_INSTALL_TYPE); >+ IVMInstall[] installs = type.getVMInstalls(); >+ for (int i = 0; i < installs.length; i++) { >+ if (installs[i].getId() == id) >+ return installs[i].getName(); >+ } >+ return null; >+ } >+ >+ public static IVMInstall getVMfromName(String Name) { >+ IVMInstallType type = JavaRuntime.getVMInstallType(IJ9LaunchConfigurationConstants.ID_J9_VM_INSTALL_TYPE); >+ IVMInstall[] installs = type.getVMInstalls(); >+ for (int i = 0; i < installs.length; i++) { >+ if (Name.compareTo (installs[i].getName()) == 0) >+ return installs[i]; >+ } >+ return null; >+ } >+ public static String getVMInstallNameFromResource (IJavaProject javaProject) >+ { >+ return J9VMContentProvider.getVMInstallNameFromResource (javaProject.getResource()); >+ } >+ >+ public static String getVMNameFromVersion (String version) >+ { >+ if (version == null) >+ return getDefaultVMName (); >+ >+ String[][] availableJ9s = J9VMContentProvider.getVMNamesAndVersions(); >+ // Try to match initial value in the names >+ for (int i = 0; i < availableJ9s.length; i++) >+ { // [0] is the name [1] is the version value >+ if (version.compareTo (availableJ9s[i][1]) == 0) >+ return availableJ9s[i][0]; >+ int lastSegment = version.lastIndexOf ('.'); >+ if (lastSegment != -1) >+ { >+ String tmp = new String (version.substring(0, lastSegment)); >+ if (tmp.compareTo (availableJ9s[i][1]) == 0) >+ return availableJ9s[i][0]; >+ } >+ } >+ return getDefaultVMName (); >+ } >+ >+ public static String getVMVersionFromName (String name) >+ { >+ if (name == null) >+ return getDefaultVMVersion(); >+ >+ //if (name.compareTo ("0.0.0") == 0) >+ //return J9VMContentProvider.getDefaultVMName(); >+ >+ String[][] availableJ9s = J9VMContentProvider.getVMNamesAndVersions(); >+ // Try to match initial value in the names >+ for (int i = 0; i < availableJ9s.length; i++) >+ { // [0] is the name [1] is the version value >+ if (name.compareTo (availableJ9s[i][0]) == 0) >+ return availableJ9s[i][1]; >+ int lastSegment = name.lastIndexOf ('.'); >+ if (lastSegment != -1) >+ { >+ String tmp = new String (name.substring(0, lastSegment)); >+ if (tmp.compareTo (availableJ9s[i][1]) == 0) >+ return availableJ9s[i][1]; >+ } >+ } >+ return J9VMContentProvider.getDefaultVMName(); >+ } >+ >+ public static String getVMVersionFromResource (IResource resource) >+ { >+ if (resource == null) >+ { >+// System.out.println ("1 v " + getDefaultVMVersion()); >+ return getDefaultVMVersion(); >+ } >+ >+ J9PropertyPage propertyPage = new J9PropertyPage (resource); >+ if (propertyPage == null) >+ { >+// System.out.println ("2 v " + getDefaultVMVersion()); >+ return getDefaultVMVersion(); >+ } >+ >+ String j9Version = propertyPage.getCurrentJ9(); >+// System.out.println ("3 v " + j9Version); >+ return j9Version; >+ } >+ >+ >+ public static String getVMInstallNameFromResource (IResource resource) >+ { >+ String j9Version = getVMVersionFromResource (resource); >+ if (j9Version == null) >+ return null; >+ >+ String j9Name = getVMNameFromVersion (j9Version); >+ return j9Name; >+ } >+ >+ public static IVMInstall getVMInstallFromResource (IJavaProject javaProject) >+ { >+ if (javaProject == null) >+ return J9Launching.getDefaultJ9VMInstall(); >+ >+ try >+ { >+ IVMInstall vmInstall = J9VMContentProvider.getVMInstallFromResource (javaProject.getResource()); >+ if (vmInstall == null) >+ vmInstall = JavaRuntime.getVMInstall(javaProject); >+ >+ return vmInstall; >+ } >+ catch (CoreException e) >+ { >+ return getDefaultVMInstall (); >+ } >+ } >+ >+ public static IVMInstall getVMInstallFromResource (IResource resource) >+ { >+ if (resource == null) >+ return getDefaultVMInstall (); >+ >+ J9PropertyPage propertyPage = new J9PropertyPage (resource); >+ if (propertyPage == null) >+ return getDefaultVMInstall (); >+ >+ >+ String j9Name = getVMNameFromVersion (propertyPage.getCurrentJ9()); >+ if (j9Name != null) >+ return J9VMContentProvider.getVMfromName(j9Name); >+ return getDefaultVMInstall (); >+ } >+ >+ public static IVMInstall getDefaultVMInstall () >+ { >+ return J9VMContentProvider.getVMInstallFromResource ((IJavaProject) null); >+ } >+ public static String getDefaultVMName () >+ { >+ IVMInstall defaultJ9 = getDefaultVMInstall(); >+ return defaultJ9.getName(); >+ } >+ >+ public static String getDefaultVMVersion () >+ { >+ IVMInstall defaultJ9 = getDefaultVMInstall(); >+ return getVMVersionFromName (defaultJ9.getName()); >+ } >+ >+ >+} >Index: j9/org/eclipse/jdt/internal/launching/j9/J9VMInstall.java >=================================================================== >RCS file: j9/org/eclipse/jdt/internal/launching/j9/J9VMInstall.java >diff -N j9/org/eclipse/jdt/internal/launching/j9/J9VMInstall.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ j9/org/eclipse/jdt/internal/launching/j9/J9VMInstall.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,140 @@ >+/******************************************************************************* >+ * Copyright (c) 2002, 2004 IBM Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Lester Lopez (IBM Corp.) - Support latest version of JVM and Eclipse. >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.launching.j9; >+ >+import java.io.BufferedReader; >+import java.io.IOException; >+import java.io.InputStream; >+import java.io.InputStreamReader; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.debug.core.ILaunchManager; >+import org.eclipse.jdt.launching.AbstractVMInstall; >+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; >+import org.eclipse.jdt.launching.IVMInstallType; >+import org.eclipse.jdt.launching.IVMRunner; >+ >+public class J9VMInstall extends AbstractVMInstall { >+ >+ private final static String J9_VERSION_PREFIX = "J9 - VM for the Java(TM) platform, Version "; //$NON-NLS-1$ >+ // TODO: Standardize a location to store this and change each version. >+ private final static String J9_VERSION_DEFAULT = "2.2"; //$NON-NLS-1$ >+ private String j9Version; >+ >+ /** >+ * Constructor for J9VM >+ */ >+ J9VMInstall(IVMInstallType type, String id) { >+ super(type, id); >+ } >+ >+ /** >+ * @see IVMInstall#getVMRunner(String) >+ */ >+ public IVMRunner getVMRunner(String mode) { >+ if (ILaunchManager.RUN_MODE.equals(mode)) { >+ return new J9VMRunner(this); >+ } else if (ILaunchManager.DEBUG_MODE.equals(mode)) { >+ try { >+ if (is21J9Version()) { >+ return new J9DebugServerVMRunner(this); >+ } >+ else { >+ return new J9DebugVMRunner(this); >+ } >+ } >+ catch (CoreException e) { >+ return new J9DebugVMRunner(this); >+ } >+ } >+ return null; >+ } >+ >+ public Process getVersionProcess() throws IOException { >+ J9VMRunner runner = new J9VMRunner(this); >+ return runner.getVersionProcess(); >+ } >+ >+ /** >+ * Get the version identifier as returned by j9 -version >+ * Throws CoreException if version cannot be determined. >+ */ >+ public String getJ9Version() throws CoreException { >+ if (j9Version == null) { >+ try { >+ Process p = getVersionProcess(); >+ InputStream is = p.getInputStream(); >+ BufferedReader br = new BufferedReader(new InputStreamReader(is)); >+ for(;;) { >+ String line = br.readLine(); >+ if (line == null) >+ { >+ j9Version = J9_VERSION_DEFAULT; >+ break; >+ } >+ if (line != null) { // && line.startsWith(J9_VERSION_PREFIX)) { >+ j9Version = line; //line.substring(J9_VERSION_PREFIX.length()); >+ break; >+ } >+ } >+ if (j9Version == null) { >+ InputStream es = p.getErrorStream(); >+ BufferedReader er = new BufferedReader(new InputStreamReader(es)); >+ StringBuffer msg = new StringBuffer(); >+ String line = null; >+ do { >+ line = er.readLine(); >+ if (line != null) { >+ msg.append(line); >+ msg.append("\n"); //$NON-NLS-1$ >+ } >+ } while (line != null); >+// J9LaunchingPlugin.abort(msg.toString(), null, IJavaLaunchConfigurationConstants.ERR_VM_LAUNCH_ERROR); >+ J9LaunchingPlugin.log(msg.toString(), null, IJavaLaunchConfigurationConstants.ERR_VM_LAUNCH_ERROR); >+ j9Version = J9_VERSION_DEFAULT; >+ } >+ } catch (IOException e) { >+ String msg = J9LauncherMessages.getString("J9Launching.Error_when_executing_j9_1"); //$NON-NLS-1$ >+// J9LaunchingPlugin.abort(msg, e, IJavaLaunchConfigurationConstants.ERR_VM_LAUNCH_ERROR); >+ J9LaunchingPlugin.log(msg, e, IJavaLaunchConfigurationConstants.ERR_VM_LAUNCH_ERROR); >+ j9Version=J9_VERSION_DEFAULT; >+ } >+ } >+ return j9Version; >+ } >+ >+ /** >+ * Return true if the j9 version is before 2.0 >+ * @throws CoreException if version cannot be determined. >+ */ >+ public boolean isPre20J9Version() throws CoreException { >+ String j9Version = getJ9Version(); >+ return j9Version != null && j9Version.compareTo("2.0") < 0; //$NON-NLS-1$ >+ } >+ >+ /** >+ * Returns true if the j9 version is 2.1 or greater >+ * @throws CoreException if version cannot be determined. >+ */ >+ public boolean is21J9Version() throws CoreException { >+ String j9Version = getJ9Version(); >+ return j9Version != null && j9Version.compareTo("2.0") > 0; //$NON-NLS-1$ >+ } >+ /** >+ * Return true if the j9 version is before 2.0 >+ * @throws CoreException if version cannot be determined. >+ */ >+ public boolean isPre22J9Version() throws CoreException { >+ String j9Version = getJ9Version(); >+ return j9Version != null && j9Version.compareTo("2.2") < 0; //$NON-NLS-1$ >+ } >+} >Index: j9/org/eclipse/jdt/internal/launching/j9/J9VMInstallType.java >=================================================================== >RCS file: j9/org/eclipse/jdt/internal/launching/j9/J9VMInstallType.java >diff -N j9/org/eclipse/jdt/internal/launching/j9/J9VMInstallType.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ j9/org/eclipse/jdt/internal/launching/j9/J9VMInstallType.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,245 @@ >+/******************************************************************************* >+ * Copyright (c) 2002, 2004 IBM Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Lester Lopez (IBM Corp.) - Support latest version of JVM and Eclipse. >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.launching.j9; >+ >+import java.io.File; >+import java.net.URL; >+import java.util.ArrayList; >+import java.util.List; >+ >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtensionPoint; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.jdt.launching.AbstractVMInstallType; >+import org.eclipse.jdt.launching.IVMInstall; >+import org.eclipse.jdt.launching.LibraryLocation; >+import org.eclipse.update.configurator.ConfiguratorUtils; >+import org.eclipse.update.configurator.IPlatformConfiguration.ISiteEntry; >+ >+public class J9VMInstallType extends AbstractVMInstallType { >+ >+ public IVMInstall doCreateVMInstall(String id) { >+ return new J9VMInstall(this, id); >+ } >+ >+ public String getName() { >+ return J9LauncherMessages.getString("J9VMType.name"); //$NON-NLS-1$ >+ } >+ >+ /** >+ * @see IVMInstallType#validateInstallLocation(java.io.File) >+ * Check if the j9 vm executable and the detected libraries exist. >+ */ >+ public IStatus validateInstallLocation(File installLocation) { >+ if (isInstallLocationValid(installLocation)) { >+ return new Status(IStatus.OK, J9LaunchingPlugin.getUniqueIdentifier(), 0, "ok", null); //$NON-NLS-1$ >+ } >+ return new Status(IStatus.ERROR, J9LaunchingPlugin.getUniqueIdentifier(), 0, J9LauncherMessages.getString("J9VMType.error.notRoot"), null); //$NON-NLS-1$ >+ } >+ >+ /** >+ * Check if the j9 vm executable and the detected libraries exist. >+ */ >+ private boolean isInstallLocationValid(File installLocation) { >+ File java= new File(installLocation, "bin"+File.separator+"j9"); //$NON-NLS-2$ //$NON-NLS-1$ >+ File javaExe= new File(installLocation, "bin"+File.separator+"j9.exe"); //$NON-NLS-2$ //$NON-NLS-1$ >+ if (java.isFile() || javaExe.isFile()) { >+ // KMH: Save this for next updates when we move the J9 to each libary. >+ // return true; >+ LibraryLocation libraryLocations[] = getDefaultLibraryLocations(installLocation); >+ boolean allLibrariesExist = true; >+ for (int i = 0; i < libraryLocations.length; i++) { >+ if (!libraryExists(libraryLocations[i])) { >+ allLibrariesExist = false; >+ } >+ } >+ if (allLibrariesExist) { >+ return true; >+ } >+ } >+ return false; >+ } >+ >+ /** >+ * Find all of the entries related to the J9VMInstallLocations Extension Point >+ * @return localData from extension point >+ */ >+ public IConfigurationElement[] getConfigurationElement () >+ { >+ IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(J9LaunchingPlugin.getUniqueIdentifier() + ".J9VMInstallLocations"); //$NON-NLS-1$ >+ IConfigurationElement[] configs= extensionPoint.getConfigurationElements(); >+ return configs; >+ } >+ >+ /** >+ * Get the location of the J9 version if available for this path >+ * @param configs The J9VMInstallLocations extension point data >+ * @param sites The possible sites where it can be installed >+ * @return >+ */ >+ public File getHomePath (IConfigurationElement configs, ISiteEntry sites[]) >+ { >+ String relPath = configs.getAttribute("path"); //$NON-NLS-1$ >+ for (int j = 0; j < sites.length; j++) { >+ URL siteURL = sites[j].getURL(); >+ IPath path = new Path(siteURL.getPath()); >+ path = path.append(relPath); >+ File home = new File(path.toOSString()); >+ if (home.exists() && isInstallLocationValid(home)) { >+ return home; >+ } >+ } >+ return null; >+ } >+ /** >+ * @see IVMInstallType#detectInstallLocation() >+ * Matches the first J9 VM found in the list of locations specified in a J9VMInstallLocations extension, or else >+ * the J9 VM the workbench may be running on. >+ * A J9VMInstallLocation extension specifies a path to the J9 VM home relative to the >+ * known configured sites. >+ */ >+ // NOTE: This is where we find the J9 >+ public File detectInstallLocation() { >+ IConfigurationElement[] configs = getConfigurationElement(); >+ >+ File home; >+ // NOTE: This is a list of sites where the root of the eclipse tree is located. >+ // NOTE: The search order here is to look at the first entry in an extension point and see >+ // NOTE: If that can be found as a child of one of these directories. If not, keep on going. >+ // NOTE: Once one match is found, stop looking. >+ // >+ // NOTE: Added attribute "current" to try to refine search to not be arbitrary order. Look for >+ // NOTE: those marked current, Value="true" first, hopefully there will be only one, but order if >+ // NOTE: more then one is arbitrary >+ >+ ISiteEntry sites[] = ConfiguratorUtils.getCurrentPlatformConfiguration().getConfiguredSites(); >+ for (int i= 0; i < configs.length; i++) { >+ // Look to see if this is marked as the current (i.e. latest) J9 >+ String isCurrent = configs[i].getAttribute ("current"); //$NON-NLS-1$ >+ if (isCurrent != null) >+ if (isCurrent.compareToIgnoreCase("true") == 0) //$NON-NLS-1$ >+ { >+ home = getHomePath (configs[i], sites); >+ if (home != null) >+ return home; >+ } >+ } >+ for (int i= 0; i < configs.length; i++) { >+ // Look to see if this is marked as the current (i.e. latest) J9 >+ String isCurrent = configs[i].getAttribute ("current"); //$NON-NLS-1$ >+ if (isCurrent == null || isCurrent.compareToIgnoreCase("true") != 0) //$NON-NLS-1$ >+ { >+ home = getHomePath (configs[i], sites); >+ if (home != null) >+ return home; >+ } >+ } >+ >+ >+ if (!"J9".equals(System.getProperty("java.vm.name"))) //$NON-NLS-2$ //$NON-NLS-1$ >+ return null; >+ >+ home = new File (System.getProperty("java.home")); //$NON-NLS-1$ >+ if (home.exists() && isInstallLocationValid(home)) { >+ return home; >+ } >+ >+ return null; >+ } >+ >+ /** >+ * Get the symbolic name for a J9 implementation from the J9VMInstallLocations Extension Point >+ * @param name The name that comes from the calling code is the end of the path for the ive directory >+ * @return >+ */ >+ public String getSymbolicName (String name) >+ { >+ IConfigurationElement[] configs = getConfigurationElement(); >+ for (int i= 0; i < configs.length; i++) >+ { >+ String relPath = configs[i].getAttribute("path"); //$NON-NLS-1$ >+ if (relPath != null && relPath.endsWith(name)) >+ { >+ String symbolicName = configs[i].getAttribute ("symbolicName" ); //$NON-NLS-1$ >+ if (symbolicName != null) >+ return symbolicName; >+ } >+ } >+ >+ return null; >+ } >+ >+ /** >+ * @see IVMInstallType#getDefaultSystemLibraryDescription(File) >+ */ >+ public LibraryLocation[] getDefaultLibraryLocations(File installLocation) { >+ IPath libFolder = new Path(installLocation + "/lib"); //$NON-NLS-1$ >+ IPath jclFolder = null; >+ >+ boolean libraryFound = false; >+ List libraryList = new ArrayList(3); >+ >+ String [] foundationAttempts = {"/jclFoundation10", "/jclFoundation"}; >+ >+ for (int i = 0; i < foundationAttempts.length && !libraryFound; i++) >+ { >+ jclFolder = new Path(libFolder + foundationAttempts[i]); //$NON-NLS-1$ >+ >+ LibraryLocation libraryLocation; >+ >+ libraryLocation = getLibraryLocation(jclFolder, "classes.zip", "source/source.zip"); //$NON-NLS-1$ //$NON-NLS-2$ >+ if (libraryExists(libraryLocation)) { >+ libraryFound = true; >+ libraryList.add(libraryLocation); >+ >+ libraryLocation = getLibraryLocation(jclFolder, "locale.zip", "source/locale-src.zip"); //$NON-NLS-1$ //$NON-NLS-2$ >+ if (libraryExists(libraryLocation)) { >+ libraryList.add(libraryLocation); >+ } >+ >+ libraryLocation = getLibraryLocation(libFolder, "charconv.zip", "charconv-src.zip"); //$NON-NLS-1$ //$NON-NLS-2$ >+ if (libraryExists(libraryLocation)) { >+ libraryList.add(libraryLocation); >+ } >+ } >+ >+ } >+ LibraryLocation libraryLocations[] = new LibraryLocation[libraryList.size()]; >+ libraryList.toArray(libraryLocations); >+ return libraryLocations; >+ } >+ >+ /** >+ * Return a LibraryLocation for one of the J9 system libraries. >+ */ >+ private static LibraryLocation getLibraryLocation( >+ IPath libPath, >+ String libName, >+ String libSrc) { >+ IPath lib = libPath.append(libName); >+ IPath source = libPath.append(libSrc); >+ IPath path = new Path(""); //$NON-NLS-1$ >+ return new LibraryLocation(lib, source, path); >+ } >+ >+ /** >+ * Test if the system library of the LibraryLocation (still) exists on the file system. >+ */ >+ private static boolean libraryExists(LibraryLocation libraryLocation) { >+ return libraryLocation.getSystemLibraryPath().toFile().exists(); >+ } >+ >+} >Index: j9/org/eclipse/jdt/internal/launching/j9/J9VMRunner.java >=================================================================== >RCS file: j9/org/eclipse/jdt/internal/launching/j9/J9VMRunner.java >diff -N j9/org/eclipse/jdt/internal/launching/j9/J9VMRunner.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ j9/org/eclipse/jdt/internal/launching/j9/J9VMRunner.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,600 @@ >+/******************************************************************************* >+ * Copyright (c) 2002, 2004 IBM Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Lester Lopez (IBM Corp.) - Support latest version of JVM and Eclipse. >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.launching.j9; >+ >+import java.io.File; >+import java.io.FileNotFoundException; >+import java.io.IOException; >+import java.net.URL; >+import java.util.ArrayList; >+import java.util.Arrays; >+import java.util.List; >+import java.util.Locale; >+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.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.internal.core.DebugCoreMessages; >+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; >+import org.eclipse.jdt.launching.IVMInstall; >+import org.eclipse.jdt.launching.LibraryLocation; >+import org.eclipse.jdt.launching.VMRunnerConfiguration; >+import org.eclipse.jdt.launching.j9.J9Launching; >+import org.eclipse.jdt.launching.j9.J9VMOptionsParser; >+ >+public class J9VMRunner extends JavaVMRunner { >+ // boolean DEBUG; >+ // private static J9LaunchingPlugin plugin; >+ >+ public J9VMRunner(IVMInstall vmInstance) { >+ super(vmInstance); >+ >+ // String dprop = System.getProperty("debug"); >+ // if ( (dprop != null) && (dprop.equals("true"))) { >+ // DEBUG = true; >+ // } >+ } >+ >+ public String[] getCmdLine(int port, int debugServerPort, String debugHost, >+ VMRunnerConfiguration config) throws CoreException { >+ String location = getJDKLocation(); >+ String program = constructProgramString(location, config); >+ List arguments = new ArrayList(); >+ >+ arguments.add(program); >+ >+ String[] bootCP = config.getBootClassPath(); >+ String[] cp = config.getClassPath(); >+ String[] vmArgs = config.getVMArguments(); >+ String[] programArgs = config.getProgramArguments(); >+ >+ >+ // 12-08-05 cf Commented out for J2 options >+ // Set up the the bootclasspath >+ // if (bootCP != null) { >+ // String bootpathOpt = isOldJ9Version() ? "-bp:" : "-Xbootclasspath:"; >+ // //$NON-NLS-1$ //$NON-NLS-2$ >+ // if (bootCP.length > 0) { >+ // arguments.add(bootpathOpt+convertClassPath(bootCP)); >+ // } else { >+ // // empty >+ // arguments.add(bootpathOpt); >+ // } >+ // } >+ >+ if (cp.length > 0) { >+ arguments.add("-classpath"); //$NON-NLS-1$ >+ arguments.add(convertClassPath(cp)); >+ } >+ >+ if (port != -1) { >+ if (isNewJ9Version()) { >+ arguments >+ .add("-Xrunjdwp:transport=dt_socket,address=" + debugHost + ":" + port); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >+ arguments.add("-Xdebug"); //$NON-NLS-1$ >+ if (debugServerPort != -1) { >+ arguments >+ .add("-Xrdbginfo:" + debugHost + ":" + debugServerPort); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ } else { >+ arguments.add("-debug:" + port); //$NON-NLS-1$ >+ } >+ } >+ >+ addArguments(vmArgs, arguments); >+ >+ String classToLaunch = config.getClassToLaunch(); >+ if (classToLaunch.length() > 0) { >+ arguments.add(classToLaunch); >+ } >+ >+ addArguments(programArgs, arguments); >+ >+ String[] cmdLine = new String[arguments.size()]; >+ arguments.toArray(cmdLine); >+ >+ return cmdLine; >+ } >+ >+ public void addVMOptionsFromRules(VMRunnerConfiguration config) >+ throws CoreException { >+ List additionalOptions = extractVMOptionsFromRules(config); >+ if (additionalOptions.size() > 0) { >+ List newArgList = new ArrayList(); >+ newArgList.addAll(additionalOptions); >+ newArgList.addAll(Arrays.asList(config.getVMArguments())); >+ String[] newVmArgs = (String[]) newArgList >+ .toArray(new String[newArgList.size()]); >+ config.setVMArguments(newVmArgs); >+ } >+ } >+ >+ public void addJitArgumentWhenNotDefault(VMRunnerConfiguration config) >+ throws CoreException { >+ if (isOldJ9Version()) { >+ if (!containsOption(config.getVMArguments(), "-jit")) { //$NON-NLS-1$ >+ List newArgList = new ArrayList(); >+ newArgList.add("-jit"); //$NON-NLS-1$ >+ newArgList.addAll(Arrays.asList(config.getVMArguments())); >+ String[] newVmArgs = (String[]) newArgList >+ .toArray(new String[newArgList.size()]); >+ config.setVMArguments(newVmArgs); >+ } >+ } >+ } >+ >+ protected J9VMInstall getJ9VMInstall() { >+ return (J9VMInstall) fVMInstance; >+ } >+ >+ /** >+ * @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; >+ } >+ >+ // Add -jit argument for old VMs >+ addJitArgumentWhenNotDefault(config); >+ >+ // Convert configuration to use -jxe option if requested. >+ config = J9Launching.adaptVMRunnerConfiguration(config, >+ getJ9VMInstall()); >+ >+ // Add VM options extracted from rules found on the bootclasspath >+ addVMOptionsFromRules(config); >+ >+ String[] cmdLine = getCmdLine(-1, -1, null, config); >+ File workingDir = getWorkingDir(config); >+ >+ // Added plugin tracing, this can be activated in the Run-time Workspace >+ if (J9LaunchingPlugin.getDefault().isDebugging()) { >+ // Display the command line args in the Console >+ System.out.println("Command Line Args:"); >+ for (int i = 0; i < cmdLine.length; i++) { >+ // If it starts with "-", it's an option so join it to the next >+ // string. >+ if ((cmdLine[i].startsWith("-classpath")) ||(cmdLine[i].startsWith("-cp")) ) { >+ String tStr = cmdLine[i++].toString(); >+ if (!cmdLine[i].startsWith("-")) { >+ System.out.println("\t" + tStr + " " >+ + cmdLine[i].toString()); >+ } else { >+ System.out.println("\t" + tStr); >+ System.out.println("\t" + cmdLine[i].toString()); >+ } >+ } else { >+ System.out.println("\t" + cmdLine[i].toString()); >+ } >+ } >+ } >+ >+ // check for cancellation >+ if (monitor.isCanceled()) { >+ return; >+ } >+ >+ Process p = exec(cmdLine, workingDir); >+ if (p != null) { >+ IProcess process = DebugPlugin.newProcess(launch, p, J9Launching >+ .renderProcessLabel(cmdLine)); >+ process.setAttribute(IProcess.ATTR_CMDLINE, J9Launching >+ .renderCommandLine(cmdLine)); >+ } >+ } >+ >+ /** >+ * Launch the VM. If the OS is Linux, you must set teh LD_LIBRARY_PATH >+ * environment variable to {ive}\bin prior to launch. NOTE! This may cause >+ * some expectations to break. There is no way from within Java to get the >+ * environment variables used to launch your VM so there is no way to simply >+ * append LD_LIBRARY_PATH to the environment variables. This code will >+ * replace them with that variable. See Bug 98297 for further discussions. >+ */ >+ protected Process exec(String[] cmdLine, File workingDirectory) >+ throws CoreException { >+ String[] env = null; >+ try { >+ //Defect 99510- modified by Sri! -start >+ //On Linux systems, AWT apps seem to need these 3 environment >+ // variables to run. >+ // So we use the env to get these and if env is not set on systems >+ // then use the >+ // java environment (using properties to get the same and as a third >+ // option use default values. >+ String osName = System.getProperty("os.name"); //$NON-NLS-1$ >+ if (osName != null) { >+ osName = osName.toLowerCase(); >+ if (osName.indexOf("linux") != -1) { //$NON-NLS-1$ >+ >+ //Get the LD_LIBRARY_PATH value >+ String libPath = getJ9VMInstall().getInstallLocation() >+ .getAbsolutePath() >+ + File.separator + "bin"; >+ >+ //execute env to get the environment for HOME and DISPLAY >+ String homeEnv = null; >+ String dispEnv = null; >+ String localeEnv = null; >+ String gdmlangEnv = null; >+ String lppathEnv = null; >+ try { >+ >+ java.util.Properties prop = new java.util.Properties(); >+ prop.load(Runtime.getRuntime().exec("env") >+ .getInputStream()); >+ homeEnv = (String) prop.get("HOME"); >+ dispEnv = (String) prop.get("DISPLAY"); >+ localeEnv = (String) prop.get("LANG"); >+ gdmlangEnv = (String) prop.get("GDM_LANG"); >+ lppathEnv = (String) prop.get("LD_LIBRARY_PATH"); >+ >+ } catch (IOException e) { >+ } >+ >+ //env is not set on system, use the java environment >+ if (homeEnv == null) { >+ try { >+ homeEnv = System.getProperty("user.home"); >+ } catch (SecurityException e) { >+ } >+ }//homeEnv >+ >+ //if at this point we don't have proper values, give >+ // default values >+ if (homeEnv == null) >+ homeEnv = "/root"; >+ if (dispEnv == null) >+ dispEnv = ":0"; >+ if (localeEnv == null) >+ localeEnv = Locale.getDefault().toString(); >+ if (gdmlangEnv == null) >+ gdmlangEnv = localeEnv + ".UTF-8"; //uses format >+ // en_US.UTF-8 >+ >+ // Make environment list >+ env = new String[] { >+ "LD_LIBRARY_PATH=" + libPath + ":" + lppathEnv, >+ "HOME=" + homeEnv, "LANG=" + localeEnv, >+ "GDM_LANG=" + gdmlangEnv, "DISPLAY=" + dispEnv }; >+ >+ }//linux specific >+ >+ } >+ } catch (Exception e) { >+ } >+ //Defect 99510- modified by Sri! - end >+ return exec(cmdLine, env, workingDirectory); >+ } >+ >+ /** >+ * The version process method needs to use the LD_LIBRARY_PATH fix as well. >+ * >+ * @return >+ * @throws IOException >+ */ >+ public Process getVersionProcess() throws IOException { >+ VMRunnerConfiguration config = new VMRunnerConfiguration( >+ "", new String[] {}); //$NON-NLS-1$ >+ String JDKLocation = getJDKLocation(); >+ String j9Command = constructProgramString(JDKLocation, config); >+ >+ // String versionCommand[] = { j9Command, "-version" }; //$NON-NLS-1$ >+ >+ List arguments = new ArrayList(); >+ >+ arguments.add(j9Command); >+ >+ J9VMInstallType j9VMInstallType = (J9VMInstallType) getJ9VMInstall() >+ .getVMInstallType(); >+ LibraryLocation[] libraryLocation = j9VMInstallType >+ .getDefaultLibraryLocations(new File(JDKLocation)); >+ >+ if (libraryLocation != null) { >+ String bootpathOpt = "-Xbootclasspath:"; //$NON-NLS-1$ //$NON-NLS-2$ >+ if (libraryLocation.length > 0) { >+ arguments.add(bootpathOpt + convertClassPath(libraryLocation)); >+ } else { >+ // empty >+ arguments.add(bootpathOpt); >+ } >+ } >+ >+ String cp = null; >+ >+ /* >+ * LL: Migration to 3.0: getDescriptor().getInstallURL() are both now >+ * deprecated. >+ */ >+ URL pluginURL = J9LaunchingPlugin.getDefault().getBundle() >+ .getEntry("/"); >+ /* >+ * LL: 108345: Check for existence of jar file. If it doesn't exist, >+ * assume it is a runtime workbench and look for the bin folder then. >+ * Note that we are harcoding the name of the output folder to bin. This >+ * is not necessarily true since it can be configured. >+ */ >+ URL newURL = null; >+ >+ try { >+ newURL = Platform.resolve(new URL(pluginURL + "j9launching.jar")); >+ } catch (FileNotFoundException e) { >+ newURL = Platform.resolve(new URL(pluginURL + "bin")); >+ } >+ >+ if (newURL != null && newURL.getProtocol().equals("file")) { >+ cp = newURL.getFile().replace('/', File.separatorChar); >+ arguments.add("-classpath"); //$NON-NLS-1$ >+ arguments.add(cp); >+ } >+ arguments.add("-jcl:foun10"); >+ arguments.add("org.eclipse.jdt.internal.launching.j9.J9VMVersion"); >+ String[] cmdLine = new String[arguments.size()]; >+ arguments.toArray(cmdLine); >+ >+ try { >+ //return exec(versionCommand, null); >+ return exec(cmdLine, null); >+ } catch (CoreException e) { >+ // since we use a copy of the DebugPluging.exec to launch this, >+ // we'll need to worry about CoreExceptions, not IOExceptions. >+ // However, if we DO catch a CoreException chances are it's been >+ // caused by an IOException. Try to extract and rethrow such a >+ // beast. Otherwise create and throw a new one. >+ Throwable t = e.getStatus().getException(); >+ if (t instanceof IOException) { >+ throw (IOException) t; >+ } else { >+ throw new IOException(); >+ } >+ } >+ } >+ >+ /** >+ * Copy of DebugPlugin.exec() that supports environment variables. >+ * >+ * @param cmdLine >+ * @param env >+ * @param workingDirectory >+ * @return >+ * @throws CoreException >+ */ >+ public static Process exec(String[] cmdLine, String[] env, >+ File workingDirectory) throws CoreException { >+ Process p = null; >+ try { >+ if (workingDirectory == null) { >+ p = Runtime.getRuntime().exec(cmdLine, env); >+ } else { >+ p = Runtime.getRuntime().exec(cmdLine, env, workingDirectory); >+ } >+ } catch (IOException e) { >+ if (p != null) { >+ p.destroy(); >+ } >+ Status status = new Status( >+ IStatus.ERROR, >+ DebugPlugin.getUniqueIdentifier(), >+ DebugPlugin.INTERNAL_ERROR, >+ DebugCoreMessages.DebugPlugin_Exception_occurred_executing_command_line__1,e); >+ >+ throw new CoreException(status); >+ } catch (NoSuchMethodError e) { >+ //attempting launches on 1.2.* - no ability to set working >+ // directory >+ IStatus status = new Status( >+ IStatus.ERROR, >+ DebugPlugin.getUniqueIdentifier(), >+ DebugPlugin.ERR_WORKING_DIRECTORY_NOT_SUPPORTED, >+ DebugCoreMessages.DebugPlugin_Eclipse_runtime_does_not_support_working_directory_2,e); >+ IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler( >+ status); >+ >+ if (handler != null) { >+ Object result = handler.handleStatus(status, null); >+ if (result instanceof Boolean >+ && ((Boolean) result).booleanValue()) { >+ p = exec(cmdLine, env, null); >+ } >+ } >+ } >+ return p; >+ } >+ >+ 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$ >+ if (command == null) { >+ int directoryLength = program.length(); >+ program.append("j9w.exe"); //$NON-NLS-1$ >+ File j9w = new File(program.toString()); >+ >+ boolean localMachine = false; >+ if (location != null) { >+ if (location.indexOf("\\win32\\") != -1) // if win32 is in the >+ // path I am local >+ localMachine = true; >+ else if (location.indexOf("\\linux\\") != -1) // if linux is in >+ // the path I am >+ // local >+ localMachine = true; >+ else if (location.indexOf("\\runtimes\\") == -1) // if runtimes >+ // is not in >+ // the path, I >+ // am local >+ localMachine = true; >+ } >+ if (!j9w.exists()) { >+ program.replace(directoryLength, program.length(), "j9"); //$NON-NLS-1$ >+ } >+ // only check to see if runAsConsole is set for platforms that are >+ // not emulator/local platforms >+ if (!localMachine && J9Launching.runAsConsole(map)) >+ program.replace(directoryLength, program.length(), "j9"); //$NON-NLS-1$ >+ } else { >+ program.append(command); >+ } >+ >+ return program.toString(); >+ } >+ >+ protected boolean shouldIncludeInPath(String path) { >+ return true; >+ } >+ >+ protected String convertClassPath(String[] cp) { >+ int pathCount = 0; >+ StringBuffer buf = new StringBuffer(); >+ for (int i = 0; i < cp.length; i++) { >+ if (pathCount > 0) { >+ buf.append(File.pathSeparator); >+ } >+ buf.append(cp[i]); >+ pathCount++; >+ } >+ return buf.toString(); >+ } >+ >+ protected String convertClassPath(LibraryLocation[] cp) { >+ int pathCount = 0; >+ StringBuffer buf = new StringBuffer(); >+ for (int i = 0; i < cp.length; i++) { >+ if (pathCount > 0) { >+ buf.append(File.pathSeparator); >+ } >+ buf.append(cp[i].getSystemLibraryPath()); >+ pathCount++; >+ } >+ return buf.toString(); >+ } >+ >+ protected boolean isOldJ9Version() throws CoreException { >+ return ((J9VMInstall) fVMInstance).isPre20J9Version(); >+ } >+ >+ protected boolean isNewJ9Version() throws CoreException { >+ return ((J9VMInstall) fVMInstance).is21J9Version(); >+ } >+ >+ public List extractVMOptionsFromRules(VMRunnerConfiguration config) >+ throws CoreException { >+ String[] bootCP = config.getBootClassPath(); >+ String[] vmArgs = config.getVMArguments(); >+ String optionName = extractOptionName(config.getClassToLaunch()); >+ // When executing using -jar, the jar is not on the boot path >+ boolean executeFromArchive = optionName.equalsIgnoreCase("jxe") || //$NON-NLS-1$ >+ containsOption(vmArgs, "-jxe"); //$NON-NLS-1$ >+ >+ // When using default bootclaspath, make sure that the libraries >+ // on the default bootclasspath are searched for rules >+ if (bootCP == null && !executeFromArchive) { >+ LibraryLocation libraries[] = fVMInstance.getLibraryLocations(); >+ if (libraries == null) { >+ libraries = fVMInstance.getVMInstallType() >+ .getDefaultLibraryLocations( >+ fVMInstance.getInstallLocation()); >+ } >+ bootCP = new String[libraries.length]; >+ for (int i = 0; i < libraries.length; i++) { >+ bootCP[i] = libraries[i].getSystemLibraryPath().toOSString(); >+ } >+ } >+ >+ ArrayList result = new ArrayList(); >+ if (bootCP != null) { >+ for (int i = 0; i < bootCP.length; i++) { >+ result.addAll(J9VMOptionsParser.extractVMOptions(bootCP[i])); >+ } >+ >+ for (int j = result.size() - 1; j >= 0; j--) { >+ String option = (String) result.get(j); >+ if (containsOption(vmArgs, option)) { >+ result.remove(j); >+ } >+ } >+ } >+ >+ return result; >+ } >+ >+ private static boolean containsOption(String[] vmArgs, String option) { >+ String optionName = extractOptionName(option); >+ for (int i = 0; i < vmArgs.length; i++) { >+ if (extractOptionName(vmArgs[i]).equalsIgnoreCase(optionName)) { >+ return true; >+ } >+ } >+ return false; >+ } >+ >+ public static String extractOptionName(String option) { >+ if (option.startsWith("-no")) { //$NON-NLS-1$ >+ option = option.substring(3); >+ } else if (option.startsWith("-")) { //$NON-NLS-1$ >+ option = option.substring(1); >+ } else { >+ return ""; //$NON-NLS-1$ >+ } >+ int p = option.indexOf(':'); >+ if (p == -1) >+ p = option.indexOf(' '); >+ return p == -1 ? option : option.substring(0, p); >+ } >+ >+ /** >+ * Tests whether the current execution is a runtime workbench. >+ * >+ * @return true if the current execution is a runtime workbench, otherwise >+ * false. >+ */ >+ public static boolean isRunTimeWorkBench() { >+ String[] sCmdList = Platform.getCommandLineArgs(); >+ >+ for (int iCount = 0; iCount < sCmdList.length; iCount++) { >+ /* >+ * LL: -pdelaunch is passed as a command line argument when running >+ * a runtime-workbench. >+ */ >+ if (sCmdList[iCount].toString().equalsIgnoreCase("-pdelaunch")) { >+ return true; >+ } >+ } >+ return false; >+ } //isRunTimeWorkBench >+} >Index: j9/org/eclipse/jdt/internal/launching/j9/J9VMVersion.java >=================================================================== >RCS file: j9/org/eclipse/jdt/internal/launching/j9/J9VMVersion.java >diff -N j9/org/eclipse/jdt/internal/launching/j9/J9VMVersion.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ j9/org/eclipse/jdt/internal/launching/j9/J9VMVersion.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.launching.j9; >+ >+/** >+ * Simple class to be executed by J9VMRunner to figure out the J9 version >+ */ >+public class J9VMVersion { >+ >+ public static void main(String[] args) { >+ System.out.println (System.getProperty( "java.vm.version", "")); >+ } >+} >Index: j9/org/eclipse/jdt/internal/launching/j9/JavaVMRunner.java >=================================================================== >RCS file: j9/org/eclipse/jdt/internal/launching/j9/JavaVMRunner.java >diff -N j9/org/eclipse/jdt/internal/launching/j9/JavaVMRunner.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ j9/org/eclipse/jdt/internal/launching/j9/JavaVMRunner.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,70 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.launching.j9; >+ >+import java.io.File; >+import java.text.MessageFormat; >+import java.util.List; >+ >+import org.eclipse.core.runtime.CoreException; >+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 fVMInstance; >+ >+ public JavaVMRunner(IVMInstall vmInstance) { >+ fVMInstance= vmInstance; >+ } >+ >+ 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= fVMInstance.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(J9LauncherMessages.getString("JavaVMRunner.Specified_working_directory_does_not_exist_or_is_not_a_directory"), new String[] {path}), null, IJavaLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST); //$NON-NLS-1$ >+ } >+ return dir; >+ } >+ >+ /** >+ * @see VMRunner#getPluginIdentifier() >+ */ >+ protected String getPluginIdentifier() { >+ return J9LaunchingPlugin.getUniqueIdentifier(); >+ } >+} >Index: j9/org/eclipse/jdt/launching/j9/IJ9LaunchConfigurationConstants.java >=================================================================== >RCS file: j9/org/eclipse/jdt/launching/j9/IJ9LaunchConfigurationConstants.java >diff -N j9/org/eclipse/jdt/launching/j9/IJ9LaunchConfigurationConstants.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ j9/org/eclipse/jdt/launching/j9/IJ9LaunchConfigurationConstants.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,83 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.launching.j9; >+ >+import org.eclipse.jdt.internal.launching.j9.J9LaunchingPlugin; >+ >+public interface IJ9LaunchConfigurationConstants { >+ >+ /** >+ * Identifier for the J9 Socket Attaching VM connector >+ * (value <code>com.ibm.ive.internal.j9.launcher.J9VMType</code>). >+ */ >+ public static final String ID_J9_VM_INSTALL_TYPE = "com.ibm.ive.internal.j9.launcher.J9VMType"; //$NON-NLS-1$ >+ >+ /** >+ * Identifier for the J9 Socket Attaching VM connector >+ * (value <code>com.ibm.ive.internal.j9.launcher.J9SocketAttachConnector</code>). >+ */ >+ public static final String ID_J9_SOCKET_ATTACH_VM_CONNECTOR = "com.ibm.ive.internal.j9.launcher.J9ConnectorDelegate"; //$NON-NLS-1$ >+ >+ /** >+ * Preference for the default J9 VM. >+ */ >+ public static final String PREF_DEFAULT_J9 = "com.ibm.ive.internal.j9.launcher.default_j9_vm"; //$NON-NLS-1$ >+ >+ /** >+ * J9 VM specific launch configuration attribute key. The value is a boolean specifying >+ * to run the J9 VM as console application or as background application. >+ */ >+ public static final String ATTR_RUN_AS_CONSOLE = J9LaunchingPlugin.getUniqueIdentifier() + ".RUN_AS_CONSOLE"; //$NON-NLS-1$ >+ >+ /** >+ * J9 VM specific launch configuration attribute key. The value is a boolean specifying >+ * to search for an executable archive on the classpath, and if found, run it using >+ * the -jxe option. >+ */ >+ public static final String ATTR_EXECUTE_FROM_ARCHIVE = J9LaunchingPlugin.getUniqueIdentifier() + ".EXECUTE_FROM_ARCHIVE"; //$NON-NLS-1$ >+ >+ /** >+ * J9 VM specific launch configuration attribute key. The value is an integer specifying >+ * the debug request timeout in milliseconds. >+ */ >+ public static final String ATTR_DEBUG_TIMEOUT = J9LaunchingPlugin.getUniqueIdentifier() + ".DEBUG_TIMEOUT"; //$NON-NLS-1$ >+ >+ /** >+ * Launch configuration attribute key. The value is an identifier of a >+ * j9 debug symbol path provider extension used to compute the symbol file lookup path >+ * for a launch configuration. When unspecified, a default symbol lookup >+ * path provider is used. >+ */ >+ public static final String ATTR_SYMBOL_PATH_PROVIDER = J9LaunchingPlugin.getUniqueIdentifier() + ".SYMBOL_PATH_PROVIDER"; //$NON-NLS-1$ >+ >+ /** >+ * Launch configuration attribute key. The value is an ordered list of >+ * strings which are mementos for associated runtime classpath entries >+ * interpreted as locations in which to look for symbol files. >+ */ >+ public static final String ATTR_SYMBOL_PATH = J9LaunchingPlugin.getUniqueIdentifier() + ".SYMBOL_PATH"; //$NON-NLS-1$ >+ >+ /** >+ * Launch configuration attribute key. The value is a boolean specifying >+ * whether a default symbol lookup path should be used. A default symbol >+ * lookup path is the same as a launch configuration's classpath. When >+ * <code>false</code> a symbol path must be specified via the >+ * <code>ATTR_SYMBOL_PATH</code> attribute. >+ */ >+ public static final String ATTR_DEFAULT_SYMBOL_PATH = J9LaunchingPlugin.getUniqueIdentifier() + ".DEFAULT_SYMBOL_PATH"; //$NON-NLS-1$ >+ >+ /** >+ * Default debug ip port number VM will be listening on. >+ */ >+ public static final String DEFAULT_DEBUG_PORT = "8096"; //$NON-NLS-1$ >+ >+} >+ >Index: j9/org/eclipse/jdt/launching/j9/J9Launching.java >=================================================================== >RCS file: j9/org/eclipse/jdt/launching/j9/J9Launching.java >diff -N j9/org/eclipse/jdt/launching/j9/J9Launching.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ j9/org/eclipse/jdt/launching/j9/J9Launching.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,560 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.launching.j9; >+ >+import java.io.File; >+import java.io.FileFilter; >+import java.io.FileInputStream; >+import java.io.IOException; >+import java.text.DateFormat; >+import java.text.MessageFormat; >+import java.util.ArrayList; >+import java.util.Arrays; >+import java.util.Date; >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Map; >+import java.util.jar.Attributes; >+import java.util.jar.JarFile; >+import java.util.jar.Manifest; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtensionPoint; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.jdi.Bootstrap; >+import org.eclipse.jdt.core.IJavaProject; >+import org.eclipse.jdt.internal.launching.LaunchingPlugin; >+import org.eclipse.jdt.internal.launching.RuntimeClasspathProvider; >+import org.eclipse.jdt.internal.launching.j9.J9ConnectorDelegate; >+import org.eclipse.jdt.internal.launching.j9.J9LauncherMessages; >+import org.eclipse.jdt.internal.launching.j9.J9LaunchingPlugin; >+import org.eclipse.jdt.internal.launching.j9.J9SocketAttachConnector; >+import org.eclipse.jdt.internal.launching.j9.J9VMContentProvider; >+import org.eclipse.jdt.internal.launching.j9.J9VMInstall; >+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; >+import org.eclipse.jdt.launching.IRuntimeClasspathEntry; >+import org.eclipse.jdt.launching.IRuntimeClasspathProvider; >+import org.eclipse.jdt.launching.IVMConnector; >+import org.eclipse.jdt.launching.IVMInstall; >+import org.eclipse.jdt.launching.IVMInstallType; >+import org.eclipse.jdt.launching.JavaRuntime; >+import org.eclipse.jdt.launching.VMRunnerConfiguration; >+import org.eclipse.jface.preference.IPreferenceStore; >+ >+import com.sun.jdi.connect.AttachingConnector; >+import com.sun.jdi.connect.ListeningConnector; >+ >+/** >+ * The central access point for J9 launching support, >+ * similar to <code>JavaRuntime</code> >+ * <p> >+ * This class provides static methods only; it is not intended to be >+ * instantiated or subclassed by clients. >+ * </p> >+ * @see org.eclipse.jdt.launching.JavaRuntime >+ */ >+public class J9Launching { >+ >+ /** >+ * Default j9 debug symbol path providers. >+ */ >+ private static IRuntimeClasspathProvider fgDefaultSymbolPathProvider = new StandardSymbolPathProvider(); >+ >+ /** >+ * Path providers keyed by id >+ */ >+ private static Map fgPathProviders = null; >+ >+ /** >+ * Check if a VM install is a J9 VM install. >+ * >+ * @param vmInstall The vm install to check. >+ * @return True if the id of the IVMInstallType of vmInstall equals ID_J9_VM_INSTALL_TYPE >+ */ >+ public static boolean isJ9VMInstall(IVMInstall vmInstall) { >+ return vmInstall.getVMInstallType().getId().equals(IJ9LaunchConfigurationConstants.ID_J9_VM_INSTALL_TYPE); >+ } >+ >+ /** >+ * Get all J9 VMs. >+ * >+ * @return all configured J9 VM instance >+ */ >+ public static IVMInstall[] getJ9VMInstalls() { >+ IVMInstallType vmInstallType = >+ JavaRuntime.getVMInstallType( >+ IJ9LaunchConfigurationConstants.ID_J9_VM_INSTALL_TYPE); >+ return vmInstallType.getVMInstalls(); >+ } >+ >+ /** >+ * Finds the J9 VM with the given name. >+ * >+ * @param name the VM name >+ * @return a VM instance, or <code>null</code> if not found >+ */ >+ public static J9VMInstall findJ9VMInstallByName(String name) { >+ IVMInstallType vmInstallType = >+ JavaRuntime.getVMInstallType( >+ IJ9LaunchConfigurationConstants.ID_J9_VM_INSTALL_TYPE); >+ return (J9VMInstall)vmInstallType.findVMInstallByName(name); >+ } >+ >+ /** >+ * Finds the J9 VM with the given id. >+ * >+ * @param id the VM id >+ * @return a VM instance, or <code>null</code> if not found >+ */ >+ public static J9VMInstall findJ9VMInstall(String id) { >+ IVMInstallType vmInstallType = >+ JavaRuntime.getVMInstallType( >+ IJ9LaunchConfigurationConstants.ID_J9_VM_INSTALL_TYPE); >+ return (J9VMInstall)vmInstallType.findVMInstall(id); >+ } >+ >+ /** >+ * Returns the path to the default J9 install, or null if there is no default J9 install. >+ * >+ * @return IPath >+ */ >+ public static IPath getDefaultIveDir() { >+ IVMInstall vm = getDefaultJ9VMInstall(); >+ >+ if (vm == null) { >+ return null; >+ } >+ >+ return new Path(vm.getInstallLocation().getAbsolutePath()); >+ } >+ >+ /** >+ * Get the default J9 VM. >+ * >+ * @return the workspace default J9VM instance, >+ * Returns <code>null</code> if no J9 VMs have been configured. >+ */ >+ public static J9VMInstall getDefaultJ9VMInstall() { >+ IPreferenceStore store = J9LaunchingPlugin.getDefault().getPreferenceStore(); >+ String id = store.getString(IJ9LaunchConfigurationConstants.PREF_DEFAULT_J9); >+ if (id == null || "".equals(id)) { //$NON-NLS-1$ >+ return null; >+ } else { >+ return findJ9VMInstall(id); >+ } >+ } >+ >+ /** >+ * Returns the VM assigned to build the given Java project >+ * if it is a J9 VM. >+ * If not, the workspace default J9 VM is returned. >+ * @param project If <code>null</code>, the default J9 VM is returned >+ * @return J9 IVMInstall of project, or the default J9 VM. >+ * Returns <code>null</code> if no J9 VMs have been configured. >+ */ >+ public static J9VMInstall getJ9VMInstall(IJavaProject project) { >+ try { >+ if (project != null) { >+ IVMInstall projectDefaultVM = null; >+ projectDefaultVM = J9VMContentProvider.getVMInstallFromResource(project); >+ if (projectDefaultVM == null) >+ projectDefaultVM = JavaRuntime.getVMInstall(project); >+ if (projectDefaultVM != null && isJ9VMInstall(projectDefaultVM)) { >+ return (J9VMInstall)projectDefaultVM; >+ } >+ } >+ } catch (CoreException e) { >+ J9LaunchingPlugin.getDefault().getLog().log(e.getStatus()); >+ } >+ return getDefaultJ9VMInstall(); >+ } >+ >+ /** >+ * Return a JDI socket transport attaching connector >+ * >+ * @exception CoreException if unable to locate the connector >+ */ >+ public static AttachingConnector getAttachingConnector() throws CoreException { >+ AttachingConnector connector= null; >+ Iterator iter= Bootstrap.virtualMachineManager().attachingConnectors().iterator(); >+ while (iter.hasNext()) { >+ AttachingConnector lc= (AttachingConnector) iter.next(); >+ if (lc.name().equals("com.sun.jdi.SocketAttach")) { //$NON-NLS-1$ >+ connector= lc; >+ break; >+ } >+ } >+ if (connector == null) { >+ J9LaunchingPlugin.abort(J9LauncherMessages.getString("J9Launching.Socket_attaching_connector_not_available"), null, IJavaLaunchConfigurationConstants.ERR_CONNECTOR_NOT_AVAILABLE); //$NON-NLS-1$ >+ } >+ return connector; >+ } >+ >+ /** >+ * >+ * @exception CoreException if unable to locate the connector >+ */ >+ public static ListeningConnector getListeningConnector() throws CoreException { >+ ListeningConnector connector= null; >+ Iterator iter= Bootstrap.virtualMachineManager().listeningConnectors().iterator(); >+ while (iter.hasNext()) { >+ ListeningConnector lc= (ListeningConnector) iter.next(); >+ if (lc.name().equals("com.sun.jdi.SocketListen")) { //$NON-NLS-1$ >+ connector= lc; >+ break; >+ } >+ } >+ if (connector == null) { >+ J9LaunchingPlugin.abort(J9LauncherMessages.getString("J9Launching.Socket_attaching_connector_not_available"), null, IJavaLaunchConfigurationConstants.ERR_CONNECTOR_NOT_AVAILABLE); //$NON-NLS-1$ >+ } >+ return connector; >+ } >+ >+ >+ /** >+ * Utility function to return string "{element} at localhost:{port}" for rendering debug target. >+ */ >+ public static String renderDebugTarget(String elementToRun, int host) { >+ String format= J9LauncherMessages.getString("J9Launching.format.dbgTarget"); //$NON-NLS-1$ >+ return MessageFormat.format(format, new String[] { elementToRun, String.valueOf(host) }); >+ } >+ >+ /** >+ * Utility function to return string "{commandLine[0]} ({timestamp})" for rendering a debug process. >+ */ >+ public static String renderProcessLabel(String[] commandLine) { >+ String format= J9LauncherMessages.getString("J9Launching.format.processLabel"); //$NON-NLS-1$ >+ String timestamp= DateFormat.getInstance().format(new Date(System.currentTimeMillis())); >+ return MessageFormat.format(format, new String[] { commandLine[0], timestamp }); >+ } >+ >+ /** >+ * Return string "commandLine[1..max]" for rendering debug process. >+ */ >+ public static String renderCommandLine(String[] commandLine) { >+ if (commandLine.length < 1) >+ return ""; //$NON-NLS-1$ >+ StringBuffer buf= new StringBuffer(commandLine[0]); >+ for (int i= 1; i < commandLine.length; i++) { >+ buf.append(' '); >+ buf.append(commandLine[i]); >+ } >+ return buf.toString(); >+ } >+ >+ /** >+ * Returns the j9 debug symbol lookup path provider for the given launch configuration. >+ * >+ * @param configuration launch configuration >+ * @return symbol lookup path provider >+ * @exception CoreException if unable to resolve the path provider >+ * @since 2.0 >+ */ >+ public static IRuntimeClasspathProvider getSymbolLookupPathProvider(ILaunchConfiguration configuration) throws CoreException { >+ String providerId = configuration.getAttribute(IJ9LaunchConfigurationConstants.ATTR_SYMBOL_PATH_PROVIDER, (String)null); >+ IRuntimeClasspathProvider provider = null; >+ if (providerId == null) { >+ provider = fgDefaultSymbolPathProvider; >+ } else { >+ provider = (IRuntimeClasspathProvider)getClasspathProviders().get(providerId); >+ } >+ return provider; >+ } >+ >+ /** >+ * Computes and returns the unresolved j9 debug symbol lookup path for the given launch >+ * configuration. >+ * >+ * @param configuration launch configuration >+ * @return runtime classpath entries >+ * @exception CoreException if unable to compute the symbol lookup path >+ * @since 2.0 >+ */ >+ public static IRuntimeClasspathEntry[] computeUnresolvedSymbolLookupPath(ILaunchConfiguration configuration) throws CoreException { >+ return getSymbolLookupPathProvider(configuration).computeUnresolvedClasspath(configuration); >+ } >+ >+ /** >+ * Resolves the given j9 debug symbol lookup path, returning the resolved symbol lookup path >+ * in the context of the given launch configuration. >+ * >+ * @param entries unresolved entries >+ * @param configuration launch configuration >+ * @return resolved entries >+ * @exception CoreException if unable to resolve the symbol lookup path >+ * @since 2.0 >+ */ >+ public static IRuntimeClasspathEntry[] resolveSymbolLookupPath(IRuntimeClasspathEntry[] entries, ILaunchConfiguration configuration) throws CoreException { >+ return getSymbolLookupPathProvider(configuration).resolveClasspath(entries, configuration); >+ } >+ >+ /** >+ * Return the resolved and absolute j9 debug symbol path calculated from the >+ * resolved symbol classpath of a launch configuration. >+ * >+ * @param configuration launch configuration >+ * @return the set of absolute directory names containing 1 or more symbol files >+ * @see J9ProxyAttachConnector#J9ProxyAttachConnector(String, String, String[], String, IVMInstall) >+ */ >+ public static String[] getResolvedSymbolLookupPath(ILaunchConfiguration configuration) throws CoreException { >+ IRuntimeClasspathEntry[] entries = J9Launching.computeUnresolvedSymbolLookupPath(configuration); >+ entries = J9Launching.resolveSymbolLookupPath(entries, configuration); >+ List symbolPath = new ArrayList(entries.length); >+ for (int i = 0; i < entries.length; i++) { >+ String entry = entries[i].getLocation(); >+ // entry will be null in the case where you originally had a project in your symbol path that has since been deleted. >+ if (entry != null) { >+ addSymbolFileEntry(symbolPath, entry); >+ } >+ } >+ return (String[])symbolPath.toArray(new String[symbolPath.size()]); >+ } >+ >+ /** >+ * @return Returns J9 IVMInstall for connector, >+ * or null if connector has no J9 IVMInstall >+ */ >+ public static J9VMInstall getJ9VMInstall(IVMConnector connector, Map arguments, IJavaProject project) throws CoreException { >+ if (connector instanceof J9ConnectorDelegate) { >+ String vmName = (String)arguments.get(J9SocketAttachConnector.ARG_VM_INSTALL_NAME); >+ >+ // If default VM is selected, take default VM for project >+ if (vmName == null || vmName.equals(J9SocketAttachConnector.DEFAULT_JRE_NAME)) { >+ return getJ9VMInstall(project); >+ } else { >+ return findJ9VMInstallByName(vmName); >+ } >+ } >+ return getJ9VMInstall(project); >+ } >+ >+ /** >+ * If the entry denotes a symbol file, add it. If the entry >+ * does not denote a symbol file, but the directory of the entry >+ * contains symbol files, add that directory. >+ */ >+ private static void addSymbolFileEntry(List symbolPath, String entry) { >+ if (!entry.toLowerCase().endsWith(".sym")) { //$NON-NLS-1$ >+ File dir = new File(entry); >+ if (!dir.isDirectory()) { >+ dir = dir.getParentFile(); >+ } >+ File files[] = dir.listFiles(new FileFilter() { >+ public boolean accept(File target) { >+ return target.getName().toLowerCase().endsWith(".sym"); //$NON-NLS-1$ >+ } >+ }); >+ if (files == null || files.length == 0) { >+ return; >+ } >+ entry = dir.getAbsolutePath(); >+ } >+ if (!symbolPath.contains(entry)) { >+ symbolPath.add(entry); >+ } >+ } >+ >+ /** >+ * Returns all registered classpath providers. >+ */ >+ private static Map getClasspathProviders() { >+ if (fgPathProviders == null) { >+ initializeProviders(); >+ } >+ return fgPathProviders; >+ } >+ >+ private static void initializeProviders() { >+ /* >+ * LL: Migration to 3.0: IPluginDescriptor.getExtensionPoint() has been deprecated. >+ * Use Platform.getExtensionRegistry().getExtensionPoint() instead. >+ */ >+ IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(LaunchingPlugin.getUniqueIdentifier(), JavaRuntime.EXTENSION_POINT_RUNTIME_CLASSPATH_PROVIDERS); >+ IConfigurationElement[] extensions = point.getConfigurationElements(); >+ fgPathProviders = new HashMap(extensions.length); >+ for (int i = 0; i < extensions.length; i++) { >+ RuntimeClasspathProvider res = new RuntimeClasspathProvider(extensions[i]); >+ fgPathProviders.put(res.getIdentifier(), res); >+ } >+ } >+ >+ /** >+ * @return Returns whether to run the J9 VM as console application. >+ * Returns true by default, if no vm specific attributes are provided. >+ */ >+ public static boolean runAsConsole(Map vmSpecificAttributesMap) { // KMH >+ if (vmSpecificAttributesMap == null) >+ return true; // the default for run on console is true. >+ return Boolean.valueOf((String)vmSpecificAttributesMap.get(IJ9LaunchConfigurationConstants.ATTR_RUN_AS_CONSOLE)).booleanValue(); >+ } >+ >+ /** >+ * @return Returns whether the -jxe option should be used to run an application, if possible. >+ * Returns true by default, if no vm specific attributes are provided. >+ */ >+ public static boolean executeFromArchive(Map vmSpecificAttributesMap) { >+ return vmSpecificAttributesMap == null || Boolean.valueOf((String)vmSpecificAttributesMap.get(IJ9LaunchConfigurationConstants.ATTR_EXECUTE_FROM_ARCHIVE)).booleanValue(); >+ } >+ >+ private static File getExecutableArchiveFile(String workingDir, String archiveFileName, String startupClass) { >+ File archiveFile = new File(archiveFileName); >+ if (workingDir != null && !archiveFile.isAbsolute()) { >+ archiveFile = new File(workingDir, archiveFileName); >+ } >+ >+ if (!startupClass.equals(getStartupClass(archiveFile))) { >+ return null; >+ } >+ >+ // Make file relative >+ // Commented out because it makes path translation for devices harder >+// if (workingDir != null) { >+// int index = archiveFileName.indexOf(workingDir); >+// if (index != -1) { >+// archiveFile = new File(archiveFileName.substring(workingDir.length() + 1, archiveFileName.length())); >+// } >+// } >+ return archiveFile; >+ } >+ >+ public static boolean isJxeArchive(File archiveFile) { >+ return archiveFile.getName().endsWith(".jxe"); //$NON-NLS-1$ >+ } >+ >+ public static boolean isJarArchive(File archiveFile) { >+ return archiveFile.getName().endsWith(".jar"); //$NON-NLS-1$ >+ } >+ >+ /** >+ * @return Returns startup class (using dots in the qualified name, not slashes), or null >+ */ >+ public static String getStartupClass(File archiveFile) { >+ try { >+ String startupClass = null; >+ if (isJxeArchive(archiveFile)) { >+ JxeInfo jxeInfo = new JxeInfo(new FileInputStream(archiveFile)); >+ startupClass = jxeInfo.getStartupClass(); >+ } else if (isJarArchive(archiveFile)) { >+ JarFile jar = new JarFile(archiveFile); >+ Manifest m = jar.getManifest(); >+ if (m != null) { >+ startupClass = m.getMainAttributes().getValue(Attributes.Name.MAIN_CLASS); >+ } >+ jar.close(); //Sri! 104644 >+ } >+ return startupClass == null ? null : startupClass.replace('/','.'); >+ } catch (IOException e) { >+ // Assume not a jxe/jar file >+ } >+ return null; >+ } >+ >+ /** >+ * Adapt the VMRunnerConfiguration to ATTR_EXECUTE_FROM_ARCHIVE. >+ * If the option is set, the boot- and classpath will be scanned for >+ * a JXE or JAR with a startup class. >+ * If an executable JXE is found, the -jxe option will be used to launch the application, >+ * and all boot- and classpath entries will be moved to the boot path. >+ * If an executable JAR is found on the classpath and the vm supports it, >+ * the -jar option will be used to launch the application. >+ * An executable jar on the boot path is ignored because -jar puts classes on the classpath. >+ */ >+ public static VMRunnerConfiguration adaptVMRunnerConfiguration(VMRunnerConfiguration config, J9VMInstall vm) throws CoreException { >+ if (executeFromArchive(config.getVMSpecificAttributesMap())) { >+ List bootPath = new ArrayList(); >+ if (config.getBootClassPath() != null) { >+ bootPath.addAll(Arrays.asList(config.getBootClassPath())); >+ } >+ List classPath = new ArrayList(Arrays.asList(config.getClassPath())); >+ List combinedPath = new ArrayList(bootPath); >+ combinedPath.addAll(classPath); >+ for (Iterator iter = combinedPath.iterator(); iter.hasNext();) { >+ String archiveFileName = (String)iter.next(); >+ File archiveFile = getExecutableArchiveFile(config.getWorkingDirectory(), archiveFileName, config.getClassToLaunch()); >+ if (archiveFile != null) { >+ boolean isJxeArchive = isJxeArchive(archiveFile); >+ if (isJxeArchive || (!vm.isPre20J9Version() && !bootPath.contains(archiveFileName))) { >+ String vmArgs[] = config.getVMArguments(); >+ List vmArgList = new ArrayList(vmArgs.length + 2); >+ vmArgList.addAll(Arrays.asList(vmArgs)); >+ String newBootPath[]; >+ String newClassPath[]; >+ String classToLaunch = config.getClassToLaunch(); >+ // TODO remove this special case which takes the bin folder >+ // off the class path only when a .jxe is being built >+ List removeList = new ArrayList(); >+ for (Iterator iterator = classPath.iterator(); iterator.hasNext();) { >+ String element = (String) iterator.next(); >+ if (element.endsWith("bin")) { //$NON-NLS-1$ >+ removeList.add(element); >+ } >+ } >+ classPath.removeAll(removeList); >+ newClassPath = (String[])classPath.toArray(new String[classPath.size()]); >+ combinedPath.removeAll(removeList); >+ >+ if (isJxeArchive) { >+ if (vm.is21J9Version()) { >+ if (config.getBootClassPath().length == 0) { >+ config.setBootClassPath(null); >+ newBootPath = new String[0]; >+ } else >+ newBootPath = config.getBootClassPath(); >+ } else { >+ // there is no class to launch for this case >+ classToLaunch = ""; //$NON-NLS-1$ >+ combinedPath.remove(archiveFileName); >+ vmArgList.add("-jxe:"+archiveFile.getPath()); //$NON-NLS-1$ >+ newBootPath = new String[combinedPath.size()]; >+ combinedPath.toArray(newBootPath); >+ newClassPath = new String[0]; >+ } >+ } >+ else { >+ if (config.getBootClassPath().length == 0) { >+ config.setBootClassPath(null); >+ newBootPath = new String[0]; >+ } else >+ newBootPath = config.getBootClassPath(); >+// vmArgList.add("-jar"); //$NON-NLS-1$ >+// vmArgList.add(archiveFile.getPath()); >+// newBootPath = new String[bootPath.size()]; >+// bootPath.toArray(newBootPath); >+// classPath.remove(archiveFileName); >+// newClassPath = new String[classPath.size()]; >+// classPath.toArray(newClassPath); >+ } >+ VMRunnerConfiguration adaptedConfig = new VMRunnerConfiguration(classToLaunch, newClassPath); //$NON-NLS-1$ >+ if (newBootPath.length == 0 && config.getBootClassPath() == null) { >+ adaptedConfig.setBootClassPath(null); >+ } else { >+ adaptedConfig.setBootClassPath(newBootPath); >+ } >+ vmArgs = new String[vmArgList.size()]; >+ vmArgList.toArray(vmArgs); >+ adaptedConfig.setProgramArguments(config.getProgramArguments()); >+ adaptedConfig.setVMArguments(vmArgs); >+ adaptedConfig.setWorkingDirectory(config.getWorkingDirectory()); >+ adaptedConfig.setVMSpecificAttributesMap(config.getVMSpecificAttributesMap()); >+ >+ return adaptedConfig; >+ } >+ } >+ } >+ } >+ return config; >+ } >+} >Index: j9/org/eclipse/jdt/launching/j9/J9VMOptionsParser.java >=================================================================== >RCS file: j9/org/eclipse/jdt/launching/j9/J9VMOptionsParser.java >diff -N j9/org/eclipse/jdt/launching/j9/J9VMOptionsParser.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ j9/org/eclipse/jdt/launching/j9/J9VMOptionsParser.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,154 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.launching.j9; >+ >+import java.io.BufferedReader; >+import java.io.File; >+import java.io.IOException; >+import java.io.InputStream; >+import java.io.InputStreamReader; >+import java.util.ArrayList; >+import java.util.Enumeration; >+import java.util.List; >+import java.util.zip.ZipEntry; >+import java.util.zip.ZipFile; >+ >+public class J9VMOptionsParser { >+ >+ private BufferedReader reader; >+ private ArrayList vmOptions = new ArrayList(); >+ private String tokens[] = new String[0]; >+ private int tokenIndex; >+ >+ public J9VMOptionsParser(InputStream in) throws IOException { >+ reader = new BufferedReader(new InputStreamReader(in)); >+ String token; >+ while ((token = getNextToken()) != null) { >+ if (token.equalsIgnoreCase("-vmOption")) { //$NON-NLS-1$ >+ vmOptions.add(getNextToken()); >+ } >+ } >+ reader.close(); >+ } >+ >+ public List getVMOptions() { >+ return vmOptions; >+ } >+ >+ private String getNextToken() throws IOException { >+ while (tokenIndex == tokens.length) { >+ String line = reader.readLine(); >+ if (line == null) { >+ return null; >+ } >+ tokens = tokenizeLine(line); >+ tokenIndex = 0; >+ } >+ return tokens[tokenIndex++]; >+ } >+ >+ private static String[] tokenizeLine(String line) { >+ ArrayList tokens = new ArrayList(); >+ char chars[] = line.toCharArray(); >+ int curIndex = 0; >+ >+ while (curIndex < chars.length) { >+ String token = null; >+ int endIndex; >+ int newCurIndex; >+ char curChar = 0; >+ >+ // skip whitespace >+ while ((curIndex < chars.length) >+ && (Character.isWhitespace(curChar = chars[curIndex]))) { >+ curIndex++; >+ } >+ >+ // handle comment and end of line >+ if (curIndex == chars.length) { >+ break; >+ } >+ // Handle comments as tokens as well >+ if ('#' == curChar) { >+ endIndex = chars.length; >+ newCurIndex = chars.length; >+ } else >+ // handle quoted strings >+ if ('"' == curChar) { >+ endIndex = line.indexOf('"', curIndex + 1); >+ if (-1 == endIndex) { >+ endIndex = chars.length; >+ } >+ curIndex++; >+ newCurIndex = endIndex + 1; >+ } >+ >+ // handle non-quoted strings >+ else { >+ for (endIndex = curIndex + 1; >+ endIndex < chars.length; >+ endIndex++) { >+ curChar = chars[endIndex]; >+ if (Character.isWhitespace(curChar) || '#' == curChar) >+ break; >+ } >+ newCurIndex = (curChar == '#' ? endIndex : endIndex + 1); >+ } >+ token = line.substring(curIndex, endIndex); >+ curIndex = newCurIndex; >+ tokens.add(token); >+ >+ } >+ >+ String[] result = new String[tokens.size()]; >+ tokens.toArray(result); >+ return result; >+ } >+ >+ public static List extractVMOptions(String file) { >+ List result = new ArrayList(); >+ try { >+ ZipFile zipFile = new ZipFile(file); >+ for (Enumeration entries = zipFile.entries(); entries.hasMoreElements();) { >+ ZipEntry entry = (ZipEntry)entries.nextElement(); >+ String entryName = entry.getName(); >+ if (entryName.equals("META-INF/JXE.MF")) { //$NON-NLS-1$ >+ readJxeMetaInfo(zipFile.getInputStream(entry), result); >+ } else if (new File(entryName).getName().equals("jxeLink.rules")) { //$NON-NLS-1$ >+ // Parse without expanding macros >+ J9VMOptionsParser parser = new J9VMOptionsParser(zipFile.getInputStream(entry)); >+ result.addAll(parser.getVMOptions()); >+ } >+ } >+ zipFile.close(); >+ } catch (IOException e) { >+ // Not a (zip) file or no jxeLink.rules entry. >+ } >+ return result; >+ } >+ >+ private static void readJxeMetaInfo(InputStream input, List result) throws IOException { >+ BufferedReader reader = new BufferedReader(new InputStreamReader(input)); >+ String line,key,value; >+ while ((line = reader.readLine()) != null) { >+ int p = line.indexOf(0); >+ int q = line.indexOf(0, p+1); >+ if (q > p) { >+ key = line.substring(0, p); >+ if (key.equals("vmOption")) { //$NON-NLS-1$ >+ value = line.substring(p+1, q); >+ result.add(value); >+ } >+ } >+ } >+ } >+ >+} >Index: j9/org/eclipse/jdt/launching/j9/JxeInfo.java >=================================================================== >RCS file: j9/org/eclipse/jdt/launching/j9/JxeInfo.java >diff -N j9/org/eclipse/jdt/launching/j9/JxeInfo.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ j9/org/eclipse/jdt/launching/j9/JxeInfo.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,71 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.launching.j9; >+ >+import java.io.BufferedReader; >+import java.io.FileInputStream; >+import java.io.IOException; >+import java.io.InputStream; >+import java.io.InputStreamReader; >+import java.util.Properties; >+import java.util.zip.ZipEntry; >+import java.util.zip.ZipInputStream; >+ >+/** >+ * A <code>JxeInfo</code> decodes the meta-information from a J9 Executable JXE application file. >+ */ >+public class JxeInfo { >+ >+ private Properties jxeMetaInfo = new Properties(); >+ >+ public JxeInfo(String file) throws IOException { >+ this(new FileInputStream(file)); >+ } >+ >+ public JxeInfo(InputStream input) throws IOException { >+ ZipInputStream zipInput = new ZipInputStream(input); >+ ZipEntry ze; >+ do { >+ ze = zipInput.getNextEntry(); >+ if (ze != null && ze.getName().equals("META-INF/JXE.MF")) { //$NON-NLS-1$ >+ readJxeMetaInfo(zipInput); >+ } >+ } while (ze != null); >+ } >+ >+ public Properties getJxeMetaInfo() { >+ return jxeMetaInfo; >+ } >+ >+ public String getStartupClass() { >+ return jxeMetaInfo.getProperty("startupClass"); //$NON-NLS-1$ >+ } >+ >+ private void readJxeMetaInfo(InputStream input) throws IOException { >+ BufferedReader reader = new BufferedReader(new InputStreamReader(input)); >+ String line,key,value,oldValue; >+ while ((line = reader.readLine()) != null) { >+ int p = line.indexOf(0); >+ int q = line.indexOf(0, p+1); >+ if (q > p) { >+ key = line.substring(0, p); >+ value = line.substring(p+1, q); >+ // when several entries with the same key >+ if (jxeMetaInfo.containsKey(key)) { >+ oldValue = (String)jxeMetaInfo.get(key); >+ value = value+","+oldValue; //$NON-NLS-1$ >+ } >+ jxeMetaInfo.setProperty(key,value); >+ } >+ } >+ } >+ >+} >Index: j9/org/eclipse/jdt/launching/j9/StandardSymbolPathProvider.java >=================================================================== >RCS file: j9/org/eclipse/jdt/launching/j9/StandardSymbolPathProvider.java >diff -N j9/org/eclipse/jdt/launching/j9/StandardSymbolPathProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ j9/org/eclipse/jdt/launching/j9/StandardSymbolPathProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,42 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.launching.j9; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.jdt.launching.IRuntimeClasspathEntry; >+import org.eclipse.jdt.launching.StandardSourcePathProvider; >+ >+/** >+ * Default implementation of j9 debug symbol lookup path computation and resolution. >+ * <p> >+ * This class may be subclassed. >+ * </p> >+ */ >+public class StandardSymbolPathProvider extends StandardSourcePathProvider { >+ >+ /** >+ * @see IRuntimeClasspathProvider#computeUnresolvedClasspath(ILaunchConfiguration) >+ */ >+ public IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration configuration) throws CoreException { >+ boolean useDefault = configuration.getAttribute(IJ9LaunchConfigurationConstants.ATTR_DEFAULT_SYMBOL_PATH, true); >+ IRuntimeClasspathEntry[] entries = null; >+ if (useDefault) { >+ // the default symbol lookup path is the same as the classpath >+ entries = super.computeUnresolvedClasspath(configuration); >+ } else { >+ // recover persisted symbol path >+ entries = recoverRuntimePath(configuration, IJ9LaunchConfigurationConstants.ATTR_SYMBOL_PATH); >+ } >+ return entries; >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 106683
:
25992
|
26133
| 26810 |
27435
|
27731