Skip to content

Bug in FieldImpl.getName() Method: Incorrect Handling of Multiple Variables in One Line #339

@alivny

Description

@alivny

We have encountered a bug in the getName() method of the FieldImpl class in the Roaster library version 2.28.0.Final. When multiple variable declarations are made on the same line (e.g., String a, b;), the method returns the name of the first variable (a) for both variables instead of returning the correct name (b) for the second variable.

steps to reproduce:

JavaType<?> javaType = Roaster.parse(MultipleFieldDeclarationDataObject);

if (javaType instanceof FieldHolderSource) {
FieldHolderSource fieldHolderSource = (FieldHolderSource) javaType;
fieldHolderSource.getFields().forEach(f -> System.out.println(f.getName()));
}

Environment:

Roaster Version: 2.28.0.Final
Java Version: 11 (Although we know newer versions support Java 17, we need a fix that remains compatible with Java 11)

This issue is urgent because it affects our application's core functionality in production. We ask for your quick attention.

Thanks in advance.

MultipleFieldDeclarationDataObject.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions