Skip to content

Constant referenced in annotation is not recognized as a constant value #4835

@s-albers

Description

@s-albers

Since Eclipse 2025-12 (JDT 3.20.400), I have a compile error with the following class:

package testing;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

import testing.Test.JsonProperties;

@JsonPropertyOrder({
	JsonProperties.CONSTANT_ONE,
	JsonProperties.CONSTANT_TWO,
})
public record Test(
    @JsonProperty(JsonProperties.CONSTANT_ONE) String attributeOne, // Error in this line
    @JsonProperty(JsonProperties.CONSTANT_TWO) String attributeTwo) {

	class JsonProperties {

		public static final String CONSTANT_ONE = "one";

		public static final String CONSTANT_TWO = "two";
	}
}

I have a dependency to com.fasterxml.jackson.core:jackson-annotations:2.20

In line 13, JsonProperties.CONSTANT_ONE is not recognized as a constant value.
The error message is: The value for annotation attribute JsonProperty.value must be a constant expression

With Eclipse 2025-09 (JDT 3.20.300), the exact same code works without error.
The OpenJDK 21 compiler can also compile this class.

Do you have any ideas, what's wrong here? Thank you very much!

Metadata

Metadata

Labels

bugSomething isn't workingcompilerEclipse Java Compiler (ecj) related issuesregressionSomething was broken by a previous change

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions