Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
alivny opened this issue Dec 11, 2024 · 4 comments · Fixed by #340
Closed

Comments

@alivny
Copy link

alivny commented Dec 11, 2024

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

@gastaldi
Copy link
Member

Thanks for the report!

Roaster requires Java 17 because Eclipse JDT (the library it depends on) requires JDK 17, that's why we can't build Roaster with JDK 11.

I can have a look, but if you could provide the fix in a pull request (with a test demonstrating the bug) it would be easier

@gastaldi
Copy link
Member

The fix is now in 2.28.1.Final and 2.30.1.Final. Enjoy!

@alivny
Copy link
Author

alivny commented Dec 12, 2024

@gastaldi Thank you very much for the prompt fix and release. However, I encountered a couple of issues:

  1. Version 2.28.1.Final is incompatible with Java 11 as it fails during compilation, requiring JDK 17.
  2. I was unable to locate version 2.30.1.Final during my project build. Additionally, this version is absent from the following repository:
    https://artifact.intuit.com/artifactory/maven-proxy-new/org/jboss/forge/roaster/roaster-api/

@gastaldi
Copy link
Member

gastaldi commented Dec 12, 2024

@alivny thanks for your feedback. In fact Eclipse uses ranged versions, which makes it impossible to create reproducible builds. I've fixed that in 145d914 and released 2.28.3.Final.

Also 2.30.1.Final is now available, Maven central was unstable yesterday

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants