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

Sort filename (if given) by name for consistent output #1922

Merged
merged 1 commit into from
Jan 31, 2024

Conversation

laeubi
Copy link
Contributor

@laeubi laeubi commented Jan 30, 2024

Currently the generation of lamdas can change depending on when the source file is processed.

What it does

This sorts the array of files (if given) to always have a predictable order independent of order given on the commandline / arguments.

Relates to #1921

How to test

Use this project:

See #1921 for detailed compiler arguments, logs and example class files showing the difference.

Author checklist

@iloveeclipse
Copy link
Member

Interesting, there are 34 test fails, some seem to be interesting like BatchCompilerTest

junit.framework.AssertionFailedError: missing file: /tmp/comptest/run.1706602408180/regression/bin1/X.class
	at junit.framework.Assert.fail(Assert.java:57)
	at junit.framework.Assert.assertTrue(Assert.java:22)
	at junit.framework.TestCase.assertTrue(TestCase.java:192)
	at org.eclipse.jdt.core.tests.compiler.regression.BatchCompilerTest.test097_per_source_output_directory(BatchCompilerTest.java:4537)

Some seem to rely on the input / error reporting order.

org.eclipse.jdt.core.tests.compiler.regression.BatchCompilerTest.test095_per_source_output_directory - 1.8
org.eclipse.jdt.core.tests.compiler.regression.BatchCompilerTest.test097_per_source_output_directory - 1.8
org.eclipse.jdt.core.tests.compiler.regression.BatchCompilerTest.test095_per_source_output_directory - 11
org.eclipse.jdt.core.tests.compiler.regression.BatchCompilerTest.test097_per_source_output_directory - 11
org.eclipse.jdt.core.tests.compiler.regression.BatchCompilerTest.test095_per_source_output_directory - 17
org.eclipse.jdt.core.tests.compiler.regression.BatchCompilerTest.test097_per_source_output_directory - 17
org.eclipse.jdt.core.tests.compiler.regression.BatchCompilerTest.test095_per_source_output_directory - 20
org.eclipse.jdt.core.tests.compiler.regression.BatchCompilerTest.test097_per_source_output_directory - 20
org.eclipse.jdt.core.tests.compiler.regression.BatchCompilerTest.test095_per_source_output_directory - 21
org.eclipse.jdt.core.tests.compiler.regression.BatchCompilerTest.test097_per_source_output_directory - 21
org.eclipse.jdt.core.tests.compiler.regression.ModuleCompilationTests.testAPILeakDetection5 - 11
org.eclipse.jdt.core.tests.compiler.regression.ModuleCompilationTests.testBug520858 - 11
org.eclipse.jdt.core.tests.compiler.regression.ModuleCompilationTests.testBug520858b - 11
org.eclipse.jdt.core.tests.compiler.regression.ModuleCompilationTests.testPackageConflict0 - 11
org.eclipse.jdt.core.tests.compiler.regression.ModuleCompilationTests.testPackageConflict1 - 11
org.eclipse.jdt.core.tests.compiler.regression.ModuleCompilationTests.testPackageTypeConflict1 - 11
org.eclipse.jdt.core.tests.compiler.regression.ModuleCompilationTests.testAPILeakDetection5 - 17
org.eclipse.jdt.core.tests.compiler.regression.ModuleCompilationTests.testBug520858 - 17
org.eclipse.jdt.core.tests.compiler.regression.ModuleCompilationTests.testBug520858b - 17
org.eclipse.jdt.core.tests.compiler.regression.ModuleCompilationTests.testPackageConflict0 - 17
org.eclipse.jdt.core.tests.compiler.regression.ModuleCompilationTests.testPackageConflict1 - 17
org.eclipse.jdt.core.tests.compiler.regression.ModuleCompilationTests.testPackageTypeConflict1 - 17
org.eclipse.jdt.core.tests.compiler.regression.ModuleCompilationTests.testAPILeakDetection5 - 20
org.eclipse.jdt.core.tests.compiler.regression.ModuleCompilationTests.testBug520858 - 20
org.eclipse.jdt.core.tests.compiler.regression.ModuleCompilationTests.testBug520858b - 20
org.eclipse.jdt.core.tests.compiler.regression.ModuleCompilationTests.testPackageConflict0 - 20
org.eclipse.jdt.core.tests.compiler.regression.ModuleCompilationTests.testPackageConflict1 - 20
org.eclipse.jdt.core.tests.compiler.regression.ModuleCompilationTests.testPackageTypeConflict1 - 20
org.eclipse.jdt.core.tests.compiler.regression.ModuleCompilationTests.testAPILeakDetection5 - 21
org.eclipse.jdt.core.tests.compiler.regression.ModuleCompilationTests.testBug520858 - 21
org.eclipse.jdt.core.tests.compiler.regression.ModuleCompilationTests.testBug520858b - 21
org.eclipse.jdt.core.tests.compiler.regression.ModuleCompilationTests.testPackageConflict0 - 21
org.eclipse.jdt.core.tests.compiler.regression.ModuleCompilationTests.testPackageConflict1 - 21
org.eclipse.jdt.core.tests.compiler.regression.ModuleCompilationTests.testPackageTypeConflict1 - 21

