Binary incompatibility in IDEA 12 openapi: Sdk#getSdkType() and ProjectJdkTable#getSdksOfType()

Hi there,

for anyone else running into this problem: Our plugin "Jangaroo 0.9" stopped working with IDEA 12 because of an openapi change that introduced a binary incompatibility.
While recompiling suffices to make it run with IDEA 12, we wanted to keep the plugin compatible with IDEA 11, so we had to use reflection to invoke the methods whose signature changed.
@Jetbrains: It would have been nice to find this incompatible API change in the release notes---maybe I just failed to find it?
The details of the API change are documented in our issue tracker in IDEA-23, here is a copy of the relevant part:

Evaluation: undocumented IDEA openapi changes that cause binary incompatibility.
In detail, a new interface com.intellij.openapi.projectRoots.SdkTypeId was extracted from class com.intellij.openapi.projectRoots.SdkType and used instead of the class in methods com.intellij.openapi.projectRoots.ProjectJdkTable#getSdksOfType(SdkTypeId) and com.intellij.openapi.projectRoots.Sdk#getSdkType() (return type).
Proposed fix: to retain binary compatibility with IDEA 10, 11 and 12, use reflection to call these methods.

To implement the fix, feel free to reuse our code (Apache 2 license, so please give credits if you do so).


1 comment
Comment actions Permalink

I'm surprised you have been able to maintain binary compatibility this long. They did some heavry refactorting in IDEA 12. I'm going to have to look at my code again. I do recall a month or two ago having to make a change related to SdkTypeId. Though I maintain separate branches for each version of the platform I support.

Thank you for your code sample. It might come in handy for me at some point.

I have been meaning to start breaking up my code into modules that can provide a facade over both the API progression as well as the API presence issues you run into when trying to support the single language IDE's which can themselves have an API version anywhere in between the IDEA versions.

Your way is similar to one I had thought about, which was simply to provide fake compile time classes to allow the code to continue building, and then catch the various exceptions NoClassDefFound...etc,

It really depends on what you do in your plugin and how many features you try to support. I have always gone a little overboard trying to support as many as I could. Something that has currently gotten me into a little bind.


Thanks. Happy Holidays!


Please sign in to leave a comment.