Skip to content

Classes from V2 "modules" are accessible on the compile classpath (but inaccessible at runtime by default) #1761

@gharrma

Description

@gharrma

What happened?

Plugins can easily be hit by ClassNotFoundException at runtime if they access classes from V2 "modules".

I've created a minimal repro scenario as a patch on top of the intellij-platform-plugin-template: gharrma/intellij-plugin-repro-module-dependency-violation@8291e98

Observed behavior:

  • ./gradlew assemble succeeds

  • ./gradlew verifyPlugin reports no issue (version: 1.373)

  • At runtime, a ClassNotFoundException is thrown when accessing class
    com.intellij.smartUpdate.VcsUpdateStep.

Expected behavior:

  • Compilation should fail because module intellij.smart.update should not
    be on the compile classpath.

  • The intellij-plugin-verifier should complain that classes from
    module intellij.smart.update are being used without a corresponding
    dependency declaration in plugin.xml, specifically:

    <dependencies>
      <module name="intellij.smart.update"/>
    </dependencies>
    

Note, I believe commit JetBrains/intellij-community@6fb57f5 in IntelliJ 2024.2 is what placed V2 modules into a separate classloader at runtime (thus requiring the explicit dependency declaration in plugin.xml).

Let me know if I should file a separate issue for intellij-plugin-verifier, given that the verifier should be reporting these dependency violations too. (Should I file this issue on YouTrack?)

Relevant log output or stack trace

java.lang.NoClassDefFoundError: com/intellij/smartUpdate/VcsUpdateStep
	at org.jetbrains.plugins.template.listeners.MyApplicationActivationListener.applicationActivated(MyApplicationActivationListener.kt:14)
	...
Caused by: java.lang.ClassNotFoundException: com.intellij.smartUpdate.VcsUpdateStep PluginClassLoader(plugin=PluginDescriptor(name=IntelliJ Platform Plugin Template, id=org.jetbrains.plugins.template, descriptorPath=plugin.xml, path=~/dev/misc/repro-module-dependency-violation/build/idea-sandbox/IC-2024.2/plugins/IntelliJ Platform Plugin Template, version=2.0.1, package=null, isBundled=false), packagePrefix=null, state=active, parents=, )
	at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.kt:157)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
	...

Steps to reproduce

[See repro steps in the main description.]

Gradle IntelliJ Plugin version

2.0.1

Gradle version

8.9

Operating System

macOS

Link to build, i.e. failing GitHub Action job

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions