Feature - Implemented Generic Types Warning Cleanup: utilities package in src (patch)

Number 2 of a series of patches to clean up generic type-related warnings.

This one focuses on the net.sourceforge.kolmafia.utilities package exclusively. That package now has 0 generic type warnings (post-patch)!

There are still warnings about serializable classes, but I ignored those.
 

roippi

Developer
Looks pretty good, I see you hit the formatter on a couple of files, which is fine.

Any reason for:

Code:
Index: src/net/sourceforge/kolmafia/utilities/InputFieldUtilities.java
===================================================================
--- src/net/sourceforge/kolmafia/utilities/InputFieldUtilities.java    (revision 11494)
+++ src/net/sourceforge/kolmafia/utilities/InputFieldUtilities.java    (working copy)
@@ -79,7 +79,7 @@
         if ( StaticEntity.isHeadless() )
         {
             RequestLogger.printLine( message );
-            String reply = KoLmafiaCLI.DEFAULT_SHELL.getNextLine( "Press enter to continue..." );
+            //String reply = KoLmafiaCLI.DEFAULT_SHELL.getNextLine( "Press enter to continue..." );
 
             return;

?
 

roippi

Developer
KoLmafiaCLI.DEFAULT_SHELL.getNextLine() still causes a pause for input, which is the point of that line of code. The proper thing would be to just remove the variable assignment.
 
I'll gladly submit an updated patch... or just forget about it for now since KoLmafia's been updated since then, and my original patch is probably no longer valid. :S
 

roippi

Developer
It's okay, I can still apply it with various svn tools.

I'll commit it when I get some free time.
 

roippi

Developer
r11497, with some alterations/additions.

One didactic point, for any budding java developers who are coding things in a post-generics environment. This is a no-no:

Code:
public class RollingLinkedList<Object>
    extends LinkedList<Object>

instead, do:

Code:
public class RollingLinkedList
    extends LinkedList<Object>

The reason is a phenomenon called name shadowing. In the latter example, your class is already explicitly extending a class that uses java.lang.Object. In the former, you're actually defining a private inner type called Object that "shadows" java.lang.Object in that namespace. It turns out that it compiles and runs fine, but you're doing some sketchy stuff that could get you into trouble down the line.

more reading

I think the warning for name shadowing may be off in Eclipse by default, I'd recommend turning it on.
 
Top