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

Remove compiler support for JLS source/target < 1.8 #2551

Merged
merged 4 commits into from
Jul 24, 2024

Conversation

iloveeclipse
Copy link
Member

@iloveeclipse iloveeclipse commented Jun 11, 2024

This is a draft, many tests have to be removed or updated as they test compliance with non supported JLS versions.

I've tried to keep all tests enabled under 1.8 (which I could understand so far) even if they were marked for older version.

Fixes #2536

TODO's

See #2761

@iloveeclipse
Copy link
Member Author

@stephan-herrmann, @srikanth-sankaran, @mpalat, @jarthana : please check this PR, even if it is a draft, because I want know if the approach taken makes sense for you or you see much easier / better way to obsolete older versions support.

Note that many tests are failing because they test something valid for Java < 1.8 only. I will check them and disable some I'm sure are, for the rest I will probably need your help.

But first check if the direction is the right one.

@srikanth-sankaran
Copy link
Contributor

But first check if the direction is the right one.

I quickly glanced through and the over all approach looks OK, tomorrow I will actually replicate the PR locally and play around with it and share feedback

@iloveeclipse
Copy link
Member Author

My idea is to "cut" old versions in compiler level first (I left the version constants there, only removed from tests), so do a "small enough" change now and look at the bigger cleanup in the second (third etc) steps, cleaning up both code in compiler and JDT core, and also upwards in JDT UI and PDE (which tests currently even reuse some removed constants from JDT tests).

At any time my aim is to have no failing tests of course, which would mean that some (obsoleted) tests could be still present if they run fine on Java 8+ and some still useful tests might be disabled temporarily till it is clear whether they should be properly fixed or removed.

Feel free to push any change to the branch here if you see a need for that.

@jarthana
Copy link
Member

@stephan-herrmann, @srikanth-sankaran, @mpalat, @jarthana : please check this PR, even if it is a draft, because I want know if the approach taken makes sense for you or you see much easier / better way to obsolete older versions support.

Note that many tests are failing because they test something valid for Java < 1.8 only. I will check them and disable some I'm sure are, for the rest I will probably need your help.

I don't mean to add more work, but it will be nice if we can identify all such tests and move them to separate suites so that they can be disabled altogether. If anyone interested, they can always test just those suites for < 1.8.

@iloveeclipse
Copy link
Member Author

I don't mean to add more work, but it will be nice if we can identify all such tests and move them to separate suites so that they can be disabled altogether. If anyone interested, they can always test just those suites for < 1.8.

With the changes here merged, there will be no more possibility to test with Java < 1.8, compiler will simply reject anything below 8.

@srikanth-sankaran
Copy link
Contributor

With the changes here merged, there will be no more possibility to test with Java < 1.8, compiler will simply reject anything below 8.

+1

IMHO we will be serving no one by leaving in half baked unmaintained, half tested support for ancient versions.

@stephan-herrmann
Copy link
Contributor

Sorry, I can't find the time to give valuable input right now, but I can at least try to play smart-ass: commit comment keeps saying "Test adoption" but I don't think you want to adopt any tests. Is "adaptation" what you are doing? ;-P

@iloveeclipse iloveeclipse force-pushed the issue_2536 branch 3 times, most recently from bd36976 to 9b9de5e Compare June 24, 2024 10:03
@iloveeclipse
Copy link
Member Author

@laeubi : could it be, that this block is executed in a random order, or order not related to the definition order in the pom.xml if tests run in tycho:

<includes>
<include>org/eclipse/jdt/core/tests/model/AllJavaModelTestsTracing.class</include>
<include>org/eclipse/jdt/core/tests/dom/RunAllTestsTracing.class</include>
<include>org/eclipse/jdt/core/tests/RunFormatterTests.class</include>
</includes>

I assume that the CompletionTests failures I see in Jenkins depend on some previous testsuite that messes up with the environment (JavaOptions and the like), because I can't reproduce the fails locally.
I've tried to change order, but it seem to have no effect, AllJavaModelTestsTracing seem to be always executed after RunAllTestsTracing.

@iloveeclipse iloveeclipse force-pushed the issue_2536 branch 2 times, most recently from 28819e2 to 5709a3b Compare June 24, 2024 17:12
@iloveeclipse
Copy link
Member Author

OK, not running RunFormatterTests seem to cause lot of test fails (~2000) , which mean, many other model tests are not self-contained and require something that is set by RunFormatterTests in the environment...
See https://ci.eclipse.org/jdt/job/eclipse.jdt.core-Github/job/PR-2551/21/display/redirect .

Still, CompletionTests fail. So next attempt is to disable everything except AllJavaModelTestsTracing...

@iloveeclipse
Copy link
Member Author

🤞 I'll be near a radio tomorrow to hear the news when this explodes 😎

OK, so let the fun begin.

