Thanks to some suggestions by Allan Caplan, I'm working on some PMD rules to aid in migrating from one JDK version to another. So far I've only got a few simple ones, like ReplaceVectorWithList and ReplaceHashtableWithMap, but there are certainly more to add:
- assert used as an identifier (in the migrating_to_14 ruleset)
- enum used as an identifier (migrating_to_15)
- better way to create Integers - already written by Allan here (migrating_to_15)
- Use new for loop style rather than old style (migrating_to_15)
- Suggest using built in JDK facilities - logging, regex - when third party libs like Log4J or Oro are detected
- Maybe something about deprecated features?
I've been looking around for more migration rules and came across this post by Attila Szegedi to the DevelopMentor advanced-java list. The replies mostly involve things that might be hard for PMD to track down - like problems with Swing tabbing and whatnot - but we'll see if any rules can come out of that.
It'd be especially nice to be able to suggest performance improvements - i.e., "use this new API because it's much faster than the old clunky way". ReplaceHashtableWithMap may fall into that category since it's suggesting that a synchronized collection usage be replaced with a non-synchronized one.... surely there are others.
Anyone have suggestions for rules to ease migration from one JDK version to another? Let me know, thanks!