Skip to content

Commit 45809fd

Browse files
8295884: Implement IDE support for Eclipse
Reviewed-by: erikj
1 parent baf11e7 commit 45809fd

File tree

9 files changed

+687
-0
lines changed

9 files changed

+687
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ NashornProfile.txt
1818
/src/utils/LogCompilation/target/
1919
/.project/
2020
/.settings/
21+
/.project
22+
/.classpath
23+
/.cproject

doc/ide.html

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,45 @@ <h4 id="visual-studio">Visual Studio</h4>
7979
<code>ide\hotspot-visualstudio</code> subfolder of the build output
8080
folder. The file can be opened in Visual Studio via
8181
<code>File -&gt; Open -&gt; Project/Solution</code>.</p>
82+
<h4 id="eclipse-cdt">Eclipse CDT</h4>
83+
<p>The make system can generate an Eclipse CDT Workspace that enables
84+
Eclipse indexing for the C and C++ sources throughout the entire
85+
codebase, as well as registering all common make targets to be runnable
86+
from the Eclipse explorer. This can be done after configuring by
87+
running:</p>
88+
<pre><code>make eclipse-native-env</code></pre>
89+
<p>After this is run, simply open and import the workspace in Eclipse
90+
through
91+
<code>File -&gt; Import -&gt; Projects from Folder or Archive</code> and
92+
at <code>Import source</code> click on the directory
93+
<code>ide\eclipse</code>, which can be found in the build output
94+
folder.</p>
95+
<p>If this doesn't work, you can also try
96+
<code>File -&gt; Import -&gt; Existing Projects into Workspace</code>
97+
instead.</p>
98+
<p>Setting up an Eclipse Workspace is relatively lightweight compared to
99+
other supported IDEs, but requires that your CDT installation has Cross
100+
GCC support enabled at the moment, even if you aren't cross compiling.
101+
The Visual C++ compiler is, at present, not supported as an indexer.</p>
102+
<p>If desired, you can instead request make to only include indexing
103+
support for just the Java Virtual Machine instead of the entire native
104+
codebase, by running:</p>
105+
<pre><code>make eclipse-hotspot-env</code></pre>
106+
<p>If you think your particular Eclipse installation can handle the
107+
strain, the make system also supports generating a combined Java and
108+
C/C++ Workspace for Eclipse which can then conveniently switch between
109+
Java and C/C++ natures during development by running:</p>
110+
<pre><code>make eclipse-mixed-env</code></pre>
111+
<p>Do note that this generates all features that come with both Java and
112+
C/C++ natures.</p>
113+
<p>By default, the Eclipse Workspace is located in the ide subdirectory
114+
in the build output. To share the JDK's source directory with the
115+
Eclipse Workspace, you can instead run:</p>
116+
<pre><code>make eclipse-shared-&lt;ENV&gt;-env</code></pre>
117+
<p>Eclipse support in the JDK is relatively new, so do keep in mind that
118+
not everything may work at the moment. As such, the resulting Workspace
119+
also has compilation database parsing support enabled, so you can pass
120+
Eclipse the compile commands file (see below) if all else fails.</p>
82121
<h4 id="compilation-database">Compilation Database</h4>
83122
<p>The make system can generate generic native code indexing support in
84123
the form of a <a
@@ -105,5 +144,28 @@ <h4 id="intellij-idea">IntelliJ IDEA</h4>
105144
<p>In order to run the tests from the IDE, you can use the JTReg plugin.
106145
Instructions for building and using the plugin can be found <a
107146
href="https://github.com/openjdk/jtreg/tree/master/plugins/idea">here</a>.</p>
147+
<h4 id="eclipse">Eclipse</h4>
148+
<p>Eclipse JDT is a widely used Java IDE and has been for a very long
149+
time, being a popular choice alongside IntelliJ IDEA for Java
150+
development. Likewise, the JDK now includes support for developing its
151+
Java sources with Eclipse, which can be achieved by setting up a Java
152+
Workspace by running:</p>
153+
<pre><code>make eclipse-java-env</code></pre>
154+
<p>After the workspace has been generated you can import it in the same
155+
way as you would with Eclipse CDT:</p>
156+
<p>Follow
157+
<code>File -&gt; Import -&gt; Projects from Folder or Archive</code> and
158+
select the <code>ide\eclipse</code> directory in the build output folder
159+
to import the newly created Java Workspace.</p>
160+
<p>If doing so results in an error, you can also import the JDK via
161+
<code>File -&gt; Import -&gt; Existing Projects into Workspace</code> as
162+
a last resort.</p>
163+
<p>Alternatively, if you want a Java Workspace inside the JDK's source
164+
directory, you can instead run:</p>
165+
<pre><code>make eclipse-shared-java-env</code></pre>
166+
<p>As mentioned above for Eclipse CDT, you can create a combined Java
167+
and C/C++ Workspace which can conveniently switch between Java and C/C++
168+
natures during development by running:</p>
169+
<pre><code>make eclipse-mixed-env</code></pre>
108170
</body>
109171
</html>

doc/ide.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,63 @@ This creates a file named `jvm.vcxproj` in `ide\hotspot-visualstudio`
5656
subfolder of the build output folder. The file can be opened in Visual Studio
5757
via `File -> Open -> Project/Solution`.
5858

