Community
Participate
Working Groups
Build Identifier: M20090917-0800 // this is actually the Float and Double implementation of their static method // isNaN() boolean isNaN(final float num){ return (num != num); } // It is unclear what @SuppressWarning can be used on the method to suppress // this. // In most cases the warning is correct and testing for a NaN is not // intended. // It would be a shame to get rid of this useful warning just because formally // it is incorrect but a clear SuppressWarning QuickFix would be extremely // useful. Reproducible: Always Steps to Reproduce: Trivial.
I would have thought the fix for bug#281776 should have taken care of this ? Will investigate.
(In reply to comment #2) > ... the fix for bug#281776 ... Missed that one in my pre-submit search. Sorry. My Eclipse is still emitting the warning for both float and double.
Version: 3.6.0 Build id: I20100129-1300 with the binary above, on a clean workspace with a small project with just the class below: public class Clazz { boolean isNaN(final float num){ return (num != num); } boolean isNaN(final double num){ return (num != num); } boolean isNaN(final int num){ return (num != num); } } I see the warning for the int version and not for the other two. Could you confirm the build id : Help + About Eclipse If the problem persists, anything special that you can think of about your situation that could be contributing to it ? If you clean and rebuild, do you still get it ? Do you get it on a small test case etc. If possible try with the above version too (3.6M5)
Hello Amos, I am able to get the warnings with this test case: public class Clazz { boolean isNaN(Float num) { // change to float - warning goes away return (num != num); } boolean isNaN(final Double num) { // change to double - warning goes away return (num != num); } } Is this what you could be seeing ? i.e for the primitive types (float, double) the fix for bug#281776 addressed the problem while for the boxed types (Float, Double) the issue is still there ?
Created attachment 158586 [details] Patch under consideration
Olivier, by code inspection I concluded that this is the only scenario under which we would issue the warning for the NaN checking idiom. Let me know if you catch some cases that I have overlooked.
(In reply to comment #4) > Is this what you could be seeing ? i.e for the primitive types > (float, double) the fix for bug#281776 addressed the problem > while for the boxed types (Float, Double) the issue is still > there ? Boxed types are objects. So I think the warning in this case is legitimate. There is no unboxing done when comparing two boxed types. Did I miss something ? (In reply to comment #2) > Missed that one in my pre-submit search. Sorry. > My Eclipse is still emitting the warning for both float and double. It makes sense that it does since you are not using a version >= 3.6M1. This fix has not been backported to 3.5.1. I would close as a dup of bug 281776.
(In reply to comment #7) > (In reply to comment #4) > > Is this what you could be seeing ? i.e for the primitive types > > (float, double) the fix for bug#281776 addressed the problem > > while for the boxed types (Float, Double) the issue is still > > there ? > Boxed types are objects. So I think the warning in this case is legitimate. > There is no unboxing done when comparing two boxed types. > Did I miss something ? Oops. No, You are right of course. The warning is legit and the "fix" is so not. > (In reply to comment #2) > > Missed that one in my pre-submit search. Sorry. > > My Eclipse is still emitting the warning for both float and double. > It makes sense that it does since you are not using a version >= 3.6M1. > > This fix has not been backported to 3.5.1. I went by the date of the build id being later than the date of 3.6M1 and the Version field of the bug being (erroneously) set to 3.6. (I realize now that that the M prefix indicates a maintenance build on 3.5.x stream and not a milestone build on 3.6.x as I imagined) Sorry this wasted everyone's time. *** This bug has been marked as a duplicate of bug 281776 ***
Verified for 3.6M6 using build I20100305-1011.