@laeubi
Copy link
Contributor Author

laeubi commented Jan 30, 2024

Yes the test seem to expect a certain order but I can't judge if/how test to be adjusted.

I applied a workaround to Tycho to simulate what this patch does and all tests (including aggregator build) succeed and order was always random so I'm quite confident it should be a valid one...

Copy link
Member

@iloveeclipse iloveeclipse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is "per output destination" feature, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=146554

Main.filenames & Main.destinationPaths should be in-sync, so change must be done not here but in configure()

@iloveeclipse
Copy link
Member

I applied a workaround to Tycho to simulate what this patch does

I would keep that in Tycho, as the patch here is incomplete and needs to be fixed.

@laeubi laeubi force-pushed the issu_1921_order_input_files branch from d69ce19 to d411905 Compare January 31, 2024 07:02
@laeubi
Copy link
Contributor Author

laeubi commented Jan 31, 2024

The problem is "per output destination" feature, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=146554

Main.filenames & Main.destinationPaths should be in-sync, so change must be done not here but in configure()

You are right, I also noticed that there are even public fields in this class so now I only sort the index here... another approach would be to do the ordering in the compiler itself I'll take a look at this as well.

@laeubi
Copy link
Contributor Author

laeubi commented Jan 31, 2024

This now seems to pass the testsuite and already shows some classes that are different in JDT, I have createad a PR here:

so get a better overview what would happen in the large (requires snapshot Tycho).

I would keep that in Tycho, as the patch here is incomplete and needs to be fixed.

I leave the decisions to you (or JDT team) if this change is useful so it can benefit everyone not only latest Tycho users...

Currently the generation of lamdas can change depending on when the
source file is processed.

This sorts the array of files (if given) to always have a predictable
order independent of order given on the commandline / arguments.

Relates to eclipse-jdt#1921
@laeubi laeubi force-pushed the issu_1921_order_input_files branch from d411905 to cf4727f Compare January 31, 2024 08:33
@iloveeclipse
Copy link
Member

if this change is useful so it can benefit everyone not only latest Tycho users.

What I've meant is: as long as patch here is incomplete and breaks ecj functionality, Tycho workaround has to be used.
If the patch is OK, we will for sure like to have it in the compiler, as stable compilation behavior is important for everyone.

@laeubi
Copy link
Contributor Author

laeubi commented Jan 31, 2024

If I where to fix it on the compiler level it seems worth to sort the CUs by name in the method org.eclipse.jdt.internal.compiler.Compiler.internalBeginToCompile(ICompilationUnit[], int) I'll prepare a PR for this to see if it gives similar results but that's beyond my understanding if compiler internals to judge what is a better approach.

@laeubi
Copy link
Contributor Author

laeubi commented Jan 31, 2024

This is done on the Compiler /CU level

@iloveeclipse iloveeclipse merged commit 4dca3bb into eclipse-jdt:master Jan 31, 2024
9 checks passed
@laeubi
Copy link
Contributor Author

laeubi commented Jan 31, 2024

Looking at the build results this has not produced any baseline problem eve though it would be expected it seems the change has had not the same effect as desired...

@iloveeclipse
Copy link
Member

Looking at the build results this has not produced any baseline problem eve though it would be expected it seems the change has had not the same effect as desired...

This change is needed to see new compiler used for SDK: eclipse-platform/eclipse.platform.releng.aggregator#1760

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.

2 participants