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 with literals in 3.4 #1474
Comments
Thanks @izeye |
Actually it seems we don't have the problem. Even if Java inlines the constant, class A is still visible in the constant pool table. I made a simple test, and changing the constant value in
|
I'm not sure why, but it doesn't appear to be that simple (maybe it depends on the compiler version). The test case linked above fails. |
As of JDK-7153958, which was included in Java 8, javac includes a reference to the the constant field in the dependent class' constant pool. So, I think this bug seems to be valid for javac <7, and the constant tracking infrastructure seems unnecessary for javac >=8. |
It doesn't seem to be the case on all versions of Java 8, at least. I ran 8u91 and the test case still fails. Which is strange considering that it's supposed to be fixed in b68. |
So it's actually a combination of 2 bugs:
The latter is pretty serious. |
See #1476 |
This commit fixes #1474, by not relying on the analysis of literals (which still exists), but rather recompiling everything whenever we detect that a constant effectively changed in a class. This doesn't prevent us from using a smarter strategy later (say, using a compiler plugin). The commit also changes the hash that is used to store constants, so that the name of the constant is used. This prevents another bug which was that if a class has multiple variants of the same value, or that values of several constants are switched, we wouldn't detect the change.
This commit fixes #1474, by not relying on the analysis of literals (which still exists), but rather recompiling everything whenever we detect that a constant effectively changed in a class. This doesn't prevent us from using a smarter strategy later (say, using a compiler plugin). The commit also changes the hash that is used to store constants, so that the name of the constant is used. This prevents another bug which was that if a class has multiple variants of the same value, or that values of several constants are switched, we wouldn't detect the change.
Incremental Compilation, the Java Library Plugin, and other performance features in Gradle 3.4 said as follows:
To find the usage of a literal, using its old value doesn't work if it is used for calculation and the result is inlined.
This was originally asked on the blog: https://blog.gradle.org/incremental-compiler-avoidance#comment-3178668770
/cc @melix
The text was updated successfully, but these errors were encountered: