JavaCoreEnvironment does work in an old version, but throws exception in the current version

Hi,

I was able to pin the issue I reported here down. To demonstrate the behavior I have set up a minimal example that uses JavaCoreApplicationEnvironmen and JavaCoreProjectEnvironment. The example consists only of one class IntelliJ-Core-Environment-Test/simple-parser/src/Main.java that parses sucessfully a sample java file.

The thing with this project is that it depends on the module intellij-plattform which is a collection of file from an older version of the API. So when you compile and run the Main.java, then it depends partly on the old intellij files that are used prior the intellij libraries. You can see in the module-dependency settings for simple-parser that the intellij-plattform comes before the idea-libs

http://i.imgur.com/NC1P9EI.png

Now, technically this all isn't necesarry, because all functionality can be found in the libraries that come with IDEA. Therefore, please delete the dependency "intellij-plattform" and "idea-libs" and add a new library directory that points to the "lib" folder of your installation of IDEA

http://i.imgur.com/TWjsvQ5.png

You can now build the simple-parser module as well without errors, but when you run it, you get the exception I have already reported.

http://i.imgur.com/gOOwrMn.png

Can someone comment on this?

Cheers
Patrick

6 comments
Comment actions Permalink

The short answer is that the current behavior is a bug and we'll fix it soon.

1
Avatar
Patrick Scheibe
Comment actions Permalink

Thank you Dmitry! Shall I report it to the IDEA bugtracker?

Cheers
Patrick

0
Comment actions Permalink

You don't need to. We already know the issue and have discussed the fix.


0
Comment actions Permalink

Dmitry,

I just looked at and built the latest sources and it seems this issue is still unfixed.

Is there any straight-forward way to apply a fix to CoreProjectEnvironment or has it been fixed in some branch that I haven't seen?

Additionally, am I right that CoreApplicationEnvironment and CoreProjectEnvironment is still the correct way to use Idea as library without the GUI itself and something new hasn't been implemented?

Cheers
Patrick

0
Comment actions Permalink

Hi Patrick --

I don't know how far along you've gotten with this issue -- but from my own limited experience -- if you are looking to implement a robust, "headless" intellij app that uses ApplicationEnvironment, VirtualFileSystem, Psi* and boots quickly --  then the KotlinCoreEnvironment.kt  is the best reference point for what ExtensionPoints and Services you should consider adding and well as work arounds to some gotcha's and what things should/could be done asynchronously (e.g. RootArea)

also, it looks like you should probably set :

System.setProperty("java.awt.headless", "true");

as early as possible.  

 

Cheers, nehal

 

0
Comment actions Permalink

I should mention that you should trace through the code path that the kotlinc launchers uses when you run the REPL (The KotlinCoreEnvironment is general purpose; following how the repl is launched is one way of figuring out what is relevant in a headless scenario).  

Also, the proper solution is likely to create MathematicaPlugCoreEnv that uses ApplicationCoreEnv directly with a few (non JavaCoreEnv) things lifted from KotlinCoreEnv -- Kotlin is doing a lot of things because it want to leverage java support but with a little code spelunking you could find a much more streamlined setup 

0

Please sign in to leave a comment.