3 ms·
Some time ago my Java app stopped showing notifications. I looked at the code and discovered that I accidentally posted URL before the line that shows notificat
by dvh 9y ago
Some time ago my Java app stopped showing notifications. I looked at the code and discovered that I accidentally posted URL before the line that shows notifications:
http://example.com/ http://example.com/ showNotification();
It compiled without problem because http: is label and // commented out the rest of the line:)
- _pmf_ 9y agoIf had a similar issue (in C) that took me at least an hour to find: switch (whatever) { E_START: // code break; E_PAUSE: // code break; E_END: // code break; } i.e. accidentally using labels instead of "case E_START:". GCC at least had the decency of generating a warning about unused labels, while I suppose `javac` does no such thing.
- astura 9y agoJust tested in my Eclipse project This mistake (unsurprisingly) isn't possible in Java: "Syntax error on token "{", case expected after this token" With an unused label I get the warning "The label E_START is never explicitly referenced" A good software process prevents these types of errors. You shouldn't have any warning in your project at all, and if you see one you'll know to check it out. You should use @SuppressWarnings for any warnings you have reviewed and have determined are not errors. Your IDE should mark warnings clearly at the project level, the file, and the offending line. They also should have an overall list of warnings (and errors) and you should go through them before building a release.
- kwhitefoot 9y agoI rather like the JPL rules which say that code MUST compile with NO warnings even if the warning is wrong. See rule 2 in https://lars-lab.jpl.nasa.gov/JPL_Coding_Standard_C.pdf https://lars-lab.jpl.nasa.gov/JPL_Coding_Standard_C.pdf.