Jtest logo




Contents  Previous  Next  Index

OPT.MAF


Make accessor methods for instance fields "final"

Description

This rule flags non-"final" accessor methods for instance fields.

Accessor methods for instance fields should be made "final". This tells the compiler that the method cannot be overridden and thus can be inlined.

Example

 package OPT;
 
 class MAF {
     public void setSize (int size) {
          _size = size;
     }
     private int _size;

}

Repair

 class DAF_fixed {
     final public void setSize (int size) {
          _size = size;
     }
     private int _size;
 }

Reference

Warren, Nigel. and Bishop, Philip. Java in Practice. Addison-Wesley, 1999, pp 4-5.


Contents  Previous  Next  Index

ParaSoft logo
(888) 305-0041 info@parasoft.com Copyright © 1996-2001 ParaSoft