Skip to content

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

@devers2

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.

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