apache / apache/netbeans

Incorrect indentation level for opening brace on new line for record classes when formatting

Open
#9,164 0 comments 1 reaction 0 assignees View on GitHub
Editor Java kind:bug needs:triage
Dominant language
Java
Stars
3.1k
Forks
935
Avg merge
2d 3h
Merged PRs (30d)
17

Description

### Apache NetBeans version

Apache NetBeans 28

### What happened

When having configured brace placement for class declarations to "New Line", invoking Source > Format on a record class declaration incorrectly indents the opening brace.

### Language / Project Type / NetBeans Component

Java, Editor

### How to reproduce

In Options > Editor > Formatting > Java > Braces > Braces Placement, set Class Declaration to New Line. Then invoke Source > Format on the following code:
```java
record ExampleRecord(int a, int b) { }
```
The result is:
```java
record ExampleRecord(int a, int b)
{
}
```
The opening brace is incorrectly indented by one level.

The expected correct result would be:
```java
record ExampleRecord(int a, int b)
{
}
```

### Did this work correctly in an earlier version?

No / Don't know

### Operating System

Windows

### JDK

JDK 21

### Apache NetBeans packaging

Apache NetBeans binary zip

### Anything else

_No response_

### Are you willing to submit a pull request?

No

Contributor guide

Open the contributing guide

Research direction

Start with the Java editor formatter behavior reached through Options > Editor > Formatting > Java > Braces, and reproduce the issue using the record declaration shown. Verify the formatter's output when Class Declaration is set to New Line; done means the opening brace is aligned at the declaration's indentation level, matching the expected example.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.