Build failed because we have bundles in the SDK that are still compiled against 1.6 :-(

https://ci.eclipse.org/releng/job/Builds/job/I-build-4.33/80/console

@iloveeclipse
Copy link
Member Author

@jarthana
Copy link
Member

  * using source from project `Converter`, `Converter15`, however, selects the AST level from the project.
    @srikanth-sankaran , @jarthana  does it make any sense have such tests here? Shouldn't tests always sit in a test class corresponding to the used `Converter*` project, e.g., `ASTConverterAST3Test`?

Yes, ideally. I have seen similar issues in many other places. We load projects from everywhere for convenience and set compliance or api level as required. and that's why we often run into issues in this area, for e.g. #2743

@laeubi
Copy link
Contributor

laeubi commented Jul 25, 2024

🤞 I'll be near a radio tomorrow to hear the news when this explodes 😎

OK, so let the fun begin.

Build failed because we have bundles in the SDK that are still compiled against 1.6 :-(

https://ci.eclipse.org/releng/job/Builds/job/I-build-4.33/80/console

What I'm wondering:
Could it maybe just be made that ECJ emits a WARNING (or even ERROR) but do not abort compilation and simply choose the lowest supported java level?

This would maybe also allow a quickfix to update the project settings in the IDE and CI builds will make the user aware but do not require to change the settings immediately.

@iloveeclipse
Copy link
Member Author

Could it maybe just be made that ECJ emits a WARNING (or even ERROR) but do not abort compilation and simply choose the lowest supported java level?

In theory (with unlimited man power available) yes. Contributions are welcome.

@laeubi
Copy link
Contributor

laeubi commented Jul 25, 2024

In theory (with unlimited man power available) yes. Contributions are welcome.

I just guessed from the error message

CompilerException: target level should be in '1.8','9'...'22' (or '8.0'..'22.0'): 1.6

that

  1. we know the minimum (=1.8)
  2. know the current value (=1.6)

and I didn't know that replacing an

if (x < y) {
 throw error
}

with

if (x < y) {
 log (error)
 x = y
}

requires "unlimited man power" but it seems the compiler code is more complex than I assumed here...

@iloveeclipse
Copy link
Member Author

@laeubi: please if you really want some feature to be implemented, create a ticket and find someone who has either free time or money to work on whatever you want. I personally have neither interest, nor free time or money to work on the requested feature. Maybe someone else has, it is open source project.

@laeubi
Copy link
Contributor

laeubi commented Jul 25, 2024

It was just a suggestion that seems easy to implement (for someone who is already deep inside the topic) to help users of ECJ/JDT in the transition phase especially as it already has shown to require additional efforts for platform itself.

But if it is not a priority of the project its fine, anyways it is exaggerated to claim every suggestion requires "unlimited man power" where it was actually meant as "I don't find it useful or plan to work on this".

@jarthana
Copy link
Member

requires "unlimited man power" but it seems the compiler code is more complex than I assumed here...

It probably is. This particular issue is proving to be much more complex and time consuming that I imagined. Not that anyone thought it was going to be easy. So, I guess it is easier to get this to a decent stage and let us look at everything around a little later. You can already see Andrey has listed quite a few items for the next iteration.

@iloveeclipse iloveeclipse deleted the issue_2536 branch July 25, 2024 13:29
iloveeclipse added a commit to iloveeclipse/eclipse.jdt.core that referenced this pull request Sep 5, 2024
Found during the review of eclipse-jdt#2551

- CompilerOptions.originalComplianceLevel is obsoleted and can be
removed + code in TypeConverter using it should be cleaned up.
- CompilerOptions.originalSourceLevel is obsoleted and can be removed +
code in JDT that uses it should be cleaned up

Fixes eclipse-jdt#2760
srikanth-sankaran pushed a commit to iloveeclipse/eclipse.jdt.core that referenced this pull request Sep 24, 2024
Found during the review of eclipse-jdt#2551

- CompilerOptions.originalComplianceLevel is obsoleted and can be
removed + code in TypeConverter using it should be cleaned up.
- CompilerOptions.originalSourceLevel is obsoleted and can be removed +
code in JDT that uses it should be cleaned up

Fixes eclipse-jdt#2760
srikanth-sankaran added a commit that referenced this pull request Sep 24, 2024
* Remove obsoleted code in CompilerOptions

Found during the review of #2551

- CompilerOptions.originalComplianceLevel is obsoleted and can be
removed + code in TypeConverter using it should be cleaned up.
- CompilerOptions.originalSourceLevel is obsoleted and can be removed +
code in JDT that uses it should be cleaned up

Fixes #2760

* Additional commit to address test failures

---------

Co-authored-by: Srikanth Sankaran <[email protected]>
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 this pull request may close these issues.

Drop support of older Java releases in ecj
6 participants