-
Notifications
You must be signed in to change notification settings - Fork 613
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 a lot of IDE warnings #6201
Conversation
Many related to unused fields
@@ -140,6 +142,7 @@ public void close() { | |||
if (m_choicesPublisher != null) { | |||
m_choicesPublisher.close(); | |||
} | |||
Reference.reachabilityFence(m_videoListener); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? What does it do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's what it does: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/ref/Reference.html#reachabilityFence(java.lang.Object)
I can't tell why it's needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does 2 things. One it gets rid of the warning, and 2 it stops the field from being GC'd. Unused fields are eligible for GC even if the class containing the field is still alive. Basically its a method to keep a field alive.
@@ -34,16 +34,16 @@ public class ADXL345_I2C implements NTSendable, AutoCloseable { | |||
private static final byte kDataFormatRegister = 0x31; | |||
private static final byte kDataRegister = 0x32; | |||
private static final double kGsPerLSB = 0.00390625; | |||
private static final byte kPowerCtl_Link = 0x20; | |||
private static final byte kPowerCtl_AutoSleep = 0x10; | |||
// private static final byte kPowerCtl_Link = 0x20; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the advantage of commenting them out rather than suppressing the unused warning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little bit cleaner IMO. We still want them there incase they're needed in the future.
Many related to unused fields