Skip to content

Eclipse plugin fails at runtime when a formatter dependency is not embedded #132

Closed as not planned

Description

@abashev

Upstream: google/google-java-format#1428
Kind: regression | Priority: low

Upstream regression in gjf 1.36.0/1.36.1: the Eclipse plugin throws
NoClassDefFoundError: Could not initialize class ...javadoc.MarkdownPositions because
org.commonmark was not packaged into the plugin bundle; formatting on save silently does
nothing. 1.35 works. Confirmed by several users; still open.

Why it matters to us: we do not use commonmark, so this exact bug does not affect us. But our
plugin embeds only an allowlist of jars (functionaljava, guava, open-java-format*),
while open-java-format also has implementation dependencies on Jackson
(core/databind/datatype-jdk8/module-parameter-names). Jackson is used by the debug/JSON
output (JsonSink, DebugRenderer, JsonDocVisitor) and annotations on core types
(BreakBehaviour has @JsonSerialize(using = BreakBehaviour.Json.class)), so it is likely
never loaded on the formatting path, but nothing verifies that. Any new runtime dependency
would hit the same failure mode as upstream.

Affected files in our repo:

  • open-java-format-eclipse-plugin/build.gradle (embeddedLibs filter, Bundle-ClassPath)
  • open-java-format/build.gradle (runtime dependencies)

Suggested action: investigate. Load the built plugin jar in a plain classloader with only
the embedded libs and format a file (including Markdown /// Javadoc), or add a build check
that compares runtimeClasspath with embeddedLibs and fails on an unexpected jar.


Filed from an upstream-watch ticket after manual review.

Activity

  1. abashev commented on Oct 30, 2026

    @abashev
    CollaboratorAuthor

    Closing, because this does not reproduce here.

    google/google-java-format#1511 fixed google/google-java-format#1428 by bundling commonmark, which only google-java-format depends on. For us the question was whether our plugin needs one of the jars it leaves out. The plugin embeds open-java-format, open-java-format-spi, guava and functionaljava, and leaves out Jackson and jsr305.

    I checked it on 21.X.X (6bcacfc). I built the plugin jar, took the four jars from its lib/, and put exactly those on the classpath. With them I made the two calls that SnippetFormatter makes, with the OJF style: Formatter.getFormatReplacements and Formatter.formatSource. The test file had a /// comment, a Javadoc comment and a long string literal. Both calls formatted it, and no class failed to load.

    If the formatter ever needs another jar at runtime, the embeddedLibs filter in open-java-format-eclipse-plugin/build.gradle has to list it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions