LocalInspectionTool depends on libraries compiled in Java 11 while bootJDK is Java 8 (2018.3)

Answered

Hi,

I am developing a plugin which does some error highlighting in java source file when some specific restricted java apis are used. I am implementing  LocalInspectionTool for that. This plugin works with only maven based projects.

To get the list of restricted apis, the plugin is dependent on a java library which usually part of maven dependencies in the target project.

The restricted api list library is compiled with Java 11 and the target JDK for maven project is also java 11. But as my plugin is in Java 8 due to bootJDK version in 2018.3, I can not leverage on the library packaged in the target maven project to find the restricted api list.

Unfortunately, I cannot recompile the library in Java 8 which provides restricted list api.

I would really appreciate any help / suggestion on this.

The question is how the code completion works in normal scenario for dependencies when the maven project sdk is java 11 and the IDE is running with  java 8.

 

Thanks

 

 

0
3 comments

The JDK used for running the IDE is completely unrelated to any SDKs used in your project, generally. UNLESS you need to package said exlusion library together with your plugin and load it in the IDE. AFAIU the exclusion library is available in the project itself, so your inspection could lookup the data using project's model (attached as library?) to access any information it needs for highlighting.

Should you really need to package this library as part of your plugin, then for 2019.1 you can use build bundled with JDK 11. Please note that this will not work for all users still using IDE bundled with JDK8.

0

Thanks for your response.

You are right. The exclusion library is available in the project as a maven dependency.

The inspection plugin needs to call a method in the exclusion library  to get the  restricted  api list. 

0

Then there's three possibilities

1) compile with and require JDK 11 IDE (currently not possible to enforce)

2) spawn a process from your plugin to invoke method in the exclusion library and "somehow" get results back to your inspection

3) generate the exlusion list statically for all possible versions and bundle them with your plugin, choose according to user's project

0

Please sign in to leave a comment.