##### Overview

- Download PMD 3.9
- What's new in PMD 3.9
- PMD in the news
- PMD-related products and books
- Best practices
- Future directions
- Similar projects
- Credits
- License
- What does 'PMD' mean?

##### Usage

- Installation
- Command line usage
- Ant task usage
- Maven plugin usage
- IDE plugin usage
- Suppressing warnings
- Finding duplicated code
- JSP support

##### Customizing PMD

- Compiling PMD
- How to write a rule
- Writing XPath rules
- How to make a rule set
- How it works

##### For example

- Run PMD on a Sourceforge project

##### Rule Sets

- Index
- Basic
- Braces
- Code Size
- Clone
- Controversial
- Coupling
- Design
- Finalizers
- Import Statements
- J2EE
- Javabeans
- JUnit Tests
- Logging (Java)
- Logging (Jakarta)
- Migrating
- Naming
- Optimizations
- Strict Exceptions
- Strings
- Sun Security
- Unused Code
- Java Server Pages
- Java Server Faces

##### Project Documentation

- About PMD
- Project Info
- Project Reports
- Development Process

## Migration Rules

Contains rules about migrating from one JDK version to another. Don't use these rules directly, rather, use a wrapper ruleset such as migrating_to_13.xml.

### ReplaceVectorWithList

Consider replacing Vector usages with the newer java.util.ArrayList if expensive threadsafe operation is not required.

This rule is defined by the following XPath expression:

    //Type/ReferenceType/ClassOrInterfaceType[@Image='Vector']

Here's an example of code that would trigger this rule:

    public class Foo {
     void bar() {
        Vector v = new Vector();
     }
    }

### ReplaceHashtableWithMap

Consider replacing this Hashtable with the newer java.util.Map

This rule is defined by the following XPath expression:

    //Type/ReferenceType/ClassOrInterfaceType[@Image='Hashtable']

Here's an example of code that would trigger this rule:

        public class Foo {
         void bar() {
            Hashtable h = new Hashtable();
         }
        }

### ReplaceEnumerationWithIterator

Consider replacing this Enumeration with the newer java.util.Iterator

This rule is defined by the following XPath expression:

    //ImplementsList/ClassOrInterfaceType[@Image='Enumeration']

Here's an example of code that would trigger this rule:

    public class Foo implements Enumeration {
        private int x = 42;
        public boolean hasMoreElements() {
            return true;
        }
        public Object nextElement() {
            return String.valueOf(i++);
        }
    }

### AvoidEnumAsIdentifier

Finds all places 'enum' is used as an identifier is used.

This rule is defined by the following XPath expression:

    //VariableDeclaratorId[@Image='enum']

Here's an example of code that would trigger this rule:

        public class A {
            public  class foo {
                String enum = "foo";
            }
        }

### AvoidAssertAsIdentifier

Finds all places 'assert' is used as an identifier is used.

This rule is defined by the following XPath expression:

    //VariableDeclaratorId[@Image='assert']

Here's an example of code that would trigger this rule:

        public class A {
            public  class foo {
                String assert = "foo";
            }
        }

### IntegerInstantiation

In JDK 1.5, calling new Integer() causes memory allocation. Integer.valueOf() is more memory friendly.

This rule is defined by the following XPath expression:

    //PrimaryPrefix
     /AllocationExpression
      [not (ArrayDimsAndInits)
       and (ClassOrInterfaceType/@Image='Integer'
        or ClassOrInterfaceType/@Image='java.lang.Integer')]

Here's an example of code that would trigger this rule:

    public class Foo {
     private Integer i = new Integer(0); // change to Integer i = Integer.valueOf(0);
    }