@FieldNameConstants incompatible with Java25 ?

5 views
Skip to first unread message

Dominik Hirt

unread,
Oct 17, 2025, 8:03:49 PM (3 days ago) Oct 17
to Project Lombok
Hi,
I use @FieldNameConstants in order to made enum values available for @RolesAllowed in Spring Boot apps.
After migrating to from Java21 to Java25 there are compile errors complaining about the use of those annotations:

Symbol not found
8516 [ERROR]   Symbol: Variable Fields

'Fields' is the variable provided by Lombok.

This is the enum class:

@FieldNameConstants(onlyExplicitlyIncluded = true)
public enum Roles {
    @FieldNameConstants.Include AL_SB, 
    @FieldNameConstants.Include AL_WW
}

This is how I use the generated constants fields:

@RolesAllowed({Roles.Fields.AL_SB, Roles.Fields.AL_WW})

I have already tried to define the used inner field name (default 'Fields') explicitely:

@FieldNameConstants(onlyExplicitlyIncluded = true, innerTypeName = "Fields")

without success.

Is this i known problem ?

Furthermore its strange the the compile error only occure on the commandline using mvn compile by using the Java25 set by sdk (MacOS with zsh).
The VSCode project compiles without an error but I'm not sure, whether VSCode really use  Java25 ?

Kind regards
Dominik

Reinier Zwitserloot

unread,
Oct 17, 2025, 8:06:11 PM (3 days ago) Oct 17
to Project Lombok
VSCode uses eclipse internally. Which means a completely different code path in lombok vs using `javac`.

But, does lombok work _at all_ in your setup, or is it just `@FieldNameConstants` that doesn't work?

Since java.. 20-something you must explicitly enable your annotation processors (easiest way: `-proc:full`) - if you forget that, lombok doesn't run and there's nothing we can do about that, unfortunately.

Simplify the problem down:

* Try just `@Getter` in a minimal project.
* If that works, move on to using `@FNC` and then simply throwing one of the constants in a `System.out` to check if that works.

and so forth.

Dominik Hirt

unread,
Oct 18, 2025, 12:31:47 PM (2 days ago) Oct 18
to Project Lombok
Hi,

thank you for your response.
Indeed, the reason was the missing maven plugin enabling those annotation processor as described in https://projectlombok.org/setup/maven

So, now it works.
Reply all
Reply to author
Forward
0 new messages