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

Incremental compilation after failure issues when all classes are not removed #21644

Closed
asodja opened this issue Aug 24, 2022 · 0 comments
Closed
Assignees
Labels
a:feature A new functionality in:java-plugins java-library, java, java-base, java-platform, java-test-fixtures
Milestone

Comments

@asodja
Copy link
Member

asodja commented Aug 24, 2022

We got some reports from GE and also internally that after added incremental compilation after failure feature there are issues with Groovy incremental compilation. It would be good if we add an option to opt-out of this feature just in case. Or maybe even to opt-in for Groovy.

The report was, that when a super class is changed, then sometimes exception like is thrown:

Standard error from JVM:
    Terminating due to fatal error
    java.lang.NoClassDefFoundError: org/gradle/.../AppTest$__spock_feature_5_0_closure3

Note: original class name is censored since this is not public repo. Check a build scan https://e.grdev.net/s/omiun4on2i5jy to see the actual class name.

After some investigation we figured, that output directory contains wrong classes. It should contain these:

AppTest$__spock_feature_4_0_closure2.class
AppTest$__spock_feature_4_0_closure3$_closure15.class
AppTest$__spock_feature_4_0_closure3.class
AppTest$__spock_feature_4_1_closure4$_closure16.class
AppTest$__spock_feature_4_1_closure4.class
AppTest$__spock_feature_4_2_closure5.class
AppTest$__spock_feature_4_3_closure6.class
AppTest$__spock_feature_4_3_closure7.class
AppTest$__spock_feature_4_4_closure8.class
AppTest$__spock_feature_4_4_closure9$_closure17$_closure18.class
AppTest$__spock_feature_4_4_closure9$_closure17$_closure19.class
AppTest$__spock_feature_4_4_closure9$_closure17.class
AppTest$__spock_feature_4_4_closure9.class
AppTest$__spock_feature_4_5_closure10.class
AppTest$__spock_feature_4_5_closure11$_closure20$_closure21.class
AppTest$__spock_feature_4_5_closure11$_closure20$_closure22.class
AppTest$__spock_feature_4_5_closure11$_closure20.class
AppTest$__spock_feature_4_5_closure11.class
AppTest$__spock_feature_4_6_closure12.class
AppTest$__spock_feature_4_7_closure13.class
AppTest$__spock_feature_4_7_closure14.class
AppTest$_setup_closure1.class
AppTest.class

But it contained these:

AppTest$__spock_feature_4_1_closure4$_closure16.class
AppTest$__spock_feature_4_1_closure4.class
AppTest$__spock_feature_4_2_closure5.class
AppTest$__spock_feature_4_3_closure6.class
AppTest$__spock_feature_4_3_closure7.class
AppTest$__spock_feature_4_4_closure8.class
AppTest$__spock_feature_4_4_closure9$_closure17$_closure18.class
AppTest$__spock_feature_4_4_closure9$_closure17$_closure19.class
AppTest$__spock_feature_4_4_closure9$_closure17.class
AppTest$__spock_feature_4_4_closure9.class
AppTest$__spock_feature_4_5_closure10.class
AppTest$__spock_feature_4_5_closure11$_closure20$_closure21.class
AppTest$__spock_feature_4_5_closure11$_closure20$_closure22.class
AppTest$__spock_feature_4_5_closure11$_closure20.class
AppTest$__spock_feature_4_5_closure11.class
AppTest$__spock_feature_4_6_closure12.class
AppTest$__spock_feature_4_7_closure13.class
AppTest$__spock_feature_4_7_closure14.class
AppTest$__spock_feature_5_0_closure3$_closure15.class
AppTest$__spock_feature_5_1_closure4$_closure16.class
AppTest$__spock_feature_5_4_closure9$_closure17$_closure18.class
AppTest$__spock_feature_5_4_closure9$_closure17$_closure19.class
AppTest$__spock_feature_5_4_closure9$_closure17.class
AppTest$__spock_feature_5_5_closure11$_closure20$_closure21.class
AppTest$__spock_feature_5_5_closure11$_closure20$_closure22.class
AppTest$__spock_feature_5_5_closure11$_closure20.class
AppTest$_setup_closure1.class
AppTest.class

We suspect, that we don't clean all .class files that will be produced by the AppTest.groovy file before compilation. And since we don't delete some classes Groovy has them at compile time on the classpath, and that is why it creates new extra spock_feature_5_5 classes.

While I wasn't able to reproduce the original issue, I was able to reproduce that we don't clean all the classes for AppTest.groovy.

A simpler test case that shows that we don't clean all classes is:

file: A.java
class A {}
file: B.java
class B extends A {}
class C {} // this class is in the same file

If/when we change A, classes B and C will be recompiled since we will pass B.java to a compiler (B.class is a dependency of A.class, so we pass B.java to the compiler). But we won't delete origin C.class. So C.class will be on the classpath at the compile time.

@asodja asodja added a:feature A new functionality to-triage @execution in:java-plugins java-library, java, java-base, java-platform, java-test-fixtures and removed to-triage labels Aug 24, 2022
@asodja asodja added this to the 7.6 RC1 milestone Aug 24, 2022
@asodja asodja self-assigned this Aug 24, 2022
@asodja asodja changed the title Add flag to opt-out of incremental compilation after failure Incremental compilation after failure issues when all classes are not removed Sep 10, 2022
bot-gradle added a commit that referenced this issue Sep 15, 2022
… to a compiler

Also add a flag to opt-out of incremental compilation after failure.

Main changes:
- code that cleans additional classes in [AbstractRecompilationSpecProvider.java](https://github.com/gradle/gradle/pull/21878/files#diff-8c264c92bbb9030e5b74a3b39a56f077a72ac91d98b7bcdf005de11577ccf6ac)
- code that disables inc. compilation after a failure in [CompileTransaction.java](https://github.com/gradle/gradle/pull/21878/files#diff-9f9ba0cbef3a27aa83d8f3c7f093758db09a3a0d395d88056a5773e43dce0b72). (it's enough that we just don't revert files on exception).

Fixes #21644

Co-authored-by: Stefan Wolf <wolf@gradle.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:feature A new functionality in:java-plugins java-library, java, java-base, java-platform, java-test-fixtures
Projects
None yet
Development

No branches or pull requests

1 participant