Using an IDE to work on the Java library
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Tue Nov 28 18:36:42 UTC 2017
On 28/11/17 18:11, Andrew Haley wrote:
> Hi, and thanks for helping. Thanks for your patience!
>
> On 27/11/17 15:42, Maurizio Cimadamore wrote:
>
>> over the last few years, Chris and I have been promoting IntelliJ
>> support for JDK [1] - the results of this work are included in OpenJDK,
>> and you can create an idea project as follows:
>>
>> sh bin/idea.sh jdk.internal.vm.ci
>>
>> the command idea.sh takes a list of modules you want to work on. I
>> tested it with the above module (which I've seen mentioned in this
>> thread) and found no issues.
>>
>> Few months ago we also released the IntelliJ jtreg plugin which allows
>> you to run/debug tests.
>>
>> I agree that we need to come up with ways to make it easier for people
>> to work/hack on openjdk using IDEs - hopefully this is a step in the
>> right direction. Note that this script works by delegating all
>> configuration decisions to the makefile - so, assuming you have an
>> existing build configuration, the source roots should be tailored for
>> your OS/HW combo.
>>
>> [1] -
>> http://mail.openjdk.java.net/pipermail/discuss/2015-January/003645.html
>> [2] -
>> http://mail.openjdk.java.net/pipermail/jtreg-dev/2016-October/000390.html
> OK, so I do this and open the [jdk] directory. So far, so good.
>
> And I can open the files in the jdk.internal.vm.ci directory, and they
> are recognized. Now, I see at the top of the file "Project SDK is not
> defined". That looks bad -- is there something wrong? Do you expect
> to see this message?
Yes, that's expected - it's standard for intellij - each project must be
associated with an SDK - so you can click on the baloon notification and
set it up from there (even adding the default one would be ok - it won't
be used much since the JDK is all in the sources :-)). Now that I think
about it, we could improve this by automatically setting project SDK to
the bootstrap JDK that is passed to configure - that should work.
>
> But the really severe problem I now have is that I can't see any way
> to create a program that uses this configuration. Let's say I want to
> create Hello.java that uses this JDK. I can create a new Java class
> under test, but I'm now stuck because of "Project SDK is not defined".
See above on how to fix that. I believe that to create a run
configuration to e.g. run some Foo.class class, you will need at least
to point IntelliJ at the place where the class you wanna run can be
found. This can be done by adding new paths to the 'classpath' in the
project structure dialog (the bluish icon on the top right).
Click on that icon, then Modules (on the left panel), then click on the
Dependencies tab, then on the '+' sign, then Add jar or directory, and
select the folder that contains the class you wanna execute.
Then you should be set, and you should be able to create a run
configuration that uses the new JDK.
Btw, you will also have to tweak the new run configuration to point to
the new JDK image in the build folder, or the project SDK will be used
(which you don' want).
If you were to run a jtreg test using the plugin, things would be much,
much easier, as all these details are handled automatically by the plugin.
Maurizio
>
> What would you do at this point? Thanks.
>
More information about the jdk10-dev
mailing list