-
Notifications
You must be signed in to change notification settings - Fork 578
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
[3.1.2] DLS_DEAD_LOCAL_STORE false-positive (regression) #571
Comments
Can you post a full example, where ++ is used? |
Well, I guess this would be enough: void foo(Reference<Integer> reference) { reference.value++; } |
You guess or does it produce the false positive? |
It does. |
Can you provide a full, self contained example? I've tried a simple example without issues:
|
The (almost) exact same example gives the warning for me: package a;
public class Foo {
void foo(Reference<Integer> reference) {
reference.value++;
}
}
final class Reference<T> {
public T value;
public Reference(T value) {
this.value = value;
}
} I've just put them in a single file. I'm not sure how to help more. Adding a new file |
Still can't reproduce :-( |
Not using Eclipse, no:
P.S. I'm also using the ErrorProne Gradle plugin, not sure if it matters. |
I can reproduce now with Oracle javac. It seem to generate some real garbage at the end of the method, see:
What should those operations after putfield do?!?:
Here is what Eclipse compiler generates for the same code:
So it looks like you've found a bug in javac. This bug was uncovered by commit ef14b65 for issue #516. I haven't checked oracle bug database yet, but this bytecode looks really buggy (or way to complex), compared with the ecj version it needs 3 (!) local variables more and does many unneeded things. |
BTW changing the |
I enjoy and appreciate the fact that you're actually reading the bytecode generated by javac. :) Which compiler are you checking against for comparison (apart from Eclipse)? P,S. And are you going to raise a bug in JDK? |
Looks like they use some bytecode generator which generates something like:
And the left over bytecode is just pure nonsense which loads var2 on stack again and immediately discards the load again:
P.S. |
We have a
Reference<T>
class like:Having an instance of
Reference<Integer>
and doing areference.value++
gives aDLS_DEAD_LOCAL_STORE
which is wrong. Didn't happen before3.1.2
.The text was updated successfully, but these errors were encountered: