Skip to content

Avoid Java compiler errors around invoking unqualified methods called "yield" in generated decoders in Java 17 #910

Closed
@writeoncereadmany

Description

@writeoncereadmany

More recent versions of Java introduce errors when invoking unqualified methods called "yield". For example, in Java 17:

error: invalid use of a restricted identifier 'yield'
        final DecimalFloatDecoder yield = yield();
                                          ^
  (to invoke a method called yield, qualify the yield with a receiver or type name)

Our build process fails on warnings, and builds decoders written using the JavaGenerator.

Those decoders include a appendTo method, which has patterns like:

        final DecimalFloatDecoder yield = yield();
        if (yield != null)
        {
            yield.appendTo(builder);
        }

where the method names are based on the field names. When we have a field called yield - which we need, that's the domain concept, this yields (if you'll pardon the pun) this compiler error.

One simple fix is - if it were instead:

        final DecimalFloatDecoder yield = this.yield();
        if (yield != null)
        {
            yield.appendTo(builder);
        }

it would not raise the error.

I'll start by trying to create a unit test to reproduce the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions