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

Using ECJ parser targetting newer -source version should emit a warning #3018

Closed
mickaelistria opened this issue Sep 26, 2024 · 5 comments · Fixed by #3020
Closed

Using ECJ parser targetting newer -source version should emit a warning #3018

mickaelistria opened this issue Sep 26, 2024 · 5 comments · Fixed by #3020
Labels
enhancement New feature or request

Comments

@mickaelistria
Copy link
Contributor

mickaelistria commented Sep 26, 2024

Currently, if I have a project setup with its options to target newer Java version (for example m2e might do it, and it's not too wrong if one has a project really targetting Java 24 already)

org.eclipse.jdt.core.compiler.codegen.targetPlatform=24
org.eclipse.jdt.core.compiler.compliance=24
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=24

then ECJ fail back to using latest, which is a good option. But it does it without showing any hint in the IDE, so the users may have wrong expectations of Java 24 being supported.
In such case, it would be helpful if ECJ would put a warning such as "Requested unsupported Java version 24, failing back to latest supported version (23)".

@mickaelistria
Copy link
Contributor Author

@iloveeclipse I see you recently added checks in the compiler for too old versions, I'm thinking of something similar (not aborting). But also, and maybe more importantly, I would like to have those checks on the Parser, so those errors can be seen when reconciling too (if builder is disabled).

@jukzi
Copy link
Contributor

jukzi commented Sep 26, 2024

mind to propose a PR at best with junit test?

@jukzi jukzi added the enhancement New feature or request label Sep 26, 2024
@mickaelistria
Copy link
Contributor Author

I'm trying; struggling with the many layers where the version is "fixed" silently instead of directly forwarded to the compiler to fix it ultimately.

@stephan-herrmann
Copy link
Contributor

the users may have wrong expectations of Java 24 being supported.

Small reminder: it's not our decision to support or not support Java 24, which simply doesn't exist until 2025/03/18.

This should be reflected in whatever warnings will be added here.

@mickaelistria
Copy link
Contributor Author

I don't really mind about the actual message, supported/available/implemented/present... they're all the same to me in this context.
But we're not there yet; currently the big issue I face is that the CompilerOptions will always "fix" the versions so they're in the range of what's supported by ECJ, even if the project options say otherwise. I would like to try changing that and having the "fix" part of ECJ instead of project options->CompilerOptions conversions. And this is made even more difficult by the fact that the compiler uses the ClassFile levels instead of the source versions internally....
My current idea is that we keep in the CompilerOptions the "raw" project settings (eg initialRequestedSourceVersion), even if they don't directly match ECJ capabilities, and have ECJ also validating/warning about those "raw"settings, so we don't change the existing implementation.

mickaelistria added a commit to mickaelistria/eclipse.jdt.core that referenced this issue Sep 26, 2024
mickaelistria added a commit to mickaelistria/eclipse.jdt.core that referenced this issue Sep 26, 2024
mickaelistria added a commit to mickaelistria/eclipse.jdt.core that referenced this issue Sep 26, 2024
mickaelistria added a commit to mickaelistria/eclipse.jdt.core that referenced this issue Sep 27, 2024
mickaelistria added a commit to mickaelistria/eclipse.jdt.core that referenced this issue Sep 27, 2024
mickaelistria added a commit to mickaelistria/eclipse.jdt.core that referenced this issue Sep 27, 2024
mickaelistria added a commit to mickaelistria/eclipse.jdt.core that referenced this issue Oct 8, 2024
mickaelistria added a commit to mickaelistria/eclipse.jdt.core that referenced this issue Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants