Skip to content

Instantly share code, notes, and snippets.

@pmenke-de
Last active September 12, 2023 10:00
Show Gist options
  • Save pmenke-de/28d8793052f51cc1f6d16c09b6ced1c4 to your computer and use it in GitHub Desktop.
Save pmenke-de/28d8793052f51cc1f6d16c09b6ced1c4 to your computer and use it in GitHub Desktop.
Lombok @with record issue
package de.pmenke.test;
import lombok.With;
public class OuterClass<V> {
private InnerRecord rec;
@With
/* static */ record InnerRecord(int aComponent) {}
/* without `static` running `mvn clean install` results in
[ERROR] [...] Compilation failure:
[ERROR] ./src/main/java/de/pmenke/test/OuterClass.java:[9,41] non-static type variable V cannot be referenced from a static context
*/
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.pmenke</groupId>
<artifactId>lombok-static-record-issue</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.28</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment