Skip to content

Declare the IntelliJ plugin incompatible with palantir-java-format - #278

Merged
abashev merged 1 commit into
21.X.Xfrom
abashev/incompatible-with-palantir-java-format
Nov 25, 2026
Merged

abashev merged 1 commit into
21.X.Xfrom
abashev/incompatible-with-palantir-java-format

Conversation

@abashev

@abashev abashev commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Based on 21.X.X. Fixes #276.

Before this PR

With palantir-java-format installed next to open-java-format, the settings page fails with a ClassCastException between two copies of com.palantir.javaformat.intellij.PalantirJavaFormatSettings, each from its own PluginClassLoader. The trace in #276 is upstream's code: its getInstance is at line 46 and its isModified at line 108, lines that no open-java-format release has there.

Both plugins register a project service with that class name, and the IDE keys a service by its class name, so one plugin's project.getService(PalantirJavaFormatSettings.class) returns the instance made by the other's class loader. It can fail either way round, in either plugin's code.

After this PR

==COMMIT_MSG==
plugin.xml declares <incompatible-with>palantir-java-format</incompatible-with>, so the IDE never loads the two together. Both replace the Java formatter, so running both was never useful.
==COMMIT_MSG==

Checked

verifyPluginStructure and the plugin's tests pass. Not yet tried in an IDE with both plugins installed.

Possible downsides?

Someone who has both plugins enabled ends up with only one of them. I haven't checked which one the IDE keeps or what it tells the user.

The real cause is still there: the plugin keeps upstream's package, com.palantir.javaformat.intellij, and its state name, PalantirJavaFormatSettings. Moving to a package of its own would end the clash, but the stored state name would then need a migration for settings already in open-java-format.xml, so that is left for a separate pull request.

Both plugins register a project service named
com.palantir.javaformat.intellij.PalantirJavaFormatSettings, and the
IDE keys a service by its class name. With both enabled, one plugin's
getService returns the instance the other plugin's class loader made,
and its settings page fails with a ClassCastException (#276). Both
replace the Java formatter, so the IDE now loads only one of them.
@abashev
abashev merged commit 654c4fd into 21.X.X Nov 25, 2026
17 of 18 checks passed
@abashev
abashev deleted the abashev/incompatible-with-palantir-java-format branch November 25, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CCE: PalantirJavaFormatSettings.getInstance

1 participant