projectlombok / lombok

Very spicy additions to the Java programming language.
https://projectlombok.org/
Other
12.92k stars 2.4k forks source link

[BUG] @Data Incompatible with JDK 23 "variable method not initialized in the default constructor" #3776

Closed tisonkun closed 2 weeks ago

tisonkun commented 2 weeks ago

See https://github.com/apache/opendal/issues/5292, a full reproducible codebase.

It's basically:

package org.apache.opendal;

import java.util.Map;
import lombok.Data;

@Data
public class PresignedRequest {
    private final String method;
    private final String uri;
    private final Map<String, String> headers;
}

Failed to compile:

[ERROR] ...: Compilation failure: Compilation failure:
[ERROR] .../PresignedRequest.java:[30,26] variable method not initialized in the default constructor
[ERROR] .../PresignedRequest.java:[35,26] variable uri not initialized in the default constructor
[ERROR] .../PresignedRequest.java:[40,39] variable headers not initialized in the default constructor
[ERROR] -> [Help 1]
tisonkun commented 2 weeks ago

IIUC lombok should not have to generate a default constructor in this case at all?

tisonkun commented 2 weeks ago

No. It's about maven building. Not sure why it happens only with JDK23, though.

Fixed by https://github.com/apache/opendal/pull/5297.