59+
#### Eclipse CDT
60+
61+
The make system can generate an Eclipse CDT Workspace that enables Eclipse
62+
indexing for the C and C++ sources throughout the entire codebase, as well as
63+
registering all common make targets to be runnable from the Eclipse explorer.
64+
This can be done after configuring by running:
65+
66+
```
67+
make eclipse-native-env
68+
```
69+
70+
After this is run, simply open and import the workspace in Eclipse through
71+
`File -> Import -> Projects from Folder or Archive` and at
72+
`Import source` click on the directory `ide\eclipse`, which can be
73+
found in the build output folder.
74+
75+
If this doesn't work, you can also try
76+
`File -> Import -> Existing Projects into Workspace`
77+
instead.
78+
79+
Setting up an Eclipse Workspace is relatively lightweight compared to other
80+
supported IDEs, but requires that your CDT installation has Cross GCC support
81+
enabled at the moment, even if you aren't cross compiling. The Visual C++
82+
compiler is, at present, not supported as an indexer.
83+
84+
If desired, you can instead request make to only include indexing support for
85+
just the Java Virtual Machine instead of the entire native codebase, by running:
86+
87+
```
88+
make eclipse-hotspot-env
89+
```
90+
91+
If you think your particular Eclipse installation can handle the strain, the
92+
make system also supports generating a combined Java and C/C++ Workspace for
93+
Eclipse which can then conveniently switch between Java and C/C++ natures
94+
during development by running:
95+
96+
```
97+
make eclipse-mixed-env
98+
```
99+
100+
Do note that this generates all features that come with both Java and C/C++
101+
natures.
102+
103+
By default, the Eclipse Workspace is located in the ide subdirectory in the
104+
build output. To share the JDK's source directory with the Eclipse Workspace,
105+
you can instead run:
106+
107+
```
108+
make eclipse-shared-<ENV>-env
109+
```
110+
111+
Eclipse support in the JDK is relatively new, so do keep in mind that not
112+
everything may work at the moment. As such, the resulting Workspace also
113+
has compilation database parsing support enabled, so you can pass Eclipse
114+
the compile commands file (see below) if all else fails.
115+
59116
#### Compilation Database
60117

61118
The make system can generate generic native code indexing support in the form of
@@ -96,3 +153,40 @@ as the SDK to use.
96153
In order to run the tests from the IDE, you can use the JTReg plugin.
97154
Instructions for building and using the plugin can be found
98155
[here](https://github.com/openjdk/jtreg/tree/master/plugins/idea).
156+
157+
#### Eclipse
158+
159+
Eclipse JDT is a widely used Java IDE and has been for a very long time, being
160+
a popular choice alongside IntelliJ IDEA for Java development. Likewise, the
161+
JDK now includes support for developing its Java sources with Eclipse, which
162+
can be achieved by setting up a Java Workspace by running:
163+
164+
```
165+
make eclipse-java-env
166+
```
167+
168+
After the workspace has been generated you can import it in the same way as
169+
you would with Eclipse CDT:
170+
171+
Follow `File -> Import -> Projects from Folder or Archive` and select the
172+
`ide\eclipse` directory in the build output folder to import the newly created
173+
Java Workspace.
174+
175+
If doing so results in an error, you can also import the JDK via
176+
`File -> Import -> Existing Projects into Workspace`
177+
as a last resort.
178+
179+
Alternatively, if you want a Java Workspace inside the JDK's source directory,
180+
you can instead run:
181+
182+
```
183+
make eclipse-shared-java-env
184+
```
185+
186+
As mentioned above for Eclipse CDT, you can create a combined Java and C/C++
187+
Workspace which can conveniently switch between Java and C/C++ natures during
188+
development by running:
189+
190+
```
191+
make eclipse-mixed-env
192+
```

make/Main.gmk

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,46 @@ $(eval $(call SetupTarget, hotspot-ide-project, \
257257
ARGS := -I$(TOPDIR)/make/hotspot, \
258258
))
259259

260+
$(eval $(call SetupTarget, eclipse-java-env, \
261+
MAKEFILE := ide/eclipse/CreateWorkspace, \
262+
ARGS := --always-make WORKSPACE=java SHARED=false, \
263+
))
264+
265+
$(eval $(call SetupTarget, eclipse-hotspot-env, \
266+
MAKEFILE := ide/eclipse/CreateWorkspace, \
267+
ARGS := --always-make WORKSPACE=hotspot SHARED=false, \
268+
))
269+
270+
$(eval $(call SetupTarget, eclipse-native-env, \
271+
MAKEFILE := ide/eclipse/CreateWorkspace, \
272+
ARGS := --always-make WORKSPACE=native SHARED=false, \
273+
))
274+
275+
$(eval $(call SetupTarget, eclipse-mixed-env, \
276+
MAKEFILE := ide/eclipse/CreateWorkspace, \
277+
ARGS := --always-make SHARED=false, \
278+
))
279+
280+
$(eval $(call SetupTarget, eclipse-shared-java-env, \
281+
MAKEFILE := ide/eclipse/CreateWorkspace, \
282+
ARGS := --always-make WORKSPACE=java SHARED=true, \
283+
))
284+
285+
$(eval $(call SetupTarget, eclipse-shared-hotspot-env, \
286+
MAKEFILE := ide/eclipse/CreateWorkspace, \
287+
ARGS := --always-make WORKSPACE=hotspot SHARED=true, \
288+
))
289+
290+
$(eval $(call SetupTarget, eclipse-shared-native-env, \
291+
MAKEFILE := ide/eclipse/CreateWorkspace, \
292+
ARGS := --always-make WORKSPACE=native SHARED=true, \
293+
))
294+
295+
$(eval $(call SetupTarget, eclipse-shared-mixed-env, \
296+
MAKEFILE := ide/eclipse/CreateWorkspace, \
297+
ARGS := --always-make SHARED=true, \
298+
))
299+
260300
ALL_TARGETS += $(HOTSPOT_VARIANT_TARGETS) $(HOTSPOT_VARIANT_GENSRC_TARGETS) \
261301
$(HOTSPOT_VARIANT_LIBS_TARGETS)
262302

0 commit comments

Comments
 (0)