Get AccessAnalysis at SourceForge.net. Fast, secure and Free Open Source software downloads

AccessAnalysis

Measuring the Usage of Access Modifiers in Java

Installation

The following steps describe the installation of AccessAnalysis in Eclipse 3.5 (Galileo) to 3.7 (Indigo).

  1. Go to menu Help and choose item Install New Software...
  2. In the following dialog click on Add... in the upper right corner.
  3. Enter a name for the new repository and as location.
  4. Select feature AccessAnalysis and follow the next steps in the installation dialog.
Screenshot of installation step 2 and 3
Step 2 and 3
Screenshot of installation step 4
Step 4

User Guide

Analyze Java projects

Once you have installed the AccessAnalysis plug-in, you can analyze your Java projects by simply clicking right on them (e.g. in the Package Explorer) and choosing Analyze Access from the context menu. You can select one project or multiple projects and analyze them altogether.

After the analysis is finished, the AccessAnalysis View will come up and show the results in a tree-like table.

Screenshot of Analyze Access action in context menu
Analyze Access action in context menu

Results

The results of the analysis are shown in a table with five columns and structured in a tree with five levels. The levels of the tree represent the hierarchy of the source code units: projects, source folders, packages, types and methods. The columns of the table are:

  1. Element: The name of the source code unit.
  2. IGAT: The unit's IGAT value which is calculated as follows: IGAT = T* / T with
    • T* : Number of included types with actual access modifier more generous than the corresponding minimal access modifier
    • T : Total number of included types
    For types, only the type itself is considered, so IGAT can only be 1.00 or 0.00. Methods don't have an IGAT value.
  3. IGAM: The unit's IGAM value which is calculated as follows: IGAM = M* / M with
    • M* : Number of included methods with actual access modifier more generous than the corresponding minimal access modifier
    • M : Total number of included methods
    For methods, only the method itself is considered, so IGAM can only be 1.00 or 0.00.
  4. Minimal Access (types and methods only): The unit's minimal access modifier, which is the most restrictive access modifier that allows all existing usages of the particular type or member from inside all analyzed projects.
    Usage means any reference to the type or method that needs access rights.
    If a type or method is not used at all in the entire projects, the pseudo access modifier not used is assigned.
  5. Actual Access (types and methods only): The access modifier actually assigned to the unit in the source code. Higlighted red when deviating from minimal access.

In the results table, you can double-click on a type or method to jump to the corresponding code line.

Screenshot of Analysis results
Analysis results (here with comma as decimal point due to local system settings)

Preferences

Annotations Constraints

If you want the minimal access modifiers of some types or methods to be not more restrictive than a particular access modifier, you can set up exceptional rules by using annotations. Therefore you have configure the annotation types in the properties of the analyzed projects.

  1. Open the properties of your project and go to AccessAnalysis => Annotations.
  2. Here you can add new Annotation Constraints and edit or delete existing ones.
  3. For the configuration of an Annotation Constraint you have to choose
    • the annotation type,
    • if it applies to types, methods or both and
    • an access modifier of your choice.

In following analysis runs, the minimal access modifier of a type or method marked with an annotation of the configured type will be at least the chosen one.

JUnit Constraints

Classes and methods that are identified to be JUnit 3 or 4 tests get public as minimal access modifier according to requirements of the test frameworks.

You can disable these features in the project properties under AccessAnalysis => JUnit constraints.

Screenshot of Annotation Constraints preferences
Annotation Constraints preferences
Screenshot of JUnit Constraints preferences
JUnit Constraints preferences

Limitations