Skip to content

MapperFeature.FIX_FIELD_NAME_UPPER_CASE_PREFIX does not work with Constructor parameters #5292

@cowtowncoder

Description

@cowtowncoder

(Discussed in #5289 )

Originally posted by @bananayong August 31, 2025

Recently I read the cowtowncoder blog
First, thank you for releasing the most wanted features!

I thought that it would be possible to use FIX_FIELD_NAME_UPPER_CASE_PREFIX feature with ParameterNamesModule.
However, I ran some tests, and it didn't work.

    static class Apple {
        private final String iPhone;

        public Apple(String iPhone) {
            this.iPhone = iPhone;
        }

        public String getIPhone() {
            return iPhone;
        }

        @Override
        public String toString() {
            return "Apple{" +
                    "iPhone='" + iPhone + '\'' +
                    '}';
        }
    }

    public static void main(String[] args) throws JsonProcessingException {
        ObjectMapper mapper = JsonMapper.builder()
                .addModule(new ParameterNamesModule())
                .enable(MapperFeature.FIX_FIELD_NAME_UPPER_CASE_PREFIX)
                .build();
        Apple apple = new Apple("iPhone 15");
        String json = mapper.writeValueAsString(apple);
        System.out.println(json); // {"iPhone":"iPhone 15"}

        Apple result = mapper.readValue(json, Apple.class); // Error thrown
        System.out.println(result);
    }

It seems like the property name is determined by the constructor parameter and FIX_FIELD_NAME_UPPER_CASE_PREFIX feature is not applied. Is that intended? Or will it be improved in the next release?

Metadata

Metadata

Assignees

No one assigned

    Labels

    2.20Issues planned at 2.20 or laterhas-failing-testIndicates that there exists a test case (under `failing/`) to reproduce the issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions