Using an IDE to work on the Java library

Andrew Dinn adinn at redhat.com
Mon Jun 5 16:51:59 UTC 2017


On 05/06/17 17:30, Andrew Haley wrote:
> Sorry for what must seem like a newbie question...
> 
> I've done almost all of my work on HotSpot, and have very little
> experience trying to use an IDE to work on the Java library.  Eclipse
> is fine when working on libraries outdie the JDK itself, but seems to
> want to look inside src.zip for its sources when debugging.  It would
> be really nice to be able to see (and edit) the real Java source files
> in jdk/java.base/.
> 
> I suppose there must be some way to create a Project for an IDE, so
> that debugging the standard library is easy.  Is there some advice
> around somewhere?  What do people do?

I use IntelliJ Idea. The latest releases cope quite happily with jdk9/10.

In the project settings you can set up a JDK you build from scratch as a
project JDK and the sources located in the build image (in src.zip) will
be picked up automatically by Idea.

In order to see sources not in src.zip you need to add the jdk source
tree to the project's main module as a source root (do this from the
"open module settings" or "project structure" dialogs). Likewise, if you
want the jdk.vm.ci sources for graal from the hotspot tree. So, for the
latter case, I add jdk9/jdk/hotspot/src/jdk.internal.vm.ci as a source
root. (Alternatively you can add it to an extra module that then gets
inherited by the project module(s)).

You then have to tag the relevant module subdirs in these added trees as
src directories to bring the desired source files into play. For example
for the jdk.vm.ci sources root I tag share/classes/jdk.v.ci.code/src etc
as source dirs. Once again this is done from the "open module settings"
dialog.

Note that you can configure the module settings for app modules (or for
any common extra module you add and then make them inherit) so that
these extra  sources are picked up prior to any sources or (what you
don't want) class files obtained from the project JDK.

regards,


Andrew Dinn
-----------
Senior Principal Software Engineer
Red Hat UK Ltd
Registered in England and Wales under Company Registration No. 03798903
Directors: Michael Cunningham, Michael ("Mike") O'Neill, Eric Shander


More information about the jdk10-dev mailing list