java.lang.IllegalAccessError in custom IntelliJ plugin


We have a custom IntelliJ plugin that, among other things, we use to invoke error-prone and highlight the errors in the IDE. Since running on JDK 17, this has started failing with java.lang.IllegalAccessError: class com.hubspot.intellij.plugin.errorprone.analyzer.CompilerFileSystem (in unnamed module @0x5dc2f766) cannot access class (in module jdk.compiler) because module jdk.compiler does not export to unnamed module @0x5dc2f766.

Is there a way to add --add-opens and/or --add-exports to the JVM args with which our plugin is invoked? Or any other way to allow our code to access this functionality?


Please refactor the plugin to move the code related to the compiler invocation to the build process plugin (see org.jetbrains.jps.incremental.BuilderService and its implementations for the reference). The corresponding “--add-opens” JVM option is already passed to the build process, but you can repeat it via a com.intellij.compiler.server.BuildProcessParametersProvider extension, just to be sure.

I was able to get things to work by adding the --add-opens to my vmoptions file, but I'd still like a more general solution to this as modifying those for every user is not the most scalable thing.


Roman Shevchenko thanks so much for responding.

Do you know where the BuilderServices are loaded? I added my service to META-INF/services/org.jetbrains.jps.incremental.BuilderService, but it's not being created. I also added breakpoints to JavaBuilderServiceand MavenBuilderService : they were never hit.

A breakpoint in JpsServiceManagerImpl#getServicedid not show BuilderService getting loaded


Mind you, build services are loaded not by the IDE process, but by the build process (org.jetbrains.jps.cmdline.Launcher in jps -l output), so they are somewhat tricky to debug (though not impossible).

The part you have probably missed is packing these services into a separate .jar and registering the .jar via `compileServer.plugin` EP, so that it can be added to the build process' class path by BuildProcessClasspathManager.


Hi, sorry for the late follow-up. Thanks so much for your help here. Sadly that approach won't work for our environment, but I appreciate you taking the time to look at this.