Skip to content

Fixes SYSTEM_EOL warnings#4412

Merged
jlerbsc merged 4 commits intojavaparser:masterfrom
matthieu-vergne:fix_EOL_warnings
May 5, 2024
Merged

Fixes SYSTEM_EOL warnings#4412
jlerbsc merged 4 commits intojavaparser:masterfrom
matthieu-vergne:fix_EOL_warnings

Conversation

@matthieu-vergne
Copy link
Copy Markdown
Contributor

@matthieu-vergne matthieu-vergne commented May 4, 2024

The first commit fixes the warnings themselves.
The next commit replaces a runtime check by a compile time check to solve an issue discovered while fixing the warnings (see commit description for details).
The last two commits remove the SYSTEM_EOL and EOL deprecated constants, since they are not used anymore.

If the constants should remain there for retrocompatibility, you can ignore the two last commits. I would however suggest to explicitly mention in their Javadoc that they should be removed in the future (preferably by telling the target version for removal, like the next major version or any precise reference).

Currently, any value can be provided at compile time, including
incompatible ones. A compatibility check is then executed at runtime on
line 111.

By using generics on the constructor, we ask the compiler to do this
check for us. Consequently, the check is done immediately (compile time)
and the runtime check of line 111 becomes irrelevant.

For example, in the previous commit, while replacing the
END_OF_LINE_CHARACTER value from SYTEM_EOL (String) to
LineSeparator.SYSTEM (LineSeparator), the type incompatibility was only
spotted upon running the tests (which massively exploded), making me fix
it by using LineSeparator.SYSTEM.asRawString() (String). Now we know the
discrepancy immediately from the compiler, before to run any test.
@jlerbsc
Copy link
Copy Markdown
Collaborator

jlerbsc commented May 5, 2024

That seems fine to me. Thanks for this PR.

@jlerbsc jlerbsc added this to the next release milestone May 5, 2024
@jlerbsc jlerbsc added the PR: Changed A PR that changes implementation without changing behaviour (e.g. performance) label May 5, 2024
@jlerbsc jlerbsc merged commit 3d17d7f into javaparser:master May 5, 2024
@matthieu-vergne matthieu-vergne deleted the fix_EOL_warnings branch May 5, 2024 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Changed A PR that changes implementation without changing behaviour (e.g. performance)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants