Skip to content

Formatter Bug: All values for parentheses_positions_in_method_declaration are ignored, while ...invocation works #4237

Description

@devers2

Problem

There appears to be a persistent bug in the Java formatter where the setting org.eclipse.jdt.core.formatter.parentheses_positions_in_method_declaration is completely ignored.

It seems that all possible values for this setting (e.g., separate_lines, preserve_positions, etc.) have no effect on formatting method declarations.

This is especially problematic for the separate_lines_if_wrapped value, which is a common and useful setting for code readability. Even when parameters are wrapped onto new lines, the closing parenthesis ) is still incorrectly forced onto the same line as the last parameter, directly violating the ...if_wrapped rule.

Key Evidence of Bug: Inconsistency with ...invocation

The strongest evidence of this bug is the clear inconsistency with its parallel setting, which works perfectly.

  • Works: org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation

    • This setting correctly applies all its values (like separate_lines_if_wrapped) to method calls.
  • Fails: org.eclipse.jdt.core.formatter.parentheses_positions_in_method_declaration

    • This setting fails to apply the exact same logic to method declarations.

This inconsistency proves the bug is isolated specifically to the ..._in_method_declaration implementation.

Related Anomaly (Workaround Glitch)

We also observed a related anomaly that further highlights the bug:

If a user manually inserts a blank line (two newlines) before the closing parenthesis in a method declaration (e.g., ...status, \n \n ) {), the formatter preserves this structure.

This shows the formatter is not applying its own rules consistently. It fails to enforce the parentheses_positions... rule, but it can be "tricked" into the correct layout by this manual formatting glitch (likely due to join_wrapped_lines="false" behavior).

Conclusion

This is a bug in the Red Hat Java extension's formatter. The configuration settings for method declarations and invocations should behave identically, but they do not.

Activity

  1. fbricon commented on Nov 7, 2025

    @fbricon
    Collaborator

    Can you please attach a sample project with code and settings, reproducing this behavior?

  2. StrikeForceZero commented on Nov 14, 2025

    @StrikeForceZero

    idk if it will work in vscode but try org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration

    I was running into a similar problem when setting up Spotless (eclipse) in intellij for a Java project I'm working on and this same problem was driving me crazy.

    turns out LLM's are good for something as it pointed out the typo in the official documentation:

    https://help.eclipse.org/latest/topic/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.html#FORMATTER_PARENTHESES_POSITIONS_IN_METHOD_DECLARATION

    Note that there is a typo (delcaration vs. declaration) in the option name. It has to remain, as fixing it would be a breaking change.

  3. fbricon commented on Nov 14, 2025

    @fbricon
    Collaborator

    nice catch! indeed, vscode-java would reuse the same typo'ed org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration

  4. github-actions commented on Dec 8, 2025

    @github-actions

    This issue has been closed automatically because it needs more information and has not had recent activity. Please reach out if you have or find the answers we need so that we can investigate further.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions